1
0
Fork 0
forked from fte/fteqw

fix demo menu with system paths.

tweak some dp compatibility things. probably futile.
moved ode to a plugin.
added screenshot_mega command to take massive screenshots that are not tied to current video mode.
removed offscreen-gecko code completely.
added cvars to rescale offsetmapping from paletted sources, so it can be disabled where its ugly.
added support for zip weak encryption. the password defaults to 'thisispublic'. nothing is fool-proof.
gl: fix stereoscopic rendering.
gl: fix rendertargets with depth.
qc: added support for named builtins that do not have any specific number.
qc: added some new builtins. drawrotpic, drawtextfield, search_getfilemtime, and a few others.
qc: PF_Fixme now attempts to figure out which builtin you tried to call, for more friendly fatal error messages.
qccgui: stepover and stepout are now implemented, as is setnextstatement.
qccgui: added a way to annotate code with the asm statements generated from them.
qccgui: fixed double-clicking a src file.
qccgui: handles multiple .src files more usefully.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4832 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2015-02-02 08:01:53 +00:00
parent d90095f511
commit 911f98ffaa
127 changed files with 7384 additions and 3629 deletions

View file

@ -28,8 +28,9 @@ int demoframe;
int cls_lastto;
int cls_lasttype;
void CL_PlayDemo(char *demoname);
void CL_PlayDemo(char *demoname, qboolean usesystempath);
char lastdemoname[256];
static qboolean lastdemowassystempath;
extern cvar_t qtvcl_forceversion1;
extern cvar_t qtvcl_eztvextensions;
@ -414,7 +415,7 @@ void CL_DemoJump_f(void)
else
{
Con_Printf("Rewinding demo\n");
CL_PlayDemo(lastdemoname);
CL_PlayDemo(lastdemoname, lastdemowassystempath);
//now fastparse it.
cls.demoseektime = newtime;
@ -1567,9 +1568,14 @@ void CL_PlayDemo_f (void)
#endif
demoname = Cmd_Argv(1);
if (*demoname == '#' && Cmd_FromGamecode())
return;
CL_PlayDemo(demoname);
if (*demoname == '#')
{
if (Cmd_FromGamecode())
return;
CL_PlayDemo(demoname+1, true);
}
else
CL_PlayDemo(demoname, false);
}
void CL_DemoStreamFullyDownloaded(struct dl_download *dl)
@ -1581,7 +1587,7 @@ void CL_DemoStreamFullyDownloaded(struct dl_download *dl)
cls.demoindownload = NULL;
}
//dl is provided so that we can receive files via chunked/gziped http downloads and on systems that don't provide sockets etc. its tracked so we can cancel the download if the client aborts playback early.
void CL_PlayDemoStream(vfsfile_t *file, struct dl_download *dl, char *filename, int demotype, float bufferdelay)
void CL_PlayDemoStream(vfsfile_t *file, struct dl_download *dl, char *filename, qboolean issyspath, int demotype, float bufferdelay)
{
int protocol = CP_UNKNOWN;
@ -1640,6 +1646,7 @@ void CL_PlayDemoStream(vfsfile_t *file, struct dl_download *dl, char *filename,
if (filename)
{
Q_strncpyz (lastdemoname, filename, sizeof(lastdemoname));
lastdemowassystempath = issyspath;
Con_Printf ("Playing demo from %s.\n", filename);
}
@ -1661,15 +1668,15 @@ void CL_PlayDemoStream(vfsfile_t *file, struct dl_download *dl, char *filename,
TP_ExecTrigger ("f_demostart");
}
vfsfile_t *CL_OpenFileInZipOrSys(char *name)
vfsfile_t *CL_OpenFileInZipOrSys(char *name, qboolean usesystempath)
{
if (*name == '#')
return VFSOS_Open(name+1, "rb");
if (usesystempath)
return VFSOS_Open(name, "rb");
else
return CL_OpenFileInPackage(NULL, name);
}
//tries to determine the demo type
void CL_PlayDemoFile(vfsfile_t *f, char *demoname)
void CL_PlayDemoFile(vfsfile_t *f, char *demoname, qboolean issyspath)
{
qofs_t start;
@ -1695,7 +1702,7 @@ void CL_PlayDemoFile(vfsfile_t *f, char *demoname)
VFS_SEEK(f, start);
if (len > 5 && type == svcq2_serverdata && protocol == PROTOCOL_VERSION_Q2)
{
CL_PlayDemoStream(f, NULL, demoname, DPB_QUAKE2, 0);
CL_PlayDemoStream(f, NULL, demoname, issyspath, DPB_QUAKE2, 0);
return;
}
}
@ -1722,7 +1729,7 @@ void CL_PlayDemoFile(vfsfile_t *f, char *demoname)
ft *= -1;
if (chr == '\n')
{
CL_PlayDemoStream(f, NULL, demoname, DPB_NETQUAKE, 0);
CL_PlayDemoStream(f, NULL, demoname, issyspath, DPB_NETQUAKE, 0);
return;
}
VFS_SEEK(f, start);
@ -1735,9 +1742,9 @@ void CL_PlayDemoFile(vfsfile_t *f, char *demoname)
//mvd and qwd have no identifying markers, other than the extension.
if (!Q_strcasecmp(demoname + strlen(demoname) - 3, "mvd") ||
!Q_strcasecmp(demoname + strlen(demoname) - 6, "mvd.gz"))
CL_PlayDemoStream(f, NULL, demoname, DPB_MVD, 0);
CL_PlayDemoStream(f, NULL, demoname, issyspath, DPB_MVD, 0);
else
CL_PlayDemoStream(f, NULL, demoname, DPB_QUAKEWORLD, 0);
CL_PlayDemoStream(f, NULL, demoname, issyspath, DPB_QUAKEWORLD, 0);
}
#ifdef WEBCLIENT
void CL_PlayDownloadedDemo(struct dl_download *dl)
@ -1746,12 +1753,12 @@ void CL_PlayDownloadedDemo(struct dl_download *dl)
Con_Printf("Failed to download %s\n", dl->url);
else
{
CL_PlayDemoFile(dl->file, dl->url);
CL_PlayDemoFile(dl->file, dl->url, false);
dl->file = NULL;
}
}
#endif
void CL_PlayDemo(char *demoname)
void CL_PlayDemo(char *demoname, qboolean usesystempath)
{
char name[256];
vfsfile_t *f;
@ -1761,13 +1768,13 @@ void CL_PlayDemo(char *demoname)
//
Q_strncpyz (name, demoname, sizeof(name));
COM_DefaultExtension (name, ".qwd", sizeof(name));
f = CL_OpenFileInZipOrSys(name);
f = CL_OpenFileInZipOrSys(name, usesystempath);
if (!f)
{
Q_strncpyz (name, demoname, sizeof(name));
COM_DefaultExtension (name, ".dem", sizeof(name));
if (*name == '#')
f = VFSOS_Open(name+1, "rb");
if (usesystempath)
f = VFSOS_Open(name, "rb");
else
f = FS_OpenVFS(name, "rb", FS_GAME);
}
@ -1775,8 +1782,8 @@ void CL_PlayDemo(char *demoname)
{
Q_strncpyz (name, demoname, sizeof(name));
COM_DefaultExtension (name, ".mvd", sizeof(name));
if (*name == '#')
f = VFSOS_Open(name+1, "rb");
if (usesystempath)
f = VFSOS_Open(name, "rb");
else
f = FS_OpenVFS(name, "rb", FS_GAME);
}
@ -1788,7 +1795,7 @@ void CL_PlayDemo(char *demoname)
}
Q_strncpyz (lastdemoname, demoname, sizeof(lastdemoname));
CL_PlayDemoFile(f, name);
CL_PlayDemoFile(f, name, usesystempath);
}
/*used with qtv*/
@ -2017,7 +2024,7 @@ void CL_QTVPoll (void)
if (streamavailable)
{
CL_PlayDemoStream(qtvrequest, NULL, NULL, iseztv?DPB_EZTV:DPB_MVD, BUFFERTIME);
CL_PlayDemoStream(qtvrequest, NULL, NULL, false, iseztv?DPB_EZTV:DPB_MVD, BUFFERTIME);
qtvrequest = NULL;
demo_resetcache(qtvrequestsize - (tail-qtvrequestbuffer), tail);
return;
@ -2302,7 +2309,7 @@ void CL_QTVPlay_f (void)
if (raw)
{
VFS_WRITE(newf, msg, msglen);
CL_PlayDemoStream(qtvrequest, NULL, qtvhostname, DPB_MVD, BUFFERTIME);
CL_PlayDemoStream(qtvrequest, NULL, qtvhostname, false, DPB_MVD, BUFFERTIME);
}
else
{

View file

@ -489,6 +489,7 @@ void FlushEntityPacket (void)
void CLFTE_ReadDelta(unsigned int entnum, entity_state_t *news, entity_state_t *olds, entity_state_t *baseline)
{
unsigned int predbits = 0;
unsigned int bits;
bits = MSG_ReadByte();
@ -534,7 +535,7 @@ void CLFTE_ReadDelta(unsigned int entnum, entity_state_t *news, entity_state_t *
if (bits & UF_ORIGINZ)
news->origin[2] = MSG_ReadCoord();
if (bits & UF_PREDINFO)
if ((bits & UF_PREDINFO) && !(cls.fteprotocolextensions2 & PEXT2_PREDINFO))
{
/*predicted stuff gets more precise angles*/
if (bits & UF_ANGLESXZ)
@ -571,7 +572,6 @@ void CLFTE_ReadDelta(unsigned int entnum, entity_state_t *news, entity_state_t *
news->u.q1.velocity[2] = 0;
if (bits & UF_PREDINFO)
{
unsigned int predbits;
predbits = MSG_ReadByte();
if (predbits & UFP_FORWARD)
@ -606,15 +606,41 @@ void CLFTE_ReadDelta(unsigned int entnum, entity_state_t *news, entity_state_t *
news->u.q1.msec = MSG_ReadByte();
else
news->u.q1.msec = 0;
if (predbits & UFP_WEAPONFRAME)
if (cls.fteprotocolextensions2 & PEXT2_PREDINFO)
{
news->u.q1.weaponframe = MSG_ReadByte();
if (news->u.q1.weaponframe & 0x80)
news->u.q1.weaponframe = (news->u.q1.weaponframe & 127) | (MSG_ReadByte()<<7);
if (predbits & UFP_VIEWANGLE)
{
if (bits & UF_ANGLESXZ)
{
news->u.q1.vangle[0] = MSG_ReadShort();
news->u.q1.vangle[2] = MSG_ReadShort();
}
if (bits & UF_ANGLESY)
news->u.q1.vangle[1] = MSG_ReadShort();
}
}
else
{
if (predbits & UFP_WEAPONFRAME_OLD)
{
news->u.q1.weaponframe = MSG_ReadByte();
if (news->u.q1.weaponframe & 0x80)
news->u.q1.weaponframe = (news->u.q1.weaponframe & 127) | (MSG_ReadByte()<<7);
}
}
}
else
{
news->u.q1.msec = 0;
}
if (!(predbits & UFP_VIEWANGLE) || (cls.fteprotocolextensions2 & PEXT2_PREDINFO))
{
news->u.q1.vangle[0] = ANGLE2SHORT(news->angles[0]);
news->u.q1.vangle[1] = ANGLE2SHORT(news->angles[1]);
news->u.q1.vangle[2] = ANGLE2SHORT(news->angles[2]);
}
if (bits & UF_MODEL)
{
@ -2774,8 +2800,9 @@ static void CL_LerpNetFrameState(int fsanim, framestate_t *fs, lerpents_t *le)
fs->g[fsanim].frametime[0] = cl.servertime - le->newframestarttime;
fs->g[fsanim].frametime[1] = cl.servertime - le->oldframestarttime;
fs->g[fsanim].lerpfrac = 1-(fs->g[fsanim].frametime[0]) / le->framelerpdeltatime;
fs->g[fsanim].lerpfrac = bound(0, fs->g[FS_REG].lerpfrac, 1);
fs->g[fsanim].lerpweight[0] = (fs->g[fsanim].frametime[0]) / le->framelerpdeltatime;
fs->g[fsanim].lerpweight[0] = bound(0, fs->g[FS_REG].lerpweight[0], 1);
fs->g[fsanim].lerpweight[1] = 1 - fs->g[fsanim].lerpweight[0];
}
static void CL_UpdateNetFrameLerpState(qboolean force, unsigned int curframe, lerpents_t *le)
@ -3548,9 +3575,9 @@ void CL_LinkPacketEntities (void)
#ifdef RAGDOLL
if (model && model->dollinfo)
rag_updatedeltaent(ent, le);
#endif
ent->framestate.g[FS_REG].frame[0] &= ~0x8000;
ent->framestate.g[FS_REG].frame[1] &= ~0x8000;
#endif
CLQ1_AddShadow(ent);
CLQ1_AddPowerupShell(ent, false, state->effects);
@ -4193,8 +4220,10 @@ void CL_AddFlagModels (entity_t *ent, int team)
if (cl_flagindex == -1)
return;
for (i = 0; i < 2; i++)
for (i = 0; i < FRAME_BLENDS; i++)
{
if (!ent->framestate.g[FS_REG].lerpweight[i])
continue;
f = 14;
if (ent->framestate.g[FS_REG].frame[i] >= 29 && ent->framestate.g[FS_REG].frame[i] <= 40) {
if (ent->framestate.g[FS_REG].frame[i] >= 29 && ent->framestate.g[FS_REG].frame[i] <= 34) { //axpain
@ -4219,7 +4248,7 @@ void CL_AddFlagModels (entity_t *ent, int team)
else if (ent->framestate.g[FS_REG].frame[i] >= 112 && ent->framestate.g[FS_REG].frame[i] <= 118) f = f + 7; //shotattack
}
offs += f + ((i==0)?(ent->framestate.g[FS_REG].lerpfrac):(1-ent->framestate.g[FS_REG].lerpfrac));
offs += f * ent->framestate.g[FS_REG].lerpweight[i];
}
newent = CL_NewTempEntity ();
@ -4246,7 +4275,7 @@ void CL_AddFlagModels (entity_t *ent, int team)
void CL_AddVWeapModel(entity_t *player, model_t *model)
{
entity_t *newent;
vec3_t angles;
// vec3_t angles;
if (!model)
return;
newent = CL_NewTempEntity ();
@ -4260,9 +4289,7 @@ void CL_AddVWeapModel(entity_t *player, model_t *model)
newent->model = model;
newent->framestate = player->framestate;
VectorCopy(newent->angles, angles);
angles[0]*=-1;
AngleVectors(angles, newent->axis[0], newent->axis[1], newent->axis[2]);
AngleVectors(newent->angles, newent->axis[0], newent->axis[1], newent->axis[2]);
VectorInverse(newent->axis[1]);
}
@ -4485,8 +4512,9 @@ void CL_LinkPlayers (void)
}
}
if (model && model->type == mod_alias)
angles[0]*=-1; //carmack screwed up when he added alias models - they pitch the wrong way.
VectorCopy(angles, ent->angles);
angles[0]*=-1;
AngleVectors(angles, ent->axis[0], ent->axis[1], ent->axis[2]);
VectorInverse(ent->axis[1]);
@ -4676,8 +4704,9 @@ void CL_LinkViewModel(void)
ent.framestate.g[FS_REG].frame[1] = pv->vm.oldframe;
ent.framestate.g[FS_REG].frametime[0] = realtime - pv->vm.lerptime;
ent.framestate.g[FS_REG].frametime[1] = realtime - pv->vm.oldlerptime;
ent.framestate.g[FS_REG].lerpfrac = 1-(realtime-pv->vm.lerptime)/pv->vm.frameduration;
ent.framestate.g[FS_REG].lerpfrac = bound(0, ent.framestate.g[FS_REG].lerpfrac, 1);
ent.framestate.g[FS_REG].lerpweight[0] = (realtime-pv->vm.lerptime)/pv->vm.frameduration;
ent.framestate.g[FS_REG].lerpweight[0] = bound(0, ent.framestate.g[FS_REG].lerpweight[0], 1);
ent.framestate.g[FS_REG].lerpweight[1] = 1-ent.framestate.g[FS_REG].lerpweight[0];
}
ent.flags |= RF_WEAPONMODEL|RF_DEPTHHACK|RF_NOSHADOW;
@ -4766,6 +4795,8 @@ void CL_SetSolidEntities (void)
pent = &pmove.physents[pmove.numphysent];
memset(pent, 0, sizeof(physent_t));
pent->model = cl.model_precache[state->modelindex];
if (pent->model->loadstate != MLS_LOADED)
continue;
VectorCopy (state->angles, pent->angles);
pent->angles[0]*=-1;
}

View file

@ -501,6 +501,22 @@ cvar_t cl_pitchspeed = SCVAR("cl_pitchspeed","150");
cvar_t cl_anglespeedkey = SCVAR("cl_anglespeedkey","1.5");
void CL_GatherButtons (usercmd_t *cmd, int pnum)
{
unsigned int bits = 0;
if (in_attack .state[pnum] & 3) bits |= 1; in_attack.state[pnum] &= ~2;
if (in_jump .state[pnum] & 3) bits |= 2; in_jump.state[pnum] &= ~2;
if (in_use .state[pnum] & 3) bits |= 4; in_use.state[pnum] &= ~2;
if (in_button3.state[pnum] & 3) bits |= 4; in_button3.state[pnum] &= ~2; //yup, flag 4 twice.
if (in_button4.state[pnum] & 3) bits |= 8; in_button4.state[pnum] &= ~2;
if (in_button5.state[pnum] & 3) bits |= 16; in_button5.state[pnum] &= ~2;
if (in_button6.state[pnum] & 3) bits |= 32; in_button6.state[pnum] &= ~2;
if (in_button7.state[pnum] & 3) bits |= 64; in_button7.state[pnum] &= ~2;
if (in_button8.state[pnum] & 3) bits |= 128; in_button8.state[pnum] &= ~2;
cmd->buttons = bits;
}
/*
================
CL_AdjustAngles
@ -604,6 +620,8 @@ void CL_BaseMove (usercmd_t *cmd, int pnum, float extra, float wantfps)
cmd->forwardmove += scale*cl_forwardspeed.value * CL_KeyState (&in_forward, pnum, true);
cmd->forwardmove -= scale*(*cl_backspeed.string?cl_backspeed.value:cl_forwardspeed.value) * CL_KeyState (&in_back, pnum, true);
}
CL_GatherButtons(cmd, pnum);
}
void CL_ClampPitch (int pnum)
@ -836,17 +854,7 @@ void CL_FinishMove (usercmd_t *cmd, int msecs, int pnum)
// figure button bits
//
bits = 0;
if (in_attack .state[pnum] & 3) bits |= 1; in_attack.state[pnum] &= ~2;
if (in_jump .state[pnum] & 3) bits |= 2; in_jump.state[pnum] &= ~2;
if (in_use .state[pnum] & 3) bits |= 4; in_use.state[pnum] &= ~2;
if (in_button3.state[pnum] & 3) bits |= 4; in_button3.state[pnum] &= ~2; //yup, flag 4 twice.
if (in_button4.state[pnum] & 3) bits |= 8; in_button4.state[pnum] &= ~2;
if (in_button5.state[pnum] & 3) bits |= 16; in_button5.state[pnum] &= ~2;
if (in_button6.state[pnum] & 3) bits |= 32; in_button6.state[pnum] &= ~2;
if (in_button7.state[pnum] & 3) bits |= 64; in_button7.state[pnum] &= ~2;
if (in_button8.state[pnum] & 3) bits |= 128; in_button8.state[pnum] &= ~2;
cmd->buttons = bits;
CL_GatherButtons(cmd, pnum);
// send milliseconds of time to apply the move
cmd->msec = msecs;

View file

@ -1247,7 +1247,7 @@ CL_ClearState
*/
void CL_ClearState (void)
{
int i;
int i, j;
#ifndef CLIENTONLY
#define serverrunning (sv.state != ss_dead)
#define tolocalserver NET_IsLoopBackAddress(&cls.netchan.remote_address)
@ -1311,6 +1311,12 @@ void CL_ClearState (void)
if (cl.particle_ssname[i])
free(cl.particle_ssname[i]);
}
if (cl.particle_csprecaches)
{
for (i = 0; i < MAX_CSPARTICLESPRE; i++)
if (cl.particle_csname[i])
free(cl.particle_csname[i]);
}
{
downloadlist_t *next;
@ -1328,6 +1334,13 @@ void CL_ClearState (void)
}
}
for (i = 0; i < MAX_SPLITS; i++)
{
for (j = 0; j < MAX_CL_STATS; j++)
if (cl.playerview[i].statsstr[j])
Z_Free(cl.playerview[i].statsstr[j]);
}
// wipe the entire cl structure
memset (&cl, 0, sizeof(cl));
@ -3953,7 +3966,7 @@ typedef struct {
int waitingformanifest;
void Host_DoRunFile(hrf_t *f);
void CL_PlayDemoStream(vfsfile_t *file, struct dl_download *, char *filename, int demotype, float bufferdelay);
void CL_PlayDemoStream(vfsfile_t *file, struct dl_download *, char *filename, qboolean issyspath, int demotype, float bufferdelay);
void CL_ParseQTVDescriptor(vfsfile_t *f, const char *name);
void Host_RunFileDownloaded(struct dl_download *dl)
@ -4031,12 +4044,12 @@ void Host_BeginFileDownload(struct dl_download *dl, char *mimetype)
}
if (f->flags & HRF_DEMO_QWD)
CL_PlayDemoStream((dl->file = VFSPIPE_Open()), dl, f->fname, DPB_QUAKEWORLD, 0);
CL_PlayDemoStream((dl->file = VFSPIPE_Open()), dl, f->fname, true, DPB_QUAKEWORLD, 0);
else if (f->flags & HRF_DEMO_MVD)
CL_PlayDemoStream((dl->file = VFSPIPE_Open()), dl, f->fname, DPB_MVD, 0);
CL_PlayDemoStream((dl->file = VFSPIPE_Open()), dl, f->fname, true, DPB_MVD, 0);
#ifdef Q2CLIENT
else if (f->flags & HRF_DEMO_DM2)
CL_PlayDemoStream((dl->file = VFSPIPE_Open()), dl, f->fname, DPB_QUAKE2, 0);
CL_PlayDemoStream((dl->file = VFSPIPE_Open()), dl, f->fname, true, DPB_QUAKE2, 0);
#endif
#ifdef NQPROT
//fixme: the demo code can't handle the cd track like this.

View file

@ -3373,6 +3373,7 @@ Con_DPrintf ("CL_SignonReply: %i\n", cls.signon);
CL_SendClientCommand(true, "playermodel %s", model.string);
CL_SendClientCommand(true, "playerskin %s", skin.string);
/*
#ifdef PEXT_CSQC
{
char *s;
@ -3380,6 +3381,7 @@ Con_DPrintf ("CL_SignonReply: %i\n", cls.signon);
CSQC_Init(false, *s?true:false, atoi(s));
}
#endif
*/
}
break;
@ -4604,35 +4606,38 @@ void CL_ServerInfo (void)
CL_SetStat
=====================
*/
static void CL_SetStat_Internal (int pnum, int stat, int value)
static void CL_SetStat_Internal (int pnum, int stat, int ivalue, float fvalue)
{
int j;
if (cl.playerview[pnum].stats[stat] != value)
if (cl.playerview[pnum].stats[stat] != ivalue)
Sbar_Changed ();
if (stat == STAT_ITEMS)
{ // set flash times
for (j=0 ; j<32 ; j++)
if ( (value & (1<<j)) && !(cl.playerview[pnum].stats[stat] & (1<<j)))
if ( (ivalue & (1<<j)) && !(cl.playerview[pnum].stats[stat] & (1<<j)))
cl.playerview[pnum].item_gettime[j] = cl.time;
}
if (stat == STAT_WEAPON)
{
if (cl.playerview[pnum].stats[stat] != value)
if (cl.playerview[pnum].stats[stat] != ivalue)
{
if (value == 0)
if (ivalue == 0)
TP_ExecTrigger ("f_reloadstart");
else if (cl.playerview[pnum].stats[stat] == 0)
TP_ExecTrigger ("f_reloadend");
}
}
cl.playerview[pnum].stats[stat] = value;
cl.playerview[pnum].statsf[stat] = value;
if (stat == STAT_VIEWHEIGHT && ((cls.z_ext & Z_EXT_VIEWHEIGHT) || cls.protocol == CP_NETQUAKE))
cl.playerview[pnum].viewheight = fvalue;
cl.playerview[pnum].stats[stat] = ivalue;
cl.playerview[pnum].statsf[stat] = fvalue;
if (pnum == 0)
TP_StatChanged(stat, value);
TP_StatChanged(stat, ivalue);
}
void CL_SetStatMovevar(int pnum, int stat, float value)
@ -4695,10 +4700,10 @@ void CL_SetStatInt (int pnum, int stat, int value)
for (pnum = 0; pnum < cl.splitclients; pnum++)
if (cl.playerview[pnum].cam_spec_track == cls_lastto)
CL_SetStat_Internal(pnum, stat, value);
CL_SetStat_Internal(pnum, stat, value, value);
}
else
CL_SetStat_Internal(pnum, stat, value);
CL_SetStat_Internal(pnum, stat, value, value);
if (cls.protocol == CP_NETQUAKE && CPNQ_IS_DP && !(cls.fteprotocolextensions2 & PEXT2_PREDINFO))
CL_SetStatMovevar(pnum, stat, *(float*)&value); //DP sucks.
@ -4728,7 +4733,7 @@ void CL_SetStatFloat (int pnum, int stat, float value)
cl.playerview[pnum].stats[stat] = value;
}
if (stat == STAT_VIEWHEIGHT && cls.z_ext & Z_EXT_VIEWHEIGHT)
if (stat == STAT_VIEWHEIGHT && ((cls.z_ext & Z_EXT_VIEWHEIGHT) || cls.protocol == CP_NETQUAKE))
cl.playerview[pnum].viewheight = value;
if (cls.fteprotocolextensions2 & PEXT2_PREDINFO)
@ -5744,7 +5749,7 @@ void CL_ParsePortalState(void)
else
a1 = MSG_ReadByte();
#ifdef Q2BSPS
CMQ2_SetAreaPortalState(a1, !!(mode&1));
CMQ2_SetAreaPortalState(cl.worldmodel, a1, !!(mode&1));
#endif
break;
case 0xc0:
@ -5759,7 +5764,7 @@ void CL_ParsePortalState(void)
a2 = MSG_ReadByte();
}
#ifdef Q3BSPS
CMQ3_SetAreaPortalState(a1, a2, !!(mode&1));
CMQ3_SetAreaPortalState(cl.worldmodel, a1, a2, !!(mode&1));
#endif
break;
@ -5767,7 +5772,7 @@ void CL_ParsePortalState(void)
//to be phased out.
mode |= MSG_ReadByte()<<8;
#ifdef Q2BSPS
CMQ2_SetAreaPortalState(mode & 0x7fff, !!(mode&0x8000));
CMQ2_SetAreaPortalState(cl.worldmodel, mode & 0x7fff, !!(mode&0x8000));
#endif
break;
}
@ -6987,14 +6992,14 @@ void CLNQ_ParseServerMessage (void)
case svcnq_updatestatlong:
i = MSG_ReadByte ();
j = MSG_ReadLong ();
CL_SetStatInt (0, i, j);
CL_SetStatFloat (0, i, j);
CL_SetStatInt (0, i, j);
break;
case svcdp_updatestatbyte:
i = MSG_ReadByte ();
j = MSG_ReadByte ();
CL_SetStatInt (0, i, j);
CL_SetStatFloat (0, i, j);
CL_SetStatInt (0, i, j);
break;
case svc_setangle:
{

View file

@ -634,9 +634,24 @@ qintptr_t VARGS Plug_Mod_GetPluginModelFuncs(void *offset, quintptr_t mask, cons
R_ConcatTransforms,
Matrix3x4_Invert_Simple,
COM_StripExtension,
VectorAngles,
AngleVectors,
GenMatrixPosQuat4Scale,
Alias_ForceConvertBoneData
COM_StripExtension,
Alias_ForceConvertBoneData,
#ifdef USERBE
World_LinkEdict,
World_RegisterPhysicsEngine,
World_UnregisterPhysicsEngine,
World_GenerateCollisionMesh,
World_ReleaseCollisionMesh
#else
NULL,
NULL,
NULL,
NULL,
NULL
#endif
};
if (VM_LONG(arg[0]) >= sizeof(funcs))
return (qintptr_t)&funcs;

View file

@ -458,7 +458,6 @@ void CL_CalcCrouch (playerview_t *pv)
VectorSubtract(pv->simorg, pv->oldorigin, delta);
teleported = Length(delta)>48;
VectorCopy (pv->simorg, pv->oldorigin);
if (teleported)
{
@ -471,6 +470,15 @@ void CL_CalcCrouch (playerview_t *pv)
return;
}
//check if we moved in the x/y axis. if we didn't then we're on a moving platform and shouldn't be crouching.
/* VectorMA(pv->oldorigin, pv->oldz-orgz, pv->gravitydir, pv->oldorigin);
VectorSubtract(pv->simorg, pv->oldorigin, delta);
if (Length(delta)<0.001)
pv->oldz = orgz;
*/
VectorCopy (pv->simorg, pv->oldorigin);
if (pv->onground && orgz - pv->oldz > 0)
{
if (orgz - pv->oldz > movevars.stepheight+2)
@ -758,6 +766,10 @@ static void CL_EntStateToPlayerState(player_state_t *plstate, entity_state_t *st
plstate->viewangles[0] *= -3;
plstate->viewangles[2] = V_CalcRoll(plstate->viewangles, plstate->velocity);
plstate->viewangles[0] = SHORT2ANGLE(state->u.q1.vangle[0]);
plstate->viewangles[1] = SHORT2ANGLE(state->u.q1.vangle[1]);
plstate->viewangles[2] = SHORT2ANGLE(state->u.q1.vangle[2]);
a[0] = ((-192-state->u.q1.gravitydir[0])/256.0f) * 360;
a[1] = (state->u.q1.gravitydir[1]/256.0f) * 360;
a[2] = 0;
@ -790,9 +802,9 @@ static void CL_EntStateToPlayerCommand(usercmd_t *cmd, entity_state_t *state, fl
cmd->sidemove = state->u.q1.movement[1];
cmd->upmove = state->u.q1.movement[2];
cmd->angles[0] = state->angles[0] * -3 *65536/360.0;
cmd->angles[1] = state->angles[1] * 65536/360.0;
cmd->angles[2] = state->angles[2] * 65536/360.0;
cmd->angles[0] = state->u.q1.vangle[0];// * -3 *65536/360.0;
cmd->angles[1] = state->u.q1.vangle[1];// * 65536/360.0;
cmd->angles[2] = state->u.q1.vangle[2];// * 65536/360.0;
}
void CL_PredictEntityMovement(entity_state_t *estate, float age)
@ -993,14 +1005,14 @@ void CL_PredictMovePNum (int seat)
//we're only interested in inbound frames, not outbound, but its outbound frames that contain the prediction timing, so we need to look that up
//(note that in qw, inframe[i].ack==i holds true, but this code tries to be generic for unsyncronised protocols)
//(note that in nq, using outbound times means we'll skip over dupe states without noticing, and input packets with dupes should also be handled gracefully)
// Con_DPrintf("in:%i:%i out:%i:%i ack:%i\n", cls.netchan.incoming_sequence, cl.validsequence, cls.netchan.outgoing_sequence,cl.movesequence, cl.ackedmovesequence);
Con_DPrintf("in:%i:%i out:%i:%i ack:%i\n", cls.netchan.incoming_sequence, cl.validsequence, cls.netchan.outgoing_sequence,cl.movesequence, cl.ackedmovesequence);
for (i = cl.validsequence; i >= cls.netchan.incoming_sequence - UPDATE_MASK; i--)
{
int out;
//skip frames which were not received, or are otherwise invalid. yay packetloss
if (cl.inframes[i & UPDATE_MASK].frameid != i || cl.inframes[i & UPDATE_MASK].invalid)
{
// Con_DPrintf("stale incoming command %i\n", i);
Con_DPrintf("stale incoming command %i\n", i);
continue;
}
@ -1009,7 +1021,7 @@ void CL_PredictMovePNum (int seat)
backdate = &cl.outframes[out & UPDATE_MASK];
if (backdate->cmd_sequence != out)
{
// Con_DPrintf("stale outgoing command %i (%i:%i:%i)\n", i, out, backdate->cmd_sequence, backdate->server_message_num);
Con_DPrintf("stale outgoing command %i (%i:%i:%i)\n", i, out, backdate->cmd_sequence, backdate->server_message_num);
continue;
}
//okay, looks valid
@ -1024,12 +1036,12 @@ void CL_PredictMovePNum (int seat)
totime = fromtime;
fromframe = i;
fromtime = backdate->senttime;
if (fromtime < simtime)
if (fromtime < simtime && fromframe != toframe)
break; //okay, we found the first frame that is older, no need to continue looking
}
}
// Con_DPrintf("sim%f, %i(%i-%i): old%f, cur%f\n", simtime, cl.ackedmovesequence, fromframe, toframe, fromtime, totime);
Con_DPrintf("sim%f, %i(%i-%i): old%f, cur%f\n", simtime, cl.ackedmovesequence, fromframe, toframe, fromtime, totime);
if (pv->cam_locked && cl.spectator && pv->viewentity && pv->viewentity <= cl.allocated_client_slots)
{

View file

@ -223,6 +223,7 @@ float scr_disabled_time;
float oldsbar = 0;
void SCR_ScreenShot_f (void);
void SCR_ScreenShot_Mega_f(void);
void SCR_RSShot_f (void);
void SCR_CPrint_f(void);
@ -1174,6 +1175,7 @@ void SCR_Init (void)
//
// register our commands
//
Cmd_AddCommand ("screenshot_mega",SCR_ScreenShot_Mega_f);
Cmd_AddCommand ("screenshot",SCR_ScreenShot_f);
Cmd_AddCommand ("sizeup",SCR_SizeUp_f);
Cmd_AddCommand ("sizedown",SCR_SizeDown_f);
@ -2114,6 +2116,75 @@ void SCR_ScreenShot_f (void)
Con_Printf ("Couldn't write %s\n", sysname);
}
void SCR_ScreenShot_Mega_f(void)
{
int width;
int height;
qbyte *rgbbuffer;
char filename[MAX_QPATH];
//poke the various modes into redrawing the screen (without huds), to avoid any menus or console drawn over the top of the current backbuffer.
//FIXME: clear-to-black first
qboolean okay = false;
char *screenyname = Cmd_Argv(1);
unsigned int fbwidth = strtoul(Cmd_Argv(2), NULL, 0);
unsigned int fbheight = strtoul(Cmd_Argv(3), NULL, 0);
if (qrenderer <= QR_HEADLESS)
{
Con_Printf("No renderer active\n");
return;
}
if (!fbwidth)
fbwidth = sh_config.texture_maxsize;
fbwidth = bound(0, fbwidth, sh_config.texture_maxsize);
if (!fbheight)
fbheight = (fbwidth * 3)/4;
fbheight = bound(0, fbheight, sh_config.texture_maxsize);
if (!*screenyname)
screenyname = "megascreeny";
Q_snprintfz(filename, sizeof(filename), "%s-%s", scr_sshot_prefix.string, screenyname);
COM_DefaultExtension (filename, scr_sshot_type.string, sizeof(filename));
Q_strncpyz(r_refdef.rt_destcolour[0].texname, "megascreeny", sizeof(r_refdef.rt_destcolour[0].texname));
R2D_RT_Configure(r_refdef.rt_destcolour[0].texname, fbwidth, fbheight, 1);
BE_RenderToTextureUpdate2d(true);
R2D_FillBlock(0, 0, vid.fbvwidth, vid.fbvheight);
#ifdef VM_CG
if (!okay && CG_Refresh())
okay = true;
#endif
#ifdef CSQC_DAT
if (!okay && CSQC_DrawView())
okay = true;
#endif
if (!okay && r_worldentity.model)
{
V_RenderView ();
okay = true;
}
//okay, we drew something, we're good to save a screeny.
if (okay)
{
rgbbuffer = VID_GetRGBInfo(0, &width, &height);
if (rgbbuffer)
{
SCR_ScreenShot(filename, rgbbuffer, width, height);
BZ_Free(rgbbuffer);
}
}
R2D_RT_Configure(r_refdef.rt_destcolour[0].texname, 0, 0, 0);
Q_strncpyz(r_refdef.rt_destcolour[0].texname, "", sizeof(r_refdef.rt_destcolour[0].texname));
BE_RenderToTextureUpdate2d(true);
}
// from gl_draw.c
qbyte *draw_chars; // 8*8 graphic characters

View file

@ -3703,7 +3703,8 @@ void CL_UpdateExplosions (void)
ent->model = ex->model;
ent->framestate.g[FS_REG].frame[1] = (int)f+firstframe;
ent->framestate.g[FS_REG].frame[0] = of+firstframe;
ent->framestate.g[FS_REG].lerpfrac = (f - (int)f);
ent->framestate.g[FS_REG].lerpweight[1] = (f - (int)f);
ent->framestate.g[FS_REG].lerpweight[0] = 1-ent->framestate.g[FS_REG].lerpweight[1];
ent->shaderRGBAf[3] = (1.0 - f/(numframes))*(ex->startalpha-ex->endalpha) + ex->endalpha;
ent->flags = ex->flags;
ent->scale = scale;

View file

@ -395,7 +395,8 @@ void VQ3_AddEntity(const q3refEntity_t *q3)
ent.framestate.g[FS_REG].frame[0] = q3->frame;
ent.framestate.g[FS_REG].frame[1] = q3->oldframe;
memcpy(ent.axis, q3->axis, sizeof(q3->axis));
ent.framestate.g[FS_REG].lerpfrac = q3->backlerp;
ent.framestate.g[FS_REG].lerpweight[1] = q3->backlerp;
ent.framestate.g[FS_REG].lerpweight[0] = 1 - ent.framestate.g[FS_REG].lerpweight[1];
if (q3->reType == RT_SPRITE)
{
ent.scale = q3->radius;
@ -508,7 +509,8 @@ int VM_LerpTag(void *out, model_t *model, int f1, int f2, float l2, char *tagnam
memset(&fstate, 0, sizeof(fstate));
fstate.g[FS_REG].frame[0] = f1;
fstate.g[FS_REG].frame[1] = f2;
fstate.g[FS_REG].lerpfrac = l2;
fstate.g[FS_REG].lerpweight[0] = 1 - l2;
fstate.g[FS_REG].lerpweight[1] = l2;
tagnum = Mod_TagNumForName(model, tagname);
found = Mod_GetTag(model, tagnum, &fstate, tr);

View file

@ -1452,9 +1452,10 @@ void Media_EndedTrack(void); //cd is no longer running, media code needs to pick
void Media_Send_Command(cin_t *cin, const char *command);
void Media_Send_MouseMove(cin_t *cin, float x, float y);
void Media_Send_Resize(cin_t *cin, int x, int y);
void Media_Send_GetSize(cin_t *cin, int *x, int *y);
void Media_Send_GetSize(cin_t *cin, int *x, int *y, float *aspect);
void Media_Send_KeyEvent(cin_t *cin, int button, int unicode, int event);
void Media_Send_Reset(cin_t *cin);
void Media_Send_GetPositions(cin_t *cin, qboolean *active, float *curtime, float *duration);
void MVD_Interpolate(void);

View file

@ -1274,7 +1274,8 @@ void CLQ2_AddPacketEntities (q2frame_t *frame)
// pmm
//======
ent.framestate.g[FS_REG].frame[1] = cent->prev.frame;
ent.framestate.g[FS_REG].lerpfrac = cl.lerpfrac;
ent.framestate.g[FS_REG].lerpweight[0] = 1-cl.lerpfrac;
ent.framestate.g[FS_REG].lerpweight[1] = cl.lerpfrac;
if (renderfx & (Q2RF_FRAMELERP|Q2RF_BEAM))
{ // step origin discretely, because the frames
@ -1302,7 +1303,8 @@ void CLQ2_AddPacketEntities (q2frame_t *frame)
ent.shaderRGBAf[2] = ((d_8to24rgbtable[ent.skinnum & 0xFF] >> 16) & 0xFF)/255.0;
ent.shaderRGBAf[3] = 0.30;
ent.model = NULL;
ent.framestate.g[FS_REG].lerpfrac = 1;
ent.framestate.g[FS_REG].lerpweight[0] = 0;
ent.framestate.g[FS_REG].lerpweight[1] = 1;
ent.rtype = RT_BEAM;
}
else
@ -1456,13 +1458,14 @@ void CLQ2_AddPacketEntities (q2frame_t *frame)
//pmm
/*lerp the ent now*/
fwds = ent.framestate.g[FS_REG].lerpfrac;
back = 1 - ent.framestate.g[FS_REG].lerpfrac;
fwds = ent.framestate.g[FS_REG].lerpweight[1];
back = ent.framestate.g[FS_REG].lerpweight[0];
for (i = 0; i < 3; i++)
{
ent.origin[i] = ent.origin[i]*fwds + ent.oldorigin[i]*back;
}
ent.framestate.g[FS_REG].lerpfrac = back;
ent.framestate.g[FS_REG].lerpweight[0] = fwds;
ent.framestate.g[FS_REG].lerpweight[1] = back;
// add to refresh list
V_AddEntity (&ent);
@ -1821,7 +1824,8 @@ void CLQ2_AddViewWeapon (q2player_state_t *ps, q2player_state_t *ops)
gun.playerindex = -1;
gun.flags = Q2RF_MINLIGHT | RF_DEPTHHACK | RF_WEAPONMODEL;
gun.framestate.g[FS_REG].lerpfrac = 1-cl.lerpfrac;
gun.framestate.g[FS_REG].lerpweight[0] = cl.lerpfrac;
gun.framestate.g[FS_REG].lerpweight[1] = 1-cl.lerpfrac;
VectorCopy (gun.origin, gun.oldorigin); // don't lerp at all
V_AddEntity (&gun);
}

View file

@ -38,6 +38,9 @@ extern cvar_t gl_picmip2d;
extern cvar_t gl_picmip;
extern cvar_t r_shadow_bumpscale_basetexture;
extern cvar_t r_shadow_bumpscale_bumpmap;
extern cvar_t r_shadow_heightscale_basetexture;
extern cvar_t r_shadow_heightscale_bumpmap;
static bucket_t *imagetablebuckets[256];
static hashtable_t imagetable;
@ -2332,7 +2335,6 @@ static qboolean Image_ReadDDSFile(texid_t tex, unsigned int flags, char *fname,
ddsheader fmtheader;
if (*(int*)filedata != *(int*)"DDS ")
return false;
filedata+=4;
memcpy(&fmtheader, filedata+4, sizeof(fmtheader));
if (fmtheader.dwSize != sizeof(fmtheader))
@ -3024,10 +3026,10 @@ void Image_ResampleTexture (unsigned *in, int inwidth, int inheight, unsigned *o
}
//ripped from tenebrae
static unsigned int * Image_GenerateNormalMap(qbyte *pixels, unsigned int *nmap, int w, int h, float scale)
static unsigned int * Image_GenerateNormalMap(qbyte *pixels, unsigned int *nmap, int w, int h, float scale, float offsetscale)
{
int i, j, wr, hr;
unsigned char r, g, b;
unsigned char r, g, b, height;
float sqlen, reciplen, nx, ny, nz;
const float oneOver255 = 1.0f/255.0f;
@ -3065,7 +3067,8 @@ static unsigned int * Image_GenerateNormalMap(qbyte *pixels, unsigned int *nmap,
/* The highest resolution mipmap level always has a
unit length magnitude. */
nmap[i*w+j] = LittleLong ((pixels[i*wr + j] << 24)|(b << 16)|(g << 8)|(r)); // <AWE> Added support for big endian.
height = bound(0, (pixels[i*wr + j]*offsetscale)+(255*(1-offsetscale)), 255);
nmap[i*w+j] = LittleLong((height << 24)|(b << 16)|(g << 8)|(r)); // <AWE> Added support for big endian.
}
}
@ -3471,7 +3474,7 @@ static qboolean Image_GenMip0(struct pendingtextureinfo *mips, unsigned int flag
unsigned int rgb = d_8to24rgbtable[((qbyte*)rawdata)[i]];
heights[i] = (((rgb>>16)&0xff) + ((rgb>>8)&0xff) + ((rgb>>0)&0xff))/3;
}
Image_GenerateNormalMap(heights, rgbadata, imgwidth, imgheight, r_shadow_bumpscale_basetexture.value?r_shadow_bumpscale_basetexture.value:4);
Image_GenerateNormalMap(heights, rgbadata, imgwidth, imgheight, r_shadow_bumpscale_basetexture.value?r_shadow_bumpscale_basetexture.value:4, r_shadow_heightscale_basetexture.value);
}
if (freedata)
BZ_Free(rawdata);
@ -3480,7 +3483,7 @@ static qboolean Image_GenMip0(struct pendingtextureinfo *mips, unsigned int flag
case TF_HEIGHT8:
mips->encoding = PTI_RGBA8;
rgbadata = BZ_Malloc(imgwidth * imgheight*4);
Image_GenerateNormalMap(rawdata, rgbadata, imgwidth, imgheight, r_shadow_bumpscale_bumpmap.value);
Image_GenerateNormalMap(rawdata, rgbadata, imgwidth, imgheight, r_shadow_bumpscale_bumpmap.value, r_shadow_heightscale_bumpmap.value);
if (freedata)
BZ_Free(rawdata);
freedata = true;
@ -3507,8 +3510,9 @@ static qboolean Image_GenMip0(struct pendingtextureinfo *mips, unsigned int flag
freedata = true;
break;
case TF_8PAL32:
if (!palettedata)
{
Con_Printf("TF_8PAL24: no palette");
Con_Printf("TF_8PAL32: no palette");
if (freedata)
BZ_Free(rawdata);
return false;
@ -3654,13 +3658,13 @@ static qboolean Image_GenMip0(struct pendingtextureinfo *mips, unsigned int flag
return true;
}
//loads from a single mip. takes ownership of the data.
static qboolean Image_LoadRawTexture(texid_t tex, unsigned int flags, void *rawdata, int imgwidth, int imgheight, uploadfmt_t fmt)
static qboolean Image_LoadRawTexture(texid_t tex, unsigned int flags, void *rawdata, void *palettedata, int imgwidth, int imgheight, uploadfmt_t fmt)
{
struct pendingtextureinfo *mips;
mips = Z_Malloc(sizeof(*mips));
mips->type = (flags & IF_3DMAP)?PTI_3D:PTI_2D;
if (!Image_GenMip0(mips, flags, rawdata, NULL, imgwidth, imgheight, fmt, true))
if (!Image_GenMip0(mips, flags, rawdata, palettedata, imgwidth, imgheight, fmt, true))
{
Z_Free(mips);
return false;
@ -3738,7 +3742,7 @@ qboolean Image_LoadTextureFromMemory(texid_t tex, int flags, const char *iname,
}
}
if (Image_LoadRawTexture(tex, flags, rgbadata, imgwidth, imgheight, TF_RGBA32))
if (Image_LoadRawTexture(tex, flags, rgbadata, NULL, imgwidth, imgheight, TF_RGBA32))
{
BZ_Free(filedata);
@ -3889,6 +3893,15 @@ void Image_LoadHiResTextureWorker(void *ctx, void *data, size_t a, size_t b)
if (!tex->fallbackdata || (gl_load24bit.ival && !(tex->flags & IF_NOREPLACE)))
{
Q_snprintfz(fname, sizeof(fname), "dds/%s.dds", nicename);
if ((buf = COM_LoadFile (fname, 5, &fsize)))
{
Q_snprintfz(iname, sizeof(iname), "dds/%s", nicename); /*should be safe if its null*/
if (Image_LoadTextureFromMemory(tex, tex->flags, iname, fname, buf, fsize))
return;
}
if (strchr(nicename, '/') || strchr(nicename, '\\')) //never look in a root dir for the pic
i = 0;
else
@ -4003,7 +4016,7 @@ void Image_LoadHiResTextureWorker(void *ctx, void *data, size_t a, size_t b)
if ((d = ReadTargaFile(buf, fsize, &w, &h, &a, 2))) //Only load a greyscale image.
{
BZ_Free(buf);
if (Image_LoadRawTexture(tex, tex->flags, d, w, h, TF_HEIGHT8))
if (Image_LoadRawTexture(tex, tex->flags, d, NULL, w, h, TF_HEIGHT8))
{
BZ_Free(tex->fallbackdata);
tex->fallbackdata = NULL;
@ -4037,7 +4050,7 @@ void Image_LoadHiResTextureWorker(void *ctx, void *data, size_t a, size_t b)
buf = W_GetTexture(nicename, &imgwidth, &imgheight, &alphaed);
if (buf)
{
if (Image_LoadRawTexture(tex, tex->flags, buf, imgwidth, imgheight, TF_RGBA32))
if (Image_LoadRawTexture(tex, tex->flags, buf, NULL, imgwidth, imgheight, TF_RGBA32))
{
BZ_Free(tex->fallbackdata);
tex->fallbackdata = NULL;
@ -4050,12 +4063,11 @@ void Image_LoadHiResTextureWorker(void *ctx, void *data, size_t a, size_t b)
if (tex->fallbackdata)
{
if (Image_LoadRawTexture(tex, tex->flags, tex->fallbackdata, tex->fallbackwidth, tex->fallbackheight, tex->fallbackfmt))
if (Image_LoadRawTexture(tex, tex->flags, tex->fallbackdata, (char*)tex->fallbackdata+(tex->fallbackwidth*tex->fallbackheight), tex->fallbackwidth, tex->fallbackheight, tex->fallbackfmt))
{
tex->fallbackdata = NULL;
return;
}
BZ_Free(tex->fallbackdata);
tex->fallbackdata = NULL;
}
@ -4235,7 +4247,7 @@ typedef struct
{
char *name;
char *legacyname;
int minimize, minmip, maximize;
int maximize, minmip, minimize;
} texmode_t;
static texmode_t texmodes[] = {
{"n", "GL_NEAREST", 0, -1, 0},

View file

@ -431,13 +431,14 @@ void Con_ExecuteLine(console_t *con, char *line)
Cbuf_AddText (line, RESTRICT_LOCAL);
else
{
char *exec = NULL;
if (line[0] == '\\' || line[0] == '/')
Cbuf_AddText (line+1, RESTRICT_LOCAL); // skip the >
exec = line+1; // skip the slash
else if (cl_chatmode.value == 2 && Cmd_IsCommand(line))
Cbuf_AddText (line, RESTRICT_LOCAL); // valid command
exec = line; // valid command
#ifdef Q2CLIENT
else if (cls.protocol == CP_QUAKE2)
Cbuf_AddText (line, RESTRICT_LOCAL); // send the command to the server via console, and let the server convert to chat
exec = line; // send the command to the server via console, and let the server convert to chat
#endif
else if (*line)
{ // convert to a chat message
@ -448,8 +449,29 @@ void Con_ExecuteLine(console_t *con, char *line)
else
Cbuf_AddText ("say ", RESTRICT_LOCAL);
waschat = true;
Cbuf_AddText (line, RESTRICT_LOCAL);
}
Cbuf_AddText (line, RESTRICT_LOCAL); // skip the >
}
if (exec)
{
#ifdef TEXTEDITOR
extern qboolean editormodal;
if (editormodal)
{
char cvarname[128];
COM_ParseOut(exec, cvarname, sizeof(cvarname));
if (Cvar_FindVar(cvarname) && !strchr(line, ';') && !strchr(line, '\n'))
{
Con_Printf ("]%s\n",line);
Cmd_ExecuteString(exec, RESTRICT_SERVER);
return;
}
Con_Footerf(false, "Commands cannot be execed while debugging QC");
}
#endif
Cbuf_AddText (exec, RESTRICT_LOCAL);
}
}
@ -1888,6 +1910,9 @@ qboolean Key_MouseShouldBeFree(void)
if (key_dest_absolutemouse & key_dest_mask)
return true;
if (Key_Dest_Has(kdm_editor))
return true;
// if (!ActiveApp)
// return true;

View file

@ -1090,12 +1090,6 @@ char *Media_NextTrack(int musicchannelnum)
#undef lTime
#ifdef OFFSCREENGECKO
#include "offscreengecko/embedding.h"
#include "offscreengecko/browser.h"
#endif
///temporary residence for media handling
#include "roq.h"
@ -1282,7 +1276,7 @@ struct cin_s
void (*cursormove) (struct cin_s *cin, float posx, float posy); //pos is 0-1
void (*key) (struct cin_s *cin, int code, int unicode, int event);
qboolean (*setsize) (struct cin_s *cin, int width, int height);
void (*getsize) (struct cin_s *cin, int *width, int *height);
void (*getsize) (struct cin_s *cin, int *width, int *height, float *aspect);
void (*changestream) (struct cin_s *cin, const char *streamname);
@ -1295,6 +1289,7 @@ struct cin_s
qbyte *outpalette;
int outunchanged;
qboolean ended;
float filmpercentage;
texid_t texture;
@ -1322,14 +1317,6 @@ struct cin_s
} avi;
#endif
#ifdef OFFSCREENGECKO
struct {
OSGK_Browser *gbrowser;
int bwidth;
int bheight;
} gecko;
#endif
#ifdef PLUGINS
struct {
void *ctx;
@ -1411,6 +1398,7 @@ qboolean Media_WinAvi_DecodeFrame(cin_t *cin, qboolean nosound)
Con_DPrintf("Dropped %i frame(s)\n", (newframei - cin->currentframe)-1);
cin->currentframe = newframei;
cin->filmpercentage = (float)cin->currentframe / cin->avi.num_frames;
if (newframei>=cin->avi.num_frames)
{
@ -1711,10 +1699,9 @@ static qboolean Media_Plugin_DecodeFrame(cin_t *cin, qboolean nosound)
cin->outunchanged = (cin->outdata==NULL);
if (cin->outtype != TF_INVALID)
return true;
cin->ended = true;
return false;
cin->filmpercentage = 0;
cin->ended = (cin->outtype == TF_INVALID);
return !cin->ended;
}
static void Media_Plugin_DoneFrame(cin_t *cin)
{
@ -1774,7 +1761,7 @@ qboolean Media_Plugin_SetSize(cin_t *cin, int width, int height)
currentplug = oldplug;
return result;
}
void Media_Plugin_GetSize(cin_t *cin, int *width, int *height)
void Media_Plugin_GetSize(cin_t *cin, int *width, int *height, float *aspect)
{
struct plugin_s *oldplug = currentplug;
currentplug = cin->plugin.plug;
@ -1875,6 +1862,8 @@ qboolean Media_Roq_DecodeFrame (cin_t *cin, qboolean nosound)
qbyte *framedata;
cin->filmpercentage = cin->roq.roqfilm->frame_num / cin->roq.roqfilm->num_frames;
cin->filmlasttime = (float)realtime;
if (!(curtime<cin->nextframetime)) //roq file was read properly
@ -2121,286 +2110,6 @@ cin_t *Media_Cin_TryLoad(char *name)
//Quake2 CIN Support
//////////////////////////////////////////////////////////////////////////////////
//Gecko Support
#ifdef OFFSCREENGECKO
int (VARGS *posgk_release) (OSGK_BaseObject* obj);
OSGK_Browser* (VARGS *posgk_browser_create) (OSGK_Embedding* embedding, int width, int height);
void (VARGS *posgk_browser_resize) (OSGK_Browser* browser, int width, int height);
void (VARGS *posgk_browser_navigate) (OSGK_Browser* browser, const char* uri);
const unsigned char* (VARGS *posgk_browser_lock_data) (OSGK_Browser* browser, int* isDirty);
void (VARGS *posgk_browser_unlock_data) (OSGK_Browser* browser, const unsigned char* data);
void (VARGS *posgk_browser_event_mouse_move) (OSGK_Browser* browser, int x, int y);
void (VARGS *posgk_browser_event_mouse_button) (OSGK_Browser* browser, OSGK_MouseButton button, OSGK_MouseButtonEventType eventType);
int (VARGS *posgk_browser_event_key) (OSGK_Browser* browser, unsigned int key, OSGK_KeyboardEventType eventType);
OSGK_EmbeddingOptions* (VARGS *posgk_embedding_options_create) (void);
OSGK_Embedding* (VARGS *posgk_embedding_create2) (unsigned int apiVer, OSGK_EmbeddingOptions* options, OSGK_GeckoResult* geckoResult);
void (VARGS *posgk_embedding_options_set_profile_dir) (OSGK_EmbeddingOptions* options, const char* profileDir, const char* localProfileDir);
void (VARGS *posgk_embedding_options_add_search_path) (OSGK_EmbeddingOptions* options, const char* path);
dllhandle_t geckodll;
dllfunction_t gecko_functions[] =
{
{(void**)&posgk_release, "osgk_release"},
{(void**)&posgk_browser_create, "osgk_browser_create"},
{(void**)&posgk_browser_resize, "osgk_browser_resize"},
{(void**)&posgk_browser_navigate, "osgk_browser_navigate"},
{(void**)&posgk_browser_lock_data, "osgk_browser_lock_data"},
{(void**)&posgk_browser_unlock_data, "osgk_browser_unlock_data"},
{(void**)&posgk_browser_event_mouse_move, "osgk_browser_event_mouse_move"},
{(void**)&posgk_browser_event_mouse_button, "osgk_browser_event_mouse_button"},
{(void**)&posgk_browser_event_key, "osgk_browser_event_key"},
{(void**)&posgk_embedding_options_create, "osgk_embedding_options_create"},
{(void**)&posgk_embedding_create2, "osgk_embedding_create2"},
{(void**)&posgk_embedding_options_set_profile_dir, "osgk_embedding_options_set_profile_dir"},
{(void**)&posgk_embedding_options_add_search_path, "osgk_embedding_options_add_search_path"},
{NULL}
};
OSGK_Embedding *gecko_embedding;
void Media_Gecko_Shutdown(struct cin_s *cin)
{
posgk_release(&cin->gecko.gbrowser->baseobj);
}
qboolean Media_Gecko_DecodeFrame(cin_t *cin, qboolean nosound)
{
cin->outdata = (char*)posgk_browser_lock_data(cin->gecko.gbrowser, &cin->outunchanged);
cin->outwidth = cin->gecko.bwidth;
cin->outheight = cin->gecko.bheight;
cin->outtype = TF_BGRA32;
return !!cin->gecko.gbrowser;
}
void Media_Gecko_DoneFrame(cin_t *cin)
{
posgk_browser_unlock_data(cin->gecko.gbrowser, cin->outdata);
cin->outdata = NULL;
}
void Media_Gecko_MoveCursor (struct cin_s *cin, float posx, float posy)
{
posgk_browser_event_mouse_move(cin->gecko.gbrowser, posx*cin->gecko.bwidth, posy*cin->gecko.bheight);
}
void Media_Gecko_KeyPress (struct cin_s *cin, int code, int unicode, int event)
{
if (code >= K_MOUSE1 && code < K_MOUSE10)
{
posgk_browser_event_mouse_button(cin->gecko.gbrowser, code - K_MOUSE1, (event==3)?2:event);
}
else
{
switch(code)
{
case K_BACKSPACE:
code = OSGKKey_Backspace;
break;
case K_TAB:
code = OSGKKey_Tab;
break;
case K_ENTER:
code = OSGKKey_Return;
break;
case K_LSHIFT:
case K_RSHIFT:
code = OSGKKey_Shift;
break;
case K_LCTRL:
case K_RCTRL:
code = OSGKKey_Control;
break;
case K_LALT:
case K_RALT:
code = OSGKKey_Alt;
break;
case K_CAPSLOCK:
code = OSGKKey_CapsLock;
break;
case K_ESCAPE:
code = OSGKKey_Escape;
break;
case K_SPACE:
code = OSGKKey_Space;
break;
case K_PGUP:
code = OSGKKey_PageUp;
break;
case K_PGDN:
code = OSGKKey_PageDown;
break;
case K_END:
code = OSGKKey_End;
break;
case K_HOME:
code = OSGKKey_Home;
break;
case K_LEFTARROW:
code = OSGKKey_Left;
break;
case K_UPARROW:
code = OSGKKey_Up;
break;
case K_RIGHTARROW:
code = OSGKKey_Right;
break;
case K_DOWNARROW:
code = OSGKKey_Down;
break;
case K_INS:
code = OSGKKey_Insert;
break;
case K_DEL:
code = OSGKKey_Delete;
break;
case K_F1:
code = OSGKKey_F1;
break;
case K_F2:
code = OSGKKey_F2;
break;
case K_F3:
code = OSGKKey_F3;
break;
case K_F4:
code = OSGKKey_F4;
break;
case K_F5:
code = OSGKKey_F5;
break;
case K_F6:
code = OSGKKey_F6;
break;
case K_F7:
code = OSGKKey_F7;
break;
case K_F8:
code = OSGKKey_F8;
break;
case K_F9:
code = OSGKKey_F9;
break;
case K_F10:
code = OSGKKey_F10;
break;
case K_F11:
code = OSGKKey_F11;
break;
case K_F12:
code = OSGKKey_F12;
break;
case K_KP_NUMLOCK:
code = OSGKKey_NumLock;
break;
case K_SCRLCK:
code = OSGKKey_ScrollLock;
break;
case K_LWIN:
code = OSGKKey_Meta;
break;
default:
code = unicode;
break;
}
posgk_browser_event_key(cin->gecko.gbrowser, code, kePress);
//posgk_browser_event_key(cin->gecko.gbrowser, code, event);
}
}
qboolean Media_Gecko_SetSize (struct cin_s *cin, int width, int height)
{
if (width < 4 || height < 4)
return false;
posgk_browser_resize(cin->gecko.gbrowser, width, height);
cin->gecko.bwidth = width;
cin->gecko.bheight = height;
return true;
}
void Media_Gecko_GetSize (struct cin_s *cin, int *width, int *height)
{
*width = cin->gecko.bwidth;
*height = cin->gecko.bheight;
}
void Media_Gecko_ChangeStream (struct cin_s *cin, char *streamname)
{
posgk_browser_navigate(cin->gecko.gbrowser, streamname);
}
cin_t *Media_Gecko_TryLoad(char *name)
{
char xulprofiledir[MAX_OSPATH];
cin_t *cin;
if (!strncmp(name, "http://", 7))
{
OSGK_GeckoResult result;
OSGK_EmbeddingOptions *opts;
if (!gecko_embedding)
{
geckodll = Sys_LoadLibrary("OffscreenGecko", gecko_functions);
if (!geckodll)
{
Con_Printf("OffscreenGecko not installed\n");
return NULL;
}
opts = posgk_embedding_options_create();
if (!opts)
return NULL;
posgk_embedding_options_add_search_path(opts, "./xulrunner/");
if (FS_NativePath("xulrunner_profile/", FS_ROOT, xulprofiledir, sizeof(xulprofiledir)))
posgk_embedding_options_set_profile_dir(opts, xulprofiledir, 0);
gecko_embedding = posgk_embedding_create2(OSGK_API_VERSION, opts, &result);
posgk_release(&opts->baseobj);
if (!gecko_embedding)
return NULL;
}
cin = Z_Malloc(sizeof(cin_t));
cin->filmtype = MFT_OFSGECKO;
cin->decodeframe = Media_Gecko_DecodeFrame;
cin->doneframe = Media_Gecko_DoneFrame;
cin->shutdown = Media_Gecko_Shutdown;
cin->cursormove = Media_Gecko_MoveCursor;
cin->key = Media_Gecko_KeyPress;
cin->setsize = Media_Gecko_SetSize;
cin->getsize = Media_Gecko_GetSize;
cin->changestream = Media_Gecko_ChangeStream;
cin->gecko.bwidth = 1024;
cin->gecko.bheight = 1024;
cin->gecko.gbrowser = posgk_browser_create(gecko_embedding, cin->gecko.bwidth, cin->gecko.bheight);
if (!cin->gecko.gbrowser)
{
Con_Printf("osgk_browser_create failed, your version of xulrunner is likely unsupported\n");
Z_Free(cin);
return NULL;
}
posgk_browser_navigate(cin->gecko.gbrowser, name);
return cin;
}
return NULL;
}
#endif
//Gecko Support
//////////////////////////////////////////////////////////////////////////////////
qboolean Media_PlayingFullScreen(void)
{
@ -2434,11 +2143,6 @@ cin_t *Media_StartCin(char *name)
if (!name || !*name) //clear only.
return NULL;
#ifdef OFFSCREENGECKO
if (!cin)
cin = Media_Gecko_TryLoad(name);
#endif
if (!cin)
cin = Media_Static_TryLoad(name);
@ -2678,14 +2382,6 @@ texid_tf Media_UpdateForShader(cin_t *cin)
}
#endif
void Media_Send_Command(cin_t *cin, const char *command)
{
if (!cin)
cin = R_ShaderGetCinematic(videoshader);
if (!cin || !cin->changestream)
return;
cin->changestream(cin, command);
}
void Media_Send_KeyEvent(cin_t *cin, int button, int unicode, int event)
{
if (!cin)
@ -2710,20 +2406,48 @@ void Media_Send_Resize(cin_t *cin, int x, int y)
return;
cin->setsize(cin, x, y);
}
void Media_Send_GetSize(cin_t *cin, int *x, int *y)
void Media_Send_GetSize(cin_t *cin, int *x, int *y, float *aspect)
{
*x = 0;
*y = 0;
*aspect = 0;
if (!cin)
cin = R_ShaderGetCinematic(videoshader);
if (!cin || !cin->getsize)
return;
cin->getsize(cin, x, y);
cin->getsize(cin, x, y, aspect);
}
void Media_Send_Reset(cin_t *cin)
{
if (!cin || !cin->rewind)
cin->rewind(cin);
}
void Media_Send_Command(cin_t *cin, const char *command)
{
if (!cin)
cin = R_ShaderGetCinematic(videoshader);
if (cin && cin->changestream)
cin->changestream(cin, command);
else if (cin && cin->rewind && !strcmp(command, "cmd:rewind"))
cin->rewind(cin);
}
void Media_Send_GetPositions(cin_t *cin, qboolean *active, float *curtime, float *duration)
{
if (!cin)
cin = R_ShaderGetCinematic(videoshader);
if (cin)
{
*active = true && !cin->ended;
*curtime = Sys_DoubleTime() - cin->filmstarttime;
*duration = cin->filmpercentage;
}
else
{
*active = false;
*curtime = 0;
*duration = 0;
}
}
void Media_PlayFilm_f (void)
@ -3449,7 +3173,7 @@ void Media_CaptureDemoEnd(void)
if (recordingdemo)
Media_StopRecordFilm_f();
}
void CL_PlayDemo(char *demoname);
void CL_PlayDemo(char *demoname, qboolean usesystempath);
void Media_RecordDemo_f(void)
{
if (Cmd_Argc() < 2)
@ -3457,7 +3181,7 @@ void Media_RecordDemo_f(void)
if (Cmd_FromGamecode())
return;
CL_PlayDemo(Cmd_Argv(1));
CL_PlayDemo(Cmd_Argv(1), false);
if (Cmd_Argc() > 2)
Cmd_ShiftArgs(1, false);
Media_RecordFilm_f();
@ -4174,6 +3898,7 @@ void Media_Init(void)
#endif
Media_RegisterEncoder(NULL, &capture_raw);
Cmd_AddCommand("playvideo", Media_PlayFilm_f);
Cmd_AddCommand("playfilm", Media_PlayFilm_f);
Cmd_AddCommand("cinematic", Media_PlayFilm_f);
Cmd_AddCommand("music_fforward", Media_FForward_f);

View file

@ -278,7 +278,7 @@ typedef struct {
int match;
} q2skinsearch_t;
int QDECL q2skin_enumerate(const char *name, qofs_t fsize, void *parm, searchpathfuncs_t *spath)
int QDECL q2skin_enumerate(const char *name, qofs_t fsize, time_t mtime, void *parm, searchpathfuncs_t *spath)
{
char blah[MAX_QPATH];
q2skinsearch_t *s = parm;

View file

@ -568,7 +568,7 @@ static qboolean M_DemoKey(menucustom_t *control, menu_t *menu, int key)
if (extnum == info->numext) //wasn't on our list of extensions.
extnum = 0;
Cbuf_AddText(va("%s \"%s%s\"\n", info->command[extnum], (info->fsroot==FS_ROOT)?"#":"", info->selected->name), RESTRICT_LOCAL);
Cbuf_AddText(va("%s \"%s%s\"\n", info->command[extnum], (info->fsroot==FS_SYSTEM)?"#":"", info->selected->name), RESTRICT_LOCAL);
M_RemoveMenu(menu);
}
}
@ -577,7 +577,7 @@ static qboolean M_DemoKey(menucustom_t *control, menu_t *menu, int key)
return false;
}
static int QDECL DemoAddItem(const char *filename, qofs_t size, void *parm, searchpathfuncs_t *spath)
static int QDECL DemoAddItem(const char *filename, qofs_t size, time_t modified, void *parm, searchpathfuncs_t *spath)
{
int extnum;
demomenu_t *menu = parm;
@ -769,18 +769,18 @@ static void ShowDemoMenu (menu_t *menu, const char *path)
if (s && strchr(s+1, '/'))
{
Q_snprintfz(match, sizeof(match), "%s../", info->path);
DemoAddItem(match, 0, info, NULL);
DemoAddItem(match, 0, 0, info, NULL);
}
}
else if (*info->path)
{
Q_snprintfz(match, sizeof(match), "%s../", info->path);
DemoAddItem(match, 0, info, NULL);
DemoAddItem(match, 0, 0, info, NULL);
}
else if (info->fsroot == FS_GAME)
{
Q_snprintfz(match, sizeof(match), "../");
DemoAddItem(match, 0, info, NULL);
DemoAddItem(match, 0, 0, info, NULL);
}
if (info->fsroot == FS_SYSTEM)
{

View file

@ -23,14 +23,15 @@ typedef enum
#define MAX_BONE_CONTROLLERS 5
#endif
#define FRAME_BLENDS 4
#define FST_BASE 0 //base frames
#define FS_REG 1 //regular frames
#define FS_COUNT 2 //regular frames
typedef struct {
struct {
int frame[2];
float frametime[2];
float lerpfrac;
struct framestateregion_s {
int frame[FRAME_BLENDS];
float frametime[FRAME_BLENDS];
float lerpweight[FRAME_BLENDS];
#ifdef HALFLIFEMODELS
float subblendfrac; //hl models are weird
@ -78,6 +79,7 @@ void R2D_ConsoleBackground (int firstline, int lastline, qboolean forceopaque);
void R2D_EditorBackground (void);
void R2D_Image(float x, float y, float w, float h, float s1, float t1, float s2, float t2, mpic_t *pic);
void R2D_Image2dQuad(vec2_t points[], vec2_t texcoords[], mpic_t *pic);
void R2D_ImageColours(float r, float g, float b, float a);
void R2D_ImagePaletteColour(unsigned int i, float a);
@ -105,10 +107,10 @@ extern void SCR_EraseCenterString (void);
extern void SCR_CenterPrint (int pnum, char *str, qboolean skipgamecode);
void R_DrawTextField(int x, int y, int w, int h, const char *text, unsigned int defaultmask, unsigned int fieldflags);
#define CPRINT_BALIGN (1<<0) //B
#define CPRINT_LALIGN (1<<0) //L
#define CPRINT_TALIGN (1<<1) //T
#define CPRINT_LALIGN (1<<2) //L
#define CPRINT_RALIGN (1<<3) //R
#define CPRINT_RALIGN (1<<2) //R
#define CPRINT_BALIGN (1<<3) //B
#define CPRINT_BACKGROUND (1<<4) //P
#define CPRINT_OBITUARTY (1<<16) //O (show at 2/3rds from top)

View file

@ -275,6 +275,8 @@ void SV_Master_Worker_Resolved(void *ctx, void *data, size_t a, size_t b)
{
switch (master->protocol)
{
case MP_UNSPECIFIED:
case MP_NETQUAKE:
case MP_DPMASTER: na->port = BigShort (27950); break;
case MP_QUAKE2: na->port = BigShort (27000); break; //FIXME: verify
case MP_QUAKE3: na->port = BigShort (27950); break;

View file

@ -359,7 +359,7 @@ void QCBUILTIN PF_cl_runningserver (pubprogfuncs_t *prinst, struct globalvars_s
#ifndef NOMEDIA
// #487 float(string name) gecko_create
void QCBUILTIN PF_cs_gecko_create (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
void QCBUILTIN PF_cs_media_create_http (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
const char *shadername = PR_GetStringOfs(prinst, OFS_PARM0);
cin_t *cin;
@ -385,17 +385,17 @@ void QCBUILTIN PF_cs_gecko_create (pubprogfuncs_t *prinst, struct globalvars_s *
G_FLOAT(OFS_RETURN) = 0;
}
// #488 void(string name) gecko_destroy
void QCBUILTIN PF_cs_gecko_destroy (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
void QCBUILTIN PF_cs_media_destroy (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
const char *shader = PR_GetStringOfs(prinst, OFS_PARM0);
cin_t *cin;
cin = R_ShaderFindCinematic(shader);
if (!cin)
return;
Media_Send_Reset(cin); //FIXME
Media_Send_Reset(cin); //FIXME. unloading shaders can be dangerous
}
// #489 void(string name, string URI) gecko_navigate
void QCBUILTIN PF_cs_gecko_navigate (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
void QCBUILTIN PF_cs_media_command (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
const char *shader = PR_GetStringOfs(prinst, OFS_PARM0);
const char *command = PR_GetStringOfs(prinst, OFS_PARM1);
@ -406,7 +406,7 @@ void QCBUILTIN PF_cs_gecko_navigate (pubprogfuncs_t *prinst, struct globalvars_s
Media_Send_Command(cin, command);
}
// #490 float(string name, float key, float eventtype) gecko_keyevent
void QCBUILTIN PF_cs_gecko_keyevent (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
void QCBUILTIN PF_cs_media_keyevent (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
const char *shader = PR_GetStringOfs(prinst, OFS_PARM0);
int key = G_FLOAT(OFS_PARM1);
@ -418,7 +418,7 @@ void QCBUILTIN PF_cs_gecko_keyevent (pubprogfuncs_t *prinst, struct globalvars_s
Media_Send_KeyEvent(cin, MP_TranslateQCtoFTECodes(key), (key>127)?0:key, eventtype);
}
// #491 void(string name, float x, float y) gecko_mousemove
void QCBUILTIN PF_cs_gecko_mousemove (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
void QCBUILTIN PF_cs_media_mousemove (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
const char *shader = PR_GetStringOfs(prinst, OFS_PARM0);
float posx = G_FLOAT(OFS_PARM1);
@ -430,7 +430,7 @@ void QCBUILTIN PF_cs_gecko_mousemove (pubprogfuncs_t *prinst, struct globalvars_
Media_Send_MouseMove(cin, posx, posy);
}
// #492 void(string name, float w, float h) gecko_resize
void QCBUILTIN PF_cs_gecko_resize (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
void QCBUILTIN PF_cs_media_resize (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
const char *shader = PR_GetStringOfs(prinst, OFS_PARM0);
float sizex = G_FLOAT(OFS_PARM1);
@ -442,25 +442,34 @@ void QCBUILTIN PF_cs_gecko_resize (pubprogfuncs_t *prinst, struct globalvars_s *
Media_Send_Resize(cin, sizex, sizey);
}
// #493 vector(string name) gecko_get_texture_extent
void QCBUILTIN PF_cs_gecko_get_texture_extent (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
void QCBUILTIN PF_cs_media_get_texture_extent (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
const char *shader = PR_GetStringOfs(prinst, OFS_PARM0);
float *ret = G_VECTOR(OFS_RETURN);
int sx, sy;
int sx = 0, sy = 0;
float aspect = 0;
cin_t *cin;
cin = R_ShaderFindCinematic(shader);
if (cin)
{
Media_Send_GetSize(cin, &sx, &sy);
}
else
{
sx = 0;
sy = 0;
}
Media_Send_GetSize(cin, &sx, &sy, &aspect);
ret[0] = sx;
ret[1] = sy;
ret[2] = 0;
ret[2] = aspect;
}
void QCBUILTIN PF_cs_media_getposition (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
const char *shader = PR_GetStringOfs(prinst, OFS_PARM0);
float *ret = G_VECTOR(OFS_RETURN);
qboolean active = false;
float curtime = 0;
float duration = 0;
cin_t *cin;
cin = R_ShaderFindCinematic(shader);
if (cin)
Media_Send_GetPositions(cin, &active, &curtime, &duration);
ret[0] = active;
ret[1] = curtime;
ret[2] = duration;
}
#endif
@ -683,4 +692,33 @@ void QCBUILTIN PF_cl_SetBindMap (pubprogfuncs_t *prinst, struct globalvars_s *pr
G_FLOAT(OFS_RETURN) = 0;
}
//evil builtins to pretend to be a server.
void QCBUILTIN PF_cl_sprint (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
//this is a bit pointless for menus as it doesn't know player names or anything.
#ifndef CLIENTONLY
int clientnum = G_FLOAT(OFS_PARM0);
char *str = PF_VarString(prinst, 1, pr_globals);
if (sv.active && clientnum < sv.allocated_client_slots && svs.clients[clientnum].state >= cs_connected)
SV_PrintToClient(&svs.clients[clientnum], PRINT_HIGH, str);
#endif
}
void QCBUILTIN PF_cl_bprint (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
#ifndef CLIENTONLY
char *str = PF_VarString(prinst, 0, pr_globals);
if (sv.active)
SV_BroadcastPrintf(PRINT_HIGH, "%s", str);
#endif
}
void QCBUILTIN PF_cl_clientcount (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
#ifndef CLIENTONLY
if (sv.active)
G_FLOAT(OFS_RETURN) = sv.allocated_client_slots;
else
G_FLOAT(OFS_RETURN) = 0;
#endif
}
#endif

View file

@ -75,7 +75,7 @@ static qboolean csqc_worldchanged; //make sure any caches are rebuilt properly b
static char csqc_printbuffer[8192];
#define CSQCPROGSGROUP "CSQC progs control"
cvar_t pr_csqc_maxedicts = CVAR("pr_csqc_maxedicts", "8192"); //not tied to protocol nor server.
cvar_t pr_csqc_maxedicts = CVAR("pr_csqc_maxedicts", "65536"); //not tied to protocol nor server.
cvar_t pr_csqc_memsize = CVAR("pr_csqc_memsize", "-1");
cvar_t cl_csqcdebug = CVAR("cl_csqcdebug", "0"); //prints entity numbers which arrive (so I can tell people not to apply it to players...)
cvar_t cl_nocsqc = CVAR("cl_nocsqc", "0");
@ -180,6 +180,9 @@ extern sfx_t *cl_sfx_r_exp3;
globalvector(input_cursor_start, "input_cursor_trace_start"); /*float filled by getinputstate*/ \
globalvector(input_cursor_impact, "input_cursor_trace_endpos"); /*float filled by getinputstate*/ \
globalfloat(input_cursor_entitynumber, "input_cursor_entitynumber"); /*float filled by getinputstate*/ \
\
globalfloat(autocvar_vid_conwidth, "autocvar_vid_conwidth"); /*float hackfix for dp mods*/ \
globalfloat(autocvar_vid_conheight, "autocvar_vid_conheight"); /*float hackfix for dp mods*/ \
typedef struct {
@ -203,6 +206,7 @@ static csqcglobals_t csqcg;
playerview_t csqc_nullview;
void VARGS CSQC_Abort (char *format, ...); //an error occured.
static void cs_set_input_state (usercmd_t *cmd);
//fixme: we should be using entity numbers, not view numbers.
static void CSQC_ChangeLocalPlayer(int seat)
@ -235,19 +239,31 @@ static void CSQC_ChangeLocalPlayer(int seat)
csqcg.view_angles[1] = csqc_playerview->viewangles[1];
csqcg.view_angles[2] = csqc_playerview->viewangles[2];
}
if (dpcompat_corruptglobals.ival || csqc_isdarkplaces)
if ((dpcompat_corruptglobals.ival || csqc_isdarkplaces) && (unsigned int)seat < MAX_SPLITS)
{
extern usercmd_t independantphysics[MAX_SPLITS];
int i;
usercmd_t *cmd = &independantphysics[seat];
usercmd_t tmp = *cmd;
cmd = &tmp;
for (i=0 ; i<3 ; i++)
cmd->angles[i] = ((int)(csqc_playerview->viewangles[i]*65536.0/360)&65535);
if (!cmd->msec)
CL_BaseMove (cmd, seat, 0, 72);
cmd->msec = (realtime - cl.outframes[(cl.movesequence-1)&UPDATE_MASK].senttime)*1000;
cs_set_input_state(cmd);
if (csqcg.pmove_org)
{
csqcg.pmove_org[0] = csqc_playerview->simorg[0];
csqcg.pmove_org[1] = csqc_playerview->simorg[1];
csqcg.pmove_org[2] = csqc_playerview->simorg[2];
}
if (csqcg.input_angles)
if (csqcg.pmove_vel)
{
csqcg.input_angles[0] = csqc_playerview->viewangles[0];
csqcg.input_angles[1] = csqc_playerview->viewangles[1];
csqcg.input_angles[2] = csqc_playerview->viewangles[2];
csqcg.pmove_vel[0] = csqc_playerview->simvel[0];
csqcg.pmove_vel[1] = csqc_playerview->simvel[1];
csqcg.pmove_vel[2] = csqc_playerview->simvel[2];
}
}
}
@ -359,7 +375,7 @@ typedef struct csqcedict_s
/*the above is shared with qclib*/
link_t area;
pvscache_t pvsinfo;
#ifdef USEODE
#ifdef USERBE
entityode_t ode;
#endif
qbyte solidtype;
@ -415,9 +431,8 @@ static int csqcentsize;
static const char *csqcmapentitydata;
static qboolean csqcmapentitydataloaded;
qboolean csqc_deprecated_warned;
#define csqc_deprecated(s) do {if (!csqc_deprecated_warned){Con_Printf("csqc warning: %s\n", s); PR_StackTrace (prinst, false); csqc_deprecated_warned = true;}}while(0)
static unsigned int csqc_deprecated_warned;
#define csqc_deprecated(s) do {if (!csqc_deprecated_warned++){Con_Printf("csqc warning: %s\n", s); PR_StackTrace (prinst, false);}}while(0)
static model_t *CSQC_GetModelForIndex(int index);
@ -454,7 +469,8 @@ static void cs_getframestate(csqcedict_t *in, unsigned int rflags, framestate_t
out->g[FST_BASE].frame[0] = in->xv->baseframe;
out->g[FST_BASE].frame[1] = in->xv->baseframe2;
out->g[FST_BASE].lerpfrac = in->xv->baselerpfrac;
out->g[FST_BASE].lerpweight[1] = in->xv->baselerpfrac;
out->g[FST_BASE].lerpweight[0] = 1-out->g[FST_BASE].lerpweight[1];
if (rflags & CSQCRF_FRAMETIMESARESTARTTIMES)
{
out->g[FST_BASE].frametime[0] = *csqcg.simtime - in->xv->baseframe1time;
@ -470,16 +486,25 @@ static void cs_getframestate(csqcedict_t *in, unsigned int rflags, framestate_t
//and the normal frames.
out->g[FS_REG].frame[0] = in->v->frame;
out->g[FS_REG].frame[1] = in->xv->frame2;
out->g[FS_REG].lerpfrac = in->xv->lerpfrac;
if (rflags & CSQCRF_FRAMETIMESARESTARTTIMES)
out->g[FS_REG].frame[2] = in->xv->frame3;
out->g[FS_REG].frame[3] = in->xv->frame4;
out->g[FS_REG].lerpweight[1] = in->xv->lerpfrac;
out->g[FS_REG].lerpweight[2] = in->xv->lerpfrac3;
out->g[FS_REG].lerpweight[3] = in->xv->lerpfrac4;
out->g[FS_REG].lerpweight[0] = 1-(out->g[FS_REG].lerpweight[1]+out->g[FS_REG].lerpweight[2]+out->g[FS_REG].lerpweight[3]);
if ((rflags & CSQCRF_FRAMETIMESARESTARTTIMES) || csqc_isdarkplaces)
{
out->g[FS_REG].frametime[0] = *csqcg.simtime - in->xv->frame1time;
out->g[FS_REG].frametime[1] = *csqcg.simtime - in->xv->frame2time;
out->g[FS_REG].frametime[2] = 0;//*csqcg.simtime - in->xv->frame3time;
out->g[FS_REG].frametime[3] = 0;//*csqcg.simtime - in->xv->frame4time;
}
else
{
out->g[FS_REG].frametime[0] = in->xv->frame1time;
out->g[FS_REG].frametime[1] = in->xv->frame2time;
out->g[FS_REG].frametime[2] = 0;//in->xv->frame3time;
out->g[FS_REG].frametime[3] = 0;//in->xv->frame4time;
}
@ -551,16 +576,32 @@ static void QCBUILTIN PF_cvar (pubprogfuncs_t *prinst, struct globalvars_s *pr_g
//too specific to the prinst's builtins.
static void QCBUILTIN PF_Fixme (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
int binum;
char fname[MAX_QPATH];
if (!prinst->GetBuiltinCallInfo(prinst, &binum, fname, sizeof(fname)))
{
binum = 0;
strcpy(fname, "?unknown?");
}
Con_Printf("\n");
prinst->RunError(prinst, "\nBuiltin %i not implemented.\nCSQC is not compatible.", prinst->lastcalledbuiltinnumber);
prinst->RunError(prinst, "\nBuiltin %i:%s not implemented.\nCSQC is not compatible.", binum, fname);
PR_BIError (prinst, "bulitin not implemented");
}
static void QCBUILTIN PF_NoCSQC (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
int binum;
char fname[MAX_QPATH];
if (!prinst->GetBuiltinCallInfo(prinst, &binum, fname, sizeof(fname)))
{
binum = 0;
strcpy(fname, "?unknown?");
}
Con_Printf("\n");
prinst->RunError(prinst, "\nBuiltin %i does not make sense in csqc.\nCSQC is not compatible.", prinst->lastcalledbuiltinnumber);
prinst->RunError(prinst, "\nBuiltin %i:%s does not make sense in csqc.\nCSQC is not compatible.", binum, fname);
PR_BIError (prinst, "bulitin not implemented");
}
@ -1715,7 +1756,7 @@ static void QCBUILTIN PF_R_RenderScene(pubprogfuncs_t *prinst, struct globalvars
static void QCBUILTIN PF_cs_getstati(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
int stnum = G_FLOAT(OFS_PARM0);
if (stnum >= 128)
if (stnum >= 128 && csqc_isdarkplaces)
G_FLOAT(OFS_RETURN) = csqc_playerview->statsf[stnum];
else
G_INT(OFS_RETURN) = csqc_playerview->stats[stnum];
@ -1736,6 +1777,8 @@ static void QCBUILTIN PF_cs_getstatbits(pubprogfuncs_t *prinst, struct globalvar
count = 1;
G_FLOAT(OFS_RETURN) = (((unsigned int)val)&(((1<<count)-1)<<first))>>first;
}
else if (csqc_isdarkplaces)
G_FLOAT(OFS_RETURN) = (int)csqc_playerview->statsf[stnum]; //stupid. mods like xonotic have a stupid hud if they're actually given any precision
else
G_FLOAT(OFS_RETURN) = csqc_playerview->statsf[stnum];
}
@ -1782,13 +1825,12 @@ static void QCBUILTIN PF_cs_SetSize (pubprogfuncs_t *prinst, struct globalvars_s
e = G_WEDICT(prinst, OFS_PARM0);
if (e->isfree)
{
Con_TPrintf("%s edict was free\n", "setsize");
prinst->pr_trace = 1;
PR_RunWarning(prinst, "%s edict was free\n", "setsize");
return;
}
if (e->readonly)
{
Con_TPrintf("setsize on entity %i\n", e->entnum);
PR_RunWarning(prinst, "setsize on entity %i\n", e->entnum);
return;
}
min = G_VECTOR(OFS_PARM1);
@ -2290,7 +2332,7 @@ static void QCBUILTIN PF_objerror (pubprogfuncs_t *prinst, struct globalvars_s *
Con_Printf("%s", s);
if (developer.value)
prinst->pr_trace = 2;
prinst->debug_trace = 2;
else
{
ED_Free (prinst, ed);
@ -2354,8 +2396,8 @@ static void QCBUILTIN PF_cs_trailparticles (pubprogfuncs_t *prinst, struct globa
float *start = G_VECTOR(OFS_PARM2);
float *end = G_VECTOR(OFS_PARM3);
if (G_INT(OFS_PARM1) >= MAX_EDICTS)
{
if ((unsigned int)G_INT(OFS_PARM1) >= MAX_EDICTS)
{ //ents can't be negative, nor can they be huge (like floats are if expressed as an integer)
efnum = G_FLOAT(OFS_PARM1);
ent = (csqcedict_t*)G_EDICT(prinst, OFS_PARM0);
}
@ -2662,11 +2704,13 @@ static void QCBUILTIN PF_cs_runplayerphysics (pubprogfuncs_t *prinst, struct glo
{
unsigned int msecs;
csqcedict_t *ent;
if (prinst->callargc >= 1)
ent = (void*)G_EDICT(prinst, OFS_PARM0);
else
ent = NULL;
csqcedict_t *ent = (void*)G_EDICT(prinst, OFS_PARM0);
int mt = ent->v->movetype;
if (prinst->callargc < 1)
{
csqc_deprecated("runplayerphysics with no ent");
return;
}
if (!cl.worldmodel)
return; //urm..
@ -2693,47 +2737,30 @@ static void QCBUILTIN PF_cs_runplayerphysics (pubprogfuncs_t *prinst, struct glo
pmove.safeorigin_known = false;
pmove.capsule = false; //FIXME
if (ent)
{
int mt = ent->v->movetype;
if (ent->xv->entnum)
pmove.skipent = ent->xv->entnum;
else
pmove.skipent = -1;
mt &= 255;
switch(mt)
{
default:
case MOVETYPE_WALK:
pmove.pm_type = PM_NORMAL;
break;
case MOVETYPE_NOCLIP:
pmove.pm_type = PM_SPECTATOR;
break;
case MOVETYPE_FLY:
pmove.pm_type = PM_FLY;
break;
}
pmove.jump_held = (int)ent->xv->pmove_flags & PMF_JUMP_HELD;
pmove.waterjumptime = 0;
VectorCopy(ent->v->origin, pmove.origin);
VectorCopy(ent->v->velocity, pmove.velocity);
VectorCopy(ent->v->maxs, pmove.player_maxs);
VectorCopy(ent->v->mins, pmove.player_mins);
}
if (ent->xv->entnum)
pmove.skipent = ent->xv->entnum;
else
pmove.skipent = -1;
mt &= 255;
switch(mt)
{
csqc_deprecated("runplayerphysics with no ent");
if (csqcg.pmove_jump_held)
pmove.jump_held = *csqcg.pmove_jump_held;
if (csqcg.pmove_waterjumptime)
pmove.waterjumptime = *csqcg.pmove_waterjumptime;
VectorCopy(csqcg.pmove_org, pmove.origin);
VectorCopy(csqcg.pmove_vel, pmove.velocity);
VectorCopy(csqcg.pmove_maxs, pmove.player_maxs);
VectorCopy(csqcg.pmove_mins, pmove.player_mins);
default:
case MOVETYPE_WALK:
pmove.pm_type = PM_NORMAL;
break;
case MOVETYPE_NOCLIP:
pmove.pm_type = PM_SPECTATOR;
break;
case MOVETYPE_FLY:
pmove.pm_type = PM_FLY;
break;
}
pmove.jump_held = (int)ent->xv->pmove_flags & PMF_JUMP_HELD;
pmove.waterjumptime = 0;
VectorCopy(ent->v->origin, pmove.origin);
VectorCopy(ent->v->velocity, pmove.velocity);
VectorCopy(ent->v->maxs, pmove.player_maxs);
VectorCopy(ent->v->mins, pmove.player_mins);
CL_SetSolidEntities();
@ -2746,29 +2773,16 @@ static void QCBUILTIN PF_cs_runplayerphysics (pubprogfuncs_t *prinst, struct glo
PM_PlayerMove(1);
}
if (ent)
{
VectorCopy(pmove.angles, ent->v->angles);
ent->v->angles[0] *= -1/3.0f;
VectorCopy(pmove.origin, ent->v->origin);
VectorCopy(pmove.velocity, ent->v->velocity);
ent->xv->pmove_flags = 0;
ent->xv->pmove_flags += pmove.jump_held ? PMF_JUMP_HELD : 0;
ent->xv->pmove_flags += pmove.onladder ? PMF_LADDER : 0;
VectorCopy(pmove.angles, ent->v->angles);
ent->v->angles[0] *= -1/3.0f; //FIXME
VectorCopy(pmove.origin, ent->v->origin);
VectorCopy(pmove.velocity, ent->v->velocity);
ent->xv->pmove_flags = 0;
ent->xv->pmove_flags += pmove.jump_held ? PMF_JUMP_HELD : 0;
ent->xv->pmove_flags += pmove.onladder ? PMF_LADDER : 0;
//fixme: touch triggers?
World_LinkEdict (&csqc_world, (wedict_t*)ent, true);
}
else
{
//Legacy path
if (csqcg.pmove_jump_held)
*csqcg.pmove_jump_held = pmove.jump_held;
if (csqcg.pmove_waterjumptime)
*csqcg.pmove_waterjumptime = pmove.waterjumptime;
VectorCopy(pmove.origin, csqcg.pmove_org);
VectorCopy(pmove.velocity, csqcg.pmove_vel);
}
//fixme: touch triggers?
World_LinkEdict (&csqc_world, (wedict_t*)ent, true);
}
static void QCBUILTIN PF_cs_getentitytoken (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
@ -3675,7 +3689,7 @@ static void QCBUILTIN PF_cs_addprogs (pubprogfuncs_t *prinst, struct globalvars_
newp = -1;
else
{
newp = PR_LoadProgs(prinst, s, NULL, 0);
newp = PR_LoadProgs(prinst, s);
if (newp >= 0)
PR_ProgsAdded(csqcprogs, newp, s);
}
@ -3694,7 +3708,7 @@ static void QCBUILTIN PF_cs_OpenPortal (pubprogfuncs_t *prinst, struct globalvar
portal = G_FLOAT(OFS_PARM0); //old legacy crap.
else
portal = G_WEDICT(prinst, OFS_PARM0)->xv->style; //read the func_areaportal's style field.
CMQ2_SetAreaPortalState(portal, state);
CMQ2_SetAreaPortalState(cl.worldmodel, portal, state);
}
#endif
*/
@ -3706,7 +3720,7 @@ static void QCBUILTIN PF_cs_OpenPortal (pubprogfuncs_t *prinst, struct globalvar
int area1 = portal->pvsinfo.areanum, area2 = portal->pvsinfo.areanum2;
if (area1 == area2 || area1<0 || area2<0)
return;
CMQ3_SetAreaPortalState(portal->pvsinfo.areanum, portal->pvsinfo.areanum2, state);
CMQ3_SetAreaPortalState(cl.worldmodel, portal->pvsinfo.areanum, portal->pvsinfo.areanum2, state);
}
#endif
}
@ -3827,10 +3841,7 @@ static void QCBUILTIN PF_rotatevectorsbytag (pubprogfuncs_t *prinst, struct glob
static void QCBUILTIN PF_cs_break (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
Con_Printf ("break statement\n");
#ifdef TEXTEDITOR
prinst->pr_trace++;
#endif
PR_RunWarning (prinst, "break statement\n");
}
//fixme merge with ssqc
@ -4694,6 +4705,7 @@ static void QCBUILTIN PF_resourcestatus(pubprogfuncs_t *prinst, struct globalvar
}
}
void QCBUILTIN PF_CL_DrawTextField (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
#define PF_FixTen PF_Fixme,PF_Fixme,PF_Fixme,PF_Fixme,PF_Fixme,PF_Fixme,PF_Fixme,PF_Fixme,PF_Fixme,PF_Fixme
@ -4969,7 +4981,7 @@ static struct {
// {"?", PF_Fixme, 313}, // #313
//2d (immediate) operations
// {"drawtextfield", PF_CL_DrawTextField, 314},
{"drawtextfield", PF_CL_DrawTextField, 0/*314*/},
{"drawline", PF_CL_drawline, 315}, // #315 void(float width, vector pos1, vector pos2) drawline (EXT_CSQC)
{"iscachedpic", PF_CL_is_cached_pic, 316}, // #316 float(string name) iscachedpic (EXT_CSQC)
{"precache_pic", PF_CL_precache_pic, 317}, // #317 string(string name, float trywad) precache_pic (EXT_CSQC)
@ -4979,6 +4991,7 @@ static struct {
{"drawcharacter", PF_CL_drawcharacter, 320}, // #320 float(vector position, float character, vector scale, vector rgb, float alpha [, float flag]) drawcharacter (EXT_CSQC, [EXT_CSQC_???])
{"drawrawstring", PF_CL_drawrawstring, 321}, // #321 float(vector position, string text, vector scale, vector rgb, float alpha [, float flag]) drawstring (EXT_CSQC, [EXT_CSQC_???])
{"drawpic", PF_CL_drawpic, 322}, // #322 float(vector position, string pic, vector size, vector rgb, float alpha [, float flag]) drawpic (EXT_CSQC, [EXT_CSQC_???])
{"drawrotpic", PF_CL_drawrotpic, 0},
{"drawfill", PF_CL_drawfill, 323}, // #323 float(vector position, vector size, vector rgb, float alpha [, float flag]) drawfill (EXT_CSQC, [EXT_CSQC_???])
{"drawsetcliparea", PF_CL_drawsetcliparea, 324}, // #324 void(float x, float y, float width, float height) drawsetcliparea (EXT_CSQC_???)
{"drawresetcliparea", PF_CL_drawresetcliparea, 325}, // #325 void(void) drawresetcliparea (EXT_CSQC_???)
@ -4986,6 +4999,7 @@ static struct {
{"drawstring", PF_CL_drawcolouredstring, 326}, // #326
{"stringwidth", PF_CL_stringwidth, 327}, // #327 EXT_CSQC_'DARKPLACES'
{"drawsubpic", PF_CL_drawsubpic, 328}, // #328 EXT_CSQC_'DARKPLACES'
{"drawrotsubpic", PF_CL_drawrotsubpic, 0},
// {"?", PF_Fixme, 329}, // #329 EXT_CSQC_'DARKPLACES'
//330
@ -4997,6 +5011,7 @@ static struct {
{"particleeffectnum", PF_cs_particleeffectnum, 335}, // #335 float(string effectname) particleeffectnum (EXT_CSQC)
{"trailparticles", PF_cs_trailparticles, 336}, // #336 void(float effectnum, entity ent, vector start, vector end) trailparticles (EXT_CSQC),
{"trailparticles_dp", PF_cs_trailparticles, 336}, // #336 DP sucks
{"pointparticles", PF_cs_pointparticles, 337}, // #337 void(float effectnum, vector origin [, vector dir, float count]) pointparticles (EXT_CSQC)
{"cprint", PF_cl_cprint, 338}, // #338 void(string s) cprint (EXT_CSQC)
@ -5126,6 +5141,8 @@ static struct {
{"search_end", PF_search_end, 445}, // #445 void search_end(float handle) (DP_QC_FS_SEARCH)
{"search_getsize", PF_search_getsize, 446}, // #446 float search_getsize(float handle) (DP_QC_FS_SEARCH)
{"search_getfilename", PF_search_getfilename,447}, // #447 string search_getfilename(float handle, float num) (DP_QC_FS_SEARCH)
{"search_getfilesize", PF_search_getfilesize, 0},
{"search_getfilemtime", PF_search_getfilemtime, 0},
{"cvar_string", PF_cvar_string, 448}, // #448 string(float n) cvar_string (DP_QC_CVAR_STRING)
{"findflags", PF_FindFlags, 449}, // #449 entity(entity start, .entity fld, float match) findflags (DP_QC_FINDFLAGS)
@ -5200,13 +5217,14 @@ static struct {
#ifndef NOMEDIA
//DP_GECKO_SUPPORT
{"gecko_create", PF_cs_gecko_create, 487}, // #487 float(string name) gecko_create( string name )
{"gecko_destroy", PF_cs_gecko_destroy, 488}, // #488 void(string name) gecko_destroy( string name )
{"gecko_navigate", PF_cs_gecko_navigate, 489}, // #489 void(string name) gecko_navigate( string name, string URI )
{"gecko_keyevent", PF_cs_gecko_keyevent, 490}, // #490 float(string name) gecko_keyevent( string name, float key, float eventtype )
{"gecko_mousemove", PF_cs_gecko_mousemove, 491}, // #491 void gecko_mousemove( string name, float x, float y )
{"gecko_resize", PF_cs_gecko_resize, 492}, // #492 void gecko_resize( string name, float w, float h )
{"gecko_get_texture_extent",PF_cs_gecko_get_texture_extent, 493}, // #493 vector gecko_get_texture_extent( string name )
{"gecko_create", PF_cs_media_create_http, 487}, // #487 float(string name) gecko_create( string name )
{"gecko_destroy", PF_cs_media_destroy, 488}, // #488 void(string name) gecko_destroy( string name )
{"gecko_navigate", PF_cs_media_command, 489}, // #489 void(string name) gecko_navigate( string name, string URI )
{"gecko_keyevent", PF_cs_media_keyevent, 490}, // #490 float(string name) gecko_keyevent( string name, float key, float eventtype )
{"gecko_mousemove", PF_cs_media_mousemove, 491}, // #491 void gecko_mousemove( string name, float x, float y )
{"gecko_resize", PF_cs_media_resize, 492}, // #492 void gecko_resize( string name, float w, float h )
{"gecko_get_texture_extent",PF_cs_media_get_texture_extent, 493}, // #493 vector gecko_get_texture_extent( string name )
{"media_getposition", PF_cs_media_getposition},
#endif
//DP_QC_CRC16
@ -5217,13 +5235,15 @@ static struct {
//DP_QC_ENTITYDATA
{"numentityfields", PF_numentityfields, 496}, // #496 float() numentityfields
{"findentityfield", PF_findentityfield, 0},
{"entityfieldref", PF_entityfieldref, 0},
{"entityfieldname", PF_entityfieldname, 497}, // #497 string(float fieldnum) entityfieldname
{"entityfieldtype", PF_entityfieldtype, 498}, // #498 float(float fieldnum) entityfieldtype
{"getentityfieldstring", PF_getentityfieldstring, 499}, // #499 string(float fieldnum, entity ent) getentityfieldstring
{"putentityfieldstring", PF_putentityfieldstring, 500}, // #500 float(float fieldnum, entity ent, string s) putentityfieldstring
//DP_SV_WRITEPICTURE
{"WritePicture", PF_ReadPicture, 501}, // #501 void(float to, string s, float sz) WritePicture
{"ReadPicture", PF_ReadPicture, 501}, // #501 void(float to, string s, float sz) WritePicture
{"boxparticles", PF_cs_boxparticles, 502},
@ -5265,7 +5285,7 @@ static struct {
// {"matchpattern", PF_Fixme, 538},
// {"undefined", PF_Fixme, 539},
#ifdef USEODE
#ifdef USERBE
{"physics_enable", PF_physics_enable, 540},
{"physics_addforce", PF_physics_addforce, 541},
{"physics_addtorque", PF_physics_addtorque, 542},
@ -5335,6 +5355,28 @@ int PR_CSQC_BuiltinValid(char *name, int num)
static builtin_t csqc_builtin[800];
static int PDECL PR_CSQC_MapNamedBuiltin(pubprogfuncs_t *progfuncs, int headercrc, const char *builtinname)
{
int i, binum;
for (i = 0;BuiltinList[i].name;i++)
{
if (!strcmp(BuiltinList[i].name, builtinname) && BuiltinList[i].bifunc != PF_Fixme)
{
for (binum = sizeof(csqc_builtin)/sizeof(csqc_builtin[0]); --binum; )
{
if (csqc_builtin[binum] && csqc_builtin[binum] != PF_Fixme && BuiltinList[i].bifunc)
continue;
csqc_builtin[binum] = BuiltinList[i].bifunc;
return binum;
}
Con_Printf("No more builtin slots to allocate for %s\n", builtinname);
break;
}
}
Con_DPrintf("Unknown csqc builtin: %s\n", builtinname);
return 0;
}
@ -5415,9 +5457,12 @@ pbool QDECL CSQC_EntFree (struct edict_s *e)
Mod_WipeSkin(ent->skinobject);
ent->skinobject = 0;
#ifdef USEODE
World_ODE_RemoveFromEntity(&csqc_world, (wedict_t*)ent);
World_ODE_RemoveJointFromEntity(&csqc_world, (wedict_t*)ent);
#ifdef USERBE
if (csqc_world.rbe)
{
csqc_world.rbe->RemoveFromEntity(&csqc_world, (wedict_t*)ent);
csqc_world.rbe->RemoveJointFromEntity(&csqc_world, (wedict_t*)ent);
}
#endif
return true;
@ -5509,9 +5554,8 @@ void CSQC_Shutdown(void)
Cmd_RemoveCommands(CS_ConsoleCommand_f);
#ifdef USEODE
World_ODE_End(&csqc_world);
#endif
if (csqc_world.rbe)
csqc_world.rbe->End(&csqc_world);
Z_Free(csqcdelta_pack_new.e);
memset(&csqcdelta_pack_new, 0, sizeof(csqcdelta_pack_new));
@ -5536,6 +5580,12 @@ void CSQC_Shutdown(void)
in_sensitivityscale = 1;
csqc_world.num_edicts = 0;
if (csqc_deprecated_warned>1)
{
Con_Printf("total %u csqc deprecation warnings suppressed\n", csqc_deprecated_warned-1);
csqc_deprecated_warned = 0;
}
}
//when the qclib needs a file, it calls out to this function.
@ -5800,8 +5850,7 @@ qboolean CSQC_Init (qboolean anycsqc, qboolean csdatenabled, unsigned int checks
csqcprogparms.cwstateop = CSQC_CWStateOp;//CWStateOp;
csqcprogparms.thinktimeop = CSQC_ThinkTimeOp;//ThinkTimeOp;
//used when loading a game
csqcprogparms.builtinsfor = NULL;//builtin_t *(*builtinsfor) (int num); //must return a pointer to the builtins that were used before the state was saved.
csqcprogparms.MapNamedBuiltin = PR_CSQC_MapNamedBuiltin;
csqcprogparms.loadcompleate = NULL;//void (*loadcompleate) (int edictsize); //notification to reset any pointers.
csqcprogparms.memalloc = PR_CB_Malloc;//void *(*memalloc) (int size); //small string allocation malloced and freed randomly
@ -5853,14 +5902,14 @@ qboolean CSQC_Init (qboolean anycsqc, qboolean csdatenabled, unsigned int checks
csqc_isdarkplaces = false;
if (csdatenabled || csqc_singlecheats || anycsqc)
{
csprogsnum = PR_LoadProgs(csqcprogs, "csprogs.dat", NULL, 0);
csprogsnum = PR_LoadProgs(csqcprogs, "csprogs.dat");
if (csprogsnum == -1)
Con_DPrintf("Loaded csprogs.dat\n");
}
if (csqc_singlecheats || anycsqc)
{
csaddonnum = PR_LoadProgs(csqcprogs, "csaddon.dat", NULL, 0);
csaddonnum = PR_LoadProgs(csqcprogs, "csaddon.dat");
if (csaddonnum >= 0)
Con_DPrintf("loaded csaddon.dat...\n");
else
@ -5898,7 +5947,10 @@ qboolean CSQC_Init (qboolean anycsqc, qboolean csdatenabled, unsigned int checks
}
}
CSQC_FindGlobals();
if (csqc_isdarkplaces)
memset(&csqcg, 0, sizeof(csqcg));
else
CSQC_FindGlobals();
csqcentsize = PR_InitEnts(csqcprogs, pr_csqc_maxedicts.value);
@ -5973,13 +6025,15 @@ void CSQC_WorldLoaded(void)
return;
if (csqcmapentitydataloaded)
return;
if (csqc_isdarkplaces)
CSQC_FindGlobals();
csqcmapentitydataloaded = true;
csqcmapentitydata = cl.worldmodel->entities;
csqc_world.worldmodel = cl.worldmodel;
#ifdef USEODE
World_ODE_Start(&csqc_world);
#endif
World_RBE_Start(&csqc_world);
worldent = (csqcedict_t *)EDICT_NUM(csqcprogs, 0);
worldent->v->solid = SOLID_BSP;
@ -5987,6 +6041,18 @@ void CSQC_WorldLoaded(void)
worldent->readonly = false; //just in case
if (csqc_isdarkplaces)
{
if (csqcg.init_function)
{
void *pr_globals = PR_globals(csqcprogs, PR_CURRENT);
G_FLOAT(OFS_PARM0) = CSQC_API_VERSION; //api version
(((string_t *)pr_globals)[OFS_PARM1] = PR_TempString(csqcprogs, FULLENGINENAME));
G_FLOAT(OFS_PARM2) = version_number();
PR_ExecuteProgram(csqcprogs, csqcg.init_function);
}
}
if (csqcg.worldloaded)
PR_ExecuteProgram(csqcprogs, csqcg.worldloaded);
csqcmapentitydata = NULL;
@ -6297,9 +6363,15 @@ qboolean CSQC_DrawView(void)
if (host_frametime > mintic)
host_frametime = mintic;
#ifdef USEODE
World_ODE_Frame(&csqc_world, host_frametime, 800);
#endif
#ifdef USERBE
if (csqc_world.rbe)
{
#ifdef RAGDOLL
rag_doallanimations(&sv.world);
#endif
csqc_world.rbe->Frame(&csqc_world, host_frametime, 800);
}
#endif
World_Physics_Frame(&csqc_world);
csqc_world.physicstime += host_frametime;
@ -6365,6 +6437,11 @@ qboolean CSQC_DrawView(void)
CSQC_RunThreads(); //wake up any qc threads
if (csqcg.autocvar_vid_conwidth)
*csqcg.autocvar_vid_conwidth = vid.width;
if (csqcg.autocvar_vid_conheight)
*csqcg.autocvar_vid_conheight = vid.height;
//EXT_CSQC_1
{
void *pr_globals = PR_globals(csqcprogs, PR_CURRENT);
@ -6378,6 +6455,13 @@ qboolean CSQC_DrawView(void)
else
PR_ExecuteProgram(csqcprogs, csqcg.f_updateview);
if (*r_refdef.rt_destcolour[0].texname)
{
Q_strncpyz(r_refdef.rt_destcolour[0].texname, "", sizeof(r_refdef.rt_destcolour[0].texname));
BE_RenderToTextureUpdate2d(true);
}
return true;
}

View file

@ -475,6 +475,51 @@ void QCBUILTIN PF_CL_drawpic (pubprogfuncs_t *prinst, struct globalvars_s *pr_gl
r2d_be_flags = 0;
}
void QCBUILTIN PF_CL_drawrotpic (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
float *pivot = G_VECTOR(OFS_PARM0);
float *mins = G_VECTOR(OFS_PARM1);
float *maxs = G_VECTOR(OFS_PARM2);
const char *picname = PR_GetStringOfs(prinst, OFS_PARM3);
float *rgb = G_VECTOR(OFS_PARM4);
float alpha = G_FLOAT(OFS_PARM5);
float angle = (G_FLOAT(OFS_PARM6) * M_PI)/180;
int flag = prinst->callargc >= 8?(int) G_FLOAT(OFS_PARM7):0;
vec2_t points[4];
vec2_t tcoords[4];
vec2_t saxis;
vec2_t taxis;
mpic_t *p;
p = R2D_SafeCachePic(picname);
if (!p)
p = R2D_SafePicFromWad(picname);
saxis[0] = cos(angle);
saxis[1] = sin(angle);
taxis[0] = -sin(angle);
taxis[1] = cos(angle);
Vector2MA(pivot, mins[0], saxis, points[0]); Vector2MA(points[0], mins[1], taxis, points[0]);
Vector2MA(pivot, maxs[0], saxis, points[1]); Vector2MA(points[1], mins[1], taxis, points[1]);
Vector2MA(pivot, maxs[0], saxis, points[2]); Vector2MA(points[2], maxs[1], taxis, points[2]);
Vector2MA(pivot, mins[0], saxis, points[3]); Vector2MA(points[3], maxs[1], taxis, points[3]);
Vector2Set(tcoords[0], 0, 0);
Vector2Set(tcoords[1], 1, 0);
Vector2Set(tcoords[2], 1, 1);
Vector2Set(tcoords[3], 0, 1);
r2d_be_flags = PF_SelectDPDrawFlag(flag);
R2D_ImageColours(rgb[0], rgb[1], rgb[2], alpha);
R2D_Image2dQuad(points, tcoords, p);
r2d_be_flags = 0;
G_FLOAT(OFS_RETURN) = 1;
}
void QCBUILTIN PF_CL_drawsubpic (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
float *pos = G_VECTOR(OFS_PARM0);
@ -503,7 +548,50 @@ void QCBUILTIN PF_CL_drawsubpic (pubprogfuncs_t *prinst, struct globalvars_s *pr
G_FLOAT(OFS_RETURN) = 1;
}
void QCBUILTIN PF_CL_drawrotsubpic (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
float *pivot = G_VECTOR(OFS_PARM0);
float *mins = G_VECTOR(OFS_PARM1);
float *maxs = G_VECTOR(OFS_PARM2);
const char *picname = PR_GetStringOfs(prinst, OFS_PARM3);
float *srcPos = G_VECTOR(OFS_PARM4);
float *srcSize = G_VECTOR(OFS_PARM5);
float *rgb = G_VECTOR(OFS_PARM6);
float alpha = G_FLOAT(OFS_PARM7+0);
float angle = (G_FLOAT(OFS_PARM7+1) * M_PI) / 180;
int flag = prinst->callargc >= 8?(int) G_FLOAT(OFS_PARM7+2):0;
vec2_t points[4], tcoords[4];
vec2_t saxis;
vec2_t taxis;
mpic_t *p;
saxis[0] = cos(angle);
saxis[1] = sin(angle);
taxis[0] = -sin(angle);
taxis[1] = cos(angle);
p = R2D_SafeCachePic(picname);
if (!p)
p = R2D_SafePicFromWad(picname);
Vector2MA(pivot, mins[0], saxis, points[0]); Vector2MA(points[0], mins[1], taxis, points[0]);
Vector2MA(pivot, maxs[0], saxis, points[1]); Vector2MA(points[1], mins[1], taxis, points[1]);
Vector2MA(pivot, maxs[0], saxis, points[2]); Vector2MA(points[2], maxs[1], taxis, points[2]);
Vector2MA(pivot, mins[0], saxis, points[3]); Vector2MA(points[3], maxs[1], taxis, points[3]);
Vector2Set(tcoords[0], srcPos[0] , srcPos[1] );
Vector2Set(tcoords[1], srcPos[0]+srcSize[0] , srcPos[1] );
Vector2Set(tcoords[2], srcPos[0]+srcSize[0] , srcPos[1]+srcSize[1] );
Vector2Set(tcoords[3], srcPos[0] , srcPos[1]+srcSize[1] );
r2d_be_flags = PF_SelectDPDrawFlag(flag);
R2D_ImageColours(rgb[0], rgb[1], rgb[2], alpha);
R2D_Image2dQuad(points, tcoords, p);
r2d_be_flags = 0;
G_FLOAT(OFS_RETURN) = 1;
}
@ -540,7 +628,7 @@ void QCBUILTIN PF_CL_precache_pic (pubprogfuncs_t *prinst, struct globalvars_s *
CL_CheckOrEnqueDownloadFile(str, str, 0);
}
if (pic)
if (pic && R_GetShaderSizes(pic, NULL, NULL, true))
G_INT(OFS_RETURN) = G_INT(OFS_PARM0);
else
G_INT(OFS_RETURN) = 0;
@ -1061,7 +1149,10 @@ void QCBUILTIN PF_nonfatalobjerror (pubprogfuncs_t *prinst, struct globalvars_s
if (developer.value)
prinst->pr_trace = 2;
{ //enable tracing.
PR_RunWarning(prinst, "======OBJECT ERROR======\n%s\n", s);
return;
}
else
{
ED_Free (prinst, ed);
@ -1099,9 +1190,16 @@ void QCBUILTIN PF_clientstate (pubprogfuncs_t *prinst, struct globalvars_s *pr_g
//too specific to the prinst's builtins.
static void QCBUILTIN PF_Fixme (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
Con_Printf("\n");
int binum;
char fname[MAX_QPATH];
if (!prinst->GetBuiltinCallInfo(prinst, &binum, fname, sizeof(fname)))
{
binum = 0;
strcpy(fname, "?unknown?");
}
prinst->RunError(prinst, "\nBuiltin %i not implemented.\nMenu is not compatible.", prinst->lastcalledbuiltinnumber);
Con_Printf("\n");
prinst->RunError(prinst, "\nBuiltin %i:%s not implemented.\nMenu is not compatible.", binum, fname);
PR_BIError (prinst, "bulitin not implemented");
}
@ -1541,13 +1639,13 @@ static void QCBUILTIN PF_m_precache_model(pubprogfuncs_t *prinst, struct globalv
static void QCBUILTIN PF_m_setmodel(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
menuedict_t *ent = (void*)G_EDICT(prinst, OFS_PARM0);
string_t modelname = G_INT(OFS_PARM1); //FIXME: zone it or something?
const char *modelname = PR_GetStringOfs(prinst, OFS_PARM1);
eval_t *modelval = prinst->GetEdictFieldValue(prinst, (void*)ent, "model", &menuc_eval.model);
eval_t *minsval = prinst->GetEdictFieldValue(prinst, (void*)ent, "mins", &menuc_eval.mins);
eval_t *maxsval = prinst->GetEdictFieldValue(prinst, (void*)ent, "maxs", &menuc_eval.maxs);
model_t *mod = Mod_ForName(prinst->StringToNative(prinst, modelname), MLV_WARN);
model_t *mod = Mod_ForName(modelname, MLV_WARN);
if (modelval)
modelval->string = modelname;
modelval->string = G_INT(OFS_PARM1); //lets hope garbage collection is enough.
if (mod && minsval)
VectorCopy(mod->mins, minsval->_vector);
if (mod && maxsval)
@ -1608,7 +1706,8 @@ static qboolean CopyMenuEdictToEntity(pubprogfuncs_t *prinst, menuedict_t *in, e
out->skinnum = skinval?skinval->_float:0;
out->framestate.g[FS_REG].frame[0] = frame1val?frame1val->_float:0;
out->framestate.g[FS_REG].frame[1] = frame2val?frame2val->_float:0;
out->framestate.g[FS_REG].lerpfrac = lerpfracval?lerpfracval->_float:0;
out->framestate.g[FS_REG].lerpweight[1] = lerpfracval?lerpfracval->_float:0;
out->framestate.g[FS_REG].lerpweight[0] = 1-out->framestate.g[FS_REG].lerpweight[1];
out->framestate.g[FS_REG].frametime[0] = frame1timeval?frame1timeval->_float:0;
out->framestate.g[FS_REG].frametime[1] = frame2timeval?frame2timeval->_float:0;
@ -1663,6 +1762,43 @@ static void QCBUILTIN PF_m_renderscene(pubprogfuncs_t *prinst, struct globalvars
void QCBUILTIN PF_R_SetViewFlag(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_R_GetViewFlag(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
static void QCBUILTIN PF_menu_cprint (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
char *str = PF_VarString(prinst, 0, pr_globals);
SCR_CenterPrint(0, str, true);
}
static void QCBUILTIN PF_cl_changelevel (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
#ifndef CLIENTONLY
const char *nextmap = PR_GetStringOfs(prinst, OFS_PARM0);
if (sv.active || !cls.state)
{
char buf[1024];
Cbuf_AddText(va("changelevel %s\n", COM_QuotedString(nextmap, buf, sizeof(buf), false)), RESTRICT_INSECURE);
}
#endif
}
static void QCBUILTIN PF_crash (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
int binum;
char fname[MAX_QPATH];
//allow people to rename it or whatever
if (!prinst->GetBuiltinCallInfo(prinst, &binum, fname, sizeof(fname)))
{
binum = 0;
strcpy(fname, "?unknown?");
}
prinst->RunError(prinst, "\n%s called", fname);
}
static void QCBUILTIN PF_stackdump (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
prinst->StackTrace(prinst, true);
}
#define PF_cl_clientcommand PF_Fixme
#define PF_altstr_ins PF_Fixme //insert after, apparently
static struct {
char *name;
builtin_t bifunc;
@ -1672,9 +1808,9 @@ static struct {
{"error", PF_error, 2},
{"objerror", PF_nonfatalobjerror, 3},
{"print", PF_print, 4},
{"bprint", PF_Fixme, 5},
{"msprint", PF_Fixme, 6},
{"cprint", PF_Fixme, 7},
{"bprint", PF_cl_bprint, 5},
{"msprint", PF_cl_sprint, 6},
{"cprint", PF_menu_cprint, 7},
{"normalize", PF_normalize, 8},
{"vlen", PF_vlen, 9},
{"vectoyaw", PF_vectoyaw, 10},
@ -1728,10 +1864,10 @@ static struct {
{"tokenize", PF_Tokenize, 58},
{"argv", PF_ArgV, 59},
{"isserver", PF_isserver, 60},
{"clientcount", PF_Fixme, 61}, //float clientcount(void) = #61;
{"clientcount", PF_cl_clientcount, 61}, //float clientcount(void) = #61;
{"clientstate", PF_clientstate, 62},
{"clientcommand", PF_Fixme, 63}, //void clientcommand(float client, string s) = #63;
{"changelevel", PF_Fixme, 64}, //void changelevel(string map) = #64;
{"clientcommand", PF_cl_clientcommand, 63}, //void clientcommand(float client, string s) = #63;
{"changelevel", PF_cl_changelevel, 64}, //void changelevel(string map) = #64;
{"localsound", PF_localsound, 65},
{"getmousepos", PF_cl_getmousepos, 66},
{"gettime", PF_gettime, 67},
@ -1739,12 +1875,14 @@ static struct {
{"loadfromfile", PF_loadfromfile, 69},
{"mod", PF_mod, 70},
{"cvar_string", PF_menu_cvar_string, 71},
{"crash", PF_Fixme, 72}, //void crash(void) = #72;
{"stackdump", PF_Fixme, 73}, //void stackdump(void) = #73;
{"crash", PF_crash, 72}, //void crash(void) = #72;
{"stackdump", PF_stackdump, 73}, //void stackdump(void) = #73;
{"search_begin", PF_search_begin, 74},
{"search_end", PF_search_end, 75},
{"search_getsize", PF_search_getsize, 76},
{"search_getfilename", PF_search_getfilename, 77},
{"search_getfilesize", PF_search_getfilesize, 0},
{"search_getfilemtime", PF_search_getfilemtime, 0},
{"chr2str", PF_chr2str, 78},
{"etof", PF_etof, 79},
{"ftoe", PF_ftoe, 80},
@ -1753,7 +1891,7 @@ static struct {
{"altstr_prepare", PF_altstr_prepare, 83},
{"altstr_get", PF_altstr_get, 84},
{"altstr_set", PF_altstr_set, 85},
{"altstr_ins", PF_Fixme, 86},
{"altstr_ins", PF_altstr_ins, 86},
{"findflags", PF_FindFlags, 87},
{"findchainflags", PF_menu_findchainflags, 88},
{"mcvar_defstring", PF_cvar_defstring, 89},
@ -1840,6 +1978,7 @@ static struct {
{"drawcharacter", PF_CL_drawcharacter, 454},
{"drawrawstring", PF_CL_drawrawstring, 455},
{"drawpic", PF_CL_drawpic, 456},
{"drawrotpic", PF_CL_drawrotpic, 0},
{"drawfill", PF_CL_drawfill, 457},
{"drawsetcliparea", PF_CL_drawsetcliparea, 458},
{"drawresetcliparea", PF_CL_drawresetcliparea, 459},
@ -1853,6 +1992,7 @@ static struct {
{"drawstring", PF_CL_drawcolouredstring, 467},
{"stringwidth", PF_CL_stringwidth, 468},
{"drawsubpic", PF_CL_drawsubpic, 469},
{"drawrotsubpic", PF_CL_drawrotsubpic, 0},
//470
//MERGES WITH CLIENT+SERVER BUILTIN MAPPINGS BELOW
{"asin", PF_asin, 471},
@ -1871,16 +2011,19 @@ static struct {
{"strreplace", PF_strreplace, 484},
{"strireplace", PF_strireplace, 485},
//486
{"gecko_create", PF_cs_gecko_create, 487},
{"gecko_destroy", PF_cs_gecko_destroy, 488},
{"gecko_navigate", PF_cs_gecko_navigate, 489},
{"gecko_keyevent", PF_cs_gecko_keyevent, 490},
{"gecko_mousemove", PF_cs_gecko_mousemove, 491},
{"gecko_resize", PF_cs_gecko_resize, 492},
{"gecko_get_texture_extent",PF_cs_gecko_get_texture_extent,493},
{"gecko_create", PF_cs_media_create_http, 487},
{"gecko_destroy", PF_cs_media_destroy, 488},
{"gecko_navigate", PF_cs_media_command, 489},
{"gecko_keyevent", PF_cs_media_keyevent, 490},
{"gecko_mousemove", PF_cs_media_mousemove, 491},
{"gecko_resize", PF_cs_media_resize, 492},
{"gecko_get_texture_extent",PF_cs_media_get_texture_extent,493},
{"media_getposition", PF_cs_media_getposition},
{"crc16", PF_crc16, 494},
{"cvar_type", PF_cvar_type, 495},
{"numentityfields", PF_numentityfields, 496},
{"findentityfield", PF_findentityfield, 0},
{"entityfieldref", PF_entityfieldref, 0},
{"entityfieldname", PF_entityfieldname, 497},
{"entityfieldtype", PF_entityfieldtype, 498},
{"getentityfieldstring", PF_getentityfieldstring, 499},
@ -1945,7 +2088,7 @@ static struct {
{"crypto_getmyidstatus", PF_crypto_getmyidfp, 641},
{NULL}
};
builtin_t menu_builtins[1024];
static builtin_t menu_builtins[1024];
int MP_BuiltinValid(char *name, int num)
@ -1979,6 +2122,28 @@ static void MP_SetupBuiltins(void)
}
}
static int PDECL PR_Menu_MapNamedBuiltin(pubprogfuncs_t *progfuncs, int headercrc, const char *builtinname)
{
int i, binum;
for (i = 0;BuiltinList[i].name;i++)
{
if (!strcmp(BuiltinList[i].name, builtinname) && BuiltinList[i].bifunc != PF_Fixme)
{
for (binum = sizeof(menu_builtins)/sizeof(menu_builtins[0]); --binum; )
{
if (menu_builtins[binum] && menu_builtins[binum] != PF_Fixme && BuiltinList[i].bifunc)
continue;
menu_builtins[binum] = BuiltinList[i].bifunc;
return binum;
}
Con_Printf("No more builtin slots to allocate for %s\n", builtinname);
break;
}
}
Con_DPrintf("Unknown menu builtin: %s\n", builtinname);
return 0;
}
void M_Init_Internal (void);
void M_DeInit_Internal (void);
@ -2119,9 +2284,7 @@ qboolean MP_Init (void)
menuprogparms.cstateop = NULL;//CStateOp;
menuprogparms.cwstateop = NULL;//CWStateOp;
menuprogparms.thinktimeop = NULL;//ThinkTimeOp;
//used when loading a game
menuprogparms.builtinsfor = NULL;//builtin_t *(*builtinsfor) (int num); //must return a pointer to the builtins that were used before the state was saved.
menuprogparms.MapNamedBuiltin = PR_Menu_MapNamedBuiltin;
menuprogparms.loadcompleate = NULL;//void (*loadcompleate) (int edictsize); //notification to reset any pointers.
menuprogparms.memalloc = PR_CB_Malloc;//void *(*memalloc) (int size); //small string allocation malloced and freed randomly
@ -2138,7 +2301,6 @@ qboolean MP_Init (void)
menuprogparms.sv_edicts = (struct edict_s **)&menu_edicts;
menuprogparms.sv_num_edicts = &num_menu_edicts;
menuprogparms.useeditor = NULL;//sorry... QCEditor;//void (*useeditor) (char *filename, int line, int nump, char **parms);
menuprogparms.useeditor = QCEditor;//void (*useeditor) (char *filename, int line, int nump, char **parms);
menuprogparms.user = &menu_world;
menu_world.keydestmask = kdm_menu;
@ -2150,7 +2312,7 @@ qboolean MP_Init (void)
Con_DPrintf("Initializing menu.dat\n");
menu_world.progs = InitProgs(&menuprogparms);
PR_Configure(menu_world.progs, 64*1024*1024, 1, pr_enable_profiling.ival);
mprogs = PR_LoadProgs(menu_world.progs, "menu.dat", NULL, 0);
mprogs = PR_LoadProgs(menu_world.progs, "menu.dat");
if (mprogs < 0) //no per-progs builtins.
{
//failed to load or something

View file

@ -59,8 +59,8 @@ typedef struct doll_s
int numbodies;
int numjoints;
int numbones;
odebodyinfo_t *body;
odejointinfo_t *joint;
rbebodyinfo_t *body;
rbejointinfo_t *joint;
struct
{
//easy lookup table for bone->body.
@ -71,7 +71,7 @@ typedef struct doll_s
typedef struct
{
odebody_t odebody;
rbebody_t odebody;
// int ownerent; /*multiple of 12*/
// int flags;
@ -100,7 +100,7 @@ typedef struct skelobject_s
unsigned int numbodies;
body_t *body;
int numjoints;
odejoint_t *joint;
rbejoint_t *joint;
doll_t *doll;
wedict_t *entity; //only valid for dolls.
#endif
@ -293,11 +293,11 @@ typedef struct {
int numbones;
galiasbone_t *bones;
odebodyinfo_t *body;
odejointinfo_t *joint;
rbebodyinfo_t *body;
rbejointinfo_t *joint;
odebodyinfo_t defbody;
odejointinfo_t defjoint;
rbebodyinfo_t defbody;
rbejointinfo_t defjoint;
} dollcreatectx_t;
static dollcreatectx_t *rag_createdoll(model_t *mod, const char *fname, int numbones)
{
@ -1088,7 +1088,7 @@ static void rag_uninstanciate(skelobject_t *sko)
for (i = 0; i < sko->numbodies; i++)
{
World_ODE_RagDestroyBody(sko->world, &sko->body[i].odebody);
sko->world->rbe->RagDestroyBody(sko->world, &sko->body[i].odebody);
}
BZ_Free(sko->body);
sko->body = NULL;
@ -1096,7 +1096,7 @@ static void rag_uninstanciate(skelobject_t *sko)
for (i = 0; i < sko->numjoints; i++)
{
World_ODE_RagDestroyJoint(sko->world, &sko->joint[i]);
sko->world->rbe->RagDestroyJoint(sko->world, &sko->joint[i]);
}
BZ_Free(sko->joint);
sko->joint = NULL;
@ -1105,7 +1105,7 @@ static void rag_uninstanciate(skelobject_t *sko)
sko->doll->uses--;
sko->doll = NULL;
}
void rag_genbodymatrix(skelobject_t *sko, odebodyinfo_t *dollbody, float *emat, float *result)
void rag_genbodymatrix(skelobject_t *sko, rbebodyinfo_t *dollbody, float *emat, float *result)
{
float *bmat;
int bone = dollbody->bone;
@ -1144,8 +1144,8 @@ qboolean rag_instanciate(skelobject_t *sko, doll_t *doll, float *emat, wedict_t
int numbones;
galiasbone_t *bones = Mod_GetBoneInfo(sko->model, &numbones);
int bone;
odebody_t *body1, *body2;
odejointinfo_t *j;
rbebody_t *body1, *body2;
rbejointinfo_t *j;
sko->numbodies = doll->numbodies;
sko->body = BZ_Malloc(sizeof(*sko->body) * sko->numbodies);
sko->doll = doll;
@ -1164,7 +1164,7 @@ qboolean rag_instanciate(skelobject_t *sko, doll_t *doll, float *emat, wedict_t
Matrix3x4_Invert_Simple(bones[doll->body[i].bone].inverse, bodymat);
else
rag_genbodymatrix(sko, &doll->body[i], emat, bodymat);
if (!World_ODE_RagCreateBody(sko->world, &sko->body[i].odebody, &doll->body[i], bodymat, ent))
if (!sko->world->rbe->RagCreateBody(sko->world, &sko->body[i].odebody, &doll->body[i], bodymat, ent))
return false;
}
sko->numjoints = doll->numjoints;
@ -1197,7 +1197,7 @@ qboolean rag_instanciate(skelobject_t *sko, doll_t *doll, float *emat, wedict_t
VectorNormalize2(j->axis, aaa2[1]);
VectorNormalize2(j->axis2, aaa2[2]);
World_ODE_RagCreateJoint(sko->world, &sko->joint[i], j, body1, body2, aaa2);
sko->world->rbe->RagCreateJoint(sko->world, &sko->joint[i], j, body1, body2, aaa2);
}
//now the joints have all their various properties, move the bones to their real positions.
@ -1205,7 +1205,7 @@ qboolean rag_instanciate(skelobject_t *sko, doll_t *doll, float *emat, wedict_t
for (i = 0; i < sko->numbodies; i++)
{
rag_genbodymatrix(sko, &doll->body[i], emat, bodymat);
World_ODE_RagMatrixToBody(&sko->body[i].odebody, bodymat);
sko->world->rbe->RagMatrixToBody(&sko->body[i].odebody, bodymat);
}
sko->doll->numdefaultanimated = sko->numanimated;
@ -1253,7 +1253,7 @@ void rag_derive(skelobject_t *sko, skelobject_t *asko, float *emat)
"}\n"
"}\n");
World_ODE_RagMatrixFromBody(sko->world, &sko->body[i].odebody, bodymat);
sko->world->rbe->RagMatrixFromBody(sko->world, &sko->body[i].odebody, bodymat);
switch(doll->body[i].geomshape)
{
@ -1283,7 +1283,7 @@ void rag_derive(skelobject_t *sko, skelobject_t *asko, float *emat)
{
if (!doll->joint[i].draw)
continue;
World_ODE_RagMatrixFromJoint(&sko->joint[i], &doll->joint[i], bodymat);
sko->world->rbe->RagMatrixFromJoint(&sko->joint[i], &doll->joint[i], bodymat);
// CLQ1_AddOrientedCube(debugshader, mins, maxs, bodymat, 0, 0.2, 0, 1);
if (!lineshader)
@ -1319,7 +1319,7 @@ void rag_derive(skelobject_t *sko, skelobject_t *asko, float *emat)
if (doll->bone[i].bodyidx >= 0)
{
//bones with a body are given an absolute pose matching that body.
World_ODE_RagMatrixFromBody(sko->world, &sko->body[doll->bone[i].bodyidx].odebody, bodymat);
sko->world->rbe->RagMatrixFromBody(sko->world, &sko->body[doll->bone[i].bodyidx].odebody, bodymat);
//that body matrix is in world space, so transform to model space for our result
R_ConcatTransforms((void*)invemat, (void*)bodymat, (void*)((float*)bmat+i*12));
}
@ -1372,7 +1372,7 @@ void rag_doallanimations(world_t *world)
{
if (!sko->body[j].animstrength)
continue;
World_ODE_RagMatrixToBody(&sko->body[j].odebody, sko->body[j].animmatrix);
sko->world->rbe->RagMatrixToBody(&sko->body[j].odebody, sko->body[j].animmatrix);
}
}
}
@ -1412,7 +1412,7 @@ void rag_updatedeltaent(entity_t *ent, lerpents_t *le)
if (mod->dollinfo)
{
w = &csqc_world;
if (!w->ode.ode)
if (!w->rbe)
return;
if (!le->skeletalobject)
@ -1508,9 +1508,9 @@ void QCBUILTIN PF_skel_ragedit(pubprogfuncs_t *prinst, struct globalvars_s *pr_g
return;
}
if (!sko->world->ode.ode)
if (!sko->world->rbe)
{
Con_DPrintf("PF_skel_ragedit: ODE not enabled\n");
Con_DPrintf("PF_skel_ragedit: rigid body system not enabled\n");
return;
}
@ -1531,7 +1531,7 @@ void QCBUILTIN PF_skel_ragedit(pubprogfuncs_t *prinst, struct globalvars_s *pr_g
{
int idx = rag_finddolljoint(sko->doll, Cmd_Argv(1));
int enable = atoi(Cmd_Argv(2));
World_ODE_RagEnableJoint(&sko->joint[idx], enable);
sko->world->rbe->RagEnableJoint(&sko->joint[idx], enable);
G_FLOAT(OFS_RETURN) = 1;
return;
}
@ -2141,6 +2141,7 @@ void QCBUILTIN PF_gettaginfo (pubprogfuncs_t *prinst, struct globalvars_s *pr_gl
world_t *w = prinst->parms->user;
wedict_t *ent = G_WEDICT(prinst, OFS_PARM0);
int tagnum = G_FLOAT(OFS_PARM1);
int chain = 10;
int modelindex = ent->v->modelindex;
@ -2149,6 +2150,7 @@ void QCBUILTIN PF_gettaginfo (pubprogfuncs_t *prinst, struct globalvars_s *pr_gl
float transent[12];
float transforms[12];
float result[12];
float result2[12];
framestate_t fstate;
@ -2159,17 +2161,22 @@ void QCBUILTIN PF_gettaginfo (pubprogfuncs_t *prinst, struct globalvars_s *pr_gl
bonemat_fromidentity(transforms);
}
if (ent->xv->tag_entity)
{
#ifdef warningmsg
#pragma warningmsg("PF_gettaginfo: This function doesn't honour attachments")
#endif
Con_Printf("bug: PF_gettaginfo doesn't support attachments\n");
}
bonemat_fromentity(w, ent, transent);
R_ConcatTransforms((void*)transent, (void*)transforms, (void*)result);
while (ent->xv->tag_entity && chain --> 0)
{
w->Get_FrameState(w, ent, &fstate);
if (!Mod_GetTag(mod, tagnum, &fstate, transforms))
bonemat_fromidentity(transforms);
bonemat_fromentity(w, ent, transent);
R_ConcatTransforms((void*)transforms, (void*)result, (void*)result2);
R_ConcatTransforms((void*)transent, (void*)result2, (void*)result);
ent = PROG_TO_WEDICT(prinst, ent->xv->tag_entity);
}
bonemat_toqcvectors(result, w->g.v_forward, w->g.v_right, w->g.v_up, G_VECTOR(OFS_RETURN));
}

View file

@ -442,6 +442,29 @@ void R2D_Image(float x, float y, float w, float h, float s1, float t1, float s2,
BE_DrawMesh_Single(pic, &draw_mesh, NULL, &pic->defaulttextures, r2d_be_flags);
}
void R2D_Image2dQuad(vec2_t points[], vec2_t texcoords[], mpic_t *pic)
{
int i;
if (!pic)
return;
//don't draw pics if they have an image which is still loading.
for (i = 0; i < pic->numpasses; i++)
{
if (pic->passes[i].texgen == T_GEN_SINGLEMAP && pic->passes[i].anim_frames[0] && pic->passes[i].anim_frames[0]->status == TEX_LOADING)
return;
if (pic->passes[i].texgen == T_GEN_DIFFUSE && pic->defaulttextures.base && pic->defaulttextures.base->status == TEX_LOADING)
return;
}
for (i = 0; i < 4; i++)
{
Vector2Copy(points[i], draw_mesh_xyz[i]);
Vector2Copy(texcoords[i], draw_mesh_st[i]);
}
BE_DrawMesh_Single(pic, &draw_mesh, NULL, &pic->defaulttextures, r2d_be_flags);
}
/*draws a block of the current colour on the screen*/
void R2D_FillBlock(float x, float y, float w, float h)

View file

@ -561,7 +561,6 @@ extern cvar_t r_clear;
extern cvar_t gl_poly;
extern cvar_t gl_affinemodels;
extern cvar_t gl_nohwblend;
extern cvar_t gl_reporttjunctions;
extern cvar_t r_coronas, r_flashblend, r_flashblendscale;
extern cvar_t r_lightstylesmooth;
extern cvar_t r_lightstylesmooth_limit;

View file

@ -356,6 +356,9 @@ cvar_t r_lightprepass = CVARFD("r_lightprepass", "0", CVAR_SHADERSYSTEM, "E
cvar_t r_shadow_bumpscale_basetexture = CVARD ("r_shadow_bumpscale_basetexture", "0", "bumpyness scaler for generation of fallback normalmap textures from models");
cvar_t r_shadow_bumpscale_bumpmap = CVARD ("r_shadow_bumpscale_bumpmap", "4", "bumpyness scaler for _bump textures");
cvar_t r_shadow_heightscale_basetexture = CVARD ("r_shadow_heightscale_basetexture", "0", "scaler for generation of height maps from legacy paletted content.");
cvar_t r_shadow_heightscale_bumpmap = CVARD ("r_shadow_heightscale_bumpmap", "1", "height scaler for 8bit _bump textures");
cvar_t r_glsl_offsetmapping = CVARFD ("r_glsl_offsetmapping", "0", CVAR_ARCHIVE|CVAR_SHADERSYSTEM, "Enables the use of paralax mapping, adding fake depth to textures.");
cvar_t r_glsl_offsetmapping_scale = CVAR ("r_glsl_offsetmapping_scale", "0.04");
cvar_t r_glsl_offsetmapping_reliefmapping = CVARFD("r_glsl_offsetmapping_reliefmapping", "1", CVAR_ARCHIVE|CVAR_SHADERSYSTEM, "Changes the paralax sampling mode to be a bit nicer. r_glsl_offsetmapping must be set.");
@ -430,8 +433,8 @@ void GLRenderer_Init(void)
Cvar_Register (&gl_maxshadowlights, GLRENDEREROPTIONS);
Cvar_Register (&r_shadow_bumpscale_basetexture, GLRENDEREROPTIONS);
Cvar_Register (&r_shadow_bumpscale_bumpmap, GLRENDEREROPTIONS);
Cvar_Register (&gl_reporttjunctions, GLRENDEREROPTIONS);
Cvar_Register (&r_shadow_heightscale_basetexture, GLRENDEREROPTIONS);
Cvar_Register (&r_shadow_heightscale_bumpmap, GLRENDEREROPTIONS);
Cvar_Register (&gl_motionblur, GLRENDEREROPTIONS);
Cvar_Register (&gl_motionblurscale, GLRENDEREROPTIONS);

View file

@ -559,6 +559,8 @@ static void OpenAL_ChannelUpdate(soundcardinfo_t *sc, channel_t *chan, unsigned
{
if (!S_LoadSound(sfx))
return; //can't load it
if (sfx->loadstate != SLS_LOADED)
return; //not available yet
if (sfx->decoder.decodedata)
{
int offset;

View file

@ -459,7 +459,7 @@ void Sys_SaveClipboard(char *text)
}
int Sys_EnumerateFiles (const char *gpath, const char *match, int (*func)(const char *, qofs_t, void *, searchpathfuncs_t *), void *parm, searchpathfuncs_t *spath)
int Sys_EnumerateFiles (const char *gpath, const char *match, int (*func)(const char *, qofs_t, time_t mtime, void *, searchpathfuncs_t *), void *parm, searchpathfuncs_t *spath)
{
DIR *dir;
char apath[MAX_OSPATH];
@ -517,7 +517,7 @@ int Sys_EnumerateFiles (const char *gpath, const char *match, int (*func)(const
{
Q_snprintfz(file, sizeof(file), "%s%s%s", apath, ent->d_name, S_ISDIR(st.st_mode)?"/":"");
if (!func(file, st.st_size, parm, spath))
if (!func(file, st.st_size, st.st_mtime, parm, spath))
{
closedir(dir);
return false;

View file

@ -410,7 +410,7 @@ int Sys_DebugLog(char *file, char *fmt, ...)
return 1;
}
int Sys_EnumerateFiles (const char *gpath, const char *match, int (*func)(const char *, qofs_t, void *, searchpathfuncs_t *), void *parm, searchpathfuncs_t *spath)
int Sys_EnumerateFiles (const char *gpath, const char *match, int (*func)(const char *, qofs_t, time_t modtime, void *, searchpathfuncs_t *), void *parm, searchpathfuncs_t *spath)
{
DIR *dir;
char apath[MAX_OSPATH];
@ -468,7 +468,7 @@ int Sys_EnumerateFiles (const char *gpath, const char *match, int (*func)(const
{
Q_snprintfz(file, sizeof(file), "%s%s%s", apath, ent->d_name, S_ISDIR(st.st_mode)?"/":"");
if (!func(file, st.st_size, parm, spath))
if (!func(file, st.st_size, st.st_mtime, parm, spath))
{
Con_DPrintf("giving up on search after finding %s\n", file);
closedir(dir);

View file

@ -160,7 +160,7 @@ void Sys_Quit (void)
//SDL provides no file enumeration facilities.
#if defined(_WIN32)
#include <windows.h>
int Sys_EnumerateFiles (const char *gpath, const char *match, int (*func)(const char *, qofs_t, void *, searchpathfuncs_t *), void *parm, searchpathfuncs_t *spath)
int Sys_EnumerateFiles (const char *gpath, const char *match, int (*func)(const char *, qofs_t, time_t mtime, void *, searchpathfuncs_t *), void *parm, searchpathfuncs_t *spath)
{
HANDLE r;
WIN32_FIND_DATA fd;
@ -207,7 +207,7 @@ int Sys_EnumerateFiles (const char *gpath, const char *match, int (*func)(const
if (wildcmp(match, fd.cFileName))
{
Q_snprintfz(file, sizeof(file), "%s%s/", apath2, fd.cFileName);
go = func(file, fd.nFileSizeLow, parm, spath);
go = func(file, fd.nFileSizeLow, 0, parm, spath);
}
}
else
@ -215,7 +215,7 @@ int Sys_EnumerateFiles (const char *gpath, const char *match, int (*func)(const
if (wildcmp(match, fd.cFileName))
{
Q_snprintfz(file, sizeof(file), "%s%s", apath2, fd.cFileName);
go = func(file, fd.nFileSizeLow, parm, spath);
go = func(file, fd.nFileSizeLow, 0, parm, spath);
}
}
}
@ -226,7 +226,7 @@ int Sys_EnumerateFiles (const char *gpath, const char *match, int (*func)(const
}
#elif defined(linux) || defined(__unix__) || defined(__MACH__)
#include <dirent.h>
int Sys_EnumerateFiles (const char *gpath, const char *match, int (*func)(const char *, qofs_t, void *, searchpathfuncs_t *), void *parm, searchpathfuncs_t *spath)
int Sys_EnumerateFiles (const char *gpath, const char *match, int (*func)(const char *, qofs_t, time_t mtime, void *, searchpathfuncs_t *), void *parm, searchpathfuncs_t *spath)
{
DIR *dir;
char apath[MAX_OSPATH];
@ -284,7 +284,7 @@ int Sys_EnumerateFiles (const char *gpath, const char *match, int (*func)(const
{
Q_snprintfz(file, sizeof(file), "%s%s%s", apath, ent->d_name, S_ISDIR(st.st_mode)?"/":"");
if (!func(file, st.st_size, parm, spath))
if (!func(file, st.st_size, st.st_mtime, parm, spath))
{
closedir(dir);
return false;
@ -300,7 +300,7 @@ int Sys_EnumerateFiles (const char *gpath, const char *match, int (*func)(const
return true;
}
#else
int Sys_EnumerateFiles (const char *gpath, const char *match, int (*func)(const char *, qofs_t, void *, void *), void *parm, void *spath)
int Sys_EnumerateFiles (const char *gpath, const char *match, int (*func)(const char *, qofs_t, time_t mtime, void *, void *), void *parm, void *spath)
{
Con_Printf("Warning: Sys_EnumerateFiles not implemented\n");
return false;

View file

@ -149,7 +149,7 @@ qboolean Sys_Rename (char *oldfname, char *newfname)
}
//enumeratefiles is recursive for */* to work
static int Sys_EnumerateFiles2 (const char *match, int matchstart, int neststart, int (QDECL *func)(const char *fname, qofs_t fsize, void *parm, searchpathfuncs_t *spath), void *parm, searchpathfuncs_t *spath)
static int Sys_EnumerateFiles2 (const char *match, int matchstart, int neststart, int (QDECL *func)(const char *fname, qofs_t fsize, time_t mtime, void *parm, searchpathfuncs_t *spath), void *parm, searchpathfuncs_t *spath)
{
qboolean go;
@ -247,7 +247,7 @@ static int Sys_EnumerateFiles2 (const char *match, int matchstart, int neststart
if (strlen(tmproot+matchstart) + strlen(utf8) + 2 < MAX_OSPATH)
{
Q_snprintfz(file, sizeof(file), "%s%s/", tmproot+matchstart, utf8);
go = func(file, qofs_Make(fd.nFileSizeLow, fd.nFileSizeHigh), parm, spath);
go = func(file, qofs_Make(fd.nFileSizeLow, fd.nFileSizeHigh), 0, parm, spath);
}
}
}
@ -258,7 +258,7 @@ static int Sys_EnumerateFiles2 (const char *match, int matchstart, int neststart
if (strlen(tmproot+matchstart) + strlen(utf8) + 1 < MAX_OSPATH)
{
Q_snprintfz(file, sizeof(file), "%s%s", tmproot+matchstart, utf8);
go = func(file, qofs_Make(fd.nFileSizeLow, fd.nFileSizeHigh), parm, spath);
go = func(file, qofs_Make(fd.nFileSizeLow, fd.nFileSizeHigh), 0, parm, spath);
}
}
}
@ -1021,7 +1021,15 @@ qboolean Sys_Rename (char *oldfname, char *newfname)
return !rename(oldfname, newfname);
}
static int Sys_EnumerateFiles2 (const char *match, int matchstart, int neststart, int (QDECL *func)(const char *fname, qofs_t fsize, void *parm, searchpathfuncs_t *spath), void *parm, searchpathfuncs_t *spath)
static time_t Sys_FileTimeToTime(FILETIME ft)
{
ULARGE_INTEGER ull;
ull.LowPart = ft.dwLowDateTime;
ull.HighPart = ft.dwHighDateTime;
return ull.QuadPart / 10000000ULL - 11644473600ULL;
}
static int Sys_EnumerateFiles2 (const char *match, int matchstart, int neststart, int (QDECL *func)(const char *fname, qofs_t fsize, time_t mtime, void *parm, searchpathfuncs_t *spath), void *parm, searchpathfuncs_t *spath)
{
qboolean go;
if (!WinNT)
@ -1109,7 +1117,7 @@ static int Sys_EnumerateFiles2 (const char *match, int matchstart, int neststart
if (strlen(tmproot+matchstart) + strlen(fd.cFileName) + 2 < MAX_OSPATH)
{
Q_snprintfz(file, sizeof(file), "%s%s/", tmproot+matchstart, fd.cFileName);
go = func(file, qofs_Make(fd.nFileSizeLow, fd.nFileSizeHigh), parm, spath);
go = func(file, qofs_Make(fd.nFileSizeLow, fd.nFileSizeHigh), Sys_FileTimeToTime(fd.ftLastWriteTime), parm, spath);
}
}
}
@ -1120,7 +1128,7 @@ static int Sys_EnumerateFiles2 (const char *match, int matchstart, int neststart
if (strlen(tmproot+matchstart) + strlen(fd.cFileName) + 1 < MAX_OSPATH)
{
Q_snprintfz(file, sizeof(file), "%s%s", tmproot+matchstart, fd.cFileName);
go = func(file, qofs_Make(fd.nFileSizeLow, fd.nFileSizeHigh), parm, spath);
go = func(file, qofs_Make(fd.nFileSizeLow, fd.nFileSizeHigh), Sys_FileTimeToTime(fd.ftLastWriteTime), parm, spath);
}
}
}
@ -1224,7 +1232,7 @@ static int Sys_EnumerateFiles2 (const char *match, int matchstart, int neststart
if (strlen(tmproot+matchstart) + strlen(utf8) + 2 < MAX_OSPATH)
{
Q_snprintfz(file, sizeof(file), "%s%s/", tmproot+matchstart, utf8);
go = func(file, qofs_Make(fd.nFileSizeLow, fd.nFileSizeHigh), parm, spath);
go = func(file, qofs_Make(fd.nFileSizeLow, fd.nFileSizeHigh), Sys_FileTimeToTime(fd.ftLastWriteTime), parm, spath);
}
}
}
@ -1235,7 +1243,7 @@ static int Sys_EnumerateFiles2 (const char *match, int matchstart, int neststart
if (strlen(tmproot+matchstart) + strlen(utf8) + 1 < MAX_OSPATH)
{
Q_snprintfz(file, sizeof(file), "%s%s", tmproot+matchstart, utf8);
go = func(file, qofs_Make(fd.nFileSizeLow, fd.nFileSizeHigh), parm, spath);
go = func(file, qofs_Make(fd.nFileSizeLow, fd.nFileSizeHigh), Sys_FileTimeToTime(fd.ftLastWriteTime), parm, spath);
}
}
}
@ -1245,7 +1253,7 @@ static int Sys_EnumerateFiles2 (const char *match, int matchstart, int neststart
}
return go;
}
int Sys_EnumerateFiles (const char *gpath, const char *match, int (QDECL *func)(const char *fname, qofs_t fsize, void *parm, searchpathfuncs_t *spath), void *parm, searchpathfuncs_t *spath)
int Sys_EnumerateFiles (const char *gpath, const char *match, int (QDECL *func)(const char *fname, qofs_t fsize, time_t mtime, void *parm, searchpathfuncs_t *spath), void *parm, searchpathfuncs_t *spath)
{
char fullmatch[MAX_OSPATH];
int start;

View file

@ -10,8 +10,8 @@ F6 will list the stack.
F7 will compile.
F8 will move execution
F9 will set a break point.
F10 will apply code changes.
F11 will step through.
F10 will step over.
F11 will step into.
*/
#include "quakedef.h"
@ -86,6 +86,7 @@ static char OpenEditorFile[256];
qboolean editoractive; //(export)
qboolean editormodal; //doesn't return. (export)
int editorstep;
static qboolean madechanges;
static qboolean editenabled;
static qboolean insertkeyhit=true;
@ -207,6 +208,7 @@ static void CloseEditor(void)
madechanges = false;
editormodal = false;
editorstep = DEBUG_TRACE_OFF;
firstblock = NULL;
@ -288,7 +290,7 @@ static void EditorNewFile(void)
editenabled = true;
}
static void EditorOpenFile(char *name, qboolean readonly)
static void EditorOpenFile(const char *name, qboolean readonly)
{
int i;
char line[8192];
@ -455,7 +457,7 @@ void Editor_Key(int key, int unicode)
{
case K_ESCAPE:
if (editprogfuncs)
editprogfuncs->pr_trace = 0;
editprogfuncs->debug_trace = DEBUG_TRACE_OFF;
useeval = false;
return;
case K_F3:
@ -628,8 +630,7 @@ void Editor_Key(int key, int unicode)
break;
case K_F5: /*stop debugging*/
editormodal = false;
if (editprogfuncs)
editprogfuncs->pr_trace = false;
editorstep = DEBUG_TRACE_OFF;
break;
case K_F6:
if (editprogfuncs)
@ -676,12 +677,17 @@ void Editor_Key(int key, int unicode)
cursorblock->flags &= ~FB_BREAK;
}
break;
case K_F10: //save+apply changes, supposedly
EditorSaveFile(OpenEditorFile);
Cbuf_AddText("applycompile\n", RESTRICT_LOCAL);
case K_F10:
editormodal = false;
editorstep = DEBUG_TRACE_OVER;
break;
case K_F11: //single step
editormodal = false;
editorstep = DEBUG_TRACE_INTO;
break;
case K_F12: //save+apply changes, supposedly
EditorSaveFile(OpenEditorFile);
Cbuf_AddText("applycompile\n", RESTRICT_LOCAL);
break;
// case K_STOP:
case K_ESCAPE:
@ -695,6 +701,7 @@ void Editor_Key(int key, int unicode)
else
CloseEditor();
editormodal = false;
editorstep = DEBUG_TRACE_ABORT;
break;
case K_HOME:
@ -1199,11 +1206,17 @@ void Editor_Draw(void)
*/
}
int QCLibEditor(pubprogfuncs_t *prfncs, char *filename, int line, int statement, int nump, char **parms)
int QCLibEditor(pubprogfuncs_t *prfncs, const char *filename, int *line, int *statement, int nump, char **parms)
{
char *f1, *f2;
if (editormodal || (line < 0 && !statement) || !pr_debugger.ival)
return line; //whoops
const char *f1, *f2;
if (!pr_debugger.ival)
{
Con_Printf("Set %s to trace\n", pr_debugger.name);
return DEBUG_TRACE_OFF; //get lost
}
//we can cope with no line info by displaying asm
if (editormodal || !statement)
return DEBUG_TRACE_OFF; //whoops
if (qrenderer == QR_NONE)
{
@ -1212,14 +1225,12 @@ int QCLibEditor(pubprogfuncs_t *prfncs, char *filename, int line, int statement,
char *r;
vfsfile_t *f;
if (line == -1)
return -1;
f = FS_OpenVFS(filename, "rb", FS_GAME);
if (!f)
Con_Printf("%s - %i\n", filename, line);
Con_Printf("%s - %i\n", filename, *line);
else
{
for (i = 0; i < line; i++)
for (i = 0; i < *line; i++)
{
VFS_GETS(f, buffer, sizeof(buffer));
}
@ -1229,7 +1240,7 @@ int QCLibEditor(pubprogfuncs_t *prfncs, char *filename, int line, int statement,
VFS_CLOSE(f);
}
//PF_break(NULL);
return line;
return DEBUG_TRACE_OUT;
}
editprogfuncs = prfncs;
@ -1245,7 +1256,7 @@ int QCLibEditor(pubprogfuncs_t *prfncs, char *filename, int line, int statement,
if (!strncmp(f2, "source/", 7))
f2 += 7;
stepasm = line < 0;
stepasm = !line;
if (stepasm)
{
@ -1255,7 +1266,7 @@ int QCLibEditor(pubprogfuncs_t *prfncs, char *filename, int line, int statement,
E_Free(firstblock->next);
E_Free(firstblock);
cursorlinenum = statement;
cursorlinenum = *statement;
firstblock = GenAsm(cursorlinenum);
cursorblock = firstblock;
@ -1286,7 +1297,7 @@ int QCLibEditor(pubprogfuncs_t *prfncs, char *filename, int line, int statement,
EditorOpenFile(filename, true);
}
for (cursorlinenum = 1, cursorblock = firstblock; cursorlinenum < line && cursorblock->next; cursorlinenum++)
for (cursorlinenum = 1, cursorblock = firstblock; cursorlinenum < *line && cursorblock->next; cursorlinenum++)
cursorblock=cursorblock->next;
}
@ -1298,6 +1309,7 @@ int QCLibEditor(pubprogfuncs_t *prfncs, char *filename, int line, int statement,
{
double oldrealtime = realtime;
editormodal = true;
editorstep = DEBUG_TRACE_OFF;
while(editormodal && editoractive && editprogfuncs)
{
@ -1317,9 +1329,13 @@ int QCLibEditor(pubprogfuncs_t *prfncs, char *filename, int line, int statement,
}
if (stepasm)
return -executionlinenum;
{
*line = 0;
*statement = executionlinenum;
}
else
return executionlinenum;
*line = executionlinenum;
return editorstep;
}
void Editor_ProgsKilled(pubprogfuncs_t *dead)
@ -1328,6 +1344,7 @@ void Editor_ProgsKilled(pubprogfuncs_t *dead)
{
editprogfuncs = NULL;
editormodal = false;
editorstep = DEBUG_TRACE_OFF;
}
}

View file

@ -1206,8 +1206,8 @@ void V_ClearRefdef(playerview_t *pv)
r_refdef.grect.x = 0;
r_refdef.grect.y = 0;
r_refdef.grect.width = vid.width;
r_refdef.grect.height = vid.height;
r_refdef.grect.width = vid.fbvwidth;//vid.width;
r_refdef.grect.height = vid.fbvheight;//vid.height;
r_refdef.afov = scr_fov.value; //will have a better value applied if fov is bad. this allows setting.
r_refdef.fov_x = 0;
@ -1404,8 +1404,8 @@ void SCR_VRectForPlayer(vrect_t *vrect, int pnum)
switch(cl.splitclients)
{
case 1:
vrect->width = vid.width;
vrect->height = vid.height;
vrect->width = vid.fbvwidth;
vrect->height = vid.fbvheight;
vrect->x = 0;
vrect->y = 0;
@ -1423,8 +1423,8 @@ void SCR_VRectForPlayer(vrect_t *vrect, int pnum)
&& ffov.value >= 0 /*panoramic view always stacks player views*/
)
{ //over twice as wide as high, assume dual moniter, horizontal.
vrect->width = vid.width/cl.splitclients;
vrect->height = vid.height;
vrect->width = vid.fbvwidth/cl.splitclients;
vrect->height = vid.fbvheight;
vrect->x = 0 + vrect->width*pnum;
vrect->y = 0;
}
@ -1432,8 +1432,8 @@ void SCR_VRectForPlayer(vrect_t *vrect, int pnum)
#endif
{
//stack them vertically
vrect->width = vid.width;
vrect->height = vid.height/cl.splitclients;
vrect->width = vid.fbvwidth;
vrect->height = vid.fbvheight/cl.splitclients;
vrect->x = 0;
vrect->y = 0 + vrect->height*pnum;
}
@ -1441,8 +1441,8 @@ void SCR_VRectForPlayer(vrect_t *vrect, int pnum)
break;
case 4: //4 squares
vrect->width = vid.width/2;
vrect->height = vid.height/2;
vrect->width = vid.fbvwidth/2;
vrect->height = vid.fbvheight/2;
vrect->x = (pnum&1) * vrect->width;
vrect->y = (pnum&2)/2 * vrect->height;
break;
@ -1503,7 +1503,8 @@ void R_DrawNameTags(void)
int buflen;
int x, y;
buflen = 0;
sprintf(asciibuffer, "entity %i ", e->entnum);
buflen = strlen(asciibuffer);
entstr = w->progs->saveent(w->progs, asciibuffer, &buflen, sizeof(asciibuffer), (edict_t*)e); //will save just one entities vars
if (entstr)
{

View file

@ -237,10 +237,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define PLUGINS //qvm/dll plugins.
#define SUPPORT_ICE //Interactive Connectivity Establishment protocol, for peer-to-peer connections
#ifdef _DEBUG
// #define OFFSCREENGECKO //FIXME: move to plugin and remove from engine
#endif
#define CSQC_DAT //support for csqc
#define MENU_DAT //support for menu.dat
@ -441,10 +437,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#if defined(CSQC_DAT) || !defined(CLIENTONLY) //use ode only if we have a constant world state, and the library is enbled in some form.
#define USEODE 1
#if !(defined(ODE_STATIC) || defined(ODE_DYNAMIC))
#undef USEODE
#endif
#define USERBE
#endif
#if defined(ZYMOTICMODELS) || defined(MD5MODELS) || defined(DPMMODELS) || defined(PSKMODELS) || defined(INTERQUAKEMODELS)
@ -453,7 +446,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#if (defined(CSQC_DAT) || !defined(CLIENTONLY)) && defined(SKELETALMODELS)
#define SKELETALOBJECTS //the skeletal objects API is only used if we actually have skeletal models, and gamecode that uses the builtins.
#endif
#if !defined(USEODE) || !defined(SKELETALMODELS)
#if !defined(USERBE) || !defined(SKELETALMODELS)
#undef RAGDOLL //not possible to ragdoll if we don't have certain other features.
#endif

View file

@ -1116,7 +1116,7 @@ static void R_LerpFrames(mesh_t *mesh, galiaspose_t *p1, galiaspose_t *p2, float
#ifdef SKELETALMODELS
/*
returns the up-to-4 skeletal bone poses to blend together.
returns the up-to-8 skeletal bone poses to blend together.
return value is the number of blends that are actually live.
*/
typedef struct
@ -1124,85 +1124,86 @@ typedef struct
skeltype_t skeltype; //the skeletal type of this bone block. all blocks should have the same result or the whole thing is unusable or whatever.
int firstbone; //first bone of interest
int endbone; //the first bone of the next group (ie: if first is 0, this is the count)
float frac[4]; //weight of this animation (1 if lerpcount is 1)
float *pose[4]; //pointer to the raw frame data for bone 0.
float frac[8]; //weight of this animation (1 if lerpcount is 1)
float *pose[8]; //pointer to the raw frame data for bone 0.
int lerpcount; //number of pose+frac entries.
} skellerps_t;
static void Alias_BuildSkelLerps(skellerps_t *lerps, int numbones, galiasgroup_t *g1, galiasgroup_t *g2, float lerpfrac, float fg1time, float fg2time)
static qboolean Alias_BuildSkelLerps(skellerps_t *lerps, struct framestateregion_s *fs, int numbones, galiasinfo_t *inf)
{
int frame1;
int frame2;
unsigned int frame1;
unsigned int frame2;
float mlerp; //minor lerp, poses within a group.
int l = 0;
if (g1 == g2)
lerpfrac = 0;
if (fg1time < 0)
fg1time = 0;
mlerp = (fg1time)*g1->rate;
frame1=mlerp;
frame2=frame1+1;
mlerp-=frame1;
if (g1->loop)
galiasgroup_t *g;
unsigned int b;
float totalweight = 0;
for (b = 0; b < FRAME_BLENDS; b++)
{
frame1=frame1%g1->numposes;
frame2=frame2%g1->numposes;
}
else
{
frame1=(frame1>g1->numposes-1)?g1->numposes-1:frame1;
frame2=(frame2>g1->numposes-1)?g1->numposes-1:frame2;
if (fs->lerpweight[b])
{
unsigned int frame = fs->frame[b];
float time = fs->frametime[b];
if (frame >= inf->groups)
continue;//frame = (unsigned)frame%inf->groups;
g = &inf->groupofs[frame];
if (!g->numposes)
continue; //err...
mlerp = time*g->rate;
frame1=mlerp;
frame2=frame1+1;
mlerp-=frame1;
if (g->loop)
{ //loop normally.
frame1=frame1%g->numposes;
frame2=frame2%g->numposes;
}
else
{
frame1=(frame1>g->numposes-1)?g->numposes-1:frame1;
frame2=(frame2>g->numposes-1)?g->numposes-1:frame2;
}
if (!l)
lerps->skeltype = g->skeltype;
else if (lerps->skeltype != g->skeltype)
continue; //oops, can't cope with mixed blend types
if (frame1 == frame2 || r_noframegrouplerp.ival)
mlerp = 0;
lerps->frac[l] = (1-mlerp)*fs->lerpweight[b];
if (lerps->frac[l]>0)
{
totalweight += lerps->frac[l];
lerps->pose[l++] = g->boneofs + numbones*12*frame1;
}
lerps->frac[l] = (mlerp)*fs->lerpweight[b];
if (lerps->frac[l]>0)
{
totalweight += lerps->frac[l];
lerps->pose[l++] = g->boneofs + numbones*12*frame2;
}
}
}
if (frame1 == frame2 || r_noframegrouplerp.ival)
mlerp = 0;
lerps->frac[l] = (1-mlerp)*(1-lerpfrac);
if (lerps->frac[l]>0)
lerps->pose[l++] = g1->boneofs + numbones*12*frame1;
lerps->frac[l] = (mlerp)*(1-lerpfrac);
if (lerps->frac[l]>0)
lerps->pose[l++] = g1->boneofs + numbones*12*frame2;
if (lerpfrac)
{
if (fg2time < 0)
fg2time = 0;
mlerp = (fg2time)*g2->rate;
frame1=mlerp;
frame2=frame1+1;
mlerp-=frame1;
if (g2->loop)
if (l && totalweight != 1)
{ //don't rescale if some animation got dropped.
totalweight = 1 / totalweight;
for (b = 0; b < l; b++)
{
frame1=frame1%g2->numposes;
frame2=frame2%g2->numposes;
lerps->frac[l] *= totalweight;
}
else
{
frame1=(frame1>g2->numposes-1)?g2->numposes-1:frame1;
frame2=(frame2>g2->numposes-1)?g2->numposes-1:frame2;
}
if (frame1 == frame2 || r_noframegrouplerp.ival)
mlerp = 0;
lerps->frac[l] = (1-mlerp)*(lerpfrac);
if (lerps->frac[l]>0)
lerps->pose[l++] = g2->boneofs + numbones*12*frame1;
lerps->frac[l] = (mlerp)*(lerpfrac);
if (lerps->frac[l]>0)
lerps->pose[l++] = g2->boneofs + numbones*12*frame2;
}
lerps->lerpcount = l;
return l > 0;
}
/*
finds the various blend info. returns number of bone blocks used.
*/
static int Alias_FindRawSkelData(galiasinfo_t *inf, framestate_t *fstate, skellerps_t *lerps, size_t firstbone, size_t lastbone)
{
galiasgroup_t *g1, *g2;
int frame1, frame2;
float f1time, f2time;
float f2ness;
int bonegroup;
int cbone = 0;
int endbone;
@ -1220,13 +1221,7 @@ static int Alias_FindRawSkelData(galiasinfo_t *inf, framestate_t *fstate, skelle
if (endbone == cbone)
continue;
frame1 = fstate->g[bonegroup].frame[0];
frame2 = fstate->g[bonegroup].frame[1];
f1time = fstate->g[bonegroup].frametime[0];
f2time = fstate->g[bonegroup].frametime[1];
f2ness = fstate->g[bonegroup].lerpfrac;
if (!inf->groups) //if there's no animations in this model, use the base pose instead.
if (!inf->groups || !Alias_BuildSkelLerps(lerps, &fstate->g[bonegroup], inf->numbones, inf)) //if there's no animations in this model, use the base pose instead.
{
if (!inf->baseframeofs)
continue; //nope, not happening.
@ -1235,34 +1230,6 @@ static int Alias_FindRawSkelData(galiasinfo_t *inf, framestate_t *fstate, skelle
lerps->pose[0] = inf->baseframeofs;
lerps->lerpcount = 1;
}
else
{
if (frame1 < 0)
{
if (frame2 < 0)
{
if (bonegroup != FS_COUNT-1)
continue; //just ignore this group
frame2 = 0;
}
frame1 = frame2;
}
else if (frame2 < 0)
frame2 = frame1;
if (frame1 >= inf->groups)
frame1 %= inf->groups;
if (frame2 >= inf->groups)
frame2 %= inf->groups;
//the higher level merges old/new anims, but we still need to blend between automated frame-groups.
g1 = &inf->groupofs[frame1];
g2 = &inf->groupofs[frame2];
if (g2->skeltype != g1->skeltype)
g2 = g1;
lerps->skeltype = g1->skeltype;
Alias_BuildSkelLerps(lerps, inf->numbones, g1, g2, f2ness, f1time, f2time);
}
lerps->firstbone = cbone;
lerps->endbone = endbone;
cbone = endbone;
@ -1814,7 +1781,7 @@ qboolean Alias_GAliasBuildMesh(mesh_t *mesh, vbo_t **vbop, galiasinfo_t *inf, in
{
frame1 = e->framestate.g[FS_REG].frame[0];
frame2 = e->framestate.g[FS_REG].frame[1];
lerp = e->framestate.g[FS_REG].lerpfrac;
lerp = e->framestate.g[FS_REG].lerpweight[1]; //FIXME
fg1time = e->framestate.g[FS_REG].frametime[0];
//fg2time = e->framestate.g[FS_REG].frametime[1];
@ -4018,7 +3985,7 @@ qboolean Mod_GetTag(model_t *model, int tagnum, framestate_t *fstate, float *res
frame2 = fstate->g[FS_REG].frame[1];
//f1time = fstate->g[FS_REG].frametime[0];
//f2time = fstate->g[FS_REG].frametime[1];
f2ness = fstate->g[FS_REG].lerpfrac;
f2ness = fstate->g[FS_REG].lerpweight[1];
if (tagnum <= 0 || tagnum > inf->numtags)
return false;
@ -5888,7 +5855,7 @@ qboolean QDECL Mod_LoadDarkPlacesModel(model_t *mod, void *buffer, size_t fsize)
#else
m->numskins = skinfiles;
skin = ZG_Malloc(&mod->memgroup, (sizeof(galiasskin_t)+sizeof(skinframe_t*))*skinfiles);
skin = ZG_Malloc(&mod->memgroup, (sizeof(galiasskin_t)+sizeof(skinframe_t))*skinfiles);
skinframe = (skinframe_t*)(skin+skinfiles);
for (j = 0; j < skinfiles; j++, skinframe++)
{
@ -6093,7 +6060,7 @@ galiasinfo_t *Mod_ParseIQMMeshModel(model_t *mod, char *buffer, size_t fsize)
galiasinfo_t *gai=NULL;
#ifndef SERVERONLY
galiasskin_t *skin=NULL;
skinframe_t *frame=NULL;
skinframe_t *skinframe=NULL;
int skinfiles;
#endif
galiasgroup_t *fgroup=NULL;
@ -6254,7 +6221,7 @@ galiasinfo_t *Mod_ParseIQMMeshModel(model_t *mod, char *buffer, size_t fsize)
else
orgbaf = NULL;
dalloc(skin, h->num_meshes*skinfiles);
dalloc(frame, h->num_meshes*skinfiles);
dalloc(skinframe, h->num_meshes*skinfiles);
#endif
dalloc(fgroup, numgroups);
dalloc(oposebase, 12*h->num_joints);
@ -6417,10 +6384,10 @@ galiasinfo_t *Mod_ParseIQMMeshModel(model_t *mod, char *buffer, size_t fsize)
skin->skinheight = 1;
skin->skinspeed = 10; /*something to avoid div by 0*/
skin->numframes = 1; //non-sequenced skins.
skin->frame = frame;
skin->frame = skinframe;
skin++;
Q_strncpyz(frame[j].shadername, strings+mesh[i].material, sizeof(frame[j].shadername));
Q_strncpyz(skinframe[j].shadername, strings+mesh[i].material, sizeof(skinframe[j].shadername));
}
#endif
@ -7321,7 +7288,7 @@ void Alias_Register(void)
Mod_RegisterModelFormatMagic(NULL, "Zymotic Model (zym)", (('O'<<24)+('M'<<16)+('Y'<<8)+'Z'), Mod_LoadZymoticModel);
#endif
#ifdef DPMMODELS
Mod_RegisterModelFormatMagic(NULL, "DarkPlaces Model (dpm)", (('K'<<24)+('R'<<16)+('A'<<8)+'D'), Mod_LoadDarkPlacesModel);
// Mod_RegisterModelFormatMagic(NULL, "DarkPlaces Model (dpm)", (('K'<<24)+('R'<<16)+('A'<<8)+'D'), Mod_LoadDarkPlacesModel);
#endif
#ifdef PSKMODELS
Mod_RegisterModelFormatMagic(NULL, "Unreal Interchange Model (psk)", ('A'<<0)+('C'<<8)+('T'<<16)+('R'<<24), Mod_LoadPSKModel);

View file

@ -1,3 +1,6 @@
#ifdef __cplusplus
extern "C" {
#endif
#include "hash.h"
#include "shader.h"
@ -182,11 +185,20 @@ typedef struct
void (QDECL *ConcatTransforms) (float in1[3][4], float in2[3][4], float out[3][4]);
void (QDECL *M3x4_Invert) (const float *in1, float *out);
void (QDECL *StripExtension) (const char *in, char *out, int outlen);
void (QDECL *VectorAngles)(float *forward, float *up, float *result);
void (QDECL *AngleVectors)(const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
void (QDECL *GenMatrixPosQuat4Scale)(vec3_t pos, vec4_t quat, vec3_t scale, float result[12]);
void (QDECL *StripExtension) (const char *in, char *out, int outlen);
void (QDECL *ForceConvertBoneData)(skeltype_t sourcetype, const float *sourcedata, size_t bonecount, galiasbone_t *bones, skeltype_t desttype, float *destbuffer, size_t destbonecount);
void (QDECL *LinkEdict)(world_t *w, wedict_t *ed, qboolean touchtriggers);
qboolean (QDECL *RegisterPhysicsEngine)(const char *enginename, void(QDECL*World_Bullet_Start)(world_t*world)); //returns false if there's already one active.
void (QDECL *UnregisterPhysicsEngine)(const char *enginename); //returns false if there's already one active.
qboolean (QDECL *GenerateCollisionMesh)(world_t *world, model_t *mod, wedict_t *ed, vec3_t geomcenter);
void (QDECL *ReleaseCollisionMesh) (wedict_t *ed);
} modplugfuncs_t;
#define MODPLUGFUNCS_VERSION 1
#define MODPLUGFUNCS_VERSION 2
#ifdef SKELETALMODELS
void Alias_TransformVerticies(float *bonepose, galisskeletaltransforms_t *weights, int numweights, vecV_t *xyzout, vec3_t *normout);
@ -210,3 +222,7 @@ qboolean QDECL Mod_LoadHLModel (model_t *mod, void *buffer, size_t fsize);
void Mod_AccumulateTextureVectors(vecV_t *vc, vec2_t *tc, vec3_t *nv, vec3_t *sv, vec3_t *tv, index_t *idx, int numidx);
void Mod_AccumulateMeshTextureVectors(mesh_t *mesh);
void Mod_NormaliseTextureVectors(vec3_t *n, vec3_t *s, vec3_t *t, int v);
#ifdef __cplusplus
};
#endif

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -4592,13 +4592,6 @@ void COM_Version_f (void)
#endif
Con_Printf("Misc:");
#ifdef ODE_STATIC
Con_Printf(" ODE(static)");
#elif defined(USEODE)
Con_Printf(" ODE(dynamic)");
#else
Con_Printf(" ^h(disabled: ODE)^7");
#endif
#ifdef SUBSERVERS
Con_Printf(" mapcluster(enabled)");
#else

View file

@ -527,7 +527,7 @@ qbyte *COM_LoadFile (const char *path, int usehunk, size_t *filesize);
qboolean COM_LoadMapPackFile(const char *name, qofs_t offset);
void COM_FlushTempoaryPacks(void);
void COM_EnumerateFiles (const char *match, int (QDECL *func)(const char *fname, qofs_t fsize, void *parm, searchpathfuncs_t *spath), void *parm);
void COM_EnumerateFiles (const char *match, int (QDECL *func)(const char *fname, qofs_t fsize, time_t mtime, void *parm, searchpathfuncs_t *spath), void *parm);
extern struct cvar_s registered;
extern qboolean standard_quake; //fixme: remove

View file

@ -1133,7 +1133,7 @@ qboolean Cvar_Register (cvar_t *variable, const char *groupname)
return true;
}
cvar_t *Cvar_Get(const char *name, const char *defaultvalue, int flags, const char *group)
cvar_t *Cvar_Get2(const char *name, const char *defaultvalue, int flags, const char *description, const char *group)
{
cvar_t *var;
int old;
@ -1151,12 +1151,19 @@ cvar_t *Cvar_Get(const char *name, const char *defaultvalue, int flags, const ch
}
return var;
}
if (!description)
description = "";
var = (cvar_t*)Z_Malloc(sizeof(cvar_t)+strlen(name)+1);
var = (cvar_t*)Z_Malloc(sizeof(cvar_t)+strlen(name)+1+(description?(strlen(description)+1):0));
var->name = (char *)(var+1);
strcpy(var->name, name);
var->string = (char*)defaultvalue;
var->flags = flags|CVAR_POINTER|CVAR_USERCREATED;
if (description)
{
var->description = var->name+strlen(var->name)+1;
strcpy(var->description, description);
}
if (!Cvar_Register(var, group))
return NULL;

View file

@ -149,7 +149,8 @@ typedef struct cvar_group_s
//an alias
#define CVAR_SAVE CVAR_ARCHIVE
cvar_t *Cvar_Get (const char *var_name, const char *value, int flags, const char *groupname);
cvar_t *Cvar_Get2 (const char *var_name, const char *value, int flags, const char *description, const char *groupname);
#define Cvar_Get(n,v,f,g) Cvar_Get2(n,v,f,NULL,g)
void Cvar_LockFromServer(cvar_t *var, const char *str);

View file

@ -593,7 +593,7 @@ COM_Dir_f
============
*/
static int QDECL COM_Dir_List(const char *name, qofs_t size, void *parm, searchpathfuncs_t *spath)
static int QDECL COM_Dir_List(const char *name, qofs_t size, time_t mtime, void *parm, searchpathfuncs_t *spath)
{
searchpath_t *s;
for (s=com_searchpaths ; s ; s=s->next)
@ -1757,7 +1757,7 @@ void FS_FreeFile(void *file)
void COM_EnumerateFiles (const char *match, int (QDECL *func)(const char *, qofs_t, void *, searchpathfuncs_t*), void *parm)
void COM_EnumerateFiles (const char *match, int (QDECL *func)(const char *, qofs_t, time_t mtime, void *, searchpathfuncs_t*), void *parm)
{
searchpath_t *search;
for (search = com_searchpaths; search ; search = search->next)
@ -1828,7 +1828,7 @@ typedef struct {
const char *puredesc;
} wildpaks_t;
static int QDECL FS_AddWildDataFiles (const char *descriptor, qofs_t size, void *vparam, searchpathfuncs_t *funcs)
static int QDECL FS_AddWildDataFiles (const char *descriptor, qofs_t size, time_t mtime, void *vparam, searchpathfuncs_t *funcs)
{
wildpaks_t *param = vparam;
vfsfile_t *vfs;
@ -4025,7 +4025,7 @@ typedef struct
qboolean (*callback)(void *usr, ftemanifest_t *man);
void *usr;
} fmfenums_t;
static int QDECL FS_EnumerateFMFs(const char *fname, qofs_t fsize, void *inf, searchpathfuncs_t *spath)
static int QDECL FS_EnumerateFMFs(const char *fname, qofs_t fsize, time_t mtime, void *inf, searchpathfuncs_t *spath)
{
fmfenums_t *e = inf;
vfsfile_t *f = NULL;

View file

@ -39,7 +39,7 @@ struct searchpathfuncs_s
//note that if rawfile and offset are set, many Com_FileOpens will read the raw file
//otherwise ReadFile will be called instead.
void (QDECL *ReadFile)(searchpathfuncs_t *handle, flocation_t *loc, char *buffer); //reads the entire file in one go (size comes from loc, so make sure the loc is valid, this is for performance with compressed archives)
int (QDECL *EnumerateFiles)(searchpathfuncs_t *handle, const char *match, int (QDECL *func)(const char *fname, qofs_t fsize, void *parm, searchpathfuncs_t *spath), void *parm);
int (QDECL *EnumerateFiles)(searchpathfuncs_t *handle, const char *match, int (QDECL *func)(const char *fname, qofs_t fsize, time_t mtime, void *parm, searchpathfuncs_t *spath), void *parm);
int (QDECL *GeneratePureCRC) (searchpathfuncs_t *handle, int seed, int usepure);

View file

@ -133,7 +133,7 @@ static unsigned int QDECL FSPAK_FLocate(searchpathfuncs_t *handle, flocation_t *
}
return FF_NOTFOUND;
}
static int QDECL FSPAK_EnumerateFiles (searchpathfuncs_t *handle, const char *match, int (QDECL *func)(const char *, qofs_t, void *, searchpathfuncs_t *spath), void *parm)
static int QDECL FSPAK_EnumerateFiles (searchpathfuncs_t *handle, const char *match, int (QDECL *func)(const char *, qofs_t, time_t mtime, void *, searchpathfuncs_t *spath), void *parm)
{
pack_t *pak = (pack_t*)handle;
int num;
@ -142,7 +142,8 @@ static int QDECL FSPAK_EnumerateFiles (searchpathfuncs_t *handle, const char *ma
{
if (wildcmp(match, pak->files[num].name))
{
if (!func(pak->files[num].name, pak->files[num].filelen, parm, handle))
//FIXME: time 0? maybe use the pak's mtime?
if (!func(pak->files[num].name, pak->files[num].filelen, 0, parm, handle))
return false;
}
}

View file

@ -224,7 +224,7 @@ static qboolean QDECL FSSTDIO_PollChanges(searchpathfuncs_t *handle)
// stdiopath_t *np = handle;
return true; //can't verify that or not, so we have to assume the worst
}
static int QDECL FSSTDIO_RebuildFSHash(const char *filename, qofs_t filesize, void *data, searchpathfuncs_t *spath)
static int QDECL FSSTDIO_RebuildFSHash(const char *filename, qofs_t filesize, time_t mtime, void *data, searchpathfuncs_t *spath)
{
stdiopath_t *sp = (void*)spath;
void (QDECL *AddFileHash)(int depth, const char *fname, fsbucket_t *filehandle, void *pathhandle) = data;
@ -310,7 +310,7 @@ static void QDECL FSSTDIO_ReadFile(searchpathfuncs_t *handle, flocation_t *loc,
fclose(f);
}
static int QDECL FSSTDIO_EnumerateFiles (searchpathfuncs_t *handle, const char *match, int (QDECL *func)(const char *, qofs_t, void *, searchpathfuncs_t *spath), void *parm)
static int QDECL FSSTDIO_EnumerateFiles (searchpathfuncs_t *handle, const char *match, int (QDECL *func)(const char *, qofs_t, time_t mtime, void *, searchpathfuncs_t *spath), void *parm)
{
stdiopath_t *sp = (stdiopath_t*)handle;
return Sys_EnumerateFiles(sp->rootpath, match, func, parm, handle);

View file

@ -351,7 +351,7 @@ static qboolean QDECL VFSW32_PollChanges(searchpathfuncs_t *handle)
}
return result;
}
static int QDECL VFSW32_RebuildFSHash(const char *filename, qofs_t filesize, void *handle, searchpathfuncs_t *spath)
static int QDECL VFSW32_RebuildFSHash(const char *filename, qofs_t filesize, time_t mtime, void *handle, searchpathfuncs_t *spath)
{
vfsw32path_t *wp = (void*)spath;
if (filename[strlen(filename)-1] == '/')
@ -446,7 +446,7 @@ static void QDECL VFSW32_ReadFile(searchpathfuncs_t *handle, flocation_t *loc, c
fread(buffer, 1, loc->len, f);
fclose(f);
}
static int QDECL VFSW32_EnumerateFiles (searchpathfuncs_t *handle, const char *match, int (QDECL *func)(const char *, qofs_t, void *, searchpathfuncs_t *spath), void *parm)
static int QDECL VFSW32_EnumerateFiles (searchpathfuncs_t *handle, const char *match, int (QDECL *func)(const char *, qofs_t, time_t mtime, void *, searchpathfuncs_t *spath), void *parm)
{
vfsw32path_t *wp = (vfsw32path_t*)handle;
return Sys_EnumerateFiles(wp->rootpath, match, func, parm, handle);

View file

@ -2,6 +2,7 @@
#include "fs.h"
#ifdef AVAIL_ZLIB
#define ZIPCRYPT
#ifndef ZEXPORT
#define ZEXPORT VARGS
@ -58,6 +59,9 @@ static int (ZEXPORT *qinflate) (z_streamp strm, int flush) ZSTATIC(inflate);
static int (ZEXPORT *qinflateInit2_) (z_streamp strm, int windowBits,
const char *version, int stream_size) ZSTATIC(inflateInit2_);
//static uLong (ZEXPORT *qcrc32) (uLong crc, const Bytef *buf, uInt len) ZSTATIC(crc32);
#ifdef ZIPCRYPT
static const uLongf *(ZEXPORT *qget_crc_table) (void) ZSTATIC(get_crc_table);
#endif
#define qinflateInit2(strm, windowBits) \
qinflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
@ -71,6 +75,9 @@ qboolean LibZ_Init(void)
{(void*)&qinflate, "inflate"},
{(void*)&qinflateInit2_, "inflateInit2_"},
// {(void*)&qcrc32, "crc32"},
#ifdef ZIPCRYPT
{(void*)&qget_crc_table, "get_crc_table"},
#endif
{NULL, NULL}
};
if (!ZLIB_LOADED())
@ -247,6 +254,7 @@ typedef struct
char name[MAX_QPATH];
qofs_t localpos; //location of local header
qofs_t filelen; //uncompressed size
time_t mtime;
unsigned int crc;
unsigned int flags;
} zpackfile_t;
@ -254,6 +262,7 @@ typedef struct
#define ZFL_STORED 2 //direct access is okay
#define ZFL_SYMLINK 4 //file is a symlink
#define ZFL_CORRUPT 8 //file is corrupt or otherwise unreadable.
#define ZFL_WEAKENCRYPT 16 //traditional zip encryption
typedef struct zipfile_s
@ -381,7 +390,7 @@ static void QDECL FSZIP_ReadFile(searchpathfuncs_t *handle, flocation_t *loc, ch
VFS_CLOSE(f);
}
static int QDECL FSZIP_EnumerateFiles (searchpathfuncs_t *handle, const char *match, int (QDECL *func)(const char *, qofs_t, void *, searchpathfuncs_t *spath), void *parm)
static int QDECL FSZIP_EnumerateFiles (searchpathfuncs_t *handle, const char *match, int (QDECL *func)(const char *, qofs_t, time_t mtime, void *, searchpathfuncs_t *spath), void *parm)
{
zipfile_t *zip = (void*)handle;
int num;
@ -390,7 +399,7 @@ static int QDECL FSZIP_EnumerateFiles (searchpathfuncs_t *handle, const char *ma
{
if (wildcmp(match, zip->files[num].name))
{
if (!func(zip->files[num].name, zip->files[num].filelen, parm, &zip->pub))
if (!func(zip->files[num].name, zip->files[num].filelen, zip->files[num].mtime, parm, &zip->pub))
return false;
}
}
@ -437,25 +446,114 @@ struct decompressstate
unsigned char outbuffer[16384];
unsigned int readoffset;
#ifdef ZIPCRYPT
qboolean encrypted;
unsigned int cryptkey[3];
unsigned int initialkey[3];
const int * crctable;
#endif
z_stream strm;
};
struct decompressstate *FSZIP_Decompress_Init(zipfile_t *source, qofs_t start, qofs_t csize, qofs_t usize)
#ifdef ZIPCRYPT
#define CRC32(c, b) ((*(st->crctable+(((int)(c) ^ (b)) & 0xff))) ^ ((c) >> 8))
static void FSZIP_UpdateKeys(struct decompressstate *st, unsigned char ch)
{
st->cryptkey[0] = CRC32(st->cryptkey[0], ch);
st->cryptkey[1] += (st->cryptkey[0] & 0xffu);
st->cryptkey[1] = st->cryptkey[1] * 0x8088405u + 1;
ch = st->cryptkey[1] >> 24;
st->cryptkey[2] = CRC32(st->cryptkey[2], ch);
}
static unsigned char FSZIP_DecryptByte(struct decompressstate *st)
{
unsigned int temp;
temp = (st->cryptkey[2]&0xffff) | 2;
return ((temp * (temp ^ 1)) >> 8) & 0xff;
}
static qboolean FSZIP_SetupCrytoKeys(struct decompressstate *st, const char *password, char *cryptheader, unsigned int crc)
{
unsigned int u;
st->crctable = qget_crc_table();
st->encrypted = true;
st->cryptkey[0] = 0x12345678;
st->cryptkey[1] = 0x23456789;
st->cryptkey[2] = 0x34567890;
while (*password)
FSZIP_UpdateKeys(st, *password++);
for (u = 0; u < 12; u++)
{
unsigned char ch = cryptheader[u] ^ FSZIP_DecryptByte(st);
FSZIP_UpdateKeys(st, ch);
cryptheader[u] = ch;
}
memcpy(st->initialkey, st->cryptkey, sizeof(st->initialkey));
//cryptheader[11] should be the high byte of the file's crc
//[10] might be the second byte, but also might not be.
if (cryptheader[11] != (unsigned char)(crc>>24))
return false;
// if (cryptheader[10] != (unsigned char)(crc>>16))
// return false;
return true;
}
static void FSZIP_DecryptBlock(struct decompressstate *st, char *block, size_t blocksize)
{
while (blocksize--)
{
unsigned char temp = *block ^ FSZIP_DecryptByte(st);
FSZIP_UpdateKeys(st, temp);
*block++ = temp;
}
}
#endif
static struct decompressstate *FSZIP_Decompress_Init(zipfile_t *source, qofs_t start, qofs_t csize, qofs_t usize, char *filename, char *password, unsigned int crc)
{
struct decompressstate *st;
if (!ZLIB_LOADED())
{
Con_Printf("zlib not available\n");
return NULL;
}
st = Z_Malloc(sizeof(*st));
st->source = source;
#ifdef ZIPCRYPT
if (password && csize >= 12)
{
char entropy[12];
if (Sys_LockMutex(source->mutex))
{
VFS_SEEK(source->raw, start);
VFS_READ(source->raw, entropy, sizeof(entropy));
Sys_UnlockMutex(source->mutex);
}
if (!FSZIP_SetupCrytoKeys(st, password, entropy, crc))
{
Con_Printf("Invalid password, cannot decrypt %s\n", filename);
Z_Free(st);
return NULL;
}
start += sizeof(entropy);
csize -= sizeof(entropy);
}
#endif
st->cstart = st->cofs = start;
st->cend = start + csize;
st->usize = usize;
st->strm.data_type = Z_UNKNOWN;
st->source = source;
qinflateInit2(&st->strm, -MAX_WBITS);
return st;
}
qofs_t FSZIP_Decompress_Read(struct decompressstate *st, qbyte *buffer, qofs_t bytes)
static qofs_t FSZIP_Decompress_Read(struct decompressstate *st, qbyte *buffer, qofs_t bytes)
{
qboolean eof = false;
int err;
@ -500,6 +598,10 @@ qofs_t FSZIP_Decompress_Read(struct decompressstate *st, qbyte *buffer, qofs_t b
st->strm.avail_in = 0;
st->strm.next_in = st->inbuffer;
st->cofs += st->strm.avail_in;
#ifdef ZIPCRYPT
if (st->encrypted)
FSZIP_DecryptBlock(st, st->inbuffer, st->strm.avail_in);
#endif
}
if (!st->strm.avail_in)
eof = true;
@ -513,12 +615,12 @@ qofs_t FSZIP_Decompress_Read(struct decompressstate *st, qbyte *buffer, qofs_t b
return read;
}
void FSZIP_Decompress_Destroy(struct decompressstate *st)
static void FSZIP_Decompress_Destroy(struct decompressstate *st)
{
qinflateEnd(&st->strm);
Z_Free(st);
}
vfsfile_t *FSZIP_Decompress_ToTempFile(struct decompressstate *decompress)
static vfsfile_t *FSZIP_Decompress_ToTempFile(struct decompressstate *decompress)
{ //if they're going to seek on a file in a zip, let's just copy it out
qofs_t cstart = decompress->cstart, csize = decompress->cend - cstart;
qofs_t upos = 0, usize = decompress->usize;
@ -527,6 +629,11 @@ vfsfile_t *FSZIP_Decompress_ToTempFile(struct decompressstate *decompress)
qbyte buffer[16384];
vfsfile_t *defer;
zipfile_t *source = decompress->source;
qboolean encrypted = decompress->encrypted;
unsigned int cryptkeys[3];
const uLongf *crctab = decompress->crctable;
memcpy(cryptkeys, decompress->initialkey, sizeof(cryptkeys));
defer = FS_OpenTemp();
if (defer)
@ -534,7 +641,11 @@ vfsfile_t *FSZIP_Decompress_ToTempFile(struct decompressstate *decompress)
FSZIP_Decompress_Destroy(decompress);
decompress = NULL;
nc = FSZIP_Decompress_Init(source, cstart, csize, usize);
nc = FSZIP_Decompress_Init(source, cstart, csize, usize, NULL, NULL, 0);
nc->encrypted = encrypted;
nc->crctable = crctab;
memcpy(nc->initialkey, cryptkeys, sizeof(nc->initialkey));
memcpy(nc->cryptkey, cryptkeys, sizeof(nc->cryptkey));
while (upos < usize)
{
@ -565,7 +676,7 @@ struct decompressstate
// unsigned char outbuffer[16384];
// unsigned int readoffset;
};
struct decompressstate *FSZIP_Decompress_Init(zipfile_t *source, qofs_t start, qofs_t csize, qofs_t usize)
struct decompressstate *FSZIP_Decompress_Init(zipfile_t *source, qofs_t start, qofs_t csize, qofs_t usize, char *filename, char *password, unsigned int crc)
{
return NULL;
}
@ -623,6 +734,9 @@ static int QDECL VFSZIP_ReadBytes (struct vfsfile_s *file, void *buffer, int byt
else
read = 0;
if (read < bytestoread)
((char*)buffer)[read] = 0;
vfsz->pos += read;
return read;
}
@ -637,6 +751,7 @@ static qboolean QDECL VFSZIP_Seek (struct vfsfile_s *file, qofs_t pos)
if (vfsz->decompress)
{ //if they're going to seek on a file in a zip, let's just copy it out
vfsz->defer = FSZIP_Decompress_ToTempFile(vfsz->decompress);
vfsz->decompress = NULL;
if (vfsz->defer)
return VFS_SEEK(vfsz->defer, pos);
return false;
@ -722,7 +837,12 @@ static vfsfile_t *QDECL FSZIP_OpenVFS(searchpathfuncs_t *handle, flocation_t *lo
if (flags & ZFL_DEFLATED)
{
vfsz->decompress = FSZIP_Decompress_Init(zip, vfsz->startpos, datasize, vfsz->length);
#ifdef ZIPCRYPT
char *password = (flags & ZFL_WEAKENCRYPT)?Cvar_Get("fs_zip_password", "thisispublic", 0, "Filesystem")->string:NULL;
#else
char *password = NULL;
#endif
vfsz->decompress = FSZIP_Decompress_Init(zip, vfsz->startpos, datasize, vfsz->length, zip->files[loc->index].name, password, zip->files[loc->index].crc);
if (!vfsz->decompress)
{
/*
@ -794,9 +914,10 @@ struct zipinfo
};
struct zipcentralentry
{
unsigned char *fname;
qofs_t cesize;
unsigned int flags;
unsigned char *fname;
qofs_t cesize;
unsigned int flags;
time_t mtime;
//PK12
unsigned short version_madeby;
@ -991,6 +1112,8 @@ static qboolean FSZIP_ReadCentralEntry(zipfile_t *zip, qbyte *data, struct zipce
entry->fname = data+entry->cesize;
entry->cesize += entry->fnane_len;
entry->mtime = 0;
//parse extra
if (entry->extra_len)
{
@ -1030,11 +1153,30 @@ static qboolean FSZIP_ReadCentralEntry(zipfile_t *zip, qbyte *data, struct zipce
extra += 4;
}
break;
case 0x000a: //NTFS extra field
//0+4: reserved
//4+2: subtag(must be 1, for times)
//6+2: subtagsize(times: must be == 8*3+4)
//8+8: mtime
//16+8: atime
//24+8: ctime
if (extrachunk_len >= 32 && LittleU2FromPtr(extra+4) == 1 && LittleU2FromPtr(extra+6) == 8*3)
entry->mtime = LittleU8FromPtr(extra+8) / 10000000ULL - 11644473600ULL;
else
Con_Printf("zip: unsupported ntfs subchunk %x\n", extrachunk_tag);
extra += extrachunk_len;
break;
case 0x5455:
if (extra[0] & 1)
entry->mtime = LittleU4FromPtr(extra+1);
//access and creation do NOT exist in the central header.
extra += extrachunk_len;
break;
default:
/* Con_Printf("Unknown chunk %x\n", extrachunk_tag);
case 0x000a: //NTFS (timestamps)
case 0x5455: //extended timestamp
case 0x7875: //unix uid/gid
case 0x9901: //aes crypto
*/ extra += extrachunk_len;
break;
}
@ -1061,8 +1203,16 @@ static qboolean FSZIP_ReadCentralEntry(zipfile_t *zip, qbyte *data, struct zipce
}
if (entry->gflags & (1u<<0)) //encrypted
{
#ifdef ZIPCRYPT
entry->flags |= ZFL_WEAKENCRYPT;
#else
entry->flags |= ZFL_CORRUPT;
else if (entry->gflags & (1u<<5)) //is patch data
#endif
}
if (entry->gflags & (1u<<5)) //is patch data
entry->flags |= ZFL_CORRUPT;
else if (entry->gflags & (1u<<6)) //strong encryption
entry->flags |= ZFL_CORRUPT;
@ -1076,7 +1226,7 @@ static qboolean FSZIP_ReadCentralEntry(zipfile_t *zip, qbyte *data, struct zipce
//7: tokenize
else if (entry->cmethod == 8)
entry->flags |= ZFL_DEFLATED;
//8: deflate64 - patented. sometimes written by microsoft's crap. only minor improvements.
//8: deflate64 - patented. sometimes written by microsoft's crap, so this might be problematic. only minor improvements.
//10: implode
//12: bzip2
// else if (entry->cmethod == 12)
@ -1088,6 +1238,9 @@ static qboolean FSZIP_ReadCentralEntry(zipfile_t *zip, qbyte *data, struct zipce
//98: ppmd
else
entry->flags |= ZFL_CORRUPT; //unsupported compression method.
if ((entry->flags & ZFL_WEAKENCRYPT) && !(entry->flags & ZFL_DEFLATED))
entry->flags |= ZFL_CORRUPT; //only support decryption with deflate.
return true;
}
@ -1165,6 +1318,7 @@ static qboolean FSZIP_EnumerateCentralDirectory(zipfile_t *zip, struct zipinfo *
f->filelen = entry.usize;
f->localpos = entry.localheaderoffset+info->zipoffset;
f->flags = entry.flags;
f->mtime = entry.mtime;
ofs += entry.cesize;
f++;
@ -1377,7 +1531,8 @@ searchpathfuncs_t *QDECL FSZIP_LoadArchive (vfsfile_t *packhandle, const char *d
#if 0
//our download protocol permits requesting various different parts of the file.
//this means that its theoretically possible to download sections pk3s such that we can skip blocks that contain files that we already have.
typedef struct
{

File diff suppressed because it is too large Load diff

View file

@ -160,18 +160,6 @@ float anglemod(float a)
return a;
}
/*
==================
BOPS_Error
Split out like this for ASM to call.
==================
*/
void VARGS BOPS_Error (void)
{
Sys_Error ("BoxOnPlaneSide: Bad signbits");
}
/*
==================
BoxOnPlaneSide
@ -200,6 +188,7 @@ int VARGS BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, mplane_t *p)
// general case
switch (p->signbits)
{
default:
case 0:
dist1 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
dist2 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
@ -232,10 +221,6 @@ dist2 = p->normal[0]*emins[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
dist1 = p->normal[0]*emins[0] + p->normal[1]*emins[1] + p->normal[2]*emins[2];
dist2 = p->normal[0]*emaxs[0] + p->normal[1]*emaxs[1] + p->normal[2]*emaxs[2];
break;
default:
dist1 = dist2 = 0; // shut up compiler
BOPS_Error ();
break;
}
#if 0
@ -313,7 +298,7 @@ void VectorVectors(const vec3_t forward, vec3_t right, vec3_t up)
CrossProduct(right, forward, up);
}
void VectorAngles(float *forward, float *up, float *result) //up may be NULL
void QDECL VectorAngles(float *forward, float *up, float *result) //up may be NULL
{
float yaw, pitch, roll;
@ -666,7 +651,7 @@ void FloorDivMod (double numer, double denom, int *quotient,
int q, r;
double x;
#ifndef PARANOID
#ifdef PARANOID
if (denom <= 0.0)
Sys_Error ("FloorDivMod: bad denominator %f\n", denom);

View file

@ -90,6 +90,7 @@ extern vec3_t vec3_origin;
#define Vector2Clear(a) ((a)[0]=(a)[1]=0)
#define Vector2Copy(a,b) do{(b)[0]=(a)[0];(b)[1]=(a)[1];}while(0)
#define Vector2Set(r,x,y) do{(r)[0] = x; (r)[1] = y;}while(0)
#define Vector2MA(a,s,b,c) do{(c)[0] = (a)[0] + (s)*(b)[0];(c)[1] = (a)[1] + (s)*(b)[1];}while(0)
#define Vector2Interpolate(a, bness, b, c) FloatInterpolate((a)[0], bness, (b)[0], (c)[0]),FloatInterpolate((a)[1], bness, (b)[1], (c)[1])
#define Vector4Copy(a,b) do{(b)[0]=(a)[0];(b)[1]=(a)[1];(b)[2]=(a)[2];(b)[3]=(a)[3];}while(0)
@ -131,7 +132,7 @@ typedef struct {
void AddPointToBounds (vec3_t v, vec3_t mins, vec3_t maxs);
float anglemod (float a);
void QDECL AngleVectors (const vec3_t angles, vec3_t forward, vec3_t right, vec3_t up);
void VectorAngles (float *forward, float *up, float *angles); //up may be NULL
void QDECL VectorAngles (float *forward, float *up, float *angles); //up may be NULL
void VARGS BOPS_Error (void);
int VARGS BoxOnPlaneSide (vec3_t emins, vec3_t emaxs, struct mplane_s *plane);
void ClearBounds (vec3_t mins, vec3_t maxs);

View file

@ -88,7 +88,7 @@ cvar_t net_mtu = CVARD("net_mtu", "1440", "Specifies a maximum udp payload size,
cvar_t net_compress = CVARD("net_compress", "0", "Enables huffman compression of network packets.");
cvar_t pext_replacementdeltas = CVAR("pext_replacementdeltas", "1");
cvar_t pext_nqpredinfo = CVAR("debug_pext_nqpredinfo", "0");
cvar_t pext_predinfo = CVAR("debug_pext_predinfo", "0");
/*returns the entire bitmask of supported+enabled extensions*/
unsigned int Net_PextMask(int maskset, qboolean fornq)
@ -198,7 +198,7 @@ unsigned int Net_PextMask(int maskset, qboolean fornq)
if (pext_replacementdeltas.ival)
mask |= PEXT2_REPLACEMENTDELTAS;
if (/*fornq &&*/ pext_nqpredinfo.ival)
if (/*fornq &&*/ pext_predinfo.ival)
mask |= PEXT2_PREDINFO;
if (MAX_CLIENTS != QWMAX_CLIENTS)
@ -242,7 +242,7 @@ void Netchan_Init (void)
Q_snprintfz(qportstr, sizeof(qportstr), "%i", port);
qport.string = qportstr;
Cvar_Register (&pext_nqpredinfo, "Protocol Extensions");
Cvar_Register (&pext_predinfo, "Protocol Extensions");
Cvar_Register (&pext_replacementdeltas, "Protocol Extensions");
Cvar_Register (&showpackets, "Networking");
Cvar_Register (&showdrop, "Networking");

View file

@ -15,6 +15,22 @@
cvar_t plug_sbar = SCVAR("plug_sbar", "1");
cvar_t plug_loaddefault = SCVAR("plug_loaddefault", "1");
qintptr_t Plug_Bullet_Init(qintptr_t *args);
qintptr_t Plug_ODE_Init(qintptr_t *args);
struct
{
const char *name;
qintptr_t (*initfunction)(qintptr_t *args);
} staticplugins[] =
{
#ifdef USERBE
// {"Bullet", Plug_Bullet_Init},
{"ODE", Plug_ODE_Init},
#endif
{NULL}
};
#ifdef GLQUAKE
#include "glquake.h"
#endif
@ -22,7 +38,7 @@ cvar_t plug_loaddefault = SCVAR("plug_loaddefault", "1");
//custom plugin builtins.
typedef qintptr_t (EXPORT_FN *Plug_Builtin_t)(void *offset, quintptr_t mask, const qintptr_t *arg);
void Plug_RegisterBuiltin(char *name, Plug_Builtin_t bi, int flags);
#define PLUG_BIF_DLLONLY 1
#define PLUG_BIF_DLLONLY 1 //WARNING: it is not enough to just specify this flag, but also the builtin code must return if there is an offset passed.
#define PLUG_BIF_QVMONLY 2
#define PLUG_BIF_NEEDSRENDERER 4
@ -120,6 +136,8 @@ void Plug_RegisterBuiltin(char *name, Plug_Builtin_t bi, int flags)
static qintptr_t VARGS Plug_GetNativePointer(void *offset, quintptr_t mask, const qintptr_t *args)
{
char *p = (char *)VM_POINTER(args[0]);
if (offset) //QVMs are not allowed to call this
return 0;
#ifdef SUPPORT_ICE
if (!strcmp(p, ICE_API_CURRENT))
return (qintptr_t)&iceapi;
@ -152,7 +170,7 @@ static void Plug_RegisterBuiltinIndex(char *name, Plug_Builtin_t bi, int flags,
}
*/
static qintptr_t Plug_FindBuiltin(qboolean native, char *p)
static qintptr_t Plug_FindBuiltin(qboolean native, const char *p)
{
int i;
for (i = 0; i < numplugbuiltins; i++)
@ -228,15 +246,15 @@ static qintptr_t EXPORT_FN Plug_SystemCallsNative(qintptr_t arg, ...)
Sys_Error("DLL Plugin tried calling invalid builtin %i", (int)arg);
return 0;
}
qintptr_t (QDECL *plugin_syscall)( qintptr_t arg, ... ) = Plug_SystemCallsNative;
plugin_t *Plug_Load(char *file, int type)
plugin_t *Plug_Load(const char *file, int type)
{
plugin_t *newplug;
for (newplug = plugs; newplug; newplug = newplug->next)
{
if (!stricmp(newplug->name, file))
if (!Q_strcasecmp(newplug->name, file))
return newplug;
}
@ -248,11 +266,21 @@ plugin_t *Plug_Load(char *file, int type)
newplug->vm = VM_Create(va("fteplug_%s", file), Plug_SystemCallsNative, NULL);
if (!newplug->vm && (type & PLUG_QVM))
newplug->vm = VM_Create(file, NULL, Plug_SystemCallsVM);
if (!newplug->vm && (type & PLUG_NATIVE))
{
unsigned int u;
for (u = 0; staticplugins[u].name; u++)
{
if (!Q_strcasecmp(file, staticplugins[u].name))
newplug->vm = VM_CreateBuiltin(file, Plug_SystemCallsNative, staticplugins[u].initfunction);
break;
}
}
currentplug = newplug;
if (newplug->vm)
{
Con_TPrintf("Created plugin %s\n", file);
Con_DPrintf("Created plugin %s\n", file);
newplug->next = plugs;
plugs = newplug;
@ -278,7 +306,7 @@ plugin_t *Plug_Load(char *file, int type)
return newplug;
}
static int QDECL Plug_Emumerated (const char *name, qofs_t size, void *param, searchpathfuncs_t *spath)
static int QDECL Plug_Emumerated (const char *name, qofs_t size, time_t mtime, void *param, searchpathfuncs_t *spath)
{
char vmname[MAX_QPATH];
Q_strncpyz(vmname, name, sizeof(vmname));
@ -288,7 +316,7 @@ static int QDECL Plug_Emumerated (const char *name, qofs_t size, void *param, se
return true;
}
static int QDECL Plug_EnumeratedRoot (const char *name, qofs_t size, void *param, searchpathfuncs_t *spath)
static int QDECL Plug_EnumeratedRoot (const char *name, qofs_t size, time_t mtime, void *param, searchpathfuncs_t *spath)
{
char vmname[MAX_QPATH];
int len;
@ -328,6 +356,19 @@ static qintptr_t VARGS Plug_Sys_Milliseconds(void *offset, quintptr_t mask, cons
{
return Sys_DoubleTime()*1000;
}
static qintptr_t VARGS Plug_Sys_LoadLibrary(void *offset, quintptr_t mask, const qintptr_t *arg)
{
if (offset)
return 0;
return (qintptr_t)Sys_LoadLibrary(VM_POINTER(arg[0]), VM_POINTER(arg[1]));
}
static qintptr_t VARGS Plug_Sys_CloseLibrary(void *offset, quintptr_t mask, const qintptr_t *arg)
{
if (offset)
return 0;
Sys_CloseLibrary(VM_POINTER(arg[0]));
return 1;
}
static qintptr_t VARGS Plug_ExportToEngine(void *offset, quintptr_t mask, const qintptr_t *arg)
{
char *name = (char*)VM_POINTER(arg[0]);
@ -403,6 +444,10 @@ static qintptr_t VARGS Plug_ExportNative(void *offset, quintptr_t mask, const qi
{
void *func;
char *name = (char*)VM_POINTER(arg[0]);
if (offset) //QVMs are not allowed to call this
return 0;
arg++;
func = ((void**)arg)[0];
@ -456,6 +501,18 @@ static qintptr_t VARGS Plug_ExportNative(void *offset, quintptr_t mask, const qi
return 1;
}
static qintptr_t VARGS Plug_Cvar_GetNVFDG(void *offset, quintptr_t mask, const qintptr_t *arg)
{
char *name = VM_POINTER(arg[0]);
char *defaultvalue = VM_POINTER(arg[1]);
unsigned int flags = VM_LONG(arg[2]);
char *description = VM_POINTER(arg[3]);
char *groupname = VM_POINTER(arg[4]);
return (qintptr_t)Cvar_Get2(name, defaultvalue, flags&1, description, groupname);
}
typedef struct {
//Make SURE that the engine has resolved all cvar pointers into globals before this happens.
plugin_t *plugin;
@ -926,7 +983,7 @@ qintptr_t VARGS Plug_VFS_Open(void *offset, quintptr_t mask, const qintptr_t *ar
char *fname = VM_POINTER(arg[0]);
vfsfile_t **handle = VM_POINTER(arg[1]);
char *mode = VM_POINTER(arg[2]);
*handle = FS_OpenVFS(fname, mode, FS_GAME);
*handle = offset?NULL:FS_OpenVFS(fname, mode, FS_GAME);
if (*handle)
return true;
return false;
@ -1282,7 +1339,7 @@ void Plug_Initialise(qboolean fromgamedir)
Cmd_AddCommand("plug_load", Plug_Load_f);
Cmd_AddCommand("plug_list", Plug_List_f);
Plug_RegisterBuiltin("Plug_GetNativePointer", Plug_GetNativePointer, 0);//plugin wishes to find a builtin number.
Plug_RegisterBuiltin("Plug_GetNativePointer", Plug_GetNativePointer, PLUG_BIF_DLLONLY);//plugin wishes to get a native interface.
Plug_RegisterBuiltin("Plug_GetEngineFunction", Plug_GetBuiltin, 0);//plugin wishes to find a builtin number.
Plug_RegisterBuiltin("Plug_ExportToEngine", Plug_ExportToEngine, 0); //plugin has a call back that we might be interested in.
Plug_RegisterBuiltin("Plug_ExportNative", Plug_ExportNative, PLUG_BIF_DLLONLY);
@ -1304,6 +1361,7 @@ void Plug_Initialise(qboolean fromgamedir)
Plug_RegisterBuiltin("Cvar_SetFloat", Plug_Cvar_SetFloat, 0);
Plug_RegisterBuiltin("Cvar_GetString", Plug_Cvar_GetString, 0);
Plug_RegisterBuiltin("Cvar_GetFloat", Plug_Cvar_GetFloat, 0);
Plug_RegisterBuiltin("Cvar_GetNVFDG", Plug_Cvar_GetNVFDG, PLUG_BIF_DLLONLY);
#ifdef HAVE_PACKET
Plug_RegisterBuiltin("Net_TCPListen", Plug_Net_TCPListen, 0);
@ -1338,11 +1396,15 @@ void Plug_Initialise(qboolean fromgamedir)
Plug_RegisterBuiltin("ReadInputBuffer", Plug_ReadInputBuffer, 0);
Plug_RegisterBuiltin("UpdateInputBuffer", Plug_UpdateInputBuffer, 0);
Plug_RegisterBuiltin("Sys_LoadLibrary", Plug_Sys_LoadLibrary, PLUG_BIF_DLLONLY);
Plug_RegisterBuiltin("Sys_CloseLibrary", Plug_Sys_CloseLibrary, PLUG_BIF_DLLONLY);
Plug_Client_Init();
}
if (plug_loaddefault.value)
{
unsigned int u;
if (!fromgamedir)
{
FS_NativePath("", FS_BINARYPATH, nat, sizeof(nat));
@ -1353,6 +1415,10 @@ void Plug_Initialise(qboolean fromgamedir)
{
COM_EnumerateFiles("plugins/*.qvm", Plug_Emumerated, ".qvm");
}
for (u = 0; staticplugins[u].name; u++)
{
Plug_Load(staticplugins[u].name, PLUG_NATIVE);
}
}
}
@ -1659,7 +1725,7 @@ void Plug_Close(plugin_t *plug)
}
if (!com_fatalerror)
Con_Printf("Closing plugin %s\n", plug->name);
Con_DPrintf("Closing plugin %s\n", plug->name);
//ensure any active contexts provided by the plugin are closed (stuff with destroy callbacks)
#if defined(PLUGINS) && !defined(NOMEDIA) && !defined(SERVERONLY)
@ -1805,4 +1871,16 @@ void Plug_Shutdown(qboolean preliminary)
}
}
//for built-in plugins
qboolean Plug_Export(const char *name, qintptr_t(QDECL *func)(qintptr_t *args))
{
qintptr_t args[] = {(qintptr_t)name, (qintptr_t)func};
return Plug_ExportToEngine(NULL, ~(size_t)0, args);
}
void *pPlug_GetEngineFunction(const char *funcname)
{
return (void*)Plug_FindBuiltin(true, funcname);
}
#endif

View file

@ -24,6 +24,8 @@ cvar_t pr_enable_uriget = CVAR("pr_enable_uriget", "1");
cvar_t pr_enable_profiling = CVARD("pr_enable_profiling", "0", "Enables profiling support. Will run more slowly. Change the map and then use the profile_ssqc/profile_csqc commands to see the results.");
int tokenizeqc(const char *str, qboolean dpfuckage);
void PF_buf_shutdown(pubprogfuncs_t *prinst);
void skel_info_f(void);
void skel_generateragdoll_f(void);
void PF_Common_RegisterCvars(void)
@ -98,7 +100,7 @@ static int debuggerstacky;
#include <windows.h>
void INS_UpdateGrabs(int fullscreen, int activeapp);
#endif
int QCLibEditor(pubprogfuncs_t *prinst, char *filename, int line, int statement, int nump, char **parms);
int QCLibEditor(pubprogfuncs_t *prinst, const char *filename, int *line, int *statement, int nump, char **parms);
void QCLoadBreakpoints(const char *vmname, const char *progsname)
{ //this asks the gui to reapply any active breakpoints and waits for them so that any spawn functions can be breakpointed properly.
#if defined(_WIN32) && !defined(SERVERONLY) && !defined(FTE_SDL)
@ -106,11 +108,11 @@ void QCLoadBreakpoints(const char *vmname, const char *progsname)
if (isPlugin >= 2)
{
Sys_SendKeyEvents();
debuggerresume = false;
debuggerresume = -1;
printf("qcreloaded \"%s\" \"%s\"\n", vmname, progsname);
fflush(stdout);
INS_UpdateGrabs(false, false);
while(debuggerresume != 2)
while(debuggerresume == -1)
{
Sleep(10);
Sys_SendKeyEvents();
@ -120,25 +122,48 @@ void QCLoadBreakpoints(const char *vmname, const char *progsname)
}
extern cvar_t pr_sourcedir;
pubprogfuncs_t *debuggerinstance;
const char *debuggerfile;
size_t debuggerwnd;
qboolean QCExternalDebuggerCommand(char *text)
{
if ((!strncmp(text, "qcstep", 6) && (text[6] == 0 || text[6] == ' ')) || (!strncmp(text, "qcresume", 8) && (text[8] == 0 || text[8] == ' ')))
{
int l;
// int l;
if (text[2] == 's')
{
debuggerresume = true;
l = atoi(text+7);
text += 6;
while(*text==' ' || *text=='\t')
text++;
if (!strncmp(text, "out", 3))
debuggerresume = DEBUG_TRACE_OUT;
else if (!strncmp(text, "over", 3))
debuggerresume = DEBUG_TRACE_OVER;
else
debuggerresume = DEBUG_TRACE_INTO;
// l = atoi(text+7);
}
else
{
l = atoi(text+9);
debuggerresume = 2;
// l = atoi(text+9);
debuggerresume = DEBUG_TRACE_OFF;
}
// if (l)
// debuggerresumeline = l;
}
else if (!strncmp(text, "qcjump ", 7))
{
char file[MAX_QPATH];
char linebuf[32];
text += 7;
text = COM_ParseOut(text, file, sizeof(file));
text = COM_ParseOut(text, linebuf, sizeof(linebuf));
if (debuggerinstance && debuggerfile && !Q_strcasecmp(file, debuggerfile))
{
debuggerresumeline = atoi(linebuf);
debuggerresume = DEBUG_TRACE_NORESUME; //'resume' from the debugger only to break again, so we know the new line number (if they tried setting the line to a blank one)
}
if (l)
debuggerresumeline = l;
}
else if (!strncmp(text, "debuggerwnd ", 11))
{
@ -243,23 +268,34 @@ qboolean QCExternalDebuggerCommand(char *text)
return true;
}
int QDECL QCEditor (pubprogfuncs_t *prinst, char *filename, int line, int statement, int nump, char **parms)
int QDECL QCEditor (pubprogfuncs_t *prinst, const char *filename, int *line, int *statement, char *reason)
{
#if defined(_WIN32) && !defined(SERVERONLY) && !defined(FTE_SDL)
if (isPlugin >= 2)
{
if (!*filename) //don't try editing an empty line, it won't work
return line;
if (!*filename || !line || !*line) //don't try editing an empty line, it won't work
return DEBUG_TRACE_OFF;
Sys_SendKeyEvents();
debuggerresume = false;
debuggerresumeline = line;
debuggerresume = -1;
debuggerresumeline = *line;
if (debuggerwnd)
SetForegroundWindow((HWND)debuggerwnd);
printf("qcstep \"%s\":%i\n", filename, line);
if (reason)
{
char tmpbuffer[8192];
printf("qcfault \"%s\":%i %s\n", filename, *line, COM_QuotedString(reason, tmpbuffer, sizeof(tmpbuffer), false));
}
else
printf("qcstep \"%s\":%i\n", filename, *line);
fflush(stdout);
INS_UpdateGrabs(false, false);
debuggerinstance = prinst;
while(!debuggerresume)
debuggerfile = filename;
if (reason)
Con_Footerf(false, "^bDebugging: %s", reason);
else
Con_Footerf(false, "^bDebugging");
while(debuggerresume == -1)
{
Sleep(10);
Sys_SendKeyEvents();
@ -267,7 +303,7 @@ int QDECL QCEditor (pubprogfuncs_t *prinst, char *filename, int line, int statem
if (qrenderer)
{
//FIXME: display a stack trace and locals instead
R2D_ImageColours((sin(Sys_DoubleTime())+1)*0.5,0, 0, 1);
R2D_ImageColours(0.1, 0, 0, 1);
R2D_FillBlock(0, 0, vid.width, vid.height);
Con_DrawConsole(vid.height/2, true); //draw console at half-height
debuggerstacky = vid.height/2;
@ -277,26 +313,15 @@ int QDECL QCEditor (pubprogfuncs_t *prinst, char *filename, int line, int statem
VID_SwapBuffers();
}
}
*line = debuggerresumeline;
debuggerinstance = NULL;
if (debuggerresume == 2)
prinst->pr_trace = false;
return debuggerresumeline;
debuggerfile = NULL;
return debuggerresume;
}
#endif
#ifdef TEXTEDITOR
if (!parms)
return QCLibEditor(prinst, filename, line, statement, nump, parms);
else
{
static char oldfuncname[64];
if (!nump && !strncmp(oldfuncname, *parms, sizeof(oldfuncname)))
{
Con_Printf("Executing %s: %s\n", *parms, filename);
Q_strncpyz(oldfuncname, *parms, sizeof(oldfuncname));
}
return line;
}
return QCLibEditor(prinst, filename, line, statement, 0, NULL);
#else
{
int i;
@ -304,12 +329,10 @@ int QDECL QCEditor (pubprogfuncs_t *prinst, char *filename, int line, int statem
char *r;
vfsfile_t *f;
if (line == -1)
return line;
#ifndef CLIENTONLY
SV_EndRedirect();
#endif
if (developer.value)
if (developer.value && line)
{
f = FS_OpenVFS(filename, "rb", FS_GAME);
}
@ -321,10 +344,15 @@ int QDECL QCEditor (pubprogfuncs_t *prinst, char *filename, int line, int statem
f = FS_OpenVFS(buffer, "rb", FS_GAME);
}
if (!f)
Con_Printf("-%s - %i\n", filename, line);
{
if (reason)
Con_Printf("-%s - %i: %s\n", filename, line?*line:*statement, reason);
else
Con_Printf("-%s - %i\n", filename, line?*line:*statement);
}
else
{
for (i = 0; i < line; i++)
for (i = 0; i < *line; i++)
{
VFS_GETS(f, buffer, sizeof(buffer));
}
@ -335,7 +363,7 @@ int QDECL QCEditor (pubprogfuncs_t *prinst, char *filename, int line, int statem
}
}
//PF_break(NULL);
return line;
return DEBUG_TRACE_OVER;
#endif
}
@ -461,8 +489,7 @@ void VARGS PR_BIError(pubprogfuncs_t *progfuncs, char *format, ...)
if (developer.value || !progfuncs)
{
struct globalvars_s *pr_globals = PR_globals(progfuncs, PR_CURRENT);
Con_Printf("%s\n", string);
progfuncs->pr_trace = 1;
PR_RunWarning(progfuncs, "%s\n", string);
G_INT(OFS_RETURN)=0; //just in case it was a float and should be an ent...
G_INT(OFS_RETURN+1)=0;
G_INT(OFS_RETURN+2)=0;
@ -2023,6 +2050,7 @@ void PF_fcloseall (pubprogfuncs_t *prinst)
PF_fclose_i(i);
}
tokenizeqc("", false);
PF_buf_shutdown(prinst); //might as well put this here
}
@ -2052,9 +2080,12 @@ typedef struct prvmsearch_s {
int handle;
pubprogfuncs_t *fromprogs; //share across menu/server
int entries;
char **names;
int *sizes;
struct
{
char *name;
qofs_t size;
time_t mtime;
} *entry;
struct prvmsearch_s *next;
} prvmsearch_t;
prvmsearch_t *prvmsearches;
@ -2082,10 +2113,9 @@ void search_close (pubprogfuncs_t *prinst, int handle)
for (i = 0; i < s->entries; i++)
{
BZ_Free(s->names[i]);
BZ_Free(s->entry[i].name);
}
BZ_Free(s->names);
BZ_Free(s->sizes);
BZ_Free(s->entry);
BZ_Free(s);
return;
@ -2116,10 +2146,9 @@ void search_close_progs(pubprogfuncs_t *prinst, qboolean complain)
for (i = 0; i < s->entries; i++)
{
BZ_Free(s->names[i]);
BZ_Free(s->entry[i].name);
}
BZ_Free(s->names);
BZ_Free(s->sizes);
BZ_Free(s->entry);
BZ_Free(s);
if (prev)
@ -2137,15 +2166,15 @@ void search_close_progs(pubprogfuncs_t *prinst, qboolean complain)
prvm_nextsearchhandle = 0; //might as well.
}
int QDECL search_enumerate(const char *name, qofs_t fsize, void *parm, searchpathfuncs_t *spath)
int QDECL search_enumerate(const char *name, qofs_t fsize, time_t mtime, void *parm, searchpathfuncs_t *spath)
{
prvmsearch_t *s = parm;
s->names = BZ_Realloc(s->names, ((s->entries+64)&~63) * sizeof(char*));
s->sizes = BZ_Realloc(s->sizes, ((s->entries+64)&~63) * sizeof(int));
s->names[s->entries] = BZ_Malloc(strlen(name)+1);
strcpy(s->names[s->entries], name);
s->sizes[s->entries] = fsize;
s->entry = BZ_Realloc(s->entry, ((s->entries+64)&~63) * sizeof(*s->entry));
s->entry[s->entries].name = BZ_Malloc(strlen(name)+1);
strcpy(s->entry[s->entries].name, name);
s->entry[s->entries].size = fsize;
s->entry[s->entries].mtime = mtime;
s->entries++;
return true;
@ -2222,7 +2251,64 @@ void QCBUILTIN PF_search_getfilename (pubprogfuncs_t *prinst, struct globalvars_
if (num < 0 || num >= s->entries)
return;
RETURN_TSTRING(s->names[num]);
RETURN_TSTRING(s->entry[num].name);
return;
}
}
PF_Warningf(prinst, "Search handle wasn't valid\n");
}
void QCBUILTIN PF_search_getfilesize (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
int handle = G_FLOAT(OFS_PARM0);
int num = G_FLOAT(OFS_PARM1);
prvmsearch_t *s;
G_INT(OFS_RETURN) = 0;
for (s = prvmsearches; s; s = s->next)
{
if (s->handle == handle)
{ //close it down.
if (s->fromprogs != prinst)
{
PF_Warningf(prinst, "Search handle wasn't valid with that progs\n");
return;
}
if (num < 0 || num >= s->entries)
return;
G_FLOAT(OFS_RETURN) = s->entry[num].size;
return;
}
}
PF_Warningf(prinst, "Search handle wasn't valid\n");
}
void QCBUILTIN PF_search_getfilemtime (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
int handle = G_FLOAT(OFS_PARM0);
int num = G_FLOAT(OFS_PARM1);
prvmsearch_t *s;
char timestr[128];
G_INT(OFS_RETURN) = 0;
for (s = prvmsearches; s; s = s->next)
{
if (s->handle == handle)
{ //close it down.
if (s->fromprogs != prinst)
{
PF_Warningf(prinst, "Search handle wasn't valid with that progs\n");
return;
}
if (num < 0 || num >= s->entries)
return;
if (s->entry[num].mtime != 0) //return null/empty if the time isn't set/known.
{
strftime(timestr, sizeof(timestr), "%Y-%m-%d %H:%M:%S", localtime(&s->entry[num].mtime));
RETURN_TSTRING(timestr);
}
return;
}
}
@ -3259,6 +3345,19 @@ void QCBUILTIN PF_buf_create (pubprogfuncs_t *prinst, struct globalvars_s *pr_g
{
int i;
const char *type = ((prinst->callargc>0)?PR_GetStringOfs(prinst, OFS_PARM0):"string");
unsigned int flags = ((prinst->callargc>1)?G_FLOAT(OFS_PARM1):0);
if (!Q_strcasecmp(type, "string"))
;
else
{
G_FLOAT(OFS_RETURN) = -1;
return;
}
//flags&1 == saved. apparently.
for (i = 0; i < NUMSTRINGBUFS; i++)
{
if (!strbuflist[i].prinst)
@ -4172,8 +4271,7 @@ void QCBUILTIN PF_mod (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
if (n == 0)
{
Con_Printf("mod by zero\n");
prinst->pr_trace = 1;
PR_RunWarning(prinst, "mod by zero\n");
G_FLOAT(OFS_RETURN) = 0;
}
else
@ -4589,7 +4687,6 @@ void QCBUILTIN PF_externrefcall (pubprogfuncs_t *prinst, struct globalvars_s *pr
for (i = OFS_PARM0; i < OFS_PARM5; i+=3)
VectorCopy(G_VECTOR(i+(2*3)), G_VECTOR(i));
prinst->pr_trace++; //continue debugging.
PR_ExecuteProgram(prinst, f);
}
@ -4656,7 +4753,6 @@ void QCBUILTIN PF_externcall (pubprogfuncs_t *prinst, struct globalvars_s *pr_gl
for (i = OFS_PARM0; i < OFS_PARM5; i+=3)
VectorCopy(G_VECTOR(i+(2*3)), G_VECTOR(i));
prinst->pr_trace++; //continue debugging
PR_ExecuteProgram(prinst, f);
}
else
@ -4672,19 +4768,18 @@ void QCBUILTIN PF_externcall (pubprogfuncs_t *prinst, struct globalvars_s *pr_gl
VectorCopy(G_VECTOR(i+(1*3)), G_VECTOR(i));
G_INT(OFS_PARM0) = failedst;
prinst->pr_trace++; //continue debugging
PR_ExecuteProgram(prinst, f);
}
}
void QCBUILTIN PF_traceon (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
prinst->pr_trace = true;
prinst->debug_trace = DEBUG_TRACE_INTO;
}
void QCBUILTIN PF_traceoff (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
prinst->pr_trace = false;
prinst->debug_trace = DEBUG_TRACE_OFF;
}
void QCBUILTIN PF_coredump (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
@ -4707,36 +4802,7 @@ void QCBUILTIN PF_eprint (pubprogfuncs_t *prinst, struct globalvars_s *pr_global
void QCBUILTIN PF_break (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
#ifdef SERVERONLY //new break code
char *s;
//I would like some sort of network activity here,
//but I don't want to mess up the sequence and stuff
//It should be possible, but would mean that I would
//need to alter the client, or rewrite a bit of the server..
if (pr_globals)
Con_Printf("Break Statement\n");
else if (developer.value!=2)
return; //non developers cann't step.
for(;;)
{
s=Sys_ConsoleInput();
if (s)
{
if (!*s)
break;
else
Con_Printf("%s\n", svprogfuncs->EvaluateDebugString(svprogfuncs, s));
}
}
#elif defined(TEXTEDITOR)
prinst->pr_trace++;
#else //old break code
Con_Printf ("break statement\n");
*(int *)-4 = 0; // dump to debugger
// PR_RunError ("break statement");
#endif
PR_RunWarning (prinst, "break statement");
}
void QCBUILTIN PF_error (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
@ -4757,7 +4823,7 @@ void QCBUILTIN PF_error (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals
{
// SV_Error ("Program error: %s", s);
PF_break(prinst, pr_globals);
prinst->pr_trace = 2;
prinst->debug_trace = DEBUG_TRACE_INTO;
}
else
{
@ -5172,6 +5238,34 @@ void QCBUILTIN PF_numentityfields (pubprogfuncs_t *prinst, struct globalvars_s *
prinst->FieldInfo(prinst, &count);
G_FLOAT(OFS_RETURN) = count;
}
void QCBUILTIN PF_findentityfield (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
const char *fieldname = PR_GetStringOfs(prinst, OFS_PARM0);
unsigned int count = 0, fidx;
fdef_t *fdef;
fdef = prinst->FieldInfo(prinst, &count);
G_FLOAT(OFS_RETURN) = 0;
for (fidx = 0; fidx < count; fidx++)
{
if (!strcmp(fdef->name, fieldname))
{
G_FLOAT(OFS_RETURN) = fidx;
break;
}
}
}
void QCBUILTIN PF_entityfieldref (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
unsigned int fidx = G_FLOAT(OFS_PARM0);
unsigned int count = 0;
fdef_t *fdef;
fdef = prinst->FieldInfo(prinst, &count);
G_INT(OFS_RETURN) = 0;
if (fidx < count)
{
G_INT(OFS_RETURN) = fdef[fidx].ofs;
}
}
//string(float fieldnum)
void QCBUILTIN PF_entityfieldname (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
@ -5256,8 +5350,51 @@ void QCBUILTIN PF_checkcommand (pubprogfuncs_t *prinst, struct globalvars_s *pr_
G_FLOAT(OFS_RETURN) = 0;
}
#ifdef USERBE
void QCBUILTIN PF_physics_enable(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
wedict_t*e = G_WEDICT(prinst, OFS_PARM0);
int isenable = G_FLOAT(OFS_PARM1);
world_t *world = prinst->parms->user;
rbecommandqueue_t cmd;
cmd.command = isenable?RBECMD_ENABLE:RBECMD_DISABLE;
cmd.edict = e;
if (world->rbe)
world->rbe->PushCommand(world, &cmd);
}
void QCBUILTIN PF_physics_addforce(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
wedict_t*e = G_WEDICT(prinst, OFS_PARM0);
float *force = G_VECTOR(OFS_PARM1);
float *relative_ofs = G_VECTOR(OFS_PARM2);
world_t *world = prinst->parms->user;
rbecommandqueue_t cmd;
cmd.command = RBECMD_FORCE;
cmd.edict = e;
VectorCopy(force, cmd.v1);
VectorCopy(relative_ofs, cmd.v2);
if (world->rbe)
world->rbe->PushCommand(world, &cmd);
}
void QCBUILTIN PF_physics_addtorque(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{
wedict_t*e = G_WEDICT(prinst, OFS_PARM0);
float *torque = G_VECTOR(OFS_PARM1);
world_t *world = prinst->parms->user;
rbecommandqueue_t cmd;
cmd.command = RBECMD_TORQUE;
cmd.edict = e;
VectorCopy(torque, cmd.v1);
if (world->rbe)
world->rbe->PushCommand(world, &cmd);
}
#endif
@ -5497,13 +5634,13 @@ lh_extension_t QSG_Extensions[] = {
{"DP_EF_FULLBRIGHT"}, //Rerouted to hexen2 support.
{"DP_EF_NODRAW"}, //implemented by sending it with no modelindex
{"DP_EF_RED"},
{"DP_ENT_COLORMOD"},
// {"DP_ENT_COLORMOD"},
{"DP_ENT_CUSTOMCOLORMAP"},
{"DP_ENT_EXTERIORMODELTOCLIENT"},
//only in dp6 currently {"DP_ENT_GLOW"},
{"DP_ENT_VIEWMODEL"},
{"DP_GECKO_SUPPORT", 7, NULL, {"gecko_create", "gecko_destroy", "gecko_navigate", "gecko_keyevent", "gecko_mousemove", "gecko_resize", "gecko_get_texture_extent"}},
{"DP_GFX_QUAKE3MODELTAGS"},
// {"DP_GFX_QUAKE3MODELTAGS"},
{"DP_GFX_SKINFILES"},
{"DP_GFX_SKYBOX"}, //according to the spec. :)
{"DP_HALFLIFE_MAP_CVAR"},

View file

@ -34,7 +34,7 @@ struct wedict_s
link_t area;
pvscache_t pvsinfo;
#ifdef USEODE
#ifdef USERBE
entityode_t ode;
#endif
/*the above is shared with ssqc*/
@ -46,15 +46,14 @@ struct wedict_s
#define PF_cin_getstate PF_Fixme
#define PF_cin_restart PF_Fixme
#define PF_drawline PF_Fixme
#define PF_gecko_create PF_Fixme
#define PF_gecko_destroy PF_Fixme
#define PF_gecko_navigate PF_Fixme
#define PF_gecko_keyevent PF_Fixme
#define PF_gecko_movemouse PF_Fixme
#define PF_gecko_resize PF_Fixme
#define PF_gecko_get_texture_extent PF_Fixme
#define PF_media_create_http PF_Fixme
#define PF_media_destroy PF_Fixme
#define PF_media_command PF_Fixme
#define PF_media_keyevent PF_Fixme
#define PF_media_movemouse PF_Fixme
#define PF_media_resize PF_Fixme
#define PF_media_get_texture_extent PF_Fixme
#define PF_gecko_mousemove PF_Fixme
#define PF_WritePicture PF_Fixme
#define PF_ReadPicture PF_Fixme
@ -166,6 +165,8 @@ void QCBUILTIN PF_search_begin (pubprogfuncs_t *prinst, struct globalvars_s *pr_
void QCBUILTIN PF_search_end (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_search_getsize (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_search_getfilename (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_search_getfilesize (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_search_getfilemtime (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_isfunction (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_callfunction (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_writetofile(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
@ -188,6 +189,8 @@ char *PF_VarString (pubprogfuncs_t *prinst, int first, struct globalvars_s *pr_g
void PR_ProgsAdded(pubprogfuncs_t *prinst, int newprogs, const char *modulename);
void PR_AutoCvar(pubprogfuncs_t *prinst, cvar_t *var);
void QCBUILTIN PF_numentityfields (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_findentityfield (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_entityfieldref (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_entityfieldname (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_entityfieldtype (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_getentityfieldstring (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
@ -338,6 +341,8 @@ void QCBUILTIN PF_CL_drawresetcliparea (pubprogfuncs_t *prinst, struct globalvar
void QCBUILTIN PF_CL_drawgetimagesize (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_CL_stringwidth (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_CL_drawsubpic (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_CL_drawrotpic (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_CL_drawrotsubpic (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_CL_findfont (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_CL_loadfont (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
#if defined(CSQC_DAT) && !defined(SERVERONLY)
@ -375,13 +380,14 @@ void QCBUILTIN PF_cl_setmousetarget (pubprogfuncs_t *prinst, struct globalvars_s
void QCBUILTIN PF_cl_getmousetarget (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_cl_playingdemo (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_cl_runningserver (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_cs_gecko_create (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_cs_gecko_destroy (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_cs_gecko_navigate (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_cs_gecko_keyevent (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_cs_gecko_mousemove (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_cs_gecko_resize (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_cs_gecko_get_texture_extent (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_cs_media_create_http (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_cs_media_destroy (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_cs_media_command (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_cs_media_keyevent (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_cs_media_mousemove (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_cs_media_resize (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_cs_media_get_texture_extent (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_cs_media_getposition (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
typedef enum{
SLIST_HOSTCACHEVIEWCOUNT,
SLIST_HOSTCACHETOTALCOUNT,
@ -394,6 +400,10 @@ typedef enum{
} hostcacheglobal_t;
void QCBUILTIN PF_shaderforname (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_cl_sprint (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_cl_bprint (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void QCBUILTIN PF_cl_clientcount (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
void search_close_progs(pubprogfuncs_t *prinst, qboolean complain);
void QCBUILTIN PF_buf_create (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
@ -432,11 +442,11 @@ void QCBUILTIN PF_gettime (pubprogfuncs_t *prinst, struct globalvars_s *pr_globa
void QCBUILTIN PF_whichpack (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals);
int QDECL QCEditor (pubprogfuncs_t *prinst, char *filename, int line, int statement, int nump, char **parms);
int QDECL QCEditor (pubprogfuncs_t *prinst, const char *filename, int *line, int *statement, char *reason);
void PR_Common_Shutdown(pubprogfuncs_t *progs, qboolean errored);
//FIXME
pbool PR_RunWarning (pubprogfuncs_t *ppf, char *error, ...);
/*these are server ones, provided by pr_cmds.c, as required by pr_q1qvm.c*/

View file

@ -73,7 +73,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define PEXT2_PRYDONCURSOR 0x00000001
#define PEXT2_VOICECHAT 0x00000002
#define PEXT2_SETANGLEDELTA 0x00000004
#define PEXT2_REPLACEMENTDELTAS 0x00000008
#define PEXT2_REPLACEMENTDELTAS 0x00000008 //weaponframe was part of the entity state. that flag is now the player's v_angle.
#define PEXT2_MAXPLAYERS 0x00000010 //Client is able to cope with more players than 32. abs max becomes 255, due to colormap issues.
#define PEXT2_PREDINFO 0x00000020 //movevar stats, NQ input sequences+acks.
@ -628,7 +628,8 @@ enum clcq2_ops_e
#define UFP_VELOCITYXY (1u<<4)
#define UFP_VELOCITYZ (1u<<5)
#define UFP_MSEC (1u<<6)
#define UFP_WEAPONFRAME (1u<<7)
#define UFP_WEAPONFRAME_OLD (1u<<7) //no longer used. just a stat now that I rewrote stat deltas.
#define UFP_VIEWANGLE (1u<<7)
#define UF_REMOVE UF_16BIT /*special flag, slightly more compact (we can reuse the 16bit flag as its not important)*/
@ -974,6 +975,7 @@ typedef struct entity_state_s
/*info to predict other players, so I don't get yelled at if fte were to stop supporting it*/
qbyte pmovetype;
qbyte msec;
short vangle[3];
unsigned short weaponframe;
short movement[3];

View file

@ -187,7 +187,7 @@ typedef struct {
int bufferleft;
int skip;
} vmsearch_t;
static int QDECL VMEnum(const char *match, qofs_t size, void *args, searchpathfuncs_t *spath)
static int QDECL VMEnum(const char *match, qofs_t size, time_t mtime, void *args, searchpathfuncs_t *spath)
{
char *check;
int newlen;
@ -211,13 +211,13 @@ static int QDECL VMEnum(const char *match, qofs_t size, void *args, searchpathfu
return true;
}
static int QDECL IfFound(const char *match, qofs_t size, void *args, searchpathfuncs_t *spath)
static int QDECL IfFound(const char *match, qofs_t size, time_t modtime, void *args, searchpathfuncs_t *spath)
{
*(qboolean*)args = true;
return true;
}
static int QDECL VMEnumMods(const char *match, qofs_t size, void *args, searchpathfuncs_t *spath)
static int QDECL VMEnumMods(const char *match, qofs_t size, time_t modtime, void *args, searchpathfuncs_t *spath)
{
char *check;
char desc[1024];

View file

@ -49,7 +49,8 @@ typedef enum vm_type_e
{
VM_NONE,
VM_NATIVE,
VM_BYTECODE
VM_BYTECODE,
VM_BUILTIN
} vm_type_t;
struct vm_s {
@ -899,13 +900,17 @@ void VM_PrintInfo(vm_t *vm)
{
qvm_t *qvm;
Con_Printf("%s (%p): ", vm->name, vm->hInst);
// Con_Printf("%s (%p): ", vm->name, vm->hInst);
Con_Printf("%s: ", vm->name);
switch(vm->type)
{
case VM_NATIVE:
Con_Printf("native\n");
break;
case VM_BUILTIN:
Con_Printf("built in\n");
break;
case VM_BYTECODE:
Con_Printf("interpreted\n");
@ -923,6 +928,17 @@ void VM_PrintInfo(vm_t *vm)
}
}
vm_t *VM_CreateBuiltin(const char *name, sys_calldll_t syscalldll, qintptr_t (*init)(qintptr_t *args))
{
vm_t *vm = Z_Malloc(sizeof(vm_t));
Q_strncpyz(vm->name, name, sizeof(vm->name));
vm->syscalldll = syscalldll;
vm->syscallqvm = NULL;
vm->hInst = init;
vm->type = VM_BUILTIN;
return vm;
}
/*
** VM_Create
*/
@ -987,6 +1003,7 @@ void VM_Destroy(vm_t *vm)
if(vm->hInst) QVM_UnLoadVM(vm->hInst);
break;
case VM_BUILTIN:
case VM_NONE:
break;
}
@ -1033,6 +1050,7 @@ void *VM_MemoryBase(vm_t *vm)
switch(vm->type)
{
case VM_NATIVE:
case VM_BUILTIN:
return NULL;
case VM_BYTECODE:
return ((qvm_t*)vm->hInst)->ds;
@ -1059,6 +1077,7 @@ qboolean VM_NonNative(vm_t *vm)
case VM_BYTECODE:
return sizeof(int) != sizeof(void*);
case VM_NATIVE:
case VM_BUILTIN:
return false;
default:
return false;
@ -1071,28 +1090,33 @@ qboolean VM_NonNative(vm_t *vm)
qintptr_t VARGS VM_Call(vm_t *vm, qintptr_t instruction, ...)
{
va_list argptr;
qintptr_t arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7;
qintptr_t arg[8];
if(!vm) Sys_Error("VM_Call with NULL vm");
va_start(argptr, instruction);
arg0=va_arg(argptr, qintptr_t);
arg1=va_arg(argptr, qintptr_t);
arg2=va_arg(argptr, qintptr_t);
arg3=va_arg(argptr, qintptr_t);
arg4=va_arg(argptr, qintptr_t);
arg5=va_arg(argptr, qintptr_t);
arg6=va_arg(argptr, qintptr_t);
arg7=va_arg(argptr, qintptr_t);
arg[0]=va_arg(argptr, qintptr_t);
arg[1]=va_arg(argptr, qintptr_t);
arg[2]=va_arg(argptr, qintptr_t);
arg[3]=va_arg(argptr, qintptr_t);
arg[4]=va_arg(argptr, qintptr_t);
arg[5]=va_arg(argptr, qintptr_t);
arg[6]=va_arg(argptr, qintptr_t);
arg[7]=va_arg(argptr, qintptr_t);
va_end(argptr);
switch(vm->type)
{
case VM_NATIVE:
return vm->vmMain(instruction, arg0, arg1, arg2, arg3, arg4, arg5, arg6);
return vm->vmMain(instruction, arg[0], arg[1], arg[2], arg[3], arg[4], arg[5], arg[6]);
case VM_BYTECODE:
return QVM_ExecVM(vm->hInst, instruction, arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
return QVM_ExecVM(vm->hInst, instruction, arg[0], arg[1], arg[2], arg[3], arg[4], arg[5], arg[6], arg[7]);
case VM_BUILTIN:
if (!instruction)
instruction = (qintptr_t)vm->hInst;
return ((qintptr_t(*)(qintptr_t*))instruction)(arg);
case VM_NONE:
return 0;

View file

@ -87,7 +87,7 @@ void Sys_ServerActivity(void);
void Sys_SendKeyEvents (void);
// Perform Key_Event () callbacks until the input que is empty
int Sys_EnumerateFiles (const char *gpath, const char *match, int (QDECL *func)(const char *fname, qofs_t fsize, void *parm, searchpathfuncs_t *spath), void *parm, searchpathfuncs_t *spath);
int Sys_EnumerateFiles (const char *gpath, const char *match, int (QDECL *func)(const char *fname, qofs_t fsize, time_t modtime, void *parm, searchpathfuncs_t *spath), void *parm, searchpathfuncs_t *spath);
void Sys_Vibrate(float count);

View file

@ -60,6 +60,7 @@ typedef struct vm_s vm_t;
// ------------------------- * interface * -------------------------
void VM_PrintInfo(vm_t *vm);
vm_t *VM_CreateBuiltin(const char *name, sys_calldll_t syscalldll, qintptr_t (*init)(qintptr_t *args));
vm_t *VM_Create(const char *name, sys_calldll_t syscalldll, sys_callqvm_t syscallqvm);
void VM_Destroy(vm_t *vm);
//qboolean VM_Restart(vm_t *vm);

View file

@ -148,6 +148,25 @@ typedef struct
vec3_t laggedpos;
} laggedentinfo_t;
#ifdef USERBE
typedef struct
{
void (QDECL *End)(struct world_s *world);
void (QDECL *RemoveJointFromEntity)(struct world_s *world, wedict_t *ed);
void (QDECL *RemoveFromEntity)(struct world_s *world, wedict_t *ed);
qboolean (QDECL *RagMatrixToBody)(rbebody_t *bodyptr, float *mat);
qboolean (QDECL *RagCreateBody)(struct world_s *world, rbebody_t *bodyptr, rbebodyinfo_t *bodyinfo, float *mat, wedict_t *ent);
void (QDECL *RagMatrixFromJoint)(rbejoint_t *joint, rbejointinfo_t *info, float *mat);
void (QDECL *RagMatrixFromBody)(struct world_s *world, rbebody_t *bodyptr, float *mat);
void (QDECL *RagEnableJoint)(rbejoint_t *joint, qboolean enabled);
void (QDECL *RagCreateJoint)(struct world_s *world, rbejoint_t *joint, rbejointinfo_t *info, rbebody_t *body1, rbebody_t *body2, vec3_t aaa2[3]);
void (QDECL *RagDestroyBody)(struct world_s *world, rbebody_t *bodyptr);
void (QDECL *RagDestroyJoint)(struct world_s *world, rbejoint_t *joint);
void (QDECL *Frame)(struct world_s *world, double frametime, double gravity);
void (QDECL *PushCommand)(struct world_s *world, rbecommandqueue_t *cmd);
} rigidbodyengine_t;
#endif
struct world_s
{
void (*Event_Touch)(struct world_s *w, wedict_t *s, wedict_t *o);
@ -199,32 +218,41 @@ struct world_s
float *drawfontscale;
} g;
#ifdef USEODE
worldode_t ode;
#ifdef USERBE
qboolean rbe_hasphysicsents;
rigidbodyengine_t *rbe;
#endif
};
typedef struct world_s world_t;
void PF_Common_RegisterCvars(void);
#ifdef USEODE
void World_ODE_RemoveFromEntity(world_t *world, wedict_t *ed);
void World_ODE_RemoveJointFromEntity(world_t *world, wedict_t *ed);
void World_ODE_Frame(world_t *world, double frametime, double gravity);
void World_ODE_Init(void);
void World_ODE_Start(world_t *world);
void World_ODE_End(world_t *world);
void World_ODE_Shutdown(void);
qboolean World_ODE_RagCreateBody(world_t *world, odebody_t *bodyptr, odebodyinfo_t *bodyinfo, float *mat, wedict_t *ent);
qboolean World_ODE_RagMatrixToBody(odebody_t *bodyptr, float *mat);
void World_ODE_RagMatrixFromBody(world_t *world, odebody_t *bodyptr, float *mat);
void World_ODE_RagDestroyBody(world_t *world, odebody_t *bodyptr);
void World_ODE_RagCreateJoint(world_t *world, odejoint_t *joint, odejointinfo_t *info, odebody_t *body1, odebody_t *body2, vec3_t aaa2[3]);
void World_ODE_RagEnableJoint(odejoint_t *joint, qboolean enabled);
void World_ODE_RagMatrixFromJoint(odejoint_t *joint, odejointinfo_t *info, float *mat);
void World_ODE_RagDestroyJoint(world_t *world, odejoint_t *joint);
#endif
qboolean QDECL World_RegisterPhysicsEngine(const char *enginename, void(QDECL*World_Bullet_Start)(world_t*world));
void QDECL World_UnregisterPhysicsEngine(const char *enginename);
qboolean QDECL World_GenerateCollisionMesh(world_t *world, model_t *mod, wedict_t *ed, vec3_t geomcenter);
void QDECL World_ReleaseCollisionMesh(wedict_t *ed);
void World_RBE_Start(world_t *world);
void World_ClearWorld (world_t *w);
// called after the world model has been loaded, before linking any entities
@ -234,7 +262,7 @@ void World_UnlinkEdict (wedict_t *ent);
// so it doesn't clip against itself
// flags ent->v.modified
void World_LinkEdict (world_t *w, wedict_t *ent, qboolean touch_triggers);
void QDECL World_LinkEdict (world_t *w, wedict_t *ent, qboolean touch_triggers);
// Needs to be called any time an entity changes origin, mins, maxs, or solid
// flags ent->v.modified
// sets ent->v.absmin and ent->v.absmax

View file

@ -2,6 +2,7 @@ Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "FTEQuake", "..\setup\setup.vdproj", "{E0EE8B50-3A75-42A9-B80A-787675979B0C}"
ProjectSection(ProjectDependencies) = postProject
{82285268-9C3B-44AD-BBE7-40670F9D2628} = {82285268-9C3B-44AD-BBE7-40670F9D2628}
{9767E236-8454-44E9-8999-CD5BDAFBE9BA} = {9767E236-8454-44E9-8999-CD5BDAFBE9BA}
{72269FEE-293D-40BC-A7AE-E429F4496869} = {72269FEE-293D-40BC-A7AE-E429F4496869}
EndProjectSection
@ -9,9 +10,6 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "botlib", "botlib.vcproj", "{0018E098-B12A-4E4D-9B22-6772DA287080}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fteqcc", "..\qclib\dotnet2005\qcc.vcproj", "{2866F783-6B44-4655-A38D-D53874037454}"
ProjectSection(ProjectDependencies) = postProject
{9767E236-8454-44E9-8999-CD5BDAFBE9BA} = {9767E236-8454-44E9-8999-CD5BDAFBE9BA}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "qtvprox", "..\..\fteqtv\dotnet2005\qtvprox.vcproj", "{62669E6C-7E18-4E4D-BA54-DFBE29E7D24E}"
EndProject
@ -53,6 +51,10 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "targets", "targets", "{EB5D
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "emscripten", "emscripten.vcproj", "{75D91BDE-CC30-4C53-BF33-5F69EF13A61B}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bulletplug", "..\..\plugins\bullet\bulletplug.vcproj", "{82285268-9C3B-44AD-BBE7-40670F9D2628}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "odeplug", "..\..\plugins\odeplug\odeplug.vcproj", "{ED16B405-BDCD-4EB8-BF70-761964301368}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
D3DDebug|Win32 = D3DDebug|Win32
@ -660,6 +662,78 @@ Global
{75D91BDE-CC30-4C53-BF33-5F69EF13A61B}.Release|Win32.ActiveCfg = Release|Win32
{75D91BDE-CC30-4C53-BF33-5F69EF13A61B}.Release|Win32.Build.0 = Release|Win32
{75D91BDE-CC30-4C53-BF33-5F69EF13A61B}.Release|x64.ActiveCfg = Release|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.D3DDebug|Win32.ActiveCfg = Debug|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.D3DDebug|Win32.Build.0 = Debug|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.D3DDebug|x64.ActiveCfg = Debug|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.D3DRelease|Win32.ActiveCfg = Release|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.D3DRelease|Win32.Build.0 = Release|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.D3DRelease|x64.ActiveCfg = Release|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.Debug Dedicated Server|Win32.ActiveCfg = Debug|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.Debug Dedicated Server|Win32.Build.0 = Debug|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.Debug Dedicated Server|x64.ActiveCfg = Debug|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.Debug|Win32.ActiveCfg = Debug|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.Debug|Win32.Build.0 = Debug|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.Debug|x64.ActiveCfg = Debug|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.GLDebug|Win32.ActiveCfg = Debug|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.GLDebug|Win32.Build.0 = Debug|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.GLDebug|x64.ActiveCfg = Debug|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.GLRelease|Win32.ActiveCfg = Release|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.GLRelease|Win32.Build.0 = Release|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.GLRelease|x64.ActiveCfg = Release|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.MDebug|Win32.ActiveCfg = Debug|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.MDebug|Win32.Build.0 = Debug|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.MDebug|x64.ActiveCfg = Debug|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.MinGLDebug|Win32.ActiveCfg = Debug|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.MinGLDebug|Win32.Build.0 = Debug|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.MinGLDebug|x64.ActiveCfg = Debug|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.MinGLRelease|Win32.ActiveCfg = Release|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.MinGLRelease|Win32.Build.0 = Release|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.MinGLRelease|x64.ActiveCfg = Release|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.MRelease|Win32.ActiveCfg = Release|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.MRelease|Win32.Build.0 = Release|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.MRelease|x64.ActiveCfg = Release|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.Release Dedicated Server|Win32.ActiveCfg = Release|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.Release Dedicated Server|Win32.Build.0 = Release|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.Release Dedicated Server|x64.ActiveCfg = Release|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.Release|Win32.ActiveCfg = Release|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.Release|Win32.Build.0 = Release|Win32
{82285268-9C3B-44AD-BBE7-40670F9D2628}.Release|x64.ActiveCfg = Release|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.D3DDebug|Win32.ActiveCfg = Debug|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.D3DDebug|Win32.Build.0 = Debug|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.D3DDebug|x64.ActiveCfg = Debug|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.D3DRelease|Win32.ActiveCfg = Release|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.D3DRelease|Win32.Build.0 = Release|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.D3DRelease|x64.ActiveCfg = Release|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.Debug Dedicated Server|Win32.ActiveCfg = Debug|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.Debug Dedicated Server|Win32.Build.0 = Debug|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.Debug Dedicated Server|x64.ActiveCfg = Debug|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.Debug|Win32.ActiveCfg = Debug|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.Debug|Win32.Build.0 = Debug|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.Debug|x64.ActiveCfg = Debug|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.GLDebug|Win32.ActiveCfg = Debug|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.GLDebug|Win32.Build.0 = Debug|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.GLDebug|x64.ActiveCfg = Debug|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.GLRelease|Win32.ActiveCfg = Release|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.GLRelease|Win32.Build.0 = Release|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.GLRelease|x64.ActiveCfg = Release|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.MDebug|Win32.ActiveCfg = Debug|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.MDebug|Win32.Build.0 = Debug|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.MDebug|x64.ActiveCfg = Debug|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.MinGLDebug|Win32.ActiveCfg = Debug|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.MinGLDebug|Win32.Build.0 = Debug|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.MinGLDebug|x64.ActiveCfg = Debug|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.MinGLRelease|Win32.ActiveCfg = Release|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.MinGLRelease|Win32.Build.0 = Release|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.MinGLRelease|x64.ActiveCfg = Release|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.MRelease|Win32.ActiveCfg = Release|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.MRelease|Win32.Build.0 = Release|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.MRelease|x64.ActiveCfg = Release|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.Release Dedicated Server|Win32.ActiveCfg = Release|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.Release Dedicated Server|Win32.Build.0 = Release|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.Release Dedicated Server|x64.ActiveCfg = Release|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.Release|Win32.ActiveCfg = Release|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.Release|Win32.Build.0 = Release|Win32
{ED16B405-BDCD-4EB8-BF70-761964301368}.Release|x64.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -677,6 +751,8 @@ Global
{72269FEE-293D-40BC-A7AE-E429F4496869} = {8CED01C6-2C61-4EC5-90B6-574D9756D773}
{6ABD62A3-C5A0-43E8-BA4F-84606057774F} = {8CED01C6-2C61-4EC5-90B6-574D9756D773}
{74542CA7-48C1-4664-9007-66F751131EA3} = {8CED01C6-2C61-4EC5-90B6-574D9756D773}
{82285268-9C3B-44AD-BBE7-40670F9D2628} = {8CED01C6-2C61-4EC5-90B6-574D9756D773}
{ED16B405-BDCD-4EB8-BF70-761964301368} = {8CED01C6-2C61-4EC5-90B6-574D9756D773}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
AMDCaProjectFile = C:\Games\Quake\wip\engine\dotnet2005\CodeAnalyst\ftequake.caw

View file

@ -1696,7 +1696,7 @@
PreprocessorDefinitions="NDEBUG;GLQUAKE;WIN32;_WINDOWS;BOTLIB_STATIC;MULTITHREAD"
StringPooling="true"
ExceptionHandling="0"
BufferSecurityCheck="true"
BufferSecurityCheck="false"
EnableEnhancedInstructionSet="2"
FloatingPointModel="2"
RuntimeTypeInfo="false"
@ -25331,178 +25331,6 @@
/>
</FileConfiguration>
</File>
<File
RelativePath="..\common\com_phys_bullet.cpp"
>
<FileConfiguration
Name="MinGLDebug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="MinGLDebug|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="D3DDebug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="D3DDebug|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="MinGLRelease|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="MinGLRelease|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="GLDebug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
CompileAs="2"
/>
</FileConfiguration>
<FileConfiguration
Name="GLDebug|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release Dedicated Server|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release Dedicated Server|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="MRelease|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="MRelease|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug Dedicated Server|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug Dedicated Server|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="MDebug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="MDebug|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="GLRelease|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="GLRelease|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="D3DRelease|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="D3DRelease|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\common\com_phys_ode.c"
>
</File>
<File
RelativePath="..\common\common.c"
>
@ -32040,6 +31868,358 @@
</File>
</Filter>
</Filter>
<Filter
Name="staticplugins"
>
<File
RelativePath="..\common\com_phys_bullet.cpp"
>
<FileConfiguration
Name="MinGLDebug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="MinGLDebug|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="D3DDebug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="D3DDebug|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="MinGLRelease|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="MinGLRelease|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="GLDebug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="GLDebug|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release Dedicated Server|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release Dedicated Server|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="MRelease|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="MRelease|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug Dedicated Server|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug Dedicated Server|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="MDebug|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="MDebug|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="GLRelease|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="GLRelease|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="D3DRelease|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="D3DRelease|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
<File
RelativePath="..\common\com_phys_ode.c"
>
<FileConfiguration
Name="MinGLDebug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="MinGLDebug|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="D3DDebug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="D3DDebug|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="MinGLRelease|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="MinGLRelease|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="GLDebug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="GLDebug|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release Dedicated Server|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Release Dedicated Server|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="MRelease|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="MRelease|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug Dedicated Server|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="Debug Dedicated Server|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="MDebug|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="MDebug|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="GLRelease|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="GLRelease|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="D3DRelease|Win32"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
<FileConfiguration
Name="D3DRelease|x64"
>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
</FileConfiguration>
</File>
</Filter>
</Filter>
<Filter
Name="Resource Files"

View file

@ -143,7 +143,8 @@ void GL_Set2D (qboolean flipped)
vid.fbvwidth = vid.fbpwidth;
vid.fbvheight = vid.fbpheight;
flipped ^= true;
if (strcmp(r_refdef.rt_destcolour[0].texname, "megascreeny"))
flipped ^= true;
}
else
{
@ -376,6 +377,18 @@ qboolean GL_LoadTextureMips(texid_t tex, struct pendingtextureinfo *mips)
}
switch(mips->encoding)
{
case PTI_DEPTH16:
qglTexImage2D(targface, j, gl_config.gles?GL_DEPTH_COMPONENT:GL_DEPTH_COMPONENT16_ARB, mips->mip[i].width, mips->mip[i].height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, mips->mip[i].data);
break;
case PTI_DEPTH24:
qglTexImage2D(targface, j, gl_config.gles?GL_DEPTH_COMPONENT:GL_DEPTH_COMPONENT24_ARB, mips->mip[i].width, mips->mip[i].height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, mips->mip[i].data);
break;
case PTI_DEPTH32:
qglTexImage2D(targface, j, gl_config.gles?GL_DEPTH_COMPONENT:GL_DEPTH_COMPONENT32_ARB, mips->mip[i].width, mips->mip[i].height, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, mips->mip[i].data);
break;
case PTI_DEPTH24_8:
qglTexImage2D(targface, j, GL_DEPTH24_STENCIL8_EXT, mips->mip[i].width, mips->mip[i].height, 0, GL_DEPTH_STENCIL_EXT, GL_UNSIGNED_INT_24_8_EXT, mips->mip[i].data);
break;
//32bit formats
case PTI_RGBX8:
qglTexImage2D(targface, j, GL_RGB, mips->mip[i].width, mips->mip[i].height, 0, GL_RGBA, GL_UNSIGNED_BYTE, mips->mip[i].data);
@ -466,6 +479,8 @@ void GL_UpdateFiltering(image_t *imagelist, int filtermip[3], int filterpic[3],
// change all the existing mipmap texture objects
for (img=imagelist ; img ; img=img->next)
{
if (img->status != TEX_LOADED)
continue;
switch((img->flags & IF_TEXTYPE) >> IF_TEXTYPESHIFT)
{
case 0:
@ -478,8 +493,6 @@ void GL_UpdateFiltering(image_t *imagelist, int filtermip[3], int filterpic[3],
targ = GL_TEXTURE_CUBE_MAP_ARB;
break;
}
if (img->status != TEX_LOADED)
continue;
GL_MTBind(0, targ, img);
GL_Texturemode_Apply(targ, img->flags);

View file

@ -1033,8 +1033,8 @@ int CM_HeadnodeForBox (struct model_s *mod, vec3_t mins, vec3_t maxs);
struct trace_s CM_TransformedBoxTrace (struct model_s *mod, vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs, int brushmask, vec3_t origin, vec3_t angles);
struct model_s *CM_TempBoxModel(vec3_t mins, vec3_t maxs);
void VARGS CMQ2_SetAreaPortalState (unsigned int portalnum, qboolean open);
void CMQ3_SetAreaPortalState (unsigned int area1, unsigned int area2, qboolean open);
void CMQ2_SetAreaPortalState (model_t *mod, unsigned int portalnum, qboolean open);
void CMQ3_SetAreaPortalState (model_t *mod, unsigned int area1, unsigned int area2, qboolean open);
#endif

View file

@ -57,7 +57,6 @@ extern cvar_t r_bloom;
extern cvar_t r_wireframe_smooth;
cvar_t gl_affinemodels = SCVAR("gl_affinemodels","0");
cvar_t gl_reporttjunctions = SCVAR("gl_reporttjunctions","0");
cvar_t gl_finish = SCVAR("gl_finish","0");
cvar_t gl_dither = SCVAR("gl_dither", "1");
extern cvar_t r_stereo_separation;
@ -455,7 +454,7 @@ void R_SetupGL (float stereooffset)
fov_x = r_refdef.fov_x;//+sin(cl.time)*5;
fov_y = r_refdef.fov_y;//-sin(cl.time+1)*5;
if (*r_refdef.rt_destcolour[0].texname || *r_refdef.rt_depth.texname)
if ((*r_refdef.rt_destcolour[0].texname || *r_refdef.rt_depth.texname) && strcmp(r_refdef.rt_destcolour[0].texname, "megascreeny"))
{
r_refdef.pxrect.y = r_refdef.pxrect.maxheight - (r_refdef.pxrect.height+r_refdef.pxrect.y);
fov_y *= -1;
@ -564,6 +563,7 @@ void R_RenderScene (void)
int stereomode;
int i;
int tmpvisents = cl_numvisedicts; /*world rendering is allowed to add additional ents, but we don't want to keep them for recursive views*/
int cull = r_refdef.flipcull;
stereomode = r_stereo_method.ival;
if (stereomode == 1)
@ -629,7 +629,10 @@ void R_RenderScene (void)
break;
}
if (i)
{
GL_ForceDepthWritable();
qglClear (GL_DEPTH_BUFFER_BIT);
}
TRACE(("dbg: calling R_SetupGL\n"));
R_SetupGL (stereooffset[i]);
@ -681,6 +684,8 @@ void R_RenderScene (void)
case 5:
break;
}
r_refdef.flipcull = cull;
}
/*generates a new modelview matrix, as well as vpn vectors*/
static void R_MirrorMatrix(plane_t *plane)
@ -1242,7 +1247,7 @@ void R_Clear (qboolean fbo)
//for performance, we clear the depth at the same time we clear colour, so we can skip clearing depth here the first time around each frame.
//but for multiple scenes, we do need to clear depth still.
//fbos always get cleared depth, just in case (colour fbos may contain junk, but hey).
qglClear (GL_DEPTH_BUFFER_BIT);
qglClear (GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
}
if (!fbo)
depthcleared = false;

View file

@ -57,7 +57,7 @@ WARNING: be very careful calling this from elsewhere, because the refresh
needs almost the entire 256k of stack space!
==================
*/
void SCR_DrawCursor(void);
void GLSCR_UpdateScreen (void)
{
int uimenu;
@ -124,6 +124,7 @@ void GLSCR_UpdateScreen (void)
if (key_dest_mask & kdm_console)
Con_DrawConsole(vid.height/2, false);
SCR_DrawCursor();
GL_EndRendering ();
VID_SwapBuffers();
RSpeedEnd(RSPEED_TOTALREFRESH);
@ -257,6 +258,14 @@ char *GLVID_GetRGBInfo(int prepadbytes, int *truewidth, int *trueheight)
int i, c;
qbyte *ret;
*truewidth = vid.pixelwidth;
*trueheight = vid.pixelheight;
if (*r_refdef.rt_destcolour[0].texname)
{
R2D_RT_GetTexture(r_refdef.rt_destcolour[0].texname, truewidth, trueheight);
}
/*if (1)
{
float *p;
@ -280,10 +289,10 @@ char *GLVID_GetRGBInfo(int prepadbytes, int *truewidth, int *trueheight)
qbyte *p;
// gles only guarantees GL_RGBA/GL_UNSIGNED_BYTE so downconvert and resize
ret = BZ_Malloc(prepadbytes + vid.pixelwidth*vid.pixelheight*4);
qglReadPixels (0, 0, vid.pixelwidth, vid.pixelheight, GL_RGBA, GL_UNSIGNED_BYTE, ret + prepadbytes);
ret = BZ_Malloc(prepadbytes + (*truewidth)*(*trueheight)*4);
qglReadPixels (0, 0, (*truewidth), (*trueheight), GL_RGBA, GL_UNSIGNED_BYTE, ret + prepadbytes);
c = vid.pixelwidth*vid.pixelheight;
c = (*truewidth)*(*trueheight);
p = ret + prepadbytes;
for (i = 1; i < c; i++)
{
@ -291,20 +300,17 @@ char *GLVID_GetRGBInfo(int prepadbytes, int *truewidth, int *trueheight)
p[i*3+1]=p[i*4+1];
p[i*3+2]=p[i*4+2];
}
ret = BZ_Realloc(ret, prepadbytes + vid.pixelwidth*vid.pixelheight*3);
ret = BZ_Realloc(ret, prepadbytes + (*truewidth)*(*trueheight)*3);
}
else
{
ret = BZ_Malloc(prepadbytes + vid.pixelwidth*vid.pixelheight*3);
qglReadPixels (0, 0, vid.pixelwidth, vid.pixelheight, GL_RGB, GL_UNSIGNED_BYTE, ret + prepadbytes);
ret = BZ_Malloc(prepadbytes + (*truewidth)*(*trueheight)*3);
qglReadPixels (0, 0, (*truewidth), (*trueheight), GL_RGB, GL_UNSIGNED_BYTE, ret + prepadbytes);
}
*truewidth = vid.pixelwidth;
*trueheight = vid.pixelheight;
if (gammaworks)
{
c = prepadbytes+vid.pixelwidth*vid.pixelheight*3;
c = prepadbytes+(*truewidth), (*trueheight)*3;
for (i=prepadbytes ; i<c ; i+=3)
{
extern qbyte gammatable[256];

View file

@ -604,7 +604,7 @@ static int Shader_SetImageFlags(shader_t *shader, shaderpass_t *pass, char **nam
{
int flags = 0;
while (name)
for(;name;)
{
if (!Q_strnicmp(*name, "$rt:", 4))
{
@ -639,7 +639,7 @@ static int Shader_SetImageFlags(shader_t *shader, shaderpass_t *pass, char **nam
pass->flags |= SHADER_PASS_LINEAR;
}
else
name = NULL;
break;
}
// if (shader->flags & SHADER_SKY)
@ -1844,6 +1844,47 @@ static void Shader_DiffuseMap(shader_t *shader, shaderpass_t *pass, char **ptr)
token = Shader_ParseString(ptr);
shader->defaulttextures.base = R_LoadHiResTexture(token, NULL, 0);
}
static void Shader_SpecularMap(shader_t *shader, shaderpass_t *pass, char **ptr)
{
char *token;
token = Shader_ParseString(ptr);
shader->defaulttextures.specular = R_LoadHiResTexture(token, NULL, 0);
}
static void Shader_BumpMap(shader_t *shader, shaderpass_t *pass, char **ptr)
{
char *token;
token = Shader_ParseString(ptr);
shader->defaulttextures.bump = R_LoadHiResTexture(token, NULL, 0);
}
static void Shader_FullbrightMap(shader_t *shader, shaderpass_t *pass, char **ptr)
{
char *token;
token = Shader_ParseString(ptr);
shader->defaulttextures.fullbright = R_LoadHiResTexture(token, NULL, 0);
}
static void Shader_UpperMap(shader_t *shader, shaderpass_t *pass, char **ptr)
{
char *token;
token = Shader_ParseString(ptr);
shader->defaulttextures.upperoverlay = R_LoadHiResTexture(token, NULL, 0);
}
static void Shader_LowerMap(shader_t *shader, shaderpass_t *pass, char **ptr)
{
char *token;
token = Shader_ParseString(ptr);
shader->defaulttextures.loweroverlay = R_LoadHiResTexture(token, NULL, 0);
}
static qboolean Shaderpass_MapGen (shader_t *shader, shaderpass_t *pass, char *tname);
static void Shader_ProgMap(shader_t *shader, shaderpass_t *pass, char **ptr)
{
//fixme
// Shaderpass_BlendFunc (shader, pass, ptr);
}
static void Shader_ProgBlendFunc(shader_t *shader, shaderpass_t *pass, char **ptr)
{
//fixme
}
static void Shader_Translucent(shader_t *shader, shaderpass_t *pass, char **ptr)
{
@ -1971,8 +2012,11 @@ static shaderkey_t shaderkeys[] =
/*doom3 compat*/
{"diffusemap", Shader_DiffuseMap}, //macro for "{\nstage diffusemap\nmap <map>\n}"
{"bumpmap", NULL}, //macro for "{\nstage bumpmap\nmap <map>\n}"
{"specularmap", NULL}, //macro for "{\nstage specularmap\nmap <map>\n}"
{"bumpmap", Shader_BumpMap}, //macro for "{\nstage bumpmap\nmap <map>\n}"
{"specularmap", Shader_SpecularMap},//macro for "{\nstage specularmap\nmap <map>\n}"
{"fullbrightmap", Shader_FullbrightMap},//macro for "{\nstage specularmap\nmap <map>\n}"
{"uppermap", Shader_UpperMap},//macro for "{\nstage specularmap\nmap <map>\n}"
{"lowermap", Shader_LowerMap},//macro for "{\nstage specularmap\nmap <map>\n}"
{"discrete", NULL},
{"nonsolid", NULL},
{"noimpact", NULL},
@ -1981,6 +2025,10 @@ static shaderkey_t shaderkeys[] =
{"nooverlays", NULL},
{"nofragment", NULL},
/*simpler parsing for fte shaders*/
{"progblendfunc", Shader_ProgBlendFunc},
{"progmap", Shader_ProgMap},
{NULL, NULL}
};
@ -2018,6 +2066,7 @@ static qboolean Shaderpass_MapGen (shader_t *shader, shaderpass_t *pass, char *t
else if (!Q_stricmp (tname, "$diffuse"))
{
pass->texgen = T_GEN_DIFFUSE;
shader->flags |= SHADER_HASDIFFUSE;
}
else if (!Q_stricmp (tname, "$normalmap"))
{
@ -2110,6 +2159,7 @@ static void Shaderpass_Map (shader_t *shader, shaderpass_t *pass, char **ptr)
pass->anim_frames[0] = r_nulltex;
token = Shader_ParseString (ptr);
flags = Shader_SetImageFlags (shader, pass, &token);
if (!Shaderpass_MapGen(shader, pass, token))
{
@ -2128,6 +2178,8 @@ static void Shaderpass_Map (shader_t *shader, shaderpass_t *pass, char **ptr)
if (pass->tcgen == TC_GEN_UNSPECIFIED)
pass->tcgen = TC_GEN_BASE;
if (!*shader->mapname && pass->tcgen == TC_GEN_BASE)
Q_strncpyz(shader->mapname, token, sizeof(shader->mapname));
pass->anim_frames[0] = Shader_FindImage (token, flags);
}
}
@ -2854,7 +2906,7 @@ void Shader_Free (shader_t *shader)
int QDECL Shader_InitCallback (const char *name, qofs_t size, void *param, searchpathfuncs_t *spath)
int QDECL Shader_InitCallback (const char *name, qofs_t size, time_t mtime, void *param, searchpathfuncs_t *spath)
{
Shader_MakeCache(name);
return true;
@ -3288,12 +3340,12 @@ void Shader_Readpass (shader_t *shader, char **ptr)
case ST_BUMPMAP:
if (pass->texgen == T_GEN_SINGLEMAP)
shader->defaulttextures.bump = pass->anim_frames[0];
ignore = true;
ignore = true; //fixme: scrolling etc may be important. but we're not doom3.
break;
case ST_SPECULARMAP:
if (pass->texgen == T_GEN_SINGLEMAP)
shader->defaulttextures.specular = pass->anim_frames[0];
ignore = true;
ignore = true; //fixme: scrolling etc may be important. but we're not doom3.
break;
}
}
@ -3526,6 +3578,7 @@ void Shader_Programify (shader_t *s)
s->prog = Shader_FindGeneric(va("%s%s", prog, mask), qrenderer);
s->numpasses = 0;
s->passes[s->numpasses++].texgen = T_GEN_DIFFUSE;
s->flags |= SHADER_HASDIFFUSE;
if (modellighting)
{
@ -3534,6 +3587,7 @@ void Shader_Programify (shader_t *s)
s->passes[s->numpasses++].texgen = T_GEN_FULLBRIGHT;
s->passes[s->numpasses++].texgen = T_GEN_NORMALMAP;
s->passes[s->numpasses++].texgen = T_GEN_SPECULAR;
s->flags |= SHADER_HASTOPBOTTOM | SHADER_HASFULLBRIGHT | SHADER_HASNORMALMAP | SHADER_HASGLOSS;
}
else if (lightmap)
{
@ -3542,6 +3596,7 @@ void Shader_Programify (shader_t *s)
s->passes[s->numpasses++].texgen = T_GEN_DELUXMAP;
s->passes[s->numpasses++].texgen = T_GEN_FULLBRIGHT;
s->passes[s->numpasses++].texgen = T_GEN_SPECULAR;
s->flags |= SHADER_HASFULLBRIGHT | SHADER_HASNORMALMAP | SHADER_HASGLOSS;
}
}
@ -3942,6 +3997,23 @@ void Shader_UpdateRegistration (void)
}
*/
/*
if (*shader_diffusemapname)
{
if (!s->defaulttextures.base)
s->defaulttextures.base = Shader_FindImage (va("%s.tga", shader_diffusemapname), 0);
if (!s->defaulttextures.bump)
s->defaulttextures.bump = Shader_FindImage (va("%s_norm.tga", shader_diffusemapname), 0);
if (!s->defaulttextures.fullbright)
s->defaulttextures.fullbright = Shader_FindImage (va("%s_glow.tga", shader_diffusemapname), 0);
if (!s->defaulttextures.specular)
s->defaulttextures.specular = Shader_FindImage (va("%s_gloss.tga", shader_diffusemapname), 0);
if (!s->defaulttextures.upperoverlay)
s->defaulttextures.upperoverlay = Shader_FindImage (va("%s_shirt.tga", shader_diffusemapname), 0);
if (!s->defaulttextures.loweroverlay)
s->defaulttextures.loweroverlay = Shader_FindImage (va("%s_pants.tga", shader_diffusemapname), 0); //stupid yanks...
}
*/
void Shader_DefaultSkin(const char *shortname, shader_t *s, const void *args);
void QDECL R_BuildDefaultTexnums(texnums_t *tn, shader_t *shader)
{
@ -3962,10 +4034,10 @@ void QDECL R_BuildDefaultTexnums(texnums_t *tn, shader_t *shader)
if (!TEXVALID(shader->defaulttextures.base))
{
/*dlights/realtime lighting needs some stuff*/
if (!TEXVALID(tn->base) && *shader->mapname)// && (shader->flags & SHADER_HASDIFFUSE))
tn->base = R_LoadHiResTexture(shader->mapname, NULL, 0);
if (!TEXVALID(tn->base))
{
tn->base = R_LoadHiResTexture(imagename, subpath, (*imagename=='{')?0:IF_NOALPHA);
}
TEXASSIGN(shader->defaulttextures.base, tn->base);
}
@ -3974,8 +4046,10 @@ void QDECL R_BuildDefaultTexnums(texnums_t *tn, shader_t *shader)
if (!TEXVALID(shader->defaulttextures.bump))
{
if (r_loadbumpmapping)
if (r_loadbumpmapping || (shader->flags & SHADER_HASNORMALMAP))
{
if (!TEXVALID(tn->bump) && *shader->mapname && (shader->flags & SHADER_HASNORMALMAP))
tn->bump = R_LoadHiResTexture(va("%s_norm", shader->mapname), NULL, IF_TRYBUMP);
if (!TEXVALID(tn->bump))
tn->bump = R_LoadHiResTexture(va("%s_norm", imagename), subpath, IF_TRYBUMP);
}
@ -3986,6 +4060,8 @@ void QDECL R_BuildDefaultTexnums(texnums_t *tn, shader_t *shader)
{
if (shader->flags & SHADER_HASTOPBOTTOM)
{
if (!TEXVALID(tn->loweroverlay) && *shader->mapname)
tn->loweroverlay = R_LoadHiResTexture(va("%s_pants", shader->mapname), NULL, 0);
if (!TEXVALID(tn->loweroverlay))
tn->loweroverlay = R_LoadHiResTexture(va("%s_pants", imagename), subpath, 0); /*how rude*/
}
@ -3996,6 +4072,8 @@ void QDECL R_BuildDefaultTexnums(texnums_t *tn, shader_t *shader)
{
if (shader->flags & SHADER_HASTOPBOTTOM)
{
if (!TEXVALID(tn->upperoverlay) && *shader->mapname)
tn->upperoverlay = R_LoadHiResTexture(va("%s_shirt", shader->mapname), NULL, 0);
if (!TEXVALID(tn->upperoverlay))
tn->upperoverlay = R_LoadHiResTexture(va("%s_shirt", imagename), subpath, 0);
}
@ -4007,6 +4085,8 @@ void QDECL R_BuildDefaultTexnums(texnums_t *tn, shader_t *shader)
extern cvar_t gl_specular;
if ((shader->flags & SHADER_HASGLOSS) && gl_specular.value && gl_load24bit.value)
{
if (!TEXVALID(tn->specular) && *shader->mapname)
tn->specular = R_LoadHiResTexture(va("%s_gloss", shader->mapname), NULL, 0);
if (!TEXVALID(tn->specular))
tn->specular = R_LoadHiResTexture(va("%s_gloss", imagename), subpath, 0);
}
@ -4018,8 +4098,10 @@ void QDECL R_BuildDefaultTexnums(texnums_t *tn, shader_t *shader)
extern cvar_t r_fb_bmodels;
if ((shader->flags & SHADER_HASFULLBRIGHT) && r_fb_bmodels.value && gl_load24bit.value)
{
if (!TEXVALID(tn->fullbright) && *shader->mapname)
tn->fullbright = R_LoadHiResTexture(va("%s_luma", shader->mapname), NULL, 0);
if (!TEXVALID(tn->fullbright))
tn->specular = R_LoadHiResTexture(va("%s_luma", imagename), subpath, 0);
tn->fullbright = R_LoadHiResTexture(va("%s_luma", imagename), subpath, 0);
}
TEXASSIGN(shader->defaulttextures.fullbright, tn->fullbright);
}
@ -4730,24 +4812,41 @@ void Shader_Default2D(const char *shortname, shader_t *s, const void *genargs)
{
if (Shader_ParseShader("default2d", s))
return;
Shader_DefaultScript(shortname, s,
"{\n"
"if $nofixed\n"
"program default2d\n"
"endif\n"
"affine\n"
"nomipmaps\n"
if (sh_config.progs_supported)
{
//hexen2 needs premultiplied alpha to avoid looking ugly
//but that results in problems where things are drawn with alpha not 0, so scale vertex colour by alpha in the fragment program
Shader_DefaultScript(shortname, s,
"{\n"
"clampmap $diffuse\n"
"rgbgen vertex\n"
"alphagen vertex\n"
"blendfunc gl_one gl_one_minus_src_alpha\n"
"affine\n"
"nomipmaps\n"
"program default2d#PREMUL\n"
"{\n"
"map $diffuse\n"
"blend gl_one gl_one_minus_src_alpha\n"
"}\n"
"sort additive\n"
"}\n"
"sort additive\n"
"}\n"
);
TEXASSIGN(s->defaulttextures.base, R_LoadHiResTexture(s->name, NULL, IF_PREMULTIPLYALPHA|IF_UIPIC|IF_NOPICMIP|IF_NOMIPMAP|IF_CLAMP));
);
TEXASSIGN(s->defaulttextures.base, R_LoadHiResTexture(s->name, NULL, IF_PREMULTIPLYALPHA|IF_UIPIC|IF_NOPICMIP|IF_NOMIPMAP|IF_CLAMP));
}
else
{
Shader_DefaultScript(shortname, s,
"{\n"
"affine\n"
"nomipmaps\n"
"{\n"
"clampmap $diffuse\n"
"rgbgen vertex\n"
"alphagen vertex\n"
"blendfunc gl_src_alpha gl_one_minus_src_alpha\n"
"}\n"
"sort additive\n"
"}\n"
);
TEXASSIGN(s->defaulttextures.base, R_LoadHiResTexture(s->name, NULL, IF_UIPIC|IF_NOPICMIP|IF_NOMIPMAP|IF_CLAMP));
}
}
qboolean Shader_ReadShaderTerms(shader_t *s, char **shadersource, int parsemode, int *conddepth, int maxconddepth, int *cond)

View file

@ -2263,6 +2263,19 @@ void GL_Init(void *(*getglfunction) (char *name))
sh_config.texfmt[PTI_ARGB1555] = true;
}
}
if (!gl_config.gles && (gl_config.glversion >= 1.4 || GL_CheckExtension("GL_ARB_depth_texture")))
{ //depth formats
sh_config.texfmt[PTI_DEPTH16] = true;
sh_config.texfmt[PTI_DEPTH24] = true;
sh_config.texfmt[PTI_DEPTH32] = true;
}
else if (gl_config.gles && GL_CheckExtension("GL_OES_depth_texture"))
{ //16+32, not 24.
sh_config.texfmt[PTI_DEPTH16] = true;
sh_config.texfmt[PTI_DEPTH32] = true;
}
if (GL_CheckExtension("GL_EXT_packed_depth_stencil"))
sh_config.texfmt[PTI_DEPTH24_8] = true;
sh_config.minver = gl_config.arb_shader_objects?110:0;
sh_config.maxver = gl_config.arb_shader_objects?gl_config.maxglslversion:0;

View file

@ -133,8 +133,15 @@ extern qlpMTex2FUNC qglMultiTexCoord2fARB;
#define GL_DEPTH_TEXTURE_MODE_ARB 0x884B
#endif
//GL_OES_depth_texture adds this because gles otherwise lacks it.
#ifndef GL_UNSIGNED_INT
#define GL_UNSIGNED_INT 0x1405
#endif
#ifndef GL_EXT_packed_depth_stencil
#define GL_DEPTH24_STENCIL8_EXT 0x88F0
#define GL_DEPTH_STENCIL_EXT 0x84F9
#define GL_UNSIGNED_INT_24_8_EXT 0x84FA
#endif
#ifndef GL_ARB_shadow

View file

@ -477,7 +477,12 @@ YOU SHOULD NOT EDIT THIS FILE BY HAND
"uniform sampler2D s_t0;\n"
"void main ()\n"
"{\n"
"gl_FragColor = texture2D(s_t0, tc) * vc;\n"
"vec4 f = vc;\n"
"#ifdef PREMUL\n"
"f.rgb *= f.a;\n"
"#endif\n"
"f *= texture2D(s_t0, tc);\n"
"gl_FragColor = f;\n"
"}\n"
"#endif\n"
},

View file

@ -485,6 +485,7 @@ enum
struct shader_s
{
char name[MAX_QPATH];
char mapname[MAX_QPATH];
enum {
SUF_NONE = 0,
SUF_LIGHTMAP = 1<<0, //$lightmap passes are valid. otherwise collapsed to an rgbgen
@ -542,6 +543,7 @@ struct shader_s
SHADER_HASGLOSS = 1 << 24, //needs a _spec texture, if possible.
SHADER_NOSHADOWS = 1 << 25, //don't cast shadows
SHADER_HASFULLBRIGHT = 1 << 26, //needs a fullbright texture, if possible.
SHADER_HASDIFFUSE = 1 << 27, //has a T_GEN_DIFFUSE pass
} flags;
program_t *prog;
@ -627,7 +629,7 @@ typedef struct
#define FBO_TEX_DEPTH 32 //internal
#define FBO_TEX_STENCIL 64 //internal
#ifndef __cplusplus //C++ sucks
typedef struct
{
char *progpath; //path to use for glsl/hlsl
@ -655,6 +657,7 @@ typedef struct
void (*pProgAutoFields) (program_t *prog, char **cvarnames, int *cvartypes);
} sh_config_t;
extern sh_config_t sh_config;
#endif
#ifdef GLSLONLY
#define gl_config_nofixedfunc true

View file

@ -134,7 +134,7 @@ void FTP_ServerShutdown(void)
}
//we ought to filter this to remove duplicates.
static int QDECL SendFileNameTo(const char *rawname, qofs_t size, void *param, searchpathfuncs_t *spath)
static int QDECL SendFileNameTo(const char *rawname, qofs_t size, time_t mtime, void *param, searchpathfuncs_t *spath)
{
SOCKET socket = *(SOCKET*)param;
// int i;

View file

@ -2,7 +2,7 @@
* jerror.h
*
* Copyright (C) 1994-1997, Thomas G. Lane.
* Modified 1997-2009 by Guido Vollbeding.
* Modified 1997-2012 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@ -106,11 +106,11 @@ JMESSAGE(JERR_QUANT_COMPONENTS,
"Cannot quantize more than %d color components")
JMESSAGE(JERR_QUANT_FEW_COLORS, "Cannot quantize to fewer than %d colors")
JMESSAGE(JERR_QUANT_MANY_COLORS, "Cannot quantize to more than %d colors")
JMESSAGE(JERR_SOF_BEFORE, "Invalid JPEG file structure: %s before SOF")
JMESSAGE(JERR_SOF_DUPLICATE, "Invalid JPEG file structure: two SOF markers")
JMESSAGE(JERR_SOF_NO_SOS, "Invalid JPEG file structure: missing SOS marker")
JMESSAGE(JERR_SOF_UNSUPPORTED, "Unsupported JPEG process: SOF type 0x%02x")
JMESSAGE(JERR_SOI_DUPLICATE, "Invalid JPEG file structure: two SOI markers")
JMESSAGE(JERR_SOS_NO_SOF, "Invalid JPEG file structure: SOS before SOF")
JMESSAGE(JERR_TFILE_CREATE, "Failed to create temporary file %s")
JMESSAGE(JERR_TFILE_READ, "Read failed on temporary file")
JMESSAGE(JERR_TFILE_SEEK, "Seek failed on temporary file")

View file

@ -2,7 +2,7 @@
* jmorecfg.h
*
* Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 1997-2009 by Guido Vollbeding.
* Modified 1997-2012 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@ -210,6 +210,26 @@ typedef unsigned int JDIMENSION;
#endif
/* The noreturn type identifier is used to declare functions
* which cannot return.
* Compilers can thus create more optimized code and perform
* better checks for warnings and errors.
* Static analyzer tools can make improved inferences about
* execution paths and are prevented from giving false alerts.
*
* Unfortunately, the proposed specifications of corresponding
* extensions in the Dec 2011 ISO C standard revision (C11),
* GCC, MSVC, etc. are not viable.
* Thus we introduce a user defined type to declare noreturn
* functions at least for clarity. A proper compiler would
* have a suitable noreturn type to match in place of void.
*/
#ifndef HAVE_NORETURN_T
typedef void noreturn_t;
#endif
/* Here is the pseudo-keyword for declaring pointers that must be "far"
* on 80x86 machines. Most of the specialized coding for 80x86 is handled
* by just saying "FAR *" where such a pointer is needed. In a few places
@ -232,15 +252,16 @@ typedef unsigned int JDIMENSION;
* Defining HAVE_BOOLEAN before including jpeglib.h should make it work.
*/
#ifndef HAVE_BOOLEAN
typedef int boolean;
#endif
#ifdef HAVE_BOOLEAN
#ifndef FALSE /* in case these macros already exist */
#define FALSE 0 /* values of boolean */
#endif
#ifndef TRUE
#define TRUE 1
#endif
#else
typedef enum { FALSE = 0, TRUE = 1 } boolean;
#endif
/*
@ -312,9 +333,7 @@ typedef int boolean;
* the offsets will also change the order in which colormap data is organized.
* RESTRICTIONS:
* 1. The sample applications cjpeg,djpeg do NOT support modified RGB formats.
* 2. These macros only affect RGB<=>YCbCr color conversion, so they are not
* useful if you are using JPEG color spaces other than YCbCr or grayscale.
* 3. The color quantizer modules will not behave desirably if RGB_PIXELSIZE
* 2. The color quantizer modules will not behave desirably if RGB_PIXELSIZE
* is not 3 (they don't understand about dummy color components!). So you
* can't use color quantization if you change that value.
*/

View file

@ -2,7 +2,7 @@
* jpeglib.h
*
* Copyright (C) 1991-1998, Thomas G. Lane.
* Modified 2002-2009 by Guido Vollbeding.
* Modified 2002-2012 by Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
@ -33,11 +33,13 @@ extern "C" {
#endif
#endif
/* Version ID for the JPEG library.
* Might be useful for tests like "#if JPEG_LIB_VERSION >= 80".
/* Version IDs for the JPEG library.
* Might be useful for tests like "#if JPEG_LIB_VERSION >= 90".
*/
#define JPEG_LIB_VERSION 80 /* Version 8.0 */
#define JPEG_LIB_VERSION 90 /* Compatibility version 9.0 */
#define JPEG_LIB_VERSION_MAJOR 9
#define JPEG_LIB_VERSION_MINOR 0
/* Various constants determining the sizes of things.
@ -45,7 +47,7 @@ extern "C" {
* if you want to be compatible.
*/
#define DCTSIZE 8 /* The basic DCT block is 8x8 samples */
#define DCTSIZE 8 /* The basic DCT block is 8x8 coefficients */
#define DCTSIZE2 64 /* DCTSIZE squared; # of elements in a block */
#define NUM_QUANT_TBLS 4 /* Quantization tables are numbered 0..3 */
#define NUM_HUFF_TBLS 4 /* Huffman tables are numbered 0..3 */
@ -219,6 +221,13 @@ typedef enum {
JCS_YCCK /* Y/Cb/Cr/K */
} J_COLOR_SPACE;
/* Supported color transforms. */
typedef enum {
JCT_NONE = 0,
JCT_SUBTRACT_GREEN = 1
} J_COLOR_TRANSFORM;
/* DCT/IDCT algorithm options. */
typedef enum {
@ -367,7 +376,10 @@ struct jpeg_compress_struct {
UINT16 X_density; /* Horizontal pixel density */
UINT16 Y_density; /* Vertical pixel density */
boolean write_Adobe_marker; /* should an Adobe marker be written? */
J_COLOR_TRANSFORM color_transform;
/* Color transform identifier, writes LSE marker if nonzero */
/* State variable: index of next scanline to be written to
* jpeg_write_scanlines(). Application may use this to control its
* processing loop, e.g., "while (next_scanline < image_height)".
@ -587,6 +599,9 @@ struct jpeg_decompress_struct {
boolean saw_Adobe_marker; /* TRUE iff an Adobe APP14 marker was found */
UINT8 Adobe_transform; /* Color transform code from Adobe marker */
J_COLOR_TRANSFORM color_transform;
/* Color transform identifier derived from LSE marker, otherwise zero */
boolean CCIR601_sampling; /* TRUE=first samples are cosited */
/* Aside from the specific data retained from APPn markers known to the
@ -679,7 +694,7 @@ struct jpeg_decompress_struct {
struct jpeg_error_mgr {
/* Error exit handler: does not return to caller */
JMETHOD(void, error_exit, (j_common_ptr cinfo));
JMETHOD(noreturn_t, error_exit, (j_common_ptr cinfo));
/* Conditionally emit a trace or warning message */
JMETHOD(void, emit_message, (j_common_ptr cinfo, int msg_level));
/* Routine that actually outputs a trace or error message */

View file

@ -1,14 +1,14 @@
/*
* jversion.h
*
* Copyright (C) 1991-2010, Thomas G. Lane, Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains software version identification.
*/
#define JVERSION "8b 16-May-2010"
#define JCOPYRIGHT "Copyright (C) 2010, Thomas G. Lane, Guido Vollbeding"
/*
* jversion.h
*
* Copyright (C) 1991-2013, Thomas G. Lane, Guido Vollbeding.
* This file is part of the Independent JPEG Group's software.
* For conditions of distribution and use, see the accompanying README file.
*
* This file contains software version identification.
*/
#define JVERSION "9 13-Jan-2013"
#define JCOPYRIGHT "Copyright (C) 2013, Thomas G. Lane, Guido Vollbeding"

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -1,5 +1,5 @@
/* zconf.h -- configuration of the zlib compression library
* Copyright (C) 1995-2010 Jean-loup Gailly.
* Copyright (C) 1995-2013 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@ -15,11 +15,13 @@
* this permanently in zconf.h using "./configure --zprefix".
*/
#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
# define Z_PREFIX_SET
/* all linked symbols */
# define _dist_code z__dist_code
# define _length_code z__length_code
# define _tr_align z__tr_align
# define _tr_flush_bits z__tr_flush_bits
# define _tr_flush_block z__tr_flush_block
# define _tr_init z__tr_init
# define _tr_stored_block z__tr_stored_block
@ -27,9 +29,11 @@
# define adler32 z_adler32
# define adler32_combine z_adler32_combine
# define adler32_combine64 z_adler32_combine64
# define compress z_compress
# define compress2 z_compress2
# define compressBound z_compressBound
# ifndef Z_SOLO
# define compress z_compress
# define compress2 z_compress2
# define compressBound z_compressBound
# endif
# define crc32 z_crc32
# define crc32_combine z_crc32_combine
# define crc32_combine64 z_crc32_combine64
@ -40,44 +44,53 @@
# define deflateInit2_ z_deflateInit2_
# define deflateInit_ z_deflateInit_
# define deflateParams z_deflateParams
# define deflatePending z_deflatePending
# define deflatePrime z_deflatePrime
# define deflateReset z_deflateReset
# define deflateResetKeep z_deflateResetKeep
# define deflateSetDictionary z_deflateSetDictionary
# define deflateSetHeader z_deflateSetHeader
# define deflateTune z_deflateTune
# define deflate_copyright z_deflate_copyright
# define get_crc_table z_get_crc_table
# define gz_error z_gz_error
# define gz_intmax z_gz_intmax
# define gz_strwinerror z_gz_strwinerror
# define gzbuffer z_gzbuffer
# define gzclearerr z_gzclearerr
# define gzclose z_gzclose
# define gzclose_r z_gzclose_r
# define gzclose_w z_gzclose_w
# define gzdirect z_gzdirect
# define gzdopen z_gzdopen
# define gzeof z_gzeof
# define gzerror z_gzerror
# define gzflush z_gzflush
# define gzgetc z_gzgetc
# define gzgets z_gzgets
# define gzoffset z_gzoffset
# define gzoffset64 z_gzoffset64
# define gzopen z_gzopen
# define gzopen64 z_gzopen64
# define gzprintf z_gzprintf
# define gzputc z_gzputc
# define gzputs z_gzputs
# define gzread z_gzread
# define gzrewind z_gzrewind
# define gzseek z_gzseek
# define gzseek64 z_gzseek64
# define gzsetparams z_gzsetparams
# define gztell z_gztell
# define gztell64 z_gztell64
# define gzungetc z_gzungetc
# define gzwrite z_gzwrite
# ifndef Z_SOLO
# define gz_error z_gz_error
# define gz_intmax z_gz_intmax
# define gz_strwinerror z_gz_strwinerror
# define gzbuffer z_gzbuffer
# define gzclearerr z_gzclearerr
# define gzclose z_gzclose
# define gzclose_r z_gzclose_r
# define gzclose_w z_gzclose_w
# define gzdirect z_gzdirect
# define gzdopen z_gzdopen
# define gzeof z_gzeof
# define gzerror z_gzerror
# define gzflush z_gzflush
# define gzgetc z_gzgetc
# define gzgetc_ z_gzgetc_
# define gzgets z_gzgets
# define gzoffset z_gzoffset
# define gzoffset64 z_gzoffset64
# define gzopen z_gzopen
# define gzopen64 z_gzopen64
# ifdef _WIN32
# define gzopen_w z_gzopen_w
# endif
# define gzprintf z_gzprintf
# define gzvprintf z_gzvprintf
# define gzputc z_gzputc
# define gzputs z_gzputs
# define gzread z_gzread
# define gzrewind z_gzrewind
# define gzseek z_gzseek
# define gzseek64 z_gzseek64
# define gzsetparams z_gzsetparams
# define gztell z_gztell
# define gztell64 z_gztell64
# define gzungetc z_gzungetc
# define gzwrite z_gzwrite
# endif
# define inflate z_inflate
# define inflateBack z_inflateBack
# define inflateBackEnd z_inflateBackEnd
@ -92,16 +105,22 @@
# define inflateReset z_inflateReset
# define inflateReset2 z_inflateReset2
# define inflateSetDictionary z_inflateSetDictionary
# define inflateGetDictionary z_inflateGetDictionary
# define inflateSync z_inflateSync
# define inflateSyncPoint z_inflateSyncPoint
# define inflateUndermine z_inflateUndermine
# define inflateResetKeep z_inflateResetKeep
# define inflate_copyright z_inflate_copyright
# define inflate_fast z_inflate_fast
# define inflate_table z_inflate_table
# define uncompress z_uncompress
# ifndef Z_SOLO
# define uncompress z_uncompress
# endif
# define zError z_zError
# define zcalloc z_zcalloc
# define zcfree z_zcfree
# ifndef Z_SOLO
# define zcalloc z_zcalloc
# define zcfree z_zcfree
# endif
# define zlibCompileFlags z_zlibCompileFlags
# define zlibVersion z_zlibVersion
@ -111,7 +130,9 @@
# define alloc_func z_alloc_func
# define charf z_charf
# define free_func z_free_func
# define gzFile z_gzFile
# ifndef Z_SOLO
# define gzFile z_gzFile
# endif
# define gz_header z_gz_header
# define gz_headerp z_gz_headerp
# define in_func z_in_func
@ -197,6 +218,12 @@
# endif
#endif
#if defined(ZLIB_CONST) && !defined(z_const)
# define z_const const
#else
# define z_const
#endif
/* Some Mac compilers merge all .h files incorrectly: */
#if defined(__MWERKS__)||defined(applec)||defined(THINK_C)||defined(__SC__)
# define NO_DUMMY_DECL
@ -243,6 +270,14 @@
# endif
#endif
#ifndef Z_ARG /* function prototypes for stdarg */
# if defined(STDC) || defined(Z_HAVE_STDARG_H)
# define Z_ARG(args) args
# else
# define Z_ARG(args) ()
# endif
#endif
/* The following definitions for FAR are needed only for MSDOS mixed
* model programming (small or medium model with some far allocations).
* This was tested only with MSC; for other MSDOS compilers you may have
@ -356,12 +391,47 @@ typedef uLong FAR uLongf;
typedef Byte *voidp;
#endif
#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
# include <limits.h>
# if (UINT_MAX == 0xffffffffUL)
# define Z_U4 unsigned
# elif (ULONG_MAX == 0xffffffffUL)
# define Z_U4 unsigned long
# elif (USHRT_MAX == 0xffffffffUL)
# define Z_U4 unsigned short
# endif
#endif
#ifdef Z_U4
typedef Z_U4 z_crc_t;
#else
typedef unsigned long z_crc_t;
#endif
#if 1 /* was set to #if 1 by ./configure */
# define Z_HAVE_UNISTD_H
#endif
#if 1 /* was set to #if 1 by ./configure */
# define Z_HAVE_STDARG_H
#endif
#ifdef STDC
# include <sys/types.h> /* for off_t */
# ifndef Z_SOLO
# include <sys/types.h> /* for off_t */
# endif
#endif
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
# ifndef Z_SOLO
# include <stdarg.h> /* for va_list */
# endif
#endif
#ifdef _WIN32
# ifndef Z_SOLO
# include <stddef.h> /* for wchar_t */
# endif
#endif
/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
@ -370,21 +440,38 @@ typedef uLong FAR uLongf;
* both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
* equivalently requesting no 64-bit operations
*/
#if -_LARGEFILE64_SOURCE - -1 == 1
#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
# undef _LARGEFILE64_SOURCE
#endif
#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
# include <unistd.h> /* for SEEK_* and off_t */
# ifdef VMS
# include <unixio.h> /* for off_t */
# endif
# ifndef z_off_t
# define z_off_t off_t
#if defined(__WATCOMC__) && !defined(Z_HAVE_UNISTD_H)
# define Z_HAVE_UNISTD_H
#endif
#ifndef Z_SOLO
# if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
# ifdef VMS
# include <unixio.h> /* for off_t */
# endif
# ifndef z_off_t
# define z_off_t off_t
# endif
# endif
#endif
#ifndef SEEK_SET
#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
# define Z_LFS64
#endif
#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
# define Z_LARGE64
#endif
#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
# define Z_WANT64
#endif
#if !defined(SEEK_SET) && !defined(Z_SOLO)
# define SEEK_SET 0 /* Seek from beginning of file. */
# define SEEK_CUR 1 /* Seek from current position. */
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
@ -394,18 +481,14 @@ typedef uLong FAR uLongf;
# define z_off_t long
#endif
#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
#if !defined(_WIN32) && defined(Z_LARGE64)
# define z_off64_t off64_t
#else
# define z_off64_t z_off_t
#endif
#if defined(__OS400__)
# define NO_vsnprintf
#endif
#if defined(__MVS__)
# define NO_vsnprintf
# if defined(_WIN32) && !defined(__GNUC__) && !defined(Z_SOLO)
# define z_off64_t __int64
# else
# define z_off64_t z_off_t
# endif
#endif
/* MVS linker does not support external names larger than 8 bytes */

View file

@ -1,7 +1,7 @@
/* zlib.h -- interface of the 'zlib' general purpose compression library
version 1.2.5, April 19th, 2010
version 1.2.8, April 28th, 2013
Copyright (C) 1995-2010 Jean-loup Gailly and Mark Adler
Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -24,8 +24,8 @@
The data format used by the zlib library is described by RFCs (Request for
Comments) 1950 to 1952 in the files http://www.ietf.org/rfc/rfc1950.txt
(zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950
(zlib format), rfc1951 (deflate format) and rfc1952 (gzip format).
*/
#ifndef ZLIB_H
@ -37,11 +37,11 @@
extern "C" {
#endif
#define ZLIB_VERSION "1.2.5"
#define ZLIB_VERNUM 0x1250
#define ZLIB_VERSION "1.2.8"
#define ZLIB_VERNUM 0x1280
#define ZLIB_VER_MAJOR 1
#define ZLIB_VER_MINOR 2
#define ZLIB_VER_REVISION 5
#define ZLIB_VER_REVISION 8
#define ZLIB_VER_SUBREVISION 0
/*
@ -83,15 +83,15 @@ typedef void (*free_func) OF((voidpf opaque, voidpf address));
struct internal_state;
typedef struct z_stream_s {
Bytef *next_in; /* next input byte */
z_const Bytef *next_in; /* next input byte */
uInt avail_in; /* number of bytes available at next_in */
uLong total_in; /* total nb of input bytes read so far */
uLong total_in; /* total number of input bytes read so far */
Bytef *next_out; /* next output byte should be put there */
uInt avail_out; /* remaining free space at next_out */
uLong total_out; /* total nb of bytes output so far */
uLong total_out; /* total number of bytes output so far */
char *msg; /* last error message, NULL if no error */
z_const char *msg; /* last error message, NULL if no error */
struct internal_state FAR *state; /* not visible by applications */
alloc_func zalloc; /* used to allocate the internal state */
@ -327,8 +327,9 @@ ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush));
Z_FINISH can be used immediately after deflateInit if all the compression
is to be done in a single step. In this case, avail_out must be at least the
value returned by deflateBound (see below). If deflate does not return
Z_STREAM_END, then it must be called again as described above.
value returned by deflateBound (see below). Then deflate is guaranteed to
return Z_STREAM_END. If not enough output space is provided, deflate will
not return Z_STREAM_END, and it must be called again as described above.
deflate() sets strm->adler to the adler32 checksum of all input read
so far (that is, total_in bytes).
@ -451,23 +452,29 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
error. However if all decompression is to be performed in a single step (a
single call of inflate), the parameter flush should be set to Z_FINISH. In
this case all pending input is processed and all pending output is flushed;
avail_out must be large enough to hold all the uncompressed data. (The size
of the uncompressed data may have been saved by the compressor for this
purpose.) The next operation on this stream must be inflateEnd to deallocate
the decompression state. The use of Z_FINISH is never required, but can be
used to inform inflate that a faster approach may be used for the single
inflate() call.
avail_out must be large enough to hold all of the uncompressed data for the
operation to complete. (The size of the uncompressed data may have been
saved by the compressor for this purpose.) The use of Z_FINISH is not
required to perform an inflation in one step. However it may be used to
inform inflate that a faster approach can be used for the single inflate()
call. Z_FINISH also informs inflate to not maintain a sliding window if the
stream completes, which reduces inflate's memory footprint. If the stream
does not complete, either because not all of the stream is provided or not
enough output space is provided, then a sliding window will be allocated and
inflate() can be called again to continue the operation as if Z_NO_FLUSH had
been used.
In this implementation, inflate() always flushes as much output as
possible to the output buffer, and always uses the faster approach on the
first call. So the only effect of the flush parameter in this implementation
is on the return value of inflate(), as noted below, or when it returns early
because Z_BLOCK or Z_TREES is used.
first call. So the effects of the flush parameter in this implementation are
on the return value of inflate() as noted below, when inflate() returns early
when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of
memory for a sliding window when Z_FINISH is used.
If a preset dictionary is needed after this call (see inflateSetDictionary
below), inflate sets strm->adler to the adler32 checksum of the dictionary
below), inflate sets strm->adler to the Adler-32 checksum of the dictionary
chosen by the compressor and returns Z_NEED_DICT; otherwise it sets
strm->adler to the adler32 checksum of all output produced so far (that is,
strm->adler to the Adler-32 checksum of all output produced so far (that is,
total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described
below. At the end of the stream, inflate() checks that its computed adler32
checksum is equal to that saved by the compressor and returns Z_STREAM_END
@ -478,7 +485,9 @@ ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush));
initializing with inflateInit2(). Any information contained in the gzip
header is not retained, so applications that need that information should
instead use raw inflate, see inflateInit2() below, or inflateBack() and
perform their own processing of the gzip header and trailer.
perform their own processing of the gzip header and trailer. When processing
gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output
producted so far. The CRC-32 is checked against the gzip trailer.
inflate() returns Z_OK if some progress has been made (more input processed
or more output produced), Z_STREAM_END if the end of the compressed data has
@ -580,10 +589,15 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
uInt dictLength));
/*
Initializes the compression dictionary from the given byte sequence
without producing any compressed output. This function must be called
immediately after deflateInit, deflateInit2 or deflateReset, before any call
of deflate. The compressor and decompressor must use exactly the same
dictionary (see inflateSetDictionary).
without producing any compressed output. When using the zlib format, this
function must be called immediately after deflateInit, deflateInit2 or
deflateReset, and before any call of deflate. When doing raw deflate, this
function must be called either before any call of deflate, or immediately
after the completion of a deflate block, i.e. after all input has been
consumed and all output has been delivered when using any of the flush
options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH. The
compressor and decompressor must use exactly the same dictionary (see
inflateSetDictionary).
The dictionary should consist of strings (byte sequences) that are likely
to be encountered later in the data to be compressed, with the most commonly
@ -610,8 +624,8 @@ ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm,
deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a
parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is
inconsistent (for example if deflate has already been called for this stream
or if the compression method is bsort). deflateSetDictionary does not
perform any compression: this will be done by deflate().
or if not at a block boundary for raw deflate). deflateSetDictionary does
not perform any compression: this will be done by deflate().
*/
ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest,
@ -688,9 +702,29 @@ ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm,
deflation of sourceLen bytes. It must be called after deflateInit() or
deflateInit2(), and after deflateSetHeader(), if used. This would be used
to allocate an output buffer for deflation in a single pass, and so would be
called before deflate().
called before deflate(). If that first deflate() call is provided the
sourceLen input bytes, an output buffer allocated to the size returned by
deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed
to return Z_STREAM_END. Note that it is possible for the compressed size to
be larger than the value returned by deflateBound() if flush options other
than Z_FINISH or Z_NO_FLUSH are used.
*/
ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm,
unsigned *pending,
int *bits));
/*
deflatePending() returns the number of bytes and bits of output that have
been generated, but not yet provided in the available output. The bytes not
provided would be due to the available output space having being consumed.
The number of bits of output not provided are between 0 and 7, where they
await more bits to join them in order to fill out a full byte. If pending
or bits are Z_NULL, then those values are not set.
deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source
stream state was inconsistent.
*/
ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
int bits,
int value));
@ -703,8 +737,9 @@ ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm,
than or equal to 16, and that many of the least significant bits of value
will be inserted in the output.
deflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source
stream state was inconsistent.
deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough
room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the
source stream state was inconsistent.
*/
ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm,
@ -790,10 +825,11 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
if that call returned Z_NEED_DICT. The dictionary chosen by the compressor
can be determined from the adler32 value returned by that call of inflate.
The compressor and decompressor must use exactly the same dictionary (see
deflateSetDictionary). For raw inflate, this function can be called
immediately after inflateInit2() or inflateReset() and before any call of
inflate() to set the dictionary. The application must insure that the
dictionary that was used for compression is provided.
deflateSetDictionary). For raw inflate, this function can be called at any
time to set the dictionary. If the provided dictionary is smaller than the
window and there is already data in the window, then the provided dictionary
will amend what's there. The application must insure that the dictionary
that was used for compression is provided.
inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a
parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is
@ -803,19 +839,38 @@ ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm,
inflate().
*/
ZEXTERN int ZEXPORT inflateGetDictionary OF((z_streamp strm,
Bytef *dictionary,
uInt *dictLength));
/*
Returns the sliding dictionary being maintained by inflate. dictLength is
set to the number of bytes in the dictionary, and that many bytes are copied
to dictionary. dictionary must have enough space, where 32768 bytes is
always enough. If inflateGetDictionary() is called with dictionary equal to
Z_NULL, then only the dictionary length is returned, and nothing is copied.
Similary, if dictLength is Z_NULL, then it is not set.
inflateGetDictionary returns Z_OK on success, or Z_STREAM_ERROR if the
stream state is inconsistent.
*/
ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm));
/*
Skips invalid compressed data until a full flush point (see above the
description of deflate with Z_FULL_FLUSH) can be found, or until all
Skips invalid compressed data until a possible full flush point (see above
for the description of deflate with Z_FULL_FLUSH) can be found, or until all
available input is skipped. No output is provided.
inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR
if no more input was provided, Z_DATA_ERROR if no flush point has been
found, or Z_STREAM_ERROR if the stream structure was inconsistent. In the
success case, the application may save the current current value of total_in
which indicates where valid compressed data was found. In the error case,
the application may repeatedly call inflateSync, providing more input each
time, until success or end of the input data.
inflateSync searches for a 00 00 FF FF pattern in the compressed data.
All full flush points have this pattern, but not all occurrences of this
pattern are full flush points.
inflateSync returns Z_OK if a possible full flush point has been found,
Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point
has been found, or Z_STREAM_ERROR if the stream structure was inconsistent.
In the success case, the application may save the current current value of
total_in which indicates where valid compressed data was found. In the
error case, the application may repeatedly call inflateSync, providing more
input each time, until success or end of the input data.
*/
ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest,
@ -962,12 +1017,13 @@ ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits,
See inflateBack() for the usage of these routines.
inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of
the paramaters are invalid, Z_MEM_ERROR if the internal state could not be
the parameters are invalid, Z_MEM_ERROR if the internal state could not be
allocated, or Z_VERSION_ERROR if the version of the library does not match
the version of the header file.
*/
typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *));
typedef unsigned (*in_func) OF((void FAR *,
z_const unsigned char FAR * FAR *));
typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned));
ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
@ -975,11 +1031,12 @@ ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm,
out_func out, void FAR *out_desc));
/*
inflateBack() does a raw inflate with a single call using a call-back
interface for input and output. This is more efficient than inflate() for
file i/o applications in that it avoids copying between the output and the
sliding window by simply making the window itself the output buffer. This
function trusts the application to not change the output buffer passed by
the output function, at least until inflateBack() returns.
interface for input and output. This is potentially more efficient than
inflate() for file i/o applications, in that it avoids copying between the
output and the sliding window by simply making the window itself the output
buffer. inflate() can be faster on modern CPUs when used with large
buffers. inflateBack() trusts the application to not change the output
buffer passed by the output function, at least until inflateBack() returns.
inflateBackInit() must be called first to allocate the internal state
and to initialize the state with the user-provided window buffer.
@ -1088,6 +1145,7 @@ ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void));
27-31: 0 (reserved)
*/
#ifndef Z_SOLO
/* utility functions */
@ -1149,10 +1207,11 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
uncompress returns Z_OK if success, Z_MEM_ERROR if there was not
enough memory, Z_BUF_ERROR if there was not enough room in the output
buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete.
buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In
the case where there is not enough room, uncompress() will fill the output
buffer with the uncompressed data up to that point.
*/
/* gzip file access functions */
/*
@ -1162,7 +1221,7 @@ ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen,
wrapper, documented in RFC 1952, wrapped around a deflate stream.
*/
typedef voidp gzFile; /* opaque gzip file descriptor */
typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */
/*
ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
@ -1172,13 +1231,28 @@ ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode));
a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only
compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F'
for fixed code compression as in "wb9F". (See the description of
deflateInit2 for more information about the strategy parameter.) Also "a"
can be used instead of "w" to request that the gzip stream that will be
written be appended to the file. "+" will result in an error, since reading
and writing to the same gzip file is not supported.
deflateInit2 for more information about the strategy parameter.) 'T' will
request transparent writing or appending with no compression and not using
the gzip format.
"a" can be used instead of "w" to request that the gzip stream that will
be written be appended to the file. "+" will result in an error, since
reading and writing to the same gzip file is not supported. The addition of
"x" when writing will create the file exclusively, which fails if the file
already exists. On systems that support it, the addition of "e" when
reading or writing will set the flag to close the file on an execve() call.
These functions, as well as gzip, will read and decode a sequence of gzip
streams in a file. The append function of gzopen() can be used to create
such a file. (Also see gzflush() for another way to do this.) When
appending, gzopen does not test whether the file begins with a gzip stream,
nor does it look for the end of the gzip streams to begin appending. gzopen
will simply append a gzip stream to the existing file.
gzopen can be used to read a file which is not in gzip format; in this
case gzread will directly read from the file without decompression.
case gzread will directly read from the file without decompression. When
reading, this will be detected automatically by looking for the magic two-
byte gzip header.
gzopen returns NULL if the file could not be opened, if there was
insufficient memory to allocate the gzFile state, or if an invalid mode was
@ -1197,7 +1271,11 @@ ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode));
descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor
fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd,
mode);. The duplicated descriptor should be saved to avoid a leak, since
gzdopen does not close fd if it fails.
gzdopen does not close fd if it fails. If you are using fileno() to get the
file descriptor from a FILE *, then you will have to use dup() to avoid
double-close()ing the file descriptor. Both gzclose() and fclose() will
close the associated file descriptor, so they need to have different file
descriptors.
gzdopen returns NULL if there was insufficient memory to allocate the
gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not
@ -1235,14 +1313,26 @@ ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy));
ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len));
/*
Reads the given number of uncompressed bytes from the compressed file. If
the input file was not in gzip format, gzread copies the given number of
bytes into the buffer.
the input file is not in gzip format, gzread copies the given number of
bytes into the buffer directly from the file.
After reaching the end of a gzip stream in the input, gzread will continue
to read, looking for another gzip stream, or failing that, reading the rest
of the input file directly without decompression. The entire input file
will be read if gzread is called until it returns less than the requested
len.
to read, looking for another gzip stream. Any number of gzip streams may be
concatenated in the input file, and will all be decompressed by gzread().
If something other than a gzip stream is encountered after a gzip stream,
that remaining trailing garbage is ignored (and no error is returned).
gzread can be used to read a gzip file that is being concurrently written.
Upon reaching the end of the input, gzread will return with the available
data. If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then
gzclearerr can be used to clear the end of file indicator in order to permit
gzread to be tried again. Z_OK indicates that a gzip stream was completed
on the last gzread. Z_BUF_ERROR indicates that the input file ended in the
middle of a gzip stream. Note that gzread does not return -1 in the event
of an incomplete gzip stream. This error is deferred until gzclose(), which
will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip
stream. Alternatively, gzerror can be used before gzclose to detect this
case.
gzread returns the number of uncompressed bytes actually read, less than
len for end of file, or -1 for error.
@ -1256,7 +1346,7 @@ ZEXTERN int ZEXPORT gzwrite OF((gzFile file,
error.
*/
ZEXTERN int ZEXPORTVA gzprintf OF((gzFile file, const char *format, ...));
ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...));
/*
Converts, formats, and writes the arguments to the compressed file under
control of the format string, as in fprintf. gzprintf returns the number of
@ -1301,7 +1391,10 @@ ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c));
ZEXTERN int ZEXPORT gzgetc OF((gzFile file));
/*
Reads one byte from the compressed file. gzgetc returns this byte or -1
in case of end of file or error.
in case of end of file or error. This is implemented as a macro for speed.
As such, it does not do all of the checking the other functions do. I.e.
it does not check to see if file is NULL, nor whether the structure file
points to has been clobbered or not.
*/
ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file));
@ -1397,9 +1490,7 @@ ZEXTERN int ZEXPORT gzeof OF((gzFile file));
ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
/*
Returns true (1) if file is being copied directly while reading, or false
(0) if file is a gzip stream being decompressed. This state can change from
false to true while reading the input file if the end of a gzip stream is
reached, but is followed by data that is not another gzip stream.
(0) if file is a gzip stream being decompressed.
If the input file is empty, gzdirect() will return true, since the input
does not contain a gzip stream.
@ -1408,6 +1499,13 @@ ZEXTERN int ZEXPORT gzdirect OF((gzFile file));
cause buffers to be allocated to allow reading the file to determine if it
is a gzip file. Therefore if gzbuffer() is used, it should be called before
gzdirect().
When writing, gzdirect() returns true (1) if transparent writing was
requested ("wT" for the gzopen() mode), or false (0) otherwise. (Note:
gzdirect() is not needed when writing. Transparent writing must be
explicitly requested, so the application already knows the answer. When
linking statically, using gzdirect() will include all of the zlib code for
gzip file reading and decompression, which may not be desired.)
*/
ZEXTERN int ZEXPORT gzclose OF((gzFile file));
@ -1419,7 +1517,8 @@ ZEXTERN int ZEXPORT gzclose OF((gzFile file));
must not be called more than once on the same allocation.
gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a
file operation error, or Z_OK on success.
file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the
last read ended in the middle of a gzip stream, or Z_OK on success.
*/
ZEXTERN int ZEXPORT gzclose_r OF((gzFile file));
@ -1457,6 +1556,7 @@ ZEXTERN void ZEXPORT gzclearerr OF((gzFile file));
file that is being written concurrently.
*/
#endif /* !Z_SOLO */
/* checksum functions */
@ -1492,16 +1592,17 @@ ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2,
Combine two Adler-32 checksums into one. For two sequences of bytes, seq1
and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for
each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of
seq1 and seq2 concatenated, requiring only adler1, adler2, and len2.
seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note
that the z_off_t type (like off_t) is a signed integer. If len2 is
negative, the result has no meaning or utility.
*/
ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len));
/*
Update a running CRC-32 with the bytes buf[0..len-1] and return the
updated CRC-32. If buf is Z_NULL, this function returns the required
initial value for the for the crc. Pre- and post-conditioning (one's
complement) is performed within this function so it shouldn't be done by the
application.
initial value for the crc. Pre- and post-conditioning (one's complement) is
performed within this function so it shouldn't be done by the application.
Usage example:
@ -1544,17 +1645,42 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
const char *version,
int stream_size));
#define deflateInit(strm, level) \
deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream))
deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream))
#define inflateInit(strm) \
inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream))
inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream))
#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \
deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\
(strategy), ZLIB_VERSION, sizeof(z_stream))
(strategy), ZLIB_VERSION, (int)sizeof(z_stream))
#define inflateInit2(strm, windowBits) \
inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream))
inflateInit2_((strm), (windowBits), ZLIB_VERSION, \
(int)sizeof(z_stream))
#define inflateBackInit(strm, windowBits, window) \
inflateBackInit_((strm), (windowBits), (window), \
ZLIB_VERSION, sizeof(z_stream))
ZLIB_VERSION, (int)sizeof(z_stream))
#ifndef Z_SOLO
/* gzgetc() macro and its supporting function and exposed data structure. Note
* that the real internal state is much larger than the exposed structure.
* This abbreviated structure exposes just enough for the gzgetc() macro. The
* user should not mess with these exposed elements, since their names or
* behavior could change in the future, perhaps even capriciously. They can
* only be used by the gzgetc() macro. You have been warned.
*/
struct gzFile_s {
unsigned have;
unsigned char *next;
z_off64_t pos;
};
ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); /* backward compatibility */
#ifdef Z_PREFIX_SET
# undef z_gzgetc
# define z_gzgetc(g) \
((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g))
#else
# define gzgetc(g) \
((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc(g))
#endif
/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or
* change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if
@ -1562,7 +1688,7 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
* functions are changed to 64 bits) -- in case these are set on systems
* without large file support, _LFS64_LARGEFILE must also be true
*/
#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
#ifdef Z_LARGE64
ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int));
ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile));
@ -1571,14 +1697,23 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t));
#endif
#if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0
# define gzopen gzopen64
# define gzseek gzseek64
# define gztell gztell64
# define gzoffset gzoffset64
# define adler32_combine adler32_combine64
# define crc32_combine crc32_combine64
# ifdef _LARGEFILE64_SOURCE
#if !defined(ZLIB_INTERNAL) && defined(Z_WANT64)
# ifdef Z_PREFIX_SET
# define z_gzopen z_gzopen64
# define z_gzseek z_gzseek64
# define z_gztell z_gztell64
# define z_gzoffset z_gzoffset64
# define z_adler32_combine z_adler32_combine64
# define z_crc32_combine z_crc32_combine64
# else
# define gzopen gzopen64
# define gzseek gzseek64
# define gztell gztell64
# define gzoffset gzoffset64
# define adler32_combine adler32_combine64
# define crc32_combine crc32_combine64
# endif
# ifndef Z_LARGE64
ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *));
ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int));
ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile));
@ -1595,6 +1730,13 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
#endif
#else /* Z_SOLO */
ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t));
ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t));
#endif /* !Z_SOLO */
/* hack for buggy compilers */
#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL)
struct internal_state {int dummy;};
@ -1603,8 +1745,21 @@ ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits,
/* undocumented functions */
ZEXTERN const char * ZEXPORT zError OF((int));
ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp));
ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void));
ZEXTERN const z_crc_t FAR * ZEXPORT get_crc_table OF((void));
ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int));
ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp));
ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp));
#if defined(_WIN32) && !defined(Z_SOLO)
ZEXTERN gzFile ZEXPORT gzopen_w OF((const wchar_t *path,
const char *mode));
#endif
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
# ifndef Z_SOLO
ZEXTERN int ZEXPORTVA gzvprintf Z_ARG((gzFile file,
const char *format,
va_list va));
# endif
#endif
#ifdef __cplusplus
}

View file

@ -1,5 +1,5 @@
/* zutil.h -- internal interface and configuration of the compression library
* Copyright (C) 1995-2010 Jean-loup Gailly.
* Copyright (C) 1995-2013 Jean-loup Gailly.
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@ -13,7 +13,7 @@
#ifndef ZUTIL_H
#define ZUTIL_H
#if ((__GNUC__-0) * 10 + __GNUC_MINOR__-0 >= 33) && !defined(NO_VIZ)
#ifdef HAVE_HIDDEN
# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
#else
# define ZLIB_INTERNAL
@ -21,7 +21,7 @@
#include "zlib.h"
#ifdef STDC
#if defined(STDC) && !defined(Z_SOLO)
# if !(defined(_WIN32_WCE) && defined(_MSC_VER))
# include <stddef.h>
# endif
@ -29,6 +29,10 @@
# include <stdlib.h>
#endif
#ifdef Z_SOLO
typedef long ptrdiff_t; /* guess -- will be caught if guess is wrong */
#endif
#ifndef local
# define local static
#endif
@ -40,13 +44,13 @@ typedef unsigned short ush;
typedef ush FAR ushf;
typedef unsigned long ulg;
extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
/* (size given to avoid silly warnings with Visual C++) */
#define ERR_MSG(err) z_errmsg[Z_NEED_DICT-(err)]
#define ERR_RETURN(strm,err) \
return (strm->msg = (char*)ERR_MSG(err), (err))
return (strm->msg = ERR_MSG(err), (err))
/* To be used only when the state is known to be valid */
/* common constants */
@ -78,16 +82,18 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#if defined(MSDOS) || (defined(WINDOWS) && !defined(WIN32))
# define OS_CODE 0x00
# if defined(__TURBOC__) || defined(__BORLANDC__)
# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
/* Allow compilation with ANSI keywords only enabled */
void _Cdecl farfree( void *block );
void *_Cdecl farmalloc( unsigned long nbytes );
# else
# include <alloc.h>
# ifndef Z_SOLO
# if defined(__TURBOC__) || defined(__BORLANDC__)
# if (__STDC__ == 1) && (defined(__LARGE__) || defined(__COMPACT__))
/* Allow compilation with ANSI keywords only enabled */
void _Cdecl farfree( void *block );
void *_Cdecl farmalloc( unsigned long nbytes );
# else
# include <alloc.h>
# endif
# else /* MSC or DJGPP */
# include <malloc.h>
# endif
# else /* MSC or DJGPP */
# include <malloc.h>
# endif
#endif
@ -107,18 +113,20 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#ifdef OS2
# define OS_CODE 0x06
# ifdef M_I86
# if defined(M_I86) && !defined(Z_SOLO)
# include <malloc.h>
# endif
#endif
#if defined(MACOS) || defined(TARGET_OS_MAC)
# define OS_CODE 0x07
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
# include <unix.h> /* for fdopen */
# else
# ifndef fdopen
# define fdopen(fd,mode) NULL /* No fdopen() */
# ifndef Z_SOLO
# if defined(__MWERKS__) && __dest_os != __be_os && __dest_os != __win32_os
# include <unix.h> /* for fdopen */
# else
# ifndef fdopen
# define fdopen(fd,mode) NULL /* No fdopen() */
# endif
# endif
# endif
#endif
@ -153,14 +161,15 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# endif
#endif
#if defined(__BORLANDC__)
#if defined(__BORLANDC__) && !defined(MSDOS)
#pragma warn -8004
#pragma warn -8008
#pragma warn -8066
#endif
/* provide prototypes for these when building zlib without LFS */
#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
#if !defined(_WIN32) && \
(!defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0)
ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t));
ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t));
#endif
@ -177,42 +186,7 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
/* functions */
#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
# ifndef HAVE_VSNPRINTF
# define HAVE_VSNPRINTF
# endif
#endif
#if defined(__CYGWIN__)
# ifndef HAVE_VSNPRINTF
# define HAVE_VSNPRINTF
# endif
#endif
#ifndef HAVE_VSNPRINTF
# ifdef MSDOS
/* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
but for now we just assume it doesn't. */
# define NO_vsnprintf
# endif
# ifdef __TURBOC__
# define NO_vsnprintf
# endif
# ifdef WIN32
/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
# if !defined(vsnprintf) && !defined(NO_vsnprintf)
# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
# define vsnprintf _vsnprintf
# endif
# endif
# endif
# ifdef __SASC
# define NO_vsnprintf
# endif
#endif
#ifdef VMS
# define NO_vsnprintf
#endif
#if defined(pyr)
#if defined(pyr) || defined(Z_SOLO)
# define NO_MEMCPY
#endif
#if defined(SMALL_MEDIUM) && !defined(_MSC_VER) && !defined(__SC__)
@ -261,14 +235,19 @@ extern const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
# define Tracecv(c,x)
#endif
voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
unsigned size));
void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr));
#ifndef Z_SOLO
voidpf ZLIB_INTERNAL zcalloc OF((voidpf opaque, unsigned items,
unsigned size));
void ZLIB_INTERNAL zcfree OF((voidpf opaque, voidpf ptr));
#endif
#define ZALLOC(strm, items, size) \
(*((strm)->zalloc))((strm)->opaque, (items), (size))
#define ZFREE(strm, addr) (*((strm)->zfree))((strm)->opaque, (voidpf)(addr))
#define TRY_FREE(s, p) {if (p) ZFREE(s, p);}
/* Reverse the bytes in a 32-bit value */
#define ZSWAP32(q) ((((q) >> 24) & 0xff) + (((q) >> 8) & 0xff00) + \
(((q) & 0xff00) << 8) + (((q) & 0xff) << 24))
#endif /* ZUTIL_H */

View file

@ -37,6 +37,10 @@ int QCC_tell (int handle);
int QC_strcasecmp (const char *s1, const char *s2);
void QC_strlcat(char *dest, const char *src, size_t destsize);
void QC_strlcpy(char *dest, const char *src, size_t destsize);
void QC_strnlcpy(char *dest, const char *src, size_t srclen, size_t destsize);
#ifdef _MSC_VER
#define QC_vsnprintf _vsnprintf
static void VARGS QC_snprintfz (char *dest, size_t size, const char *fmt, ...)

View file

@ -91,10 +91,7 @@ pbool CompileParams(progfuncs_t *progfuncs, int doall, int nump, char **parms)
PostCompile();
if (*errorfile)
{
if (!externs->useeditor)
printf("Error in %s on line %i\n", errorfile, errorline);
else
externs->useeditor(&progfuncs->funcs, errorfile, errorline, 0, nump, parms);
printf("Error in %s on line %i\n", errorfile, errorline);
}
return false;
}
@ -118,8 +115,6 @@ int PDECL Comp_Begin(pubprogfuncs_t *progfuncs, int nump, char **parms)
if (setjmp(qcccompileerror))
{
PostCompile();
if (*errorfile)
progfuncs->parms->useeditor(&qccprogfuncs->funcs, errorfile, errorline, 0, nump, parms);
return false;
}
@ -134,8 +129,6 @@ int PDECL Comp_Continue(pubprogfuncs_t *progfuncs)
if (setjmp(qcccompileerror))
{
PostCompile();
if (*errorfile && progfuncs->parms->useeditor)
progfuncs->parms->useeditor(progfuncs, errorfile, errorline, 0, comp_nump, comp_parms);
return false;
}
@ -145,9 +138,6 @@ int PDECL Comp_Continue(pubprogfuncs_t *progfuncs)
{
PostCompile();
if (*errorfile && progfuncs->parms->useeditor)
progfuncs->parms->useeditor(progfuncs, errorfile, errorline, 0 , comp_nump, comp_parms);
return false;
}

View file

@ -31,18 +31,16 @@
#error Bad cont size
#endif
#ifdef DEBUGABLE
#define OPCODE (progfuncs->funcs.pr_trace?(st->op & ~0x8000):st->op)
#else
#define OPCODE (st->op)
#endif
#define ENGINEPOINTER(p) ((char*)(p) - progfuncs->funcs.stringtable)
#define QCPOINTER(p) (eval_t *)(p->_int+progfuncs->funcs.stringtable)
#define QCPOINTERM(p) (eval_t *)((p)+progfuncs->funcs.stringtable)
#define QCPOINTERWRITEFAIL(p,sz) ((unsigned int)p->_int-1 >= prinst.addressableused-1-sz) //disallows null writes
#define QCPOINTERREADFAIL(p,sz) ((unsigned int)p->_int >= prinst.addressableused-sz) //permits null reads
#define QCFAULT return (pr_xstatement=(st-pr_statements)-1),PR_HandleFault
//rely upon just st
{
#ifdef DEBUGABLE
@ -69,20 +67,23 @@ cont: //last statement may have been a breakpoint
}
prinst.watch_old = *prinst.watch_ptr;
// prinst.watch_ptr = NULL;
if (progfuncs->funcs.pr_trace<1)
progfuncs->funcs.pr_trace=1; //this is what it's for
}
progfuncs->funcs.debug_trace=DEBUG_TRACE_INTO; //this is what it's for
if (progfuncs->funcs.pr_trace)
s=ShowStep(progfuncs, s);
s=ShowStep(progfuncs, s, "Watchpoint hit");
}
else if (progfuncs->funcs.debug_trace)
s=ShowStep(progfuncs, s, NULL);
st = pr_statements + s;
pr_xfunction->profile+=1;
op = (progfuncs->funcs.debug_trace?(st->op & ~0x8000):st->op);
reeval:
#else
st++;
op = st->op;
#endif
switch (OPCODE)
switch (op)
{
case OP_ADD_F:
OPC->_float = OPA->_float + OPB->_float;
@ -338,8 +339,7 @@ reeval:
{
if (OPB->_int == -1)
break;
pr_xstatement = st-pr_statements;
PR_RunError (&progfuncs->funcs, "bad pointer write in %s", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name));
QCFAULT(&progfuncs->funcs, "bad pointer write in %s", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name));
}
ptr = QCPOINTER(OPB);
ptr->_float = (float)OPA->_int;
@ -349,8 +349,7 @@ reeval:
{
if (OPB->_int == -1)
break;
pr_xstatement = st-pr_statements;
PR_RunError (&progfuncs->funcs, "bad pointer write in %s", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name));
QCFAULT(&progfuncs->funcs, "bad pointer write in %s", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name));
}
ptr = QCPOINTER(OPB);
ptr->_int = (int)OPA->_float;
@ -365,8 +364,7 @@ reeval:
{
if (OPB->_int == -1)
break;
pr_xstatement = st-pr_statements;
PR_RunError (&progfuncs->funcs, "bad pointer write in %s (%x >= %x)", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name), OPB->_int, prinst.addressableused);
QCFAULT(&progfuncs->funcs, "bad pointer write in %s (%x >= %x)", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name), OPB->_int, prinst.addressableused);
}
ptr = QCPOINTER(OPB);
ptr->_int = OPA->_int;
@ -376,8 +374,7 @@ reeval:
{
if (OPB->_int == -1)
break;
pr_xstatement = st-pr_statements;
PR_RunError (&progfuncs->funcs, "bad pointer write in %s (%x >= %x)", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name), OPB->_int, prinst.addressableused);
QCFAULT(&progfuncs->funcs, "bad pointer write in %s (%x >= %x)", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name), OPB->_int, prinst.addressableused);
}
ptr = QCPOINTER(OPB);
ptr->_vector[0] = OPA->_vector[0];
@ -388,8 +385,7 @@ reeval:
case OP_STOREP_C: //store character in a string
if (QCPOINTERWRITEFAIL(OPB, sizeof(char)))
{
pr_xstatement = st-pr_statements;
PR_RunError (&progfuncs->funcs, "bad pointer write in %s (%x >= %x)", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name), OPB->_int, prinst.addressableused);
QCFAULT(&progfuncs->funcs, "bad pointer write in %s (%x >= %x)", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name), OPB->_int, prinst.addressableused);
}
ptr = QCPOINTER(OPB);
*(unsigned char *)ptr = (char)OPA->_float;
@ -400,7 +396,7 @@ reeval:
if ((unsigned)OPA->edict >= (unsigned)sv_num_edicts)
{
pr_xstatement = st-pr_statements;
if (PR_RunWarning (&progfuncs->funcs, "OP_ADDRESS references invalid entity in %s", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name)))
if (PR_RunWarning (&progfuncs->funcs, "OP_ADDRESS references invalid entity in %s\n", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name)))
{
st--;
goto cont;
@ -421,7 +417,7 @@ reeval:
d16 = ED_GlobalAtOfs16(progfuncs, st->a);
f = ED_FieldAtOfs(progfuncs, OPB->_int + progfuncs->funcs.fieldadjust);
pr_xstatement = st-pr_statements;
if (PR_RunWarning(&progfuncs->funcs, "assignment to read-only entity %i in %s (%s.%s)", OPA->edict, PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name), d16?PR_StringToNative(&progfuncs->funcs, d16->s_name):NULL, f?f->name:NULL))
if (PR_RunWarning(&progfuncs->funcs, "assignment to read-only entity %i in %s (%s.%s)\n", OPA->edict, PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name), d16?PR_StringToNative(&progfuncs->funcs, d16->s_name):NULL, f?f->name:NULL))
{
st--;
goto cont;
@ -451,7 +447,7 @@ reeval:
if ((unsigned)OPA->edict >= (unsigned)sv_num_edicts)
{
pr_xstatement = st-pr_statements;
if (PR_RunWarning (&progfuncs->funcs, "OP_LOAD references invalid entity %i in %s", OPA->edict, PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name)))
if (PR_RunWarning (&progfuncs->funcs, "OP_LOAD references invalid entity %i in %s\n", OPA->edict, PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name)))
{
st--;
goto cont;
@ -471,7 +467,7 @@ reeval:
if ((unsigned)OPA->edict >= (unsigned)sv_num_edicts)
{
pr_xstatement = st-pr_statements;
if (PR_RunWarning (&progfuncs->funcs, "OP_LOAD_V references invalid entity %i in %s", OPA->edict, PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name)))
if (PR_RunWarning (&progfuncs->funcs, "OP_LOAD_V references invalid entity %i in %s\n", OPA->edict, PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name)))
{
st--;
goto cont;
@ -565,10 +561,10 @@ reeval:
RUNAWAYCHECK();
pr_xstatement = st-pr_statements;
if (OPCODE > OP_CALL8)
progfuncs->funcs.callargc = OPCODE - (OP_CALL1H-1);
if (op > OP_CALL8)
progfuncs->funcs.callargc = op - (OP_CALL1H-1);
else
progfuncs->funcs.callargc = OPCODE - OP_CALL0;
progfuncs->funcs.callargc = op - OP_CALL0;
fnum = OPA->function;
glob = NULL; //try to derestrict it.
@ -583,26 +579,23 @@ reeval:
char *msg = fnum?"OP_CALL references invalid function in %s\n":"NULL function from qc (inside %s).\n";
PR_SwitchProgsParms(progfuncs, callerprogs);
//break/skip the instruction.
glob = pr_globals;
if (!progfuncs->funcs.debug_trace)
QCFAULT(&progfuncs->funcs, msg, PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name));
//skip the instruction if they just try stepping over it anyway.
PR_StackTrace(&progfuncs->funcs, 0);
printf(msg, PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name));
glob = pr_globals;
#ifndef DEBUGABLE
progfuncs->funcs.pr_trace++;
st--;
goto cont;
#else
pr_globals[OFS_RETURN] = 0;
pr_globals[OFS_RETURN+1] = 0;
pr_globals[OFS_RETURN+2] = 0;
break;
#endif
}
newf = &pr_cp_functions[fnum & ~0xff000000];
if (newf->first_statement < 0)
if (newf->first_statement <= 0)
{ // negative statements are built in functions
/*calling a builtin in another progs may affect that other progs' globals instead, is the theory anyway, so args and stuff need to move over*/
if (pr_typecurrent != 0)
@ -613,7 +606,6 @@ reeval:
}
i = -newf->first_statement;
// p = pr_typecurrent;
progfuncs->funcs.lastcalledbuiltinnumber = i;
if (i < externs->numglobalbuiltins)
{
#ifndef QCGC
@ -630,16 +622,10 @@ reeval:
}
else
{
i -= externs->numglobalbuiltins;
if (i >= current_progstate->numbuiltins)
{
// if (newf->first_statement == -0x7fffffff)
// ((builtin_t)newf->profile) (progfuncs, (struct globalvars_s *)current_progstate->globals);
// else
PR_RunError (&progfuncs->funcs, "Bad builtin call number - %i", -newf->first_statement);
}
else
current_progstate->builtins [i] (&progfuncs->funcs, (struct globalvars_s *)current_progstate->globals);
// if (newf->first_statement == -0x7fffffff)
// ((builtin_t)newf->profile) (progfuncs, (struct globalvars_s *)current_progstate->globals);
// else
PR_RunError (&progfuncs->funcs, "Bad builtin call number - %i", -newf->first_statement);
}
// memcpy(&pr_progstate[p].globals[OFS_RETURN], &current_progstate->globals[OFS_RETURN], sizeof(vec3_t));
PR_SwitchProgsParms(progfuncs, (progsnum_t)callerprogs);
@ -836,7 +822,7 @@ reeval:
OPC->_vector[2] = ptr->_vector[2];
break;
case OP_XOR_I:
case OP_BITXOR_I:
OPC->_int = OPA->_int ^ OPB->_int;
break;
case OP_RSHIFT_I:
@ -1044,7 +1030,7 @@ reeval:
//the case opcodes depend upon the preceding switch.
//otherwise the switch itself is much like a goto
//don't embed the case/caserange checks directly into the switch so that custom caseranges can be potentially be implemented with hybrid emulation.
switchcomparison = OPCODE - OP_SWITCH_F;
switchcomparison = op - OP_SWITCH_F;
switchref = OPA;
RUNAWAYCHECK();
st += (sofs)st->b - 1; // offset the s++
@ -1207,12 +1193,13 @@ reeval:
if ((unsigned int)OPA->_int < (unsigned int)st->c || (unsigned int)OPA->_int >= (unsigned int)st->b)
{
printf("Progs boundcheck failed. Value is %i. Must be between %u and %u\n", OPA->_int, st->c, st->b);
s=ShowStep(progfuncs, st - pr_statements);
QCFAULT(&progfuncs->funcs, "Progs boundcheck failed. Value is %i. Must be between %u and %u\n", OPA->_int, st->c, st->b);
/* s=ShowStepf(progfuncs, st - pr_statements, "Progs boundcheck failed. Value is %i. Must be between %u and %u\n", OPA->_int, st->c, st->b);
if (st == pr_statements + s)
PR_RunError(&progfuncs->funcs, "unable to resume boundcheck");
st = pr_statements + s;
return s;
}
*/ }
break;
/* case OP_PUSH:
OPC->_int = ENGINEPOINTER(&localstack[localstack_used+pr_spushed]);
@ -1235,18 +1222,19 @@ reeval:
break;
*/
default:
if (st->op & 0x8000) //break point!
if (op & 0x8000) //break point!
{
pr_xstatement = s = st-pr_statements;
printf("Break point hit in %s.\n", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name));
if (progfuncs->funcs.pr_trace<1)
progfuncs->funcs.pr_trace=1; //this is what it's for
s = ShowStep(progfuncs, s);
st = &pr_statements[s]; //let the user move execution
pr_xstatement = s = st-pr_statements;
op &= ~0x8000;
s = st-pr_statements;
if (pr_xstatement != s)
{
pr_xstatement = s;
printf("Break point hit in %s.\n", PR_StringToNative(&progfuncs->funcs, pr_xfunction->s_name));
s = ShowStep(progfuncs, s, NULL);
st = &pr_statements[s]; //let the user move execution
pr_xstatement = s = st-pr_statements;
op = st->op & ~0x8000;
}
goto reeval; //reexecute
}
pr_xstatement = st-pr_statements;

View file

@ -902,7 +902,7 @@ const char *ASMCALL PR_StringToNative (pubprogfuncs_t *ppf, string_t str)
int i = str & ~STRING_SPECMASK;
if (i >= prinst.numallocedstrings)
{
if (!progfuncs->funcs.pr_trace) //don't spam this
if (!progfuncs->funcs.debug_trace) //don't spam this
PR_RunWarning(&progfuncs->funcs, "invalid static string %x\n", str);
return "";
}
@ -910,7 +910,7 @@ const char *ASMCALL PR_StringToNative (pubprogfuncs_t *ppf, string_t str)
return prinst.allocedstrings[i];
else
{
if (!progfuncs->funcs.pr_trace)
if (!progfuncs->funcs.debug_trace)
PR_RunWarning(&progfuncs->funcs, "invalid static string %x\n", str);
return ""; //urm, was freed...
}
@ -920,7 +920,7 @@ const char *ASMCALL PR_StringToNative (pubprogfuncs_t *ppf, string_t str)
unsigned int i = str & ~STRING_SPECMASK;
if (i >= prinst.numtempstrings || !prinst.tempstrings[i])
{
if (!progfuncs->funcs.pr_trace)
if (!progfuncs->funcs.debug_trace)
PR_RunWarning(&progfuncs->funcs, "invalid temp string %x\n", str);
return "";
}
@ -929,7 +929,7 @@ const char *ASMCALL PR_StringToNative (pubprogfuncs_t *ppf, string_t str)
if ((unsigned int)str >= (unsigned int)prinst.addressableused)
{
if (!progfuncs->funcs.pr_trace)
if (!progfuncs->funcs.debug_trace)
PR_RunWarning(&progfuncs->funcs, "invalid string offset %x\n", str);
return "";
}
@ -1273,8 +1273,7 @@ pubprogfuncs_t deffuncs = {
PR_ForkStack,
PR_ResumeThread,
PR_AbortStack,
0, //called builtin number
PR_GetBuiltinCallInfo,
QC_RegisterFieldVar,

View file

@ -222,7 +222,7 @@ enum qcop_e {
OP_DIV_VF,
OP_XOR_I, //140
OP_BITXOR_I, //140
OP_RSHIFT_I,
OP_LSHIFT_I,
@ -365,8 +365,8 @@ enum qcop_e {
OP_LOADA_STRUCT,
OP_STOREP_P,
OP_BINARYNOT_F,
OP_BINARYNOT_I,
OP_BITNOT_F,
OP_BITNOT_I,
OP_EQ_P,
OP_NE_P,
@ -393,6 +393,10 @@ enum qcop_e {
OP_MOD_I,
OP_MOD_V,
OP_BITXOR_F, //140
OP_RSHIFT_F,
OP_LSHIFT_F,
OP_NUMOPS
};

View file

@ -102,8 +102,7 @@ struct edict_s *PDECL ED_Alloc (pubprogfuncs_t *ppf)
if (i >= maxedicts-2)
{
printf("Running out of edicts\n");
progfuncs->funcs.pr_trace = 1; //trip the debugger whilst it's still valid
PR_RunWarning(&progfuncs->funcs, "Running out of edicts\n");
}
if (i >= maxedicts-1)
{
@ -1782,7 +1781,6 @@ char *PDECL PR_SaveEnts(pubprogfuncs_t *ppf, char *buf, int *bufofs, int bufmax,
AddS (qcva("progs %i {\n", a));
AddS (qcva("\"filename\" \"%s\"\n", pr_progstate[a].filename));
AddS (qcva("\"crc\" \"%i\"\n", pr_progstate[a].progs->crc));
AddS (qcva("\"numbuiltins\" \"%i\"\n", pr_progstate[a].numbuiltins));
AddS ("}\n");
}
}
@ -1979,8 +1977,8 @@ int PDECL PR_LoadEnts(pubprogfuncs_t *ppf, const char *file, float killonspawnfl
{file = QCC_COM_Parse(file); strcpy(filename, qcc_token);}
else if (!strcmp("crc", qcc_token))
{file = QCC_COM_Parse(file); header_crc = atoi(qcc_token);}
else if (!strcmp("numbuiltins", qcc_token))
{file = QCC_COM_Parse(file); numbuiltins = atoi(qcc_token);}
else if (!strcmp("numbuiltins", qcc_token)) //no longer supported.
{file = QCC_COM_Parse(file); /*qcc_token unused*/}
else if (qcc_token[0] == '}') //end of block
break;
else
@ -1988,17 +1986,6 @@ int PDECL PR_LoadEnts(pubprogfuncs_t *ppf, const char *file, float killonspawnfl
}
PR_ReallyLoadProgs(progfuncs, filename, &pr_progstate[num], true);
if (!externs->builtinsfor)
{
// Sys_Error("Couldn't reset the builtin functions");
current_progstate->builtins = NULL; //these are specific, we assume the global ones were set via pr_configure
current_progstate->numbuiltins = 0;
}
else
{
current_progstate->builtins = externs->builtinsfor(num, header_crc);
current_progstate->numbuiltins = numbuiltins;
}
if (num == 0 && oldglobals)
{
@ -3332,6 +3319,15 @@ retry:
if (progfuncs->funcs.stringtablesize + progfuncs->funcs.stringtable < pr_strings + pr_progs->numstrings)
progfuncs->funcs.stringtablesize = (pr_strings + pr_progs->numstrings) - progfuncs->funcs.stringtable;
if (externs->MapNamedBuiltin)
{
for (i=0,fnc2=pr_cp_functions; i<pr_progs->numfunctions; i++, fnc2++)
{
if (i && !fnc2->first_statement)
fnc2->first_statement = -externs->MapNamedBuiltin(&progfuncs->funcs, pr_progs->crc, PR_StringToNative(&progfuncs->funcs, fnc2->s_name));
}
}
eval = PR_FindGlobal(&progfuncs->funcs, "thisprogs", progstype, NULL);
if (eval)
eval->prog = progstype;

View file

@ -367,56 +367,6 @@ void PDECL PR_StackTrace (pubprogfuncs_t *ppf, int showlocals)
}
}
/*
============
PR_RunError
Aborts the currently executing function
============
*/
void VARGS PR_RunError (pubprogfuncs_t *progfuncs, char *error, ...)
{
va_list argptr;
char string[1024];
va_start (argptr,error);
Q_vsnprintf (string,sizeof(string)-1, error,argptr);
va_end (argptr);
// {
// void SV_EndRedirect (void);
// SV_EndRedirect();
// }
// PR_PrintStatement (pr_statements + pr_xstatement);
PR_StackTrace (progfuncs, true);
progfuncs->parms->Printf ("\n");
//editbadfile(pr_strings + pr_xfunction->s_file, -1);
// pr_depth = 0; // dump the stack so host_error can shutdown functions
// prinst->exitdepth = 0;
progfuncs->parms->Abort ("%s", string);
}
pbool PR_RunWarning (pubprogfuncs_t *progfuncs, char *error, ...)
{
va_list argptr;
char string[1024];
va_start (argptr,error);
Q_vsnprintf (string,sizeof(string)-1, error,argptr);
va_end (argptr);
progfuncs->parms->Printf ("%s, %s\n", string, ((progfuncs->pr_trace)?"ignoring":"enabling trace"));
PR_StackTrace (progfuncs, false);
if (progfuncs->pr_trace++ == 0)
return true;
return false;
}
/*
============================================================================
PR_ExecuteProgram
@ -440,6 +390,9 @@ int ASMCALL PR_EnterFunction (progfuncs_t *progfuncs, mfunction_t *f, int progsn
pr_stack[pr_depth].f = pr_xfunction;
pr_stack[pr_depth].progsnum = progsnum;
pr_stack[pr_depth].pushed = pr_spushed;
pr_stack[pr_depth].stepping = progfuncs->funcs.debug_trace;
if (progfuncs->funcs.debug_trace == DEBUG_TRACE_OVER)
progfuncs->funcs.debug_trace = DEBUG_TRACE_OFF;
if (prinst.profiling)
{
pr_stack[pr_depth].timestamp = Sys_GetClock();
@ -515,6 +468,9 @@ int ASMCALL PR_LeaveFunction (progfuncs_t *progfuncs)
PR_SwitchProgsParms(progfuncs, pr_stack[pr_depth].progsnum);
pr_spushed = pr_stack[pr_depth].pushed;
if (!progfuncs->funcs.debug_trace)
progfuncs->funcs.debug_trace = pr_stack[pr_depth].stepping;
if (prinst.profiling)
{
unsigned long long cycles;
@ -812,62 +768,68 @@ char *PDECL PR_EvaluateDebugString(pubprogfuncs_t *ppf, char *key)
*/
if (assignment)
{
assignment++;
while(*assignment == ' ')
assignment++;
char *str = assignment+1;
while(*str == ' ')
str++;
switch (type&~DEF_SAVEGLOBAL)
{
case ev_string:
#ifdef QCGC
*(string_t *)val = PR_AllocTempString(&progfuncs->funcs, assignment);
*(string_t *)val = PR_AllocTempString(&progfuncs->funcs, str);
#else
*(string_t *)val = PR_StringToProgs(&progfuncs->funcs, ED_NewString (&progfuncs->funcs, assignment, 0, true));
#endif
break;
case ev_float:
if (assignment[0] == '0' && (assignment[1] == 'x' || assignment[1] == 'X'))
*(float*)val = strtoul(assignment, NULL, 0);
if (str[0] == '0' && (str[1] == 'x' || str[1] == 'X'))
*(float*)val = strtoul(str, NULL, 0);
else
*(float *)val = (float)atof (assignment);
*(float *)val = (float)atof (str);
break;
case ev_integer:
*(int *)val = atoi (assignment);
*(int *)val = atoi (str);
break;
/* case ev_vector:
strcpy (string, assignment);
v = string;
w = string;
for (i=0 ; i<3 ; i++)
case ev_vector:
{
while (*v && *v != ' ')
v++;
*v = 0;
((float *)d)[i] = (float)atof (w);
w = v = v+1;
int i;
if (*str == '\'')
str++;
for (i = 0; i < 3; i++)
{
while(*str == ' ' || *str == '\t')
str++;
((float *)val)[i] = strtod(str, &str);
}
while(*str == ' ' || *str == '\t')
str++;
if (*str == '\'')
str++;
}
break;
*/
case ev_entity:
if (!EDICT_NUM(progfuncs, atoi (assignment)))
if (!EDICT_NUM(progfuncs, atoi (str)))
return "(invalid entity)";
*(int *)val = EDICT_TO_PROG(progfuncs, EDICT_NUM(progfuncs, atoi (assignment)));
*(int *)val = EDICT_TO_PROG(progfuncs, EDICT_NUM(progfuncs, atoi (str)));
break;
case ev_field:
fdef = ED_FindField (progfuncs, assignment);
fdef = ED_FindField (progfuncs, str);
if (!fdef)
{
size_t l,nl = strlen(assignment);
size_t l,nl = strlen(str);
*assignment = '=';
strcpy(buf, "Can't find field ");
l = strlen(buf);
if (nl > sizeof(buf)-l-2)
nl = sizeof(buf)-l-2;
memcpy(buf+l, assignment, nl);
assignment[l+nl+0] = '\n';
assignment[l+nl+1] = 0;
memcpy(buf+l, str, nl);
buf[l+nl+1] = 0;
return buf;
}
*(int *)val = G_INT(fdef->ofs);
@ -878,32 +840,30 @@ char *PDECL PR_EvaluateDebugString(pubprogfuncs_t *ppf, char *key)
mfunction_t *func;
int i;
int progsnum = -1;
char *s = assignment;
if (s[0] && s[1] == ':')
if (str[0] && str[1] == ':')
{
progsnum = atoi(s);
s+=2;
progsnum = atoi(str);
str+=2;
}
else if (s[0] && s[1] && s[2] == ':')
else if (str[0] && str[1] && str[2] == ':')
{
progsnum = atoi(s);
s+=3;
progsnum = atoi(str);
str+=3;
}
func = ED_FindFunction (progfuncs, s, &i, progsnum);
func = ED_FindFunction (progfuncs, str, &i, progsnum);
if (!func)
{
size_t l,nl = strlen(s);
size_t l,nl = strlen(str);
assignment[-1] = '=';
*assignment = '=';
strcpy(buf, "Can't find field ");
l = strlen(buf);
if (nl > sizeof(buf)-l-2)
nl = sizeof(buf)-l-2;
memcpy(buf+l, assignment, nl);
assignment[l+nl+0] = '\n';
assignment[l+nl+1] = 0;
memcpy(buf+l, str, nl);
buf[l+nl+1] = 0;
return buf;
}
*(func_t *)val = (func - pr_progstate[i].functions) | (i<<24);
@ -914,7 +874,7 @@ char *PDECL PR_EvaluateDebugString(pubprogfuncs_t *ppf, char *key)
break;
}
assignment[-1] = '=';
*assignment = '=';
}
QC_snprintfz(buf, sizeof(buf), "%s", PR_ValueString(progfuncs, type, val, true));
@ -1046,6 +1006,8 @@ int PDECL PR_ToggleBreakpoint(pubprogfuncs_t *ppf, char *filename, int linenum,
Sys_Error("Bad structtype");
op = 0;
}
if (ret) //if its set, only set one breakpoint statement, not all of them.
return true;
}
goto cont;
}
@ -1125,16 +1087,19 @@ cont:
return ret;
}
int ShowStep(progfuncs_t *progfuncs, int statement)
int ShowStep(progfuncs_t *progfuncs, int statement, char *fault)
{
// return statement;
// texture realcursortex;
static int lastline = 0;
static char *lastfile = 0;
static int ignorestatement = 0; //
static const char *lastfile = 0;
int pn = pr_typecurrent;
int i;
const mfunction_t *f = pr_xfunction;
int faultline;
int debugaction;
pr_xstatement = statement;
if (!externs->useeditor)
@ -1145,50 +1110,183 @@ static char *lastfile = 0;
if (f && externs->useeditor)
{
if (pr_progstate[pn].linenums)
for(;;) //for DEBUG_TRACE_NORESUME handling
{
if (lastline == pr_progstate[pn].linenums[statement] && lastfile == f->s_file+progfuncs->funcs.stringtable)
return statement; //no info/same line as last time
lastline = pr_progstate[pn].linenums[statement];
}
else
lastline = -1;
lastfile = f->s_file+progfuncs->funcs.stringtable;
lastline = externs->useeditor(&progfuncs->funcs, lastfile, lastline, statement, 0, NULL);
if (!pr_progstate[pn].linenums)
return statement;
if (lastline <= 0)
return -lastline;
if (pr_progstate[pn].linenums[statement] != lastline)
{
for (i = f->first_statement; ; i++)
if (pr_progstate[pn].linenums)
{
if (lastline == pr_progstate[pn].linenums[i])
if (lastline == pr_progstate[pn].linenums[statement] && lastfile == f->s_file+progfuncs->funcs.stringtable && statement == ignorestatement && !fault)
{
return i;
ignorestatement++;
return statement; //no info/same line as last time
}
else if (lastline <= pr_progstate[pn].linenums[i])
lastline = pr_progstate[pn].linenums[statement];
}
else
lastline = -1;
lastfile = PR_StringToNative(&progfuncs->funcs, f->s_file);
faultline = lastline;
debugaction = externs->useeditor(&progfuncs->funcs, lastfile, ((lastline>0)?&lastline:NULL), &statement, fault);
//if they changed the line to execute, we need to find a statement that is on that line
if (lastline && faultline != lastline)
{
switch(pr_progstate[pn].structtype)
{
return statement;
case PST_FTE32:
case PST_KKQWSV:
{
dstatement32_t *st = pr_progstate[pn].statements;
unsigned int *lnos = pr_progstate[pn].linenums;
for (i = f->first_statement; ; i++)
{
if (lastline == lnos[i])
{
statement = i;
break;
}
else if (lastline <= lnos[i])
break;
else if (st[i].op == OP_DONE)
break;
}
}
break;
case PST_DEFAULT:
case PST_QTEST:
{
dstatement16_t *st = pr_progstate[pn].statements;
unsigned int *lnos = pr_progstate[pn].linenums;
for (i = f->first_statement; ; i++)
{
if (lastline == lnos[i])
{
statement = i;
break;
}
else if (lastline <= lnos[i])
break;
else if (st[i].op == OP_DONE)
break;
}
}
}
}
if (debugaction == DEBUG_TRACE_NORESUME)
continue;
else if(debugaction == DEBUG_TRACE_ABORT)
progfuncs->funcs.parms->Abort ("Debugging terminated");
else if (debugaction == DEBUG_TRACE_OUT)
{
//clear tracing for now, but ensure that it'll be reactivated once we reach the caller (if from qc)
progfuncs->funcs.debug_trace = DEBUG_TRACE_OFF;
if (pr_depth)
pr_stack[pr_depth-1].stepping = DEBUG_TRACE_INTO;
}
else //some other debug action. maybe resume.
progfuncs->funcs.debug_trace = debugaction;
break;
}
}
else if (f) //annoying.
{
if (*(f->s_file+progfuncs->funcs.stringtable)) //if we can't get the filename, then it was stripped, and debugging it like this is useless
if (externs->useeditor)
externs->useeditor(&progfuncs->funcs, f->s_file+progfuncs->funcs.stringtable, -1, 0, 0, NULL);
externs->useeditor(&progfuncs->funcs, f->s_file+progfuncs->funcs.stringtable, NULL, NULL, fault);
return statement;
}
ignorestatement = statement+1;
return statement;
}
int ShowStepf(progfuncs_t *progfuncs, int statement, char *fault, ...)
{
va_list argptr;
char faultstring[1024];
va_start (argptr,fault);
Q_vsnprintf (faultstring,sizeof(faultstring)-1, fault,argptr);
va_end (argptr);
return ShowStep(progfuncs, statement, faultstring);
}
//called by the qcvm when executing some statement that cannot be execed.
int PR_HandleFault (pubprogfuncs_t *ppf, char *error, ...)
{
progfuncs_t *progfuncs = (progfuncs_t *)ppf;
va_list argptr;
char string[1024];
int resumestatement;
va_start (argptr,error);
Q_vsnprintf (string,sizeof(string)-1, error,argptr);
va_end (argptr);
PR_StackTrace (ppf, true);
ppf->parms->Printf ("%s\n", string);
resumestatement = ShowStep(progfuncs, pr_xstatement, string);
if (resumestatement == 0)
{
PR_AbortStack(ppf);
return prinst.continuestatement;
// ppf->parms->Abort ("%s", string);
}
return resumestatement;
}
/*
============
PR_RunError
Aborts the currently executing function
============
*/
void VARGS PR_RunError (pubprogfuncs_t *progfuncs, char *error, ...)
{
va_list argptr;
char string[1024];
va_start (argptr,error);
Q_vsnprintf (string,sizeof(string)-1, error,argptr);
va_end (argptr);
// PR_PrintStatement (pr_statements + pr_xstatement);
PR_StackTrace (progfuncs, true);
progfuncs->parms->Printf ("\n");
//editbadfile(pr_strings + pr_xfunction->s_file, -1);
progfuncs->parms->Abort ("%s", string);
}
pbool PR_RunWarning (pubprogfuncs_t *ppf, char *error, ...)
{
progfuncs_t *progfuncs = (progfuncs_t *)ppf;
va_list argptr;
char string[1024];
va_start (argptr,error);
Q_vsnprintf (string,sizeof(string)-1, error,argptr);
va_end (argptr);
progfuncs->funcs.parms->Printf ("%s", string);
if (pr_depth != 0)
PR_StackTrace (ppf, false);
if (progfuncs->funcs.debug_trace == 0)
{
progfuncs->funcs.debug_trace = DEBUG_TRACE_INTO;
return true;
}
return false;
}
static pbool casecmp_f(progfuncs_t *progfuncs, eval_t *ref, eval_t *val) {return ref->_float == val->_float;}
static pbool casecmp_i(progfuncs_t *progfuncs, eval_t *ref, eval_t *val) {return ref->_int == val->_int;}
static pbool casecmp_v(progfuncs_t *progfuncs, eval_t *ref, eval_t *val) {return ref->_vector[0] == val->_vector[0] &&
@ -1249,6 +1347,7 @@ static int PR_ExecuteCode16 (progfuncs_t *fte_restrict progfuncs, int s, int *ft
float *fte_restrict glob = pr_globals;
float tmpf;
int tmpi;
unsigned short op;
eval_t *switchref = (eval_t*)glob;
@ -1258,7 +1357,7 @@ static int PR_ExecuteCode16 (progfuncs_t *fte_restrict progfuncs, int s, int *ft
#define INTSIZE 16
st = &pr_statements16[s];
while (progfuncs->funcs.pr_trace || prinst.watch_ptr || prinst.profiling)
while (progfuncs->funcs.debug_trace || prinst.watch_ptr || prinst.profiling)
{
#ifdef FTE_TARGET_WEB
cont16:
@ -1308,13 +1407,15 @@ static int PR_ExecuteCode32 (progfuncs_t *fte_restrict progfuncs, int s, int *ft
int tmpi;
eval_t *switchref = (eval_t*)glob;
unsigned int op;
#define OPA ((eval_t *)&glob[st->a])
#define OPB ((eval_t *)&glob[st->b])
#define OPC ((eval_t *)&glob[st->c])
#define INTSIZE 32
st = &pr_statements32[s];
while (progfuncs->funcs.pr_trace || prinst.watch_ptr || prinst.profiling)
while (progfuncs->funcs.debug_trace || prinst.watch_ptr || prinst.profiling)
{
#define DEBUGABLE
#ifdef SEPARATEINCLUDES
@ -1458,22 +1559,16 @@ void PDECL PR_ExecuteProgram (pubprogfuncs_t *ppf, func_t fnum)
(*externs->globalbuiltins[i]) (&progfuncs->funcs, (struct globalvars_s *)current_progstate->globals);
else
{
i -= externs->numglobalbuiltins;
if (i > current_progstate->numbuiltins)
{
printf ("Bad builtin call number %i (from exe)\n", -f->first_statement);
// PR_MoveParms(p, pr_typecurrent);
PR_SwitchProgs(progfuncs, initial_progs);
return;
}
current_progstate->builtins [i] (&progfuncs->funcs, (struct globalvars_s *)current_progstate->globals);
printf ("Bad builtin call number %i (from exe)\n", -f->first_statement);
// PR_MoveParms(p, pr_typecurrent);
PR_SwitchProgs(progfuncs, initial_progs);
}
PR_SwitchProgsParms(progfuncs, initial_progs);
return;
}
if (progfuncs->funcs.pr_trace)
progfuncs->funcs.pr_trace--;
//forget about any tracing if its active. control returning to the engine should not look like its calling some random function.
progfuncs->funcs.debug_trace = 0;
// make a stack frame
prinst.exitdepth = pr_depth;
@ -1697,3 +1792,27 @@ void PDECL PR_AbortStack (pubprogfuncs_t *ppf)
prinst.continuestatement = 0;
}
pbool PDECL PR_GetBuiltinCallInfo (pubprogfuncs_t *ppf, int *builtinnum, char *function, size_t sizeoffunction)
{
progfuncs_t *progfuncs = (progfuncs_t*)ppf;
int st = pr_xstatement;
int op;
int a;
const char *fname;
op = pr_statements16[st].op;
a = pr_statements16[st].a;
*builtinnum = 0;
*function = 0;
if ((op >= OP_CALL0 && op <= OP_CALL8) || (op >= OP_CALL1H && op <= OP_CALL8H))
{
a = ((eval_t *)&pr_globals[a])->function;
*builtinnum = -current_progstate->functions[a].first_statement;
fname = PR_StringToNative(ppf, current_progstate->functions[a].s_name);
strncpy(function, fname, sizeoffunction-1);
function[sizeoffunction-1] = 0;
return true;
}
return false;
}

View file

@ -4,7 +4,6 @@
//#define MAPPING_DEBUG
//#define MAPPING_PARANOID //may actually break unions, so beware.
void PR_SetBuiltins(int type);
/*
progstate_t *pr_progstate;
progsnum_t pr_typecurrent;
@ -94,7 +93,7 @@ pbool PR_SwitchProgsParms(progfuncs_t *progfuncs, progsnum_t newpr) //from 2 to
return PR_SwitchProgs(progfuncs, newpr);
}
progsnum_t PDECL PR_LoadProgs(pubprogfuncs_t *ppf, const char *s, builtin_t *builtins, int numbuiltins)
progsnum_t PDECL PR_LoadProgs(pubprogfuncs_t *ppf, const char *s)
{
progfuncs_t *progfuncs = (progfuncs_t*)ppf;
unsigned int a;
@ -108,8 +107,6 @@ progsnum_t PDECL PR_LoadProgs(pubprogfuncs_t *ppf, const char *s, builtin_t *bui
current_progstate = &pr_progstate[a];
if (PR_ReallyLoadProgs(progfuncs, s, &pr_progstate[a], false)) //try and load it
{
current_progstate->builtins = builtins;
current_progstate->numbuiltins = numbuiltins;
if (a <= progfuncs->funcs.numprogs)
progfuncs->funcs.numprogs = a+1;

View file

@ -60,9 +60,10 @@ typedef struct sharedvar_s
} sharedvar_t;
typedef struct
{
int s;
mfunction_t *f;
int progsnum;
unsigned char stepping;
unsigned char progsnum;
int s;
int pushed;
unsigned long long timestamp;
} prstack_t;
@ -331,9 +332,6 @@ typedef struct progstate_s
char filename[128];
builtin_t *builtins;
int numbuiltins;
int *linenums; //debug versions only
progstructtype_t structtype;
@ -375,7 +373,7 @@ void PR_Init (void);
pbool PR_RunWarning (pubprogfuncs_t *progfuncs, char *error, ...);
void PDECL PR_ExecuteProgram (pubprogfuncs_t *progfuncs, func_t fnum);
int PDECL PR_LoadProgs(pubprogfuncs_t *progfncs, const char *s, builtin_t *builtins, int numbuiltins);
int PDECL PR_LoadProgs(pubprogfuncs_t *progfncs, const char *s);
int PR_ReallyLoadProgs (progfuncs_t *progfuncs, const char *filename, progstate_t *progstate, pbool complain);
void *PRHunkAlloc(progfuncs_t *progfuncs, int ammount, char *name);
@ -527,13 +525,13 @@ pbool PDECL ED_ParseEval (pubprogfuncs_t *progfuncs, eval_t *eval, int type, con
//pr_multi.c
void PR_SetBuiltins(int type);
extern vec3_t vec3_origin;
struct qcthread_s *PDECL PR_ForkStack (pubprogfuncs_t *progfuncs);
void PDECL PR_ResumeThread (pubprogfuncs_t *progfuncs, struct qcthread_s *thread);
void PDECL PR_AbortStack (pubprogfuncs_t *progfuncs);
pbool PDECL PR_GetBuiltinCallInfo (pubprogfuncs_t *ppf, int *builtinnum, char *function, size_t sizeoffunction);
eval_t *PDECL PR_FindGlobal(pubprogfuncs_t *prfuncs, const char *globname, progsnum_t pnum, etype_t *type);
ddef16_t *ED_FindTypeGlobalFromProgs16 (progfuncs_t *progfuncs, const char *name, progsnum_t prnum, int type);

View file

@ -53,6 +53,7 @@ typedef struct {
} evalc_t;
#define sizeofevalc sizeof(evalc_t)
typedef enum {ev_void, ev_string, ev_float, ev_vector, ev_entity, ev_field, ev_function, ev_pointer, ev_integer, ev_variant, ev_struct, ev_union, ev_accessor} etype_t;
enum {DEBUG_TRACE_OFF, DEBUG_TRACE_INTO, DEBUG_TRACE_OVER, DEBUG_TRACE_UNBREAK, DEBUG_TRACE_OUT, DEBUG_TRACE_ABORT, DEBUG_TRACE_NORESUME};
typedef struct fdef_s
{
@ -72,7 +73,7 @@ struct pubprogfuncs_s
void (PDECL *CloseProgs) (pubprogfuncs_t *inst);
void (PDECL *Configure) (pubprogfuncs_t *prinst, size_t addressablesize, int max_progs, pbool enableprofiling); //configure buffers and memory. Used to reset and must be called first. Flushes a running VM.
progsnum_t (PDECL *LoadProgs) (pubprogfuncs_t *prinst, const char *s, builtin_t *builtins, int numbuiltins); //load a progs
progsnum_t (PDECL *LoadProgs) (pubprogfuncs_t *prinst, const char *s); //load a progs
int (PDECL *InitEnts) (pubprogfuncs_t *prinst, int max_ents); //returns size of edicts for use with nextedict macro
void (PDECL *ExecuteProgram) (pubprogfuncs_t *prinst, func_t fnum); //start execution
struct globalvars_s *(PDECL *globals) (pubprogfuncs_t *prinst, progsnum_t num); //get the globals of a progs
@ -116,7 +117,7 @@ struct pubprogfuncs_s
char *(PDECL *EvaluateDebugString) (pubprogfuncs_t *prinst, char *key); //evaluate a string and return it's value (according to current progs) (expands edict vars)
int pr_trace; //start calling the editor for each line executed
int debug_trace; //start calling the editor for each line executed
void (PDECL *StackTrace) (pubprogfuncs_t *prinst, int showlocals);
@ -140,7 +141,7 @@ struct pubprogfuncs_s
void (PDECL *RunThread) (pubprogfuncs_t *prinst, struct qcthread_s *thread);
void (PDECL *AbortStack) (pubprogfuncs_t *prinst); //annigilates the current stack, positioning on a return statement. It is expected that this is only used via a builtin!
int lastcalledbuiltinnumber; //useful with non-implemented opcodes.
pbool (PDECL *GetBuiltinCallInfo) (pubprogfuncs_t *prinst, int *builtinnum, char *function, size_t sizeoffunction); //call to query the qc's name+index for the builtin
int (PDECL *RegisterFieldVar) (pubprogfuncs_t *prinst, unsigned int type, char *name, signed long requestedpos, signed long originalofs);
@ -195,14 +196,14 @@ typedef struct progexterns_s {
//used when loading a game
builtin_t *(PDECL *builtinsfor) (int num, int headercrc); //must return a pointer to the builtins that were used before the state was saved.
int (PDECL *MapNamedBuiltin) (pubprogfuncs_t *prinst, int headercrc, const char *builtinname); //return 0 for not found.
void (PDECL *loadcompleate) (int edictsize); //notification to reset any pointers.
pbool (PDECL *badfield) (pubprogfuncs_t *prinst, struct edict_s *ent, const char *keyname, const char *value); //called for any fields that are not registered
void *(VARGS *memalloc) (int size); //small string allocation malloced and freed randomly by the executor. (use malloc if you want)
void (VARGS *memfree) (void * mem);
int (PDECL *useeditor) (pubprogfuncs_t *prinst, char *filename, int line, int statement, int nump, char **parms); //called on syntax errors or step-by-step debugging.
int (PDECL *useeditor) (pubprogfuncs_t *prinst, const char *filename, int *line, int *statement, char *reason); //called on syntax errors or step-by-step debugging. line and statement(if line was set to 0) can be used to change the next line. return value is the new debug state to use/step.
void (PDECL *addressablerelocated) (pubprogfuncs_t *progfuncs, char *oldb, char *newb, int oldlen); //called when the progs memory was resized. you must fix up all pointers to globals, strings, fields, addressable blocks.
builtin_t *globalbuiltins; //these are available to all progs
@ -243,7 +244,7 @@ typedef union eval_s
#ifndef DLL_PROG
#define PR_Configure(pf, memsize, max_progs, profiling) (*pf->Configure) (pf, memsize, max_progs, profiling)
#define PR_LoadProgs(pf, s, builtins, numb) (*pf->LoadProgs) (pf, s, builtins, numb)
#define PR_LoadProgs(pf, s) (*pf->LoadProgs) (pf, s)
#define PR_InitEnts(pf, maxents) (*pf->InitEnts) (pf, maxents)
#define PR_ExecuteProgram(pf, fnum) (*pf->ExecuteProgram) (pf, fnum)
#define PR_globals(pf, num) (*pf->globals) (pf, num)

View file

@ -544,6 +544,7 @@ extern pbool flag_debugmacros;
extern pbool flag_filetimes;
extern pbool flag_typeexplicit;
extern pbool flag_noboundchecks;
extern pbool flag_guiannotate;
extern pbool opt_overlaptemps;
extern pbool opt_shortenifnots;
@ -683,6 +684,7 @@ enum {
WARN_EXTENSION_USED, //extension that frikqcc also understands
WARN_IFSTRING_USED,
WARN_LAXCAST, //some errors become this with a compiler flag
WARN_TYPEMISMATCHREDECOPTIONAL,
WARN_UNDESIRABLECONVENTION,
WARN_SAMENAMEASGLOBAL,
WARN_CONSTANTCOMPARISON,

View file

@ -123,6 +123,40 @@ void SetEndian(void)
}
void QC_strlcat(char *dest, const char *src, size_t destsize)
{
size_t curlen = strlen(dest);
if (!destsize)
return; //err
dest += curlen;
while(*src && ++curlen < destsize)
*dest++ = *src++;
if (*src)
printf("QC_strlcpy: truncation\n");
*dest = 0;
}
void QC_strlcpy(char *dest, const char *src, size_t destsize)
{
size_t curlen = strlen(dest);
if (!destsize)
return; //err
while(*src && ++curlen < destsize)
*dest++ = *src++;
if (*src)
printf("QC_strlcpy: truncation\n");
*dest = 0;
}
void QC_strnlcpy(char *dest, const char *src, size_t srclen, size_t destsize)
{
size_t curlen = strlen(dest);
if (!destsize)
return; //err
for(; *src && srclen > 0 && ++curlen < destsize; srclen--)
*dest++ = *src++;
if (srclen)
printf("QC_strlcpy: truncation\n");
*dest = 0;
}
#if !defined(MINIMAL) && !defined(OMIT_QCC)
/*

View file

@ -85,6 +85,7 @@ pbool flag_assume_integer; //5 - is that an integer or a float? qcc says float.
pbool flag_filetimes;
pbool flag_typeexplicit; //no implicit type conversions, you must do the casts yourself.
pbool flag_noboundchecks; //Disable generation of bound check instructions.
pbool flag_guiannotate;
pbool opt_overlaptemps; //reduce numpr_globals by reuse of temps. When they are not needed they are freed for reuse. The way this is implemented is better than frikqcc's. (This is the single most important optimisation)
pbool opt_assignments; //STORE_F isn't used if an operation wrote to a temp.
@ -293,7 +294,7 @@ QCC_opcode_t pr_opcodes[] =
{6, "=", "STOREP_FLD", 6, ASSOC_RIGHT, &type_pointer, &type_field, &type_field},
{6, "=", "STOREP_FNC", 6, ASSOC_RIGHT, &type_pointer, &type_function, &type_function},
{6, "<RETURN>", "RETURN", -1, ASSOC_LEFT, &type_float, &type_void, &type_void},
{6, "<RETURN>", "RETURN", -1, ASSOC_LEFT, &type_vector, &type_void, &type_void},
{6, "!", "NOT_F", -1, ASSOC_LEFT, &type_float, &type_void, &type_float},
{6, "!", "NOT_V", -1, ASSOC_LEFT, &type_vector, &type_void, &type_float},
@ -430,7 +431,7 @@ QCC_opcode_t pr_opcodes[] =
{7, "/", "DIV_VF", 3, ASSOC_LEFT, &type_vector, &type_float, &type_float},
{7, "^", "XOR_I", 3, ASSOC_LEFT, &type_integer, &type_integer, &type_integer},
{7, "^", "BITXOR_I", 3, ASSOC_LEFT, &type_integer, &type_integer, &type_integer},
{7, ">>", "RSHIFT_I", 3, ASSOC_LEFT, &type_integer, &type_integer, &type_integer},
{7, "<<", "LSHIFT_I", 3, ASSOC_LEFT, &type_integer, &type_integer, &type_integer},
@ -585,8 +586,8 @@ QCC_opcode_t pr_opcodes[] =
{7, "=", "LOADA_STRUCT", 6, ASSOC_LEFT, &type_float, &type_integer, &type_float},
{7, "=", "STOREP_P", 6, ASSOC_RIGHT, &type_pointer, &type_pointer, &type_pointer},
{7, "~", "BINARYNOT_F", -1, ASSOC_LEFT, &type_float, &type_void, &type_float},
{7, "~", "BINARYNOT_I", -1, ASSOC_LEFT, &type_integer, &type_void, &type_integer},
{7, "~", "BITNOT_F", -1, ASSOC_LEFT, &type_float, &type_void, &type_float},
{7, "~", "BITNOT_I", -1, ASSOC_LEFT, &type_integer, &type_void, &type_integer},
{7, "==", "EQ_P", 5, ASSOC_LEFT, &type_pointer, &type_pointer, &type_float},
{7, "!=", "NE_P", 5, ASSOC_LEFT, &type_pointer, &type_pointer, &type_float},
@ -611,6 +612,10 @@ QCC_opcode_t pr_opcodes[] =
{7, "%", "MOD_I", 6, ASSOC_LEFT, &type_integer, &type_integer, &type_integer},
{7, "%", "MOD_V", 6, ASSOC_LEFT, &type_vector, &type_vector, &type_vector},
{7, "^", "BITXOR_F", 3, ASSOC_LEFT, &type_float, &type_float, &type_float},
{7, ">>", "RSHIFT_F", 3, ASSOC_LEFT, &type_float, &type_float, &type_float},
{7, "<<", "LSHIFT_F", 3, ASSOC_LEFT, &type_float, &type_float, &type_float},
{0, NULL}
};
@ -758,7 +763,8 @@ QCC_opcode_t *opcodes_orstore[] =
};
QCC_opcode_t *opcodes_xorstore[] =
{
&pr_opcodes[OP_XOR_I],
&pr_opcodes[OP_BITXOR_I],
&pr_opcodes[OP_BITXOR_F],
NULL
};
QCC_opcode_t *opcodes_andstore[] =
@ -858,9 +864,13 @@ QCC_opcode_t *opcodeprioritized[TOP_PRIORITY+1][128] =
&pr_opcodes[OP_BITOR_IF],
&pr_opcodes[OP_BITOR_FI],
&pr_opcodes[OP_XOR_I],
&pr_opcodes[OP_BITXOR_I],
&pr_opcodes[OP_RSHIFT_I],
&pr_opcodes[OP_LSHIFT_I],
&pr_opcodes[OP_BITXOR_F],
&pr_opcodes[OP_RSHIFT_F],
&pr_opcodes[OP_LSHIFT_F],
&pr_opcodes[OP_MOD_F],
&pr_opcodes[OP_MOD_I],
@ -1255,7 +1265,7 @@ pbool QCC_OPCodeValid(QCC_opcode_t *op)
case OP_LOADP_V:
return true;
case OP_XOR_I:
case OP_BITXOR_I:
case OP_RSHIFT_I:
case OP_LSHIFT_I:
return true;
@ -1615,7 +1625,7 @@ static void QCC_RemapLockedTemp(temp_t *t, int firststatement, int laststatement
def = QCC_PR_DummyDef(type_float, NULL, pr_scope, t->size==1?0:t->size, newofs, false, 0);
#ifdef WRITEASM
sprintf(buffer, "locked_%i", t->ofs);
sprintf(buffer, "locked_%i", t->ofs-FIRST_TEMP);
def->name = qccHunkAlloc(strlen(buffer)+1);
strcpy(def->name, buffer);
#endif
@ -1633,7 +1643,7 @@ static void QCC_RemapLockedTemp(temp_t *t, int firststatement, int laststatement
def = QCC_PR_DummyDef(type_float, NULL, pr_scope, t->size==1?0:t->size, newofs, false, 0);
#ifdef WRITEASM
sprintf(buffer, "locked_%i", t->ofs);
sprintf(buffer, "locked_%i", t->ofs-FIRST_TEMP);
def->name = qccHunkAlloc(strlen(buffer)+1);
strcpy(def->name, buffer);
#endif
@ -1703,9 +1713,9 @@ static const char *QCC_VarAtOffset(unsigned int ofs, unsigned int size)
if (ofs >= t->ofs && ofs < t->ofs + t->size)
{
if (size < t->size)
sprintf(message, "temp_%i_%c", t->ofs, 'x' + (ofs-t->ofs)%3);
QC_snprintfz(message, sizeof(message), "temp_%i_%c", t->ofs - FIRST_TEMP, 'x' + (ofs-t->ofs)%3);
else
sprintf(message, "temp_%i", t->ofs);
QC_snprintfz(message, sizeof(message), "temp_%i", t->ofs - FIRST_TEMP);
return message;
}
}
@ -1723,12 +1733,12 @@ static const char *QCC_VarAtOffset(unsigned int ofs, unsigned int size)
if (size < var->type->size)
{
if (var->type->type == ev_vector)
sprintf(message, "%s_%c", var->name, 'x' + (ofs-var->ofs)%3);
QC_snprintfz(message, sizeof(message), "%s_%c", var->name, 'x' + (ofs-var->ofs)%3);
else
sprintf(message, "%s+%i", var->name, ofs-var->ofs);
QC_snprintfz(message, sizeof(message), "%s+%i", var->name, ofs-var->ofs);
}
else
sprintf(message, "%s", var->name);
QC_snprintfz(message, sizeof(message), "%s", var->name);
return message;
}
}
@ -1747,23 +1757,60 @@ static const char *QCC_VarAtOffset(unsigned int ofs, unsigned int size)
switch(var->type->type)
{
case ev_string:
sprintf(message, "\"%.1020s\"", &strings[((int *)qcc_pr_globals)[var->ofs]]);
dumpstring:
{
char *in = &strings[((int *)qcc_pr_globals)[var->ofs]], *out=message;
char *end = out+sizeof(message)-3;
*out++ = '\"';
for(; out < end && *in; in++)
{
if (*in == '\n')
{
*out++ = '\\';
*out++ = 'n';
}
else if (*in == '\t')
{
*out++ = '\\';
*out++ = 't';
}
else if (*in == '\r')
{
*out++ = '\\';
*out++ = 'r';
}
else if (*in == '\"')
{
*out++ = '\\';
*out++ = '"';
}
else if (*in == '\'')
{
*out++ = '\\';
*out++ = '\'';
}
else
*out++ = *in;
}
*out++ = '\"';
*out++ = 0;
}
return message;
case ev_integer:
sprintf(message, "%ii", ((int *)qcc_pr_globals)[var->ofs]);
QC_snprintfz(message, sizeof(message), "%ii", ((int *)qcc_pr_globals)[var->ofs]);
return message;
case ev_float:
sprintf(message, "%gf", qcc_pr_globals[var->ofs]);
QC_snprintfz(message, sizeof(message), "%gf", qcc_pr_globals[var->ofs]);
return message;
case ev_vector:
sprintf(message, "'%g %g %g'", qcc_pr_globals[var->ofs], qcc_pr_globals[var->ofs+1], qcc_pr_globals[var->ofs+2]);
QC_snprintfz(message, sizeof(message), "'%g %g %g'", qcc_pr_globals[var->ofs], qcc_pr_globals[var->ofs+1], qcc_pr_globals[var->ofs+2]);
return message;
default:
sprintf(message, "IMMEDIATE");
QC_snprintfz(message, sizeof(message), "IMMEDIATE");
return message;
}
}
sprintf(message, "%s", var->name);
QC_snprintfz(message, sizeof(message), "%s", var->name);
return message;
}
}
@ -1783,31 +1830,30 @@ static const char *QCC_VarAtOffset(unsigned int ofs, unsigned int size)
switch(var->type->type)
{
case ev_string:
sprintf(message, "\"%.1020s\"", &strings[((int *)qcc_pr_globals)[var->ofs]]);
return message;
goto dumpstring;
case ev_integer:
sprintf(message, "%ii", ((int *)qcc_pr_globals)[var->ofs]);
QC_snprintfz(message, sizeof(message), "%ii", ((int *)qcc_pr_globals)[var->ofs]);
return message;
case ev_float:
sprintf(message, "%gf", qcc_pr_globals[var->ofs]);
QC_snprintfz(message, sizeof(message), "%gf", qcc_pr_globals[var->ofs]);
return message;
case ev_vector:
sprintf(message, "'%g %g %g'", qcc_pr_globals[var->ofs], qcc_pr_globals[var->ofs+1], qcc_pr_globals[var->ofs+2]);
QC_snprintfz(message, sizeof(message), "'%g %g %g'", qcc_pr_globals[var->ofs], qcc_pr_globals[var->ofs+1], qcc_pr_globals[var->ofs+2]);
return message;
default:
sprintf(message, "IMMEDIATE");
QC_snprintfz(message, sizeof(message), "IMMEDIATE");
return message;
}
}
if (size < var->type->size)
{
if (var->type->type == ev_vector)
sprintf(message, "%s_%c", var->name, 'x' + (ofs-var->ofs)%3);
QC_snprintfz(message, sizeof(message), "%s_%c", var->name, 'x' + (ofs-var->ofs)%3);
else
sprintf(message, "%s+%i", var->name, ofs-var->ofs);
QC_snprintfz(message, sizeof(message), "%s+%i", var->name, ofs-var->ofs);
}
else
sprintf(message, "%s", var->name);
QC_snprintfz(message, sizeof(message), "%s", var->name);
return message;
}
}
@ -1816,20 +1862,20 @@ static const char *QCC_VarAtOffset(unsigned int ofs, unsigned int size)
if (size >= 3)
{
if (ofs >= OFS_RETURN && ofs < OFS_PARM0)
sprintf(message, "return");
QC_snprintfz(message, sizeof(message), "return");
else if (ofs >= OFS_PARM0 && ofs < RESERVED_OFS)
sprintf(message, "parm%i", (ofs-OFS_PARM0)/3);
QC_snprintfz(message, sizeof(message), "parm%i", (ofs-OFS_PARM0)/3);
else
sprintf(message, "offset_%i", ofs);
QC_snprintfz(message, sizeof(message), "offset_%i", ofs);
}
else
{
if (ofs >= OFS_RETURN && ofs < OFS_PARM0)
sprintf(message, "return_%c", 'x' + ofs-OFS_RETURN);
QC_snprintfz(message, sizeof(message), "return_%c", 'x' + ofs-OFS_RETURN);
else if (ofs >= OFS_PARM0 && ofs < RESERVED_OFS)
sprintf(message, "parm%i_%c", (ofs-OFS_PARM0)/3, 'x' + (ofs-OFS_PARM0)%3);
QC_snprintfz(message, sizeof(message), "parm%i_%c", (ofs-OFS_PARM0)/3, 'x' + (ofs-OFS_PARM0)%3);
else
sprintf(message, "offset_%i", ofs);
QC_snprintfz(message, sizeof(message), "offset_%i", ofs);
}
return message;
}
@ -1894,6 +1940,15 @@ pbool QCC_Temp_Describe(QCC_def_t *def, char *buffer, int buffersize)
return true;
}
static int QCC_PR_RoundFloatConst(int ofs)
{
float val = G_FLOAT(ofs);
int ival = val;
if (val != (float)ival)
QCC_PR_ParseWarning(WARN_CONSTANTCOMPARISON, "Constant float operand not an integer value");
return ival;
}
QCC_statement_t *QCC_PR_SimpleStatement( int op, int var_a, int var_b, int var_c, int force);
QCC_def_t *QCC_PR_StatementFlags (QCC_opcode_t *op, QCC_def_t *var_a, QCC_def_t *var_b, QCC_statement_t **outstatement, unsigned int flags)
@ -1960,7 +2015,7 @@ QCC_def_t *QCC_PR_StatementFlags (QCC_opcode_t *op, QCC_def_t *var_a, QCC_def_t
return nd;
}
break;
case OP_XOR_I:
case OP_BITXOR_I:
optres_constantarithmatic++;
return QCC_MakeIntConst(G_INT(var_a->ofs) ^ G_INT(var_b->ofs));
case OP_RSHIFT_I:
@ -1969,12 +2024,21 @@ QCC_def_t *QCC_PR_StatementFlags (QCC_opcode_t *op, QCC_def_t *var_a, QCC_def_t
case OP_LSHIFT_I:
optres_constantarithmatic++;
return QCC_MakeIntConst(G_INT(var_a->ofs) << G_INT(var_b->ofs));
case OP_BITXOR_F:
optres_constantarithmatic++;
return QCC_MakeFloatConst(QCC_PR_RoundFloatConst(var_a->ofs) ^ QCC_PR_RoundFloatConst(var_b->ofs));
case OP_RSHIFT_F:
optres_constantarithmatic++;
return QCC_MakeFloatConst(QCC_PR_RoundFloatConst(var_a->ofs) >> QCC_PR_RoundFloatConst(var_b->ofs));
case OP_LSHIFT_F:
optres_constantarithmatic++;
return QCC_MakeFloatConst(QCC_PR_RoundFloatConst(var_a->ofs) << QCC_PR_RoundFloatConst(var_b->ofs));
case OP_BITOR_F:
optres_constantarithmatic++;
return QCC_MakeFloatConst((float)((int)G_FLOAT(var_a->ofs) | (int)G_FLOAT(var_b->ofs)));
return QCC_MakeFloatConst(QCC_PR_RoundFloatConst(var_a->ofs) | QCC_PR_RoundFloatConst(var_b->ofs));
case OP_BITAND_F:
optres_constantarithmatic++;
return QCC_MakeFloatConst((float)((int)G_FLOAT(var_a->ofs) & (int)G_FLOAT(var_b->ofs)));
return QCC_MakeFloatConst(QCC_PR_RoundFloatConst(var_a->ofs) & QCC_PR_RoundFloatConst(var_b->ofs));
case OP_MUL_F:
optres_constantarithmatic++;
return QCC_MakeFloatConst(G_FLOAT(var_a->ofs) * G_FLOAT(var_b->ofs));
@ -2047,12 +2111,18 @@ QCC_def_t *QCC_PR_StatementFlags (QCC_opcode_t *op, QCC_def_t *var_a, QCC_def_t
optres_constantarithmatic++;
return QCC_MakeFloatConst(G_FLOAT(var_a->ofs) - G_INT(var_b->ofs));
case OP_AND_F:
case OP_AND_I:
optres_constantarithmatic++;
return QCC_MakeIntConst(G_INT(var_a->ofs) && G_INT(var_b->ofs));
case OP_OR_F:
case OP_OR_I:
optres_constantarithmatic++;
return QCC_MakeIntConst(G_INT(var_a->ofs) || G_INT(var_b->ofs));
case OP_AND_F:
optres_constantarithmatic++;
return QCC_MakeIntConst(G_FLOAT(var_a->ofs) && G_FLOAT(var_b->ofs));
case OP_OR_F:
optres_constantarithmatic++;
return QCC_MakeIntConst(G_FLOAT(var_a->ofs) || G_FLOAT(var_b->ofs));
case OP_MUL_V: //mul_f is actually a dot-product
optres_constantarithmatic++;
return QCC_MakeFloatConst( G_FLOAT(var_a->ofs) * G_FLOAT(var_b->ofs+0) +
@ -2099,6 +2169,10 @@ QCC_def_t *QCC_PR_StatementFlags (QCC_opcode_t *op, QCC_def_t *var_a, QCC_def_t
case OP_NOT_I:
optres_constantarithmatic++;
return QCC_MakeIntConst(!G_INT(var_a->ofs));
case OP_BITNOT_F:
return QCC_MakeFloatConst(~QCC_PR_RoundFloatConst(var_a->ofs));
case OP_BITNOT_I:
return QCC_MakeIntConst(~G_INT(var_a->ofs));
case OP_CONV_FTOI:
optres_constantarithmatic++;
return QCC_MakeIntConst(G_FLOAT(var_a->ofs));
@ -2125,7 +2199,7 @@ QCC_def_t *QCC_PR_StatementFlags (QCC_opcode_t *op, QCC_def_t *var_a, QCC_def_t
break;
case OP_BITAND_F:
case OP_AND_F:
if (G_FLOAT(var_a->ofs) != 0)
if (QCC_PR_RoundFloatConst(var_a->ofs) != 0)
{
optres_constantarithmatic++;
QCC_UnFreeTemp(var_b);
@ -2727,6 +2801,15 @@ QCC_def_t *QCC_PR_StatementFlags (QCC_opcode_t *op, QCC_def_t *var_a, QCC_def_t
op = pr_opcodes+OP_STORE_F;
break;
case OP_BITXOR_F:
numstatements--;
// a = (a & ~b) | (b & ~a);
var_c = QCC_PR_StatementFlags(&pr_opcodes[OP_BITNOT_F], var_b, NULL, NULL, STFL_PRESERVEA);
var_c = QCC_PR_StatementFlags(&pr_opcodes[OP_BITAND_F], var_a, var_c, NULL, STFL_PRESERVEA);
var_a = QCC_PR_StatementFlags(&pr_opcodes[OP_BITNOT_F], var_a, NULL, NULL, 0);
var_a = QCC_PR_StatementFlags(&pr_opcodes[OP_BITAND_F], var_b, var_a, NULL, 0);
return QCC_PR_StatementFlags(&pr_opcodes[OP_BITOR_F], var_c, var_a, NULL, STFL_PRESERVEA);
case OP_IF_S:
var_c = QCC_PR_GetDef(type_string, "string_null", NULL, true, 0, false);
numstatements--;
@ -2823,12 +2906,12 @@ QCC_def_t *QCC_PR_StatementFlags (QCC_opcode_t *op, QCC_def_t *var_a, QCC_def_t
var_a = var_c;
break;
case OP_BINARYNOT_I:
case OP_BITNOT_I:
op = &pr_opcodes[OP_SUB_I];
var_b = var_a;
var_a = QCC_MakeIntConst(~0);
break;
case OP_BINARYNOT_F:
case OP_BITNOT_F:
op = &pr_opcodes[OP_SUB_F];
var_b = var_a;
var_a = QCC_MakeFloatConst(-1); //divVerent says -1 is safe, even with floats. I guess I'm just too paranoid.
@ -5538,18 +5621,21 @@ void QCC_PR_EmitClassFromFunction(QCC_def_t *scope, QCC_type_t *basetype)
if (numfunctions >= MAX_FUNCTIONS)
QCC_Error(ERR_INTERNAL, "Too many function defs");
if (!strcmp(basetype->name, "mitem_desktop"))
pr_scope = NULL;
pr_scope = NULL;
memset(basictypefield, 0, sizeof(basictypefield));
// QCC_PR_EmitFieldsForMembers(basetype, basictypefield);
pr_source_line = 0;
pr_source_line = pr_token_line_last = scope->s_line;
pr_scope = scope;
df = &functions[numfunctions];
numfunctions++;
df->s_file = 0;
df->s_file = scope->s_file;
df->s_name = QCC_CopyString(scope->name);
df->first_statement = numstatements;
df->parm_size[0] = 1;
@ -6412,9 +6498,9 @@ QCC_ref_t *QCC_PR_RefTerm (QCC_ref_t *retbuf, unsigned int exprflags)
e = QCC_PR_Expression (NOT_PRIORITY, EXPR_DISALLOW_COMMA|EXPR_WARN_ABOVE_1);
t = e->type->type;
if (t == ev_float)
e2 = QCC_PR_Statement (&pr_opcodes[OP_BINARYNOT_F], e, 0, NULL);
e2 = QCC_PR_Statement (&pr_opcodes[OP_BITNOT_F], e, 0, NULL);
else if (t == ev_integer)
e2 = QCC_PR_Statement (&pr_opcodes[OP_BINARYNOT_I], e, 0, NULL); //functions are integer values too.
e2 = QCC_PR_Statement (&pr_opcodes[OP_BITNOT_I], e, 0, NULL); //functions are integer values too.
else
{
e2 = NULL; // shut up compiler warning;
@ -6988,6 +7074,27 @@ QCC_def_t *QCC_LoadFromArray(QCC_def_t *base, QCC_def_t *index, QCC_type_t *t, p
base->references++;
if (base->type->type == ev_field && base->constant && !base->initialized && flag_noboundchecks && flag_fasttrackarrays)
{
int i;
//denormalised floats means we could do:
//return (add_f: base + (mul_f: index*1i))
//make sure the array has no gaps
//the initialised thing is to ensure that it doesn't contain random consecutive system fields that might get remapped weirdly by an engine.
for (i = 1; i < base->arraysize; i++)
{
if (G_INT(base->ofs+i) != G_INT(base->ofs+i-1)+1)
break;
}
//its contiguous. we'll do this in two instructions.
if (i == base->arraysize)
{
//denormalised floats means we could do:
//return (add_f: base + (mul_f: index*1i))
return QCC_PR_StatementFlags(&pr_opcodes[OP_ADD_F], base, QCC_PR_StatementFlags(&pr_opcodes[OP_MUL_F], index, QCC_MakeIntConst(1), NULL, 0), NULL, 0);
}
}
funcretr = QCC_PR_GetDef(NULL, qcva("ArrayGet*%s", base->name), base->scope, false, 0, GDF_CONST|(base->scope?GDF_STATIC:0));
if (!funcretr)
{
@ -9828,6 +9935,77 @@ void QCC_Marshal_Locals(int firststatement, int laststatement)
}
#ifdef WRITEASM
void QCC_WriteGUIAsmFunction(QCC_def_t *sc, unsigned int firststatement)
{
unsigned int i;
// QCC_type_t *type;
char typebuf[512];
char line[2048];
extern int currentsourcefile;
// type = sc->type;
for (i = firststatement; i < (unsigned int)numstatements; i++)
{
line[0] = 0;
QC_strlcat(line, pr_opcodes[statements[i].op].opname, sizeof(line));
if (pr_opcodes[statements[i].op].type_a != &type_void)
{
// if (strlen(pr_opcodes[statements[i].op].opname)<6)
// QC_strlcat(line, " ", sizeof(line));
if (pr_opcodes[statements[i].op].type_a)
QC_snprintfz(typebuf, sizeof(typebuf), " %s/*%i*/", QCC_VarAtOffset(statements[i].a, (*pr_opcodes[statements[i].op].type_a)->size), statements[i].a);
else
QC_snprintfz(typebuf, sizeof(typebuf), " %i", statements[i].a);
QC_strlcat(line, typebuf, sizeof(line));
if (pr_opcodes[statements[i].op].type_b != &type_void)
{
if (pr_opcodes[statements[i].op].type_b)
QC_snprintfz(typebuf, sizeof(typebuf), ", %s/*%i*/", QCC_VarAtOffset(statements[i].b, (*pr_opcodes[statements[i].op].type_b)->size), statements[i].b);
else
QC_snprintfz(typebuf, sizeof(typebuf), ", %i", statements[i].b);
QC_strlcat(line, typebuf, sizeof(line));
if (pr_opcodes[statements[i].op].type_c != &type_void && (pr_opcodes[statements[i].op].associative==ASSOC_LEFT || statements[i].c))
{
if (pr_opcodes[statements[i].op].type_c)
QC_snprintfz(typebuf, sizeof(typebuf), ", %s/*%i*/", QCC_VarAtOffset(statements[i].c, (*pr_opcodes[statements[i].op].type_c)->size), statements[i].c);
else
QC_snprintfz(typebuf, sizeof(typebuf), ", %i", statements[i].c);
QC_strlcat(line, typebuf, sizeof(line));
}
}
else
{
if (pr_opcodes[statements[i].op].type_c != &type_void)
{
if (pr_opcodes[statements[i].op].type_c)
QC_snprintfz(typebuf, sizeof(typebuf), ", %s/*%i*/", QCC_VarAtOffset(statements[i].c, (*pr_opcodes[statements[i].op].type_c)->size), statements[i].c);
else
QC_snprintfz(typebuf, sizeof(typebuf), ", %i", statements[i].c);
QC_strlcat(line, typebuf, sizeof(line));
}
}
}
else
{
if (pr_opcodes[statements[i].op].type_c != &type_void)
{
if (pr_opcodes[statements[i].op].type_c)
QC_snprintfz(typebuf, sizeof(typebuf), " %s/*%i*/", QCC_VarAtOffset(statements[i].c, (*pr_opcodes[statements[i].op].type_c)->size), statements[i].c);
else
QC_snprintfz(typebuf, sizeof(typebuf), " %i", statements[i].c);
QC_strlcat(line, typebuf, sizeof(line));
}
}
if (currentsourcefile)
printf("code: %s:%i: %i:%s;\n", strings+sc->s_file, statements[i].linenum, currentsourcefile, line);
else
printf("code: %s:%i: %s;\n", strings+sc->s_file, statements[i].linenum, line);
}
}
void QCC_WriteAsmFunction(QCC_def_t *sc, unsigned int firststatement, gofs_t firstparm)
{
unsigned int i;
@ -9836,6 +10014,9 @@ void QCC_WriteAsmFunction(QCC_def_t *sc, unsigned int firststatement, gofs_t fir
QCC_def_t *param;
char typebuf[512];
if (flag_guiannotate)
QCC_WriteGUIAsmFunction(sc, firststatement);
if (!asmfile)
return;
@ -9966,6 +10147,8 @@ QCC_function_t *QCC_PR_ParseImmediateStatements (QCC_type_t *type)
binum = pr_immediate._int;
else
QCC_PR_ParseError (ERR_BADBUILTINIMMEDIATE, "Bad builtin immediate");
if (!binum)
printf("omg!\n");
f->builtin = binum;
QCC_PR_Lex ();
@ -10317,6 +10500,7 @@ QCC_def_t *QCC_PR_EmitArrayGetVector(QCC_def_t *array)
s_file = array->s_file;
func = QCC_PR_GetDef(ftype, qcva("ArrayGetVec*%s", array->name), NULL, true, 0, false);
pr_source_line = pr_token_line_last = array->s_line; //thankfully these functions are emitted after compilation.
pr_scope = func;
if (numfunctions >= MAX_FUNCTIONS)
@ -10339,7 +10523,7 @@ QCC_def_t *QCC_PR_EmitArrayGetVector(QCC_def_t *array)
QCC_PR_ArrayRecurseDivideUsingVectors(array, temp, 0, numslots);
QCC_PR_Statement(pr_opcodes+OP_RETURN, QCC_MakeFloatConst(0), 0, NULL); //err... we didn't find it, give up.
QCC_PR_Statement(pr_opcodes+OP_RETURN, QCC_MakeVectorConst(0,0,0), 0, NULL); //err... we didn't find it, give up.
QCC_PR_Statement(pr_opcodes+OP_DONE, 0, 0, NULL); //err... we didn't find it, give up.
G_FUNCTION(func->ofs) = df - functions;
@ -10361,6 +10545,7 @@ void QCC_PR_EmitArrayGetFunction(QCC_def_t *scope, QCC_def_t *thearray, char *ar
QCC_statement_t *st;
QCC_def_t *eq;
QCC_statement_t *bc1=NULL, *bc2=NULL;
QCC_def_t *fasttrackpossible;
int numslots;
@ -10390,7 +10575,7 @@ void QCC_PR_EmitArrayGetFunction(QCC_def_t *scope, QCC_def_t *thearray, char *ar
df = &functions[numfunctions];
numfunctions++;
pr_source_line = thearray->s_line; //thankfully these functions are emitted after compilation.
pr_source_line = pr_token_line_last = thearray->s_line; //thankfully these functions are emitted after compilation.
df->s_file = thearray->s_file;
df->s_name = QCC_CopyString(scope->name);
df->first_statement = numstatements;
@ -10418,6 +10603,9 @@ void QCC_PR_EmitArrayGetFunction(QCC_def_t *scope, QCC_def_t *thearray, char *ar
st->b = &statements[numstatements] - st;
}
if (!flag_noboundchecks)
QCC_FreeTemp(QCC_PR_Statement(pr_opcodes+OP_IF_I, QCC_PR_Statement(pr_opcodes+OP_LT_F, index, QCC_MakeFloatConst(0), NULL), 0, &bc1));
if (vectortrick)
{
QCC_def_t *div3, *intdiv3, *ret;
@ -10426,6 +10614,9 @@ void QCC_PR_EmitArrayGetFunction(QCC_def_t *scope, QCC_def_t *thearray, char *ar
//we need to work out which part, x/y/z that it's stored in.
//0,1,2 = i - ((int)i/3 *) 3;
if (!flag_noboundchecks)
QCC_FreeTemp(QCC_PR_Statement(pr_opcodes+OP_IF_I, QCC_PR_Statement(pr_opcodes+OP_GE_F, index, QCC_MakeFloatConst(numslots), NULL), 0, &bc2));
div3 = QCC_PR_GetDef(type_float, "div3___", thearray, true, 0, false);
intdiv3 = QCC_PR_GetDef(type_float, "intdiv3___", thearray, true, 0, false);
@ -10478,8 +10669,19 @@ void QCC_PR_EmitArrayGetFunction(QCC_def_t *scope, QCC_def_t *thearray, char *ar
QCC_PR_ArrayRecurseDivideRegular(thearray, index, 0, numslots);
}
QCC_PR_Statement(pr_opcodes+OP_RETURN, QCC_MakeFloatConst(0), 0, NULL);
if (bc1)
bc1->b = &statements[numstatements] - bc1;
if (bc2)
bc2->b = &statements[numstatements] - bc2;
if (1)
{
QCC_def_t *errfnc = QCC_PR_GetDef(NULL, "error", NULL, false, 0, false);
QCC_def_t *errmsg = QCC_MakeStringConst("bounds check failed\n");
QCC_FreeTemp(QCC_PR_GenerateFunctionCall(NULL, errfnc, &errmsg, &type_string, 1));
}
//we get here if they tried reading beyond the end of the array with bounds checks disabled. just return the last valid element.
QCC_PR_Statement(pr_opcodes+OP_RETURN, 0, 0, &st);
st->a = thearray->ofs + (numslots-1) * thearray->type->size;
QCC_PR_Statement(pr_opcodes+OP_DONE, 0, 0, NULL);
df->parm_start = locals_start;
@ -10541,6 +10743,7 @@ void QCC_PR_EmitArraySetFunction(QCC_def_t *scope, QCC_def_t *thearray, char *ar
QCC_def_t *fasttrackpossible;
int numslots;
QCC_statement_t *bc1=NULL, *bc2=NULL;
if (thearray->type->type == ev_vector)
numslots = thearray->arraysize;
@ -10561,7 +10764,7 @@ void QCC_PR_EmitArraySetFunction(QCC_def_t *scope, QCC_def_t *thearray, char *ar
df = &functions[numfunctions];
numfunctions++;
pr_source_line = thearray->s_line; //thankfully these functions are emitted after compilation.
pr_source_line = pr_token_line_last = thearray->s_line; //thankfully these functions are emitted after compilation.
df->s_file = thearray->s_file;
df->s_name = QCC_CopyString(scope->name);
df->first_statement = numstatements;
@ -10582,7 +10785,8 @@ void QCC_PR_EmitArraySetFunction(QCC_def_t *scope, QCC_def_t *thearray, char *ar
//note that the array size is coded into the globals, one index before the array.
QCC_PR_Statement3(&pr_opcodes[OP_CONV_FTOI], index, NULL, index, true); //address stuff is integer based, but standard qc (which this accelerates in supported engines) only supports floats
QCC_PR_SimpleStatement (OP_BOUNDCHECK, index->ofs, ((int*)qcc_pr_globals)[thearray->ofs-1]+1, 0, true);//annoy the programmer. :p
if (!flag_noboundchecks)
QCC_PR_SimpleStatement (OP_BOUNDCHECK, index->ofs, ((int*)qcc_pr_globals)[thearray->ofs-1]+1, 0, true);//annoy the programmer. :p
if (thearray->type->type == ev_vector)//shift it upwards for larger types
QCC_PR_Statement3(&pr_opcodes[OP_MUL_I], index, QCC_MakeIntConst(thearray->type->size), index, true);
QCC_PR_Statement3(&pr_opcodes[OP_GLOBALADDRESS], thearray, index, index, true); //comes with built in add
@ -10597,8 +10801,24 @@ void QCC_PR_EmitArraySetFunction(QCC_def_t *scope, QCC_def_t *thearray, char *ar
}
QCC_PR_Statement3(pr_opcodes+OP_BITAND_F, index, index, index, false);
if (!flag_noboundchecks)
QCC_FreeTemp(QCC_PR_Statement(pr_opcodes+OP_IF_I, QCC_PR_Statement(pr_opcodes+OP_LT_F, index, QCC_MakeFloatConst(0), NULL), 0, &bc1));
if (!flag_noboundchecks)
QCC_FreeTemp(QCC_PR_Statement(pr_opcodes+OP_IF_I, QCC_PR_Statement(pr_opcodes+OP_GT_F, index, QCC_MakeFloatConst(numslots-1), NULL), 0, &bc2));
QCC_PR_ArraySetRecurseDivide(thearray, index, value, 0, numslots);
if (bc1)
bc1->b = &statements[numstatements] - bc1;
if (bc2)
bc2->b = &statements[numstatements] - bc2;
if (bc1 || bc2)
{
QCC_def_t *errfnc = QCC_PR_GetDef(NULL, "error", NULL, false, 0, false);
QCC_def_t *errmsg = QCC_MakeStringConst("bounds check failed\n");
QCC_FreeTemp(QCC_PR_GenerateFunctionCall(NULL, errfnc, &errmsg, &type_string, 1));
}
QCC_PR_Statement(pr_opcodes+OP_DONE, 0, 0, NULL);
@ -10887,7 +11107,7 @@ QCC_def_t *QCC_PR_GetDef (QCC_type_t *type, char *name, QCC_def_t *scope, pbool
//this is a hack. droptofloor was wrongly declared in vanilla qc, which causes problems with replacement extensions.qc.
//yes, this is a selfish lazy hack for this, there's probably a better way, but at least we spit out a warning still.
QCC_PR_ParseWarning (WARN_LAXCAST, "%s builtin was wrongly defined as %s. ignoring invalid dupe definition",name, TypeName(type, typebuf1, sizeof(typebuf1)));
QCC_PR_ParsePrintDef(WARN_DUPLICATEDEFINITION, def);
QCC_PR_ParsePrintDef(WARN_LAXCAST, def);
}
else
{
@ -10901,8 +11121,8 @@ QCC_def_t *QCC_PR_GetDef (QCC_type_t *type, char *name, QCC_def_t *scope, pbool
{
//if the second def simply has no ..., don't bother warning about it.
QCC_PR_ParseWarning (WARN_LAXCAST, "Optional arguments differ on redeclaration of %s. %s, should be %s",name, TypeName(type, typebuf1, sizeof(typebuf1)), TypeName(def->type, typebuf2, sizeof(typebuf2)));
QCC_PR_ParsePrintDef(WARN_DUPLICATEDEFINITION, def);
QCC_PR_ParseWarning (WARN_TYPEMISMATCHREDECOPTIONAL, "Optional arguments differ on redeclaration of %s. %s, should be %s",name, TypeName(type, typebuf1, sizeof(typebuf1)), TypeName(def->type, typebuf2, sizeof(typebuf2)));
QCC_PR_ParsePrintDef(WARN_TYPEMISMATCHREDECOPTIONAL, def);
if (type->type == ev_function)
{
@ -11158,8 +11378,10 @@ void QCC_PR_ParseInitializerType(int arraysize, QCC_def_t *def, QCC_type_t *type
QCC_def_t *parentfunc = pr_scope;
QCC_function_t *f;
QCC_dfunction_t *df;
char fname[256];
tmp = NULL;
*fname = 0;
def->references++;
pr_scope = def;
@ -11172,17 +11394,41 @@ void QCC_PR_ParseInitializerType(int arraysize, QCC_def_t *def, QCC_type_t *type
binum = (int)pr_immediate._float;
else if (pr_token_type == tt_immediate && pr_immediate_type == type_integer)
binum = pr_immediate._int;
else
else if (pr_token_type == tt_immediate && pr_immediate_type == type_string)
strncpy(fname, pr_immediate_string, sizeof(fname));
else if (pr_token_type == tt_name)
strncpy(fname, pr_token, sizeof(fname));
else
QCC_PR_ParseError (ERR_BADBUILTINIMMEDIATE, "Bad builtin immediate");
QCC_PR_Lex();
if (!*fname && QCC_PR_CheckToken (":"))
strncpy(fname, QCC_PR_ParseName(), sizeof(fname));
//if the builtin already exists, just use that dfunction instead
if (def->initialized)
for (i = 0; i < numfunctions; i++)
{
if (functions[i].first_statement == -binum)
if (*fname)
{
tmp = QCC_MakeIntConst(i);
break;
for (i = 1; i < numfunctions; i++)
{
if (!strcmp(strings+functions[i].s_name, fname) && functions[i].first_statement == -binum)
{
tmp = QCC_MakeIntConst(i);
break;
}
}
}
else
{
for (i = 1; i < numfunctions; i++)
{
if (!strcmp(strings+functions[i].s_name, def->name) && functions[i].first_statement == -binum)
{
tmp = QCC_MakeIntConst(i);
break;
}
}
}
}
@ -11222,6 +11468,19 @@ void QCC_PR_ParseInitializerType(int arraysize, QCC_def_t *def, QCC_type_t *type
QCC_PR_ParseErrorPrintDef (ERR_REDECLARATION, def, "redeclaration of function body");
}
f = QCC_PR_ParseImmediateStatements (type);
//allow dupes if its a builtin
if (!f->code && def->initialized)
{
for (i = 1; i < numfunctions; i++)
{
if (functions[i].first_statement == -f->builtin)
{
tmp = QCC_MakeIntConst(i);
break;
}
}
}
}
if (!tmp)
{
@ -11240,7 +11499,9 @@ void QCC_PR_ParseInitializerType(int arraysize, QCC_def_t *def, QCC_type_t *type
else
df->first_statement = f->code;
if (f->builtin && opt_function_names)
if (*fname)
df->s_name = QCC_CopyString (fname);
else if (f->builtin && opt_function_names && df->first_statement)
optres_function_names += strlen(f->def->name);
else
df->s_name = QCC_CopyString (f->def->name);
@ -12269,9 +12530,10 @@ void QCC_PR_ParseDefs (char *classname)
else
def->constant = 1;
if (def->constant)
if (!def->initialized && def->constant)
{
unsigned int i;
def->initialized = true;
//if the field already has a value, don't allocate new field space for it as that would confuse things.
//otherwise allocate new space.
if (*(int *)&qcc_pr_globals[def->ofs])

View file

@ -701,7 +701,7 @@ pbool QCC_PR_Precompiler(void)
if (strlen(msg) >= sizeof(QCC_copyright))
QCC_PR_ParseWarning(WARN_STRINGTOOLONG, "Copyright message is too long\n");
strncpy(QCC_copyright, msg, sizeof(QCC_copyright)-1);
QC_strlcpy(QCC_copyright, msg, sizeof(QCC_copyright)-1);
}
else if (!strncmp(directive, "pack", 4))
{
@ -927,7 +927,7 @@ pbool QCC_PR_Precompiler(void)
{
if (strlen(msg) >= sizeof(QCC_copyright))
QCC_PR_ParseWarning(WARN_STRINGTOOLONG, "Copyright message is too long\n");
strncpy(QCC_copyright, msg, sizeof(QCC_copyright)-1);
QC_strlcpy(QCC_copyright, msg, sizeof(QCC_copyright)-1);
}
else if (!QC_strcasecmp(qcc_token, "compress"))
{
@ -1109,7 +1109,7 @@ pbool QCC_PR_Precompiler(void)
p--;
}
}
sprintf(destfile, "%s", s2);
QC_snprintfz(destfile, sizeof(destfile), "%s", s2);
while (p>0)
{
@ -2145,7 +2145,7 @@ void QCC_PR_ExpandMacro(void)
if (i < 0)
QCC_PR_ParseError (ERR_BADFRAMEMACRO, "Unknown frame macro $%s", pr_token);
sprintf (pr_token,"%d", i);
QC_snprintfz(pr_token, sizeof(pr_token),"%d", i);
pr_token_type = tt_immediate;
pr_immediate_type = type_float;
pr_immediate._float = (float)i;
@ -2335,8 +2335,7 @@ void QCC_PR_LexGrab (void)
if (*pr_framemodelname)
QCC_PR_MacroFrame(pr_framemodelname, pr_macrovalue);
strncpy(pr_framemodelname, pr_token, sizeof(pr_framemodelname)-1);
pr_framemodelname[sizeof(pr_framemodelname)-1] = '\0';
QC_strlcpy(pr_framemodelname, pr_token, sizeof(pr_framemodelname));
i = QCC_PR_FindMacro(pr_framemodelname);
if (i)
@ -2769,8 +2768,7 @@ int QCC_PR_CheckCompConst(void)
|| *end == '#')
break;
}
strncpy(pr_token, pr_file_p, end-pr_file_p);
pr_token[end-pr_file_p]='\0';
QC_strnlcpy(pr_token, pr_file_p, end-pr_file_p, sizeof(pr_token));
// printf("%s\n", pr_token);
c = pHash_Get(&compconstantstable, pr_token);
@ -3166,7 +3164,7 @@ void QCC_PR_Lex (void)
return;
}
if (c == '#' && !(pr_file_p[1]=='-' || (pr_file_p[1]>='0' && pr_file_p[1] <='9'))) //hash and not number
if (c == '#' && !(pr_file_p[1]=='\"' || pr_file_p[1]=='-' || (pr_file_p[1]>='0' && pr_file_p[1] <='9'))) //hash and not number
{
pr_file_p++;
if (!QCC_PR_CheckCompConst())
@ -4692,7 +4690,7 @@ QCC_type_t *QCC_PR_ParseType (int newtype, pbool silentfail)
QCC_Error(ERR_INTERNAL, "Nested function declaration");
isnull = (QCC_PR_CheckImmediate("0") || QCC_PR_CheckImmediate("0i"));
sprintf(membername, "%s::%s", classname, parmname);
QC_snprintfz(membername, sizeof(membername), "%s::%s", classname, parmname);
if (isnull)
{
def = QCC_PR_GetDef(newparm, membername, NULL, true, 0, 0);
@ -4800,7 +4798,7 @@ QCC_type_t *QCC_PR_ParseType (int newtype, pbool silentfail)
//static members are technically just funny-named globals, and do not generate fields.
if (isnonvirt || isstatic || (newparm->type == ev_function && !arraysize))
{
sprintf(membername, "%s::%s", classname, parmname);
QC_snprintfz(membername, sizeof(membername), "%s::%s", classname, parmname);
QCC_PR_GetDef(newparm, membername, NULL, true, 0, GDF_CONST);
if (isnonvirt || isstatic)
@ -4872,7 +4870,7 @@ QCC_type_t *QCC_PR_ParseType (int newtype, pbool silentfail)
d = QCC_PR_GetDef(NULL, parmname, NULL, 0, 0, GDF_CONST);
if (!d)
{ //don't go all weird with unioning generic fields
sprintf(membername, "::%s%i", basictypenames[newparm->type], basicindex+1);
QC_snprintfz(membername, sizeof(membername), "::%s%i", basictypenames[newparm->type], basicindex+1);
d = QCC_PR_GetDef(NULL, membername, NULL, 0, 0, GDF_CONST);
if (!d)
{
@ -4887,7 +4885,7 @@ QCC_type_t *QCC_PR_ParseType (int newtype, pbool silentfail)
//and make sure we can do member::__fname
//actually, that seems pointless.
sprintf(membername, "%s::"MEMBERFIELDNAME, classname, parmname);
QC_snprintfz(membername, sizeof(membername), "%s::"MEMBERFIELDNAME, classname, parmname);
// printf("define %s -> %s\n", membername, d->name);
d = QCC_PR_DummyDef(fieldtype, membername, pr_scope, 0, d->ofs, true, (isnull?0:GDF_CONST)|(opt_classfields?GDF_STRIP:0));
d->references++; //always referenced, so you can inherit safely.
@ -4920,7 +4918,7 @@ QCC_type_t *QCC_PR_ParseType (int newtype, pbool silentfail)
{
QCC_def_t *d;
//if there's a constructor, make sure the spawnfunc_ function is defined so that its available to maps.
sprintf(membername, "spawnfunc_%s", classname);
QC_snprintfz(membername, sizeof(membername), "spawnfunc_%s", classname);
d = QCC_PR_GetDef(type_function, membername, NULL, true, 0, GDF_CONST);
d->timescalled++;
d->references++;

File diff suppressed because it is too large Load diff

Some files were not shown because too many files have changed in this diff Show more