1
0
Fork 0
forked from fte/fteqw

Big fat-off commit.

A few changes. Half-Life support is finally getting committed.
Some unnecessary filesystem code changes.
And there's code for nsapi - meaning we can embed FTE in a browser (firefox and opera on windows work).
A couple of CSQC changes, trying to move towards a final EXT_CSQC_1.
Revised ruleset format finally implemented.
Doesn't compile with msvc6 due to issues with libjpeg not being a clean library.
Presumably its fine in vs2005.
Your mileage may vary.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@3148 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2009-04-01 22:03:56 +00:00
parent 262bc69548
commit 4974c57c2c
125 changed files with 16306 additions and 3148 deletions

View file

@ -633,7 +633,16 @@ static int CG_SystemCallsEx(void *offset, unsigned int mask, int fn, const int *
if (!angles)
angles = vec3_origin;
if (mod)
#ifndef CLIENTONLY
TransformedNativeTrace(mod, 0, 0, start, end, mins, maxs, brushmask, &tr, origin, angles);
#else
{
#pragma message("FIXME: G3 CGame requires TransformedNativeTrace!")
memset(&tr, 0, sizeof(tr));
tr.allsolid = tr.startsolid = true;
tr.contents = 1;
}
#endif
else
{
memset(&tr, 0, sizeof(tr));
@ -859,7 +868,7 @@ vec3_t listener_up;
VectorCopy(axis+3, listener_right);
VectorCopy(axis+6, listener_up);
// S_Update(origin, axis[0], axis[1], axis[2], false);
S_UpdateListener(org, axis[0], axis[1], axis[2], false);
}
break;

View file

@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "quakedef.h"
#include "fs.h"
void CL_FinishTimeDemo (void);
float demtime;
@ -883,7 +884,6 @@ void CL_Record_f (void)
{
int c;
char name[MAX_OSPATH];
int namelen = sizeof(name);
sizebuf_t buf;
char buf_data[MAX_QWMSGLEN];
int n, i, j;
@ -910,7 +910,6 @@ void CL_Record_f (void)
if (cls.demorecording)
CL_Stop_f();
namelen -= strlen(com_gamedir)+1;
if (c == 2) //user supplied a name
{
fname = Cmd_Argv(1);
@ -1651,6 +1650,8 @@ void CL_QTVPoll (void)
else if (!strcmp(s, "BEGIN"))
{
while (*colon && *(unsigned char*)colon <= ' ')
colon++;
if (*colon)
Con_Printf("streaming \"%s\" from qtv\n", colon);
else
@ -1737,6 +1738,171 @@ char *strchrrev(char *str, char chr)
return NULL;
}
void CL_ParseQTVFile(vfsfile_t *f, const char *fname, qtvfile_t *result)
{
char buffer[2048];
char *s;
memset(result, 0, sizeof(*result));
if (!f)
{
Con_Printf("Couldn't open QTV file: %s\n", name);
return;
}
if (!VFS_GETS(f, buffer, sizeof(buffer)-1))
{
Con_Printf("Empty QTV file: %s\n", name);
VFS_CLOSE(f);
return;
}
s = buffer;
while (*s == ' ' || *s == '\t')
s++;
if (*s != '[')
{
Con_Printf("Bad QTV file: %s\n", name);
VFS_CLOSE(f);
return;
}
s++;
while (*s == ' ' || *s == '\t')
s++;
if (strnicmp(s, "QTV", 3))
{
Con_Printf("Bad QTV file: %s\n", name);
VFS_CLOSE(f);
return;
}
s+=3;
while (*s == ' ' || *s == '\t')
s++;
if (*s != ']')
{
Con_Printf("Bad QTV file: %s\n", name);
VFS_CLOSE(f);
return;
}
s++;
while (*s == ' ' || *s == '\t' || *s == '\r')
s++;
if (*s)
{
Con_Printf("Bad QTV file: %s\n", name);
VFS_CLOSE(f);
return;
}
while (VFS_GETS(f, buffer, sizeof(buffer)-1))
{
s = COM_ParseToken(buffer, ":=");
if (*s != '=' && *s != ':')
s = "";
else
s++;
if (!stricmp(com_token, "stream"))
{
result->connectiontype = QTVCT_STREAM;
s = COM_ParseOut(s, result->server, sizeof(result->server));
}
else if (!stricmp(com_token, "connect"))
{
result->connectiontype = QTVCT_CONNECT;
s = COM_ParseOut(s, result->server, sizeof(result->server));
}
else if (!stricmp(com_token, "join"))
{
result->connectiontype = QTVCT_JOIN;
s = COM_ParseOut(s, result->server, sizeof(result->server));
}
else if (!stricmp(com_token, "observe"))
{
result->connectiontype = QTVCT_OBSERVE;
s = COM_ParseOut(s, result->server, sizeof(result->server));
}
else if (!stricmp(com_token, "splash"))
{
s = COM_ParseOut(s, result->splashscreen, sizeof(result->server));
}
}
VFS_CLOSE(f);
}
void CL_ParseQTVDescriptor(vfsfile_t *f, const char *name)
{
char buffer[1024];
char *s;
if (!f)
{
Con_Printf("Couldn't open QTV file: %s\n", name);
return;
}
while (VFS_GETS(f, buffer, sizeof(buffer)-1))
{
if (!strncmp(buffer, "Stream=", 7) || !strncmp(buffer, "Stream:", 7))
{
for (s = buffer + strlen(buffer)-1; s >= buffer; s--)
{
if (*s == '\r' || *s == '\n' || *s == ';')
*s = 0;
else
break;
}
s = buffer+7;
while(*s && *s <= ' ')
s++;
Cbuf_AddText(va("qtvplay \"%s\"\n", s), Cmd_ExecLevel);
break;
}
if (!strncmp(buffer, "Connect=", 8) || !strncmp(buffer, "Connect:", 8))
{
for (s = buffer + strlen(buffer)-1; s >= buffer; s--)
{
if (*s == '\r' || *s == '\n' || *s == ';')
*s = 0;
else
break;
}
s = buffer+8;
while(*s && *s <= ' ')
s++;
Cbuf_AddText(va("connect \"%s\"\n", s), Cmd_ExecLevel);
break;
}
if (!strncmp(buffer, "Join=", 5) || !strncmp(buffer, "Join:", 5))
{
for (s = buffer + strlen(buffer)-1; s >= buffer; s--)
{
if (*s == '\r' || *s == '\n' || *s == ';')
*s = 0;
else
break;
}
s = buffer+5;
while(*s && *s <= ' ')
s++;
Cbuf_AddText(va("join \"%s\"\n", s), Cmd_ExecLevel);
break;
}
if (!strncmp(buffer, "Observe=", 8) || !strncmp(buffer, "Observe:", 8))
{
for (s = buffer + strlen(buffer)-1; s >= buffer; s--)
{
if (*s == '\r' || *s == '\n' || *s == ';')
*s = 0;
else
break;
}
s = buffer+8;
while(*s && *s <= ' ')
s++;
Cbuf_AddText(va("observe \"%s\"\n", s), Cmd_ExecLevel);
break;
}
}
VFS_CLOSE(f);
}
void CL_QTVPlay_f (void)
{
qboolean raw=0;
@ -1754,80 +1920,8 @@ void CL_QTVPlay_f (void)
if (*connrequest == '#')
{
char buffer[1024];
char *s;
FILE *f;
f = fopen(connrequest+1, "rt");
if (!f)
{
Con_Printf("Couldn't open QTV file: %s\n", connrequest+1);
return;
}
while (!feof(f))
{
fgets(buffer, sizeof(buffer)-1, f);
if (!strncmp(buffer, "Stream=", 7) || !strncmp(buffer, "Stream:", 7))
{
for (s = buffer + strlen(buffer)-1; s >= buffer; s--)
{
if (*s == '\r' || *s == '\n' || *s == ';')
*s = 0;
else
break;
}
s = buffer+7;
while(*s && *s <= ' ')
s++;
Cbuf_AddText(va("qtvplay \"%s\"\n", s), Cmd_ExecLevel);
break;
}
if (!strncmp(buffer, "Connect=", 8) || !strncmp(buffer, "Connect:", 8))
{
for (s = buffer + strlen(buffer)-1; s >= buffer; s--)
{
if (*s == '\r' || *s == '\n' || *s == ';')
*s = 0;
else
break;
}
s = buffer+8;
while(*s && *s <= ' ')
s++;
Cbuf_AddText(va("connect \"%s\"\n", s), Cmd_ExecLevel);
break;
}
if (!strncmp(buffer, "Join=", 5) || !strncmp(buffer, "Join:", 5))
{
for (s = buffer + strlen(buffer)-1; s >= buffer; s--)
{
if (*s == '\r' || *s == '\n' || *s == ';')
*s = 0;
else
break;
}
s = buffer+5;
while(*s && *s <= ' ')
s++;
Cbuf_AddText(va("join \"%s\"\n", s), Cmd_ExecLevel);
break;
}
if (!strncmp(buffer, "Observe=", 8) || !strncmp(buffer, "Observe:", 8))
{
for (s = buffer + strlen(buffer)-1; s >= buffer; s--)
{
if (*s == '\r' || *s == '\n' || *s == ';')
*s = 0;
else
break;
}
s = buffer+8;
while(*s && *s <= ' ')
s++;
Cbuf_AddText(va("observe \"%s\"\n", s), Cmd_ExecLevel);
break;
}
}
fclose(f);
//#FILENAME is a local system path
CL_ParseQTVDescriptor(VFSOS_Open(connrequest+1, "rt"), connrequest+1);
return;
}

View file

@ -1595,6 +1595,8 @@ void CL_LinkPacketEntities (void)
autorotate = anglemod(100*servertime);
CLCSQC_DeltaStart();
for (newpnum=0 ; newpnum<pack->num_entities ; newpnum++)
{
state = &pack->entities[newpnum];
@ -1606,6 +1608,10 @@ void CL_LinkPacketEntities (void)
Con_Printf("Too many visible entities\n");
break;
}
if (CLCSQC_DeltaUpdate(state))
continue;
ent = &cl_visedicts[cl_numvisedicts];
#ifdef Q3SHADERS
ent->forcedshader = NULL;
@ -1762,12 +1768,11 @@ void CL_LinkPacketEntities (void)
AngleVectors(angles, ent->axis[0], ent->axis[1], ent->axis[2]);
VectorInverse(ent->axis[1]);
if (ent->keynum <= MAX_CLIENTS
#ifdef NQPROT
&& cls.protocol == CP_QUAKEWORLD
#endif
)
ent->keynum += MAX_EDICTS;
if (ent->keynum <= MAX_CLIENTS)
{
if (!cl.nolocalplayer[0])
ent->keynum += MAX_EDICTS;
}
if (state->tagentity)
{ //ent is attached to a tag, rotate this ent accordingly.
@ -1869,6 +1874,7 @@ void CL_LinkPacketEntities (void)
}
}
CLCSQC_DeltaEnd();
}
#else
@ -2752,6 +2758,9 @@ void CL_LinkPlayers (void)
vec3_t angles;
float *org;
if (!cl.worldmodel || cl.worldmodel->needload)
return;
playertime = realtime - cls.latency + 0.02;
if (playertime > realtime)
playertime = realtime;
@ -2763,7 +2772,13 @@ void CL_LinkPlayers (void)
; j++, info++, state++)
{
if (state->messagenum != cl.validsequence)
{
CLCSQC_DeltaPlayer(j, NULL);
continue; // not present this frame
}
if (CLCSQC_DeltaPlayer(j, state))
continue;
// spawn light flashes, even ones coming from invisible objects
if (r_powerupglow.value && !(r_powerupglow.value == 2 && j == cl.playernum[0]))
@ -3010,25 +3025,29 @@ void CL_LinkViewModel(void)
ent.shaderRGBAf[2] = 1;
ent.shaderRGBAf[3] = alpha;
ent.framestate.g[FS_REG].frame[0] = cl.viewent[r_refdef.currentplayernum].framestate.g[FS_REG].frame[0];
ent.framestate.g[FS_REG].frame[1] = oldframe[r_refdef.currentplayernum];
if (ent.framestate.g[FS_REG].frame[0] != prevframe[r_refdef.currentplayernum])
#ifdef HLCLIENT
if (!CLHL_AnimateViewEntity(&ent))
#endif
{
oldframe[r_refdef.currentplayernum] = ent.framestate.g[FS_REG].frame[1] = prevframe[r_refdef.currentplayernum];
lerptime[r_refdef.currentplayernum] = realtime;
}
prevframe[r_refdef.currentplayernum] = ent.framestate.g[FS_REG].frame[0];
ent.framestate.g[FS_REG].frame[0] = cl.viewent[r_refdef.currentplayernum].framestate.g[FS_REG].frame[0];
ent.framestate.g[FS_REG].frame[1] = oldframe[r_refdef.currentplayernum];
if (ent.model != oldmodel[r_refdef.currentplayernum])
{
oldmodel[r_refdef.currentplayernum] = ent.model;
oldframe[r_refdef.currentplayernum] = ent.framestate.g[FS_REG].frame[1] = ent.framestate.g[FS_REG].frame[0];
lerptime[r_refdef.currentplayernum] = realtime;
}
ent.framestate.g[FS_REG].lerpfrac = 1-(realtime-lerptime[r_refdef.currentplayernum])*10;
ent.framestate.g[FS_REG].lerpfrac = bound(0, ent.framestate.g[FS_REG].lerpfrac, 1);
if (ent.framestate.g[FS_REG].frame[0] != prevframe[r_refdef.currentplayernum])
{
oldframe[r_refdef.currentplayernum] = ent.framestate.g[FS_REG].frame[1] = prevframe[r_refdef.currentplayernum];
lerptime[r_refdef.currentplayernum] = realtime;
}
prevframe[r_refdef.currentplayernum] = ent.framestate.g[FS_REG].frame[0];
if (ent.model != oldmodel[r_refdef.currentplayernum])
{
oldmodel[r_refdef.currentplayernum] = ent.model;
oldframe[r_refdef.currentplayernum] = ent.framestate.g[FS_REG].frame[1] = ent.framestate.g[FS_REG].frame[0];
lerptime[r_refdef.currentplayernum] = realtime;
}
ent.framestate.g[FS_REG].lerpfrac = 1-(realtime-lerptime[r_refdef.currentplayernum])*10;
ent.framestate.g[FS_REG].lerpfrac = bound(0, ent.framestate.g[FS_REG].lerpfrac, 1);
}
#define Q2RF_VIEWERMODEL 2 // don't draw through eyes, only mirrors
#define Q2RF_WEAPONMODEL 4 // only draw through eyes
#define Q2RF_DEPTHHACK 16 // for view weapon Z crunching

View file

@ -1505,6 +1505,9 @@ void CL_SendCmd (double frametime)
}
}
#ifdef HLCLIENT
if (!CLHL_BuildUserInput(msecstouse, &independantphysics[0]))
#endif
for (plnum = 0; plnum < cl.splitclients; plnum++)
{
// CL_BaseMove (&independantphysics[plnum], plnum, (msecstouse - independantphysics[plnum].msec), wantfps);

View file

@ -1504,7 +1504,7 @@ void CL_CheckServerInfo(void)
cl.ktprogametime = 0;
Cvar_ForceCheatVars(cls.allow_semicheats, cls.allow_cheats);
Validation_Apply_Ruleset();
if (oldallowshaders != cls.allow_shaders)
Cache_Flush(); //this will cause all models to be reloaded.
@ -2774,7 +2774,7 @@ void CL_ServerInfo_f(void)
{
if (!sv.state && cls.state)
{
if (cls.demoplayback)
if (cls.demoplayback || cls.protocol != CP_QUAKEWORLD)
{
Info_Print (cl.serverinfo);
}
@ -3385,10 +3385,10 @@ void Host_Frame (double time)
if (cls.protocol == CP_QUAKE3)
S_ExtraUpdate();
else
S_Update (r_origin, vpn, vright, vup);
S_UpdateListener (r_origin, vpn, vright, vup, false);
}
else
S_Update (vec3_origin, vec3_origin, vec3_origin, vec3_origin);
S_UpdateListener (vec3_origin, vec3_origin, vec3_origin, vec3_origin, false);
CDAudio_Update();
@ -3420,6 +3420,8 @@ void Host_Frame (double time)
static void simple_crypt(char *buf, int len)
{
if (!(*buf & 128))
return;
while (len--)
*buf++ ^= 0xff;
}
@ -3626,6 +3628,7 @@ void Host_Init (quakeparms_t *parms)
Cvar_ApplyLatches(CVAR_RENDERERLATCH);
#ifndef NPQTV
//-1 means 'never set'
if (qrenderer == -1 && *vid_renderer.string)
{
@ -3641,6 +3644,7 @@ void Host_Init (quakeparms_t *parms)
if (qrenderer == QR_NONE)
Con_Printf("Use the setrenderer command to use a gui\n");
#endif
#ifdef VM_UI
UI_Init();
@ -3695,14 +3699,12 @@ to run quit through here before the final handoff to the sys code.
*/
void Host_Shutdown(void)
{
static qboolean isdown = false;
if (isdown)
if (!host_initialized)
{
Sys_Printf ("recursive shutdown\n");
return;
}
isdown = true;
host_initialized = false;
#ifdef VM_UI
UI_Stop();
@ -3713,6 +3715,7 @@ void Host_Shutdown(void)
CDAudio_Shutdown ();
S_Shutdown();
IN_Shutdown ();
R_ShutdownRenderer();
if (VID_DeInit)
VID_DeInit();
#ifndef CLIENTONLY
@ -3720,11 +3723,16 @@ void Host_Shutdown(void)
#else
NET_Shutdown ();
#endif
FS_Shutdown();
Cvar_Shutdown();
Validation_FlushFileList();
Cmd_Shutdown();
Memory_DeInit();
memset(&sv, 0, sizeof(sv));
memset(&svs, 0, sizeof(svs));
}
#ifdef CLIENTONLY

View file

@ -1,4 +1,5 @@
#define SS_GENERICQUAKEWORLD 0
#define SS_FTESERVER 1 //hehehe...
#define SS_QUAKE2 2 //useful (and cool). Could be blamed for swamping.
#define SS_NETQUAKE 4

View file

@ -452,12 +452,10 @@ void CL_DownloadFinished(char *filename, char *tempname)
{
if (strncmp(tempname,"skins/",6))
{
FS_CreatePath(filename, FS_GAME);
FS_Rename(tempname, filename, FS_GAME);
}
else
{
FS_CreatePath(filename+6, FS_SKINS);
FS_Rename(tempname+6, filename+6, FS_SKINS);
}
}
@ -834,6 +832,14 @@ int CL_LoadModels(int stage)
}
#endif
#ifdef HLCLIENT
if (atstage())
{
CLHL_LoadClientGame();
endstage();
}
#endif
#ifdef PEXT_CSQC
if (atstage())
{
@ -890,8 +896,12 @@ int CL_LoadModels(int stage)
else
CSQC_LoadResource(cl.model_name[i], "model");
#endif
cl.model_precache[i] = Mod_ForName (cl.model_name[i], false);
#ifdef Q2CLIENT
if (cls.protocol == CP_QUAKE2 && *cl.model_name[i] == '#')
cl.model_precache[i] = NULL;
else
#endif
cl.model_precache[i] = Mod_ForName (cl.model_name[i], false);
Hunk_Check();
S_ExtraUpdate();
@ -3334,7 +3344,7 @@ void CL_NewTranslation (int slot)
}
else
local = cl.playernum[0];
if (cl.teamplay && !strcmp(player->team, cl.players[local].team))
if ((cl.teamplay || cls.protocol == CP_NETQUAKE) && !strcmp(player->team, cl.players[local].team))
{
if (cl_teamtopcolor != ~0)
top = cl_teamtopcolor;
@ -4961,6 +4971,18 @@ void CL_ParseServerMessage (void)
case svcfte_pointparticles1:
CLDP_ParsePointParticles(true);
break;
case svcfte_cgamepacket:
#ifdef HLCLIENT
if (CLHL_ParseGamePacket());
break;
#endif
#ifdef CSQC_DAT
if (CSQC_ParseGamePacket());
break;
#endif
Con_Printf("Unable to parse gamecode packet\n");
break;
}
}
}
@ -4995,7 +5017,6 @@ void CLQ2_ParseServerMessage (void)
{
if (msg_badread)
{
SV_UnspawnServer();
Host_EndGame ("CLQ2_ParseServerMessage: Bad server message");
break;
}
@ -5490,6 +5511,8 @@ void CLNQ_ParseServerMessage (void)
if (cls.state == ca_active)
Skin_Find (&cl.players[i]);
if (i == cl.playernum[0])
Skin_FlushPlayers();
Sbar_Changed ();
CL_NewTranslation (i);
}

View file

@ -715,6 +715,9 @@ void CL_PredictMovePNum (int pnum)
//these are to make svc_viewentity work better
float *vel;
float *org;
cl.nolocalplayer[pnum] = false;
#ifdef Q2CLIENT
if (cls.protocol == CP_QUAKE2)
{
@ -775,6 +778,7 @@ void CL_PredictMovePNum (int pnum)
{
if (cl.viewentity[pnum] < cl.maxlerpents)
{
cl.nolocalplayer[pnum] = true;
// Con_Printf("Using lerped pos\n");
org = cl.lerpents[cl.viewentity[pnum]].origin;
vel = vec3_origin;
@ -822,6 +826,7 @@ void CL_PredictMovePNum (int pnum)
//no player states?? put the view on an ent
if (cl.playernum[pnum] < cl.maxlerpents)
{
cl.nolocalplayer[pnum] = true;
// Con_Printf("Using lerped pos\n");
org = cl.lerpents[cl.playernum[pnum]+1].origin;
vel = vec3_origin;

View file

@ -1317,6 +1317,12 @@ void SCR_DrawFPS (void)
lastfps = 1/host_frametime;
lastframetime = t;
break;
#ifdef RGLQUAKE
case 5:
if (qrenderer == QR_OPENGL)
GLR_FrameTimeGraph((int)(1000.0*host_frametime));
break;
#endif
}
if (usemsecs)
@ -1742,8 +1748,6 @@ int Image_WritePNG (char *filename, int compression, qbyte *pixels, int width, i
#endif
void WriteBMPFile(char *filename, qbyte *in, int width, int height);
void WritePCXfile (char *filename, qbyte *data, int width, int height, int rowbytes, qbyte *palette, qboolean upload); //data is 8bit.
/*
Find closest color in the palette for named color
*/
@ -1870,7 +1874,6 @@ SCR_ScreenShot_f
void SCR_ScreenShot_f (void)
{
char pcxname[80];
char checkname[MAX_OSPATH];
int i;
vfsfile_t *vfs;
@ -1903,7 +1906,7 @@ void SCR_ScreenShot_f (void)
pcxname[17] = (i%1000)/100 + '0';
pcxname[18] = (i%100)/10 + '0';
pcxname[19] = (i%10) + '0';
sprintf (checkname, "%s/%s", com_gamedir, pcxname);
if (!(vfs = FS_OpenVFS(pcxname, "rb", FS_GAMEONLY)))
break; // file doesn't exist
VFS_CLOSE(vfs);

View file

@ -618,7 +618,7 @@ void UI_RegisterFont(char *fontName, int pointSize, fontInfo_t *font)
#define VALIDATEPOINTER(o,l) if ((int)o + l >= mask || VM_POINTER(o) < offset) SV_Error("Call to ui trap %i passes invalid pointer\n", fn); //out of bounds.
#define VALIDATEPOINTER(o,l) if ((int)o + l >= mask || VM_POINTER(o) < offset) Host_EndGame("Call to ui trap %i passes invalid pointer\n", fn); //out of bounds.
#ifndef _DEBUG
static

1373
engine/client/clhl_game.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -552,6 +552,7 @@ typedef struct
char levelname[40]; // for display on solo scoreboard
int playernum[MAX_SPLITS];
qboolean nolocalplayer[MAX_SPLITS];
int splitclients; //we are running this many clients split screen.
// refresh related state
@ -804,6 +805,28 @@ void CL_QTVDemos_f (void);
void CL_DemoJump_f(void);
void CL_ProgressDemoTime(void);
void CL_TimeDemo_f (void);
typedef struct
{
enum
{
QTVCT_NONE,
QTVCT_STREAM,
QTVCT_CONNECT,
QTVCT_JOIN,
QTVCT_OBSERVE,
} connectiontype;
enum
{
QTVCT_NETQUAKE,
QTVCT_QUAKEWORLD,
QTVCT_QUAKE2,
QTVCT_QUAKE3
} protocol;
char server[256];
char splashscreen[256];
//char *datafiles;
} qtvfile_t;
void CL_ParseQTVFile(vfsfile_t *f, const char *fname, qtvfile_t *result);
//
// cl_parse.c

View file

@ -464,8 +464,6 @@ qboolean CLQ3_SystemInfoChanged(char *str)
Info_SetValueForStarKey (svs.info, "*gamedir", value, MAX_SERVERINFO_STRING);
#endif
COM_FlushFSCache();
Shader_Init();
}
if (usingpure)
@ -607,7 +605,7 @@ void CLQ3_ParseGameState(void)
{
char buffer[2048];
strcpy(buffer, va("cp %i ", cl.servercount));
FS_GenerateClientPacksList(buffer, sizeof(buffer), ccs.fs_key);
FSQ3_GenerateClientPacksList(buffer, sizeof(buffer), ccs.fs_key);
CLQ3_SendClientCommand(buffer);
}

View file

@ -894,6 +894,9 @@ The input line scrolls horizontally if typing goes beyond the right edge
*/
void Con_DrawInput (void)
{
#ifdef _WIN32
extern qboolean ActiveApp;
#endif
int y;
int i;
int p;
@ -999,6 +1002,9 @@ void Con_DrawInput (void)
}
}
#ifdef _WIN32
if (ActiveApp)
#endif
if (((int)(realtime*con_cursorspeed)&1))
{
maskedtext[key_linepos] = 11|CON_WHITEMASK; //make it blink

View file

@ -584,7 +584,7 @@ void VARGS readpngdata(png_structp png_ptr,png_bytep data,png_size_t len)
}
qbyte *png_rgba;
qbyte *ReadPNGFile(qbyte *buf, int length, int *width, int *height, char *fname)
qbyte *ReadPNGFile(qbyte *buf, int length, int *width, int *height, const char *fname)
{
qbyte header[8], **rowpointers = NULL, *data = NULL;
png_structp png;
@ -702,12 +702,10 @@ int Image_WritePNG (char *filename, int compression, qbyte *pixels, int width, i
png_structp png_ptr;
png_infop info_ptr;
png_byte **row_pointers;
snprintf (name, sizeof(name)-1, "%s/%s", com_gamedir, filename);
if (Sys_PathProtection(filename) )
if (!FS_NativePath(filename, FS_GAMEONLY, name, sizeof(name)))
return false;
if (!(fp = fopen (name, "wb")))
{
COM_CreatePath (name);
@ -1146,7 +1144,7 @@ void screenshotJPEG(char *filename, int compression, qbyte *screendata, int scre
WritePCXfile
==============
*/
void WritePCXfile (char *filename, qbyte *data, int width, int height,
void WritePCXfile (const char *filename, qbyte *data, int width, int height,
int rowbytes, qbyte *palette, qboolean upload) //data is 8bit.
{
int i, j, length;

View file

@ -401,7 +401,7 @@ void IN_UpdateClipCursor (void)
IN_ShowMouse
===========
*/
void IN_ShowMouse (void)
static void IN_ShowMouse (void)
{
if (!mouseshowtoggle)
@ -417,7 +417,7 @@ void IN_ShowMouse (void)
IN_HideMouse
===========
*/
void IN_HideMouse (void)
static void IN_HideMouse (void)
{
if (mouseshowtoggle)
@ -433,12 +433,12 @@ void IN_HideMouse (void)
IN_ActivateMouse
===========
*/
void IN_ActivateMouse (void)
static void IN_ActivateMouse (void)
{
mouseactivatetoggle = true;
if (mouseinitialized)
if (mouseinitialized && !mouseactive)
{
#ifdef AVAIL_DINPUT
#if (DIRECTINPUT_VERSION >= DINPUT_VERSION_DX7)
@ -502,31 +502,17 @@ void IN_ActivateMouse (void)
}
/*
===========
IN_SetQuakeMouseState
===========
*/
void IN_SetQuakeMouseState (void)
{
if (mouseactivatetoggle)
IN_ActivateMouse ();
else
IN_DeactivateMouse();
}
/*
===========
IN_DeactivateMouse
===========
*/
void IN_DeactivateMouse (void)
static void IN_DeactivateMouse (void)
{
mouseactivatetoggle = false;
if (mouseinitialized)
if (mouseinitialized && mouseactive)
{
#ifdef AVAIL_DINPUT
#if (DIRECTINPUT_VERSION >= DINPUT_VERSION_DX7)
@ -579,6 +565,18 @@ void IN_DeactivateMouse (void)
}
}
/*
===========
IN_SetQuakeMouseState
===========
*/
void IN_SetQuakeMouseState (void)
{
if (mouseactivatetoggle)
IN_ActivateMouse ();
else
IN_DeactivateMouse();
}
/*
===========
@ -599,6 +597,60 @@ void IN_RestoreOriginalMouseState (void)
ShowCursor (FALSE);
}
void IN_UpdateGrabs(int fullscreen, int activeapp)
{
int grabmouse;
if (fullscreen)
grabmouse = true;
else if (activeapp && _windowed_mouse.value)
{
if (!Key_MouseShouldBeFree())
grabmouse = true;
else
grabmouse = false;
}
else
grabmouse = false;
//visiblity
if (grabmouse)
IN_HideMouse();
else
IN_ShowMouse();
#ifdef HLCLIENT
//halflife gamecode does its own mouse control... yes this is vile.
if (grabmouse)
{
if (CLHL_GamecodeDoesMouse())
grabmouse = 2;
}
if (grabmouse == 2)
{
IN_DeactivateMouse();
CLHL_SetMouseActive(true);
return;
}
CLHL_SetMouseActive(false);
#endif
if (grabmouse)
IN_ActivateMouse();
else
IN_DeactivateMouse();
}
#ifdef AVAIL_DINPUT
BOOL CALLBACK IN_EnumerateDevices(LPCDIDEVICEINSTANCE inst, LPVOID parm)
{
@ -1315,7 +1367,15 @@ void IN_MouseEvent (int mstate)
{
int i;
if ((mouseactive || (key_dest != key_game)) && !dinput)
if (dinput)
return;
#ifdef HLCLIENT
if (CLHL_MouseEvent(mstate))
return;
#endif
if (mouseactive || (key_dest != key_game))
{
// perform button actions
for (i=0 ; i<sysmouse.numbuttons ; i++)
@ -1367,18 +1427,21 @@ static void ProcessMouse(mouse_t *mouse, usercmd_t *cmd, int pnum)
if (m_forcewheel.value)
{
mfwt = (int)m_forcewheel_threshold.value;
while(mouse->wheeldelta <= -mfwt)
if (mfwt)
{
Key_Event (K_MWHEELUP, true);
Key_Event (K_MWHEELUP, false);
mouse->wheeldelta += mfwt;
}
while(mouse->wheeldelta <= -mfwt)
{
Key_Event (K_MWHEELUP, true);
Key_Event (K_MWHEELUP, false);
mouse->wheeldelta += mfwt;
}
while(mouse->wheeldelta >= mfwt)
{
Key_Event (K_MWHEELDOWN, true);
Key_Event (K_MWHEELDOWN, false);
mouse->wheeldelta -= mfwt;
while(mouse->wheeldelta >= mfwt)
{
Key_Event (K_MWHEELDOWN, true);
Key_Event (K_MWHEELDOWN, false);
mouse->wheeldelta -= mfwt;
}
}
if (m_forcewheel.value < 2)
@ -1460,10 +1523,6 @@ static void ProcessMouse(mouse_t *mouse, usercmd_t *cmd, int pnum)
if (!cmd)
{
if (mx || my)
{
SetCursorPos (window_center_x, window_center_y);
}
return;
}

View file

@ -402,6 +402,7 @@ void Con_ExecuteLine(console_t *con, char *line)
Cbuf_AddText ("\n", RESTRICT_LOCAL);
if (!waschat || con_echochat.value)
Con_Printf ("]%s\n",line);
if (cls.state == ca_disconnected)
SCR_UpdateScreen (); // force an update, because the command
// may take some time
@ -1372,7 +1373,7 @@ qboolean Key_MouseShouldBeFree(void)
if (key_dest == key_menu)
{
if (m_state == m_complex || m_state == m_plugin)
if (m_state == m_complex || m_state == m_plugin || m_state == m_menu_dat)
return true;
}
if (key_dest == key_console)

View file

@ -1643,17 +1643,24 @@ void M_Menu_Main_f (void)
if (!p)
return;
MC_AddPicture(mainm, 0, 173, "pics/m_main_logo");
#ifndef CLIENTONLY
MC_AddSelectablePicture(mainm, 68, 13, "pics/m_main_game");
#endif
MC_AddSelectablePicture(mainm, 68, 53, "pics/m_main_multiplayer");
MC_AddSelectablePicture(mainm, 68, 93, "pics/m_main_options");
MC_AddSelectablePicture(mainm, 68, 133, "pics/m_main_video");
MC_AddSelectablePicture(mainm, 68, 173, "pics/m_main_quit");
#ifndef CLIENTONLY
b = MC_AddConsoleCommand (mainm, 68, 13, "", "menu_single\n");
mainm->selecteditem = (menuoption_t *)b;
b->common.width = 12*20;
b->common.height = 20;
#endif
b = MC_AddConsoleCommand (mainm, 68, 53, "", "menu_multi\n");
#ifdef CLIENTONLY
mainm->selecteditem = (menuoption_t *)b;
#endif
b->common.width = 12*20;
b->common.height = 20;
b = MC_AddConsoleCommand (mainm, 68, 93, "", "menu_options\n");
@ -1666,7 +1673,7 @@ void M_Menu_Main_f (void)
b->common.width = 12*20;
b->common.height = 20;
mainm->cursoritem = (menuoption_t *)MC_AddCursor(mainm, 42, 13);
mainm->cursoritem = (menuoption_t *)MC_AddCursor(mainm, 42, mainm->selecteditem->common.posy);
}
return;
}

View file

@ -120,7 +120,6 @@ void WinAmp_Think(void)
#endif
void Media_Seek (float time)
{
soundcardinfo_t *sc;
#ifdef WINAMP
if (media_hijackwinamp.value)
{
@ -135,18 +134,7 @@ void Media_Seek (float time)
}
}
#endif
for (sc = sndcardinfo; sc; sc=sc->next)
{
sc->channel[NUM_AMBIENTS].pos += sc->sn.speed*time;
sc->channel[NUM_AMBIENTS].end += sc->sn.speed*time;
if (sc->channel[NUM_AMBIENTS].pos < 0)
{
sc->channel[NUM_AMBIENTS].end -= sc->channel[NUM_AMBIENTS].pos;
sc->channel[NUM_AMBIENTS].pos=0;
}
//if we seek over the end, ignore it. The sound playing code will spot that.
}
S_Music_Seek(time);
}
void Media_FForward_f(void)
@ -226,23 +214,7 @@ qboolean Media_EvaluateNextTrack(void)
//flushes music channel on all soundcards, and the tracks that arn't decoded yet.
void Media_Clear (void)
{
sfx_t *s;
soundcardinfo_t *sc;
for (sc = sndcardinfo; sc; sc=sc->next)
{
sc->channel[NUM_AMBIENTS].end = 0;
s = sc->channel[NUM_AMBIENTS].sfx;
sc->channel[NUM_AMBIENTS].sfx = NULL;
if (s)
if (s->decoder)
if (!S_IsPlayingSomewhere(s)) //if we aint playing it elsewhere, free it compleatly.
{
s->decoder->abort(s);
if (s->cache.data)
Cache_Free(&s->cache);
}
}
S_Music_Clear(NULL);
}
qboolean fakecdactive;
@ -250,6 +222,12 @@ void Media_FakeTrack(int i, qboolean loop)
{
char trackname[512];
if (i > 999 || i < 0)
{
fakecdactive = false;
return;
}
sprintf(trackname, "sound/cdtracks/track%03i.ogg", i);
if (COM_FCheckExists(trackname))
{
@ -259,6 +237,8 @@ void Media_FakeTrack(int i, qboolean loop)
fakecdactive = true;
media_playing = true;
}
else
fakecdactive = false;
}
//actually, this func just flushes and states that it should be playing. the ambientsound func actually changes the track.
@ -414,11 +394,11 @@ void M_Media_Draw (void)
char compleatenamepath[MAX_OSPATH];
char compleatenamename[MAX_OSPATH];
qboolean compleatenamemultiple;
int Com_CompleatenameCallback(char *name, int size, void *data)
int Com_CompleatenameCallback(const char *name, int size, void *data)
{
if (*compleatenamename)
compleatenamemultiple = true;
strcpy(compleatenamename, name);
Q_strncpyz(compleatenamename, name, sizeof(compleatenamename));
return true;
}
@ -727,7 +707,7 @@ void Media_LoadTrackNames (char *listname)
}
//safeprints only.
char *Media_NextTrack(void)
char *Media_NextTrack(int musicchannelnum)
{
#ifdef WINAMP
if (media_hijackwinamp.value)
@ -885,15 +865,6 @@ struct cin_s {
roq_info *roqfilm;
} roq;
sfxcache_t *moviesoundbuffer;
sfx_t mediaaudio;
/* = {
"movieaudio",
{NULL, true},
NULL
};
*/
float filmstarttime;
float nextframetime;
float filmlasttime;
@ -1173,7 +1144,7 @@ qboolean Media_Roq_DecodeFrame (cin_t *cin, qboolean nosound)
cin->outdata = cin->framedata;
if (!nosound)
if (cin->roq.roqfilm->audio_channels && sndcardinfo && cin->roq.roqfilm->aud_pos < cin->roq.roqfilm->vid_pos)
if (cin->roq.roqfilm->audio_channels && S_HaveOutput() && cin->roq.roqfilm->aud_pos < cin->roq.roqfilm->vid_pos)
if (roq_read_audio(cin->roq.roqfilm)>0)
{
/* FILE *f;
@ -1260,10 +1231,6 @@ cin_t *Media_Static_TryLoad(char *name)
char fullname[MAX_QPATH];
qbyte *file;
qbyte *ReadPCXFile(qbyte *buf, int length, int *width, int *height);
qbyte *ReadTargaFile(qbyte *buf, int length, int *width, int *height, int asgrey);
qbyte *ReadJPEGFile(qbyte *infile, int length, int *width, int *height);
qbyte *ReadPNGFile(qbyte *buf, int length, int *width, int *height, char *fname);
sprintf(fullname, "%s", name);
file = COM_LoadMallocFile(fullname); //read file
@ -1563,6 +1530,7 @@ void Media_Gecko_ChangeStream (struct cin_s *cin, char *streamname)
cin_t *Media_Gecko_TryLoad(char *name)
{
char xulprofiledir[MAX_OSPATH];
cin_t *cin;
if (!strncmp(name, "http://", 7))
@ -1585,7 +1553,8 @@ cin_t *Media_Gecko_TryLoad(char *name)
return NULL;
posgk_embedding_options_add_search_path(opts, "./xulrunner/");
posgk_embedding_options_set_profile_dir(opts, va("%s/xulrunner_profile/", com_gamedir), 0);
if (FS_NativePath("xulrunner_profile/", FS_GAMEONLY, 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);
@ -1636,23 +1605,9 @@ qboolean Media_PlayingFullScreen(void)
void Media_ShutdownCin(cin_t *cin)
{
soundcardinfo_t *sc;
sfx_t *s;
if (!cin)
return;
for (sc = sndcardinfo; sc; sc=sc->next)
{
s = sc->channel[NUM_AMBIENTS].sfx;
if (s && s == &cin->mediaaudio)
{
sc->channel[NUM_AMBIENTS].pos = 0;
sc->channel[NUM_AMBIENTS].end = 0;
sc->channel[NUM_AMBIENTS].sfx = NULL;
}
}
if (cin->shutdown)
cin->shutdown(cin);

View file

@ -112,6 +112,7 @@ typedef struct {
menuedit_t *nameedit;
menuedit_t *teamedit;
menuedit_t *skinedit;
menucombo_t *modeledit;
int topcolour;
int lowercolour;
@ -175,6 +176,93 @@ qboolean SetupMenuColour (union menuoption_s *option,struct menu_s *menu, int ke
}
return false;
}
typedef struct {
char **names;
int entries;
int match;
} q2skinsearch_t;
int q2skin_enumerate(const char *name, int fsize, void *parm)
{
char blah[MAX_QPATH];
q2skinsearch_t *s = parm;
COM_StripExtension(name+8, blah, sizeof(blah));
if (strlen(blah) < 2)
return false; //this should never happen
blah[strlen(blah)-2] = 0;
s->names = BZ_Realloc(s->names, ((s->entries+64)&~63) * sizeof(char*));
s->names[s->entries] = BZ_Malloc(strlen(blah)+1);
strcpy(s->names[s->entries], blah);
if (!strcmp(blah, skin.string))
s->match = s->entries;
s->entries++;
return true;
}
void q2skin_destroy(q2skinsearch_t *s)
{
int i;
for (i = 0; i < s->entries; i++)
{
BZ_Free(s->names[i]);
}
BZ_Free(s);
}
qboolean MSetupQ2_ChangeSkin (struct menucustom_s *option,struct menu_s *menu, int key)
{
setupmenu_t *info = menu->data;
q2skinsearch_t *s = Z_Malloc(sizeof(*s));
COM_EnumerateFiles(va("players/%s/*_i.*", info->modeledit->values[info->modeledit->selectedoption]), q2skin_enumerate, s);
if (key == K_ENTER || key == K_RIGHTARROW)
{
s->match ++;
if (s->match>=s->entries)
s->match=0;
}
else if (key == K_LEFTARROW)
{
s->match --;
if (s->match<=0)
s->match=s->entries-1;
}
else
{
q2skin_destroy(s);
return false;
}
if (s->entries)
Cvar_Set(&skin, s->names[s->match]);
S_LocalSound ("misc/menu2.wav");
q2skin_destroy(s);
return true;
}
void MSetupQ2_TransDraw (int x, int y, menucustom_t *option, menu_t *menu)
{
setupmenu_t *info = menu->data;
mpic_t *p;
p = Draw_SafeCachePic (va("players/%s_i", skin.string));
if (!p)
{
q2skinsearch_t *s = Z_Malloc(sizeof(*s));
COM_EnumerateFiles(va("players/%s/*_i.*", info->modeledit->values[info->modeledit->selectedoption]), q2skin_enumerate, s);
if (s->entries)
Cvar_Set(&skin, s->names[rand()%s->entries]);
q2skin_destroy(s);
p = Draw_SafeCachePic (va("players/%s_i", skin.string));
}
if (p)
Draw_TransPic (x-12, y-8, p);
}
void MSetup_TransDraw (int x, int y, menucustom_t *option, menu_t *menu)
{
extern qbyte translationTable[256];
@ -209,9 +297,72 @@ void MSetup_TransDraw (int x, int y, menucustom_t *option, menu_t *menu)
void M_Menu_Setup_f (void)
{
int mgt;
setupmenu_t *info;
menu_t *menu;
mgt = M_GameType();
if (mgt == MGT_QUAKE2) //quake2 main menu.
{
if (Draw_SafeCachePic("pics/m_banner_plauer_setup"))
{
char *modeloptions[] =
{
"male",
"female",
NULL
};
mpic_t *p;
menucustom_t *cu;
m_state = m_complex;
key_dest = key_menu;
menu = M_CreateMenu(sizeof(setupmenu_t));
info = menu->data;
// menu->key = MC_Main_Key;
MC_AddPicture(menu, 0, 4, "pics/m_main_plaque");
p = Draw_SafeCachePic("pics/m_main_logo");
if (!p)
return;
MC_AddPicture(menu, 0, 173, "pics/m_main_logo");
menu->selecteditem = (menuoption_t*)
(info->nameedit = MC_AddEdit(menu, 64, 40, "Your name", name.string));
(info->modeledit = MC_AddCvarCombo(menu, 64, 72, "model", &skin, modeloptions, modeloptions));
info->modeledit->selectedoption = !strncmp(skin.string, "female", 6);
cu = MC_AddCustom(menu, 172-16, 88+16, NULL);
cu->draw = MSetupQ2_TransDraw;
cu->key = MSetupQ2_ChangeSkin;
/* MC_AddSelectablePicture(mainm, 68, 13, "pics/m_main_game");
MC_AddSelectablePicture(mainm, 68, 53, "pics/m_main_multiplayer");
MC_AddSelectablePicture(mainm, 68, 93, "pics/m_main_options");
MC_AddSelectablePicture(mainm, 68, 133, "pics/m_main_video");
MC_AddSelectablePicture(mainm, 68, 173, "pics/m_main_quit");
b = MC_AddConsoleCommand (mainm, 68, 13, "", "menu_single\n");
mainm->selecteditem = (menuoption_t *)b;
b->common.width = 12*20;
b->common.height = 20;
b = MC_AddConsoleCommand (mainm, 68, 53, "", "menu_multi\n");
b->common.width = 12*20;
b->common.height = 20;
b = MC_AddConsoleCommand (mainm, 68, 93, "", "menu_options\n");
b->common.width = 12*20;
b->common.height = 20;
b = MC_AddConsoleCommand (mainm, 68, 133, "", "menu_video\n");
b->common.width = 12*20;
b->common.height = 20;
b = MC_AddConsoleCommand (mainm, 68, 173, "", "menu_quit\n");
b->common.width = 12*20;
b->common.height = 20;
*/
menu->cursoritem = (menuoption_t*)MC_AddWhiteText(menu, 54, 32, NULL, false);
}
return;
}
key_dest = key_menu;
m_state = m_complex;

View file

@ -165,6 +165,7 @@ void M_Audio_StartSound (struct menu_s *menu)
vec3_t org;
audiomenuinfo_t *info = menu->data;
soundcardinfo_t *sc;
vec3_t mat[4];
static float lasttime;
@ -189,10 +190,12 @@ void M_Audio_StartSound (struct menu_s *menu)
if (lasttime+0.5 < Sys_DoubleTime())
{
S_GetListenerInfo(mat[0], mat[1], mat[2], mat[3]);
lasttime = Sys_DoubleTime();
org[0] = listener_origin[0] + 2*(listener_right[0]*(info->testsoundsource->common.posx-320/2) + listener_forward[0]*(info->testsoundsource->common.posy-200/2));
org[1] = listener_origin[1] + 2*(listener_right[1]*(info->testsoundsource->common.posx-320/2) + listener_forward[1]*(info->testsoundsource->common.posy-200/2));
org[2] = listener_origin[2] + 2*(listener_right[2]*(info->testsoundsource->common.posx-320/2) + listener_forward[2]*(info->testsoundsource->common.posy-200/2));
org[0] = mat[0][0] + 2*(mat[1][0]*(info->testsoundsource->common.posx-320/2) + mat[1][0]*(info->testsoundsource->common.posy-200/2));
org[1] = mat[0][1] + 2*(mat[1][1]*(info->testsoundsource->common.posx-320/2) + mat[1][1]*(info->testsoundsource->common.posy-200/2));
org[2] = mat[0][2] + 2*(mat[1][2]*(info->testsoundsource->common.posx-320/2) + mat[1][2]*(info->testsoundsource->common.posy-200/2));
S_StartSound(-2, 0, S_PrecacheSound("player/pain3.wav"), org, 1, 4);
}
}

View file

@ -223,10 +223,10 @@ void M_Menu_SinglePlayer_f (void)
else
{
#ifdef CLIENTONLY
MC_AddBox (menu, 60, 10*8, 23, 4);
MC_AddWhiteText(menu, 92, 12*8, "QuakeWorld is for", false);
MC_AddWhiteText(menu, 92, 13*8, "Internet play only", false);
MC_AddBox (menu, 60, 10*8, 23, 4);
#else
MC_AddPicture(menu, 72, 32, "gfx/sp_menu.lmp");
@ -384,7 +384,7 @@ static qboolean M_DemoKey(menucustom_t *control, menu_t *menu, int key)
return false;
}
static int DemoAddItem(char *filename, int size, void *parm)
static int DemoAddItem(const char *filename, int size, void *parm)
{
int extnum;
demomenu_t *menu = parm;

View file

@ -843,26 +843,31 @@ void M_Menu_Quit_f (void)
{
int i;
if (1)
{
CL_Disconnect ();
Sys_Quit ();
}
else
{
key_dest = key_menu;
m_state = m_complex;
key_dest = key_menu;
m_state = m_complex;
M_RemoveMenu(&quitmenu);
memset(&quitmenu, 0, sizeof(quitmenu));
M_AddMenuFront(&quitmenu);
quitmenu.exclusive = false;
quitmenu.key = MC_Quit_Key;
M_RemoveMenu(&quitmenu);
memset(&quitmenu, 0, sizeof(quitmenu));
M_AddMenuFront(&quitmenu);
quitmenu.exclusive = false;
quitmenu.key = MC_Quit_Key;
i = rand()&7;
i = rand()&7;
MC_AddWhiteText(&quitmenu, 64, 84, quitMessage[i*4+0], false);
MC_AddWhiteText(&quitmenu, 64, 92, quitMessage[i*4+1], false);
MC_AddWhiteText(&quitmenu, 64, 100, quitMessage[i*4+2], false);
MC_AddWhiteText(&quitmenu, 64, 108, quitMessage[i*4+3], false);
MC_AddBox (&quitmenu, 56, 76, 24, 4);
MC_AddWhiteText(&quitmenu, 64, 84, quitMessage[i*4+0], false);
MC_AddWhiteText(&quitmenu, 64, 92, quitMessage[i*4+1], false);
MC_AddWhiteText(&quitmenu, 64, 100, quitMessage[i*4+2], false);
MC_AddWhiteText(&quitmenu, 64, 108, quitMessage[i*4+3], false);
MC_AddBox (&quitmenu, 56, 76, 24, 4);
}
}
//=============================================================================

View file

@ -133,6 +133,7 @@ extern void FNC(Mod_NowLoadExternal) (void);
extern void FNC(Mod_Think) (void);
extern int FNC(Mod_SkinForName) (struct model_s *model, char *name);
extern int FNC(Mod_FrameForName) (struct model_s *model, char *name);
#undef FNC
@ -221,6 +222,7 @@ typedef struct {
qboolean (*Mod_GetTag) (struct model_s *model, int tagnum, framestate_t *fstate, float *result);
int (*Mod_TagNumForName) (struct model_s *model, char *name);
int (*Mod_SkinForName) (struct model_s *model, char *name);
int (*Mod_FrameForName) (struct model_s *model, char *name);
qboolean (*VID_Init) (rendererstate_t *info, unsigned char *palette);

View file

@ -37,7 +37,7 @@ typedef int SOCKET;
cvar_t slist_cacheinfo = SCVAR("slist_cacheinfo", "0"); //this proves dangerous, memory wise.
cvar_t slist_writeserverstxt = SCVAR("slist_writeservers", "0");
void CL_MasterListParse(int type, qboolean slashpad);
void CL_MasterListParse(netadrtype_t adrtype, int type, qboolean slashpad);
void CL_QueryServers(void);
int CL_ReadServerInfo(char *msg, int servertype, qboolean favorite);
@ -83,27 +83,34 @@ int slist_customkeys;
#endif
#define POLLUDPSOCKETS 64 //it's big so we can have lots of messages when behind a firewall. Basically if a firewall only allows replys, and only remembers 3 servers per socket, we need this big cos it can take a while for a packet to find a fast optimised route and we might be waiting for a few secs for a reply the first time around.
SOCKET pollsocketsUDP[POLLUDPSOCKETS];
int lastpollsockUDP;
#define POLLUDP4SOCKETS 64 //it's big so we can have lots of messages when behind a firewall. Basically if a firewall only allows replys, and only remembers 3 servers per socket, we need this big cos it can take a while for a packet to find a fast optimised route and we might be waiting for a few secs for a reply the first time around.
int lastpollsockUDP4;
#ifdef IPPROTO_IPV6
#define POLLUDP6SOCKETS 4 //it's non-zero so we can have lots of messages when behind a firewall. Basically if a firewall only allows replys, and only remembers 3 servers per socket, we need this big cos it can take a while for a packet to find a fast optimised route and we might be waiting for a few secs for a reply the first time around.
int lastpollsockUDP6;
#else
#define POLLUDP6SOCKETS 0
#endif
#ifdef USEIPX
#define POLLIPXSOCKETS 2 //ipx isn't used as much. In fact, we only expect local servers to be using it. I'm not sure why I implemented it anyway.
SOCKET pollsocketsIPX[POLLIPXSOCKETS];
#define POLLIPXSOCKETS 2 //ipx isn't used as much. In fact, we only expect local servers to be using it. I'm not sure why I implemented it anyway. You might see a q2 server using it. Rarely.
int lastpollsockIPX;
#else
#define POLLIPXSOCKETS 0
#endif
#define FIRSTIPXSOCKET (0)
#define FIRSTUDP4SOCKET (FIRSTIPXSOCKET+POLLIPXSOCKETS)
#define FIRSTUDP6SOCKET (FIRSTUDP4SOCKET+POLLUDP4SOCKETS)
#define POLLTOTALSOCKETS (FIRSTUDP6SOCKET+POLLUDP6SOCKETS)
SOCKET pollsocketsList[POLLTOTALSOCKETS];
void Master_SetupSockets(void)
{
int i;
for (i = 0; i < POLLUDPSOCKETS; i++)
pollsocketsUDP[i] = INVALID_SOCKET;
#ifdef USEIPX
for (i = 0; i < POLLIPXSOCKETS; i++)
pollsocketsIPX[i] = INVALID_SOCKET;
#endif
for (i = 0; i < POLLTOTALSOCKETS; i++)
pollsocketsList[i] = INVALID_SOCKET;
}
void Master_HideServer(serverinfo_t *server)
@ -587,6 +594,8 @@ void Master_AddMaster (char *address, int type, char *description)
adr.type = NA_BROADCAST_IP;
if (adr.type == NA_IPX)
adr.type = NA_BROADCAST_IPX;
if (adr.type == NA_IPV6)
adr.type = NA_BROADCAST_IP6;
}
for (mast = master; mast; mast = mast->next)
@ -785,24 +794,38 @@ void NET_SendPollPacket(int len, void *data, netadr_t to)
lastpollsockIPX++;
if (lastpollsockIPX>=POLLIPXSOCKETS)
lastpollsockIPX=0;
if (pollsocketsIPX[lastpollsockIPX]==INVALID_SOCKET)
pollsocketsIPX[lastpollsockIPX] = IPX_OpenSocket(PORT_ANY, true);
if (pollsocketsIPX[lastpollsockIPX]==INVALID_SOCKET)
if (pollsocketsList[FIRSTIPXSOCKET+lastpollsockIPX]==INVALID_SOCKET)
pollsocketsList[FIRSTIPXSOCKET+lastpollsockIPX] = IPX_OpenSocket(PORT_ANY, true);
if (pollsocketsList[FIRSTIPXSOCKET+lastpollsockIPX]==INVALID_SOCKET)
return; //bother
ret = sendto (pollsocketsIPX[lastpollsockIPX], data, len, 0, (struct sockaddr *)&addr, sizeof(addr) );
ret = sendto (pollsocketsList[FIRSTIPXSOCKET+lastpollsockIPX], data, len, 0, (struct sockaddr *)&addr, sizeof(addr) );
}
else
#endif
#ifdef IPPROTO_IPV6
if (((struct sockaddr*)&addr)->sa_family == AF_INET6)
{
lastpollsockUDP6++;
if (lastpollsockUDP6>=POLLUDP6SOCKETS)
lastpollsockUDP6=0;
if (pollsocketsList[FIRSTUDP6SOCKET+lastpollsockUDP6]==INVALID_SOCKET)
pollsocketsList[FIRSTUDP6SOCKET+lastpollsockUDP6] = UDP6_OpenSocket(PORT_ANY, true);
if (pollsocketsList[FIRSTUDP6SOCKET+lastpollsockUDP6]==INVALID_SOCKET)
return; //bother
ret = sendto (pollsocketsList[FIRSTUDP6SOCKET+lastpollsockUDP6], data, len, 0, (struct sockaddr *)&addr, sizeof(addr) );
}
else
#endif
if (((struct sockaddr*)&addr)->sa_family == AF_INET)
{
lastpollsockUDP++;
if (lastpollsockUDP>=POLLUDPSOCKETS)
lastpollsockUDP=0;
if (pollsocketsUDP[lastpollsockUDP]==INVALID_SOCKET)
pollsocketsUDP[lastpollsockUDP] = UDP_OpenSocket(PORT_ANY, true);
if (pollsocketsUDP[lastpollsockUDP]==INVALID_SOCKET)
lastpollsockUDP4++;
if (lastpollsockUDP4>=POLLUDP4SOCKETS)
lastpollsockUDP4=0;
if (pollsocketsList[FIRSTUDP4SOCKET+lastpollsockUDP4]==INVALID_SOCKET)
pollsocketsList[FIRSTUDP4SOCKET+lastpollsockUDP4] = UDP_OpenSocket(PORT_ANY, true);
if (pollsocketsList[FIRSTUDP4SOCKET+lastpollsockUDP4]==INVALID_SOCKET)
return; //bother
ret = sendto (pollsocketsUDP[lastpollsockUDP], data, len, 0, (struct sockaddr *)&addr, sizeof(struct sockaddr_in) );
ret = sendto (pollsocketsList[FIRSTUDP4SOCKET+lastpollsockUDP4], data, len, 0, (struct sockaddr *)&addr, sizeof(struct sockaddr_in) );
}
else
return;
@ -831,18 +854,13 @@ int NET_CheckPollSockets(void)
SOCKET usesocket;
char adr[MAX_ADR_SIZE];
for (sock = 0; sock < POLLUDPSOCKETS+POLLIPXSOCKETS; sock++)
for (sock = 0; sock < POLLTOTALSOCKETS; sock++)
{
int ret;
struct sockaddr_qstorage from;
int fromlen;
#ifdef USEIPX
if (sock >= POLLUDPSOCKETS)
usesocket = pollsocketsIPX[sock-POLLUDPSOCKETS];
else
#endif
usesocket = pollsocketsUDP[sock];
usesocket = pollsocketsList[sock];
if (usesocket == INVALID_SOCKET)
continue;
@ -900,10 +918,18 @@ int NET_CheckPollSockets(void)
CL_ReadServerInfo(MSG_ReadString(), MT_SINGLEQ2, false);
continue;
}
if (!strncmp(s, "servers", 6)) //parse a bit more...
#ifdef IPPROTO_IPV6
if (!strncmp(s, "server6", 7)) //parse a bit more...
{
msg_readcount = c+7;
CL_MasterListParse(SS_QUAKE2, false);
CL_MasterListParse(NA_IPV6, SS_QUAKE2, false);
continue;
}
#endif
if (!strncmp(s, "servers", 7)) //parse a bit more...
{
msg_readcount = c+7;
CL_MasterListParse(NA_IP, SS_QUAKE2, false);
continue;
}
#endif
@ -915,10 +941,18 @@ int NET_CheckPollSockets(void)
}
#endif
#ifdef IPPROTO_IPV6
if (!strncmp(s, "getserversResponse6\\", 20)) //parse a bit more...
{
msg_readcount = c+19-1;
CL_MasterListParse(NA_IPV6, SS_DARKPLACES, true);
continue;
}
#endif
if (!strncmp(s, "getserversResponse\\", 19)) //parse a bit more...
{
msg_readcount = c+18-1;
CL_MasterListParse(SS_DARKPLACES, true);
CL_MasterListParse(NA_IP, SS_DARKPLACES, true);
continue;
}
if (!strcmp(s, "infoResponse")) //parse a bit more...
@ -926,6 +960,16 @@ int NET_CheckPollSockets(void)
CL_ReadServerInfo(MSG_ReadString(), MT_SINGLEDP, false);
continue;
}
#ifdef IPPROTO_IPV6
if (!strncmp(s, "qw_slist6\\", 10)) //parse a bit more...
{
msg_readcount = c+9-1;
CL_MasterListParse(NA_IPV6, SS_GENERICQUAKEWORLD, false);
continue;
}
#endif
msg_readcount = c;
c = MSG_ReadByte ();
@ -938,7 +982,7 @@ int NET_CheckPollSockets(void)
if (c == M2C_MASTER_REPLY) //qw master reply.
{
CL_MasterListParse(false, false);
CL_MasterListParse(NA_IP, SS_GENERICQUAKEWORLD, false);
continue;
}
}
@ -976,7 +1020,7 @@ int NET_CheckPollSockets(void)
// Q_strcat(name, name);
}
CL_ReadServerInfo(va("\\hostname\\%s\\map\\%s\\maxclients\\%i", name, map, maxusers), MT_SINGLENQ, false);
CL_ReadServerInfo(va("\\hostname\\%s\\map\\%s\\maxclients\\%i\\clients\\%i", name, map, maxusers, users), MT_SINGLENQ, false);
}
#endif
continue;
@ -1196,10 +1240,10 @@ void MasterInfo_WriteServers(void)
char *typename;
master_t *mast;
serverinfo_t *server;
FILE *mf, *qws;
vfsfile_t *mf, *qws;
char adr[MAX_ADR_SIZE];
mf = fopen("masters.txt", "wt");
mf = FS_OpenVFS("masters.txt", "wt", FS_ROOT);
if (!mf)
{
Con_Printf("Couldn't write masters.txt");
@ -1259,40 +1303,40 @@ void MasterInfo_WriteServers(void)
typename = "writeerror";
}
if (mast->address)
fprintf(mf, "%s\t%s\t%s\n", mast->address , typename, mast->name);
VFS_PUTS(mf, va("%s\t%s\t%s\n", mast->address , typename, mast->name));
else
fprintf(mf, "%s\t%s\t%s\n", NET_AdrToString(adr, sizeof(adr), mast->adr), typename, mast->name);
VFS_PUTS(mf, va("%s\t%s\t%s\n", NET_AdrToString(adr, sizeof(adr), mast->adr), typename, mast->name));
}
if (slist_writeserverstxt.value)
qws = fopen("servers.txt", "wt");
qws = FS_OpenVFS("servers.txt", "wt", FS_ROOT);
else
qws = NULL;
if (qws)
fprintf(mf, "\n%s\t%s\t%s\n\n", "file servers.txt", "favorite:qw", "personal server list");
VFS_PUTS(mf, va("\n%s\t%s\t%s\n\n", "file servers.txt", "favorite:qw", "personal server list"));
for (server = firstserver; server; server = server->next)
{
if (server->special & SS_FAVORITE)
{
if (server->special & SS_QUAKE3)
fprintf(mf, "%s\t%s\t%s\n", NET_AdrToString(adr, sizeof(adr), server->adr), "favorite:q3", server->name);
VFS_PUTS(mf, va("%s\t%s\t%s\n", NET_AdrToString(adr, sizeof(adr), server->adr), "favorite:q3", server->name));
else if (server->special & SS_QUAKE2)
fprintf(mf, "%s\t%s\t%s\n", NET_AdrToString(adr, sizeof(adr), server->adr), "favorite:q2", server->name);
VFS_PUTS(mf, va("%s\t%s\t%s\n", NET_AdrToString(adr, sizeof(adr), server->adr), "favorite:q2", server->name));
else if (server->special & SS_NETQUAKE)
fprintf(mf, "%s\t%s\t%s\n", NET_AdrToString(adr, sizeof(adr), server->adr), "favorite:nq", server->name);
VFS_PUTS(mf, va("%s\t%s\t%s\n", NET_AdrToString(adr, sizeof(adr), server->adr), "favorite:nq", server->name));
else if (qws) //servers.txt doesn't support the extra info.
fprintf(qws, "%s\t%s\n", NET_AdrToString(adr, sizeof(adr), server->adr), server->name);
VFS_PUTS(qws, va("%s\t%s\n", NET_AdrToString(adr, sizeof(adr), server->adr), server->name));
else //read only? damn them!
fprintf(mf, "%s\t%s\t%s\n", NET_AdrToString(adr, sizeof(adr), server->adr), "favorite:qw", server->name);
VFS_PUTS(mf, va("%s\t%s\t%s\n", NET_AdrToString(adr, sizeof(adr), server->adr), "favorite:qw", server->name));
}
}
if (qws)
fclose(qws);
VFS_CLOSE(qws);
fclose(mf);
VFS_CLOSE(mf);
}
//poll master servers for server lists.
@ -1758,19 +1802,36 @@ int CL_ReadServerInfo(char *msg, int servertype, qboolean favorite)
}
//rewrite to scan for existing server instead of wiping all.
void CL_MasterListParse(int type, qboolean slashpad)
void CL_MasterListParse(netadrtype_t adrtype, int type, qboolean slashpad)
{
serverinfo_t *info;
serverinfo_t *last, *old;
int adrlen;
int p1, p2;
char adr[MAX_ADR_SIZE];
int i;
switch(adrtype)
{
case NA_IP:
adrlen = 4;
break;
case NA_IPV6:
adrlen = 16;
break;
case NA_IPX:
adrlen = 10;
break;
default:
return;
}
MSG_ReadByte ();
last = firstserver;
while(msg_readcount+6 < net_message.cursize)
while(msg_readcount+adrlen+2 < net_message.cursize)
{
if (slashpad)
{
@ -1779,11 +1840,17 @@ void CL_MasterListParse(int type, qboolean slashpad)
}
info = Z_Malloc(sizeof(serverinfo_t));
info->adr.type = NA_IP;
info->adr.address.ip[0] = MSG_ReadByte();
info->adr.address.ip[1] = MSG_ReadByte();
info->adr.address.ip[2] = MSG_ReadByte();
info->adr.address.ip[3] = MSG_ReadByte();
info->adr.type = adrtype;
switch(adrtype)
{
case NA_IP:
case NA_IPV6:
case NA_IPX:
//generic fixed-length addresses
for (i = 0; i < adrlen; i++)
((qbyte *)&info->adr.address)[i] = MSG_ReadByte();
break;
}
p1 = MSG_ReadByte();
p2 = MSG_ReadByte();

View file

@ -186,6 +186,19 @@ static void PClassic_ClearParticles (void)
particles[r_numparticles - 1].next = NULL;
}
#define USEARRAYS
#define BUFFERVERTS 2048*3
vec3_t classicverts[BUFFERVERTS];
union c
{
byte_vec4_t b;
unsigned int i;
} classiccolours[BUFFERVERTS];
vec2_t classictexcoords[BUFFERVERTS];
int classicnumverts;
int setuptexcoords;
//draws all the active particles.
static void PClassic_DrawParticles(void)
{
@ -198,6 +211,8 @@ static void PClassic_DrawParticles(void)
unsigned char *at, theAlpha;
vec3_t up, right;
float dist, scale, r_partscale=0;
union c usecolours;
#endif
if (!active_particles)
@ -218,10 +233,32 @@ static void PClassic_DrawParticles(void)
if (!gl_solidparticles.value)
qglDepthMask (GL_FALSE);
qglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
#ifdef USEARRAYS
if (!setuptexcoords)
{
setuptexcoords = true;
for (i = 0; i < BUFFERVERTS; i += 3)
{
classictexcoords[i+1][0] = 1;
classictexcoords[i+2][1] = 1;
}
}
qglTexCoordPointer(2, GL_FLOAT, 0, classictexcoords);
qglVertexPointer(3, GL_FLOAT, 0, classicverts);
qglColorPointer(4, GL_UNSIGNED_BYTE, 0, classiccolours);
qglEnableClientState(GL_TEXTURE_COORD_ARRAY);
qglEnableClientState(GL_COLOR_ARRAY);
qglEnableClientState(GL_VERTEX_ARRAY);
#else
qglBegin (GL_TRIANGLES);
#endif
VectorScale (vup, 1.5, up);
VectorScale (vright, 1.5, right);
classicnumverts = 0;
break;
#endif
#ifdef SWQUAKE
@ -277,10 +314,36 @@ static void PClassic_DrawParticles(void)
{
#ifdef RGLQUAKE
case QR_OPENGL:
#ifdef USEARRAYS
if (classicnumverts >= BUFFERVERTS-3)
{
qglDrawArrays(GL_TRIANGLES, 0, classicnumverts);
classicnumverts = 0;
}
#endif
// hack a scale up to keep particles from disapearing
dist = (p->org[0] - r_origin[0]) * vpn[0] + (p->org[1] - r_origin[1]) * vpn[1] + (p->org[2] - r_origin[2]) * vpn[2];
scale = 1 + dist * r_partscale;
#ifdef USEARRAYS
usecolours.i = d_8to24rgbtable[(int)p->color];
if (p->type == pt_fire)
usecolours.b[3] = 255 * (6 - p->ramp) / 6;
else
usecolours.b[3] = 255;
classiccolours[classicnumverts].i = usecolours.i;
VectorCopy(p->org, classicverts[classicnumverts]);
classicnumverts++;
classiccolours[classicnumverts].i = usecolours.i;
VectorMA(p->org, scale, up, classicverts[classicnumverts]);
classicnumverts++;
classiccolours[classicnumverts].i = usecolours.i;
VectorMA(p->org, scale, right, classicverts[classicnumverts]);
classicnumverts++;
#else
at = (qbyte *) &d_8to24rgbtable[(int)p->color];
if (p->type == pt_fire)
theAlpha = 255 * (6 - p->ramp) / 6;
@ -290,6 +353,7 @@ static void PClassic_DrawParticles(void)
qglTexCoord2f (0, 0); qglVertex3fv (p->org);
qglTexCoord2f (1, 0); qglVertex3f (p->org[0] + up[0] * scale, p->org[1] + up[1] * scale, p->org[2] + up[2] * scale);
qglTexCoord2f (0, 1); qglVertex3f (p->org[0] + right[0] * scale, p->org[1] + right[1] * scale, p->org[2] + right[2] * scale);
#endif
break;
#endif
#ifdef SWQUAKE
@ -356,7 +420,15 @@ static void PClassic_DrawParticles(void)
{
#ifdef RGLQUAKE
case QR_OPENGL:
#ifdef USEARRAYS
if (classicnumverts)
{
qglDrawArrays(GL_TRIANGLES, 0, classicnumverts);
classicnumverts = 0;
}
#else
qglEnd ();
#endif
qglDisable (GL_BLEND);
qglDepthMask (GL_TRUE);
qglTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);

View file

@ -53,6 +53,7 @@ static int num_csqc_edicts;
static int csqc_fakereadbyte;
static int csqc_lplayernum;
static qboolean csqc_isdarkplaces;
#define CSQCPROGSGROUP "CSQC progs control"
cvar_t pr_csmaxedicts = SCVAR("pr_csmaxedicts", "3072");
@ -140,8 +141,6 @@ typedef enum
\
globalfunction(ent_update, "CSQC_Ent_Update"); \
globalfunction(ent_remove, "CSQC_Ent_Remove"); \
globalfunction(delta_update, "CSQC_Delta_Update");/*EXT_CSQC_1*/ \
globalfunction(delta_remove, "CSQC_Delta_Remove");/*EXT_CSQC_1*/ \
\
globalfunction(event_sound, "CSQC_Event_Sound"); \
globalfunction(serversound, "CSQC_ServerSound");/*obsolete, use event_sound*/ \
@ -698,8 +697,11 @@ static void cs_getframestate(csqcedict_t *in, unsigned int rflags, framestate_t
out->g[FST_BASE].endbone = in->v->basebone;
if (out->g[FST_BASE].endbone)
{ //small optimisation.
out->g[FST_BASE].endbone -= 1;
out->g[FST_BASE].frame[0] = in->v->baseframe;
out->g[FST_BASE].frame[1] = in->v->baseframe2;
out->g[FST_BASE].lerpfrac = in->v->baselerpfrac;
if (rflags & CSQCRF_FRAMETIMESARESTARTTIMES)
{
out->g[FST_BASE].frametime[0] = *csqcg.svtime - in->v->baseframe1time;
@ -710,7 +712,6 @@ static void cs_getframestate(csqcedict_t *in, unsigned int rflags, framestate_t
out->g[FST_BASE].frametime[0] = in->v->baseframe1time;
out->g[FST_BASE].frametime[1] = in->v->baseframe2time;
}
out->g[FST_BASE].lerpfrac = in->v->baselerpfrac;
}
//and the normal frames.
@ -928,10 +929,15 @@ static qboolean CopyCSQCEdictToEntity(csqcedict_t *in, entity_t *out)
AngleVectors(out->angles, out->axis[0], out->axis[1], out->axis[2]);
VectorInverse(out->axis[1]);
if (!in->v->scale)
if (!in->v->scale || in->v->scale == 1.0f)
out->scale = 1;
else
{
VectorScale(out->axis[0], in->v->scale, out->axis[0]);
VectorScale(out->axis[1], in->v->scale, out->axis[1]);
VectorScale(out->axis[2], in->v->scale, out->axis[2]);
out->scale = in->v->scale;
}
}
if (in->v->colormap > 0 && in->v->colormap <= MAX_CLIENTS)
@ -1032,6 +1038,16 @@ static void PF_R_AddEntityMask(progfuncs_t *prinst, struct globalvars_s *pr_glob
int e;
int oldself = *csqcg.self;
if (cl.worldmodel)
{
if (mask & MASK_DELTA)
{
CL_LinkPlayers ();
CL_LinkPacketEntities ();
}
}
for (e=1; e < *prinst->parms->sv_num_edicts; e++)
{
ent = (void*)EDICT_NUM(prinst, e);
@ -1061,13 +1077,8 @@ static void PF_R_AddEntityMask(progfuncs_t *prinst, struct globalvars_s *pr_glob
{
CL_LinkViewModel ();
}
if (mask & MASK_DELTA)
{
CL_LinkPlayers ();
CL_LinkPacketEntities ();
CL_LinkProjectiles ();
CL_UpdateTEnts ();
}
CL_LinkProjectiles ();
CL_UpdateTEnts ();
}
}
@ -1990,11 +2001,22 @@ static void PF_cs_pointparticles (progfuncs_t *prinst, struct globalvars_s *pr_g
static void PF_cs_trailparticles (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
int efnum = G_FLOAT(OFS_PARM0)-1;
csqcedict_t *ent = (csqcedict_t*)G_EDICT(prinst, OFS_PARM1);
int efnum;
csqcedict_t *ent;
float *start = G_VECTOR(OFS_PARM2);
float *end = G_VECTOR(OFS_PARM3);
if (csqc_isdarkplaces)
{
efnum = G_FLOAT(OFS_PARM1)-1;
ent = (csqcedict_t*)G_EDICT(prinst, OFS_PARM0);
}
else
{
efnum = G_FLOAT(OFS_PARM0)-1;
ent = (csqcedict_t*)G_EDICT(prinst, OFS_PARM1);
}
if (!ent->entnum) //world trails are non-state-based.
pe->ParticleTrail(start, end, efnum, NULL);
else
@ -3071,7 +3093,7 @@ static void PF_cs_addprogs (progfuncs_t *prinst, struct globalvars_s *pr_globals
static void PF_cs_OpenPortal (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
#ifdef Q2BSPS
if (sv.worldmodel->fromgame == fg_quake2)
if (cl.worldmodel->fromgame == fg_quake2)
CMQ2_SetAreaPortalState(G_FLOAT(OFS_PARM0), G_FLOAT(OFS_PARM1));
#endif
}
@ -3409,6 +3431,17 @@ static void PF_rotatevectorsbymatrix (progfuncs_t *prinst, struct globalvars_s *
VectorNegate(res[1], csqcg.right);
VectorCopy(res[2], csqcg.up);
}
static void PF_frameforname (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
int modelindex = G_FLOAT(OFS_PARM0);
char *str = PF_VarString(prinst, 1, pr_globals);
model_t *mod = CSQC_GetModelForIndex(modelindex);
if (mod && Mod_FrameForName)
G_FLOAT(OFS_RETURN) = Mod_FrameForName(mod, str);
else
G_FLOAT(OFS_RETURN) = -1;
}
static void PF_skinforname (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
int modelindex = G_FLOAT(OFS_PARM0);
@ -3416,7 +3449,7 @@ static void PF_skinforname (progfuncs_t *prinst, struct globalvars_s *pr_globals
model_t *mod = CSQC_GetModelForIndex(modelindex);
if (Mod_SkinForName)
if (mod && Mod_SkinForName)
G_FLOAT(OFS_RETURN) = Mod_SkinForName(mod, str);
else
G_FLOAT(OFS_RETURN) = -1;
@ -4066,25 +4099,356 @@ static void PF_cs_setlistener (progfuncs_t *prinst, struct globalvars_s *pr_glob
float *right = G_VECTOR(OFS_PARM2);
float *up = G_VECTOR(OFS_PARM3);
csqc_usinglistener = true;
S_Update(origin, forward, right, up);
S_UpdateListener(origin, forward, right, up, false);
}
typedef struct oldcsqcpack_s
{
unsigned int numents;
unsigned int maxents;
unsigned short *entnum;
csqcedict_t **entptr;
} oldcsqcpack_t;
static oldcsqcpack_t loadedcsqcpack[2];
static int loadedcsqcpacknum;
static csqcedict_t *deltaedplayerents[MAX_CLIENTS];
#define RSES_NOLERP 1
#define RSES_NOROTATE 2
#define RSES_NOTRAILS 4
#define RSES_NOLIGHTS 8
void CSQC_EntStateToCSQC(unsigned int flags, float lerptime, entity_state_t *src, csqcedict_t *ent)
{
model_t *model;
lerpents_t *le;
le = &cl.lerpents[src->number];
//frames needs special handling
ent->v->frame = src->frame;
ent->v->frame2 = le->frame;
if (le->framechange == le->oldframechange)
ent->v->lerpfrac = 0;
else
{
ent->v->lerpfrac = 1-(lerptime - le->framechange) / (le->framechange - le->oldframechange);
if (ent->v->lerpfrac > 1)
ent->v->lerpfrac = 1;
else if (ent->v->lerpfrac < 0)
{
ent->v->lerpfrac = 0;
}
}
model = cl.model_precache[src->modelindex];
if (!(flags & RSES_NOTRAILS))
{
//use entnum as a test to see if its new (if the old origin isn't usable)
if (ent->v->entnum && model->particletrail >= 0)
{
if (pe->ParticleTrail (ent->v->origin, src->origin, model->particletrail, &(le->trailstate)))
pe->ParticleTrailIndex(ent->v->origin, src->origin, model->traildefaultindex, 0, &(le->trailstate));
}
}
ent->v->entnum = src->number;
ent->v->modelindex = src->modelindex;
// ent->v->bitmask = src->bitmask;
ent->v->flags = src->flags;
// ent->v->effects = src->effects;
ent->v->origin[0] = src->origin[0];
ent->v->origin[1] = src->origin[1];
ent->v->origin[2] = src->origin[2];
ent->v->angles[0] = src->angles[0];
ent->v->angles[1] = src->angles[1];
ent->v->angles[2] = src->angles[2];
//we ignore the q2 state fields
ent->v->colormap = src->colormap;
ent->v->skin = src->skinnum;
// ent->v->glowsize = src->glowsize;
// ent->v->glowcolor = src->glowcolour;
ent->v->scale = src->scale/16.0f;
ent->v->fatness = src->fatness/16.0f;
// ent->v->hexen2flags = src->hexen2flags;
// ent->v->abslight = src->abslight;
// ent->v->dpflags = src->dpflags;
// ent->v->colormod[0] = (src->colormod[0]/255.0f)*8;
// ent->v->colormod[1] = (src->colormod[1]/255.0f)*8;
// ent->v->colormod[2] = (src->colormod[2]/255.0f)*8;
ent->v->alpha = src->trans/255.0f;
// ent->v->lightstyle = src->lightstyle;
// ent->v->lightpflags = src->lightpflags;
// ent->v->solid = src->solid;
// ent->v->light[0] = src->light[0];
// ent->v->light[1] = src->light[1];
// ent->v->light[2] = src->light[2];
// ent->v->light[3] = src->light[3];
// ent->v->tagentity = src->tagentity;
// ent->v->tagindex = src->tagindex;
if (model)
{
if (!(flags & RSES_NOROTATE) && (model->flags & EF_ROTATE))
{
ent->v->angles[0] = 0;
ent->v->angles[1] = 100*lerptime;
ent->v->angles[2] = 0;
}
}
}
void CSQC_PlayerStateToCSQC(int pnum, player_state_t *srcp, csqcedict_t *ent)
{
ent->v->entnum = pnum+1;
if (cl.spectator && !Cam_DrawPlayer(0, pnum))
{
ent->v->modelindex = 0;
}
else
ent->v->modelindex = srcp->modelindex;
ent->v->skin = srcp->skinnum;
ent->v->frame1time = cl.time - cl.lerpplayers[pnum].framechange;
ent->v->frame2time = cl.time - cl.lerpplayers[pnum].oldframechange;
if (ent->v->frame != cl.lerpplayers[pnum].frame)
{
ent->v->frame2 = ent->v->frame;
ent->v->frame = cl.lerpplayers[pnum].frame;
}
ent->v->lerpfrac = 1-(realtime - cl.lerpplayers[pnum].framechange)*10;
if (ent->v->lerpfrac > 1)
ent->v->lerpfrac = 1;
else if (ent->v->lerpfrac < 0)
{
ent->v->lerpfrac = 0;
}
VectorCopy(srcp->origin, ent->v->origin);
VectorCopy(srcp->velocity, ent->v->velocity);
VectorCopy(srcp->viewangles, ent->v->angles);
ent->v->angles[0] *= -0.333;
ent->v->colormap = pnum+1;
ent->v->scale = srcp->scale/16.0f;
//ent->v->fatness = srcp->fatness;
ent->v->alpha = srcp->alpha/255.0f;
// ent->v->colormod[0] = (srcp->colormod[0]/255.0f)*8;
// ent->v->colormod[1] = (srcp->colormod[1]/255.0f)*8;
// ent->v->colormod[2] = (srcp->colormod[2]/255.0f)*8;
// ent->v->effects = srcp->effects;
}
unsigned int deltaflags[MAX_MODELS];
func_t deltafunction[MAX_MODELS];
typedef struct
{
unsigned int readpos; //pos
unsigned int numents; //present
unsigned int maxents; //buffer size
struct
{
unsigned short n; //don't rely on the ent->v->entnum
csqcedict_t *e; //the csqc ent
} *e;
} csqcdelta_pack_t;
static csqcdelta_pack_t csqcdelta_pack_new;
static csqcdelta_pack_t csqcdelta_pack_old;
float csqcdelta_time;
static csqcedict_t *csqcdelta_playerents[MAX_CLIENTS];
qboolean CLCSQC_DeltaPlayer(int playernum, player_state_t *state)
{
func_t func;
if (!state || !state->modelindex)
{
if (csqcdelta_playerents[playernum])
{
*csqcg.self = EDICT_TO_PROG(csqcprogs, (void*)csqcdelta_playerents[playernum]);
PR_ExecuteProgram(csqcprogs, csqcg.ent_remove);
csqcdelta_playerents[playernum] = NULL;
}
return false;
}
func = deltafunction[state->modelindex];
if (func)
{
void *pr_globals;
csqcedict_t *ent;
ent = csqcdelta_playerents[playernum];
if (!ent)
ent = (csqcedict_t *)ED_Alloc(csqcprogs);
CSQC_PlayerStateToCSQC(playernum, state, ent);
ent->v->drawmask = MASK_DELTA;
*csqcg.self = EDICT_TO_PROG(csqcprogs, (void*)ent);
pr_globals = PR_globals(csqcprogs, PR_CURRENT);
G_FLOAT(OFS_PARM0) = !csqcdelta_playerents[playernum];
PR_ExecuteProgram(csqcprogs, func);
csqcdelta_playerents[playernum] = ent;
return true;
}
else if (csqcdelta_playerents[playernum])
{
*csqcg.self = EDICT_TO_PROG(csqcprogs, (void*)csqcdelta_playerents[playernum]);
PR_ExecuteProgram(csqcprogs, csqcg.ent_remove);
csqcdelta_playerents[playernum] = NULL;
}
return false;
}
void CLCSQC_DeltaStart(float time)
{
csqcdelta_pack_t tmp;
csqcdelta_time = time;
tmp = csqcdelta_pack_new;
csqcdelta_pack_new = csqcdelta_pack_old;
csqcdelta_pack_old = tmp;
csqcdelta_pack_new.numents = 0;
csqcdelta_pack_new.readpos = 0;
csqcdelta_pack_old.readpos = 0;
}
qboolean CLCSQC_DeltaUpdate(entity_state_t *src)
{
//FTE ensures that this function is called with increasing ent numbers each time
func_t func;
func = deltafunction[src->modelindex];
if (func)
{
void *pr_globals;
csqcedict_t *ent, *oldent;
if (csqcdelta_pack_old.readpos == csqcdelta_pack_old.numents)
{ //reached the end of the old frame's ents
oldent = NULL;
}
else
{
while (csqcdelta_pack_old.readpos < csqcdelta_pack_old.numents && csqcdelta_pack_old.e[csqcdelta_pack_old.readpos].n < src->number)
{
//this entity is stale, remove it.
oldent = csqcdelta_pack_old.e[csqcdelta_pack_old.readpos].e;
*csqcg.self = EDICT_TO_PROG(csqcprogs, (void*)oldent);
PR_ExecuteProgram(csqcprogs, csqcg.ent_remove);
csqcdelta_pack_old.readpos++;
}
if (src->number < csqcdelta_pack_old.e[csqcdelta_pack_old.readpos].n)
oldent = NULL;
else
{
oldent = csqcdelta_pack_old.e[csqcdelta_pack_old.readpos].e;
csqcdelta_pack_old.readpos++;
}
}
if (src->number < maxcsqcentities && csqcent[src->number])
{
//in the csqc list (don't permit in the delta list too)
if (oldent)
{
*csqcg.self = EDICT_TO_PROG(csqcprogs, (void*)oldent);
PR_ExecuteProgram(csqcprogs, csqcg.ent_remove);
}
return false;
}
if (oldent)
ent = oldent;
else
ent = (csqcedict_t *)ED_Alloc(csqcprogs);
CSQC_EntStateToCSQC(deltaflags[src->modelindex], csqcdelta_time, src, ent);
ent->v->drawmask = MASK_DELTA;
*csqcg.self = EDICT_TO_PROG(csqcprogs, (void*)ent);
pr_globals = PR_globals(csqcprogs, PR_CURRENT);
G_FLOAT(OFS_PARM0) = !oldent;
PR_ExecuteProgram(csqcprogs, func);
if (csqcdelta_pack_new.maxents <= csqcdelta_pack_new.numents)
{
csqcdelta_pack_new.maxents = csqcdelta_pack_new.numents + 64;
csqcdelta_pack_new.e = BZ_Realloc(csqcdelta_pack_new.e, sizeof(*csqcdelta_pack_new.e)*csqcdelta_pack_new.maxents);
}
csqcdelta_pack_new.e[csqcdelta_pack_new.numents].e = ent;
csqcdelta_pack_new.e[csqcdelta_pack_new.numents].n = src->number;
csqcdelta_pack_new.numents++;
return G_FLOAT(OFS_RETURN);
}
return false;
}
void CLCSQC_DeltaEnd(void)
{
//remove any unreferenced ents stuck on the end
while (csqcdelta_pack_old.readpos < csqcdelta_pack_old.numents)
{
*csqcg.self = EDICT_TO_PROG(csqcprogs, (void*)csqcdelta_pack_old.e[csqcdelta_pack_old.readpos].e);
PR_ExecuteProgram(csqcprogs, csqcg.ent_remove);
csqcdelta_pack_old.readpos++;
}
}
void PF_DeltaListen(progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
int i;
char *mname = PR_GetStringOfs(prinst, OFS_PARM0);
func_t func = G_INT(OFS_PARM1);
unsigned int flags = G_FLOAT(OFS_PARM2);
if (PR_GetFuncArgCount(prinst, func) < 0)
{
Con_Printf("PF_DeltaListen: Bad function index\n");
return;
}
if (!strcmp(mname, "*"))
{
//yes, even things that are not allocated yet
for (i = 0; i < MAX_MODELS; i++)
{
deltafunction[i] = func;
deltaflags[i] = flags;
}
}
else
{
for (i = 1; i < MAX_MODELS; i++)
{
if (!*cl.model_name[i])
break;
if (!strcmp(cl.model_name[i], mname))
{
deltafunction[i] = func;
deltaflags[i] = flags;
break;
}
}
}
}
#if 1
void PF_ReadServerEntityState(progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
}
#else
packet_entities_t *CL_ProcessPacketEntities(float *servertime, qboolean nolerp);
void PF_ReadServerEntityState(progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
@ -4127,45 +4491,7 @@ void PF_ReadServerEntityState(progfuncs_t *prinst, struct globalvars_s *pr_globa
G_FLOAT(OFS_PARM0) = false;
}
ent->v->entnum = i+1;
if (cl.spectator && !Cam_DrawPlayer(0, i))
{
ent->v->modelindex = 0;
}
else
ent->v->modelindex = srcp->modelindex;
ent->v->skin = srcp->skinnum;
ent->v->frame1time = cl.time - cl.lerpplayers[i].framechange;
ent->v->frame2time = cl.time - cl.lerpplayers[i].oldframechange;
if (ent->v->frame != cl.lerpplayers[i].frame)
{
ent->v->frame2 = ent->v->frame;
ent->v->frame = cl.lerpplayers[i].frame;
}
ent->v->lerpfrac = 1-(cl.time - cl.lerpplayers[i].framechange)*10;
if (ent->v->lerpfrac > 1)
ent->v->lerpfrac = 1;
else if (ent->v->lerpfrac < 0)
{
ent->v->lerpfrac = 0;
}
VectorCopy(srcp->origin, ent->v->origin);
VectorCopy(srcp->velocity, ent->v->velocity);
VectorCopy(srcp->viewangles, ent->v->angles);
ent->v->angles[0] *= -0.333;
ent->v->colormap = i+1;
ent->v->scale = srcp->scale/16.0f;
//ent->v->fatness = srcp->fatness;
ent->v->alpha = srcp->alpha/255.0f;
// ent->v->colormod[0] = (srcp->colormod[0]/255.0f)*8;
// ent->v->colormod[1] = (srcp->colormod[1]/255.0f)*8;
// ent->v->colormod[2] = (srcp->colormod[2]/255.0f)*8;
// ent->v->effects = srcp->effects;
CSQC_PlayerStateToCSQC(i, srcp, ent);
if (csqcg.delta_update)
{
@ -4240,81 +4566,8 @@ void PF_ReadServerEntityState(progfuncs_t *prinst, struct globalvars_s *pr_globa
else
ent = (csqcedict_t *)ED_Alloc(prinst);
le = &cl.lerpents[src->number];
//frames needs special handling
ent->v->frame = src->frame;
ent->v->frame2 = le->frame;
if (le->framechange == le->oldframechange)
ent->v->lerpfrac = 0;
else
{
ent->v->lerpfrac = 1-(servertime - le->framechange) / (le->framechange - le->oldframechange);
if (ent->v->lerpfrac > 1)
ent->v->lerpfrac = 1;
else if (ent->v->lerpfrac < 0)
{
ent->v->lerpfrac = 0;
}
}
model = cl.model_precache[src->modelindex];
if (!(flags & RSES_NOTRAILS))
{
if (oldent && model->particletrail >= 0)
{
if (pe->ParticleTrail (ent->v->origin, src->origin, model->particletrail, &(le->trailstate)))
pe->ParticleTrailIndex(ent->v->origin, src->origin, model->traildefaultindex, 0, &(le->trailstate));
}
}
ent->v->entnum = src->number;
ent->v->modelindex = src->modelindex;
// ent->v->bitmask = src->bitmask;
ent->v->flags = src->flags;
// ent->v->effects = src->effects;
ent->v->origin[0] = src->origin[0];
ent->v->origin[1] = src->origin[1];
ent->v->origin[2] = src->origin[2];
ent->v->angles[0] = src->angles[0];
ent->v->angles[1] = src->angles[1];
ent->v->angles[2] = src->angles[2];
//we ignore the q2 state fields
ent->v->colormap = src->colormap;
ent->v->skin = src->skinnum;
// ent->v->glowsize = src->glowsize;
// ent->v->glowcolor = src->glowcolour;
ent->v->scale = src->scale/16.0f;
ent->v->fatness = src->fatness/16.0f;
// ent->v->hexen2flags = src->hexen2flags;
// ent->v->abslight = src->abslight;
// ent->v->dpflags = src->dpflags;
// ent->v->colormod[0] = (src->colormod[0]/255.0f)*8;
// ent->v->colormod[1] = (src->colormod[1]/255.0f)*8;
// ent->v->colormod[2] = (src->colormod[2]/255.0f)*8;
ent->v->alpha = src->trans/255.0f;
// ent->v->lightstyle = src->lightstyle;
// ent->v->lightpflags = src->lightpflags;
// ent->v->solid = src->solid;
// ent->v->light[0] = src->light[0];
// ent->v->light[1] = src->light[1];
// ent->v->light[2] = src->light[2];
// ent->v->light[3] = src->light[3];
// ent->v->tagentity = src->tagentity;
// ent->v->tagindex = src->tagindex;
if (model)
{
if (!(flags & RSES_NOROTATE) && (model->flags & EF_ROTATE))
{
ent->v->angles[0] = 0;
ent->v->angles[1] = 100*servertime;
ent->v->angles[2] = 0;
}
}
CSQC_EntStateToCSQC(flags, servertime, src, ent);
if (csqcg.delta_update)
{
*csqcg.self = EDICT_TO_PROG(prinst, (void*)ent);
@ -4345,6 +4598,7 @@ void PF_ReadServerEntityState(progfuncs_t *prinst, struct globalvars_s *pr_globa
newlist->numents = newidx;
}
#endif
#define PF_FixTen PF_Fixme,PF_Fixme,PF_Fixme,PF_Fixme,PF_Fixme,PF_Fixme,PF_Fixme,PF_Fixme,PF_Fixme,PF_Fixme
@ -4560,6 +4814,7 @@ static struct {
{"skel_mul_bones", PF_skel_mul_bones, 272},//void(float skel, float startbone, float endbone, vector org) skel_mul_bone (FTE_CSQC_SKELETONOBJECTS) (reads v_forward etc)
{"skel_copybones", PF_skel_copybones, 273},//void(float skeldst, float skelsrc, float startbone, float entbone) skel_copybones (FTE_CSQC_SKELETONOBJECTS)
{"skel_delete", PF_skel_delete, 274},//void(float skel) skel_delete (FTE_CSQC_SKELETONOBJECTS)
{"frameforname", PF_frameforname, 275}, // #275
//300
{"clearscene", PF_R_ClearScene, 300}, // #300 void() clearscene (EXT_CSQC)
@ -4659,9 +4914,11 @@ static struct {
{"readangle", PF_ReadAngle, 365}, // #365 float() readangle (EXT_CSQC)
{"readstring", PF_ReadString, 366}, // #366 string() readstring (EXT_CSQC)
{"readfloat", PF_ReadFloat, 367}, // #367 string() readfloat (EXT_CSQC)
{"readentitynum", PF_ReadEntityNum, 368}, // #368 float() readentitynum (EXT_CSQC)
{"readserverentitystate", PF_ReadServerEntityState, 369}, // #369 void(float flags, float simtime) readserverentitystate (EXT_CSQC_1)
// {"readsingleentitystate", PF_ReadSingleEntityState, 370},
{"deltalisten", PF_DeltaListen, 371}, // #371 float(string modelname, float flags) deltalisten (EXT_CSQC_1)
//400
{"copyentity", PF_cs_copyentity, 400}, // #400 void(entity from, entity to) copyentity (DP_QC_COPYENTITY)
@ -4901,6 +5158,8 @@ void CSQC_Shutdown(void)
csqcprogs = NULL;
in_sensitivityscale = 1;
csqc_usinglistener = false;
}
//when the qclib needs a file, it calls out to this function.
@ -5019,6 +5278,8 @@ qboolean CSQC_Init (unsigned int checksum)
csqcedict_t *worldent;
csqcchecksum = checksum;
csqc_usinglistener = false;
//its already running...
if (csqcprogs)
return false;
@ -5070,7 +5331,7 @@ qboolean CSQC_Init (unsigned int checksum)
csqcprogparms.globalbuiltins = pr_builtin;//builtin_t *globalbuiltins; //these are available to all progs
csqcprogparms.numglobalbuiltins = sizeof(pr_builtin)/sizeof(pr_builtin[0]);
csqcprogparms.autocompile = PR_NOCOMPILE;//enum {PR_NOCOMPILE, PR_COMPILENEXIST, PR_COMPILECHANGED, PR_COMPILEALWAYS} autocompile;
csqcprogparms.autocompile = PR_COMPILEIGNORE;//enum {PR_NOCOMPILE, PR_COMPILENEXIST, PR_COMPILECHANGED, PR_COMPILEALWAYS} autocompile;
csqcprogparms.gametime = &csqctime;
@ -5089,11 +5350,16 @@ qboolean CSQC_Init (unsigned int checksum)
CSQC_InitFields(); //let the qclib know the field order that the engine needs.
if (PR_LoadProgs(csqcprogs, "csprogs.dat", 0, NULL, 0) < 0) //no per-progs builtins.
csqc_isdarkplaces = false;
if (PR_LoadProgs(csqcprogs, "csprogs.dat", 32199, NULL, 0) < 0) //no per-progs builtins.
{
CSQC_Shutdown();
//failed to load or something
return false;
if (PR_LoadProgs(csqcprogs, "csprogs.dat", 52195, NULL, 0) < 0) //no per-progs builtins.
{
CSQC_Shutdown();
//failed to load or something
return false;
}
csqc_isdarkplaces = true;
}
if (setjmp(csqc_abort))
{
@ -5120,17 +5386,16 @@ qboolean CSQC_Init (unsigned int checksum)
worldent->readonly = true;
worldent->isfree = false;
worldent->v->model = PR_SetString(csqcprogs, cl.model_name[1]);
for (i = 0; i < 2; i++)
{
loadedcsqcpack[i].numents = 0;
loadedcsqcpack[i].maxents = 0;
Z_Free(loadedcsqcpack[i].entptr);
loadedcsqcpack[i].entptr = NULL;
Z_Free(loadedcsqcpack[i].entnum);
loadedcsqcpack[i].entnum = NULL;
}
memset(deltaedplayerents, 0, sizeof(deltaedplayerents));
Z_Free(csqcdelta_pack_new.e);
memset(&csqcdelta_pack_new, 0, sizeof(csqcdelta_pack_new));
Z_Free(csqcdelta_pack_old.e);
memset(&csqcdelta_pack_old, 0, sizeof(csqcdelta_pack_old));
memset(&deltafunction, 0, sizeof(deltafunction));
memset(csqcdelta_playerents, 0, sizeof(csqcdelta_playerents));
csqcmapentitydata = NULL;
csqcmapentitydataloaded = false;
@ -5415,6 +5680,11 @@ qboolean CSQC_ParseTempEntity(unsigned char firstbyte)
return !!G_FLOAT(OFS_RETURN);
}
qboolean CSQC_ParseGamePacket(void)
{
return false;
}
qboolean CSQC_LoadResource(char *resname, char *restype)
{
void *pr_globals;

View file

@ -718,6 +718,8 @@ void PF_cl_setmousetarget (progfuncs_t *prinst, struct globalvars_s *pr_globals)
//float getmousetarget(void) = #604;
void PF_cl_getmousetarget (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
extern int mouseusedforgui;
G_FLOAT(OFS_RETURN) = mouseusedforgui?1:2;
}
int MP_TranslateDPtoFTECodes(int code);
@ -760,6 +762,7 @@ void PF_cl_getmousepos (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
float *ret = G_VECTOR(OFS_RETURN);
extern int mousemove_x, mousemove_y;
extern int mousecursor_x, mousecursor_y;
ret[0] = mousemove_x;
ret[1] = mousemove_y;
@ -767,8 +770,8 @@ void PF_cl_getmousepos (progfuncs_t *prinst, struct globalvars_s *pr_globals)
mousemove_x=0;
mousemove_y=0;
/* ret[0] = mousecursor_x;
ret[1] = mousecursor_y;*/
ret[0] = mousecursor_x;
ret[1] = mousecursor_y;
ret[2] = 0;
}
@ -1637,7 +1640,7 @@ void MP_Init (void)
menuprogparms.globalbuiltins = menu_builtins;//builtin_t *globalbuiltins; //these are available to all progs
menuprogparms.numglobalbuiltins = menu_numbuiltins;
menuprogparms.autocompile = PR_COMPILEEXISTANDCHANGED;//enum {PR_NOCOMPILE, PR_COMPILENEXIST, PR_COMPILECHANGED, PR_COMPILEALWAYS} autocompile;
menuprogparms.autocompile = PR_COMPILEIGNORE;//PR_COMPILEEXISTANDCHANGED;//enum {PR_NOCOMPILE, PR_COMPILENEXIST, PR_COMPILECHANGED, PR_COMPILEALWAYS} autocompile;
menuprogparms.gametime = &menutime;

View file

@ -131,17 +131,19 @@ extern "C" {
#include "sys.h"
#include "zone.h"
#include "mathlib.h"
#include "wad.h"
#include "cvar.h"
#include "screen.h"
#include "net.h"
#include "protocol.h"
#include "cmd.h"
#if 1//ndef SERVERONLY
#include "wad.h"
#include "screen.h"
#include "sbar.h"
#include "sound.h"
#include "merged.h"
#include "render.h"
#include "client.h"
#endif
#include "vm.h"
@ -173,10 +175,8 @@ extern "C" {
#include "progs.h"
#endif
#include "world.h"
#ifndef CLIENTONLY
//#ifdef Q2SERVER
#include "q2game.h"
//#endif
#ifndef CLIENTONLY
#include "server.h"
#endif
@ -218,7 +218,7 @@ typedef struct quakeparms_s
{
char *basedir;
int argc;
char **argv;
const char **argv;
void *membase;
unsigned int memsize;
} quakeparms_t;
@ -238,6 +238,7 @@ extern qboolean noclip_anglehack;
extern quakeparms_t host_parms;
extern cvar_t com_gamename;
extern cvar_t com_modname;
extern cvar_t sys_ticrate;
extern cvar_t sys_nostdout;
extern cvar_t developer;

View file

@ -383,6 +383,7 @@ void GL_InfinatePerspective(double fovx, double fovy, double zNear);
void GLMod_Init (void);
int Mod_TagNumForName(struct model_s *model, char *name);
int Mod_SkinNumForName(struct model_s *model, char *name);
int Mod_FrameNumForName(struct model_s *model, char *name);
void GLMod_ClearAll (void);
struct model_s *GLMod_ForName (char *name, qboolean crash);
@ -444,11 +445,11 @@ void CLQ2_FlyEffect(struct q2centity_s *ent, vec3_t org);
void CLQ2_DiminishingTrail(vec3_t oldorg, vec3_t neworg, struct q2centity_s *ent, unsigned int effects);
void CLQ2_BlasterTrail2(vec3_t oldorg, vec3_t neworg);
void WritePCXfile (char *filename, qbyte *data, int width, int height, int rowbytes, qbyte *palette, qboolean upload); //data is 8bit.
void WritePCXfile (const char *filename, qbyte *data, int width, int height, int rowbytes, qbyte *palette, qboolean upload); //data is 8bit.
qbyte *ReadPCXFile(qbyte *buf, int length, int *width, int *height);
qbyte *ReadTargaFile(qbyte *buf, int length, int *width, int *height, int asgrey);
qbyte *ReadJPEGFile(qbyte *infile, int length, int *width, int *height);
qbyte *ReadPNGFile(qbyte *buf, int length, int *width, int *height, char *name);
qbyte *ReadPNGFile(qbyte *buf, int length, int *width, int *height, const char *name);
qbyte *ReadPCXPalette(qbyte *buf, int len, qbyte *out);
void BoostGamma(qbyte *rgba, int width, int height);

View file

@ -179,8 +179,15 @@ static cvar_t vid_bpp = SCVARF ("vid_bpp", "32",
CVAR_ARCHIVE | CVAR_RENDERERLATCH);
static cvar_t vid_desktopsettings = SCVARF ("vid_desktopsettings", "0",
CVAR_ARCHIVE | CVAR_RENDERERLATCH);
#ifdef NPQTV
static cvar_t vid_fullscreen_npqtv = SCVARF ("vid_fullscreen", "1",
CVAR_ARCHIVE | CVAR_RENDERERLATCH);
static cvar_t vid_fullscreen = SCVARF ("vid_fullscreen_embedded", "0",
CVAR_ARCHIVE | CVAR_RENDERERLATCH);
#else
static cvar_t vid_fullscreen = SCVARF ("vid_fullscreen", "1",
CVAR_ARCHIVE | CVAR_RENDERERLATCH);
#endif
static cvar_t vid_height = SCVARF ("vid_height", "480",
CVAR_ARCHIVE | CVAR_RENDERERLATCH);
static cvar_t vid_multisample = SCVARF ("vid_multisample", "0",
@ -571,6 +578,7 @@ void Renderer_Init(void)
currentrendererstate.bpp = -1; //no previous.
currentrendererstate.renderer = -1;
qrenderer = -1;
Cmd_AddCommand("setrenderer", R_SetRenderer_f);
Cmd_AddCommand("vid_restart", R_RestartRenderer_f);
@ -593,6 +601,9 @@ void Renderer_Init(void)
Cvar_Register (&_windowed_mouse, VIDCOMMANDGROUP);
Cvar_Register (&vid_renderer, VIDCOMMANDGROUP);
#ifdef NPQTV
Cvar_Register (&vid_fullscreen_npqtv, VIDCOMMANDGROUP);
#endif
Cvar_Register (&vid_fullscreen, VIDCOMMANDGROUP);
// Cvar_Register (&vid_stretch, VIDCOMMANDGROUP);
Cvar_Register (&vid_bpp, VIDCOMMANDGROUP);
@ -772,6 +783,7 @@ void (*Mod_Think) (void);
//qboolean (*Mod_GetTag) (struct model_s *model, int tagnum, int frame, int frame2, float f2ness, float f1time, float f2time, float *transforms);
//int (*Mod_TagNumForName) (struct model_s *model, char *name);
int (*Mod_SkinForName) (struct model_s *model, char *name);
int (*Mod_FrameForName) (struct model_s *model, char *name);
@ -790,7 +802,7 @@ void (*VID_SetWindowCaption) (char *msg);
void (*SCR_UpdateScreen) (void);
r_qrenderer_t qrenderer=-1;
r_qrenderer_t qrenderer;
char *q_renderername = "Non-Selected renderer";
@ -883,6 +895,7 @@ rendererinfo_t dedicatedrendererinfo = {
NULL, //Mod_GetTag
NULL, //fixme: server will need this one at some point.
NULL,
NULL,
NULL, //VID_Init,
NULL, //VID_DeInit,
@ -976,6 +989,7 @@ rendererinfo_t softwarerendererinfo = {
NULL, //Mod_GetTag
NULL, //Mod_TagForName
NULL,
NULL,
SWVID_Init,
SWVID_Shutdown,
@ -1073,6 +1087,7 @@ rendererinfo_t openglrendererinfo = {
Mod_GetTag,
Mod_TagNumForName,
Mod_SkinNumForName,
Mod_FrameNumForName,
GLVID_Init,
GLVID_DeInit,
@ -1108,7 +1123,9 @@ rendererinfo_t *pd3d9rendererinfo = &d3d9rendererinfo;
rendererinfo_t **rendererinfo[] =
{
#ifndef NPQTV
&pdedicatedrendererinfo,
#endif
#ifdef SWQUAKE
&psoftwarerendererinfo,
#endif
@ -1554,10 +1571,8 @@ void D3DSucks(void)
Sys_Error("Failed to reload content after mode switch\n");
}
qboolean R_ApplyRenderer (rendererstate_t *newr)
void R_ShutdownRenderer(void)
{
if (newr->bpp == -1)
return false;
CL_AllowIndependantSendCmd(false); //FIXME: figure out exactly which parts are going to affect the model loading.
@ -1581,6 +1596,14 @@ qboolean R_ApplyRenderer (rendererstate_t *newr)
COM_FlushTempoaryPacks();
S_Shutdown();
}
qboolean R_ApplyRenderer (rendererstate_t *newr)
{
if (newr->bpp == -1)
return false;
R_ShutdownRenderer();
if (qrenderer == QR_NONE || qrenderer==-1)
{

View file

@ -1164,7 +1164,7 @@ void Sbar_FillPC (int x, int y, int w, int h, unsigned int pcolour)
{
if (pcolour >= 16)
{
Draw_FillRGB (x, y, w, h, (pcolour&0xff)/255.0f, ((pcolour&0xff00)>>8)/255.0f, ((pcolour&0xff0000)>>16)/255.0f);
Draw_FillRGB (x, y, w, h, ((pcolour&0xff0000)>>16)/255.0f, ((pcolour&0xff00)>>8)/255.0f, (pcolour&0xff)/255.0f);
}
else
{
@ -2255,6 +2255,10 @@ void Sbar_Draw (void)
sbar_parsingteamstatuses = false;
#ifdef HLCLIENT
if (CLHL_DrawHud())
return;
#endif
#ifdef Q2CLIENT
if (cls.protocol == CP_QUAKE2)

View file

@ -563,6 +563,9 @@ void Skin_FlushPlayers(void)
int i;
for (i = 0; i < MAX_CLIENTS; i++)
cl.players[i].skin = NULL;
for (i = 0; i < MAX_CLIENTS; i++)
CL_NewTranslation(i);
}
/*

View file

@ -102,6 +102,11 @@ void S_AmbientOn (void)
snd_ambient = true;
}
qboolean S_HaveOutput(void)
{
return sound_started && sndcardinfo;
}
void S_SoundInfo_f(void)
{
@ -361,7 +366,7 @@ void S_Startup (void)
break;
}
sound_started = 1;
sound_started = !!sndcardinfo;
S_ClearRaw();
}
@ -540,11 +545,6 @@ void S_Init (void)
{
int p;
if (snd_initialized) //whoops
{
Con_Printf("Sound is already initialized\n");
return;
}
Con_DPrintf("\nSound Initialization\n");
Cmd_AddCommand("play", S_Play);
@ -1115,6 +1115,58 @@ void S_StaticSound (sfx_t *sfx, vec3_t origin, float vol, float attenuation)
//=============================================================================
void S_Music_Clear(sfx_t *onlyifsample)
{
//stops the current BGM music
//calling this will trigger Media_NextTrack later
sfx_t *s;
soundcardinfo_t *sc;
int i;
for (i = NUM_AMBIENTS; i < NUM_AMBIENTS + NUM_MUSICS; i++)
{
for (sc = sndcardinfo; sc; sc=sc->next)
{
s = sc->channel[i].sfx;
if (!s)
continue;
if (onlyifsample && s != onlyifsample)
continue;
sc->channel[i].end = 0;
sc->channel[i].sfx = NULL;
if (s)
if (s->decoder)
if (!S_IsPlayingSomewhere(s)) //if we aint playing it elsewhere, free it compleatly.
{
s->decoder->abort(s);
if (s->cache.data)
Cache_Free(&s->cache);
}
}
}
}
void S_Music_Seek(float time)
{
soundcardinfo_t *sc;
int i;
for (i = NUM_AMBIENTS; i < NUM_AMBIENTS + NUM_MUSICS; i++)
{
for (sc = sndcardinfo; sc; sc=sc->next)
{
sc->channel[i].pos += sc->sn.speed*time;
sc->channel[i].end += sc->sn.speed*time;
if (sc->channel[i].pos < 0)
{ //clamp to the start of the track
sc->channel[i].end -= sc->channel[i].pos;
sc->channel[i].pos=0;
}
//if we seek over the end, ignore it. The sound playing code will spot that.
}
}
}
/*
===================
S_UpdateAmbientSounds
@ -1138,7 +1190,7 @@ void S_UpdateAmbientSounds (soundcardinfo_t *sc)
chan = &sc->channel[i];
if (!chan->sfx)
{
char *nexttrack = Media_NextTrack();
char *nexttrack = Media_NextTrack(i-NUM_AMBIENTS);
sfxcache_t *scache;
sfx_t *newmusic;
@ -1210,7 +1262,7 @@ S_Update
Called once each time through the main loop
============
*/
void S_Update(vec3_t origin, vec3_t forward, vec3_t right, vec3_t up)
void S_UpdateListener(vec3_t origin, vec3_t forward, vec3_t right, vec3_t up, qboolean dontmix)
{
soundcardinfo_t *sc;
@ -1219,12 +1271,24 @@ void S_Update(vec3_t origin, vec3_t forward, vec3_t right, vec3_t up)
VectorCopy(right, listener_right);
VectorCopy(up, listener_up);
S_RunCapture();
if (dontmix)
{
S_RunCapture();
for (sc = sndcardinfo; sc; sc = sc->next)
S_UpdateCard(sc);
for (sc = sndcardinfo; sc; sc = sc->next)
S_UpdateCard(sc);
}
}
void S_GetListenerInfo(float *origin, float *forward, float *right, float *up)
{
VectorCopy(listener_origin, origin);
VectorCopy(listener_forward, forward);
VectorCopy(listener_right, right);
VectorCopy(listener_up, up);
}
void S_UpdateCard(soundcardinfo_t *sc)
{
int i, j;

View file

@ -843,15 +843,21 @@ sfxcache_t *S_LoadSound (sfx_t *s)
// load it in
data = NULL;
if (*name == '*')
if (*name == '*') //q2 sexed sounds
{
//clq2_parsestartsound detects this also
//here we just precache the male sound name, which provides us with our default
Q_strcpy(namebuffer, "players/male/"); //q2
Q_strcat(namebuffer, name+1); //q2
}
else if (name[0] == '.' && name[1] == '.' && name[2] == '/')
{
//not relative to sound/
Q_strcpy(namebuffer, name+3);
}
else
{
//q1 behaviour, relative to sound/
Q_strcpy(namebuffer, "sound/");
Q_strcat(namebuffer, name);
data = COM_LoadStackFile(name, stackbuf, sizeof(stackbuf));
@ -874,7 +880,7 @@ sfxcache_t *S_LoadSound (sfx_t *s)
if (!data)
{
//FIXME: check to see if qued for download.
//FIXME: check to see if queued for download.
Con_DPrintf ("Couldn't load %s\n", namebuffer);
s->failedload = true;
return NULL;

1002
engine/client/sys_npqtv.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -37,6 +37,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <process.h>
#endif
#if !defined(CLIENTONLY) && !defined(SERVERONLY)
qboolean isDedicated = false;
#endif
HWND sys_hijackwindow;
void Sys_CloseLibrary(dllhandle_t *lib)
{
@ -51,16 +56,19 @@ dllhandle_t *Sys_LoadLibrary(char *name, dllfunction_t *funcs)
if (!lib)
return NULL;
for (i = 0; funcs[i].name; i++)
if (funcs)
{
*funcs[i].funcptr = GetProcAddress(lib, funcs[i].name);
if (!*funcs[i].funcptr)
break;
}
if (funcs[i].name)
{
Sys_CloseLibrary((dllhandle_t*)lib);
lib = NULL;
for (i = 0; funcs[i].name; i++)
{
*funcs[i].funcptr = GetProcAddress(lib, funcs[i].name);
if (!*funcs[i].funcptr)
break;
}
if (funcs[i].name)
{
Sys_CloseLibrary((dllhandle_t*)lib);
lib = NULL;
}
}
return (dllhandle_t*)lib;
@ -462,7 +470,7 @@ qboolean Sys_remove (char *path)
return true;
}
int Sys_EnumerateFiles (char *gpath, char *match, int (*func)(char *, int, void *), void *parm)
int Sys_EnumerateFiles (const char *gpath, const char *match, int (*func)(const char *, int, void *), void *parm)
{
HANDLE r;
WIN32_FIND_DATA fd;
@ -718,7 +726,14 @@ void Sys_Quit (void)
SV_Shutdown();
#endif
#ifdef NPQTV
{
extern jmp_buf host_abort;
longjmp (host_abort, 1);
}
#else
exit (0);
#endif
}
@ -1076,9 +1091,9 @@ void Sys_Sleep (void)
{
}
void Sys_SendKeyEvents (void)
{
#ifndef NPQTV
MSG msg;
if (isDedicated)
@ -1100,6 +1115,7 @@ void Sys_SendKeyEvents (void)
TranslateMessage (&msg);
DispatchMessage (&msg);
}
#endif
}
@ -1129,6 +1145,128 @@ void SleepUntilInput (int time)
MsgWaitForMultipleObjects(1, &tevent, FALSE, time, QS_ALLINPUT);
}
qboolean Sys_Startup_CheckMem(quakeparms_t *parms)
{
int t;
MEMORYSTATUS lpBuffer;
lpBuffer.dwLength = sizeof(MEMORYSTATUS);
GlobalMemoryStatus (&lpBuffer);
// take the greater of all the available memory or half the total memory,
// but at least 8 Mb and no more than 16 Mb, unless they explicitly
// request otherwise
parms->memsize = lpBuffer.dwAvailPhys;
if (parms->memsize < MINIMUM_WIN_MEMORY)
parms->memsize = MINIMUM_WIN_MEMORY;
if (parms->memsize < (lpBuffer.dwTotalPhys >> 1))
parms->memsize = lpBuffer.dwTotalPhys >> 1;
if (parms->memsize > MAXIMUM_WIN_MEMORY)
parms->memsize = MAXIMUM_WIN_MEMORY;
if (COM_CheckParm ("-heapsize"))
{
t = COM_CheckParm("-heapsize") + 1;
if (t < com_argc)
parms->memsize = Q_atoi (com_argv[t]) * 1024;
}
else if (COM_CheckParm ("-mem"))
{
t = COM_CheckParm("-mem") + 1;
if (t < com_argc)
parms->memsize = Q_atoi (com_argv[t]) * 1024*1024;
}
parms->membase = VirtualAlloc (NULL, parms->memsize, MEM_RESERVE, PAGE_NOACCESS);
// parms->membase = malloc (parms.memsize);
if (!parms->membase)
return false;
return true;
}
#ifdef NPQTV
static quakeparms_t parms;
double lastlooptime;
qboolean NPQTV_Sys_Startup(int argc, char *argv[])
{
if (!host_initialized)
{
TL_InitLanguages();
parms.argc = argc;
parms.argv = argv;
parms.basedir = argv[0];
COM_InitArgv (parms.argc, parms.argv);
if (!Sys_Startup_CheckMem(&parms))
return false;
Host_Init (&parms);
}
lastlooptime = Sys_DoubleTime ();
return true;
}
void NPQTV_Sys_MainLoop(void)
{
double duratrion, newtime;
if (isDedicated)
{
#ifndef CLIENTONLY
NET_Sleep(50, false);
// find time passed since last cycle
newtime = Sys_DoubleTime ();
duratrion = newtime - lastlooptime;
lastlooptime = newtime;
SV_Frame ();
#else
Sys_Error("wut?");
#endif
}
else
{
#ifndef SERVERONLY
newtime = Sys_DoubleTime ();
duratrion = newtime - lastlooptime;
Host_Frame (duratrion);
lastlooptime = newtime;
SetHookState(sys_disableWinKeys.value);
// Sleep(0);
#else
Sys_Error("wut?");
#endif
}
}
void NPQTV_Sys_Shutdown(void)
{
//disconnect server/client/etc
CL_Disconnect_f();
R_ShutdownRenderer();
Host_Shutdown();
}
#else
/*
==================
WinMain
@ -1140,9 +1278,6 @@ char *argv[MAX_NUM_ARGVS];
static char exename[256];
HWND hwnd_dialog;
#if !defined(CLIENTONLY) && !defined(SERVERONLY)
qboolean isDedicated = false;
#endif
/*
#ifdef _MSC_VER
#include <signal.h>
@ -1160,11 +1295,9 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
// MSG msg;
quakeparms_t parms;
double time, oldtime, newtime;
MEMORYSTATUS lpBuffer;
char cwd[1024];
int t;
RECT rect;
char *qtvfile = NULL;
const char *qtvfile = NULL;
/* previous instances do not exist in Win32 */
if (hPrevInstance)
@ -1181,9 +1314,6 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
global_hInstance = hInstance;
global_nCmdShow = nCmdShow;
lpBuffer.dwLength = sizeof(MEMORYSTATUS);
GlobalMemoryStatus (&lpBuffer);
parms.argc = 1;
argv[0] = exename;
@ -1301,41 +1431,11 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin
SetForegroundWindow (hwnd_dialog);
}
// take the greater of all the available memory or half the total memory,
// but at least 8 Mb and no more than 16 Mb, unless they explicitly
// request otherwise
parms.memsize = lpBuffer.dwAvailPhys;
if (parms.memsize < MINIMUM_WIN_MEMORY)
parms.memsize = MINIMUM_WIN_MEMORY;
if (parms.memsize < (lpBuffer.dwTotalPhys >> 1))
parms.memsize = lpBuffer.dwTotalPhys >> 1;
if (parms.memsize > MAXIMUM_WIN_MEMORY)
parms.memsize = MAXIMUM_WIN_MEMORY;
if (COM_CheckParm ("-heapsize"))
{
t = COM_CheckParm("-heapsize") + 1;
if (t < com_argc)
parms.memsize = Q_atoi (com_argv[t]) * 1024;
}
else if (COM_CheckParm ("-mem"))
{
t = COM_CheckParm("-mem") + 1;
if (t < com_argc)
parms.memsize = Q_atoi (com_argv[t]) * 1024*1024;
}
parms.membase = VirtualAlloc (NULL, parms.memsize, MEM_RESERVE, PAGE_NOACCESS);
// parms.membase = malloc (parms.memsize);
if (!parms.membase)
if (!Sys_Startup_CheckMem(&parms))
Sys_Error ("Not enough memory free; check disk space\n");
#ifndef CLIENTONLY
if (isDedicated) //compleate denial to switch to anything else - many of the client structures are not initialized.
{
@ -1429,6 +1529,7 @@ int __cdecl main(void)
FreeConsole();
return WinMain(GetModuleHandle(NULL), NULL, GetCommandLine(), SW_NORMAL);
}
#endif
qboolean Sys_GetDesktopParameters(int *width, int *height, int *bpp, int *refreshrate)
{

View file

@ -312,7 +312,7 @@ void EditorOpenFile(char *name)
memcpy(firstblock->data, line, len);
if (editprogfuncs)
{
if (editprogfuncs->ToggleBreak(editprogfuncs, OpenEditorFile+strlen(com_gamedir)+1, i, 3))
if (editprogfuncs->ToggleBreak(editprogfuncs, OpenEditorFile, i, 3))
{
firstblock->flags |= FB_BREAK;
}
@ -321,7 +321,7 @@ void EditorOpenFile(char *name)
{
if (svprogfuncs)
{
if (svprogfuncs->ToggleBreak(svprogfuncs, OpenEditorFile+strlen(com_gamedir)+1, i, 3))
if (svprogfuncs->ToggleBreak(svprogfuncs, OpenEditorFile, i, 3))
{
firstblock->flags |= FB_BREAK;
}

View file

@ -444,17 +444,13 @@ void Validation_DelatchRulesets(void)
Con_DPrintf("Ruleset deactivated\n");
}
void Validation_AllChecks(void)
{
}
void Validation_OldRuleset(void)
qboolean Validation_GetCurrentRulesetName(char *rsnames, int resultbuflen, qboolean enforcechosenrulesets)
{ //this code is more complex than it needs to be
//this allows for the ruleset code to print a ruleset name that is applied via the cvars, but not directly named by the user
cvar_t *var;
ruleset_t *rs;
int i;
char rsnames[1024];
rs = rulesets;
*rsnames = '\0';
@ -484,34 +480,75 @@ void Validation_OldRuleset(void)
{
if (*rsnames)
{
Q_strncatz(rsnames, ", ", sizeof(rsnames));
Q_strncatz(rsnames, ", ", resultbuflen);
}
Q_strncatz(rsnames, rs->rulesetname, sizeof(rsnames));
Q_strncatz(rsnames, rs->rulesetname, resultbuflen);
rs->flagged = true;
}
}
if (*rsnames)
{
Cbuf_AddText(va("say Ruleset: %s\n", rsnames), RESTRICT_LOCAL);
//now we've told the other players what rules we're playing by, we'd best stick to them
for (rs = rulesets; rs->rulesetname; rs++)
//as we'll be telling the other players what rules we're playing by, we'd best stick to them
if (enforcechosenrulesets)
{
if (!rs->flagged)
continue;
for (i = 0; rs->rule[i].rulename; i++)
for (rs = rulesets; rs->rulesetname; rs++)
{
var = Cvar_FindVar(rs->rule[i].rulename);
if (!var)
if (!rs->flagged)
continue;
RulesetLatch(var); //set the latched flag
for (i = 0; rs->rule[i].rulename; i++)
{
var = Cvar_FindVar(rs->rule[i].rulename);
if (!var)
continue;
RulesetLatch(var); //set the latched flag
}
}
}
return true;
}
else
return false;
}
void Validation_OldRuleset(void)
{
char rsnames[1024];
if (Validation_GetCurrentRulesetName(rsnames, sizeof(rsnames), true))
Cbuf_AddText(va("say Ruleset: %s\n", rsnames), RESTRICT_LOCAL);
else
Cbuf_AddText("say No specific ruleset\n", RESTRICT_LOCAL);
}
void Validation_AllChecks(void)
{
char servername[22];
char playername[16];
char *enginebuild = va(DISTRIBUTION "%i", build_number());
char localpnamelen = strlen(cl.players[cl.playernum[0]].name);
char ruleset[1024];
//figure out the padding for the player's name.
if (localpnamelen >= 15)
playername[0] = 0;
else
{
memset(playername, ' ', 15-localpnamelen-1);
playername[15-localpnamelen] = 0;
}
//get the current server address
NET_AdrToString(servername, sizeof(servername), cls.netchan.remote_address);
//get the ruleset names
if (!Validation_GetCurrentRulesetName(ruleset, sizeof(ruleset), true))
Q_strncpyz(ruleset, "no ruleset", sizeof(ruleset));
//now send it
CL_SendClientCommand(true, "say \"%s%21s " "%16s %s\"", playername, servername, enginebuild, ruleset);
}
void Validation_Apply_Ruleset(void)
{ //rulesets are applied when the client first gets a connection to the server
ruleset_t *rs;

View file

@ -1198,7 +1198,10 @@ void V_CalcRefdef (int pnum)
view->model = NULL;
else
view->model = cl.model_precache[cl.stats[pnum][STAT_WEAPON]];
view->framestate.g[FS_REG].frame[0] = view_message?view_message->weaponframe:0;
#ifdef HLCLIENT
if (!CLHL_AnimateViewEntity(view))
#endif
view->framestate.g[FS_REG].frame[0] = view_message?view_message->weaponframe:0;
#ifdef SWQUAKE
view->palremap = D_IdentityRemap();
#endif

View file

@ -43,6 +43,14 @@ typedef struct
qbyte data[4]; // variably sized
} qpic_t;
#ifdef RGLQUAKE
typedef struct
{
int texnum;
float sl, tl, sh, th;
} glpic_t;
#endif
//this is what's actually used.
#define MPIC_ALPHA 1
typedef struct //use this so we don't have to go slow over pics, and don't have to shift too much data around.
@ -51,7 +59,16 @@ typedef struct //use this so we don't have to go slow over pics, and don't have
unsigned short height;
qbyte flags;
qbyte pad;
qbyte data[4]; // variably sized
union {
int dummy;
#ifdef RGLQUAKE
glpic_t gl;
#endif
#ifdef SWQUAKE
qbyte data[4]; // variably sized
#endif
} d;
} mpic_t;

View file

@ -62,6 +62,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern HINSTANCE global_hInstance;
extern int global_nCmdShow;
extern HWND sys_hijackwindow;
#ifndef SERVERONLY
#ifdef _WIN32
@ -151,10 +153,7 @@ extern qboolean ActiveApp, Minimized;
extern qboolean WinNT;
void IN_ShowMouse (void);
void IN_DeactivateMouse (void);
void IN_HideMouse (void);
void IN_ActivateMouse (void);
void IN_UpdateGrabs(int fullscreen, int activeapp);
void IN_RestoreOriginalMouseState (void);
void IN_SetQuakeMouseState (void);
void IN_MouseEvent (int mstate);

View file

@ -56,7 +56,7 @@ IDD_DIALOG1 DIALOGEX 0, 0, 67, 40
STYLE DS_MODALFRAME | DS_SETFOREGROUND | DS_3DLOOK | DS_CENTER | WS_POPUP |
WS_VISIBLE
EXSTYLE WS_EX_TOOLWINDOW | WS_EX_CLIENTEDGE
FONT 16, "Times New Roman"
FONT 16, "Times New Roman", 0, 0, 0x1
BEGIN
CTEXT "FTE QuakeWorld",IDC_STATIC,0,0,67,21,SS_CENTERIMAGE
CTEXT "http://www.fteqw.com",IDC_STATIC,0,23,66,17,

View file

@ -3184,7 +3184,7 @@ qbool TP_CheckSoundTrigger (char *str)
// clean up the message
strcpy (str + j, str + i);
if (!snd_initialized)
if (!S_HaveOutput())
return false;
COM_DefaultExtension (soundname, ".wav", sizeof(soundname));

View file

@ -198,11 +198,17 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#undef USE_D3D
#endif
#ifdef NPQTV
#undef TEXTEDITOR
#undef WEBCLIENT
#undef WEBSERVER
#endif
#ifdef SERVERONLY //remove options that don't make sense on only a server
#undef Q2CLIENT
#undef Q3CLIENT
#undef HLCLIENT
#undef HALFLIFEMODELS
#undef VM_UI
#undef VM_CG
#undef WEBCLIENT

View file

@ -74,12 +74,22 @@ static int macro_count = 0;
void Cmd_AddMacro(char *s, char *(*f)(void), int disputableintentions)
{
if (macro_count == MAX_MACROS)
int i;
for (i = 0; i < macro_count; i++)
{
if (!strcmp(macro_commands[i].name, s))
break;
}
if (i == MAX_MACROS)
Sys_Error("Cmd_AddMacro: macro_count == MAX_MACROS");
Q_strncpyz(macro_commands[macro_count].name, s, sizeof(macro_commands[macro_count].name));
macro_commands[macro_count].func = f;
macro_commands[macro_count].disputableintentions = disputableintentions;
macro_count++;
if (i == macro_count)
macro_count++;
}
char *TP_MacroString (char *s, int *len)
@ -1482,7 +1492,10 @@ qboolean Cmd_AddRemCommand (char *cmd_name, xcommand_t function)
if (cmd->function == function) //happens a lot with q3
Con_DPrintf ("Cmd_AddCommand: %s already defined\n", cmd_name);
else
{
Con_Printf ("Cmd_AddCommand: %s already defined\n", cmd_name);
break;
}
return false;
}
}
@ -2812,6 +2825,17 @@ void Cmd_Condump_f(void)
}
#endif
void Cmd_Shutdown(void)
{
//make sure we get no other execution
int level;
for (level = 0; level < sizeof(cmd_text)/sizeof(cmd_text[0]); level++)
SZ_Clear (&cmd_text[level].buf);
cmd_functions = NULL;
cmd_alias = NULL;
}
/*
============
Cmd_Init

View file

@ -1126,10 +1126,10 @@ void Mod_FloodFillSkin( qbyte *skin, int skinwidth, int skinheight )
#endif
//additional skin loading
char **skinfilelist;
char ** skinfilelist;
int skinfilecount;
static qboolean VARGS Mod_TryAddSkin(char *skinname, ...)
static qboolean VARGS Mod_TryAddSkin(const char *skinname, ...)
{
va_list argptr;
char string[MAX_QPATH];
@ -1159,7 +1159,7 @@ static qboolean VARGS Mod_TryAddSkin(char *skinname, ...)
return true;
}
int Mod_EnumerateSkins(char *name, int size, void *param)
int Mod_EnumerateSkins(const char *name, int size, void *param)
{
Mod_TryAddSkin(name);
return true;
@ -2330,8 +2330,6 @@ qboolean Mod_LoadQ2Model (model_t *mod, void *buffer)
int Mod_GetNumBones(model_t *model, qboolean allowtags)
{
galiasinfo_t *inf;
@ -2608,7 +2606,13 @@ int Mod_TagNumForName(model_t *model, char *name)
galiasinfo_t *inf;
md3tag_t *t;
if (!model || model->type != mod_alias)
if (!model)
return 0;
#ifdef HALFLIFEMODELS
if (model->type == mod_halflife)
return HLMod_BoneForName(model, name);
#endif
if (model->type != mod_alias)
return 0;
inf = Mod_Extradata(model);
@ -2634,6 +2638,32 @@ int Mod_TagNumForName(model_t *model, char *name)
return 0;
}
#ifndef SERVERONLY
int Mod_FrameNumForName(model_t *model, char *name)
{
galiasgroup_t *group;
galiasinfo_t *inf;
int i;
if (!model)
return -1;
#ifdef HALFLIFEMODELS
if (model->type == mod_halflife)
return HLMod_FrameForName(model, name);
#endif
if (model->type != mod_alias)
return 0;
inf = Mod_Extradata(model);
for (i = 0; i < model->numframes; i++)
{
group = (galiasgroup_t*)((char*)inf + inf->groupofs);
if (!strcmp(group->name, name))
return i;
}
return -1;
}
int Mod_SkinNumForName(model_t *model, char *name)
{
int i;

View file

@ -38,15 +38,16 @@ usercmd_t nullcmd; // guarenteed to be zero
entity_state_t nullentitystate; //this is the default state
static char *largv[MAX_NUM_ARGVS + NUM_SAFE_ARGVS + 1];
static const char *largv[MAX_NUM_ARGVS + NUM_SAFE_ARGVS + 1];
static char *argvdummy = " ";
static char *safeargvs[NUM_SAFE_ARGVS] =
{"-stdvid", "-nolan", "-nosound", "-nocdaudio", "-nojoy", "-nomouse"};
cvar_t registered = SCVAR("registered","0");
cvar_t gameversion = SCVAR("gameversion","0");
cvar_t gameversion = SCVARF("gameversion","", CVAR_SERVERINFO);
cvar_t com_gamename = SCVAR("com_gamename", "");
cvar_t com_modname = SCVAR("com_modname", "");
qboolean com_modified; // set true if using non-id files
@ -342,9 +343,9 @@ char *Q_strlwr(char *s)
return ret;
}
int wildcmp(char *wild, char *string)
int wildcmp(const char *wild, const char *string)
{
char *cp=NULL, *mp=NULL;
const char *cp=NULL, *mp=NULL;
while ((*string) && (*wild != '*'))
{
@ -434,7 +435,7 @@ void Q_ftoa(char *str, float in)
}
}
int Q_atoi (char *str)
int Q_atoi (const char *str)
{
int val;
int sign;
@ -493,7 +494,7 @@ int Q_atoi (char *str)
}
float Q_atof (char *str)
float Q_atof (const char *str)
{
double val;
int sign;
@ -1429,9 +1430,9 @@ void SZ_Print (sizebuf_t *buf, const char *data)
COM_SkipPath
============
*/
char *COM_SkipPath (char *pathname)
char *COM_SkipPath (const char *pathname)
{
char *last;
const char *last;
last = pathname;
while (*pathname)
@ -1440,7 +1441,7 @@ char *COM_SkipPath (char *pathname)
last = pathname+1;
pathname++;
}
return last;
return (char *)last;
}
/*
@ -1448,11 +1449,11 @@ char *COM_SkipPath (char *pathname)
COM_StripExtension
============
*/
void COM_StripExtension (char *in, char *out, int outlen)
void COM_StripExtension (const char *in, char *out, int outlen)
{
char *s;
if (out != in)
if (out != in) //optimisation, most calls use the same buffer
Q_strncpyz(out, in, outlen);
s = out+strlen(out);
@ -1494,7 +1495,7 @@ void COM_StripAllExtensions (char *in, char *out, int outlen)
COM_FileExtension
============
*/
char *COM_FileExtension (char *in)
char *COM_FileExtension (const char *in)
{
static char exten[8];
int i;
@ -1565,9 +1566,9 @@ void COM_CleanUpPath(char *str)
COM_FileBase
============
*/
void COM_FileBase (char *in, char *out, int outlen)
void COM_FileBase (const char *in, char *out, int outlen)
{
char *s, *s2;
const char *s, *s2;
s = in + strlen(in) - 1;
@ -1901,7 +1902,7 @@ messedup:
#define TOKENSIZE sizeof(com_token)
char com_token[TOKENSIZE];
int com_argc;
char **com_argv;
const char **com_argv;
com_tokentype_t com_tokentype;
@ -1913,7 +1914,8 @@ COM_Parse
Parse a token out of a string
==============
*/
char *COM_Parse (char *data)
#ifndef COM_Parse
char *COM_Parse (const char *data)
{
int c;
int len;
@ -1952,13 +1954,13 @@ skipwhite:
while (1)
{
if (len >= TOKENSIZE-1)
return data;
return (char*)data;
c = *data++;
if (c=='\"' || !c)
{
com_token[len] = 0;
return data;
return (char*)data;
}
com_token[len] = c;
len++;
@ -1969,7 +1971,7 @@ skipwhite:
do
{
if (len >= TOKENSIZE-1)
return data;
return (char*)data;
com_token[len] = c;
data++;
@ -1978,10 +1980,11 @@ skipwhite:
} while (c>32);
com_token[len] = 0;
return data;
return (char*)data;
}
#endif
char *COM_ParseStringSet (char *data)
char *COM_ParseStringSet (const char *data)
{
int c;
int len;
@ -2004,7 +2007,10 @@ char *COM_ParseStringSet (char *data)
do
{
if (len >= TOKENSIZE-1)
return data;
{
com_token[len] = 0;
return (char*)data;
}
com_token[len] = c;
data++;
@ -2013,11 +2019,11 @@ char *COM_ParseStringSet (char *data)
} while (c>32 && c != ';');
com_token[len] = 0;
return data;
return (char*)data;
}
char *COM_ParseOut (char *data, char *out, int outlen)
char *COM_ParseOut (const char *data, char *out, int outlen)
{
int c;
int len;
@ -2056,13 +2062,16 @@ skipwhite:
while (1)
{
if (len >= outlen-1)
return data;
{
out[len] = 0;
return (char*)data;
}
c = *data++;
if (c=='\"' || !c)
{
out[len] = 0;
return data;
return (char*)data;
}
out[len] = c;
len++;
@ -2073,7 +2082,10 @@ skipwhite:
do
{
if (len >= outlen-1)
return data;
{
out[len] = 0;
return (char*)data;
}
out[len] = c;
data++;
@ -2082,11 +2094,11 @@ skipwhite:
} while (c>32);
out[len] = 0;
return data;
return (char*)data;
}
//same as COM_Parse, but parses two quotes next to each other as a single quote as part of the string
char *COM_StringParse (char *data, qboolean expandmacros, qboolean qctokenize)
char *COM_StringParse (const char *data, qboolean expandmacros, qboolean qctokenize)
{
int c;
int len;
@ -2144,7 +2156,7 @@ skipwhite:
if (len >= TOKENSIZE-1)
{
com_token[len] = '\0';
return data;
return (char*)data;
}
@ -2155,7 +2167,7 @@ skipwhite:
if (c!='\"')
{
com_token[len] = 0;
return data;
return (char*)data;
}
while (c=='\"')
{
@ -2168,7 +2180,7 @@ skipwhite:
if (!c)
{
com_token[len] = 0;
return data;
return (char*)data;
}
com_token[len] = c;
len++;
@ -2184,7 +2196,7 @@ skipwhite:
if (len >= TOKENSIZE-1)
{
com_token[len] = '\0';
return data;
return (char*)data;
}
@ -2195,7 +2207,7 @@ skipwhite:
if (c!='\'')
{
com_token[len] = 0;
return data;
return (char*)data;
}
while (c=='\'')
{
@ -2208,7 +2220,7 @@ skipwhite:
if (!c)
{
com_token[len] = 0;
return data;
return (char*)data;
}
com_token[len] = c;
len++;
@ -2220,7 +2232,7 @@ skipwhite:
// single character
com_token[len++] = c;
com_token[len] = 0;
return data+1;
return (char*)data+1;
}
// parse a regular word
@ -2229,7 +2241,7 @@ skipwhite:
if (len >= TOKENSIZE-1)
{
com_token[len] = '\0';
return data;
return (char*)data;
}
com_token[len] = c;
@ -2241,7 +2253,7 @@ skipwhite:
com_token[len] = 0;
if (!expandmacros)
return data;
return (char*)data;
//now we check for macros.
for (s = com_token, c= 0; c < len; c++, s++) //this isn't a quoted token by the way.
@ -2267,7 +2279,7 @@ skipwhite:
if (len+strlen(macro->string)-(i+1) >= TOKENSIZE-1) //give up.
{
com_token[len] = '\0';
return data;
return (char*)data;
}
memmove(s+strlen(macro->string), s+i+1, len-c-i);
memcpy(s, macro->string, strlen(macro->string));
@ -2277,7 +2289,7 @@ skipwhite:
}
}
return data;
return (char*)data;
}
#define DEFAULT_PUNCTUATION "(,{})(\':;=!><&|+"
@ -2396,7 +2408,7 @@ skipwhite:
return (char*)data;
}
char *COM_ParseCString (char *data)
char *COM_ParseCString (const char *data)
{
int c;
int len;
@ -2437,14 +2449,14 @@ skipwhite:
if (len >= TOKENSIZE-2)
{
com_token[len] = '\0';
return data;
return (char*)data;
}
c = *data++;
if (!c)
{
com_token[len] = 0;
return data;
return (char*)data;
}
if (c == '\\')
{
@ -2464,13 +2476,13 @@ skipwhite:
continue;
default:
com_token[len] = 0;
return data;
return (char*)data;
}
}
if (c=='\"' || !c)
{
com_token[len] = 0;
return data;
return (char*)data;
}
com_token[len] = c;
len++;
@ -2489,7 +2501,7 @@ skipwhite:
} while (c>32);
com_token[len] = 0;
return data;
return (char*)data;
}
@ -2502,7 +2514,7 @@ where the given parameter apears, or 0 if not present
================
*/
int COM_CheckNextParm (char *parm, int last)
int COM_CheckNextParm (const char *parm, int last)
{
int i = last+1;
@ -2517,7 +2529,7 @@ int COM_CheckNextParm (char *parm, int last)
return 0;
}
int COM_CheckParm (char *parm)
int COM_CheckParm (const char *parm)
{
return COM_CheckNextParm(parm, 0);
}
@ -2607,7 +2619,7 @@ void COM_CheckRegistered (void)
COM_InitArgv
================
*/
void COM_InitArgv (int argc, char **argv) //not allowed to tprint
void COM_InitArgv (int argc, const char **argv) //not allowed to tprint
{
qboolean safe;
int i;
@ -2685,7 +2697,7 @@ COM_AddParm
Adds the given string at the end of the current argument list
================
*/
void COM_AddParm (char *parm)
void COM_AddParm (const char *parm)
{
largv[com_argc++] = parm;
}
@ -2920,7 +2932,7 @@ void COM_Effectinfo_Reload(void)
}
}
unsigned int COM_Effectinfo_ForName(char *efname)
unsigned int COM_Effectinfo_ForName(const char *efname)
{
struct effectinfo_s *e;

View file

@ -170,11 +170,11 @@ void MSG_ReadData (void *data, int len);
//============================================================================
char *Q_strcpyline(char *out, char *in, int maxlen); //stops at '\n' (and '\r')
char *Q_strcpyline(char *out, const char *in, int maxlen); //stops at '\n' (and '\r')
void Q_ftoa(char *str, float in);
char *Q_strlwr(char *str);
int wildcmp(char *wild, char *string); //1 if match
int wildcmp(const char *wild, const char *string); //1 if match
#define Q_memset(d, f, c) memset((d), (f), (c))
#define Q_memcpy(d, s, c) memcpy((d), (s), (c))
@ -220,8 +220,8 @@ void Q_strncpyz(char*d, const char*s, int n);
#endif
int Q_atoi (char *str);
float Q_atof (char *str);
int Q_atoi (const char *str);
float Q_atof (const char *str);
@ -234,34 +234,37 @@ extern com_tokentype_t com_tokentype;
extern qboolean com_eof;
char *COM_Parse (char *data);
char *COM_ParseStringSet (char *data);
char *COM_ParseCString (char *data);
char *COM_StringParse (char *data, qboolean expandmacros, qboolean qctokenize);
//these cast away the const for the return value.
//char *COM_Parse (const char *data);
#define COM_Parse(d) COM_ParseOut(d,com_token, sizeof(com_token))
char *COM_ParseOut (const char *data, char *out, int outlen);
char *COM_ParseStringSet (const char *data);
char *COM_ParseCString (const char *data);
char *COM_StringParse (const char *data, qboolean expandmacros, qboolean qctokenize);
char *COM_ParseToken (const char *data, const char *punctuation);
char *COM_TrimString(char *str);
extern int com_argc;
extern char **com_argv;
extern const char **com_argv;
int COM_CheckParm (char *parm);
int COM_CheckNextParm (char *parm, int last);
void COM_AddParm (char *parm);
int COM_CheckParm (const char *parm);
int COM_CheckNextParm (const char *parm, int last);
void COM_AddParm (const char *parm);
void COM_Init (void);
void COM_InitArgv (int argc, char **argv);
void COM_InitArgv (int argc, const char **argv);
void COM_ParsePlusSets (void);
char *COM_SkipPath (char *pathname);
void COM_StripExtension (char *in, char *out, int outlen);
void COM_FileBase (char *in, char *out, int outlen);
int COM_FileSize(char *path);
char *COM_SkipPath (const char *pathname);
void COM_StripExtension (const char *in, char *out, int outlen);
void COM_FileBase (const char *in, char *out, int outlen);
int COM_FileSize(const char *path);
void COM_DefaultExtension (char *path, char *extension, int maxlen);
void COM_DeFunString(unsigned long *str, char *out, int outsize, qboolean ignoreflags);
void COM_ParseFunString(char *str, unsigned long *out, int outsize);
int COM_FunStringLength(unsigned char *str);
char *COM_FileExtension (char *in);
char *COM_FileExtension (const char *in);
void COM_CleanUpPath(char *str);
char *VARGS va(char *format, ...);
@ -273,7 +276,6 @@ extern qboolean com_file_copyprotected;
extern int com_filesize;
struct cache_user_s;
extern char com_gamedir[MAX_OSPATH];
extern char com_quakedir[MAX_OSPATH];
extern char com_homedir[MAX_OSPATH];
extern char com_configdir[MAX_OSPATH]; //dir to put cfg_save configs in
@ -294,15 +296,15 @@ struct vfsfile_s;
typedef enum {FSLFRT_IFFOUND, FSLFRT_LENGTH, FSLFRT_DEPTH_OSONLY, FSLFRT_DEPTH_ANYPATH} FSLF_ReturnType_e;
//if loc is valid, loc->search is always filled in, the others are filled on success.
//returns -1 if couldn't find.
int FS_FLocateFile(char *filename, FSLF_ReturnType_e returntype, flocation_t *loc);
int FS_FLocateFile(const char *filename, FSLF_ReturnType_e returntype, flocation_t *loc);
struct vfsfile_s *FS_OpenReadLocation(flocation_t *location);
char *FS_WhichPackForLocation(flocation_t *loc);
char *FS_GetPackHashes(char *buffer, int buffersize, qboolean referencedonly);
char *FS_GetPackNames(char *buffer, int buffersize, qboolean referencedonly);
int COM_FOpenFile (char *filename, FILE **file);
int COM_FOpenWriteFile (char *filename, FILE **file);
int COM_FOpenFile (const char *filename, FILE **file);
int COM_FOpenWriteFile (const char *filename, FILE **file);
//#ifdef _MSC_VER //this is enough to annoy me, without conflicting with other (more bizzare) platforms.
//#define fopen dont_use_fopen
@ -316,7 +318,7 @@ void COM_CloseFile (FILE *h);
typedef struct vfsfile_s {
int (*ReadBytes) (struct vfsfile_s *file, void *buffer, int bytestoread);
int (*WriteBytes) (struct vfsfile_s *file, void *buffer, int bytestoread);
int (*WriteBytes) (struct vfsfile_s *file, const void *buffer, int bytestoread);
qboolean (*Seek) (struct vfsfile_s *file, unsigned long pos); //returns false for error
unsigned long (*Tell) (struct vfsfile_s *file);
unsigned long (*GetLen) (struct vfsfile_s *file); //could give some lag
@ -332,54 +334,58 @@ typedef struct vfsfile_s {
#define VFS_READ(vf,buffer,buflen) (vf->ReadBytes(vf,buffer,buflen))
#define VFS_WRITE(vf,buffer,buflen) (vf->WriteBytes(vf,buffer,buflen))
#define VFS_FLUSH(vf) do{if(vf->Flush)vf->Flush(vf);}while(0)
#define VFS_PUTS(vf,s) do{const char *t=s;vf->WriteBytes(vf,t,strlen(t));}while(0)
char *VFS_GETS(vfsfile_t *vf, char *buffer, int buflen);
void VFS_PRINTF(vfsfile_t *vf, char *fmt, ...);
enum fs_relative{
FS_GAME, //standard search (not generally valid for save/rename/delete/etc)
FS_ROOT, //./
FS_GAMEONLY, //$gamedir/
FS_CONFIGONLY, //fte/ (should still be part of the game path)
FS_SKINS //qw/skins/
};
void FS_FlushFSHash(void);
void FS_CreatePath(char *pname, int relativeto);
int FS_Rename(char *oldf, char *newf, int relativeto); //0 on success, non-0 on error
int FS_Rename2(char *oldf, char *newf, int oldrelativeto, int newrelativeto);
int FS_Remove(char *fname, int relativeto); //0 on success, non-0 on error
qboolean FS_WriteFile (char *filename, void *data, int len, int relativeto);
vfsfile_t *FS_OpenVFS(char *filename, char *mode, int relativeto);
void FS_CreatePath(const char *pname, enum fs_relative relativeto);
int FS_Rename(const char *oldf, const char *newf, enum fs_relative relativeto); //0 on success, non-0 on error
int FS_Rename2(const char *oldf, const char *newf, enum fs_relative oldrelativeto, enum fs_relative newrelativeto);
int FS_Remove(const char *fname, int relativeto); //0 on success, non-0 on error
qboolean FS_NativePath(const char *fname, enum fs_relative relativeto, char *out, int outlen); //if you really need to fopen yourself
qboolean FS_WriteFile (const char *filename, const void *data, int len, enum fs_relative relativeto);
vfsfile_t *FS_OpenVFS(const char *filename, const char *mode, enum fs_relative relativeto);
vfsfile_t *FS_OpenTemp(void);
vfsfile_t *FS_OpenTCP(char *name);
vfsfile_t *FS_OpenTCP(const char *name);
void FS_UnloadPackFiles(void);
void FS_ReloadPackFiles(void);
char *FS_GenerateClientPacksList(char *buffer, int maxlen, int basechecksum);
enum {
FS_GAME,
FS_ROOT,
FS_GAMEONLY,
FS_CONFIGONLY,
FS_SKINS
};
char *FSQ3_GenerateClientPacksList(char *buffer, int maxlen, int basechecksum);
int COM_filelength (FILE *f);
qbyte *COM_LoadStackFile (char *path, void *buffer, int bufsize);
qbyte *COM_LoadTempFile (char *path);
qbyte *COM_LoadTempFile2 (char *path); //allocates a little bit more without freeing old temp
qbyte *COM_LoadHunkFile (char *path);
qbyte *COM_LoadMallocFile (char *path);
void COM_LoadCacheFile (char *path, struct cache_user_s *cu);
qbyte *COM_LoadStackFile (const char *path, void *buffer, int bufsize);
qbyte *COM_LoadTempFile (const char *path);
qbyte *COM_LoadTempFile2 (const char *path); //allocates a little bit more without freeing old temp
qbyte *COM_LoadHunkFile (const char *path);
qbyte *COM_LoadMallocFile (const char *path);
void COM_LoadCacheFile (const char *path, struct cache_user_s *cu);
void COM_CreatePath (char *path);
void COM_Gamedir (char *dir);
void FS_ForceToPure(char *str, char *crcs, int seed);
void COM_Gamedir (const char *dir);
void FS_ForceToPure(const char *str, const char *crcs, int seed);
char *COM_GetPathInfo (int i, int *crc);
char *COM_NextPath (char *prevpath);
void COM_FlushFSCache(void); //a file was written using fopen
void COM_RefreshFSCache_f(void);
qboolean COM_LoadMapPackFile(char *name, int offset);
qboolean COM_LoadMapPackFile(const char *name, int offset);
void COM_FlushTempoaryPacks(void);
void COM_EnumerateFiles (char *match, int (*func)(char *, int, void *), void *parm);
void COM_EnumerateFiles (const char *match, int (*func)(const char *, int, void *), void *parm);
extern struct cvar_s registered;
extern qboolean standard_quake; //fixme: remove
void COM_Effectinfo_Clear(void);
unsigned int COM_Effectinfo_ForName(char *efname);
unsigned int COM_Effectinfo_ForName(const char *efname);
char *COM_Effectinfo_ForNumber(unsigned int efnum);
#define MAX_INFO_KEY 64

View file

@ -26,15 +26,18 @@ cvar_group_t *cvar_groups;
//cvar_t *cvar_vars;
static char *cvar_null_string = "";
static char *cvar_zero_string = "0";
static char *cvar_one_string = "1";
char *Cvar_DefaultAlloc(char *str)
{
char *c;
if (str[0] == '\0')
return cvar_null_string;
if (str[0] == '0' && str[1] == '\0')
return cvar_zero_string;
if (str[0] == '1' && str[1] == '\0')
return cvar_one_string;
c = (char *)Z_Malloc(strlen(str)+1);
Q_strcpy(c, str);
@ -48,6 +51,8 @@ void Cvar_DefaultFree(char *str)
return;
else if (str == cvar_zero_string)
return;
else if (str == cvar_one_string)
return;
else
Z_Free(str);
}
@ -868,7 +873,8 @@ void Cvar_Free(cvar_t *tbf)
}
unlinked:
Z_Free(tbf->string);
Cvar_DefaultFree(tbf->defaultstr);
if (tbf->flags & CVAR_FREEDEFAULT)
Cvar_DefaultFree(tbf->defaultstr);
if (tbf->latched_string)
Z_Free(tbf->latched_string);
Z_Free(tbf);
@ -886,10 +892,12 @@ qboolean Cvar_Register (cvar_t *variable, const char *groupname)
{
cvar_t *old;
cvar_group_t *group;
char value[512];
char *initial;
// copy the value off, because future sets will Z_Free it
strcpy (value, variable->string);
if (variable->defaultstr)
initial = variable->defaultstr;
else
initial = variable->string;
// check to see if it has already been defined
old = Cvar_FindVar (variable->name);
@ -900,7 +908,7 @@ qboolean Cvar_Register (cvar_t *variable, const char *groupname)
group = Cvar_GetGroup(groupname);
variable->modified = old->modified;
variable->flags |= old->flags & CVAR_ARCHIVE;
variable->flags |= (old->flags & CVAR_ARCHIVE);
// link the variable in
variable->next = group->cvars;
@ -911,7 +919,10 @@ qboolean Cvar_Register (cvar_t *variable, const char *groupname)
variable->string = (char*)Z_Malloc (1);
//cheat prevention - engine set default is the one that stays.
variable->defaultstr = Cvar_DefaultAlloc(value); //give it it's default (for server controlled vars and things)
if (variable->flags & CVAR_FREEDEFAULT)
variable->defaultstr = Cvar_DefaultAlloc(initial);
else
variable->defaultstr = initial;
// set it through the function to be consistant
if (old->latched_string)
@ -943,19 +954,17 @@ qboolean Cvar_Register (cvar_t *variable, const char *groupname)
variable->string = (char*)Z_Malloc (1);
variable->defaultstr = Cvar_DefaultAlloc(value); //give it it's default (for server controlled vars and things)
if (variable->flags & CVAR_FREEDEFAULT)
variable->defaultstr = Cvar_DefaultAlloc(initial);
else
variable->defaultstr = initial;
// set it through the function to be consistant
Cvar_SetCore (variable, value, true);
Cvar_SetCore (variable, initial, true);
return true;
}
/*
void Cvar_RegisterVariable (cvar_t *variable)
{
Cvar_Register(variable, NULL);
}
*/
cvar_t *Cvar_Get(const char *name, const char *defaultvalue, int flags, const char *group)
{
cvar_t *var;
@ -979,7 +988,7 @@ cvar_t *Cvar_Get(const char *name, const char *defaultvalue, int flags, const ch
var->name = (char *)(var+1);
strcpy(var->name, name);
var->string = (char*)defaultvalue;
var->flags = flags|CVAR_POINTER|CVAR_USERCREATED;
var->flags = flags|CVAR_POINTER|CVAR_FREEDEFAULT|CVAR_USERCREATED;
if (!Cvar_Register(var, group))
return NULL;
@ -1203,9 +1212,16 @@ void Cvar_Shutdown(void)
var = cvar_groups->cvars;
cvar_groups->cvars = var->next;
if (var->flags & CVAR_FREEDEFAULT)
{
Cvar_DefaultFree(var->defaultstr);
var->defaultstr = NULL;
}
Z_Free(var->string);
if (var->flags & CVAR_POINTER)
Z_Free(var);
else
var->string = NULL;
}
grp = cvar_groups;

View file

@ -103,17 +103,18 @@ typedef struct cvar_group_s
//freestyle
#define CVAR_POINTER (1<<5) // q2 style. May be converted to q1 if needed. These are often specified on the command line and then converted into q1 when registered properly.
#define CVAR_NOTFROMSERVER (1<<6) // the console will ignore changes to cvars if set at from the server or any gamecode. This is to protect against security flaws - like qterm
#define CVAR_USERCREATED (1<<7) //write a 'set' or 'seta' in front of the var name.
#define CVAR_CHEAT (1<<8) //latch to the default, unless cheats are enabled.
#define CVAR_SEMICHEAT (1<<9) //if strict ruleset, force to 0/blank.
#define CVAR_RENDERERLATCH (1<<10) //requires a vid_restart to reapply.
#define CVAR_SERVEROVERRIDE (1<<11) //the server has overridden out local value - should probably be called SERVERLATCH
#define CVAR_RENDERERCALLBACK (1<<12) //force callback for cvars on renderer change
#define CVAR_NOUNSAFEEXPAND (1<<13) // do not expand cvar value when command is from gamecode
#define CVAR_RULESETLATCH (1<<14) //latched by the ruleset
#define CVAR_FREEDEFAULT (1<<6) // q2 style. May be converted to q1 if needed. These are often specified on the command line and then converted into q1 when registered properly.
#define CVAR_NOTFROMSERVER (1<<7) // the console will ignore changes to cvars if set at from the server or any gamecode. This is to protect against security flaws - like qterm
#define CVAR_USERCREATED (1<<8) //write a 'set' or 'seta' in front of the var name.
#define CVAR_CHEAT (1<<9) //latch to the default, unless cheats are enabled.
#define CVAR_SEMICHEAT (1<<10) //if strict ruleset, force to 0/blank.
#define CVAR_RENDERERLATCH (1<<11) //requires a vid_restart to reapply.
#define CVAR_SERVEROVERRIDE (1<<12) //the server has overridden out local value - should probably be called SERVERLATCH
#define CVAR_RENDERERCALLBACK (1<<13) //force callback for cvars on renderer change
#define CVAR_NOUNSAFEEXPAND (1<<14) // do not expand cvar value when command is from gamecode
#define CVAR_RULESETLATCH (1<<15) //latched by the ruleset
#define CVAR_LASTFLAG CVAR_NOUNSAFEEXPAND
#define CVAR_LASTFLAG CVAR_RULESETLATCH
#define CVAR_LATCHMASK (CVAR_LATCH|CVAR_RENDERERLATCH|CVAR_SERVEROVERRIDE|CVAR_CHEAT|CVAR_SEMICHEAT) //you're only allowed one of these.
#define CVAR_NEEDDEFAULT CVAR_CHEAT
@ -129,8 +130,6 @@ qboolean Cvar_Register (cvar_t *variable, const char *cvargroup);
// registers a cvar that already has the name, string, and optionally the
// archive elements set.
//#define Cvar_RegisterVariable(x) Cvar_Register(x,__FILE__);
cvar_t *Cvar_ForceSet (cvar_t *var, const char *value);
cvar_t *Cvar_Set (cvar_t *var, const char *value);
// equivelant to "<name> <variable>" typed at the console

File diff suppressed because it is too large Load diff

30
engine/common/fs.h Normal file
View file

@ -0,0 +1,30 @@
#include "hash.h"
extern hashtable_t filesystemhash; //this table is the one to build your hash references into
extern int fs_hash_dups; //for tracking efficiency. no functional use.
extern int fs_hash_files; //for tracking efficiency. no functional use.
typedef struct {
void (*PrintPath)(void *handle);
void (*ClosePath)(void *handle);
void (*BuildHash)(void *handle);
qboolean (*FindFile)(void *handle, flocation_t *loc, const char *name, void *hashedresult); //true if found (hashedresult can be NULL)
//note that if rawfile and offset are set, many Com_FileOpens will read the raw file
//otherwise ReadFile will be called instead.
void (*ReadFile)(void *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 (*EnumerateFiles)(void *handle, const char *match, int (*func)(const char *, int, void *), void *parm);
void *(*OpenNew)(vfsfile_t *file, const char *desc); //returns a handle to a new pak/path
int (*GeneratePureCRC) (void *handle, int seed, int usepure);
vfsfile_t *(*OpenVFS)(void *handle, flocation_t *loc, const char *mode);
} searchpathfuncs_t;
//the stdio filesystem is special as that's the starting point of the entire filesystem
//warning: the handle is known to be a string pointer to the dir name
extern searchpathfuncs_t osfilefuncs;
vfsfile_t *VFSOS_Open(const char *osname, const char *mode);
int FS_RegisterFileSystemType(const char *extension, searchpathfuncs_t *funcs);
void FS_UnRegisterFileSystemType(int idx);

544
engine/common/fs_pak.c Normal file
View file

@ -0,0 +1,544 @@
#include "quakedef.h"
#include "fs.h"
//
// in memory
//
typedef struct
{
char name[MAX_QPATH];
int filepos, filelen;
bucket_t bucket;
} packfile_t;
typedef struct pack_s
{
char descname[MAX_OSPATH];
vfsfile_t *handle;
unsigned int filepos; //the pos the subfiles left it at (to optimize calls to vfs_seek)
int numfiles;
packfile_t *files;
int references; //seeing as all vfiles from a pak file use the parent's vfsfile, we need to keep the parent open until all subfiles are closed.
} pack_t;
//
// on disk
//
typedef struct
{
char name[56];
int filepos, filelen;
} dpackfile_t;
typedef struct
{
int filepos, filelen;
char name[8];
} dwadfile_t;
typedef struct
{
char id[4];
int dirofs;
int dirlen;
} dpackheader_t;
typedef struct
{
char id[4];
int dirlen;
int dirofs;
} dwadheader_t;
#define MAX_FILES_IN_PACK 2048
void FSPAK_PrintPath(void *handle)
{
pack_t *pak = handle;
if (pak->references != 1)
Con_Printf("%s (%i)\n", pak->descname, pak->references-1);
else
Con_Printf("%s\n", pak->descname);
}
void FSPAK_ClosePath(void *handle)
{
pack_t *pak = handle;
pak->references--;
if (pak->references > 0)
return; //not free yet
VFS_CLOSE (pak->handle);
if (pak->files)
Z_Free(pak->files);
Z_Free(pak);
}
void FSPAK_BuildHash(void *handle)
{
pack_t *pak = handle;
int i;
for (i = 0; i < pak->numfiles; i++)
{
if (!Hash_GetInsensative(&filesystemhash, pak->files[i].name))
{
fs_hash_files++;
Hash_AddInsensative(&filesystemhash, pak->files[i].name, &pak->files[i], &pak->files[i].bucket);
}
else
fs_hash_dups++;
}
}
qboolean FSPAK_FLocate(void *handle, flocation_t *loc, const char *filename, void *hashedresult)
{
packfile_t *pf = hashedresult;
int i, len;
pack_t *pak = handle;
// look through all the pak file elements
if (pf)
{ //is this a pointer to a file in this pak?
if (pf < pak->files || pf > pak->files + pak->numfiles)
return false; //was found in a different path
}
else
{
for (i=0 ; i<pak->numfiles ; i++) //look for the file
{
if (!strcmp (pak->files[i].name, filename))
{
pf = &pak->files[i];
break;
}
}
}
if (pf)
{
len = pf->filelen;
if (loc)
{
loc->index = pf - pak->files;
snprintf(loc->rawname, sizeof(loc->rawname), "%s", pak->descname);
loc->offset = pf->filepos;
loc->len = pf->filelen;
}
return true;
}
return false;
}
int FSPAK_EnumerateFiles (void *handle, const char *match, int (*func)(const char *, int, void *), void *parm)
{
pack_t *pak = handle;
int num;
for (num = 0; num<(int)pak->numfiles; num++)
{
if (wildcmp(match, pak->files[num].name))
{
if (!func(pak->files[num].name, pak->files[num].filelen, parm))
return false;
}
}
return true;
}
/*
=================
COM_LoadPackFile
Takes an explicit (not game tree related) path to a pak file.
Loads the header and directory, adding the files at the beginning
of the list so they override previous pack files.
=================
*/
void *FSPAK_LoadPackFile (vfsfile_t *file, const char *desc)
{
dpackheader_t header;
int i;
// int j;
packfile_t *newfiles;
int numpackfiles;
pack_t *pack;
vfsfile_t *packhandle;
dpackfile_t info;
int read;
// unsigned short crc;
packhandle = file;
if (packhandle == NULL)
return NULL;
VFS_READ(packhandle, &header, sizeof(header));
if (header.id[0] != 'P' || header.id[1] != 'A'
|| header.id[2] != 'C' || header.id[3] != 'K')
{
VFS_CLOSE(packhandle);
return NULL;
// Sys_Error ("%s is not a packfile", packfile);
}
header.dirofs = LittleLong (header.dirofs);
header.dirlen = LittleLong (header.dirlen);
numpackfiles = header.dirlen / sizeof(dpackfile_t);
// if (numpackfiles > MAX_FILES_IN_PACK)
// Sys_Error ("%s has %i files", packfile, numpackfiles);
// if (numpackfiles != PAK0_COUNT)
// com_modified = true; // not the original file
newfiles = (packfile_t*)Z_Malloc (numpackfiles * sizeof(packfile_t));
VFS_SEEK(packhandle, header.dirofs);
// fread (&info, 1, header.dirlen, packhandle);
// crc the directory to check for modifications
// crc = QCRC_Block((qbyte *)info, header.dirlen);
// QCRC_Init (&crc);
pack = (pack_t*)Z_Malloc (sizeof (pack_t));
// parse the directory
for (i=0 ; i<numpackfiles ; i++)
{
*info.name = '\0';
read = VFS_READ(packhandle, &info, sizeof(info));
/*
for (j=0 ; j<sizeof(info) ; j++)
CRC_ProcessByte(&crc, ((qbyte *)&info)[j]);
*/
strcpy (newfiles[i].name, info.name);
COM_CleanUpPath(newfiles[i].name); //blooming tanks.
newfiles[i].filepos = LittleLong(info.filepos);
newfiles[i].filelen = LittleLong(info.filelen);
}
/*
if (crc != PAK0_CRC)
com_modified = true;
*/
strcpy (pack->descname, desc);
pack->handle = packhandle;
pack->numfiles = numpackfiles;
pack->files = newfiles;
pack->filepos = 0;
VFS_SEEK(packhandle, pack->filepos);
pack->references++;
Con_TPrintf (TL_ADDEDPACKFILE, desc, numpackfiles);
return pack;
}
typedef struct {
vfsfile_t funcs;
pack_t *parentpak;
unsigned long startpos;
unsigned long length;
unsigned long currentpos;
} vfspack_t;
int VFSPAK_ReadBytes (struct vfsfile_s *vfs, void *buffer, int bytestoread)
{
vfspack_t *vfsp = (vfspack_t*)vfs;
int read;
if (bytestoread == 0)
return 0;
if (vfsp->currentpos - vfsp->startpos + bytestoread > vfsp->length)
bytestoread = vfsp->length - (vfsp->currentpos - vfsp->startpos);
if (bytestoread <= 0)
{
return -1;
}
if (vfsp->parentpak->filepos != vfsp->currentpos)
VFS_SEEK(vfsp->parentpak->handle, vfsp->currentpos);
read = VFS_READ(vfsp->parentpak->handle, buffer, bytestoread);
vfsp->currentpos += read;
vfsp->parentpak->filepos = vfsp->currentpos;
return read;
}
int VFSPAK_WriteBytes (struct vfsfile_s *vfs, const void *buffer, int bytestoread)
{ //not supported.
Sys_Error("Cannot write to pak files\n");
return 0;
}
qboolean VFSPAK_Seek (struct vfsfile_s *vfs, unsigned long pos)
{
vfspack_t *vfsp = (vfspack_t*)vfs;
if (pos < 0 || pos > vfsp->length)
return false;
vfsp->currentpos = pos + vfsp->startpos;
return true;
}
unsigned long VFSPAK_Tell (struct vfsfile_s *vfs)
{
vfspack_t *vfsp = (vfspack_t*)vfs;
return vfsp->currentpos - vfsp->startpos;
}
unsigned long VFSPAK_GetLen (struct vfsfile_s *vfs)
{
vfspack_t *vfsp = (vfspack_t*)vfs;
return vfsp->length;
}
void VFSPAK_Close(vfsfile_t *vfs)
{
vfspack_t *vfsp = (vfspack_t*)vfs;
FSPAK_ClosePath(vfsp->parentpak); //tell the parent that we don't need it open any more (reference counts)
Z_Free(vfsp); //free ourselves.
}
vfsfile_t *FSPAK_OpenVFS(void *handle, flocation_t *loc, const char *mode)
{
pack_t *pack = (pack_t*)handle;
vfspack_t *vfs;
if (strcmp(mode, "rb"))
return NULL; //urm, unable to write/append
vfs = Z_Malloc(sizeof(vfspack_t));
vfs->parentpak = pack;
vfs->parentpak->references++;
vfs->startpos = loc->offset;
vfs->length = loc->len;
vfs->currentpos = vfs->startpos;
vfs->funcs.Close = VFSPAK_Close;
vfs->funcs.GetLen = VFSPAK_GetLen;
vfs->funcs.ReadBytes = VFSPAK_ReadBytes;
vfs->funcs.Seek = VFSPAK_Seek;
vfs->funcs.Tell = VFSPAK_Tell;
vfs->funcs.WriteBytes = VFSPAK_WriteBytes; //not supported
return (vfsfile_t *)vfs;
}
void FSPAK_ReadFile(void *handle, flocation_t *loc, char *buffer)
{
vfsfile_t *f;
f = FSPAK_OpenVFS(handle, loc, "rb");
if (!f) //err...
return;
VFS_READ(f, buffer, loc->len);
VFS_CLOSE(f);
/*
FILE *f;
f = fopen(loc->rawname, "rb");
if (!f) //err...
return;
fseek(f, loc->offset, SEEK_SET);
fread(buffer, 1, loc->len, f);
fclose(f);
*/
}
searchpathfuncs_t packfilefuncs = {
FSPAK_PrintPath,
FSPAK_ClosePath,
FSPAK_BuildHash,
FSPAK_FLocate,
FSPAK_ReadFile,
FSPAK_EnumerateFiles,
FSPAK_LoadPackFile,
NULL,
FSPAK_OpenVFS
};
#ifdef DOOMWADS
void *FSPAK_LoadDoomWadFile (vfsfile_t *packhandle, char *desc)
{
dwadheader_t header;
int i;
packfile_t *newfiles;
int numpackfiles;
pack_t *pack;
dwadfile_t info;
int section=0;
char sectionname[MAX_QPATH];
char filename[52];
char neatwadname[52];
if (packhandle == NULL)
return NULL;
VFS_READ(packhandle, &header, sizeof(header));
if (header.id[1] != 'W' || header.id[2] != 'A' || header.id[3] != 'D')
return NULL; //not a doom wad
//doom wads come in two sorts. iwads and pwads.
//iwads are the master wads, pwads are meant to replace parts of the master wad.
//this is awkward, of course.
//we ignore the i/p bit for the most part, but with maps, pwads are given a prefixed name.
if (header.id[0] == 'I')
*neatwadname = '\0';
else if (header.id[0] == 'P')
{
COM_FileBase(desc, neatwadname, sizeof(neatwadname));
strcat(neatwadname, "#");
}
else
return NULL;
header.dirofs = LittleLong (header.dirofs);
header.dirlen = LittleLong (header.dirlen);
numpackfiles = header.dirlen;
newfiles = (packfile_t*)Z_Malloc (numpackfiles * sizeof(packfile_t));
VFS_SEEK(packhandle, header.dirofs);
//doom wads are awkward.
//they have no directory structure, except for start/end 'files'.
//they follow along the lines of lumps after the parent name.
//a map is the name of that map, and then a squence of the lumps that form that map (found by next-with-that-name).
//this is a problem for a real virtual filesystem, so we add a hack to recognise special names and expand them specially.
for (i=0 ; i<numpackfiles ; i++)
{
VFS_READ (packhandle, &info, sizeof(info));
strcpy (filename, info.name);
filename[8] = '\0';
Q_strlwr(filename);
newfiles[i].filepos = LittleLong(info.filepos);
newfiles[i].filelen = LittleLong(info.filelen);
switch(section) //be prepared to remap filenames.
{
newsection:
case 0:
if (info.filelen == 0)
{ //marker for something...
if (!strcmp(filename, "s_start"))
{
section = 2;
sprintf (newfiles[i].name, "sprites/%s", filename); //the model loader has a hack to recognise .dsp
break;
}
if (!strcmp(filename, "p_start"))
{
section = 3;
sprintf (newfiles[i].name, "patches/%s", filename); //the map loader will find these.
break;
}
if (!strcmp(filename, "f_start"))
{
section = 4;
sprintf (newfiles[i].name, "flats/%s", filename); //the map loader will find these
break;
}
if ((filename[0] == 'e' && filename[2] == 'm') || !strncmp(filename, "map", 3))
{ //this is the start of a beutiful new map
section = 1;
strcpy(sectionname, filename);
sprintf (newfiles[i].name, "maps/%s%s.bsp", neatwadname, filename); //generate fake bsps to allow the server to find them
newfiles[i].filepos = 0;
newfiles[i].filelen = 4;
break;
}
if (!strncmp(filename, "gl_", 3) && ((filename[4] == 'e' && filename[5] == 'm') || !strncmp(filename+3, "map", 3)))
{ //this is the start of a beutiful new map
section = 5;
strcpy(sectionname, filename+3);
break;
}
}
sprintf (newfiles[i].name, "wad/%s", filename); //but there are many files that we don't recognise/know about. archive them off to keep the vfs moderatly clean.
break;
case 1: //map section
if (strcmp(filename, "things") &&
strcmp(filename, "linedefs") &&
strcmp(filename, "sidedefs") &&
strcmp(filename, "vertexes") &&
strcmp(filename, "segs") &&
strcmp(filename, "ssectors") &&
strcmp(filename, "nodes") &&
strcmp(filename, "sectors") &&
strcmp(filename, "reject") &&
strcmp(filename, "blockmap"))
{
section = 0;
goto newsection;
}
sprintf (newfiles[i].name, "maps/%s%s.%s", neatwadname, sectionname, filename);
break;
case 5: //glbsp output section
if (strcmp(filename, "gl_vert") &&
strcmp(filename, "gl_segs") &&
strcmp(filename, "gl_ssect") &&
strcmp(filename, "gl_pvs") &&
strcmp(filename, "gl_nodes"))
{
section = 0;
goto newsection;
}
sprintf (newfiles[i].name, "maps/%s%s.%s", neatwadname, sectionname, filename);
break;
case 2: //sprite section
if (!strcmp(filename, "s_end"))
{
section = 0;
goto newsection;
}
sprintf (newfiles[i].name, "sprites/%s", filename);
break;
case 3: //patches section
if (!strcmp(filename, "p_end"))
{
section = 0;
goto newsection;
}
sprintf (newfiles[i].name, "patches/%s", filename);
break;
case 4: //flats section
if (!strcmp(filename, "f_end"))
{
section = 0;
goto newsection;
}
sprintf (newfiles[i].name, "flats/%s", filename);
break;
}
}
pack = (pack_t*)Z_Malloc (sizeof (pack_t));
strcpy (pack->descname, desc);
pack->handle = packhandle;
pack->numfiles = numpackfiles;
pack->files = newfiles;
pack->filepos = 0;
VFS_SEEK(packhandle, pack->filepos);
pack->references++;
Con_TPrintf (TL_ADDEDPACKFILE, desc, numpackfiles);
return pack;
}
searchpathfuncs_t doomwadfilefuncs = {
FSPAK_PrintPath,
FSPAK_ClosePath,
FSPAK_BuildHash,
FSPAK_FLocate,
FSPAK_ReadFile,
FSPAK_EnumerateFiles,
FSPAK_LoadDoomWadFile,
NULL,
FSPAK_OpenVFS
};
#endif

226
engine/common/fs_stdio.c Normal file
View file

@ -0,0 +1,226 @@
#include "quakedef.h"
#include "fs.h"
typedef struct {
vfsfile_t funcs;
FILE *handle;
} vfsosfile_t;
int VFSOS_ReadBytes (struct vfsfile_s *file, void *buffer, int bytestoread)
{
vfsosfile_t *intfile = (vfsosfile_t*)file;
return fread(buffer, 1, bytestoread, intfile->handle);
}
int VFSOS_WriteBytes (struct vfsfile_s *file, const void *buffer, int bytestoread)
{
vfsosfile_t *intfile = (vfsosfile_t*)file;
return fwrite(buffer, 1, bytestoread, intfile->handle);
}
qboolean VFSOS_Seek (struct vfsfile_s *file, unsigned long pos)
{
vfsosfile_t *intfile = (vfsosfile_t*)file;
return fseek(intfile->handle, pos, SEEK_SET) == 0;
}
unsigned long VFSOS_Tell (struct vfsfile_s *file)
{
vfsosfile_t *intfile = (vfsosfile_t*)file;
return ftell(intfile->handle);
}
void VFSOS_Flush(struct vfsfile_s *file)
{
vfsosfile_t *intfile = (vfsosfile_t*)file;
fflush(intfile->handle);
}
unsigned long VFSOS_GetSize (struct vfsfile_s *file)
{
vfsosfile_t *intfile = (vfsosfile_t*)file;
unsigned int curpos;
unsigned int maxlen;
curpos = ftell(intfile->handle);
fseek(intfile->handle, 0, SEEK_END);
maxlen = ftell(intfile->handle);
fseek(intfile->handle, curpos, SEEK_SET);
return maxlen;
}
void VFSOS_Close(vfsfile_t *file)
{
vfsosfile_t *intfile = (vfsosfile_t*)file;
fclose(intfile->handle);
Z_Free(file);
}
vfsfile_t *FS_OpenTemp(void)
{
FILE *f;
vfsosfile_t *file;
f = tmpfile();
if (!f)
return NULL;
file = Z_Malloc(sizeof(vfsosfile_t));
file->funcs.ReadBytes = VFSOS_ReadBytes;
file->funcs.WriteBytes = VFSOS_WriteBytes;
file->funcs.Seek = VFSOS_Seek;
file->funcs.Tell = VFSOS_Tell;
file->funcs.GetLen = VFSOS_GetSize;
file->funcs.Close = VFSOS_Close;
file->funcs.Flush = VFSOS_Flush;
file->handle = f;
return (vfsfile_t*)file;
}
vfsfile_t *VFSOS_Open(const char *osname, const char *mode)
{
FILE *f;
vfsosfile_t *file;
qboolean read = !!strchr(mode, 'r');
qboolean write = !!strchr(mode, 'w');
qboolean append = !!strchr(mode, 'a');
qboolean text = !!strchr(mode, 't');
char newmode[3];
int modec = 0;
if (read)
newmode[modec++] = 'r';
if (write)
newmode[modec++] = 'w';
if (append)
newmode[modec++] = 'a';
if (text)
newmode[modec++] = 't';
else
newmode[modec++] = 'b';
newmode[modec++] = '\0';
f = fopen(osname, newmode);
if (!f)
return NULL;
file = Z_Malloc(sizeof(vfsosfile_t));
file->funcs.ReadBytes = strchr(mode, 'r')?VFSOS_ReadBytes:NULL;
file->funcs.WriteBytes = (strchr(mode, 'w')||strchr(mode, 'a'))?VFSOS_WriteBytes:NULL;
file->funcs.Seek = VFSOS_Seek;
file->funcs.Tell = VFSOS_Tell;
file->funcs.GetLen = VFSOS_GetSize;
file->funcs.Close = VFSOS_Close;
file->funcs.Flush = VFSOS_Flush;
file->handle = f;
return (vfsfile_t*)file;
}
vfsfile_t *FSOS_OpenVFS(void *handle, flocation_t *loc, const char *mode)
{
char diskname[MAX_OSPATH];
//path is already cleaned, as anything that gets a valid loc needs cleaning up first.
snprintf(diskname, sizeof(diskname), "%s/%s", (char*)handle, loc->rawname);
return VFSOS_Open(diskname, mode);
}
void FSOS_PrintPath(void *handle)
{
Con_Printf("%s\n", handle);
}
void FSOS_ClosePath(void *handle)
{
Z_Free(handle);
}
int FSOS_RebuildFSHash(const char *filename, int filesize, void *data)
{
if (filename[strlen(filename)-1] == '/')
{ //this is actually a directory
char childpath[256];
sprintf(childpath, "%s*", filename);
Sys_EnumerateFiles((char*)data, childpath, FSOS_RebuildFSHash, data);
return true;
}
if (!Hash_GetInsensative(&filesystemhash, filename))
{
bucket_t *bucket = (bucket_t*)BZ_Malloc(sizeof(bucket_t) + strlen(filename)+1);
strcpy((char *)(bucket+1), filename);
#ifdef _WIN32
Q_strlwr((char *)(bucket+1));
#endif
Hash_AddInsensative(&filesystemhash, (char *)(bucket+1), data, bucket);
fs_hash_files++;
}
else
fs_hash_dups++;
return true;
}
void FSOS_BuildHash(void *handle)
{
Sys_EnumerateFiles(handle, "*", FSOS_RebuildFSHash, handle);
}
qboolean FSOS_FLocate(void *handle, flocation_t *loc, const char *filename, void *hashedresult)
{
FILE *f;
int len;
char netpath[MAX_OSPATH];
if (hashedresult && (void *)hashedresult != handle)
return false;
/*
if (!static_registered)
{ // if not a registered version, don't ever go beyond base
if ( strchr (filename, '/') || strchr (filename,'\\'))
continue;
}
*/
// check a file in the directory tree
snprintf (netpath, sizeof(netpath)-1, "%s/%s",(char*)handle, filename);
f = fopen(netpath, "rb");
if (!f)
return false;
fseek(f, 0, SEEK_END);
len = ftell(f);
fclose(f);
if (loc)
{
loc->len = len;
loc->offset = 0;
loc->index = 0;
Q_strncpyz(loc->rawname, filename, sizeof(loc->rawname));
}
return true;
}
void FSOS_ReadFile(void *handle, flocation_t *loc, char *buffer)
{
FILE *f;
f = fopen(loc->rawname, "rb");
if (!f) //err...
return;
fseek(f, loc->offset, SEEK_SET);
fread(buffer, 1, loc->len, f);
fclose(f);
}
int FSOS_EnumerateFiles (void *handle, const char *match, int (*func)(const char *, int, void *), void *parm)
{
return Sys_EnumerateFiles(handle, match, func, parm);
}
searchpathfuncs_t osfilefuncs = {
FSOS_PrintPath,
FSOS_ClosePath,
FSOS_BuildHash,
FSOS_FLocate,
FSOS_ReadFile,
FSOS_EnumerateFiles,
NULL,
NULL,
FSOS_OpenVFS
};

461
engine/common/fs_zip.c Normal file
View file

@ -0,0 +1,461 @@
#include "quakedef.h"
#include "fs.h"
#ifdef AVAIL_ZLIB
#ifndef ZEXPORT
#define ZEXPORT VARGS
#endif
#include <zlib.h>
#include "unzip.c"
#ifdef _WIN32
#pragma comment( lib, "../libs/zlib.lib" )
#endif
typedef struct
{
char name[MAX_QPATH];
int filepos, filelen;
bucket_t bucket;
} zpackfile_t;
typedef struct zipfile_s
{
char filename[MAX_QPATH];
unzFile handle;
int numfiles;
zpackfile_t *files;
#ifdef HASH_FILESYSTEM
hashtable_t hash;
#endif
vfsfile_t *raw;
vfsfile_t *currentfile; //our unzip.c can only handle one active file at any one time
//so we have to keep closing and switching.
//slow, but it works. most of the time we'll only have a single file open anyway.
int references; //and a reference count
} zipfile_t;
static void FSZIP_PrintPath(void *handle)
{
zipfile_t *zip = handle;
if (zip->references != 1)
Con_Printf("%s (%i)\n", zip->filename, zip->references-1);
else
Con_Printf("%s\n", zip->filename);
}
static void FSZIP_ClosePath(void *handle)
{
zipfile_t *zip = handle;
if (--zip->references > 0)
return; //not yet time
unzClose(zip->handle);
if (zip->files)
Z_Free(zip->files);
Z_Free(zip);
}
static void FSZIP_BuildHash(void *handle)
{
zipfile_t *zip = handle;
int i;
for (i = 0; i < zip->numfiles; i++)
{
if (!Hash_GetInsensative(&filesystemhash, zip->files[i].name))
{
fs_hash_files++;
Hash_AddInsensative(&filesystemhash, zip->files[i].name, &zip->files[i], &zip->files[i].bucket);
}
else
fs_hash_dups++;
}
}
static qboolean FSZIP_FLocate(void *handle, flocation_t *loc, const char *filename, void *hashedresult)
{
zpackfile_t *pf = hashedresult;
int i, len;
zipfile_t *zip = handle;
// look through all the pak file elements
if (pf)
{ //is this a pointer to a file in this pak?
if (pf < zip->files || pf >= zip->files + zip->numfiles)
return false; //was found in a different path
}
else
{
for (i=0 ; i<zip->numfiles ; i++) //look for the file
{
if (!stricmp (zip->files[i].name, filename))
{
pf = &zip->files[i];
break;
}
}
}
if (pf)
{
len = pf->filelen;
if (loc)
{
loc->index = pf - zip->files;
strcpy(loc->rawname, zip->filename);
loc->offset = pf->filepos;
loc->len = pf->filelen;
unzLocateFileMy (zip->handle, loc->index, zip->files[loc->index].filepos);
loc->offset = unzGetCurrentFileUncompressedPos(zip->handle);
// if (loc->offset<0)
// { //file not found, or is compressed.
// *loc->rawname = '\0';
// loc->offset=0;
// }
}
return true;
}
return false;
}
static void FSZIP_ReadFile(void *handle, flocation_t *loc, char *buffer)
{
zipfile_t *zip = handle;
int err;
unzLocateFileMy (zip->handle, loc->index, zip->files[loc->index].filepos);
unzOpenCurrentFile (zip->handle);
err = unzReadCurrentFile (zip->handle, buffer, zip->files[loc->index].filelen);
unzCloseCurrentFile (zip->handle);
if (err!=zip->files[loc->index].filelen)
{
Con_Printf ("Can't extract file \"%s:%s\" (corrupt)\n", zip->filename, zip->files[loc->index].name);
return;
}
return;
}
static int FSZIP_EnumerateFiles (void *handle, const char *match, int (*func)(const char *, int, void *), void *parm)
{
zipfile_t *zip = handle;
int num;
for (num = 0; num<(int)zip->numfiles; num++)
{
if (wildcmp(match, zip->files[num].name))
{
if (!func(zip->files[num].name, zip->files[num].filelen, parm))
return false;
}
}
return true;
}
/*
=================
COM_LoadZipFile
Takes an explicit (not game tree related) path to a pak file.
Loads the header and directory, adding the files at the beginning
of the list so they override previous pack files.
=================
*/
static void *FSZIP_LoadZipFile (vfsfile_t *packhandle, const char *desc)
{
int i;
int nextfileziphandle;
zipfile_t *zip;
zpackfile_t *newfiles;
unz_global_info globalinf = {0};
unz_file_info file_info;
zip = Z_Malloc(sizeof(zipfile_t));
Q_strncpyz(zip->filename, desc, sizeof(zip->filename));
zip->handle = unzOpen ((zip->raw = packhandle));
if (!zip->handle)
{
Z_Free(zip);
Con_TPrintf (TL_COULDNTOPENZIP, desc);
return NULL;
}
unzGetGlobalInfo (zip->handle, &globalinf);
zip->numfiles = globalinf.number_entry;
zip->files = newfiles = Z_Malloc (zip->numfiles * sizeof(zpackfile_t));
for (i = 0; i < zip->numfiles; i++)
{
if (unzGetCurrentFileInfo (zip->handle, &file_info, newfiles[i].name, sizeof(newfiles[i].name), NULL, 0, NULL, 0) != UNZ_OK)
Con_Printf("Zip Error\n");
Q_strlwr(newfiles[i].name);
newfiles[i].filelen = file_info.uncompressed_size;
newfiles[i].filepos = file_info.c_offset;
nextfileziphandle = unzGoToNextFile (zip->handle);
if (nextfileziphandle == UNZ_END_OF_LIST_OF_FILE)
break;
else if (nextfileziphandle != UNZ_OK)
Con_Printf("Zip Error\n");
}
zip->references = 1;
zip->currentfile = NULL;
Con_TPrintf (TL_ADDEDZIPFILE, desc, zip->numfiles);
return zip;
}
int FSZIP_GeneratePureCRC(void *handle, int seed, int crctype)
{
zipfile_t *zip = handle;
unz_file_info file_info;
int *filecrcs;
int numcrcs=0;
int i;
filecrcs = BZ_Malloc((zip->numfiles+1)*sizeof(int));
filecrcs[numcrcs++] = seed;
unzGoToFirstFile(zip->handle);
for (i = 0; i < zip->numfiles; i++)
{
if (zip->files[i].filelen>0)
{
unzGetCurrentFileInfo (zip->handle, &file_info, NULL, 0, NULL, 0, NULL, 0);
filecrcs[numcrcs++] = file_info.crc;
}
unzGoToNextFile (zip->handle);
}
if (crctype)
return Com_BlockChecksum(filecrcs, numcrcs*sizeof(int));
else
return Com_BlockChecksum(filecrcs+1, (numcrcs-1)*sizeof(int));
}
typedef struct {
vfsfile_t funcs;
vfsfile_t *defer;
//in case we're forced away.
zipfile_t *parent;
qboolean iscompressed;
int pos;
int length; //try and optimise some things
int index;
int startpos;
} vfszip_t;
void VFSZIP_MakeActive(vfszip_t *vfsz)
{
int i;
char buffer[8192]; //must be power of two
if ((vfszip_t*)vfsz->parent->currentfile == vfsz)
return; //already us
if (vfsz->parent->currentfile)
unzCloseCurrentFile(vfsz->parent->handle);
unzLocateFileMy(vfsz->parent->handle, vfsz->index, vfsz->startpos);
unzOpenCurrentFile(vfsz->parent->handle);
if (vfsz->pos > 0)
{
Con_DPrintf("VFSZIP_MakeActive: Shockingly inefficient\n");
//now we need to seek up to where we had previously gotten to.
for (i = 0; i < vfsz->pos-sizeof(buffer); i++)
unzReadCurrentFile(vfsz->parent->handle, buffer, sizeof(buffer));
unzReadCurrentFile(vfsz->parent->handle, buffer, vfsz->pos - i);
}
vfsz->parent->currentfile = (vfsfile_t*)vfsz;
}
int VFSZIP_ReadBytes (struct vfsfile_s *file, void *buffer, int bytestoread)
{
int read;
vfszip_t *vfsz = (vfszip_t*)file;
if (vfsz->defer)
return VFS_READ(vfsz->defer, buffer, bytestoread);
if (vfsz->iscompressed)
{
VFSZIP_MakeActive(vfsz);
read = unzReadCurrentFile(vfsz->parent->handle, buffer, bytestoread);
}
else
{
if (vfsz->parent->currentfile != file)
{
unzCloseCurrentFile(vfsz->parent->handle);
VFS_SEEK(vfsz->parent->raw, vfsz->pos+vfsz->startpos);
vfsz->parent->currentfile = file;
}
read = VFS_READ(vfsz->parent->raw, buffer, bytestoread);
}
vfsz->pos += read;
return read;
}
int VFSZIP_WriteBytes (struct vfsfile_s *file, void *buffer, int bytestoread)
{
Sys_Error("VFSZIP_WriteBytes: Not supported\n");
return 0;
}
qboolean VFSZIP_Seek (struct vfsfile_s *file, unsigned long pos)
{
vfszip_t *vfsz = (vfszip_t*)file;
if (vfsz->defer)
return VFS_SEEK(vfsz->defer, pos);
//This is *really* inefficient
if (vfsz->parent->currentfile == file)
{
if (vfsz->iscompressed)
{ //if they're going to seek on a file in a zip, let's just copy it out
char buffer[8192];
unsigned int chunk;
unsigned int i;
unsigned int length;
vfsz->defer = FS_OpenTemp();
if (vfsz->defer)
{
unzCloseCurrentFile(vfsz->parent->handle);
vfsz->parent->currentfile = NULL; //make it not us
length = vfsz->length;
i = 0;
vfsz->pos = 0;
VFSZIP_MakeActive(vfsz);
while (1)
{
chunk = length - i;
if (chunk > sizeof(buffer))
chunk = sizeof(buffer);
if (chunk == 0)
break;
unzReadCurrentFile(vfsz->parent->handle, buffer, chunk);
VFS_WRITE(vfsz->defer, buffer, chunk);
i += chunk;
}
}
}
unzCloseCurrentFile(vfsz->parent->handle);
vfsz->parent->currentfile = NULL; //make it not us
if (vfsz->defer)
return VFS_SEEK(vfsz->defer, pos);
}
if (pos < 0 || pos > vfsz->length)
return false;
vfsz->pos = pos;
return true;
}
unsigned long VFSZIP_Tell (struct vfsfile_s *file)
{
vfszip_t *vfsz = (vfszip_t*)file;
if (vfsz->defer)
return VFS_TELL(vfsz->defer);
return vfsz->pos;
}
unsigned long VFSZIP_GetLen (struct vfsfile_s *file)
{
vfszip_t *vfsz = (vfszip_t*)file;
return vfsz->length;
}
void VFSZIP_Close (struct vfsfile_s *file)
{
vfszip_t *vfsz = (vfszip_t*)file;
if (vfsz->parent->currentfile == file)
vfsz->parent->currentfile = NULL; //make it not us
if (vfsz->defer)
VFS_CLOSE(vfsz->defer);
FSZIP_ClosePath(vfsz->parent);
Z_Free(vfsz);
}
vfsfile_t *FSZIP_OpenVFS(void *handle, flocation_t *loc, const char *mode)
{
int rawofs;
zipfile_t *zip = handle;
vfszip_t *vfsz;
if (strcmp(mode, "rb"))
return NULL; //urm, unable to write/append
vfsz = Z_Malloc(sizeof(vfszip_t));
vfsz->parent = zip;
vfsz->index = loc->index;
vfsz->startpos = zip->files[loc->index].filepos;
vfsz->length = loc->len;
vfsz->funcs.Close = VFSZIP_Close;
vfsz->funcs.GetLen = VFSZIP_GetLen;
vfsz->funcs.ReadBytes = VFSZIP_ReadBytes;
vfsz->funcs.Seek = VFSZIP_Seek;
vfsz->funcs.Tell = VFSZIP_Tell;
vfsz->funcs.WriteBytes = NULL;
vfsz->funcs.seekingisabadplan = true;
unzLocateFileMy(vfsz->parent->handle, vfsz->index, vfsz->startpos);
rawofs = unzGetCurrentFileUncompressedPos(zip->handle);
vfsz->iscompressed = rawofs<0;
if (!vfsz->iscompressed)
{
vfsz->startpos = rawofs;
VFS_SEEK(zip->raw, vfsz->startpos);
vfsz->parent->currentfile = (vfsfile_t*)vfsz;
}
zip->references++;
return (vfsfile_t*)vfsz;
}
searchpathfuncs_t zipfilefuncs = {
FSZIP_PrintPath,
FSZIP_ClosePath,
FSZIP_BuildHash,
FSZIP_FLocate,
FSZIP_ReadFile,
FSZIP_EnumerateFiles,
FSZIP_LoadZipFile,
FSZIP_GeneratePureCRC,
FSZIP_OpenVFS
};
#endif

View file

@ -388,15 +388,24 @@ void AngleVectors (vec3_t angles, vec3_t forward, vec3_t right, vec3_t up)
sr = sin(angle);
cr = cos(angle);
forward[0] = cp*cy;
forward[1] = cp*sy;
forward[2] = -sp;
right[0] = (-1*sr*sp*cy+-1*cr*-sy);
right[1] = (-1*sr*sp*sy+-1*cr*cy);
right[2] = -1*sr*cp;
up[0] = (cr*sp*cy+-sr*-sy);
up[1] = (cr*sp*sy+-sr*cy);
up[2] = cr*cp;
if (forward)
{
forward[0] = cp*cy;
forward[1] = cp*sy;
forward[2] = -sp;
}
if (right)
{
right[0] = (-1*sr*sp*cy+-1*cr*-sy);
right[1] = (-1*sr*sp*sy+-1*cr*cy);
right[2] = -1*sr*cp;
}
if (up)
{
up[0] = (cr*sp*cy+-sr*-sy);
up[1] = (cr*sp*sy+-sr*cy);
up[2] = cr*cp;
}
}
int VectorCompare (vec3_t v1, vec3_t v2)

View file

@ -89,13 +89,13 @@ qboolean NET_CompareAdr (netadr_t a, netadr_t b);
qboolean NET_CompareBaseAdr (netadr_t a, netadr_t b);
char *NET_AdrToString (char *s, int len, netadr_t a);
char *NET_BaseAdrToString (char *s, int len, netadr_t a);
qboolean NET_StringToSockaddr (char *s, struct sockaddr_qstorage *sadr);
qboolean NET_StringToAdr (char *s, netadr_t *a);
qboolean NET_StringToSockaddr (const char *s, struct sockaddr_qstorage *sadr);
qboolean NET_StringToAdr (const char *s, netadr_t *a);
qboolean NET_IsClientLegal(netadr_t *adr);
qboolean NET_IsLoopBackAddress (netadr_t adr);
qboolean NET_StringToAdrMasked (char *s, netadr_t *a, netadr_t *amask);
qboolean NET_StringToAdrMasked (const char *s, netadr_t *a, netadr_t *amask);
char *NET_AdrToStringMasked (char *s, int len, netadr_t a, netadr_t amask);
void NET_IntegerToMask (netadr_t *a, netadr_t *amask, int bits);
qboolean NET_CompareAdrMasked(netadr_t a, netadr_t b, netadr_t mask);

View file

@ -563,7 +563,7 @@ any form of ipv6, including port number.
sscanf (copy, "%x", &val); \
((struct sockaddr_ipx *)sadr)->dest = val
qboolean NET_StringToSockaddr (char *s, struct sockaddr_qstorage *sadr)
qboolean NET_StringToSockaddr (const char *s, struct sockaddr_qstorage *sadr)
{
struct hostent *h;
char *colon;
@ -619,9 +619,12 @@ qboolean NET_StringToSockaddr (char *s, struct sockaddr_qstorage *sadr)
error = EAI_NONAME;
else
{
*port = 0;
error = pgetaddrinfo(s+1, port+2, &udp6hint, &addrinfo);
*port = ']';
len = port - (s+1);
if (len >= sizeof(dupbase))
len = sizeof(dupbase)-1;
strncpy(dupbase, s+1, len);
dupbase[len] = '\0';
error = pgetaddrinfo(dupbase, port+2, &udp6hint, &addrinfo);
}
}
else
@ -709,7 +712,7 @@ dblbreak:
accepts anything that NET_StringToSockaddr accepts plus certain url schemes
including: tcp, irc
*/
qboolean NET_StringToAdr (char *s, netadr_t *a)
qboolean NET_StringToAdr (const char *s, netadr_t *a)
{
struct sockaddr_qstorage sadr;
@ -872,9 +875,9 @@ void NET_IntegerToMask (netadr_t *a, netadr_t *amask, int bits)
// ParsePartialIPv4: check string to see if it is a partial IPv4 address and
// return bits to mask and set netadr_t or 0 if not an address
int ParsePartialIPv4(char *s, netadr_t *a)
int ParsePartialIPv4(const char *s, netadr_t *a)
{
char *colon = NULL;
const char *colon = NULL;
char *address = a->address.ip;
int bits = 8;
@ -920,7 +923,7 @@ int ParsePartialIPv4(char *s, netadr_t *a)
// NET_StringToAdrMasked: extension to NET_StringToAdr to handle IP addresses
// with masks or integers representing the bit masks
qboolean NET_StringToAdrMasked (char *s, netadr_t *a, netadr_t *amask)
qboolean NET_StringToAdrMasked (const char *s, netadr_t *a, netadr_t *amask)
{
char t[64];
char *spoint;
@ -1300,10 +1303,10 @@ void NET_SendLoopPacket (netsrc_t sock, int length, void *data, netadr_t to)
#define FTENET_ADDRTYPES 2
typedef struct ftenet_generic_connection_s {
char *name;
const char *name;
int (*GetLocalAddress)(struct ftenet_generic_connection_s *con, netadr_t *local, int adridx);
qboolean (*ChangeLocalAddress)(struct ftenet_generic_connection_s *con, char *newaddress);
qboolean (*ChangeLocalAddress)(struct ftenet_generic_connection_s *con, const char *newaddress);
qboolean (*GetPacket)(struct ftenet_generic_connection_s *con);
qboolean (*SendPacket)(struct ftenet_generic_connection_s *con, int length, void *data, netadr_t to);
void (*Close)(struct ftenet_generic_connection_s *con);
@ -1327,7 +1330,7 @@ ftenet_connections_t *FTENET_CreateCollection(qboolean listen)
return col;
}
qboolean FTENET_AddToCollection(ftenet_connections_t *col, char *name, char *address, ftenet_generic_connection_t *(*establish)(qboolean isserver, char *address))
qboolean FTENET_AddToCollection(ftenet_connections_t *col, const char *name, const char *address, ftenet_generic_connection_t *(*establish)(qboolean isserver, const char *address))
{
int i;
if (!col)
@ -1423,7 +1426,7 @@ qboolean FTENET_Loop_SendPacket(ftenet_generic_connection_t *con, int length, vo
return false;
}
ftenet_generic_connection_t *FTENET_Loop_EstablishConnection(qboolean isserver, char *address)
ftenet_generic_connection_t *FTENET_Loop_EstablishConnection(qboolean isserver, const char *address)
{
ftenet_generic_connection_t *newcon;
newcon = Z_Malloc(sizeof(*newcon));
@ -1626,7 +1629,7 @@ qboolean FTENET_Generic_SendPacket(ftenet_generic_connection_t *con, int length,
return true;
}
qboolean NET_PortToAdr (int adrfamily, char *s, netadr_t *a)
qboolean NET_PortToAdr (int adrfamily, const char *s, netadr_t *a)
{
char *e;
int port;
@ -1658,7 +1661,7 @@ qboolean NET_PortToAdr (int adrfamily, char *s, netadr_t *a)
return false;
}
ftenet_generic_connection_t *FTENET_Generic_EstablishConnection(int adrfamily, int protocol, qboolean isserver, char *address)
ftenet_generic_connection_t *FTENET_Generic_EstablishConnection(int adrfamily, int protocol, qboolean isserver, const char *address)
{
//this is written to support either ipv4 or ipv6, depending on the remote addr.
ftenet_generic_connection_t *newcon;
@ -1735,17 +1738,17 @@ ftenet_generic_connection_t *FTENET_Generic_EstablishConnection(int adrfamily, i
}
#ifdef IPPROTO_IPV6
ftenet_generic_connection_t *FTENET_UDP6_EstablishConnection(qboolean isserver, char *address)
ftenet_generic_connection_t *FTENET_UDP6_EstablishConnection(qboolean isserver, const char *address)
{
return FTENET_Generic_EstablishConnection(AF_INET6, IPPROTO_UDP, isserver, address);
}
#endif
ftenet_generic_connection_t *FTENET_UDP4_EstablishConnection(qboolean isserver, char *address)
ftenet_generic_connection_t *FTENET_UDP4_EstablishConnection(qboolean isserver, const char *address)
{
return FTENET_Generic_EstablishConnection(AF_INET, IPPROTO_UDP, isserver, address);
}
#ifdef USEIPX
ftenet_generic_connection_t *FTENET_IPX_EstablishConnection(qboolean isserver, char *address)
ftenet_generic_connection_t *FTENET_IPX_EstablishConnection(qboolean isserver, const char *address)
{
return FTENET_Generic_EstablishConnection(AF_IPX, NSPROTO_IPX, isserver, address);
}
@ -1946,7 +1949,7 @@ void FTENET_TCPConnect_Close(ftenet_generic_connection_t *gcon)
FTENET_Generic_Close(gcon);
}
ftenet_generic_connection_t *FTENET_TCPConnect_EstablishConnection(int affamily, qboolean isserver, char *address)
ftenet_generic_connection_t *FTENET_TCPConnect_EstablishConnection(int affamily, qboolean isserver, const char *address)
{
//this is written to support either ipv4 or ipv6, depending on the remote addr.
ftenet_tcpconnect_connection_t *newcon;
@ -2055,13 +2058,13 @@ ftenet_generic_connection_t *FTENET_TCPConnect_EstablishConnection(int affamily,
}
#ifdef IPPROTO_IPV6
ftenet_generic_connection_t *FTENET_TCP6Connect_EstablishConnection(qboolean isserver, char *address)
ftenet_generic_connection_t *FTENET_TCP6Connect_EstablishConnection(qboolean isserver, const char *address)
{
return FTENET_TCPConnect_EstablishConnection(AF_INET6, isserver, address);
}
#endif
ftenet_generic_connection_t *FTENET_TCP4Connect_EstablishConnection(qboolean isserver, char *address)
ftenet_generic_connection_t *FTENET_TCP4Connect_EstablishConnection(qboolean isserver, const char *address)
{
return FTENET_TCPConnect_EstablishConnection(AF_INET, isserver, address);
}
@ -2606,7 +2609,7 @@ void FTENET_IRCConnect_Close(ftenet_generic_connection_t *gcon)
FTENET_Generic_Close(gcon);
}
ftenet_generic_connection_t *FTENET_IRCConnect_EstablishConnection(qboolean isserver, char *address)
ftenet_generic_connection_t *FTENET_IRCConnect_EstablishConnection(qboolean isserver, const char *address)
{
//this is written to support either ipv4 or ipv6, depending on the remote addr.
ftenet_ircconnect_connection_t *newcon;
@ -3254,7 +3257,7 @@ void NET_Init (void)
#ifndef SERVERONLY
void NET_InitClient(void)
{
char *port;
const char *port;
int p;
port = STRINGIFY(PORT_CLIENT);
@ -3474,7 +3477,7 @@ int VFSTCP_ReadBytes (struct vfsfile_s *file, void *buffer, int bytestoread)
return 0; //signal nothing available
}
}
int VFSTCP_WriteBytes (struct vfsfile_s *file, void *buffer, int bytestoread)
int VFSTCP_WriteBytes (struct vfsfile_s *file, const void *buffer, int bytestoread)
{
tcpfile_t *tf = (tcpfile_t*)file;
int len;
@ -3510,7 +3513,7 @@ void VFSTCP_Close (struct vfsfile_s *file)
Z_Free(file);
}
vfsfile_t *FS_OpenTCP(char *name)
vfsfile_t *FS_OpenTCP(const char *name)
{
tcpfile_t *newf;
int sock;

View file

@ -329,10 +329,10 @@ plugin_t *Plug_Load(char *file)
return newplug;
}
int Plug_Emumerated (char *name, int size, void *param)
int Plug_Emumerated (const char *name, int size, void *param)
{
char vmname[MAX_QPATH];
strcpy(vmname, name);
Q_strncpyz(vmname, name, sizeof(vmname));
vmname[strlen(vmname) - strlen(param)] = '\0';
if (!Plug_Load(vmname))
Con_Printf("Couldn't load plugin %s\n", vmname);

View file

@ -123,6 +123,8 @@ int PM_PointContents (vec3_t p)
model_t *pm;
pm = pmove.physents[0].model;
if (!pm)
return FTECONTENTS_EMPTY;
pc = pm->funcs.PointContents(pm, p);
//we need this for e2m2 - waterjumping on to plats wouldn't work otherwise.
for (num = 1; num < pmove.numphysent; num++)

View file

@ -469,7 +469,7 @@ void PF_registercvar (progfuncs_t *prinst, struct globalvars_s *pr_globals)
////////////////////////////////////////////////////
//File access
#define MAX_QC_FILES 8
#define MAX_QC_FILES 256
#define FIRST_QC_FILE_INDEX 1000
@ -496,6 +496,7 @@ void PF_fopen (progfuncs_t *prinst, struct globalvars_s *pr_globals)
if (i == MAX_QC_FILES) //too many already open
{
Con_Printf("qcfopen: too many files open (trying %s)\n", name);
G_FLOAT(OFS_RETURN) = -1;
return;
}
@ -550,6 +551,14 @@ void PF_fopen (progfuncs_t *prinst, struct globalvars_s *pr_globals)
G_FLOAT(OFS_RETURN) = i + FIRST_QC_FILE_INDEX;
pf_fopen_files[i].prinst = prinst;
break;
case 3:
pf_fopen_files[i].bufferlen = 0;
pf_fopen_files[i].data = "";
pf_fopen_files[i].len = 0;
pf_fopen_files[i].ofs = 0;
G_FLOAT(OFS_RETURN) = i + FIRST_QC_FILE_INDEX;
pf_fopen_files[i].prinst = prinst;
break;
default: //bad
G_FLOAT(OFS_RETURN) = -1;
break;
@ -580,6 +589,8 @@ void PF_fclose_i (int fnum)
COM_WriteFile(pf_fopen_files[fnum].name, pf_fopen_files[fnum].data, pf_fopen_files[fnum].len);
BZ_Free(pf_fopen_files[fnum].data);
break;
case 3:
break;
}
pf_fopen_files[fnum].data = NULL;
pf_fopen_files[fnum].prinst = NULL;
@ -606,7 +617,7 @@ void PF_fclose (progfuncs_t *prinst, struct globalvars_s *pr_globals)
void PF_fgets (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
char c, *s, *o, *max;
char c, *s, *o, *max, *eof;
int fnum = G_FLOAT(OFS_PARM0) - FIRST_QC_FILE_INDEX;
char pr_string_temp[4096];
@ -632,9 +643,10 @@ void PF_fgets (progfuncs_t *prinst, struct globalvars_s *pr_globals)
//read up to the next \n, ignoring any \rs.
o = pr_string_temp;
max = o + MAXTEMPBUFFERLEN-1;
max = o + sizeof(pr_string_temp)-1;
s = pf_fopen_files[fnum].data+pf_fopen_files[fnum].ofs;
while(*s)
eof = pf_fopen_files[fnum].data+pf_fopen_files[fnum].len;
while(s < eof)
{
c = *s++;
if (c == '\n')
@ -650,7 +662,7 @@ void PF_fgets (progfuncs_t *prinst, struct globalvars_s *pr_globals)
pf_fopen_files[fnum].ofs = s - pf_fopen_files[fnum].data;
if (!pr_string_temp[0] && !*s)
if (!pr_string_temp[0] && s == eof)
G_INT(OFS_RETURN) = 0; //EOF
else
RETURN_TSTRING(pr_string_temp);
@ -679,20 +691,28 @@ void PF_fputs (progfuncs_t *prinst, struct globalvars_s *pr_globals)
return; //this just isn't ours.
}
if (pf_fopen_files[fnum].bufferlen < pf_fopen_files[fnum].ofs + len)
switch(pf_fopen_files[fnum].accessmode)
{
char *newbuf;
pf_fopen_files[fnum].bufferlen = pf_fopen_files[fnum].bufferlen*2 + len;
newbuf = BZF_Malloc(pf_fopen_files[fnum].bufferlen);
memcpy(newbuf, pf_fopen_files[fnum].data, pf_fopen_files[fnum].len);
BZ_Free(pf_fopen_files[fnum].data);
pf_fopen_files[fnum].data = newbuf;
}
default:
break;
case 1:
case 2:
if (pf_fopen_files[fnum].bufferlen < pf_fopen_files[fnum].ofs + len)
{
char *newbuf;
pf_fopen_files[fnum].bufferlen = pf_fopen_files[fnum].bufferlen*2 + len;
newbuf = BZF_Malloc(pf_fopen_files[fnum].bufferlen);
memcpy(newbuf, pf_fopen_files[fnum].data, pf_fopen_files[fnum].len);
BZ_Free(pf_fopen_files[fnum].data);
pf_fopen_files[fnum].data = newbuf;
}
memcpy(pf_fopen_files[fnum].data + pf_fopen_files[fnum].ofs, msg, len);
if (pf_fopen_files[fnum].len < pf_fopen_files[fnum].ofs + len)
pf_fopen_files[fnum].len = pf_fopen_files[fnum].ofs + len;
pf_fopen_files[fnum].ofs+=len;
memcpy(pf_fopen_files[fnum].data + pf_fopen_files[fnum].ofs, msg, len);
if (pf_fopen_files[fnum].len < pf_fopen_files[fnum].ofs + len)
pf_fopen_files[fnum].len = pf_fopen_files[fnum].ofs + len;
pf_fopen_files[fnum].ofs+=len;
break;
}
}
void PF_fcloseall (progfuncs_t *prinst)
@ -815,7 +835,7 @@ void search_close_progs(progfuncs_t *prinst, qboolean complain)
prvm_nextsearchhandle = 0; //might as well.
}
int search_enumerate(char *name, int fsize, void *parm)
int search_enumerate(const char *name, int fsize, void *parm)
{
prvmsearch_t *s = parm;

View file

@ -257,6 +257,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define svcfte_pointparticles 81 // [short] effectnum [vector] start [vector] velocity [short] count
#define svcfte_pointparticles1 82 // [short] effectnum [vector] start, same as svc_pointparticles except velocity is zero and count is 1
#define svcfte_cgamepacket 83
//DP extended svcs

View file

@ -186,7 +186,7 @@ typedef struct {
int bufferleft;
int skip;
} vmsearch_t;
static int VMEnum(char *match, int size, void *args)
static int VMEnum(const char *match, int size, void *args)
{
char *check;
int newlen;
@ -210,13 +210,13 @@ static int VMEnum(char *match, int size, void *args)
return true;
}
static int IfFound(char *match, int size, void *args)
static int IfFound(const char *match, int size, void *args)
{
*(qboolean*)args = true;
return true;
}
static int VMEnumMods(char *match, int size, void *args)
static int VMEnumMods(const char *match, int size, void *args)
{
char *check;
char desc[1024];
@ -227,21 +227,23 @@ static int VMEnumMods(char *match, int size, void *args)
newlen = strlen(match)+1;
if (*match && match[newlen-2] != '/')
if (newlen <= 2)
return true;
match[newlen-2] = '\0';
newlen--;
if (!stricmp(match, "baseq3"))
//make sure match is a directory
if (match[newlen-2] != '/')
return true;
if (!stricmp(match, "baseq3/"))
return true; //we don't want baseq3
foundone = false;
Sys_EnumerateFiles(va("%s/%s/", ((vmsearch_t *)args)->dir, match), "*.pk3", IfFound, &foundone);
Sys_EnumerateFiles(va("%s%s/", ((vmsearch_t *)args)->dir, match), "*.pk3", IfFound, &foundone);
if (foundone == false)
return true; //we only count directories with a pk3 file
Q_strncpyz(desc, match, sizeof(desc));
f = FS_OpenVFS(va("%s/description.txt", match), "rb", FS_ROOT);
f = FS_OpenVFS(va("%sdescription.txt", match), "rb", FS_ROOT);
if (f)
{
VFS_GETS(f, desc, sizeof(desc));

View file

@ -116,7 +116,7 @@ dllhandle_t *QVM_LoadDLL(const char *name, void **vmMain, int (EXPORT_FN *syscal
return NULL; // couldn't find one anywhere
snprintf (name, sizeof(name), "%s/%s", gpath, dllname);
Con_Printf("Loading native: %s\n", name);
Con_DPrintf("Loading native: %s\n", name);
hVM = Sys_LoadLibrary(name, funcs);
if (hVM)
{

View file

@ -21,23 +21,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
// file IO
// for the most part, we use stdio.
// if your system doesn't have stdio then urm... well.
//
// returns the file size
// return -1 if file is not present
// the file should be in BINARY mode for stupid OSs that care
int Sys_FileOpenRead (char *path, int *hndl);
int Sys_FileOpenWrite (char *path);
void Sys_FileClose (int handle);
void Sys_FileSeek (int handle, int position);
int Sys_FileRead (int handle, void *dest, int count);
int Sys_FileWrite (int handle, void *data, int count);
int Sys_FileTime (char *path);
void Sys_mkdir (char *path);
void Sys_mkdir (char *path); //not all pre-unix systems have directories (including dos 1)
qboolean Sys_remove (char *path);
qboolean Sys_FindGameData(char *gamename, char *basepath, int basepathlen);
qboolean Sys_FindGameData(const char *gamename, char *basepath, int basepathlen);
//
// memory protection
@ -95,7 +84,7 @@ void Sys_LowFPPrecision (void);
void Sys_HighFPPrecision (void);
void VARGS Sys_SetFPCW (void);
int Sys_EnumerateFiles (char *gpath, char *match, int (*func)(char *, int, void *), void *parm);
int Sys_EnumerateFiles (const char *gpath, const char *match, int (*func)(const char *, int, void *), void *parm);
qboolean Sys_GetDesktopParameters(int *width, int *height, int *bpp, int *refreshrate);

View file

@ -159,8 +159,8 @@ void *VARGS Z_TagMalloc(int size, int tag)
else
{
zone->pvdn = zone_head;
if (s->next)
s->next->pvdn = zone;
// if (s->next)
// s->next->pvdn = zone;
zone_head = zone;
}
}
@ -2166,6 +2166,9 @@ void Memory_Init (void *buf, int size)
void Memory_DeInit(void)
{
Hunk_TempFree();
Cache_Flush();
#ifdef MULTITHREAD
if (zonelock)
{

View file

@ -326,7 +326,7 @@ mpic_t *(D3D7_Draw_SafePicFromWad) (char *name)
pic->pic.width = qpic->width;
pic->pic.height = qpic->height;
p = (LPDIRECTDRAWSURFACE7*)&pic->pic.data;
p = (LPDIRECTDRAWSURFACE7*)&pic->pic.d.data;
if (!strcmp(name, "conchars"))
*p = draw_chars_tex;
else
@ -367,7 +367,7 @@ mpic_t *(D3D7_Draw_SafeCachePic) (char *path)
pic->pic.width = qpic->width;
pic->pic.height = qpic->height;
p = (LPDIRECTDRAWSURFACE7*)&pic->pic.data;
p = (LPDIRECTDRAWSURFACE7*)&pic->pic.d.data;
*p = (LPDIRECTDRAWSURFACE7)Mod_LoadReplacementTexture(pic->name, "gfx", false, true, true);
if (!*p)
*p = D3D7_LoadTexture_8_Pal24(path, (unsigned char*)(qpic+1), qpic->width, qpic->height, TF_NOMIPMAP|TF_ALPHA|TF_NOTBUMPMAP, host_basepal, 255);
@ -422,7 +422,7 @@ void (D3D7_Draw_ReInit) (void)
strcpy(d3dmenu_cachepics[d3dmenu_numcachepics].name, "conchars");
d3dmenu_cachepics[d3dmenu_numcachepics].pic.width = 128;
d3dmenu_cachepics[d3dmenu_numcachepics].pic.height = 128;
*(int *)&d3dmenu_cachepics[d3dmenu_numcachepics].pic.data = (int)draw_chars_tex;
*(int *)&d3dmenu_cachepics[d3dmenu_numcachepics].pic.d.data = (int)draw_chars_tex;
d3dmenu_numcachepics++;
@ -713,7 +713,7 @@ void (D3D7_Draw_Image) (float x, float y, float w, float h, float s1, float t
d3dquadvert[3].s = s1;// - 3.0/pic->width;
d3dquadvert[3].t = t2;
p = (LPDIRECTDRAWSURFACE7*)&pic->data;
p = (LPDIRECTDRAWSURFACE7*)&pic->d.data;
pD3DDev->lpVtbl->SetTexture(pD3DDev, 0, *p);
pD3DDev->lpVtbl->SetTextureStageState(pD3DDev, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
@ -780,7 +780,7 @@ void (D3D7_Media_ShowFrameBGR_24_Flip) (qbyte *framedata, int inwidth, int inhei
{
mpic_t pic;
LPDIRECTDRAWSURFACE7 *p;
p = (LPDIRECTDRAWSURFACE7*)&pic.data;
p = (LPDIRECTDRAWSURFACE7*)&pic.d.data;
*p = D3D7_LoadTexture_32("", (unsigned int*)framedata, inwidth, inheight, TF_NOMIPMAP|TF_NOALPHA|TF_NOTBUMPMAP);
D3D7_Set2D ();
@ -799,7 +799,7 @@ void (D3D7_Media_ShowFrameRGBA_32) (qbyte *framedata, int inwidth, int inheight
pic.width = inwidth;
pic.height = inheight;
pic.flags = 0;
p = (LPDIRECTDRAWSURFACE7*)&pic.data;
p = (LPDIRECTDRAWSURFACE7*)&pic.d.data;
*p = D3D7_LoadTexture_32("", (unsigned int*)framedata, inwidth, inheight, TF_NOMIPMAP|TF_NOALPHA|TF_NOTBUMPMAP);
D3D7_Set2D ();
@ -814,7 +814,7 @@ void (D3D7_Media_ShowFrame8bit) (qbyte *framedata, int inwidth, int inheight,
{
mpic_t pic;
LPDIRECTDRAWSURFACE7 *p;
p = (LPDIRECTDRAWSURFACE7*)&pic.data;
p = (LPDIRECTDRAWSURFACE7*)&pic.d.data;
*p = D3D7_LoadTexture_8_Pal24("", (unsigned char*)framedata, inwidth, inheight, TF_NOMIPMAP|TF_NOALPHA|TF_NOTBUMPMAP, palette, 256);
D3D7_Set2D ();

View file

@ -113,33 +113,6 @@ static galiastexnum_t *D3D7_ChooseSkin(galiasinfo_t *inf, char *modelname, int s
Skin_Find(e->scoreboard);
tc = e->scoreboard->ttopcolor;
bc = e->scoreboard->tbottomcolor;
//colour forcing
if (cl.splitclients<2 && !(cl.fpd & FPD_NO_FORCE_COLOR)) //no colour/skin forcing in splitscreen.
{
if (cl.teamplay && cl.spectator)
{
local = Cam_TrackNum(0);
if (local < 0)
local = cl.playernum[0];
}
else
local = cl.playernum[0];
if (cl.teamplay && !strcmp(e->scoreboard->team, cl.players[local].team))
{
if (cl_teamtopcolor>=0)
tc = cl_teamtopcolor;
if (cl_teambottomcolor>=0)
bc = cl_teambottomcolor;
}
else
{
if (cl_enemytopcolor>=0)
tc = cl_enemytopcolor;
if (cl_enemybottomcolor>=0)
bc = cl_enemybottomcolor;
}
}
}
else
{

View file

@ -672,7 +672,7 @@ static void D3D7_DrawSpriteModel (entity_t *e)
right[1]*=e->scale;
right[2]*=e->scale;
pD3DDev->lpVtbl->SetTexture(pD3DDev, 0, (LPDIRECTDRAWSURFACE7)frame->gl_texturenum);
pD3DDev->lpVtbl->SetTexture(pD3DDev, 0, *(LPDIRECTDRAWSURFACE7*)frame->p.d.data);
/* {
extern int gldepthfunc;

View file

@ -255,65 +255,16 @@ qboolean D3DAppActivate(BOOL fActive, BOOL minimize)
sound_active = true;
}
IN_UpdateGrabs(modestate != MS_WINDOWED, ActiveApp);
if (fActive)
{
/* if (modestate != MS_WINDOWED)
{
IN_ActivateMouse ();
IN_HideMouse ();
// if (vid_canalttab && vid_wassuspended)
{
// vid_wassuspended = false;
// ChangeDisplaySettings (&gdevmode, CDS_FULLSCREEN);
ShowWindow(mainwindow, SW_SHOWNORMAL);
// Fix for alt-tab bug in NVidia drivers
// MoveWindow (mainwindow, 0, 0, gdevmode.dmPelsWidth, gdevmode.dmPelsHeight, false);
}
}
else if ((modestate == MS_WINDOWED) && _windowed_mouse.value && (key_dest == key_game || key_dest == key_menu))
{
IN_ActivateMouse ();
IN_HideMouse ();
}
*/
Cvar_ForceCallback(&v_gamma);
}
if (!fActive)
{
/* if (modestate != MS_WINDOWED)
{
IN_DeactivateMouse ();
IN_ShowMouse ();
// if (vid_canalttab)
// {
// ChangeDisplaySettings (NULL, 0);
// vid_wassuspended = true;
// }
}
else if ((modestate == MS_WINDOWED) && _windowed_mouse.value)
{
IN_DeactivateMouse ();
IN_ShowMouse ();
}
*/
Cvar_ForceCallback(&v_gamma); //wham bam thanks.
/*
if (qSetDeviceGammaRamp)
{
if (vid_desktopgamma.value)
{
HDC hDC = GetDC(GetDesktopWindow());
qSetDeviceGammaRamp (hDC, originalgammaramps);
ReleaseDC(GetDesktopWindow(), hDC);
}
else
{
qSetDeviceGammaRamp(maindc, originalgammaramps);
}
}
*/
}
return true;
@ -950,6 +901,14 @@ void (D3D7_SCR_UpdateScreen) (void)
extern cvar_t vid_conwidth, vid_conheight;
vid.conwidth = vid_conwidth.value;
vid.conheight = vid_conheight.value;
{
DWORD w, h;
pD3DX->lpVtbl->GetBufferSize((void*)pD3DX, &w, &h);
if (vid.conwidth <= 0)
vid.conwidth = w;
if (vid.conheight <= 0)
vid.conheight = h;
}
if (vid.width != vid.conwidth || vid.height != vid.conheight)
vid.recalc_refdef = true;
vid.width = vid.conwidth;
@ -1067,32 +1026,7 @@ void (D3D7_SCR_UpdateScreen) (void)
if (modestate == MS_WINDOWED)
{
extern int mouseusedforgui;
extern qboolean mouseactive;
if (!_windowed_mouse.value)
{
if (mouseactive)
{
IN_DeactivateMouse ();
IN_ShowMouse ();
}
}
else
{
if ((key_dest == key_game||mouseusedforgui) && !mouseactive && ActiveApp)
{
IN_ActivateMouse ();
IN_HideMouse ();
}
else if (mouseactive && key_dest == key_console)
{//!(key_dest == key_game || mouseusedforgui)) {
IN_DeactivateMouse ();
IN_ShowMouse ();
}
}
}
IN_UpdateGrabs(modestate != MS_WINDOWED, ActiveApp);
}

View file

@ -343,7 +343,7 @@ mpic_t *D3D9_Draw_SafePicFromWad (char *name)
Q_strncpyz (pic->name, name, sizeof(pic->name));
p = (LPDIRECT3DBASETEXTURE9*)&pic->pic.data;
p = (LPDIRECT3DBASETEXTURE9*)&pic->pic.d.data;
if (!strcmp(name, "conchars"))
{
pic->pic.width = 256;
@ -396,7 +396,7 @@ mpic_t *D3D9_Draw_SafeCachePic (char *path)
Q_strncpyz (pic->name, path, sizeof(pic->name));
p = (LPDIRECT3DBASETEXTURE9*)&pic->pic.data;
p = (LPDIRECT3DBASETEXTURE9*)&pic->pic.d.data;
if (qpic)
{
@ -453,7 +453,7 @@ void D3D9_Draw_ReInit (void)
strcpy(d3dmenu_cachepics[d3dmenu_numcachepics].name, "conchars");
d3dmenu_cachepics[d3dmenu_numcachepics].pic.width = 128;
d3dmenu_cachepics[d3dmenu_numcachepics].pic.height = 128;
*(int *)&d3dmenu_cachepics[d3dmenu_numcachepics].pic.data = (int)d3d9chars_tex;
*(int *)&d3dmenu_cachepics[d3dmenu_numcachepics].pic.d.data = (int)d3d9chars_tex;
d3dmenu_numcachepics++;
@ -751,7 +751,7 @@ void D3D9_Draw_Image (float x, float y, float w, float h, float s1, float t1
d3d9quadvert[3].s = s1;// - 3.0/pic->width;
d3d9quadvert[3].t = t2;
p = (LPDIRECT3DBASETEXTURE9*)&pic->data;
p = (LPDIRECT3DBASETEXTURE9*)&pic->d.data;
IDirect3DDevice9_SetTexture(pD3DDev9, 0, *p);
IDirect3DDevice9_SetTextureStageState(pD3DDev9, 0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
@ -820,7 +820,7 @@ void D3D9_Media_ShowFrameBGR_24_Flip (qbyte *framedata, int inwidth, int inheigh
{
mpic_t pic;
LPDIRECT3DBASETEXTURE9 *p;
p = (LPDIRECT3DBASETEXTURE9*)&pic.data;
p = (LPDIRECT3DBASETEXTURE9*)&pic.d.data;
*p = D3D9_LoadTexture_32("", (unsigned int*)framedata, inwidth, inheight, TF_NOMIPMAP|TF_NOALPHA|TF_NOTBUMPMAP);
D3D9_Set2D ();
@ -839,7 +839,7 @@ void D3D9_Media_ShowFrameRGBA_32 (qbyte *framedata, int inwidth, int inheight)
pic.width = inwidth;
pic.height = inheight;
pic.flags = 0;
p = (LPDIRECT3DBASETEXTURE9*)&pic.data;
p = (LPDIRECT3DBASETEXTURE9*)&pic.d;
*p = D3D9_LoadTexture_32("", (unsigned int*)framedata, inwidth, inheight, TF_NOMIPMAP|TF_NOALPHA|TF_NOTBUMPMAP);
D3D9_Set2D ();
@ -854,7 +854,7 @@ void (D3D9_Media_ShowFrame8bit) (qbyte *framedata, int inwidth, int inheight,
{
mpic_t pic;
LPDIRECT3DBASETEXTURE9 *p;
p = (LPDIRECT3DBASETEXTURE9*)&pic.data;
p = (LPDIRECT3DBASETEXTURE9*)&pic.d;
*p = D3D9_LoadTexture_8_Pal24("", (unsigned char*)framedata, inwidth, inheight, TF_NOMIPMAP|TF_NOALPHA|TF_NOTBUMPMAP, palette, 256);
D3D9_Set2D ();

View file

@ -997,7 +997,7 @@ static void D3D9_DrawSpriteModel (entity_t *e)
IDirect3DDevice9_SetRenderState(pD3DDev9, D3DRS_ALPHABLENDENABLE, TRUE);
if (pic)
IDirect3DDevice9_SetTexture(pD3DDev9, 0, *(LPDIRECT3DBASETEXTURE9*)&pic->data);
IDirect3DDevice9_SetTexture(pD3DDev9, 0, *(LPDIRECT3DBASETEXTURE9*)&pic->d);
else
IDirect3DDevice9_SetTexture(pD3DDev9, 0, NULL);
@ -1085,7 +1085,7 @@ static void D3D9_DrawSpriteModel (entity_t *e)
right[1]*=e->scale;
right[2]*=e->scale;
IDirect3DDevice9_SetTexture(pD3DDev9, 0, (void*)frame->gl_texturenum);
IDirect3DDevice9_SetTexture(pD3DDev9, 0, *(void**)&frame->p.d);
/* {
extern int gldepthfunc;

View file

@ -263,65 +263,15 @@ qboolean D3D9AppActivate(BOOL fActive, BOOL minimize)
sound_active = true;
}
IN_UpdateGrabs(modestate != MS_WINDOWED, ActiveApp);
if (fActive)
{
/* if (modestate != MS_WINDOWED)
{
IN_ActivateMouse ();
IN_HideMouse ();
// if (vid_canalttab && vid_wassuspended)
{
// vid_wassuspended = false;
// ChangeDisplaySettings (&gdevmode, CDS_FULLSCREEN);
ShowWindow(mainwindow, SW_SHOWNORMAL);
// Fix for alt-tab bug in NVidia drivers
// MoveWindow (mainwindow, 0, 0, gdevmode.dmPelsWidth, gdevmode.dmPelsHeight, false);
}
}
else if ((modestate == MS_WINDOWED) && _windowed_mouse.value && (key_dest == key_game || key_dest == key_menu))
{
IN_ActivateMouse ();
IN_HideMouse ();
}
*/
Cvar_ForceCallback(&v_gamma);
}
if (!fActive)
{
/* if (modestate != MS_WINDOWED)
{
IN_DeactivateMouse ();
IN_ShowMouse ();
// if (vid_canalttab)
// {
// ChangeDisplaySettings (NULL, 0);
// vid_wassuspended = true;
// }
}
else if ((modestate == MS_WINDOWED) && _windowed_mouse.value)
{
IN_DeactivateMouse ();
IN_ShowMouse ();
}
*/
Cvar_ForceCallback(&v_gamma); //wham bam thanks.
/*
if (qSetDeviceGammaRamp)
{
if (vid_desktopgamma.value)
{
HDC hDC = GetDC(GetDesktopWindow());
qSetDeviceGammaRamp (hDC, originalgammaramps);
ReleaseDC(GetDesktopWindow(), hDC);
}
else
{
qSetDeviceGammaRamp(maindc, originalgammaramps);
}
}
*/
}
return true;
@ -1335,28 +1285,7 @@ void (D3D9_SCR_UpdateScreen) (void)
window_center_y = (window_rect.top + window_rect.bottom)/2;
if (modestate == MS_WINDOWED)
{
extern int mouseusedforgui;
extern qboolean mouseactive;
qboolean wantactive;
wantactive = _windowed_mouse.value && (key_dest == key_game||mouseusedforgui) && ActiveApp;
if (wantactive != mouseactive)
{
if (!mouseactive)
{
IN_ActivateMouse ();
IN_HideMouse ();
}
else
{
IN_DeactivateMouse ();
IN_ShowMouse ();
}
}
}
IN_UpdateGrabs(modestate != MS_WINDOWED, ActiveApp);
VID_ShiftPalette (NULL);
}

View file

@ -260,7 +260,7 @@ BSC32=bscmake.exe
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 comctl32.lib wsock32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib winmm.lib /nologo /subsystem:windows /machine:I386 /out:"../../../fteglqw.exe"
# ADD LINK32 wsock32.lib winmm.lib kernel32.lib user32.lib gdi32.lib /nologo /subsystem:windows /pdb:none /map /machine:I386 /nodefaultlib:"msvcrt.lib" /out:"../../fteminglqw.exe" /libpath:"../libs/dxsdk7/lib"
# ADD LINK32 wsock32.lib winmm.lib kernel32.lib user32.lib gdi32.lib /nologo /subsystem:windows /pdb:none /map /machine:I386 /out:"../../fteminglqw.exe" /libpath:"../libs/dxsdk7/lib"
!ELSEIF "$(CFG)" == "ftequake - Win32 Debug Dedicated Server"
@ -363,7 +363,7 @@ LINK32=link.exe
# PROP Target_Dir ""
# ADD BASE CPP /nologo /G5 /ML /W3 /GX /ZI /Od /I "..\client" /I "../common" /I "../server" /I "../gl" /I "../sw" /I "../qclib" /I "../libs" /I "../libs/dxsdk7/include" /D "_DEBUG" /D "GLQUAKE" /D "WIN32" /D "_WINDOWS" /D "AVAIL_OGGVORBIS" /D "Q3CLIENT" /FR".\GLDebug/" /Fp".\GLDebug/qwcl.pch" /YX /Fo".\GLDebug/" /Fd".\GLDebug/" /FD /c
# SUBTRACT BASE CPP /X
# ADD CPP /nologo /G5 /W3 /GX /ZI /Od /I "..\client" /I "../common" /I "../server" /I "../gl" /I "../sw" /I "../qclib" /I "../libs" /I "../libs/dxsdk7/include" /D "_DEBUG" /D "GLQUAKE" /D "WIN32" /D "_WINDOWS" /D "Q3CLIENT" /D "Q3SERVER" /FR /Fp".\GLDebugQ3/qwcl.pch" /Yu"quakedef.h" /Fo".\GLDebugQ3/" /Fd".\GLDebugQ3/" /FD /c
# ADD CPP /nologo /G5 /W3 /GX /ZI /Od /I "..\client" /I "../common" /I "../server" /I "../gl" /I "../sw" /I "../qclib" /I "../libs" /I "../libs/dxsdk7/include" /D "_DEBUG" /D "GLQUAKE" /D "WIN32" /D "_WINDOWS" /FR /Fp".\GLDebugQ3/qwcl.pch" /Yu"quakedef.h" /Fo".\GLDebugQ3/" /Fd".\GLDebugQ3/" /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x809 /d "_DEBUG"
@ -550,6 +550,195 @@ SOURCE=..\server\sv_user.c
# End Source File
# Begin Source File
SOURCE=..\server\svhl_game.c
!IF "$(CFG)" == "ftequake - Win32 Release"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 Debug"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 GLDebug"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 GLRelease"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 MDebug"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 MRelease"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 MinGLDebug"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 MinGLRelease"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 Debug Dedicated Server"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 Release Dedicated Server"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 MinSW"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 GLDebugQ3"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 Debug Dedicated ServerQ3"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 D3DDebug"
# ADD CPP /Yu"qwsvdef.h"
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\server\svhl_phys.c
!IF "$(CFG)" == "ftequake - Win32 Release"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 Debug"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 GLDebug"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 GLRelease"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 MDebug"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 MRelease"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 MinGLDebug"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 MinGLRelease"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 Debug Dedicated Server"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 Release Dedicated Server"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 MinSW"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 GLDebugQ3"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 Debug Dedicated ServerQ3"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 D3DDebug"
# ADD CPP /Yu"qwsvdef.h"
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\server\svhl_world.c
!IF "$(CFG)" == "ftequake - Win32 Release"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 Debug"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 GLDebug"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 GLRelease"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 MDebug"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 MRelease"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 MinGLDebug"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 MinGLRelease"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 Debug Dedicated Server"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 Release Dedicated Server"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 MinSW"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 GLDebugQ3"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 Debug Dedicated ServerQ3"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 D3DDebug"
# ADD CPP /Yu"qwsvdef.h"
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\server\svq2_ents.c
# ADD CPP /Yu"qwsvdef.h"
# End Source File
@ -565,45 +754,65 @@ SOURCE=..\server\svq3_game.c
!IF "$(CFG)" == "ftequake - Win32 Release"
# PROP Exclude_From_Build 1
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 Debug"
# PROP Exclude_From_Build 1
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 GLDebug"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 GLRelease"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 MDebug"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 MRelease"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 MinGLDebug"
# PROP Exclude_From_Build 1
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 MinGLRelease"
# PROP Exclude_From_Build 1
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 Debug Dedicated Server"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 Release Dedicated Server"
# PROP Exclude_From_Build 1
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 MinSW"
# PROP Exclude_From_Build 1
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 GLDebugQ3"
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 Debug Dedicated ServerQ3"
# PROP BASE Exclude_From_Build 1
# ADD CPP /Yu"qwsvdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 D3DDebug"
# ADD CPP /Yu"qwsvdef.h"
!ENDIF
# End Source File
@ -1183,6 +1392,45 @@ SOURCE=..\client\cl_ui.c
# End Source File
# Begin Source File
SOURCE=..\client\clhl_game.c
!IF "$(CFG)" == "ftequake - Win32 Release"
!ELSEIF "$(CFG)" == "ftequake - Win32 Debug"
!ELSEIF "$(CFG)" == "ftequake - Win32 GLDebug"
!ELSEIF "$(CFG)" == "ftequake - Win32 GLRelease"
!ELSEIF "$(CFG)" == "ftequake - Win32 MDebug"
!ELSEIF "$(CFG)" == "ftequake - Win32 MRelease"
!ELSEIF "$(CFG)" == "ftequake - Win32 MinGLDebug"
!ELSEIF "$(CFG)" == "ftequake - Win32 MinGLRelease"
!ELSEIF "$(CFG)" == "ftequake - Win32 Debug Dedicated Server"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 Release Dedicated Server"
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 MinSW"
!ELSEIF "$(CFG)" == "ftequake - Win32 GLDebugQ3"
!ELSEIF "$(CFG)" == "ftequake - Win32 Debug Dedicated ServerQ3"
!ELSEIF "$(CFG)" == "ftequake - Win32 D3DDebug"
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\client\clq2_cin.c
!IF "$(CFG)" == "ftequake - Win32 Release"
@ -6165,6 +6413,18 @@ SOURCE=..\common\fs.c
# End Source File
# Begin Source File
SOURCE=..\common\fs_pak.c
# End Source File
# Begin Source File
SOURCE=..\common\fs_stdio.c
# End Source File
# Begin Source File
SOURCE=..\common\fs_zip.c
# End Source File
# Begin Source File
SOURCE=..\common\huff.c
# End Source File
# Begin Source File
@ -10457,9 +10717,6 @@ SOURCE=..\client\winquake.rc
!IF "$(CFG)" == "ftequake - Win32 Release"
# ADD BASE RSC /l 0x809 /i "\engine\client" /i "\ftetgcvs\svn\engine\client" /i "\ftesvn - Copy\engine\client" /i "\ftesvn\engine\client" /i "\ftetgcvs\svnd3d\engine\client" /i "\ftetgcvs\engine\client" /i "\Projects\fteqw\engine\client" /i "\windows\J\ftetgcvs\engine\client" /i "\ftetgcvs\source\client" /i "\ftetgcvs\temp\client" /i "\ftetgcvs\fte\QW\client"
# ADD RSC /l 0x809 /i "\engine\client" /i "\ftetgcvs\svn\engine\client" /i "\ftesvn - Copy\engine\client" /i "\ftesvn\engine\client" /i "\ftetgcvs\svnd3d\engine\client" /i "\ftetgcvs\engine\client" /i "\Projects\fteqw\engine\client" /i "\windows\J\ftetgcvs\engine\client" /i "\ftetgcvs\source\client" /i "\ftetgcvs\temp\client" /i "\ftetgcvs\fte\QW\client" /d "MINIMAL"
!ELSEIF "$(CFG)" == "ftequake - Win32 Debug"
!ELSEIF "$(CFG)" == "ftequake - Win32 GLDebug"
@ -10537,6 +10794,10 @@ SOURCE=..\client\quakedef.h
SOURCE=..\client\render.h
# End Source File
# Begin Source File
SOURCE=..\server\svhl_gcapi.h
# End Source File
# End Group
# Begin Group "Resource Files"

View file

@ -45,6 +45,21 @@ Package=<4>
###############################################################################
Project: "npqtv"=.\npqtv.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
Begin Project Dependency
Project_Dep_Name qcvm
End Project Dependency
}}}
###############################################################################
Project: "q3asm2"=..\..\Q3ASM2\q3asm2.dsp - Package Owner=<4>
Package=<5>
@ -69,6 +84,18 @@ Package=<4>
###############################################################################
Project: "qcvm"=..\QCLIB\qcvm\qcvm.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>

View file

@ -0,0 +1,5 @@
EXPORTS
NP_GetEntryPoints
NP_GetMIMEDescription
NP_Initialize
NP_Shutdown

111
engine/ftequake/npplug.rc Normal file
View file

@ -0,0 +1,111 @@
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
#include "afxres.h"
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
// English (U.K.) resources
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENG)
#ifdef _WIN32
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_UK
#pragma code_page(1252)
#endif //_WIN32
#ifndef _MAC
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,1
PRODUCTVERSION 1,0,0,1
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x40004L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904e4"
BEGIN
VALUE "Comments", "\0"
VALUE "CompanyName", "Forethought Entertainment\0"
VALUE "FileDescription", "Quake in a browser\0"
VALUE "FileExtents", "qtv|mvd\0"
VALUE "FileVersion", "1, 0, 0, 1\0"
VALUE "InternalName", "npqtv\0"
VALUE "LegalCopyright", "Copyright © 2009\0"
VALUE "LegalTrademarks", "\0"
VALUE "MIMEType", "text/x-quaketvident|application/x-multiviewdemo\0"
VALUE "OriginalFilename", "npqtv.dll\0"
VALUE "PrivateBuild", "\0"
VALUE "ProductName", "QTV Viewer\0"
VALUE "ProductVersion", "1, 0, 0, 1\0"
VALUE "SpecialBuild", "\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1252
END
END
#endif // !_MAC
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE DISCARDABLE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE DISCARDABLE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
3 TEXTINCLUDE DISCARDABLE
BEGIN
"\r\n"
"\0"
END
#endif // APSTUDIO_INVOKED
#endif // English (U.K.) resources
/////////////////////////////////////////////////////////////////////////////
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED

1044
engine/ftequake/npqtv.dsp Normal file

File diff suppressed because it is too large Load diff

View file

@ -92,14 +92,8 @@ static unsigned cs_data[16*16];
static int externalhair;
int gl_anisotropy_factor;
typedef struct
{
int texnum;
float sl, tl, sh, th;
} glpic_t;
qbyte conback_buffer[sizeof(mpic_t) + sizeof(glpic_t)];
qbyte custconback_buffer[sizeof(mpic_t) + sizeof(glpic_t)];
qbyte conback_buffer[sizeof(mpic_t)];
qbyte custconback_buffer[sizeof(mpic_t)];
mpic_t *default_conback = (mpic_t *)&conback_buffer, *conback, *custom_conback = (mpic_t *)&custconback_buffer;
#include "hash.h"
@ -245,7 +239,7 @@ qboolean Draw_RealPicFromWad (mpic_t *out, char *name)
in = W_SafeGetLumpName (name+4);
else
in = W_SafeGetLumpName (name);
gl = (glpic_t *)out->data;
gl = &out->d.gl;
if (in)
{
@ -393,7 +387,7 @@ mpic_t *GLDraw_SafeCachePic (char *path)
if ((mem = ReadPCXFile(data, com_filesize, &pic->pic.width, &height)))
{
pic->pic.height = height;
gl = (glpic_t *)pic->pic.data;
gl = &pic->pic.d.gl;
if (!(gl->texnum = Mod_LoadReplacementTexture(alternatename, "pics", false, true, false)))
gl->texnum = GL_LoadTexture32(path, pic->pic.width, pic->pic.height, (unsigned *)mem, false, false);
gl->sl = 0;
@ -434,7 +428,7 @@ mpic_t *GLDraw_SafeCachePic (char *path)
pic->pic.height = height;
if (mem)
{
gl = (glpic_t *)pic->pic.data;
gl = &pic->pic.d.gl;
if (!(gl->texnum = Mod_LoadReplacementTexture(alternatename, NULL, false, true, false)))
gl->texnum = GL_LoadTexture32(path, pic->pic.width, pic->pic.height, (unsigned *)mem, false, true);
gl->sl = 0;
@ -463,7 +457,7 @@ mpic_t *GLDraw_SafeCachePic (char *path)
if ((mem = ReadJPEGFile(data, com_filesize, &pic->pic.width, &height)))
{
pic->pic.height = height;
gl = (glpic_t *)pic->pic.data;
gl = &pic->pic.d.gl;
if (!(gl->texnum = Mod_LoadReplacementTexture(alternatename, NULL, false, true, false)))
gl->texnum = GL_LoadTexture32(path, pic->pic.width, pic->pic.height, (unsigned *)mem, false, false);
gl->sl = 0;
@ -491,7 +485,7 @@ mpic_t *GLDraw_SafeCachePic (char *path)
strcpy(pic->name, path);
if (mem = ReadTargaFile ((qbyte *)dat, com_filesize, &pic->pic.width, &pic->pic.height, false))
{
gl = (glpic_t *)pic->pic.data;
gl = &pic->pic.d.gl;
if (!(gl->texnum = Mod_LoadReplacementTexture(alternatename, false, true)))
gl->texnum = GL_LoadTexture32(path, pic->pic.width, pic->pic.height, (unsigned *)dat, false, true);
gl->sl = 0;
@ -542,7 +536,7 @@ mpic_t *GLDraw_SafeCachePic (char *path)
pic->pic.width = qpic->width;
pic->pic.height = qpic->height;
gl = (glpic_t *)pic->pic.data;
gl = &pic->pic.d.gl;
if (!(gl->texnum = Mod_LoadReplacementTexture(path, NULL, false, true, false)))
gl->texnum = GL_LoadPicTexture (qpic);
gl->sl = 0;
@ -969,7 +963,7 @@ TRACE(("dbg: GLDraw_ReInit: Allocating upload buffers\n"));
strcpy(glmenu_cachepics[glmenu_numcachepics].name, "conchars");
glmenu_cachepics[glmenu_numcachepics].pic.width = 128;
glmenu_cachepics[glmenu_numcachepics].pic.height = 128;
gl = (glpic_t *)&glmenu_cachepics[glmenu_numcachepics].pic.data;
gl = &glmenu_cachepics[glmenu_numcachepics].pic.d.gl;
gl->texnum = char_texture;
gl->sl = 0;
gl->tl = 0;
@ -988,7 +982,7 @@ TRACE(("dbg: GLDraw_ReInit: Allocating upload buffers\n"));
strcpy(glmenu_cachepics[glmenu_numcachepics].name, "tinyfont");
glmenu_cachepics[glmenu_numcachepics].pic.width = 128;
glmenu_cachepics[glmenu_numcachepics].pic.height = 32;
gl = (glpic_t *)&glmenu_cachepics[glmenu_numcachepics].pic.data;
gl = &glmenu_cachepics[glmenu_numcachepics].pic.d.gl;
char_texturetiny = gl->texnum = GL_LoadTexture ("tinyfont", 128, 32, tinyfont, false, true);
gl->sl = 0;
gl->tl = 0;
@ -1008,7 +1002,7 @@ TRACE(("dbg: GLDraw_ReInit: Allocating upload buffers\n"));
strcpy(glmenu_cachepics[glmenu_numcachepics].name, "gfx/menu/bigfont.lmp");
glmenu_cachepics[glmenu_numcachepics].pic.width = bigfont->width;
glmenu_cachepics[glmenu_numcachepics].pic.height = bigfont->height;
gl = (glpic_t *)&glmenu_cachepics[glmenu_numcachepics].pic.data;
gl = &glmenu_cachepics[glmenu_numcachepics].pic.d.gl;
gl->texnum = GL_LoadTexture ("gfx/menu/bigfont.lmp", bigfont->width, bigfont->height, data, false, true);
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
@ -1110,7 +1104,7 @@ TRACE(("dbg: GLDraw_ReInit: Allocating upload buffers\n"));
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
gl = (glpic_t *)conback->data;
gl = &conback->d.gl;
if (!(gl->texnum=Mod_LoadReplacementTexture("gfx/conback.lmp", NULL, false, true, false)))
{
if (!ncdata) //no fallback
@ -1142,7 +1136,7 @@ TRACE(("dbg: GLDraw_ReInit: Allocating upload buffers\n"));
custom_conback->width = vid.conwidth;
custom_conback->height = vid.conheight;
gl = (glpic_t *)custom_conback->data;
gl = &custom_conback->d.gl;
gl->texnum = 0;
gl->sl = 0;
gl->sh = 1;
@ -1586,7 +1580,7 @@ void GLDraw_Pic (int x, int y, mpic_t *pic)
if (scrap_dirty)
Scrap_Upload ();
gl = (glpic_t *)pic->data;
gl = &pic->d.gl;
draw_mesh_xyz[0][0] = x;
draw_mesh_xyz[0][1] = y;
@ -1749,7 +1743,7 @@ void GLDraw_ScalePic (int x, int y, int width, int height, mpic_t *pic)
if (scrap_dirty)
Scrap_Upload ();
gl = (glpic_t *)pic->data;
gl = &pic->d.gl;
// qglColor4f (1,1,1,1);
GL_Bind (gl->texnum);
qglBegin (GL_QUADS);
@ -1775,7 +1769,7 @@ void GLDraw_AlphaPic (int x, int y, mpic_t *pic, float alpha)
if (scrap_dirty)
Scrap_Upload ();
gl = (glpic_t *)pic->data;
gl = &pic->d.gl;
qglDisable(GL_ALPHA_TEST);
qglEnable (GL_BLEND);
// qglBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@ -1805,7 +1799,7 @@ void GLDraw_SubPic(int x, int y, mpic_t *pic, int srcx, int srcy, int width, int
if (scrap_dirty)
Scrap_Upload ();
gl = (glpic_t *)pic->data;
gl = &pic->d.gl;
oldglwidth = gl->sh - gl->sl;
oldglheight = gl->th - gl->tl;
@ -2005,7 +1999,7 @@ void GLDraw_TileClear (int x, int y, int w, int h)
}
else
{
GL_Bind (*(int *)draw_backtile->data);
GL_Bind (draw_backtile->d.gl.texnum);
qglBegin (GL_QUADS);
qglTexCoord2f (x/64.0, y/64.0);
qglVertex2f (x, y);
@ -2243,7 +2237,7 @@ void GLDraw_Image(float x, float y, float w, float h, float s1, float t1, float
if (scrap_dirty)
Scrap_Upload ();
gl = (glpic_t *)pic->data;
gl = &pic->d.gl;
/*
s2 = s2
@ -2370,7 +2364,7 @@ void GL_Font_Callback(struct cvar_s *var, char *oldvalue)
pic = GLDraw_IsCached("conchars");
if (pic)
{
glpic_t *gl = (glpic_t *)pic->data;
glpic_t *gl = &pic->d.gl;
gl->texnum = char_texture;
}
else
@ -2398,7 +2392,7 @@ void GL_Conback_Callback(struct cvar_s *var, char *oldvalue)
else
{
conback = custom_conback;
((glpic_t *)conback->data)->texnum = newtex;
conback->d.gl.texnum = newtex;
}
}

View file

@ -234,6 +234,50 @@ void *Mod_GetHalfLifeModelData(model_t *mod)
}
#endif
int HLMod_FrameForName(model_t *mod, char *name)
{
int i;
hlmdl_header_t *h;
hlmdl_sequencelist_t *seqs;
hlmodelcache_t *mc;
if (!mod || mod->type != mod_halflife)
return -1; //halflife models only, please
mc = Mod_Extradata(mod);
h = (hlmdl_header_t *)((char *)mc + mc->header);
seqs = (hlmdl_sequencelist_t*)((char*)h+h->seqindex);
for (i = 0; i < h->numseq; i++)
{
if (!strcmp(seqs[i].name, name))
return i;
}
return -1;
}
int HLMod_BoneForName(model_t *mod, char *name)
{
int i;
hlmdl_header_t *h;
hlmdl_bone_t *bones;
hlmodelcache_t *mc;
if (!mod || mod->type != mod_halflife)
return -1; //halflife models only, please
mc = Mod_Extradata(mod);
h = (hlmdl_header_t *)((char *)mc + mc->header);
bones = (hlmdl_bone_t*)((char*)h+h->boneindex);
for (i = 0; i < h->numbones; i++)
{
if (!strcmp(bones[i].name, name))
return i+1;
}
return 0;
}
/*
=======================================================================================================================
HL_CalculateBones - calculate bone positions - quaternion+vector in one function
@ -403,10 +447,10 @@ void HL_SetupBones(hlmodel_t *model, int seqnum, int firstbone, int lastbone, fl
return;
if(frame >= sequence->numframes)
{
if (sequence->motiontype&1)
frame = sequence->numframes-1;
else
if (sequence->loop)
frame %= sequence->numframes;
else
frame = sequence->numframes-1;
}
if (lastbone > model->header->numbones)
@ -576,6 +620,7 @@ void R_DrawHLModel(entity_t *curent)
if (cbone >= lastbone)
continue;
HL_SetupBones(&model, curent->framestate.g[bgroup].frame[0], cbone, lastbone, (curent->framestate.g[bgroup].subblendfrac+1)*0.5, curent->framestate.g[bgroup].frametime[0]); /* Setup the bones */
cbone = lastbone;
}
/* Manipulate each mesh directly */

View file

@ -404,7 +404,6 @@ Mod_LoadModel
Loads a model into the cache
==================
*/
char *COM_FileExtension (char *in);
model_t *GLMod_LoadModel (model_t *mod, qboolean crash)
{
void *d;
@ -2064,7 +2063,6 @@ void *suplementryclipnodes;
void *suplementryplanes;
void *crouchhullfile;
qbyte *COM_LoadMallocFile (char *path);
void GLMod_LoadCrouchHull(void)
{
int i, h;
@ -2235,7 +2233,7 @@ qboolean GLMod_LoadClipnodes (lump_t *l)
hull->planes = loadmodel->planes;
hull->clip_mins[0] = -16;
hull->clip_mins[1] = -16;
hull->clip_mins[2] = -32;//-36 is correct here, but we'll just copy mvdsv instead.
hull->clip_mins[2] = -36;//-36 is correct here, but mvdsv uses -32 instead. This breaks prediction between the two
hull->clip_maxs[0] = 16;
hull->clip_maxs[1] = 16;
hull->clip_maxs[2] = hull->clip_mins[2]+72;
@ -3028,8 +3026,8 @@ void * GLMod_LoadSpriteFrame (void * pin, mspriteframe_t **ppframe, int framenum
*ppframe = pspriteframe;
pspriteframe->width = width;
pspriteframe->height = height;
pspriteframe->p.width = width;
pspriteframe->p.height = height;
origin[0] = LittleLong (pinframe->origin[0]);
origin[1] = LittleLong (pinframe->origin[1]);
@ -3038,42 +3036,46 @@ void * GLMod_LoadSpriteFrame (void * pin, mspriteframe_t **ppframe, int framenum
pspriteframe->left = origin[0];
pspriteframe->right = width + origin[0];
pspriteframe->gl_texturenum = 0;
pspriteframe->p.d.gl.texnum = 0;
pspriteframe->p.d.gl.sl = 0;
pspriteframe->p.d.gl.sh = 1;
pspriteframe->p.d.gl.tl = 0;
pspriteframe->p.d.gl.th = 1;
if (!pspriteframe->gl_texturenum)
if (!pspriteframe->p.d.gl.texnum)
{ //the dp way
COM_StripExtension(loadmodel->name, name, sizeof(name));
Q_strncatz(name, va("_%i", framenum), sizeof(name));
pspriteframe->gl_texturenum = Mod_LoadReplacementTexture(name, "sprites", true, true, true);
pspriteframe->p.d.gl.texnum = Mod_LoadReplacementTexture(name, "sprites", true, true, true);
}
if (!pspriteframe->gl_texturenum)
if (!pspriteframe->p.d.gl.texnum)
{ //the older fte way.
COM_StripExtension(loadmodel->name, name, sizeof(name));
Q_strncatz(name, va("_%i", framenum), sizeof(name));
pspriteframe->gl_texturenum = Mod_LoadReplacementTexture(name, "sprites", true, true, true);
pspriteframe->p.d.gl.texnum = Mod_LoadReplacementTexture(name, "sprites", true, true, true);
}
if (!pspriteframe->gl_texturenum)
if (!pspriteframe->p.d.gl.texnum)
{ //the fuhquake way
COM_StripExtension(COM_SkipPath(loadmodel->name), name, sizeof(name));
Q_strncatz(name, va("_%i", framenum), sizeof(name));
pspriteframe->gl_texturenum = Mod_LoadReplacementTexture(name, "sprites", true, true, true);
pspriteframe->p.d.gl.texnum = Mod_LoadReplacementTexture(name, "sprites", true, true, true);
}
if (version == SPRITE32_VERSION)
{
size *= 4;
if (!pspriteframe->gl_texturenum)
pspriteframe->gl_texturenum = R_LoadTexture32 (name, width, height, (unsigned *)(pinframe + 1), true, true);
if (!pspriteframe->p.d.gl.texnum)
pspriteframe->p.d.gl.texnum = R_LoadTexture32 (name, width, height, (unsigned *)(pinframe + 1), true, true);
}
else if (version == SPRITEHL_VERSION)
{
if (!pspriteframe->gl_texturenum)
pspriteframe->gl_texturenum = R_LoadTexture8Pal32 (name, width, height, (qbyte *)(pinframe + 1), (qbyte*)palette, true, true);
if (!pspriteframe->p.d.gl.texnum)
pspriteframe->p.d.gl.texnum = R_LoadTexture8Pal32 (name, width, height, (qbyte *)(pinframe + 1), (qbyte*)palette, true, true);
}
else
{
if (!pspriteframe->gl_texturenum)
pspriteframe->gl_texturenum = R_LoadTexture8 (name, width, height, (qbyte *)(pinframe + 1), true, true);
if (!pspriteframe->p.d.gl.texnum)
pspriteframe->p.d.gl.texnum = R_LoadTexture8 (name, width, height, (qbyte *)(pinframe + 1), true, true);
}
return (void *)((qbyte *)(pinframe+1) + size);
@ -3330,17 +3332,17 @@ qboolean GLMod_LoadSprite2Model (model_t *mod, void *buffer)
frame = psprite->frames[i].frameptr = Hunk_AllocName(sizeof(mspriteframe_t), loadname);
frame->gl_texturenum = Mod_LoadHiResTexture(pframetype->name, NULL, true, true, true);
frame->p.d.gl.texnum = Mod_LoadHiResTexture(pframetype->name, NULL, true, true, true);
frame->width = LittleLong(pframetype->width);
frame->height = LittleLong(pframetype->height);
frame->p.width = LittleLong(pframetype->width);
frame->p.height = LittleLong(pframetype->height);
origin[0] = LittleLong (pframetype->origin_x);
origin[1] = LittleLong (pframetype->origin_y);
frame->up = -origin[1];
frame->down = frame->height - origin[1];
frame->down = frame->p.height - origin[1];
frame->left = -origin[0];
frame->right = frame->width - origin[0];
frame->right = frame->p.width - origin[0];
pframetype++;
}

View file

@ -416,13 +416,16 @@ SPRITE MODELS
// FIXME: shorten these?
typedef struct mspriteframe_s
{
float up, down, left, right;
/*
int width;
int height;
float up, down, left, right;
int gl_texturenum;
#ifdef SWQUAKE
qbyte pixels[4];
#endif
*/
mpic_t p;
} mspriteframe_t;
mspriteframe_t *R_GetSpriteFrame (entity_t *currententity);

View file

@ -142,4 +142,64 @@ void GLR_NetGraph (void)
qglEnd ();
}
void GLR_FrameTimeGraph (int frametime)
{
int a, x, i, y;
int lost;
char st[80];
unsigned ngraph_pixels[NET_GRAPHHEIGHT][NET_TIMINGS];
static int timehistory[NET_TIMINGS];
static int findex;
timehistory[findex++&NET_TIMINGSMASK] = frametime;
x = 0;
lost = CL_CalcNet();
for (a=0 ; a<NET_TIMINGS ; a++)
{
i = (findex-a) & NET_TIMINGSMASK;
R_LineGraph (NET_TIMINGS-1-a, timehistory[i]);
}
// now load the netgraph texture into gl and draw it
for (y = 0; y < NET_GRAPHHEIGHT; y++)
for (x = 0; x < NET_TIMINGS; x++)
ngraph_pixels[y][x] = d_8to24rgbtable[ngraph_texels[y][x]];
x = ((vid.width - 320)>>1);
x=-x;
y = vid.height - sb_lines - 24 - NET_GRAPHHEIGHT - 1;
M_DrawTextBox (x, y, NET_TIMINGS/8, NET_GRAPHHEIGHT/8 + 1);
y += 8;
sprintf(st, "%3i%% packet loss", lost);
Draw_String(8, y, st);
y += 8;
GL_Bind(netgraphtexture);
qglTexImage2D (GL_TEXTURE_2D, 0, gl_alpha_format,
NET_TIMINGS, NET_GRAPHHEIGHT, 0, GL_RGBA,
GL_UNSIGNED_BYTE, ngraph_pixels);
GL_TexEnv(GL_MODULATE);
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
x = 8;
qglColor3f (1,1,1);
qglBegin (GL_QUADS);
qglTexCoord2f (0, 0);
qglVertex2f (x, y);
qglTexCoord2f (1, 0);
qglVertex2f (x+NET_TIMINGS, y);
qglTexCoord2f (1, 1);
qglVertex2f (x+NET_TIMINGS, y+NET_GRAPHHEIGHT);
qglTexCoord2f (0, 1);
qglVertex2f (x, y+NET_GRAPHHEIGHT);
qglEnd ();
}
#endif

View file

@ -598,7 +598,7 @@ void R_DrawSpriteModel (entity_t *e)
GL_DisableMultitexture();
GL_Bind(frame->gl_texturenum);
GL_Bind(frame->p.d.gl.texnum);
{
extern int gldepthfunc;

View file

@ -2061,8 +2061,10 @@ void GLR_DrawWaterSurfaces (void)
}
static void GLR_DrawAlphaSurface(msurface_t *s)
static void GLR_DrawAlphaSurface(int count, msurface_t **surfs, void *type)
{
msurface_t *s = (*surfs);
qglPushMatrix();
R_RotateForEntity(s->ownerent);
#ifdef Q3SHADERS
@ -3620,7 +3622,6 @@ void GL_CreateSurfaceLightmap (msurface_t *surf, int shift)
void GLSurf_DeInit(void)
{
int i;
qglDeleteTextures(numlightmaps, lightmap_textures);
for (i = 0; i < numlightmaps; i++)
{
if (!lightmap[i])
@ -3630,7 +3631,10 @@ void GLSurf_DeInit(void)
}
if (lightmap_textures)
{
qglDeleteTextures(numlightmaps, lightmap_textures);
BZ_Free(lightmap_textures);
}
if (lightmap)
BZ_Free(lightmap);
@ -3650,7 +3654,7 @@ with all the surfaces from all brush models
*/
void GL_BuildLightmaps (void)
{
int i, j;
int i, j, t;
model_t *m;
int shift;
@ -3740,13 +3744,19 @@ void GL_BuildLightmaps (void)
currentmodel = m;
shift = GLR_LightmapShift(currentmodel);
for (i=0 ; i<m->numsurfaces ; i++)
for (t = 0; t < m->numtextures; t++)
{
GL_CreateSurfaceLightmap (m->surfaces + i, shift);
P_EmitSkyEffectTris(m, &m->surfaces[i]);
if (m->surfaces[i].mesh) //there are some surfaces that have a display list already (the subdivided ones)
continue;
GL_BuildSurfaceDisplayList (m->surfaces + i);
for (i=0 ; i<m->numsurfaces ; i++)
{//extra surface loop so we get slightly less texture switches
if (m->surfaces[i].texinfo->texture == m->textures[t])
{
GL_CreateSurfaceLightmap (m->surfaces + i, shift);
P_EmitSkyEffectTris(m, &m->surfaces[i]);
if (m->surfaces[i].mesh) //there are some surfaces that have a display list already (the subdivided ones)
continue;
GL_BuildSurfaceDisplayList (m->surfaces + i);
}
}
}
}

View file

@ -1140,7 +1140,7 @@ static shaderkey_t shaderpasskeys[] =
// ===============================================================
int Shader_InitCallback (char *name, int size, void *param)
int Shader_InitCallback (const char *name, int size, void *param)
{
strcpy(shaderbuf+shaderbuflen, name);
Shader_MakeCache(shaderbuf+shaderbuflen);
@ -2350,7 +2350,7 @@ void Shader_Default2D(char *shortname, shader_t *s)
{
mp = Draw_SafeCachePic(va("%s.lmp", shortname));
if (mp)
pass->anim_frames[0] = *(int*)mp->data;
pass->anim_frames[0] = mp->d.gl.texnum;
if (!pass->anim_frames[0])
pass->anim_frames[0] = missing_texture;

View file

@ -26,6 +26,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "resource.h"
#include <commctrl.h>
#ifndef SetWindowLongPtr //yes its a define, for unicode support
#define SetWindowLongPtr SetWindowLong
#endif
#ifndef CDS_FULLSCREEN
#define CDS_FULLSCREEN 4
@ -65,7 +68,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern cvar_t vid_conwidth, vid_conautoscale;
#define WINDOW_CLASS_NAME "WinQuake"
#define WINDOW_CLASS_NAME "FTEGLQuake"
#define MAX_MODE_LIST 128
#define VID_ROW_SIZE 3
@ -349,11 +352,20 @@ qboolean VID_SetWindowedMode (rendererstate_t *info)
DIBWidth = info->width;
DIBHeight = info->height;
WindowStyle = WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_SYSMENU |
WS_MINIMIZEBOX;
ExWindowStyle = 0;
if (sys_hijackwindow)
{
SetWindowLong(sys_hijackwindow, GWL_STYLE, GetWindowLong(sys_hijackwindow, GWL_STYLE)|WS_OVERLAPPED);
WindowStyle = WS_CHILDWINDOW|WS_OVERLAPPED;
ExWindowStyle = 0;
}
else
{
WindowStyle = WS_OVERLAPPED | WS_BORDER | WS_CAPTION | WS_SYSMENU |
WS_MINIMIZEBOX;
ExWindowStyle = 0;
WindowStyle |= WS_SIZEBOX | WS_MAXIMIZEBOX;
WindowStyle |= WS_SIZEBOX | WS_MAXIMIZEBOX;
}
rect = WindowRect;
AdjustWindowRectEx(&rect, WindowStyle, FALSE, 0);
@ -370,7 +382,7 @@ qboolean VID_SetWindowedMode (rendererstate_t *info)
rect.left, rect.top,
wwidth,
wheight,
NULL,
sys_hijackwindow,
NULL,
global_hInstance,
NULL);
@ -381,9 +393,14 @@ qboolean VID_SetWindowedMode (rendererstate_t *info)
return false;
}
// Center and show the DIB window
CenterWindow(dibwindow, WindowRect.right - WindowRect.left,
WindowRect.bottom - WindowRect.top, false);
if (!sys_hijackwindow)
{
// Center and show the DIB window
CenterWindow(dibwindow, WindowRect.right - WindowRect.left,
WindowRect.bottom - WindowRect.top, false);
}
else
SetFocus(dibwindow);
// ShowWindow (dibwindow, SW_SHOWDEFAULT);
// UpdateWindow (dibwindow);
@ -575,13 +592,9 @@ static qboolean CreateMainWindow(rendererstate_t *info)
{
TRACE(("dbg: GLVID_SetMode: VID_SetWindowedMode\n"));
stat = VID_SetWindowedMode(info);
IN_ActivateMouse ();
IN_HideMouse ();
}
else
{
IN_DeactivateMouse ();
IN_ShowMouse ();
TRACE(("dbg: GLVID_SetMode: VID_SetWindowedMode 2\n"));
stat = VID_SetWindowedMode(info);
}
@ -590,12 +603,10 @@ static qboolean CreateMainWindow(rendererstate_t *info)
{
TRACE(("dbg: GLVID_SetMode: VID_SetFullDIBMode\n"));
stat = VID_SetFullDIBMode(info);
if (stat)
{
IN_ActivateMouse ();
IN_HideMouse ();
}
}
IN_UpdateGrabs(info->fullscreen, ActiveApp);
return stat;
}
BOOL CheckForcePixelFormat(rendererstate_t *info);
@ -604,7 +615,9 @@ int GLVID_SetMode (rendererstate_t *info, unsigned char *palette)
{
int temp;
qboolean stat;
#ifndef NPQTV
MSG msg;
#endif
// HDC hdc;
TRACE(("dbg: GLVID_SetMode\n"));
@ -676,12 +689,13 @@ int GLVID_SetMode (rendererstate_t *info, unsigned char *palette)
SetForegroundWindow (mainwindow);
VID_SetPalette (palette);
while (PeekMessage (&msg, NULL, 0, 0, PM_REMOVE))
#ifndef NPQTV
while (PeekMessage (&msg, mainwindow, 0, 0, PM_REMOVE))
{
TranslateMessage (&msg);
DispatchMessage (&msg);
}
#endif
Sleep (100);
SetWindowPos (mainwindow, HWND_TOP, 0, 0, 0, 0,
@ -750,7 +764,9 @@ void VID_UnSetMode (void)
if (mainwindow)
{
dibwindow=NULL;
// SendMessage(mainwindow, WM_CLOSE, 0, 0);
// ShowWindow(mainwindow, SW_HIDE);
// SetWindowLongPtr(mainwindow, GWL_WNDPROC, DefWindowProc);
// PostMessage(mainwindow, WM_CLOSE, 0, 0);
DestroyWindow(mainwindow);
mainwindow = NULL;
}
@ -915,33 +931,8 @@ void GL_DoSwap (void)
qSwapBuffers(maindc);
// handle the mouse state when windowed if that's changed
if (modestate == MS_WINDOWED)
{
if (!_windowed_mouse.value)
{
if (mouseactive)
{
IN_DeactivateMouse ();
IN_ShowMouse ();
}
}
else
{
if ((key_dest == key_game||(mouseusedforgui && key_dest != key_console)) && ActiveApp)
{
if (!mouseactive)
{
IN_ActivateMouse ();
IN_HideMouse ();
}
}
else if (mouseactive && key_dest == key_console)
{//!(key_dest == key_game || mouseusedforgui)) {
IN_DeactivateMouse ();
IN_ShowMouse ();
}
}
}
IN_UpdateGrabs(modestate != MS_WINDOWED, ActiveApp);
}
void GL_EndRendering (void)
@ -1042,13 +1033,6 @@ void GLVID_ShiftPalette (unsigned char *palette)
}
}
void VID_SetDefaultMode (void)
{
IN_DeactivateMouse ();
}
void GLVID_Shutdown (void)
{
if (qSetDeviceGammaRamp)
@ -1324,12 +1308,12 @@ qboolean GLAppActivate(BOOL fActive, BOOL minimize)
sound_active = true;
}
IN_UpdateGrabs(modestate != MS_WINDOWED, ActiveApp);
if (fActive)
{
if (modestate != MS_WINDOWED)
{
IN_ActivateMouse ();
IN_HideMouse ();
if (vid_canalttab && vid_wassuspended) {
vid_wassuspended = false;
ChangeDisplaySettings (&gdevmode, CDS_FULLSCREEN);
@ -1339,11 +1323,6 @@ qboolean GLAppActivate(BOOL fActive, BOOL minimize)
MoveWindow (mainwindow, 0, 0, gdevmode.dmPelsWidth, gdevmode.dmPelsHeight, false);
}
}
else if ((modestate == MS_WINDOWED) && _windowed_mouse.value && (key_dest == key_game || key_dest == key_menu))
{
IN_ActivateMouse ();
IN_HideMouse ();
}
Cvar_ForceCallback(&v_gamma);
}
@ -1352,18 +1331,11 @@ qboolean GLAppActivate(BOOL fActive, BOOL minimize)
{
if (modestate != MS_WINDOWED)
{
IN_DeactivateMouse ();
IN_ShowMouse ();
if (vid_canalttab) {
ChangeDisplaySettings (NULL, 0);
vid_wassuspended = true;
}
}
else if ((modestate == MS_WINDOWED) && _windowed_mouse.value)
{
IN_DeactivateMouse ();
IN_ShowMouse ();
}
Cvar_ForceCallback(&v_gamma); //wham bam thanks.
@ -1405,16 +1377,33 @@ LONG WINAPI GLMainWndProc (
switch (uMsg)
{
case WM_KILLFOCUS:
GLAppActivate(FALSE, Minimized);
if (modestate == MS_FULLDIB)
ShowWindow(mainwindow, SW_SHOWMINNOACTIVE);
ClearAllStates ();
break;
case WM_SETFOCUS:
if (!GLAppActivate(TRUE, Minimized))
break;
ClearAllStates ();
break;
case WM_CREATE:
break;
case WM_MOVE:
window_x = (int) LOWORD(lParam);
window_y = (int) HIWORD(lParam);
{
RECT r;
// window_x = (int) LOWORD(lParam);
// window_y = (int) HIWORD(lParam);
GetWindowRect(hWnd, &r);
window_x = r.left;
window_y = r.top;
window_width = r.right - r.left;
window_height = r.bottom - r.top;
glwidth = window_width;
glheight = window_height;
}
VID_UpdateWindowStatus ();
break;
@ -1448,7 +1437,12 @@ LONG WINAPI GLMainWndProc (
temp = 0;
if (wParam & MK_LBUTTON)
{
temp |= 1;
#ifdef NPQTV
SetFocus(hWnd);
#endif
}
if (wParam & MK_RBUTTON)
temp |= 2;
@ -1606,6 +1600,7 @@ void VID_Init8bitPalette()
void GLVID_DeInit (void)
{
GLVID_Shutdown();
ActiveApp = false;
Cvar_Unhook(&_vid_wait_override);
@ -1636,11 +1631,8 @@ qboolean GLVID_Init (rendererstate_t *info, unsigned char *palette)
wc.lpszMenuName = 0;
wc.lpszClassName = WINDOW_CLASS_NAME;
if (!RegisterClass (&wc) )
{
Con_Printf(CON_ERROR "Couldn't register window class\n");
return false;
}
if (!RegisterClass (&wc)) //this isn't really fatal, we'll let the CreateWindow fail instead.
MessageBox(NULL, "RegisterClass failed", "GAH", 0);
hIcon = LoadIcon (global_hInstance, MAKEINTRESOURCE (IDI_ICON2));

View file

@ -4144,6 +4144,7 @@ rendererinfo_t d3drendererinfo = {
Mod_GetTag,
Mod_TagNumForName,
NULL,
NULL,
D3DVID_Init,
GLVID_DeInit,

View file

@ -167,7 +167,8 @@ typedef struct
{
char name[32];
float timing;
int unknown1[5];
int loop;
int unknown1[4];
int numframes;
int unknown2[2];
int motiontype;

View file

@ -14,8 +14,6 @@
int ftpfilelistsocket;
char *COM_ParseOut (char *data, char *out, int outlen);
static iwboolean ftpserverinitied = false;
iwboolean ftpserverfailed = false;
static int ftpserversocket;
@ -103,22 +101,26 @@ void FTP_ServerShutdown(void)
IWebPrintf("FTP server is deactivated\n");
}
static int SendFileNameTo(char *fname, int size, void *param)
static int SendFileNameTo(const char *rawname, int size, void *param)
{
int socket = ftpfilelistsocket; //64->32... this is safe due to where it's called from. It's just not so portable.
// int i;
char buffer[256+1];
char *slash;
int isdir = fname[strlen(fname)-1] == '/';
char nondirname[MAX_QPATH];
int isdir = rawname[strlen(rawname)-1] == '/';
char *fname;
#ifndef WEBSVONLY //copy protection of the like that QWSV normally has.
if (!isdir)
if (!SV_AllowDownload(fname)) //don't advertise if we're going to disallow it
if (!SV_AllowDownload(rawname)) //don't advertise if we're going to disallow it
return true;
#endif
Q_strncpyz(nondirname, rawname, sizeof(nondirname));
if (isdir)
fname[strlen(fname)-1] = '\0';
nondirname[strlen(nondirname)-1] = '\0';
fname = nondirname;
while((slash = strchr(fname, '/')))
fname = slash+1;

View file

@ -71,7 +71,7 @@ struct sockaddr;
struct sockaddr_qstorage;
int NetadrToSockadr (netadr_t *a, struct sockaddr_qstorage *s);
qboolean SV_AllowDownload (char *name);
qboolean SV_AllowDownload (const char *name);
typedef qboolean iwboolean;
@ -108,11 +108,11 @@ vfsfile_t *IWebGenerateFile(char *name, char *content, int contentlength);
char *COM_ParseOut (char *data, char *out, int outlen);
void COM_EnumerateFiles (char *match, int (*func)(char *, int, void *), void *parm);
char *COM_ParseOut (const char *data, char *out, int outlen);
void COM_EnumerateFiles (const char *match, int (*func)(const char *, int, void *), void *parm);
char *Q_strcpyline(char *out, char *in, int maxlen);
char *Q_strcpyline(char *out, const char *in, int maxlen);

View file

@ -512,7 +512,7 @@ iwboolean FTP_StringToAdr (const char *s, qbyte ip[4], qbyte port[2])
return true;
}
char *Q_strcpyline(char *out, char *in, int maxlen)
char *Q_strcpyline(char *out, const char *in, int maxlen)
{
char *w = out;
while (*in && maxlen > 0)

View file

@ -347,7 +347,7 @@ int VFSGen_ReadBytes(vfsfile_t *f, void *buffer, int bytes)
return bytes;
}
int VFSGen_WriteBytes(vfsfile_t *f, void *buffer, int bytes)
int VFSGen_WriteBytes(vfsfile_t *f, const void *buffer, int bytes)
{
Sys_Error("VFSGen_WriteBytes: Readonly\n");
return 0;

766
engine/libs/npapi/npapi.h Normal file
View file

@ -0,0 +1,766 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
* npapi.h $Revision: 3.48 $
* Netscape client plug-in API spec
*/
#ifndef _NPAPI_H_
#define _NPAPI_H_
#ifdef __OS2__
#pragma pack(1)
#endif
#include "prtypes.h"
/* Copied from xp_core.h */
/* removed #ifdef for hpux defined in /usr/include/model.h */
#ifndef _INT16
#define _INT16
#endif
#ifndef _INT32
#define _INT32
#endif
#ifndef _UINT16
#define _UINT16
#endif
#ifndef _UINT32
#define _UINT32
#endif
/*
* NO_NSPR_10_SUPPORT disables the inclusion
* of obsolete/protypes.h, whose int16, uint16,
* int32, and uint32 typedefs conflict with those
* in this file.
*/
#ifndef NO_NSPR_10_SUPPORT
#define NO_NSPR_10_SUPPORT
#endif
#ifdef OJI
#include "jri.h" /* Java Runtime Interface */
#endif
#if defined (__OS2__ ) || defined (OS2)
# ifndef XP_OS2
# define XP_OS2 1
# endif /* XP_OS2 */
#endif /* __OS2__ */
#ifdef _WINDOWS
# include <windef.h>
# ifndef XP_WIN
# define XP_WIN 1
# endif /* XP_WIN */
#endif /* _WINDOWS */
#ifdef __MWERKS__
# define _declspec __declspec
# ifdef __INTEL__
# undef NULL
# ifndef XP_WIN
# define XP_WIN 1
# endif /* XP_WIN */
# endif /* __INTEL__ */
#endif /* __MWERKS__ */
#ifdef XP_MACOSX
#include <Carbon/Carbon.h>
#ifdef __LP64__
#define NP_NO_QUICKDRAW
#endif
#endif
#if defined(XP_UNIX)
# include <stdio.h>
# if defined(MOZ_X11)
# include <X11/Xlib.h>
# include <X11/Xutil.h>
# endif
#endif
/*----------------------------------------------------------------------*/
/* Plugin Version Constants */
/*----------------------------------------------------------------------*/
#define NP_VERSION_MAJOR 0
#define NP_VERSION_MINOR 19
/* The OS/2 version of Netscape uses RC_DATA to define the
mime types, file extensions, etc that are required.
Use a vertical bar to separate types, end types with \0.
FileVersion and ProductVersion are 32bit ints, all other
entries are strings the MUST be terminated wwith a \0.
AN EXAMPLE:
RCDATA NP_INFO_ProductVersion { 1,0,0,1,}
RCDATA NP_INFO_MIMEType { "video/x-video|",
"video/x-flick\0" }
RCDATA NP_INFO_FileExtents { "avi|",
"flc\0" }
RCDATA NP_INFO_FileOpenName{ "MMOS2 video player(*.avi)|",
"MMOS2 Flc/Fli player(*.flc)\0" }
RCDATA NP_INFO_FileVersion { 1,0,0,1 }
RCDATA NP_INFO_CompanyName { "Netscape Communications\0" }
RCDATA NP_INFO_FileDescription { "NPAVI32 Extension DLL\0"
RCDATA NP_INFO_InternalName { "NPAVI32\0" )
RCDATA NP_INFO_LegalCopyright { "Copyright Netscape Communications \251 1996\0"
RCDATA NP_INFO_OriginalFilename { "NVAPI32.DLL" }
RCDATA NP_INFO_ProductName { "NPAVI32 Dynamic Link Library\0" }
*/
/* RC_DATA types for version info - required */
#define NP_INFO_ProductVersion 1
#define NP_INFO_MIMEType 2
#define NP_INFO_FileOpenName 3
#define NP_INFO_FileExtents 4
/* RC_DATA types for version info - used if found */
#define NP_INFO_FileDescription 5
#define NP_INFO_ProductName 6
/* RC_DATA types for version info - optional */
#define NP_INFO_CompanyName 7
#define NP_INFO_FileVersion 8
#define NP_INFO_InternalName 9
#define NP_INFO_LegalCopyright 10
#define NP_INFO_OriginalFilename 11
#ifndef RC_INVOKED
/*----------------------------------------------------------------------*/
/* Definition of Basic Types */
/*----------------------------------------------------------------------*/
#ifndef _UINT16
typedef unsigned short uint16;
#endif
#ifndef _UINT32
# if defined(__alpha) || defined(__amd64__) || defined(__x86_64__)
typedef unsigned int uint32;
# else /* __alpha */
typedef unsigned long uint32;
# endif /* __alpha */
#endif
/*
* AIX defines these in sys/inttypes.h included from sys/types.h
*/
#ifndef AIX
#ifndef _INT16
typedef short int16;
#endif
#ifndef _INT32
# if defined(__alpha) || defined(__amd64__) || defined(__x86_64__)
typedef int int32;
# else /* __alpha */
typedef long int32;
# endif /* __alpha */
#endif
#endif
#ifndef FALSE
#define FALSE (0)
#endif
#ifndef TRUE
#define TRUE (1)
#endif
#ifndef NULL
#define NULL (0L)
#endif
#ifdef XP_MACOSX
typedef enum {
#ifndef NP_NO_QUICKDRAW
NPDrawingModelQuickDraw = 0,
#endif
NPDrawingModelCoreGraphics = 1
} NPDrawingModel;
#endif
typedef unsigned char NPBool;
typedef int16 NPError;
typedef int16 NPReason;
typedef char* NPMIMEType;
/*----------------------------------------------------------------------*/
/* Structures and definitions */
/*----------------------------------------------------------------------*/
/*
* NPP is a plug-in's opaque instance handle
*/
typedef struct _NPP
{
void* pdata; /* plug-in private data */
void* ndata; /* netscape private data */
} NPP_t;
typedef NPP_t* NPP;
typedef struct _NPStream
{
void* pdata; /* plug-in private data */
void* ndata; /* netscape private data */
const char* url;
uint32 end;
uint32 lastmodified;
void* notifyData;
const char* headers; /* Response headers from host.
* Exists only for >= NPVERS_HAS_RESPONSE_HEADERS.
* Used for HTTP only; NULL for non-HTTP.
* Available from NPP_NewStream onwards.
* Plugin should copy this data before storing it.
* Includes HTTP status line and all headers,
* preferably verbatim as received from server,
* headers formatted as in HTTP ("Header: Value"),
* and newlines (\n, NOT \r\n) separating lines.
* Terminated by \n\0 (NOT \n\n\0). */
} NPStream;
typedef struct _NPByteRange
{
int32 offset; /* negative offset means from the end */
uint32 length;
struct _NPByteRange* next;
} NPByteRange;
typedef struct _NPSavedData
{
int32 len;
void* buf;
} NPSavedData;
typedef struct _NPRect
{
uint16 top;
uint16 left;
uint16 bottom;
uint16 right;
} NPRect;
typedef struct _NPSize
{
int32 width;
int32 height;
} NPSize;
#ifdef XP_UNIX
/*
* Unix specific structures and definitions
*/
/*
* Callback Structures.
*
* These are used to pass additional platform specific information.
*/
enum {
NP_SETWINDOW = 1,
NP_PRINT
};
typedef struct
{
int32 type;
} NPAnyCallbackStruct;
typedef struct
{
int32 type;
#ifdef MOZ_X11
Display* display;
Visual* visual;
Colormap colormap;
unsigned int depth;
#endif
} NPSetWindowCallbackStruct;
typedef struct
{
int32 type;
FILE* fp;
} NPPrintCallbackStruct;
#endif /* XP_UNIX */
/*
* The following masks are applied on certain platforms to NPNV and
* NPPV selectors that pass around pointers to COM interfaces. Newer
* compilers on some platforms may generate vtables that are not
* compatible with older compilers. To prevent older plugins from
* not understanding a new browser's ABI, these masks change the
* values of those selectors on those platforms. To remain backwards
* compatible with differenet versions of the browser, plugins can
* use these masks to dynamically determine and use the correct C++
* ABI that the browser is expecting. This does not apply to Windows
* as Microsoft's COM ABI will likely not change.
*/
#define NP_ABI_GCC3_MASK 0x10000000
/*
* gcc 3.x generated vtables on UNIX and OSX are incompatible with
* previous compilers.
*/
#if (defined (XP_UNIX) && defined(__GNUC__) && (__GNUC__ >= 3))
#define _NP_ABI_MIXIN_FOR_GCC3 NP_ABI_GCC3_MASK
#else
#define _NP_ABI_MIXIN_FOR_GCC3 0
#endif
#define NP_ABI_MACHO_MASK 0x01000000
/*
* On OSX, the Mach-O executable format is significantly
* different than CFM. In addition to having a different
* C++ ABI, it also has has different C calling convention.
* You must use glue code when calling between CFM and
* Mach-O C functions.
*/
#if (defined(TARGET_RT_MAC_MACHO))
#define _NP_ABI_MIXIN_FOR_MACHO NP_ABI_MACHO_MASK
#else
#define _NP_ABI_MIXIN_FOR_MACHO 0
#endif
#define NP_ABI_MASK (_NP_ABI_MIXIN_FOR_GCC3 | _NP_ABI_MIXIN_FOR_MACHO)
/*
* List of variable names for which NPP_GetValue shall be implemented
*/
typedef enum {
NPPVpluginNameString = 1,
NPPVpluginDescriptionString,
NPPVpluginWindowBool,
NPPVpluginTransparentBool,
NPPVjavaClass, /* Not implemented in Mozilla 1.0 */
NPPVpluginWindowSize,
NPPVpluginTimerInterval,
NPPVpluginScriptableInstance = (10 | NP_ABI_MASK),
NPPVpluginScriptableIID = 11,
/* Introduced in Mozilla 0.9.9 */
NPPVjavascriptPushCallerBool = 12,
/* Introduced in Mozilla 1.0 */
NPPVpluginKeepLibraryInMemory = 13,
NPPVpluginNeedsXEmbed = 14,
/* Get the NPObject for scripting the plugin. Introduced in Firefox
* 1.0 (NPAPI minor version 14).
*/
NPPVpluginScriptableNPObject = 15,
/* Get the plugin value (as \0-terminated UTF-8 string data) for
* form submission if the plugin is part of a form. Use
* NPN_MemAlloc() to allocate memory for the string data. Introduced
* in Mozilla 1.8b2 (NPAPI minor version 15).
*/
NPPVformValue = 16
#ifdef XP_MACOSX
/* Used for negotiating drawing models */
, NPPVpluginDrawingModel = 1000
#endif
} NPPVariable;
/*
* List of variable names for which NPN_GetValue is implemented by Mozilla
*/
typedef enum {
NPNVxDisplay = 1,
NPNVxtAppContext,
NPNVnetscapeWindow,
NPNVjavascriptEnabledBool,
NPNVasdEnabledBool,
NPNVisOfflineBool,
/* 10 and over are available on Mozilla builds starting with 0.9.4 */
NPNVserviceManager = (10 | NP_ABI_MASK),
NPNVDOMElement = (11 | NP_ABI_MASK), /* available in Mozilla 1.2 */
NPNVDOMWindow = (12 | NP_ABI_MASK),
NPNVToolkit = (13 | NP_ABI_MASK),
NPNVSupportsXEmbedBool = 14,
/* Get the NPObject wrapper for the browser window. */
NPNVWindowNPObject = 15,
/* Get the NPObject wrapper for the plugins DOM element. */
NPNVPluginElementNPObject = 16,
NPNVSupportsWindowless = 17
#ifdef XP_MACOSX
/* Used for negotiating drawing models */
, NPNVpluginDrawingModel = 1000
#ifndef NP_NO_QUICKDRAW
, NPNVsupportsQuickDrawBool = 2000
#endif
, NPNVsupportsCoreGraphicsBool = 2001
#endif
} NPNVariable;
/*
* The type of Tookkit the widgets use
*/
typedef enum {
NPNVGtk12 = 1,
NPNVGtk2
} NPNToolkitType;
/*
* The type of a NPWindow - it specifies the type of the data structure
* returned in the window field.
*/
typedef enum {
NPWindowTypeWindow = 1,
NPWindowTypeDrawable
} NPWindowType;
typedef struct _NPWindow
{
void* window; /* Platform specific window handle */
/* OS/2: x - Position of bottom left corner */
/* OS/2: y - relative to visible netscape window */
int32 x; /* Position of top left corner relative */
int32 y; /* to a netscape page. */
uint32 width; /* Maximum window size */
uint32 height;
NPRect clipRect; /* Clipping rectangle in port coordinates */
/* Used by MAC only. */
#if defined(XP_UNIX) && !defined(XP_MACOSX)
void * ws_info; /* Platform-dependent additonal data */
#endif /* XP_UNIX */
NPWindowType type; /* Is this a window or a drawable? */
} NPWindow;
typedef struct _NPFullPrint
{
NPBool pluginPrinted;/* Set TRUE if plugin handled fullscreen printing */
NPBool printOne; /* TRUE if plugin should print one copy to default printer */
void* platformPrint; /* Platform-specific printing info */
} NPFullPrint;
typedef struct _NPEmbedPrint
{
NPWindow window;
void* platformPrint; /* Platform-specific printing info */
} NPEmbedPrint;
typedef struct _NPPrint
{
uint16 mode; /* NP_FULL or NP_EMBED */
union
{
NPFullPrint fullPrint; /* if mode is NP_FULL */
NPEmbedPrint embedPrint; /* if mode is NP_EMBED */
} print;
} NPPrint;
#ifdef XP_MACOSX
typedef EventRecord NPEvent;
#elif defined(XP_WIN)
typedef struct _NPEvent
{
uint16 event;
uint32 wParam;
uint32 lParam;
} NPEvent;
#elif defined(XP_OS2)
typedef struct _NPEvent
{
uint32 event;
uint32 wParam;
uint32 lParam;
} NPEvent;
#elif defined (XP_UNIX) && defined(MOZ_X11)
typedef XEvent NPEvent;
#else
typedef void* NPEvent;
#endif /* XP_MACOSX */
#ifdef XP_MACOSX
typedef void* NPRegion;
#ifndef NP_NO_QUICKDRAW
typedef RgnHandle NPQDRegion;
#endif
typedef CGPathRef NPCGRegion;
#elif defined(XP_WIN)
typedef HRGN NPRegion;
#elif defined(XP_UNIX) && defined(MOZ_X11)
typedef Region NPRegion;
#else
typedef void *NPRegion;
#endif /* XP_MACOSX */
#ifdef XP_MACOSX
/*
* Mac-specific structures and definitions.
*/
typedef struct NP_Port
{
CGrafPtr port; /* Grafport */
int32 portx; /* position inside the topmost window */
int32 porty;
} NP_Port;
typedef struct NP_CGContext
{
CGContextRef context;
WindowRef window;
} NP_CGContext;
/*
* Non-standard event types that can be passed to HandleEvent
*/
enum NPEventType {
NPEventType_GetFocusEvent = (osEvt + 16),
NPEventType_LoseFocusEvent,
NPEventType_AdjustCursorEvent,
NPEventType_MenuCommandEvent,
NPEventType_ClippingChangedEvent,
NPEventType_ScrollingBeginsEvent = 1000,
NPEventType_ScrollingEndsEvent
};
#ifdef OBSOLETE
#define getFocusEvent (osEvt + 16)
#define loseFocusEvent (osEvt + 17)
#define adjustCursorEvent (osEvt + 18)
#endif
#endif /* XP_MACOSX */
/*
* Values for mode passed to NPP_New:
*/
#define NP_EMBED 1
#define NP_FULL 2
/*
* Values for stream type passed to NPP_NewStream:
*/
#define NP_NORMAL 1
#define NP_SEEK 2
#define NP_ASFILE 3
#define NP_ASFILEONLY 4
#define NP_MAXREADY (((unsigned)(~0)<<1)>>1)
/*----------------------------------------------------------------------*/
/* Error and Reason Code definitions */
/*----------------------------------------------------------------------*/
/*
* Values of type NPError:
*/
#define NPERR_BASE 0
#define NPERR_NO_ERROR (NPERR_BASE + 0)
#define NPERR_GENERIC_ERROR (NPERR_BASE + 1)
#define NPERR_INVALID_INSTANCE_ERROR (NPERR_BASE + 2)
#define NPERR_INVALID_FUNCTABLE_ERROR (NPERR_BASE + 3)
#define NPERR_MODULE_LOAD_FAILED_ERROR (NPERR_BASE + 4)
#define NPERR_OUT_OF_MEMORY_ERROR (NPERR_BASE + 5)
#define NPERR_INVALID_PLUGIN_ERROR (NPERR_BASE + 6)
#define NPERR_INVALID_PLUGIN_DIR_ERROR (NPERR_BASE + 7)
#define NPERR_INCOMPATIBLE_VERSION_ERROR (NPERR_BASE + 8)
#define NPERR_INVALID_PARAM (NPERR_BASE + 9)
#define NPERR_INVALID_URL (NPERR_BASE + 10)
#define NPERR_FILE_NOT_FOUND (NPERR_BASE + 11)
#define NPERR_NO_DATA (NPERR_BASE + 12)
#define NPERR_STREAM_NOT_SEEKABLE (NPERR_BASE + 13)
/*
* Values of type NPReason:
*/
#define NPRES_BASE 0
#define NPRES_DONE (NPRES_BASE + 0)
#define NPRES_NETWORK_ERR (NPRES_BASE + 1)
#define NPRES_USER_BREAK (NPRES_BASE + 2)
/*
* Don't use these obsolete error codes any more.
*/
#define NP_NOERR NP_NOERR_is_obsolete_use_NPERR_NO_ERROR
#define NP_EINVAL NP_EINVAL_is_obsolete_use_NPERR_GENERIC_ERROR
#define NP_EABORT NP_EABORT_is_obsolete_use_NPRES_USER_BREAK
/*
* Version feature information
*/
#define NPVERS_HAS_STREAMOUTPUT 8
#define NPVERS_HAS_NOTIFICATION 9
#define NPVERS_HAS_LIVECONNECT 9
#define NPVERS_WIN16_HAS_LIVECONNECT 9
#define NPVERS_68K_HAS_LIVECONNECT 11
#define NPVERS_HAS_WINDOWLESS 11
#define NPVERS_HAS_XPCONNECT_SCRIPTING 13
#define NPVERS_HAS_NPRUNTIME_SCRIPTING 14
#define NPVERS_HAS_FORM_VALUES 15
#define NPVERS_HAS_POPUPS_ENABLED_STATE 16
#define NPVERS_HAS_RESPONSE_HEADERS 17
#define NPVERS_HAS_NPOBJECT_ENUM 18
#define NPVERS_HAS_PLUGIN_THREAD_ASYNC_CALL 19
/*----------------------------------------------------------------------*/
/* Function Prototypes */
/*----------------------------------------------------------------------*/
#if defined(_WINDOWS) && !defined(WIN32)
#define NP_LOADDS _loadds
#else
#if defined(__OS2__)
#define NP_LOADDS _System
#else
#define NP_LOADDS
#endif
#endif
#ifdef __cplusplus
extern "C" {
#endif
/*
* NPP_* functions are provided by the plugin and called by the navigator.
*/
#ifdef XP_UNIX
char* NPP_GetMIMEDescription(void);
#endif /* XP_UNIX */
NPError NP_LOADDS NPP_Initialize(void);
void NP_LOADDS NPP_Shutdown(void);
NPError NP_LOADDS NPP_New(NPMIMEType pluginType, NPP instance,
uint16 mode, int16 argc, char* argn[],
char* argv[], NPSavedData* saved);
NPError NP_LOADDS NPP_Destroy(NPP instance, NPSavedData** save);
NPError NP_LOADDS NPP_SetWindow(NPP instance, NPWindow* window);
NPError NP_LOADDS NPP_NewStream(NPP instance, NPMIMEType type,
NPStream* stream, NPBool seekable,
uint16* stype);
NPError NP_LOADDS NPP_DestroyStream(NPP instance, NPStream* stream,
NPReason reason);
int32 NP_LOADDS NPP_WriteReady(NPP instance, NPStream* stream);
int32 NP_LOADDS NPP_Write(NPP instance, NPStream* stream, int32 offset,
int32 len, void* buffer);
void NP_LOADDS NPP_StreamAsFile(NPP instance, NPStream* stream,
const char* fname);
void NP_LOADDS NPP_Print(NPP instance, NPPrint* platformPrint);
int16 NP_LOADDS NPP_HandleEvent(NPP instance, void* event);
void NP_LOADDS NPP_URLNotify(NPP instance, const char* url,
NPReason reason, void* notifyData);
#ifdef OJI
jref NP_LOADDS NPP_GetJavaClass(void);
#endif
NPError NP_LOADDS NPP_GetValue(NPP instance, NPPVariable variable, void *value);
NPError NP_LOADDS NPP_SetValue(NPP instance, NPNVariable variable, void *value);
/*
* NPN_* functions are provided by the navigator and called by the plugin.
*/
void NP_LOADDS NPN_Version(int* plugin_major, int* plugin_minor,
int* netscape_major, int* netscape_minor);
NPError NP_LOADDS NPN_GetURLNotify(NPP instance, const char* url,
const char* target, void* notifyData);
NPError NP_LOADDS NPN_GetURL(NPP instance, const char* url,
const char* target);
NPError NP_LOADDS NPN_PostURLNotify(NPP instance, const char* url,
const char* target, uint32 len,
const char* buf, NPBool file,
void* notifyData);
NPError NP_LOADDS NPN_PostURL(NPP instance, const char* url,
const char* target, uint32 len,
const char* buf, NPBool file);
NPError NP_LOADDS NPN_RequestRead(NPStream* stream, NPByteRange* rangeList);
NPError NP_LOADDS NPN_NewStream(NPP instance, NPMIMEType type,
const char* target, NPStream** stream);
int32 NP_LOADDS NPN_Write(NPP instance, NPStream* stream, int32 len, void* buffer);
NPError NP_LOADDS NPN_DestroyStream(NPP instance, NPStream* stream, NPReason reason);
void NP_LOADDS NPN_Status(NPP instance, const char* message);
const char* NP_LOADDS NPN_UserAgent(NPP instance);
void* NP_LOADDS NPN_MemAlloc(uint32 size);
void NP_LOADDS NPN_MemFree(void* ptr);
uint32 NP_LOADDS NPN_MemFlush(uint32 size);
void NP_LOADDS NPN_ReloadPlugins(NPBool reloadPages);
#ifdef OJI
JRIEnv* NP_LOADDS NPN_GetJavaEnv(void);
jref NP_LOADDS NPN_GetJavaPeer(NPP instance);
#endif
NPError NP_LOADDS NPN_GetValue(NPP instance, NPNVariable variable, void *value);
NPError NP_LOADDS NPN_SetValue(NPP instance, NPPVariable variable, void *value);
void NP_LOADDS NPN_InvalidateRect(NPP instance, NPRect *invalidRect);
void NP_LOADDS NPN_InvalidateRegion(NPP instance, NPRegion invalidRegion);
void NP_LOADDS NPN_ForceRedraw(NPP instance);
void NP_LOADDS NPN_PushPopupsEnabledState(NPP instance, NPBool enabled);
void NP_LOADDS NPN_PopPopupsEnabledState(NPP instance);
void NP_LOADDS NPN_PluginThreadAsyncCall(NPP instance,
void (*func) (void *),
void *userData);
#ifdef __cplusplus
} /* end extern "C" */
#endif
#endif /* RC_INVOKED */
#ifdef __OS2__
#pragma pack()
#endif
#endif /* _NPAPI_H_ */

View file

@ -0,0 +1,423 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* Copyright © 2004, Apple Computer, Inc. and The Mozilla Foundation.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the names of Apple Computer, Inc. ("Apple") or The Mozilla
* Foundation ("Mozilla") nor the names of their contributors may be used
* to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY APPLE, MOZILLA AND THEIR CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE, MOZILLA OR
* THEIR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Revision 1 (March 4, 2004):
* Initial proposal.
*
* Revision 2 (March 10, 2004):
* All calls into script were made asynchronous. Results are
* provided via the NPScriptResultFunctionPtr callback.
*
* Revision 3 (March 10, 2004):
* Corrected comments to not refer to class retain/release FunctionPtrs.
*
* Revision 4 (March 11, 2004):
* Added additional convenience NPN_SetExceptionWithUTF8().
* Changed NPHasPropertyFunctionPtr and NPHasMethodFunctionPtr to take NPClass
* pointers instead of NPObject pointers.
* Added NPIsValidIdentifier().
*
* Revision 5 (March 17, 2004):
* Added context parameter to result callbacks from ScriptObject functions.
*
* Revision 6 (March 29, 2004):
* Renamed functions implemented by user agent to NPN_*. Removed _ from
* type names.
* Renamed "JavaScript" types to "Script".
*
* Revision 7 (April 21, 2004):
* NPIdentifier becomes a void*, was int32_t
* Remove NP_IsValidIdentifier, renamed NP_IdentifierFromUTF8 to NP_GetIdentifier
* Added NPVariant and modified functions to use this new type.
*
* Revision 8 (July 9, 2004):
* Updated to joint Apple-Mozilla license.
*
*/
#ifndef _NP_RUNTIME_H_
#define _NP_RUNTIME_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "nptypes.h"
/*
This API is used to facilitate binding code written in C to script
objects. The API in this header does not assume the presence of a
user agent. That is, it can be used to bind C code to scripting
environments outside of the context of a user agent.
However, the normal use of the this API is in the context of a
scripting environment running in a browser or other user agent.
In particular it is used to support the extended Netscape
script-ability API for plugins (NP-SAP). NP-SAP is an extension
of the Netscape plugin API. As such we have adopted the use of
the "NP" prefix for this API.
The following NP{N|P}Variables were added to the Netscape plugin
API (in npapi.h):
NPNVWindowNPObject
NPNVPluginElementNPObject
NPPVpluginScriptableNPObject
These variables are exposed through NPN_GetValue() and
NPP_GetValue() (respectively) and are used to establish the
initial binding between the user agent and native code. The DOM
objects in the user agent can be examined and manipulated using
the NPN_ functions that operate on NPObjects described in this
header.
To the extent possible the assumptions about the scripting
language used by the scripting environment have been minimized.
*/
#define NP_BEGIN_MACRO do {
#define NP_END_MACRO } while (0)
/*
Objects (non-primitive data) passed between 'C' and script is
always wrapped in an NPObject. The 'interface' of an NPObject is
described by an NPClass.
*/
typedef struct NPObject NPObject;
typedef struct NPClass NPClass;
typedef char NPUTF8;
typedef struct _NPString {
const NPUTF8 *utf8characters;
uint32_t utf8length;
} NPString;
typedef enum {
NPVariantType_Void,
NPVariantType_Null,
NPVariantType_Bool,
NPVariantType_Int32,
NPVariantType_Double,
NPVariantType_String,
NPVariantType_Object
} NPVariantType;
typedef struct _NPVariant {
NPVariantType type;
union {
bool boolValue;
int32_t intValue;
double doubleValue;
NPString stringValue;
NPObject *objectValue;
} value;
} NPVariant;
/*
NPN_ReleaseVariantValue is called on all 'out' parameters
references. Specifically it is to be called on variants that own
their value, as is the case with all non-const NPVariant*
arguments after a successful call to any methods (except this one)
in this API.
After calling NPN_ReleaseVariantValue, the type of the variant
will be NPVariantType_Void.
*/
void NPN_ReleaseVariantValue(NPVariant *variant);
#define NPVARIANT_IS_VOID(_v) ((_v).type == NPVariantType_Void)
#define NPVARIANT_IS_NULL(_v) ((_v).type == NPVariantType_Null)
#define NPVARIANT_IS_BOOLEAN(_v) ((_v).type == NPVariantType_Bool)
#define NPVARIANT_IS_INT32(_v) ((_v).type == NPVariantType_Int32)
#define NPVARIANT_IS_DOUBLE(_v) ((_v).type == NPVariantType_Double)
#define NPVARIANT_IS_STRING(_v) ((_v).type == NPVariantType_String)
#define NPVARIANT_IS_OBJECT(_v) ((_v).type == NPVariantType_Object)
#define NPVARIANT_TO_BOOLEAN(_v) ((_v).value.boolValue)
#define NPVARIANT_TO_INT32(_v) ((_v).value.intValue)
#define NPVARIANT_TO_DOUBLE(_v) ((_v).value.doubleValue)
#define NPVARIANT_TO_STRING(_v) ((_v).value.stringValue)
#define NPVARIANT_TO_OBJECT(_v) ((_v).value.objectValue)
#define VOID_TO_NPVARIANT(_v) \
NP_BEGIN_MACRO \
(_v).type = NPVariantType_Void; \
(_v).value.objectValue = NULL; \
NP_END_MACRO
#define NULL_TO_NPVARIANT(_v) \
NP_BEGIN_MACRO \
(_v).type = NPVariantType_Null; \
(_v).value.objectValue = NULL; \
NP_END_MACRO
#define BOOLEAN_TO_NPVARIANT(_val, _v) \
NP_BEGIN_MACRO \
(_v).type = NPVariantType_Bool; \
(_v).value.boolValue = !!(_val); \
NP_END_MACRO
#define INT32_TO_NPVARIANT(_val, _v) \
NP_BEGIN_MACRO \
(_v).type = NPVariantType_Int32; \
(_v).value.intValue = _val; \
NP_END_MACRO
#define DOUBLE_TO_NPVARIANT(_val, _v) \
NP_BEGIN_MACRO \
(_v).type = NPVariantType_Double; \
(_v).value.doubleValue = _val; \
NP_END_MACRO
#define STRINGZ_TO_NPVARIANT(_val, _v) \
NP_BEGIN_MACRO \
(_v).type = NPVariantType_String; \
NPString str = { _val, strlen(_val) }; \
(_v).value.stringValue = str; \
NP_END_MACRO
#define STRINGN_TO_NPVARIANT(_val, _len, _v) \
NP_BEGIN_MACRO \
(_v).type = NPVariantType_String; \
NPString str = { _val, _len }; \
(_v).value.stringValue = str; \
NP_END_MACRO
#define OBJECT_TO_NPVARIANT(_val, _v) \
NP_BEGIN_MACRO \
(_v).type = NPVariantType_Object; \
(_v).value.objectValue = _val; \
NP_END_MACRO
/*
Type mappings (JavaScript types have been used for illustration
purposes):
JavaScript to C (NPVariant with type:)
undefined NPVariantType_Void
null NPVariantType_Null
Boolean NPVariantType_Bool
Number NPVariantType_Double or NPVariantType_Int32
String NPVariantType_String
Object NPVariantType_Object
C (NPVariant with type:) to JavaScript
NPVariantType_Void undefined
NPVariantType_Null null
NPVariantType_Bool Boolean
NPVariantType_Int32 Number
NPVariantType_Double Number
NPVariantType_String String
NPVariantType_Object Object
*/
typedef void *NPIdentifier;
/*
NPObjects have methods and properties. Methods and properties are
identified with NPIdentifiers. These identifiers may be reflected
in script. NPIdentifiers can be either strings or integers, IOW,
methods and properties can be identified by either strings or
integers (i.e. foo["bar"] vs foo[1]). NPIdentifiers can be
compared using ==. In case of any errors, the requested
NPIdentifier(s) will be NULL.
*/
NPIdentifier NPN_GetStringIdentifier(const NPUTF8 *name);
void NPN_GetStringIdentifiers(const NPUTF8 **names, int32_t nameCount,
NPIdentifier *identifiers);
NPIdentifier NPN_GetIntIdentifier(int32_t intid);
bool NPN_IdentifierIsString(NPIdentifier identifier);
/*
The NPUTF8 returned from NPN_UTF8FromIdentifier SHOULD be freed.
*/
NPUTF8 *NPN_UTF8FromIdentifier(NPIdentifier identifier);
/*
Get the integer represented by identifier. If identifier is not an
integer identifier, the behaviour is undefined.
*/
int32_t NPN_IntFromIdentifier(NPIdentifier identifier);
/*
NPObject behavior is implemented using the following set of
callback functions.
The NPVariant *result argument of these functions (where
applicable) should be released using NPN_ReleaseVariantValue().
*/
typedef NPObject *(*NPAllocateFunctionPtr)(NPP npp, NPClass *aClass);
typedef void (*NPDeallocateFunctionPtr)(NPObject *npobj);
typedef void (*NPInvalidateFunctionPtr)(NPObject *npobj);
typedef bool (*NPHasMethodFunctionPtr)(NPObject *npobj, NPIdentifier name);
typedef bool (*NPInvokeFunctionPtr)(NPObject *npobj, NPIdentifier name,
const NPVariant *args, uint32_t argCount,
NPVariant *result);
typedef bool (*NPInvokeDefaultFunctionPtr)(NPObject *npobj,
const NPVariant *args,
uint32_t argCount,
NPVariant *result);
typedef bool (*NPHasPropertyFunctionPtr)(NPObject *npobj, NPIdentifier name);
typedef bool (*NPGetPropertyFunctionPtr)(NPObject *npobj, NPIdentifier name,
NPVariant *result);
typedef bool (*NPSetPropertyFunctionPtr)(NPObject *npobj, NPIdentifier name,
const NPVariant *value);
typedef bool (*NPRemovePropertyFunctionPtr)(NPObject *npobj,
NPIdentifier name);
typedef bool (*NPEnumerationFunctionPtr)(NPObject *npobj, NPIdentifier **value,
uint32_t *count);
typedef bool (*NPConstructFunctionPtr)(NPObject *npobj,
const NPVariant *args,
uint32_t argCount,
NPVariant *result);
/*
NPObjects returned by create, retain, invoke, and getProperty pass
a reference count to the caller. That is, the callee adds a
reference count which passes to the caller. It is the caller's
responsibility to release the returned object.
NPInvokeFunctionPtr function may return 0 to indicate a void
result.
NPInvalidateFunctionPtr is called by the scripting environment
when the native code is shutdown. Any attempt to message a
NPObject instance after the invalidate callback has been
called will result in undefined behavior, even if the native code
is still retaining those NPObject instances. (The runtime
will typically return immediately, with 0 or NULL, from an attempt
to dispatch to a NPObject, but this behavior should not be
depended upon.)
The NPEnumerationFunctionPtr function may pass an array of
NPIdentifiers back to the caller. The callee allocs the memory of
the array using NPN_MemAlloc(), and it's the caller's responsibility
to release it using NPN_MemFree().
*/
struct NPClass
{
uint32_t structVersion;
NPAllocateFunctionPtr allocate;
NPDeallocateFunctionPtr deallocate;
NPInvalidateFunctionPtr invalidate;
NPHasMethodFunctionPtr hasMethod;
NPInvokeFunctionPtr invoke;
NPInvokeDefaultFunctionPtr invokeDefault;
NPHasPropertyFunctionPtr hasProperty;
NPGetPropertyFunctionPtr getProperty;
NPSetPropertyFunctionPtr setProperty;
NPRemovePropertyFunctionPtr removeProperty;
NPEnumerationFunctionPtr enumerate;
NPConstructFunctionPtr construct;
};
#define NP_CLASS_STRUCT_VERSION 3
#define NP_CLASS_STRUCT_VERSION_ENUM 2
#define NP_CLASS_STRUCT_VERSION_CTOR 3
#define NP_CLASS_STRUCT_VERSION_HAS_ENUM(npclass) \
((npclass)->structVersion >= NP_CLASS_STRUCT_VERSION_ENUM)
#define NP_CLASS_STRUCT_VERSION_HAS_CTOR(npclass) \
((npclass)->structVersion >= NP_CLASS_STRUCT_VERSION_CTOR)
struct NPObject {
NPClass *_class;
uint32_t referenceCount;
/*
* Additional space may be allocated here by types of NPObjects
*/
};
/*
If the class has an allocate function, NPN_CreateObject invokes
that function, otherwise a NPObject is allocated and
returned. This method will initialize the referenceCount member of
the NPObject to 1.
*/
NPObject *NPN_CreateObject(NPP npp, NPClass *aClass);
/*
Increment the NPObject's reference count.
*/
NPObject *NPN_RetainObject(NPObject *npobj);
/*
Decremented the NPObject's reference count. If the reference
count goes to zero, the class's destroy function is invoke if
specified, otherwise the object is freed directly.
*/
void NPN_ReleaseObject(NPObject *npobj);
/*
Functions to access script objects represented by NPObject.
Calls to script objects are synchronous. If a function returns a
value, it will be supplied via the result NPVariant
argument. Successful calls will return true, false will be
returned in case of an error.
Calls made from plugin code to script must be made from the thread
on which the plugin was initialized.
*/
bool NPN_Invoke(NPP npp, NPObject *npobj, NPIdentifier methodName,
const NPVariant *args, uint32_t argCount, NPVariant *result);
bool NPN_InvokeDefault(NPP npp, NPObject *npobj, const NPVariant *args,
uint32_t argCount, NPVariant *result);
bool NPN_Evaluate(NPP npp, NPObject *npobj, NPString *script,
NPVariant *result);
bool NPN_GetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName,
NPVariant *result);
bool NPN_SetProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName,
const NPVariant *value);
bool NPN_RemoveProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName);
bool NPN_HasProperty(NPP npp, NPObject *npobj, NPIdentifier propertyName);
bool NPN_HasMethod(NPP npp, NPObject *npobj, NPIdentifier methodName);
bool NPN_Enumerate(NPP npp, NPObject *npobj, NPIdentifier **identifier,
uint32_t *count);
bool NPN_Construct(NPP npp, NPObject *npobj, const NPVariant *args,
uint32_t argCount, NPVariant *result);
/*
NPN_SetException may be called to trigger a script exception upon
return from entry points into NPObjects. Typical usage:
NPN_SetException (npobj, message);
*/
void NPN_SetException(NPObject *npobj, const NPUTF8 *message);
#ifdef __cplusplus
}
#endif
#endif

105
engine/libs/npapi/nptypes.h Normal file
View file

@ -0,0 +1,105 @@
/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* mozilla.org.
* Portions created by the Initial Developer are Copyright (C) 2004
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
* Johnny Stenback <jst@mozilla.org> (Original author)
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
* Header file for ensuring that C99 types ([u]int32_t and bool) are
* available.
*/
#if defined(WIN32) || defined(OS2)
/*
* Win32 and OS/2 don't know C99, so define [u]int_32 here. The bool
* is predefined tho, both in C and C++.
*/
typedef int int32_t;
typedef unsigned int uint32_t;
#elif defined(_AIX) || defined(__sun) || defined(__osf__) || defined(IRIX) || defined(HPUX)
/*
* AIX and SunOS ship a inttypes.h header that defines [u]int32_t,
* but not bool for C.
*/
#include <inttypes.h>
#ifndef __cplusplus
typedef int bool;
#endif
#elif defined(bsdi) || defined(FREEBSD) || defined(OPENBSD)
/*
* BSD/OS, FreeBSD, and OpenBSD ship sys/types.h that define int32_t and
* u_int32_t.
*/
#include <sys/types.h>
/*
* BSD/OS ships no header that defines uint32_t, nor bool (for C)
*/
#if defined(bsdi)
typedef u_int32_t uint32_t;
#if !defined(__cplusplus)
typedef int bool;
#endif
#else
/*
* FreeBSD and OpenBSD define uint32_t and bool.
*/
#include <inttypes.h>
#include <stdbool.h>
#endif
#elif defined(BEOS)
#include <inttypes.h>
#else
/*
* For those that ship a standard C99 stdint.h header file, include
* it. Can't do the same for stdbool.h tho, since some systems ship
* with a stdbool.h file that doesn't compile!
*/
#include <stdint.h>
#ifndef __cplusplus
#if !defined(__GNUC__) || (__GNUC__ > 2 || __GNUC_MINOR__ > 95)
#include <stdbool.h>
#else
/*
* GCC 2.91 can't deal with a typedef for bool, but a #define
* works.
*/
#define bool int
#endif
#endif
#endif

721
engine/libs/npapi/npupp.h Normal file
View file

@ -0,0 +1,721 @@
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
* npupp.h $Revision: 3.26 $
* function call mecahnics needed by platform specific glue code.
*/
#ifndef _NPUPP_H_
#define _NPUPP_H_
#if defined(__OS2__)
#pragma pack(1)
#endif
#ifndef GENERATINGCFM
#define GENERATINGCFM 0
#endif
#ifndef _NPAPI_H_
#include "npapi.h"
#endif
#include "npruntime.h"
#ifdef DOJRI
#include "jri.h"
#else
typedef struct JRIGlobal* JRIGlobalRef;
typedef void *JRIEnv;
typedef void *jref;
#endif
/******************************************************************************************
plug-in function table macros
for each function in and out of the plugin API we define
typedef NPP_FooUPP
#define NewNPP_FooProc
#define CallNPP_FooProc
*******************************************************************************************/
/* NPP_Initialize */
typedef void (* NP_LOADDS NPP_InitializeUPP)(void);
#define NewNPP_InitializeProc(FUNC) \
((NPP_InitializeUPP) (FUNC))
#define CallNPP_InitializeProc(FUNC) \
(*(FUNC))()
/* NPP_Shutdown */
typedef void (* NP_LOADDS NPP_ShutdownUPP)(void);
#define NewNPP_ShutdownProc(FUNC) \
((NPP_ShutdownUPP) (FUNC))
#define CallNPP_ShutdownProc(FUNC) \
(*(FUNC))()
/* NPP_New */
typedef NPError (* NP_LOADDS NPP_NewUPP)(NPMIMEType pluginType, NPP instance, uint16 mode, int16 argc, char* argn[], char* argv[], NPSavedData* saved);
#define NewNPP_NewProc(FUNC) \
((NPP_NewUPP) (FUNC))
#define CallNPP_NewProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7) \
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6), (ARG7))
/* NPP_Destroy */
typedef NPError (* NP_LOADDS NPP_DestroyUPP)(NPP instance, NPSavedData** save);
#define NewNPP_DestroyProc(FUNC) \
((NPP_DestroyUPP) (FUNC))
#define CallNPP_DestroyProc(FUNC, ARG1, ARG2) \
(*(FUNC))((ARG1), (ARG2))
/* NPP_SetWindow */
typedef NPError (* NP_LOADDS NPP_SetWindowUPP)(NPP instance, NPWindow* window);
#define NewNPP_SetWindowProc(FUNC) \
((NPP_SetWindowUPP) (FUNC))
#define CallNPP_SetWindowProc(FUNC, ARG1, ARG2) \
(*(FUNC))((ARG1), (ARG2))
/* NPP_NewStream */
typedef NPError (* NP_LOADDS NPP_NewStreamUPP)(NPP instance, NPMIMEType type, NPStream* stream, NPBool seekable, uint16* stype);
#define NewNPP_NewStreamProc(FUNC) \
((NPP_NewStreamUPP) (FUNC))
#define CallNPP_NewStreamProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5) \
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5))
/* NPP_DestroyStream */
typedef NPError (* NP_LOADDS NPP_DestroyStreamUPP)(NPP instance, NPStream* stream, NPReason reason);
#define NewNPP_DestroyStreamProc(FUNC) \
((NPP_DestroyStreamUPP) (FUNC))
#define CallNPP_DestroyStreamProc(FUNC, NPParg, NPStreamPtr, NPReasonArg) \
(*(FUNC))((NPParg), (NPStreamPtr), (NPReasonArg))
/* NPP_WriteReady */
typedef int32 (* NP_LOADDS NPP_WriteReadyUPP)(NPP instance, NPStream* stream);
#define NewNPP_WriteReadyProc(FUNC) \
((NPP_WriteReadyUPP) (FUNC))
#define CallNPP_WriteReadyProc(FUNC, NPParg, NPStreamPtr) \
(*(FUNC))((NPParg), (NPStreamPtr))
/* NPP_Write */
typedef int32 (* NP_LOADDS NPP_WriteUPP)(NPP instance, NPStream* stream, int32 offset, int32 len, void* buffer);
#define NewNPP_WriteProc(FUNC) \
((NPP_WriteUPP) (FUNC))
#define CallNPP_WriteProc(FUNC, NPParg, NPStreamPtr, offsetArg, lenArg, bufferPtr) \
(*(FUNC))((NPParg), (NPStreamPtr), (offsetArg), (lenArg), (bufferPtr))
/* NPP_StreamAsFile */
typedef void (* NP_LOADDS NPP_StreamAsFileUPP)(NPP instance, NPStream* stream, const char* fname);
#define NewNPP_StreamAsFileProc(FUNC) \
((NPP_StreamAsFileUPP) (FUNC))
#define CallNPP_StreamAsFileProc(FUNC, ARG1, ARG2, ARG3) \
(*(FUNC))((ARG1), (ARG2), (ARG3))
/* NPP_Print */
typedef void (* NP_LOADDS NPP_PrintUPP)(NPP instance, NPPrint* platformPrint);
#define NewNPP_PrintProc(FUNC) \
((NPP_PrintUPP) (FUNC))
#define CallNPP_PrintProc(FUNC, NPParg, NPPrintArg) \
(*(FUNC))((NPParg), (NPPrintArg))
/* NPP_HandleEvent */
typedef int16 (* NP_LOADDS NPP_HandleEventUPP)(NPP instance, void* event);
#define NewNPP_HandleEventProc(FUNC) \
((NPP_HandleEventUPP) (FUNC))
#define CallNPP_HandleEventProc(FUNC, NPParg, voidPtr) \
(*(FUNC))((NPParg), (voidPtr))
/* NPP_URLNotify */
typedef void (* NP_LOADDS NPP_URLNotifyUPP)(NPP instance, const char* url, NPReason reason, void* notifyData);
#define NewNPP_URLNotifyProc(FUNC) \
((NPP_URLNotifyUPP) (FUNC))
#define CallNPP_URLNotifyProc(FUNC, ARG1, ARG2, ARG3, ARG4) \
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
/* NPP_GetValue */
typedef NPError (* NP_LOADDS NPP_GetValueUPP)(NPP instance, NPPVariable variable, void *ret_alue);
#define NewNPP_GetValueProc(FUNC) \
((NPP_GetValueUPP) (FUNC))
#define CallNPP_GetValueProc(FUNC, ARG1, ARG2, ARG3) \
(*(FUNC))((ARG1), (ARG2), (ARG3))
/* NPP_SetValue */
typedef NPError (* NP_LOADDS NPP_SetValueUPP)(NPP instance, NPNVariable variable, void *ret_alue);
#define NewNPP_SetValueProc(FUNC) \
((NPP_SetValueUPP) (FUNC))
#define CallNPP_SetValueProc(FUNC, ARG1, ARG2, ARG3) \
(*(FUNC))((ARG1), (ARG2), (ARG3))
/*
* Netscape entry points
*/
/* NPN_GetValue */
typedef NPError (* NP_LOADDS NPN_GetValueUPP)(NPP instance, NPNVariable variable, void *ret_alue);
#define NewNPN_GetValueProc(FUNC) \
((NPN_GetValueUPP) (FUNC))
#define CallNPN_GetValueProc(FUNC, ARG1, ARG2, ARG3) \
(*(FUNC))((ARG1), (ARG2), (ARG3))
/* NPN_SetValue */
typedef NPError (* NP_LOADDS NPN_SetValueUPP)(NPP instance, NPPVariable variable, void *ret_alue);
#define NewNPN_SetValueProc(FUNC) \
((NPN_SetValueUPP) (FUNC))
#define CallNPN_SetValueProc(FUNC, ARG1, ARG2, ARG3) \
(*(FUNC))((ARG1), (ARG2), (ARG3))
/* NPN_GetUrlNotify */
typedef NPError (* NP_LOADDS NPN_GetURLNotifyUPP)(NPP instance, const char* url, const char* window, void* notifyData);
#define NewNPN_GetURLNotifyProc(FUNC) \
((NPN_GetURLNotifyUPP) (FUNC))
#define CallNPN_GetURLNotifyProc(FUNC, ARG1, ARG2, ARG3, ARG4) \
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
/* NPN_PostUrlNotify */
typedef NPError (* NP_LOADDS NPN_PostURLNotifyUPP)(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file, void* notifyData);
#define NewNPN_PostURLNotifyProc(FUNC) \
((NPN_PostURLNotifyUPP) (FUNC))
#define CallNPN_PostURLNotifyProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6, ARG7) \
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6), (ARG7))
/* NPN_GetUrl */
typedef NPError (* NP_LOADDS NPN_GetURLUPP)(NPP instance, const char* url, const char* window);
#define NewNPN_GetURLProc(FUNC) \
((NPN_GetURLUPP) (FUNC))
#define CallNPN_GetURLProc(FUNC, ARG1, ARG2, ARG3) \
(*(FUNC))((ARG1), (ARG2), (ARG3))
/* NPN_PostUrl */
typedef NPError (* NP_LOADDS NPN_PostURLUPP)(NPP instance, const char* url, const char* window, uint32 len, const char* buf, NPBool file);
#define NewNPN_PostURLProc(FUNC) \
((NPN_PostURLUPP) (FUNC))
#define CallNPN_PostURLProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6) \
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6))
/* NPN_RequestRead */
typedef NPError (* NP_LOADDS NPN_RequestReadUPP)(NPStream* stream, NPByteRange* rangeList);
#define NewNPN_RequestReadProc(FUNC) \
((NPN_RequestReadUPP) (FUNC))
#define CallNPN_RequestReadProc(FUNC, stream, range) \
(*(FUNC))((stream), (range))
/* NPN_NewStream */
typedef NPError (* NP_LOADDS NPN_NewStreamUPP)(NPP instance, NPMIMEType type, const char* window, NPStream** stream);
#define NewNPN_NewStreamProc(FUNC) \
((NPN_NewStreamUPP) (FUNC))
#define CallNPN_NewStreamProc(FUNC, npp, type, window, stream) \
(*(FUNC))((npp), (type), (window), (stream))
/* NPN_Write */
typedef int32 (* NP_LOADDS NPN_WriteUPP)(NPP instance, NPStream* stream, int32 len, void* buffer);
#define NewNPN_WriteProc(FUNC) \
((NPN_WriteUPP) (FUNC))
#define CallNPN_WriteProc(FUNC, npp, stream, len, buffer) \
(*(FUNC))((npp), (stream), (len), (buffer))
/* NPN_DestroyStream */
typedef NPError (* NP_LOADDS NPN_DestroyStreamUPP)(NPP instance, NPStream* stream, NPReason reason);
#define NewNPN_DestroyStreamProc(FUNC) \
((NPN_DestroyStreamUPP) (FUNC))
#define CallNPN_DestroyStreamProc(FUNC, npp, stream, reason) \
(*(FUNC))((npp), (stream), (reason))
/* NPN_Status */
typedef void (* NP_LOADDS NPN_StatusUPP)(NPP instance, const char* message);
#define NewNPN_StatusProc(FUNC) \
((NPN_StatusUPP) (FUNC))
#define CallNPN_StatusProc(FUNC, npp, msg) \
(*(FUNC))((npp), (msg))
/* NPN_UserAgent */
typedef const char* (* NP_LOADDS NPN_UserAgentUPP)(NPP instance);
#define NewNPN_UserAgentProc(FUNC) \
((NPN_UserAgentUPP) (FUNC))
#define CallNPN_UserAgentProc(FUNC, ARG1) \
(*(FUNC))((ARG1))
/* NPN_MemAlloc */
typedef void* (* NP_LOADDS NPN_MemAllocUPP)(uint32 size);
#define NewNPN_MemAllocProc(FUNC) \
((NPN_MemAllocUPP) (FUNC))
#define CallNPN_MemAllocProc(FUNC, ARG1) \
(*(FUNC))((ARG1))
/* NPN__MemFree */
typedef void (* NP_LOADDS NPN_MemFreeUPP)(void* ptr);
#define NewNPN_MemFreeProc(FUNC) \
((NPN_MemFreeUPP) (FUNC))
#define CallNPN_MemFreeProc(FUNC, ARG1) \
(*(FUNC))((ARG1))
/* NPN_MemFlush */
typedef uint32 (* NP_LOADDS NPN_MemFlushUPP)(uint32 size);
#define NewNPN_MemFlushProc(FUNC) \
((NPN_MemFlushUPP) (FUNC))
#define CallNPN_MemFlushProc(FUNC, ARG1) \
(*(FUNC))((ARG1))
/* NPN_ReloadPlugins */
typedef void (* NP_LOADDS NPN_ReloadPluginsUPP)(NPBool reloadPages);
#define NewNPN_ReloadPluginsProc(FUNC) \
((NPN_ReloadPluginsUPP) (FUNC))
#define CallNPN_ReloadPluginsProc(FUNC, ARG1) \
(*(FUNC))((ARG1))
/* NPN_GetJavaEnv */
typedef JRIEnv* (* NP_LOADDS NPN_GetJavaEnvUPP)(void);
#define NewNPN_GetJavaEnvProc(FUNC) \
((NPN_GetJavaEnvUPP) (FUNC))
#define CallNPN_GetJavaEnvProc(FUNC) \
(*(FUNC))()
/* NPN_GetJavaPeer */
typedef jref (* NP_LOADDS NPN_GetJavaPeerUPP)(NPP instance);
#define NewNPN_GetJavaPeerProc(FUNC) \
((NPN_GetJavaPeerUPP) (FUNC))
#define CallNPN_GetJavaPeerProc(FUNC, ARG1) \
(*(FUNC))((ARG1))
/* NPN_InvalidateRect */
typedef void (* NP_LOADDS NPN_InvalidateRectUPP)(NPP instance, NPRect *rect);
#define NewNPN_InvalidateRectProc(FUNC) \
((NPN_InvalidateRectUPP) (FUNC))
#define CallNPN_InvalidateRectProc(FUNC, ARG1, ARG2) \
(*(FUNC))((ARG1), (ARG2))
/* NPN_InvalidateRegion */
typedef void (* NP_LOADDS NPN_InvalidateRegionUPP)(NPP instance, NPRegion region);
#define NewNPN_InvalidateRegionProc(FUNC) \
((NPN_InvalidateRegionUPP) (FUNC))
#define CallNPN_InvalidateRegionProc(FUNC, ARG1, ARG2) \
(*(FUNC))((ARG1), (ARG2))
/* NPN_ForceRedraw */
typedef void (* NP_LOADDS NPN_ForceRedrawUPP)(NPP instance);
#define NewNPN_ForceRedrawProc(FUNC) \
((NPN_ForceRedrawUPP) (FUNC))
#define CallNPN_ForceRedrawProc(FUNC, ARG1) \
(*(FUNC))((ARG1))
/* NPN_GetStringIdentifier */
typedef NPIdentifier (* NP_LOADDS NPN_GetStringIdentifierUPP)(const NPUTF8* name);
#define NewNPN_GetStringIdentifierProc(FUNC) \
((NPN_GetStringIdentifierUPP) (FUNC))
#define CallNPN_GetStringIdentifierProc(FUNC, ARG1) \
(*(FUNC))((ARG1))
/* NPN_GetStringIdentifiers */
typedef void (* NP_LOADDS NPN_GetStringIdentifiersUPP)(const NPUTF8** names,
int32_t nameCount,
NPIdentifier* identifiers);
#define NewNPN_GetStringIdentifiersProc(FUNC) \
((NPN_GetStringIdentifiersUPP) (FUNC))
#define CallNPN_GetStringIdentifiersProc(FUNC, ARG1, ARG2, ARG3) \
(*(FUNC))((ARG1), (ARG2), (ARG3))
/* NPN_GetIntIdentifier */
typedef NPIdentifier (* NP_LOADDS NPN_GetIntIdentifierUPP)(int32_t intid);
#define NewNPN_GetIntIdentifierProc(FUNC) \
((NPN_GetIntIdentifierUPP) (FUNC))
#define CallNPN_GetIntIdentifierProc(FUNC, ARG1) \
(*(FUNC))((ARG1))
/* NPN_IdentifierIsString */
typedef bool (* NP_LOADDS NPN_IdentifierIsStringUPP)(NPIdentifier identifier);
#define NewNPN_IdentifierIsStringProc(FUNC) \
((NPN_IdentifierIsStringUPP) (FUNC))
#define CallNPN_IdentifierIsStringProc(FUNC, ARG1) \
(*(FUNC))((ARG1))
/* NPN_UTF8FromIdentifier */
typedef NPUTF8* (* NP_LOADDS NPN_UTF8FromIdentifierUPP)(NPIdentifier identifier);
#define NewNPN_UTF8FromIdentifierProc(FUNC) \
((NPN_UTF8FromIdentifierUPP) (FUNC))
#define CallNPN_UTF8FromIdentifierProc(FUNC, ARG1) \
(*(FUNC))((ARG1))
/* NPN_IntFromIdentifier */
typedef int32_t (* NP_LOADDS NPN_IntFromIdentifierUPP)(NPIdentifier identifier);
#define NewNPN_IntFromIdentifierProc(FUNC) \
((NPN_IntFromIdentifierUPP) (FUNC))
#define CallNPN_IntFromIdentifierProc(FUNC, ARG1) \
(*(FUNC))((ARG1))
/* NPN_CreateObject */
typedef NPObject* (* NP_LOADDS NPN_CreateObjectUPP)(NPP npp, NPClass *aClass);
#define NewNPN_CreateObjectProc(FUNC) \
((NPN_CreateObjectUPP) (FUNC))
#define CallNPN_CreateObjectProc(FUNC, ARG1, ARG2) \
(*(FUNC))((ARG1), (ARG2))
/* NPN_RetainObject */
typedef NPObject* (* NP_LOADDS NPN_RetainObjectUPP)(NPObject *obj);
#define NewNPN_RetainObjectProc(FUNC) \
((NPN_RetainObjectUPP) (FUNC))
#define CallNPN_RetainObjectProc(FUNC, ARG1) \
(*(FUNC))((ARG1))
/* NPN_ReleaseObject */
typedef void (* NP_LOADDS NPN_ReleaseObjectUPP)(NPObject *obj);
#define NewNPN_ReleaseObjectProc(FUNC) \
((NPN_ReleaseObjectUPP) (FUNC))
#define CallNPN_ReleaseObjectProc(FUNC, ARG1) \
(*(FUNC))((ARG1))
/* NPN_Invoke */
typedef bool (* NP_LOADDS NPN_InvokeUPP)(NPP npp, NPObject* obj, NPIdentifier methodName, const NPVariant *args, uint32_t argCount, NPVariant *result);
#define NewNPN_InvokeProc(FUNC) \
((NPN_InvokeUPP) (FUNC))
#define CallNPN_InvokeProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5, ARG6) \
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5), (ARG6))
/* NPN_InvokeDefault */
typedef bool (* NP_LOADDS NPN_InvokeDefaultUPP)(NPP npp, NPObject* obj, const NPVariant *args, uint32_t argCount, NPVariant *result);
#define NewNPN_InvokeDefaultProc(FUNC) \
((NPN_InvokeDefaultUPP) (FUNC))
#define CallNPN_InvokeDefaultProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5) \
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5))
/* NPN_Evaluate */
typedef bool (* NP_LOADDS NPN_EvaluateUPP)(NPP npp, NPObject *obj, NPString *script, NPVariant *result);
#define NewNPN_EvaluateProc(FUNC) \
((NPN_EvaluateUPP) (FUNC))
#define CallNPN_EvaluateProc(FUNC, ARG1, ARG2, ARG3, ARG4) \
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
/* NPN_GetProperty */
typedef bool (* NP_LOADDS NPN_GetPropertyUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName, NPVariant *result);
#define NewNPN_GetPropertyProc(FUNC) \
((NPN_GetPropertyUPP) (FUNC))
#define CallNPN_GetPropertyProc(FUNC, ARG1, ARG2, ARG3, ARG4) \
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
/* NPN_SetProperty */
typedef bool (* NP_LOADDS NPN_SetPropertyUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName, const NPVariant *value);
#define NewNPN_SetPropertyProc(FUNC) \
((NPN_SetPropertyUPP) (FUNC))
#define CallNPN_SetPropertyProc(FUNC, ARG1, ARG2, ARG3, ARG4) \
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
/* NPN_RemoveProperty */
typedef bool (* NP_LOADDS NPN_RemovePropertyUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName);
#define NewNPN_RemovePropertyProc(FUNC) \
((NPN_RemovePropertyUPP) (FUNC))
#define CallNPN_RemovePropertyProc(FUNC, ARG1, ARG2, ARG3) \
(*(FUNC))((ARG1), (ARG2), (ARG3))
/* NPN_HasProperty */
typedef bool (* NP_LOADDS NPN_HasPropertyUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName);
#define NewNPN_HasPropertyProc(FUNC) \
((NPN_HasPropertyUPP) (FUNC))
#define CallNPN_HasPropertyProc(FUNC, ARG1, ARG2, ARG3) \
(*(FUNC))((ARG1), (ARG2), (ARG3))
/* NPN_HasMethod */
typedef bool (* NP_LOADDS NPN_HasMethodUPP)(NPP npp, NPObject *obj, NPIdentifier propertyName);
#define NewNPN_HasMethodProc(FUNC) \
((NPN_HasMethodUPP) (FUNC))
#define CallNPN_HasMethodProc(FUNC, ARG1, ARG2, ARG3) \
(*(FUNC))((ARG1), (ARG2), (ARG3))
/* NPN_ReleaseVariantValue */
typedef void (* NP_LOADDS NPN_ReleaseVariantValueUPP)(NPVariant *variant);
#define NewNPN_ReleaseVariantValueProc(FUNC) \
((NPN_ReleaseVariantValueUPP) (FUNC))
#define CallNPN_ReleaseVariantValueProc(FUNC, ARG1) \
(*(FUNC))((ARG1))
/* NPN_SetException */
typedef void (* NP_LOADDS NPN_SetExceptionUPP)(NPObject *obj, const NPUTF8 *message);
#define NewNPN_SetExceptionProc(FUNC) \
((NPN_SetExceptionUPP) (FUNC))
#define CallNPN_SetExceptionProc(FUNC, ARG1, ARG2) \
(*(FUNC))((ARG1), (ARG2))
/* NPN_PushPopupsEnabledStateUPP */
typedef bool (* NP_LOADDS NPN_PushPopupsEnabledStateUPP)(NPP npp, NPBool enabled);
#define NewNPN_PushPopupsEnabledStateProc(FUNC) \
((NPN_PushPopupsEnabledStateUPP) (FUNC))
#define CallNPN_PushPopupsEnabledStateProc(FUNC, ARG1, ARG2) \
(*(FUNC))((ARG1), (ARG2))
/* NPN_PopPopupsEnabledState */
typedef bool (* NP_LOADDS NPN_PopPopupsEnabledStateUPP)(NPP npp);
#define NewNPN_PopPopupsEnabledStateProc(FUNC) \
((NPN_PopPopupsEnabledStateUPP) (FUNC))
#define CallNPN_PopPopupsEnabledStateProc(FUNC, ARG1) \
(*(FUNC))((ARG1))
/* NPN_Enumerate */
typedef bool (* NP_LOADDS NPN_EnumerateUPP)(NPP npp, NPObject *obj, NPIdentifier **identifier, uint32_t *count);
#define NewNPN_EnumerateProc(FUNC) \
((NPN_EnumerateUPP) (FUNC))
#define CallNPN_EnumerateProc(FUNC, ARG1, ARG2, ARG3, ARG4) \
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4))
/* NPN_PluginThreadAsyncCall */
typedef void (* NP_LOADDS NPN_PluginThreadAsyncCallUPP)(NPP instance, void (*func)(void *), void *userData);
#define NewNPN_PluginThreadAsyncCallProc(FUNC) \
((NPN_PluginThreadAsyncCallUPP) (FUNC))
#define CallNPN_PluginThreadAsyncCallProc(FUNC, ARG1, ARG2, ARG3) \
(*(FUNC))((ARG1), (ARG2), (ARG3))
/* NPN_Construct */
typedef bool (* NP_LOADDS NPN_ConstructUPP)(NPP npp, NPObject* obj, const NPVariant *args, uint32_t argCount, NPVariant *result);
#define NewNPN_ConstructProc(FUNC) \
((NPN_ConstructUPP) (FUNC))
#define CallNPN_ConstructProc(FUNC, ARG1, ARG2, ARG3, ARG4, ARG5) \
(*(FUNC))((ARG1), (ARG2), (ARG3), (ARG4), (ARG5))
/******************************************************************************************
* The actual plugin function table definitions
*******************************************************************************************/
typedef struct _NPPluginFuncs {
uint16 size;
uint16 version;
NPP_NewUPP newp;
NPP_DestroyUPP destroy;
NPP_SetWindowUPP setwindow;
NPP_NewStreamUPP newstream;
NPP_DestroyStreamUPP destroystream;
NPP_StreamAsFileUPP asfile;
NPP_WriteReadyUPP writeready;
NPP_WriteUPP write;
NPP_PrintUPP print;
NPP_HandleEventUPP event;
NPP_URLNotifyUPP urlnotify;
JRIGlobalRef javaClass;
NPP_GetValueUPP getvalue;
NPP_SetValueUPP setvalue;
} NPPluginFuncs;
typedef struct _NPNetscapeFuncs {
uint16 size;
uint16 version;
NPN_GetURLUPP geturl;
NPN_PostURLUPP posturl;
NPN_RequestReadUPP requestread;
NPN_NewStreamUPP newstream;
NPN_WriteUPP write;
NPN_DestroyStreamUPP destroystream;
NPN_StatusUPP status;
NPN_UserAgentUPP uagent;
NPN_MemAllocUPP memalloc;
NPN_MemFreeUPP memfree;
NPN_MemFlushUPP memflush;
NPN_ReloadPluginsUPP reloadplugins;
NPN_GetJavaEnvUPP getJavaEnv;
NPN_GetJavaPeerUPP getJavaPeer;
NPN_GetURLNotifyUPP geturlnotify;
NPN_PostURLNotifyUPP posturlnotify;
NPN_GetValueUPP getvalue;
NPN_SetValueUPP setvalue;
NPN_InvalidateRectUPP invalidaterect;
NPN_InvalidateRegionUPP invalidateregion;
NPN_ForceRedrawUPP forceredraw;
NPN_GetStringIdentifierUPP getstringidentifier;
NPN_GetStringIdentifiersUPP getstringidentifiers;
NPN_GetIntIdentifierUPP getintidentifier;
NPN_IdentifierIsStringUPP identifierisstring;
NPN_UTF8FromIdentifierUPP utf8fromidentifier;
NPN_IntFromIdentifierUPP intfromidentifier;
NPN_CreateObjectUPP createobject;
NPN_RetainObjectUPP retainobject;
NPN_ReleaseObjectUPP releaseobject;
NPN_InvokeUPP invoke;
NPN_InvokeDefaultUPP invokeDefault;
NPN_EvaluateUPP evaluate;
NPN_GetPropertyUPP getproperty;
NPN_SetPropertyUPP setproperty;
NPN_RemovePropertyUPP removeproperty;
NPN_HasPropertyUPP hasproperty;
NPN_HasMethodUPP hasmethod;
NPN_ReleaseVariantValueUPP releasevariantvalue;
NPN_SetExceptionUPP setexception;
NPN_PushPopupsEnabledStateUPP pushpopupsenabledstate;
NPN_PopPopupsEnabledStateUPP poppopupsenabledstate;
NPN_EnumerateUPP enumerate;
NPN_PluginThreadAsyncCallUPP pluginthreadasynccall;
NPN_ConstructUPP construct;
} NPNetscapeFuncs;
#ifdef XP_MACOSX
/******************************************************************************************
* Mac platform-specific plugin glue stuff
*******************************************************************************************/
/*
* Main entry point of the plugin.
* This routine will be called when the plugin is loaded. The function
* tables are passed in and the plugin fills in the NPPluginFuncs table
* and NPPShutdownUPP for Netscape's use.
*/
typedef NPError (* NP_LOADDS NPP_MainEntryUPP)(NPNetscapeFuncs*, NPPluginFuncs*, NPP_ShutdownUPP*);
#define NewNPP_MainEntryProc(FUNC) \
((NPP_MainEntryUPP) (FUNC))
#define CallNPP_MainEntryProc(FUNC, netscapeFunc, pluginFunc, shutdownUPP) \
(*(FUNC))((netscapeFunc), (pluginFunc), (shutdownUPP))
/*
* Mac OS X version(s) of NP_GetMIMEDescription(const char *)
* These can be called to retreive MIME information from the plugin dynamically
*
* Note: For compatibility with Quicktime, BPSupportedMIMEtypes is another way
* to get mime info from the plugin only on OSX and may not be supported
* in furture version -- use NP_GetMIMEDescription instead
*/
enum
{
kBPSupportedMIMETypesStructVers_1 = 1
};
typedef struct _BPSupportedMIMETypes
{
SInt32 structVersion; /* struct version */
Handle typeStrings; /* STR# formated handle, allocated by plug-in */
Handle infoStrings; /* STR# formated handle, allocated by plug-in */
} BPSupportedMIMETypes;
OSErr BP_GetSupportedMIMETypes(BPSupportedMIMETypes *mimeInfo, UInt32 flags);
/* NP_GetMIMEDescription */
#define NP_GETMIMEDESCRIPTION_NAME "NP_GetMIMEDescription"
typedef const char* (* NP_LOADDS NP_GetMIMEDescriptionUPP)();
#define NewNP_GetMIMEDescEntryProc(FUNC) \
((NP_GetMIMEDescriptionUPP) (FUNC))
#define CallNP_GetMIMEDescEntryProc(FUNC) \
(*(FUNC))()
/* BP_GetSupportedMIMETypes */
typedef OSErr (* NP_LOADDS BP_GetSupportedMIMETypesUPP)(BPSupportedMIMETypes*, UInt32);
#define NewBP_GetSupportedMIMETypesEntryProc(FUNC) \
((BP_GetSupportedMIMETypesUPP) (FUNC))
#define CallBP_GetMIMEDescEntryProc(FUNC, mimeInfo, flags) \
(*(FUNC))((mimeInfo), (flags))
#endif /* XP_MACOSX */
#if defined(_WINDOWS)
#define OSCALL WINAPI
#else
#if defined(__OS2__)
#define OSCALL _System
#else
#define OSCALL
#endif
#endif
#if defined(XP_UNIX)
/* GCC 3.3 and later support the visibility attribute. */
#if defined(__GNUC__) && \
((__GNUC__ >= 4) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))
#define NP_VISIBILITY_DEFAULT __attribute__((visibility("default")))
#else
#define NP_VISIBILITY_DEFAULT
#endif
#define NP_EXPORT(__type) NP_VISIBILITY_DEFAULT __type
#endif
#if defined( _WINDOWS ) || defined (__OS2__)
#ifdef __cplusplus
extern "C" {
#endif
/* plugin meta member functions */
#if defined(__OS2__)
typedef struct _NPPluginData { /* Alternate OS2 Plugin interface */
char *pMimeTypes;
char *pFileExtents;
char *pFileOpenTemplate;
char *pProductName;
char *pProductDescription;
unsigned long dwProductVersionMS;
unsigned long dwProductVersionLS;
} NPPluginData;
NPError OSCALL NP_GetPluginData(NPPluginData * pPluginData);
#endif
NPError OSCALL NP_GetEntryPoints(NPPluginFuncs* pFuncs);
NPError OSCALL NP_Initialize(NPNetscapeFuncs* pFuncs);
NPError OSCALL NP_Shutdown();
char* NP_GetMIMEDescription();
#ifdef __cplusplus
}
#endif
#endif /* _WINDOWS || __OS2__ */
#if defined(__OS2__)
#pragma pack()
#endif
#ifdef XP_UNIX
#ifdef __cplusplus
extern "C" {
#endif
/* plugin meta member functions */
NP_EXPORT(char*) NP_GetMIMEDescription(void);
NP_EXPORT(NPError) NP_Initialize(NPNetscapeFuncs*, NPPluginFuncs*);
NP_EXPORT(NPError) NP_Shutdown(void);
NP_EXPORT(NPError) NP_GetValue(void *future, NPPVariable aVariable, void *aValue);
#ifdef __cplusplus
}
#endif
#endif /* XP_UNIX */
#endif /* _NPUPP_H_ */

View file

@ -0,0 +1,252 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Netscape Portable Runtime (NSPR).
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998-2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
/*
* This header typedefs the old 'native' types to the new PR<type>s.
* These definitions are scheduled to be eliminated at the earliest
* possible time. The NSPR API is implemented and documented using
* the new definitions.
*/
#if !defined(PROTYPES_H)
#define PROTYPES_H
typedef PRUintn uintn;
#ifndef _XP_Core_
typedef PRIntn intn;
#endif
/*
* It is trickier to define uint, int8, uint8, int16, uint16,
* int32, uint32, int64, and uint64 because some of these int
* types are defined by standard header files on some platforms.
* Our strategy here is to include all such standard headers
* first, and then define these int types only if they are not
* defined by those standard headers.
*/
/*
* BeOS defines all the int types below in its standard header
* file SupportDefs.h.
*/
#ifdef XP_BEOS
#include <support/SupportDefs.h>
#endif
/*
* OpenVMS defines all the int types below in its standard
* header files ints.h and types.h.
*/
#ifdef VMS
#include <ints.h>
#include <types.h>
#endif
/*
* SVR4 typedef of uint is commonly found on UNIX machines.
*
* On AIX 4.3, sys/inttypes.h (which is included by sys/types.h)
* defines the types int8, int16, int32, and int64.
*/
#ifdef XP_UNIX
#include <sys/types.h>
#endif
/* model.h on HP-UX defines int8, int16, and int32. */
#ifdef HPUX
#include <model.h>
#endif
/*
* uint
*/
#if !defined(XP_BEOS) && !defined(VMS) \
&& !defined(XP_UNIX) || defined(NTO)
typedef PRUintn uint;
#endif
/*
* uint64
*/
#if !defined(XP_BEOS) && !defined(VMS)
typedef PRUint64 uint64;
#endif
/*
* uint32
*/
#if !defined(XP_BEOS) && !defined(VMS)
#if !defined(XP_MAC) && !defined(_WIN32) && !defined(XP_OS2) && !defined(NTO)
typedef PRUint32 uint32;
#else
typedef unsigned long uint32;
#endif
#endif
/*
* uint16
*/
#if !defined(XP_BEOS) && !defined(VMS)
typedef PRUint16 uint16;
#endif
/*
* uint8
*/
#if !defined(XP_BEOS) && !defined(VMS)
typedef PRUint8 uint8;
#endif
/*
* int64
*/
#if !defined(XP_BEOS) && !defined(VMS) \
&& !defined(_PR_AIX_HAVE_BSD_INT_TYPES)
typedef PRInt64 int64;
#endif
/*
* int32
*/
#if !defined(XP_BEOS) && !defined(VMS) \
&& !defined(_PR_AIX_HAVE_BSD_INT_TYPES) \
&& !defined(HPUX)
#if !defined(XP_MAC) && !defined(_WIN32) && !defined(XP_OS2) && !defined(NTO)
typedef PRInt32 int32;
#else
typedef long int32;
#endif
#endif
/*
* int16
*/
#if !defined(XP_BEOS) && !defined(VMS) \
&& !defined(_PR_AIX_HAVE_BSD_INT_TYPES) \
&& !defined(HPUX)
typedef PRInt16 int16;
#endif
/*
* int8
*/
#if !defined(XP_BEOS) && !defined(VMS) \
&& !defined(_PR_AIX_HAVE_BSD_INT_TYPES) \
&& !defined(HPUX)
typedef PRInt8 int8;
#endif
typedef PRFloat64 float64;
typedef PRUptrdiff uptrdiff_t;
typedef PRUword uprword_t;
typedef PRWord prword_t;
/* Re: prbit.h */
#define TEST_BIT PR_TEST_BIT
#define SET_BIT PR_SET_BIT
#define CLEAR_BIT PR_CLEAR_BIT
/* Re: prarena.h->plarena.h */
#define PRArena PLArena
#define PRArenaPool PLArenaPool
#define PRArenaStats PLArenaStats
#define PR_ARENA_ALIGN PL_ARENA_ALIGN
#define PR_INIT_ARENA_POOL PL_INIT_ARENA_POOL
#define PR_ARENA_ALLOCATE PL_ARENA_ALLOCATE
#define PR_ARENA_GROW PL_ARENA_GROW
#define PR_ARENA_MARK PL_ARENA_MARK
#define PR_CLEAR_UNUSED PL_CLEAR_UNUSED
#define PR_CLEAR_ARENA PL_CLEAR_ARENA
#define PR_ARENA_RELEASE PL_ARENA_RELEASE
#define PR_COUNT_ARENA PL_COUNT_ARENA
#define PR_ARENA_DESTROY PL_ARENA_DESTROY
#define PR_InitArenaPool PL_InitArenaPool
#define PR_FreeArenaPool PL_FreeArenaPool
#define PR_FinishArenaPool PL_FinishArenaPool
#define PR_CompactArenaPool PL_CompactArenaPool
#define PR_ArenaFinish PL_ArenaFinish
#define PR_ArenaAllocate PL_ArenaAllocate
#define PR_ArenaGrow PL_ArenaGrow
#define PR_ArenaRelease PL_ArenaRelease
#define PR_ArenaCountAllocation PL_ArenaCountAllocation
#define PR_ArenaCountInplaceGrowth PL_ArenaCountInplaceGrowth
#define PR_ArenaCountGrowth PL_ArenaCountGrowth
#define PR_ArenaCountRelease PL_ArenaCountRelease
#define PR_ArenaCountRetract PL_ArenaCountRetract
/* Re: prhash.h->plhash.h */
#define PRHashEntry PLHashEntry
#define PRHashTable PLHashTable
#define PRHashNumber PLHashNumber
#define PRHashFunction PLHashFunction
#define PRHashComparator PLHashComparator
#define PRHashEnumerator PLHashEnumerator
#define PRHashAllocOps PLHashAllocOps
#define PR_NewHashTable PL_NewHashTable
#define PR_HashTableDestroy PL_HashTableDestroy
#define PR_HashTableRawLookup PL_HashTableRawLookup
#define PR_HashTableRawAdd PL_HashTableRawAdd
#define PR_HashTableRawRemove PL_HashTableRawRemove
#define PR_HashTableAdd PL_HashTableAdd
#define PR_HashTableRemove PL_HashTableRemove
#define PR_HashTableEnumerateEntries PL_HashTableEnumerateEntries
#define PR_HashTableLookup PL_HashTableLookup
#define PR_HashTableDump PL_HashTableDump
#define PR_HashString PL_HashString
#define PR_CompareStrings PL_CompareStrings
#define PR_CompareValues PL_CompareValues
#if defined(XP_MAC)
#ifndef TRUE /* Mac standard is lower case true */
#define TRUE 1
#endif
#ifndef FALSE /* Mac standard is lower case false */
#define FALSE 0
#endif
#endif
#endif /* !defined(PROTYPES_H) */

View file

@ -0,0 +1,300 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is the Netscape Portable Runtime (NSPR).
*
* The Initial Developer of the Original Code is
* Netscape Communications Corporation.
* Portions created by the Initial Developer are Copyright (C) 1998-2000
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nspr_cpucfg___
#define nspr_cpucfg___
#ifndef XP_PC
#define XP_PC
#endif
#ifndef WIN32
#define WIN32
#endif
#ifndef WIN95
#define WIN95
#endif
#define PR_AF_INET6 23 /* same as AF_INET6 */
#if defined(_M_IX86) || defined(_X86_)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_DOUBLE 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_DWORD 64
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_WORD_LOG2 5
#define PR_BITS_PER_DWORD_LOG2 6
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_WORD 4
#define PR_ALIGN_OF_DWORD 8
#define PR_ALIGN_OF_DOUBLE 4
#define PR_ALIGN_OF_POINTER 4
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 2
#elif defined(_ALPHA_)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_DOUBLE 8
#define PR_BYTES_PER_WORD 4
#define PR_BYTES_PER_DWORD 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_WORD 32
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_BITS_PER_WORD_LOG2 5
#define PR_BYTES_PER_WORD_LOG2 2
#define PR_BYTES_PER_DWORD_LOG2 3
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 4
#elif defined(_AMD64_)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_DOUBLE 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_DWORD 64
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_WORD_LOG2 6
#define PR_BITS_PER_DWORD_LOG2 6
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_WORD 8
#define PR_ALIGN_OF_DWORD 8
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#elif defined(_IA64_)
#define IS_LITTLE_ENDIAN 1
#undef IS_BIG_ENDIAN
#define IS_64
#define PR_BYTES_PER_BYTE 1
#define PR_BYTES_PER_SHORT 2
#define PR_BYTES_PER_INT 4
#define PR_BYTES_PER_INT64 8
#define PR_BYTES_PER_LONG 4
#define PR_BYTES_PER_FLOAT 4
#define PR_BYTES_PER_WORD 8
#define PR_BYTES_PER_DWORD 8
#define PR_BYTES_PER_DOUBLE 8
#define PR_BITS_PER_BYTE 8
#define PR_BITS_PER_SHORT 16
#define PR_BITS_PER_INT 32
#define PR_BITS_PER_INT64 64
#define PR_BITS_PER_LONG 32
#define PR_BITS_PER_FLOAT 32
#define PR_BITS_PER_WORD 64
#define PR_BITS_PER_DWORD 64
#define PR_BITS_PER_DOUBLE 64
#define PR_BITS_PER_BYTE_LOG2 3
#define PR_BITS_PER_SHORT_LOG2 4
#define PR_BITS_PER_INT_LOG2 5
#define PR_BITS_PER_INT64_LOG2 6
#define PR_BITS_PER_LONG_LOG2 5
#define PR_BITS_PER_FLOAT_LOG2 5
#define PR_BITS_PER_WORD_LOG2 6
#define PR_BITS_PER_DWORD_LOG2 6
#define PR_BITS_PER_DOUBLE_LOG2 6
#define PR_ALIGN_OF_SHORT 2
#define PR_ALIGN_OF_INT 4
#define PR_ALIGN_OF_LONG 4
#define PR_ALIGN_OF_INT64 8
#define PR_ALIGN_OF_FLOAT 4
#define PR_ALIGN_OF_WORD 8
#define PR_ALIGN_OF_DWORD 8
#define PR_ALIGN_OF_DOUBLE 8
#define PR_ALIGN_OF_POINTER 8
#define PR_BYTES_PER_WORD_LOG2 3
#define PR_BYTES_PER_DWORD_LOG2 3
#else /* defined(_M_IX86) || defined(_X86_) */
#error unknown processor architecture
#endif /* defined(_M_IX86) || defined(_X86_) */
#ifndef HAVE_LONG_LONG
#define HAVE_LONG_LONG
#endif
#ifndef NO_NSPR_10_SUPPORT
#define BYTES_PER_BYTE PR_BYTES_PER_BYTE
#define BYTES_PER_SHORT PR_BYTES_PER_SHORT
#define BYTES_PER_INT PR_BYTES_PER_INT
#define BYTES_PER_INT64 PR_BYTES_PER_INT64
#define BYTES_PER_LONG PR_BYTES_PER_LONG
#define BYTES_PER_FLOAT PR_BYTES_PER_FLOAT
#define BYTES_PER_DOUBLE PR_BYTES_PER_DOUBLE
#define BYTES_PER_WORD PR_BYTES_PER_WORD
#define BYTES_PER_DWORD PR_BYTES_PER_DWORD
#define BITS_PER_BYTE PR_BITS_PER_BYTE
#define BITS_PER_SHORT PR_BITS_PER_SHORT
#define BITS_PER_INT PR_BITS_PER_INT
#define BITS_PER_INT64 PR_BITS_PER_INT64
#define BITS_PER_LONG PR_BITS_PER_LONG
#define BITS_PER_FLOAT PR_BITS_PER_FLOAT
#define BITS_PER_DOUBLE PR_BITS_PER_DOUBLE
#define BITS_PER_WORD PR_BITS_PER_WORD
#define BITS_PER_BYTE_LOG2 PR_BITS_PER_BYTE_LOG2
#define BITS_PER_SHORT_LOG2 PR_BITS_PER_SHORT_LOG2
#define BITS_PER_INT_LOG2 PR_BITS_PER_INT_LOG2
#define BITS_PER_INT64_LOG2 PR_BITS_PER_INT64_LOG2
#define BITS_PER_LONG_LOG2 PR_BITS_PER_LONG_LOG2
#define BITS_PER_FLOAT_LOG2 PR_BITS_PER_FLOAT_LOG2
#define BITS_PER_DOUBLE_LOG2 PR_BITS_PER_DOUBLE_LOG2
#define BITS_PER_WORD_LOG2 PR_BITS_PER_WORD_LOG2
#define ALIGN_OF_SHORT PR_ALIGN_OF_SHORT
#define ALIGN_OF_INT PR_ALIGN_OF_INT
#define ALIGN_OF_LONG PR_ALIGN_OF_LONG
#define ALIGN_OF_INT64 PR_ALIGN_OF_INT64
#define ALIGN_OF_FLOAT PR_ALIGN_OF_FLOAT
#define ALIGN_OF_DOUBLE PR_ALIGN_OF_DOUBLE
#define ALIGN_OF_POINTER PR_ALIGN_OF_POINTER
#define ALIGN_OF_WORD PR_ALIGN_OF_WORD
#define BYTES_PER_WORD_LOG2 PR_BYTES_PER_WORD_LOG2
#define BYTES_PER_DWORD_LOG2 PR_BYTES_PER_DWORD_LOG2
#define WORDS_PER_DWORD_LOG2 PR_WORDS_PER_DWORD_LOG2
#endif /* NO_NSPR_10_SUPPORT */
#endif /* nspr_cpucfg___ */

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