Changes merged from trunk. Also additional extensive changes. Q3 portals work.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/branches/wip@3541 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2010-07-11 02:22:39 +00:00
commit 1e1084bed7
113 changed files with 83312 additions and 4323 deletions

View file

@ -106,7 +106,7 @@ qboolean Cam_DrawViewModel(int pnum)
} }
else else
{ {
if (selfcam == 1 && r_secondaryview != 3) if (selfcam == 1 && !r_refdef.externalview)
return true; return true;
return false; return false;
} }
@ -125,7 +125,7 @@ qboolean Cam_DrawPlayer(int pnum, int playernum)
} }
else else
{ {
if (selfcam == 1 && r_secondaryview != 3) if (selfcam == 1 && !r_refdef.externalview)
if (playernum == (cl.viewentity[pnum]?cl.viewentity[pnum]-1:(cl.playernum[pnum]))) if (playernum == (cl.viewentity[pnum]?cl.viewentity[pnum]-1:(cl.playernum[pnum])))
return false; return false;
} }

View file

@ -453,7 +453,7 @@ int VM_LerpTag(void *out, model_t *model, int f1, int f2, float l2, char *tagnam
#define VALIDATEPOINTER(o,l) if ((int)o + l >= mask || VM_POINTER(o) < offset) Host_EndGame("Call to cgame 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 cgame trap %i passes invalid pointer\n", fn); //out of bounds.
static int CG_SystemCallsEx(void *offset, unsigned int mask, int fn, const int *arg) static qintptr_t CG_SystemCallsEx(void *offset, quintptr_t mask, qintptr_t fn, const qintptr_t *arg)
{ {
int ret=0; int ret=0;
@ -1048,7 +1048,7 @@ static int CG_SystemCallsEx(void *offset, unsigned int mask, int fn, const int *
return ret; return ret;
} }
#ifdef _DEBUG #ifdef _DEBUG
static int CG_SystemCallsExWrapper(void *offset, unsigned int mask, int fn, const int *arg) static qintptr_t CG_SystemCallsExWrapper(void *offset, quintptr_t mask, qintptr_t fn, const qintptr_t *arg)
{ //this is so we can use edit and continue properly (vc doesn't like function pointers for edit+continue) { //this is so we can use edit and continue properly (vc doesn't like function pointers for edit+continue)
return CG_SystemCallsEx(offset, mask, fn, arg); return CG_SystemCallsEx(offset, mask, fn, arg);
} }

View file

@ -1171,7 +1171,7 @@ void CL_Record_f (void)
for (i = 0; i < cl.num_statics; i++) for (i = 0; i < cl.num_statics; i++)
{ {
ent = cl_static_entities + i; ent = &cl_static_entities[i].ent;
MSG_WriteByte (&buf, svc_spawnstatic); MSG_WriteByte (&buf, svc_spawnstatic);

View file

@ -1434,6 +1434,50 @@ static void CL_UpdateNetFrameLerpState(qboolean force, unsigned int curframe, le
} }
} }
void CL_LinkStaticEntities(void *pvs)
{
int i;
entity_t *ent, *stat;
model_t *clmodel;
extern cvar_t r_drawflame, gl_part_flame;
// if (!cl_staticentities.ival)
// return;
if (!cl.worldmodel)
return;
for (i = 0; i < cl.num_statics; i++)
{
if (cl_numvisedicts == MAX_VISEDICTS)
break;
stat = &cl_static_entities[i].ent;
clmodel = stat->model;
if ((!r_drawflame.ival) && (clmodel->engineflags & MDLF_FLAME))
continue;
if (!cl.worldmodel->funcs.EdictInFatPVS(cl.worldmodel, &cl_static_entities[i].pvscache, pvs))
continue;
/*pvs test*/
ent = &cl_visedicts[cl_numvisedicts++];
*ent = *stat;
ent->framestate.g[FS_REG].frametime[0] = cl.time;
ent->framestate.g[FS_REG].frametime[1] = cl.time;
// emit particles for statics (we don't need to cheat check statics)
if (clmodel->particleeffect >= 0 && gl_part_flame.ival)
{
// TODO: this is ugly.. assumes ent is in static entities, and subtracts
// pointer math to get an index to use in cl_static emit
// there needs to be a cleaner method for this
P_EmitEffect(ent->origin, clmodel->particleeffect, &cl_static_entities[i].emit);
}
}
}
/* /*
=============== ===============
CL_LinkPacketEntities CL_LinkPacketEntities
@ -1669,9 +1713,11 @@ qboolean CL_MayLerp(void)
return true; return true;
if (cls.protocol == CP_NETQUAKE) //this includes DP protocols. if (cls.protocol == CP_NETQUAKE) //this includes DP protocols.
return !cl_nolerp_netquake.value; return !cl_nolerp_netquake.ival;
#endif #endif
return !cl_nolerp.value; if (cl_nolerp.ival == 2 && cls.gamemode != GAME_DEATHMATCH)
return true;
return !cl_nolerp.ival;
} }
void CL_LinkPacketEntities (void) void CL_LinkPacketEntities (void)

View file

@ -29,19 +29,19 @@ float in_sensitivityscale = 1;
void CL_SpareMsec_Callback (struct cvar_s *var, char *oldvalue); void CL_SpareMsec_Callback (struct cvar_s *var, char *oldvalue);
cvar_t cl_nodelta = SCVAR("cl_nodelta","0"); cvar_t cl_nodelta = CVAR("cl_nodelta","0");
cvar_t cl_c2spps = SCVAR("cl_c2spps", "0"); cvar_t cl_c2spps = CVAR("cl_c2spps", "0");
cvar_t cl_c2sImpulseBackup = SCVAR("cl_c2sImpulseBackup","3"); cvar_t cl_c2sImpulseBackup = SCVAR("cl_c2sImpulseBackup","3");
cvar_t cl_netfps = SCVAR("cl_netfps", "0"); cvar_t cl_netfps = CVAR("cl_netfps", "0");
cvar_t cl_sparemsec = SCVARC("cl_sparemsec", "10", CL_SpareMsec_Callback); cvar_t cl_sparemsec = CVARC("cl_sparemsec", "10", CL_SpareMsec_Callback);
cvar_t cl_queueimpulses = SCVAR("cl_queueimpulses", "0"); cvar_t cl_queueimpulses = CVAR("cl_queueimpulses", "0");
cvar_t cl_smartjump = SCVAR("cl_smartjump", "1"); cvar_t cl_smartjump = CVAR("cl_smartjump", "1");
cvar_t cl_prydoncursor = SCVAR("cl_prydoncursor", ""); //for dp protocol cvar_t cl_prydoncursor = CVAR("cl_prydoncursor", ""); //for dp protocol
cvar_t cl_instantrotate = SCVARF("cl_instantrotate", "1", CVAR_SEMICHEAT); cvar_t cl_instantrotate = CVARF("cl_instantrotate", "1", CVAR_SEMICHEAT);
cvar_t prox_inmenu = SCVAR("prox_inmenu", "0"); cvar_t prox_inmenu = CVAR("prox_inmenu", "0");
usercmd_t independantphysics[MAX_SPLITS]; usercmd_t independantphysics[MAX_SPLITS];
vec3_t mousemovements[MAX_SPLITS]; vec3_t mousemovements[MAX_SPLITS];

View file

@ -45,52 +45,52 @@ cvar_t cl_timeout = SCVAR("cl_timeout", "60");
cvar_t cl_shownet = SCVAR("cl_shownet","0"); // can be 0, 1, or 2 cvar_t cl_shownet = SCVAR("cl_shownet","0"); // can be 0, 1, or 2
cvar_t cl_sbar = SCVARFC("cl_sbar", "0", CVAR_ARCHIVE, CL_Sbar_Callback); cvar_t cl_sbar = CVARFC("cl_sbar", "0", CVAR_ARCHIVE, CL_Sbar_Callback);
cvar_t cl_hudswap = SCVARF("cl_hudswap", "0", CVAR_ARCHIVE); cvar_t cl_hudswap = CVARF("cl_hudswap", "0", CVAR_ARCHIVE);
cvar_t cl_maxfps = SCVARF("cl_maxfps", "1000", CVAR_ARCHIVE); cvar_t cl_maxfps = CVARF("cl_maxfps", "1000", CVAR_ARCHIVE);
cvar_t cl_nopext = SCVARF("cl_nopext", "0", CVAR_ARCHIVE); cvar_t cl_nopext = CVARF("cl_nopext", "0", CVAR_ARCHIVE);
cvar_t cl_pext_mask = SCVAR("cl_pext_mask", "0xffffffff"); cvar_t cl_pext_mask = CVAR("cl_pext_mask", "0xffffffff");
cvar_t cl_nolerp = SCVAR("cl_nolerp", "1"); cvar_t cl_nolerp = CVAR("cl_nolerp", "2");
cvar_t cl_nolerp_netquake = SCVAR("cl_nolerp_netquake", "0"); cvar_t cl_nolerp_netquake = CVAR("cl_nolerp_netquake", "0");
cvar_t hud_tracking_show = SCVAR("hud_tracking_show", "1"); cvar_t hud_tracking_show = CVAR("hud_tracking_show", "1");
cvar_t cfg_save_name = SCVARF("cfg_save_name", "fte", CVAR_ARCHIVE); cvar_t cfg_save_name = CVARF("cfg_save_name", "fte", CVAR_ARCHIVE);
cvar_t cl_splitscreen = SCVAR("cl_splitscreen", "0"); cvar_t cl_splitscreen = CVAR("cl_splitscreen", "0");
cvar_t lookspring = SCVARF("lookspring","0", CVAR_ARCHIVE); cvar_t lookspring = CVARF("lookspring","0", CVAR_ARCHIVE);
cvar_t lookstrafe = SCVARF("lookstrafe","0", CVAR_ARCHIVE); cvar_t lookstrafe = CVARF("lookstrafe","0", CVAR_ARCHIVE);
cvar_t sensitivity = SCVARF("sensitivity","10", CVAR_ARCHIVE); cvar_t sensitivity = CVARF("sensitivity","10", CVAR_ARCHIVE);
cvar_t cl_staticsounds = SCVAR("cl_staticsounds", "1"); cvar_t cl_staticsounds = CVAR("cl_staticsounds", "1");
cvar_t m_pitch = SCVARF("m_pitch","0.022", CVAR_ARCHIVE); cvar_t m_pitch = CVARF("m_pitch","0.022", CVAR_ARCHIVE);
cvar_t m_yaw = SCVARF("m_yaw","0.022", CVAR_ARCHIVE); cvar_t m_yaw = CVARF("m_yaw","0.022", CVAR_ARCHIVE);
cvar_t m_forward = SCVARF("m_forward","1", CVAR_ARCHIVE); cvar_t m_forward = CVARF("m_forward","1", CVAR_ARCHIVE);
cvar_t m_side = SCVARF("m_side","0.8", CVAR_ARCHIVE); cvar_t m_side = CVARF("m_side","0.8", CVAR_ARCHIVE);
cvar_t entlatency = SCVAR("entlatency", "20"); cvar_t entlatency = CVAR("entlatency", "20");
cvar_t cl_predict_players = SCVAR("cl_predict_players", "1"); cvar_t cl_predict_players = CVAR("cl_predict_players", "1");
cvar_t cl_predict_players2 = SCVAR("cl_predict_players2", "1"); cvar_t cl_predict_players2 = CVAR("cl_predict_players2", "1");
cvar_t cl_solid_players = SCVAR("cl_solid_players", "1"); cvar_t cl_solid_players = CVAR("cl_solid_players", "1");
cvar_t cl_noblink = SCVAR("cl_noblink", "0"); cvar_t cl_noblink = CVAR("cl_noblink", "0");
cvar_t cl_servername = SCVAR("cl_servername", "none"); cvar_t cl_servername = CVAR("cl_servername", "none");
cvar_t cl_serveraddress = SCVAR("cl_serveraddress", "none"); cvar_t cl_serveraddress = CVAR("cl_serveraddress", "none");
cvar_t qtvcl_forceversion1 = SCVAR("qtvcl_forceversion1", "0"); cvar_t qtvcl_forceversion1 = CVAR("qtvcl_forceversion1", "0");
cvar_t qtvcl_eztvextensions = SCVAR("qtvcl_eztvextensions", "0"); cvar_t qtvcl_eztvextensions = CVAR("qtvcl_eztvextensions", "0");
cvar_t cl_demospeed = FCVAR("cl_demospeed", "demo_setspeed", "1", 0); cvar_t cl_demospeed = CVARAF("cl_demospeed", "1", "demo_setspeed", 0);
cvar_t cl_loopbackprotocol = SCVAR("cl_loopbackprotocol", "qw"); cvar_t cl_loopbackprotocol = CVAR("cl_loopbackprotocol", "qw");
cvar_t cl_indepphysics = SCVAR("cl_indepphysics", "0"); cvar_t cl_indepphysics = CVAR("cl_indepphysics", "0");
cvar_t localid = SCVAR("localid", ""); cvar_t localid = SCVAR("localid", "");
cvar_t cl_antibunch = SCVAR("cl_antibunch", "0"); cvar_t cl_antibunch = CVAR("cl_antibunch", "0");
cvar_t r_drawflame = SCVAR("r_drawflame", "1"); cvar_t r_drawflame = CVAR("r_drawflame", "1");
static qboolean allowremotecmd = true; static qboolean allowremotecmd = true;
@ -99,33 +99,33 @@ extern int total_loading_size, current_loading_size, loading_stage;
// //
// info mirrors // info mirrors
// //
cvar_t password = SCVARF("password", "", CVAR_USERINFO | CVAR_NOUNSAFEEXPAND); //this is parhaps slightly dodgy... cvar_t password = CVARF("password", "", CVAR_USERINFO | CVAR_NOUNSAFEEXPAND); //this is parhaps slightly dodgy...
cvar_t spectator = SCVARF("spectator", "", CVAR_USERINFO); cvar_t spectator = CVARF("spectator", "", CVAR_USERINFO);
cvar_t name = SCVARFC("name", "unnamed", CVAR_ARCHIVE | CVAR_USERINFO, Name_Callback); cvar_t name = CVARFC("name", "unnamed", CVAR_ARCHIVE | CVAR_USERINFO, Name_Callback);
cvar_t team = SCVARF("team", "", CVAR_ARCHIVE | CVAR_USERINFO); cvar_t team = CVARF("team", "", CVAR_ARCHIVE | CVAR_USERINFO);
cvar_t skin = SCVARF("skin", "", CVAR_ARCHIVE | CVAR_USERINFO); cvar_t skin = CVARF("skin", "", CVAR_ARCHIVE | CVAR_USERINFO);
cvar_t model = SCVARF("model", "", CVAR_ARCHIVE | CVAR_USERINFO); cvar_t model = CVARF("model", "", CVAR_ARCHIVE | CVAR_USERINFO);
cvar_t topcolor = SCVARF("topcolor", "", CVAR_ARCHIVE | CVAR_USERINFO); cvar_t topcolor = CVARF("topcolor", "", CVAR_ARCHIVE | CVAR_USERINFO);
cvar_t bottomcolor = SCVARF("bottomcolor", "", CVAR_ARCHIVE | CVAR_USERINFO); cvar_t bottomcolor = CVARF("bottomcolor", "", CVAR_ARCHIVE | CVAR_USERINFO);
cvar_t rate = SCVARF("rate", "10000"/*"6480"*/, CVAR_ARCHIVE | CVAR_USERINFO); cvar_t rate = CVARF("rate", "10000"/*"6480"*/, CVAR_ARCHIVE | CVAR_USERINFO);
cvar_t drate = SCVARF("drate", "100000", CVAR_ARCHIVE | CVAR_USERINFO); // :) cvar_t drate = CVARF("drate", "100000", CVAR_ARCHIVE | CVAR_USERINFO); // :)
cvar_t noaim = SCVARF("noaim", "", CVAR_ARCHIVE | CVAR_USERINFO); cvar_t noaim = CVARF("noaim", "", CVAR_ARCHIVE | CVAR_USERINFO);
cvar_t msg = SCVARF("msg", "1", CVAR_ARCHIVE | CVAR_USERINFO); cvar_t msg = CVARF("msg", "1", CVAR_ARCHIVE | CVAR_USERINFO);
cvar_t b_switch = SCVARF("b_switch", "", CVAR_ARCHIVE | CVAR_USERINFO); cvar_t b_switch = CVARF("b_switch", "", CVAR_ARCHIVE | CVAR_USERINFO);
cvar_t w_switch = SCVARF("w_switch", "", CVAR_ARCHIVE | CVAR_USERINFO); cvar_t w_switch = CVARF("w_switch", "", CVAR_ARCHIVE | CVAR_USERINFO);
cvar_t cl_nofake = SCVAR("cl_nofake", "2"); cvar_t cl_nofake = CVAR("cl_nofake", "2");
cvar_t cl_chatsound = SCVAR("cl_chatsound","1"); cvar_t cl_chatsound = CVAR("cl_chatsound","1");
cvar_t cl_enemychatsound = SCVAR("cl_enemychatsound", "misc/talk.wav"); cvar_t cl_enemychatsound = CVAR("cl_enemychatsound", "misc/talk.wav");
cvar_t cl_teamchatsound = SCVAR("cl_teamchatsound", "misc/talk.wav"); cvar_t cl_teamchatsound = CVAR("cl_teamchatsound", "misc/talk.wav");
cvar_t r_torch = SCVARF("r_torch", "0", CVAR_CHEAT); cvar_t r_torch = CVARF("r_torch", "0", CVAR_CHEAT);
cvar_t r_rocketlight = SCVARC("r_rocketlight", "1", Cvar_Limiter_ZeroToOne_Callback); cvar_t r_rocketlight = CVARC("r_rocketlight", "1", Cvar_Limiter_ZeroToOne_Callback);
cvar_t r_lightflicker = SCVAR("r_lightflicker", "1"); cvar_t r_lightflicker = CVAR("r_lightflicker", "1");
cvar_t cl_r2g = SCVAR("cl_r2g", "0"); cvar_t cl_r2g = CVAR("cl_r2g", "0");
cvar_t r_powerupglow = SCVAR("r_powerupglow", "1"); cvar_t r_powerupglow = CVAR("r_powerupglow", "1");
cvar_t v_powerupshell = SCVAR("v_powerupshell", "0"); cvar_t v_powerupshell = CVAR("v_powerupshell", "0");
cvar_t cl_gibfilter = SCVAR("cl_gibfilter", "0"); cvar_t cl_gibfilter = CVAR("cl_gibfilter", "0");
cvar_t cl_deadbodyfilter = SCVAR("cl_deadbodyfilter", "0"); cvar_t cl_deadbodyfilter = CVAR("cl_deadbodyfilter", "0");
cvar_t cl_gunx = SCVAR("cl_gunx", "0"); cvar_t cl_gunx = SCVAR("cl_gunx", "0");
cvar_t cl_guny = SCVAR("cl_guny", "0"); cvar_t cl_guny = SCVAR("cl_guny", "0");
@ -153,7 +153,8 @@ cvar_t cl_parsewhitetext = SCVAR("cl_parsewhitetext", "1");
cvar_t cl_dlemptyterminate = SCVAR("cl_dlemptyterminate", "1"); cvar_t cl_dlemptyterminate = SCVAR("cl_dlemptyterminate", "1");
cvar_t host_mapname = FCVAR("mapname", "host_mapname", "", 0); cvar_t host_mapname = CVARAF("mapname", "",
"host_mapname", 0);
cvar_t ruleset_allow_playercount = SCVAR("ruleset_allow_playercount", "1"); cvar_t ruleset_allow_playercount = SCVAR("ruleset_allow_playercount", "1");
cvar_t ruleset_allow_frj = SCVAR("ruleset_allow_frj", "1"); cvar_t ruleset_allow_frj = SCVAR("ruleset_allow_frj", "1");
@ -165,7 +166,7 @@ cvar_t ruleset_allow_larger_models = SCVAR("ruleset_allow_larger_models", "1");
cvar_t ruleset_allow_modified_eyes = SCVAR("ruleset_allow_modified_eyes", "0"); cvar_t ruleset_allow_modified_eyes = SCVAR("ruleset_allow_modified_eyes", "0");
cvar_t ruleset_allow_sensative_texture_replacements = SCVAR("ruleset_allow_sensative_texture_replacements", "1"); cvar_t ruleset_allow_sensative_texture_replacements = SCVAR("ruleset_allow_sensative_texture_replacements", "1");
cvar_t ruleset_allow_localvolume = SCVAR("ruleset_allow_localvolume", "1"); cvar_t ruleset_allow_localvolume = SCVAR("ruleset_allow_localvolume", "1");
cvar_t ruleset_allow_shaders = SCVAR("ruleset_allow_shaders", "1"); cvar_t ruleset_allow_shaders = SCVARF("ruleset_allow_shaders", "1", CVAR_SHADERSYSTEM);
extern cvar_t cl_hightrack; extern cvar_t cl_hightrack;
extern cvar_t vid_renderer; extern cvar_t vid_renderer;
@ -181,9 +182,7 @@ client_state_t cl;
// alot of this should probably be dynamically allocated // alot of this should probably be dynamically allocated
entity_state_t *cl_baselines; entity_state_t *cl_baselines;
efrag_t cl_efrags[MAX_EFRAGS]; static_entity_t cl_static_entities[MAX_STATIC_ENTITIES];
entity_t cl_static_entities[MAX_STATIC_ENTITIES];
trailstate_t *cl_static_emit[MAX_STATIC_ENTITIES];
lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES]; lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
//lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES]; //lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
dlight_t *cl_dlights; dlight_t *cl_dlights;
@ -1053,7 +1052,6 @@ void CL_ClearState (void)
r_worldentity.model = NULL; r_worldentity.model = NULL;
// clear other arrays // clear other arrays
memset (cl_efrags, 0, sizeof(cl_efrags));
// memset (cl_dlights, 0, sizeof(cl_dlights)); // memset (cl_dlights, 0, sizeof(cl_dlights));
memset (cl_lightstyle, 0, sizeof(cl_lightstyle)); memset (cl_lightstyle, 0, sizeof(cl_lightstyle));
@ -1066,14 +1064,6 @@ void CL_ClearState (void)
} }
cl_baselines_count = 0; cl_baselines_count = 0;
//
// allocate the efrags and chain together into a free list
//
cl.free_efrags = cl_efrags;
for (i=0 ; i<MAX_EFRAGS-1 ; i++)
cl.free_efrags[i].entnext = &cl.free_efrags[i+1];
cl.free_efrags[i].entnext = NULL;
for (i = 0; i < MAX_SPLITS; i++) for (i = 0; i < MAX_SPLITS; i++)
cl.viewheight[i] = DEFAULT_VIEWHEIGHT; cl.viewheight[i] = DEFAULT_VIEWHEIGHT;
cl.minpitch = -70; cl.minpitch = -70;
@ -1758,7 +1748,7 @@ void CL_Packet_f (void)
if (!NET_StringToAdr (Cmd_Argv(1), &adr)) if (!NET_StringToAdr (Cmd_Argv(1), &adr))
{ {
Con_TPrintf (TLC_BADADDRESS); Con_Printf ("Bad address: %s\n", Cmd_Argv(1));
return; return;
} }
@ -1801,6 +1791,26 @@ void CL_Packet_f (void)
*out++ = '\n'; *out++ = '\n';
i++; i++;
} }
else if (in[i] == '\\' && in[i+1] == '\\')
{
*out++ = '\\';
i++;
}
else if (in[i] == '\\' && in[i+1] == 'r')
{
*out++ = '\r';
i++;
}
else if (in[i] == '\\' && in[i+1] == '\"')
{
*out++ = '\"';
i++;
}
else if (in[i] == '\\' && in[i+1] == '0')
{
*out++ = '\0';
i++;
}
else else
*out++ = in[i]; *out++ = in[i];
} }
@ -3551,6 +3561,7 @@ void Host_Init (quakeparms_t *parms)
if (parms->memsize < MINIMUM_MEMORY) if (parms->memsize < MINIMUM_MEMORY)
Sys_Error ("Only %4.1f megs of memory reported, can't execute game", parms->memsize / (float)0x100000); Sys_Error ("Only %4.1f megs of memory reported, can't execute game", parms->memsize / (float)0x100000);
Cvar_Init();
Memory_Init (parms->membase, parms->memsize); Memory_Init (parms->membase, parms->memsize);
Sys_Init(); Sys_Init();
@ -3637,7 +3648,8 @@ void Host_FinishInit(void)
{ //they didn't give us an rc file! { //they didn't give us an rc file!
Cbuf_AddText ("bind ~ toggleconsole\n", RESTRICT_LOCAL); //we expect default.cfg to not exist. :( Cbuf_AddText ("bind ~ toggleconsole\n", RESTRICT_LOCAL); //we expect default.cfg to not exist. :(
Cbuf_AddText ("exec default.cfg\n", RESTRICT_LOCAL); Cbuf_AddText ("exec default.cfg\n", RESTRICT_LOCAL);
Cbuf_AddText ("exec config.cfg\n", RESTRICT_LOCAL); if (COM_FCheckExists ("config.cfg"))
Cbuf_AddText ("exec config.cfg\n", RESTRICT_LOCAL);
if (COM_FCheckExists ("q3config.cfg")) if (COM_FCheckExists ("q3config.cfg"))
Cbuf_AddText ("exec q3config.cfg\n", RESTRICT_LOCAL); Cbuf_AddText ("exec q3config.cfg\n", RESTRICT_LOCAL);
Cbuf_AddText ("exec autoexec.cfg\n", RESTRICT_LOCAL); Cbuf_AddText ("exec autoexec.cfg\n", RESTRICT_LOCAL);

View file

@ -421,6 +421,7 @@ void CL_DisenqueDownload(char *filename)
} }
} }
#ifdef WEBCLIENT
void CL_WebDownloadFinished(struct dl_download *dl) void CL_WebDownloadFinished(struct dl_download *dl)
{ {
if (dl->status == DL_FAILED) if (dl->status == DL_FAILED)
@ -433,6 +434,7 @@ void CL_WebDownloadFinished(struct dl_download *dl)
CL_DownloadFinished(); CL_DownloadFinished();
} }
} }
#endif
void CL_SendDownloadStartRequest(char *filename, char *localname) void CL_SendDownloadStartRequest(char *filename, char *localname)
{ {
@ -446,6 +448,7 @@ void CL_SendDownloadStartRequest(char *filename, char *localname)
COM_StripExtension (localname, cls.downloadtempname, sizeof(cls.downloadtempname)-5); COM_StripExtension (localname, cls.downloadtempname, sizeof(cls.downloadtempname)-5);
strcat (cls.downloadtempname, ".tmp"); strcat (cls.downloadtempname, ".tmp");
#ifdef WEBCLIENT
if (!strncmp(cls.downloadremotename, "http://", 7)) if (!strncmp(cls.downloadremotename, "http://", 7))
{ {
cls.downloadmethod = DL_HTTP; cls.downloadmethod = DL_HTTP;
@ -454,6 +457,7 @@ void CL_SendDownloadStartRequest(char *filename, char *localname)
CL_DownloadFailed(cls.downloadremotename); CL_DownloadFailed(cls.downloadremotename);
} }
else else
#endif
{ {
CL_SendClientCommand(true, "download %s", filename); CL_SendClientCommand(true, "download %s", filename);
@ -787,10 +791,10 @@ void Model_CheckDownloads (void)
// Con_TPrintf (TLC_CHECKINGMODELS); // Con_TPrintf (TLC_CHECKINGMODELS);
R_SetSky(cl.skyname);
#ifdef Q2CLIENT #ifdef Q2CLIENT
if (cls.protocol == CP_QUAKE2) if (cls.protocol == CP_QUAKE2)
{ {
// R_SetSky(cl.skyname);
for (i = 0; i < Q2MAX_IMAGES; i++) for (i = 0; i < Q2MAX_IMAGES; i++)
{ {
char picname[256]; char picname[256];
@ -845,18 +849,19 @@ int CL_LoadModels(int stage, qboolean dontactuallyload)
float giveuptime = Sys_DoubleTime()+0.1; //small things get padded into a single frame float giveuptime = Sys_DoubleTime()+0.1; //small things get padded into a single frame
#define atstage() ((cl.contentstage == stage++ && !dontactuallyload)?++cl.contentstage:false) #define atstage() ((cl.contentstage == stage++ && !dontactuallyload)?++cl.contentstage:false)
#define endstage() if (giveuptime<Sys_DoubleTime()) return -1; #define endstage() if (!cls.timedemo && giveuptime<Sys_DoubleTime()) return -1;
pmove.numphysent = 0; pmove.numphysent = 0;
#ifdef PEXT_CSQC #ifdef PEXT_CSQC
if (atstage()) if (atstage())
{ {
if (cls.protocol == CP_NETQUAKE) extern cvar_t cl_nocsqc;
if (cls.protocol == CP_NETQUAKE && !cl_nocsqc.ival && !cls.demoplayback)
{ {
char *s; char *s;
s = Info_ValueForKey(cl.serverinfo, "*csprogs"); s = Info_ValueForKey(cl.serverinfo, "*csprogs");
if (*s || cls.demoplayback) //only allow csqc if the server says so, and the 'checksum' matches. if (*s) //only allow csqc if the server says so, and the 'checksum' matches.
{ {
extern cvar_t allow_download_csprogs; extern cvar_t allow_download_csprogs;
unsigned int chksum = strtoul(s, NULL, 0); unsigned int chksum = strtoul(s, NULL, 0);
@ -1102,9 +1107,12 @@ void Sound_CheckDownloads (void)
s = Info_ValueForKey(cl.serverinfo, "*csprogs"); s = Info_ValueForKey(cl.serverinfo, "*csprogs");
if (*s) //only allow csqc if the server says so, and the 'checksum' matches. if (*s) //only allow csqc if the server says so, and the 'checksum' matches.
{ {
extern cvar_t allow_download_csprogs; extern cvar_t allow_download_csprogs, cl_nocsqc;
unsigned int chksum = strtoul(s, NULL, 0); unsigned int chksum = strtoul(s, NULL, 0);
if (allow_download_csprogs.ival) if (cl_nocsqc.ival || cls.demoplayback)
{
}
else if (allow_download_csprogs.ival)
{ {
char *str = va("csprogsvers/%x.dat", chksum); char *str = va("csprogsvers/%x.dat", chksum);
CL_CheckOrEnqueDownloadFile("csprogs.dat", str, DLLF_REQUIRED); CL_CheckOrEnqueDownloadFile("csprogs.dat", str, DLLF_REQUIRED);
@ -3107,6 +3115,7 @@ void CL_ParseStatic (int version)
entity_t *ent; entity_t *ent;
int i; int i;
entity_state_t es; entity_state_t es;
vec3_t mins,maxs;
if (version == 1) if (version == 1)
{ {
@ -3120,10 +3129,9 @@ void CL_ParseStatic (int version)
es.number+=MAX_EDICTS; es.number+=MAX_EDICTS;
for (i = 0; i < cl.num_statics; i++) for (i = 0; i < cl.num_statics; i++)
if (cl_static_entities[i].keynum == es.number) if (cl_static_entities[i].ent.keynum == es.number)
{ {
R_RemoveEfrags (&cl_static_entities[i]); pe->DelinkTrailstate (&cl_static_entities[i].emit);
pe->DelinkTrailstate (&cl_static_emit[i]);
break; break;
} }
@ -3137,9 +3145,9 @@ void CL_ParseStatic (int version)
Con_Printf ("Too many static entities"); Con_Printf ("Too many static entities");
return; return;
} }
ent = &cl_static_entities[i]; ent = &cl_static_entities[i].ent;
memset(ent, 0, sizeof(*ent)); memset(ent, 0, sizeof(*ent));
cl_static_emit[i] = NULL; cl_static_entities[i].emit = NULL;
ent->keynum = es.number; ent->keynum = es.number;
@ -3171,8 +3179,12 @@ void CL_ParseStatic (int version)
Con_TPrintf (TLC_PARSESTATICWITHNOMAP); Con_TPrintf (TLC_PARSESTATICWITHNOMAP);
return; return;
} }
if (ent->model)
R_AddEfrags (ent); {
VectorAdd(es.origin, ent->model->mins, mins);
VectorAdd(es.origin, ent->model->maxs, maxs);
cl.worldmodel->funcs.FindTouchedLeafs(cl.worldmodel, &cl_static_entities[i].pvscache, mins, maxs);
}
} }
/* /*
@ -4525,9 +4537,9 @@ void CL_ParseStuffCmd(char *msg, int destsplit) //this protects stuffcmds from n
} }
#endif #endif
#ifdef CSQC_DAT #ifdef CSQC_DAT
else else if (CSQC_StuffCmd(destsplit, stufftext, msg))
if (CSQC_StuffCmd(destsplit, stufftext)) {
{} }
#endif #endif
else else
{ {
@ -4666,7 +4678,7 @@ void CL_ParseServerMessage (void)
{ {
SHOWNET(svc_strings[cmd]); SHOWNET(svc_strings[cmd]);
destsplit = MSG_ReadByte(); destsplit = MSG_ReadByte() % MAX_SPLITS;
cmd = MSG_ReadByte(); cmd = MSG_ReadByte();
} }
else else
@ -4902,11 +4914,11 @@ void CL_ParseServerMessage (void)
break; break;
case svc_killedmonster: case svc_killedmonster:
cl.stats[0][STAT_MONSTERS]++; cl.stats[destsplit][STAT_MONSTERS]++;
break; break;
case svc_foundsecret: case svc_foundsecret:
cl.stats[0][STAT_SECRETS]++; cl.stats[destsplit][STAT_SECRETS]++;
break; break;
case svc_updatestat: case svc_updatestat:

View file

@ -62,22 +62,6 @@ qintptr_t VARGS Plug_SCR_CenterPrint(void *offset, quintptr_t mask, const qintpt
SCR_CenterPrint(0, VM_POINTER(arg[0]), true); SCR_CenterPrint(0, VM_POINTER(arg[0]), true);
return 0; return 0;
} }
qintptr_t VARGS Plug_Media_ShowFrameRGBA_32(void *offset, quintptr_t mask, const qintptr_t *arg)
{
void *src = VM_POINTER(arg[0]);
int srcwidth = VM_LONG(arg[1]);
int srcheight = VM_LONG(arg[2]);
// int x = VM_LONG(arg[3]);
// int y = VM_LONG(arg[4]);
// int width = VM_LONG(arg[5]);
// int height = VM_LONG(arg[6]);
if (qrenderer == QR_NONE)
return 0;
Media_ShowFrameRGBA_32(src, srcwidth, srcheight);
return 0;
}
@ -568,7 +552,6 @@ void Plug_Client_Init(void)
Plug_RegisterBuiltin("LocalSound", Plug_LocalSound, PLUG_BIF_NEEDSRENDERER); Plug_RegisterBuiltin("LocalSound", Plug_LocalSound, PLUG_BIF_NEEDSRENDERER);
Plug_RegisterBuiltin("SCR_CenterPrint", Plug_SCR_CenterPrint, PLUG_BIF_NEEDSRENDERER); Plug_RegisterBuiltin("SCR_CenterPrint", Plug_SCR_CenterPrint, PLUG_BIF_NEEDSRENDERER);
Plug_RegisterBuiltin("Media_ShowFrameRGBA_32", Plug_Media_ShowFrameRGBA_32, PLUG_BIF_NEEDSRENDERER);
Plug_RegisterBuiltin("GetLocationName", Plug_GetLocationName, PLUG_BIF_NEEDSRENDERER); Plug_RegisterBuiltin("GetLocationName", Plug_GetLocationName, PLUG_BIF_NEEDSRENDERER);
Plug_RegisterBuiltin("GetPlayerInfo", Plug_GetPlayerInfo, PLUG_BIF_NEEDSRENDERER); Plug_RegisterBuiltin("GetPlayerInfo", Plug_GetPlayerInfo, PLUG_BIF_NEEDSRENDERER);

View file

@ -243,14 +243,6 @@ CENTER PRINTING
typedef struct { typedef struct {
unsigned int flags; unsigned int flags;
#define CPRINT_BALIGN (1<<0) //B
#define CPRINT_OBITUARTY (1<<1) //O
#define CPRINT_TALIGN (1<<2) //T
#define CPRINT_LALIGN (1<<3) //L
#define CPRINT_RALIGN (1<<4) //R
#define CPRINT_PERSIST (1<<5) //P
#define CPRINT_BACKGROUND (1<<6) //P
#define CPRINT_TYPEWRITER (1<<7) //
conchar_t string[1024]; conchar_t string[1024];
unsigned int charcount; unsigned int charcount;
@ -539,6 +531,24 @@ extern qboolean sb_showscores;
} }
} }
void R_DrawTextField(int x, int y, int w, int h, char *text, unsigned int defaultmask, unsigned int fieldflags)
{
cprint_t p;
vrect_t r;
r.x = x;
r.y = y;
r.width = w;
r.height = h;
p.flags = fieldflags;
p.charcount = COM_ParseFunString(defaultmask, text, p.string, sizeof(p.string), false) - p.string;
p.time_off = scr_centertime.value;
p.time_start = cl.time;
SCR_DrawCenterString(&r, &p);
}
void SCR_DrawCursor(int prydoncursornum) void SCR_DrawCursor(int prydoncursornum)
{ {
extern cvar_t cl_cursor, cl_cursorbias, cl_cursorsize; extern cvar_t cl_cursor, cl_cursorbias, cl_cursorsize;
@ -1488,7 +1498,7 @@ void SCR_DrawLoading (void)
unsigned int tsize; unsigned int tsize;
qboolean sizeextra; qboolean sizeextra;
x = vid.conwidth/2 - 160; x = vid.width/2 - 160;
CL_GetDownloadSizes(&fcount, &tsize, &sizeextra); CL_GetDownloadSizes(&fcount, &tsize, &sizeextra);
//downloading files? //downloading files?

View file

@ -234,10 +234,10 @@ sfx_t *cl_sfx_ric2;
sfx_t *cl_sfx_ric3; sfx_t *cl_sfx_ric3;
sfx_t *cl_sfx_r_exp3; sfx_t *cl_sfx_r_exp3;
cvar_t cl_expsprite = SCVAR("cl_expsprite", "0"); cvar_t cl_expsprite = CVAR("cl_expsprite", "0");
cvar_t r_explosionlight = SCVARC("r_explosionlight", "1", Cvar_Limiter_ZeroToOne_Callback); cvar_t r_explosionlight = CVARC("r_explosionlight", "1", Cvar_Limiter_ZeroToOne_Callback);
cvar_t cl_truelightning = SCVARF("cl_truelightning", "0", CVAR_SEMICHEAT); cvar_t cl_truelightning = CVARF("cl_truelightning", "0", CVAR_SEMICHEAT);
cvar_t cl_beam_trace = SCVAR("cl_beam_trace", "0"); cvar_t cl_beam_trace = CVAR("cl_beam_trace", "0");
typedef struct { typedef struct {
sfx_t **sfx; sfx_t **sfx;
@ -1762,7 +1762,7 @@ void CL_Laser (vec3_t start, vec3_t end, int colors)
ex->firstframe = 0; ex->firstframe = 0;
ex->numframes = 10; ex->numframes = 10;
ex->alpha = 0.33f; ex->alpha = 0.33f;
ex->model = (void*)0xDEAFF00D; //something not null ex->model = NULL;
ex->skinnum = (colors >> ((rand() % 4)*8)) & 0xff; ex->skinnum = (colors >> ((rand() % 4)*8)) & 0xff;
VectorCopy (start, ex->origin); VectorCopy (start, ex->origin);
VectorCopy (end, ex->oldorigin); VectorCopy (end, ex->oldorigin);
@ -1913,7 +1913,7 @@ void CLQ2_ParseTEnt (void)
ex->model = Mod_ForName (q2tentmodels[q2cl_mod_explode].modelname, false); ex->model = Mod_ForName (q2tentmodels[q2cl_mod_explode].modelname, false);
ex->firstframe = 0; ex->firstframe = 0;
ex->numframes = 4; ex->numframes = 4;
ex->flags = Q2RF_FULLBRIGHT; ex->flags = Q2RF_FULLBRIGHT|Q2RF_ADDITIVE|RF_NOSHADOW;
ex->angles[0] = acos(dir[2])/M_PI*180; ex->angles[0] = acos(dir[2])/M_PI*180;
// PMM - fixed to correct for pitch of 0 // PMM - fixed to correct for pitch of 0
@ -2240,7 +2240,7 @@ void CLQ2_ParseTEnt (void)
ex->model = Mod_ForName (q2tentmodels[q2cl_mod_explode].modelname, false); ex->model = Mod_ForName (q2tentmodels[q2cl_mod_explode].modelname, false);
ex->firstframe = 0; ex->firstframe = 0;
ex->numframes = 4; ex->numframes = 4;
ex->flags = Q2RF_FULLBRIGHT; ex->flags = Q2RF_FULLBRIGHT|RF_NOSHADOW;
ex->angles[0] = acos(dir[2])/M_PI*180; ex->angles[0] = acos(dir[2])/M_PI*180;
// PMM - fixed to correct for pitch of 0 // PMM - fixed to correct for pitch of 0
@ -2290,7 +2290,7 @@ void CLQ2_ParseTEnt (void)
ex->model = Mod_ForName (q2tentmodels[q2cl_mod_explode].modelname, false); ex->model = Mod_ForName (q2tentmodels[q2cl_mod_explode].modelname, false);
ex->firstframe = 0; ex->firstframe = 0;
ex->numframes = 4; ex->numframes = 4;
ex->flags = Q2RF_FULLBRIGHT; ex->flags = Q2RF_FULLBRIGHT|RF_NOSHADOW;
ex->angles[0] = acos(dir[2])/M_PI*180; ex->angles[0] = acos(dir[2])/M_PI*180;
// PMM - fixed to correct for pitch of 0 // PMM - fixed to correct for pitch of 0
@ -2343,7 +2343,7 @@ void CLQ2_ParseTEnt (void)
ex = CL_AllocExplosion (); ex = CL_AllocExplosion ();
VectorCopy (pos, ex->origin); VectorCopy (pos, ex->origin);
// ex->type = ex_poly; // ex->type = ex_poly;
ex->flags = Q2RF_FULLBRIGHT; ex->flags = Q2RF_FULLBRIGHT|RF_NOSHADOW;
ex->angles[1] = rand() % 360; ex->angles[1] = rand() % 360;
ex->model = Mod_ForName (q2tentmodels[q2cl_mod_explo4].modelname, false); ex->model = Mod_ForName (q2tentmodels[q2cl_mod_explo4].modelname, false);
if (rand() < RAND_MAX/2) if (rand() < RAND_MAX/2)
@ -2530,7 +2530,7 @@ void CLQ2_ParseTEnt (void)
MSG_ReadPos (pos); MSG_ReadPos (pos);
ex = CL_AllocExplosion (); ex = CL_AllocExplosion ();
VectorCopy (pos, ex->origin); VectorCopy (pos, ex->origin);
ex->flags = Q2RF_FULLBRIGHT; ex->flags = Q2RF_FULLBRIGHT|RF_NOSHADOW;
ex->start = cl.q2frame.servertime - 100; ex->start = cl.q2frame.servertime - 100;
CL_NewDlightRGB(0, pos, 350, 0.5, 0.2, 0.1, 0); CL_NewDlightRGB(0, pos, 350, 0.5, 0.2, 0.1, 0);
P_RunParticleEffectTypeString(pos, NULL, 1, "te_muzzleflash"); P_RunParticleEffectTypeString(pos, NULL, 1, "te_muzzleflash");
@ -2539,7 +2539,7 @@ void CLQ2_ParseTEnt (void)
MSG_ReadPos (pos); MSG_ReadPos (pos);
ex = CL_AllocExplosion (); ex = CL_AllocExplosion ();
VectorCopy (pos, ex->origin); VectorCopy (pos, ex->origin);
ex->flags = Q2RF_FULLBRIGHT; ex->flags = Q2RF_FULLBRIGHT|RF_NOSHADOW;
ex->start = cl.q2frame.servertime - 100; ex->start = cl.q2frame.servertime - 100;
CL_NewDlightRGB(0, pos, 350, 0.5, 0.2, 0.1, 0); CL_NewDlightRGB(0, pos, 350, 0.5, 0.2, 0.1, 0);
P_RunParticleEffectTypeString(pos, NULL, 1, "te_blue_muzzleflash"); P_RunParticleEffectTypeString(pos, NULL, 1, "te_blue_muzzleflash");
@ -2548,7 +2548,7 @@ void CLQ2_ParseTEnt (void)
MSG_ReadPos (pos); MSG_ReadPos (pos);
ex = CL_AllocExplosion (); ex = CL_AllocExplosion ();
VectorCopy (pos, ex->origin); VectorCopy (pos, ex->origin);
ex->flags = Q2RF_FULLBRIGHT; ex->flags = Q2RF_FULLBRIGHT|RF_NOSHADOW;
ex->start = cl.q2frame.servertime - 100; ex->start = cl.q2frame.servertime - 100;
CL_NewDlightRGB(0, pos, 350, 0.5, 0.2, 0, 0.2); CL_NewDlightRGB(0, pos, 350, 0.5, 0.2, 0, 0.2);
P_RunParticleEffectTypeString(pos, NULL, 1, "te_smart_muzzleflash"); P_RunParticleEffectTypeString(pos, NULL, 1, "te_smart_muzzleflash");
@ -2559,7 +2559,7 @@ void CLQ2_ParseTEnt (void)
MSG_ReadPos (pos); MSG_ReadPos (pos);
ex = CL_AllocExplosion (); ex = CL_AllocExplosion ();
VectorCopy (pos, ex->origin); VectorCopy (pos, ex->origin);
ex->flags = Q2RF_FULLBRIGHT; ex->flags = Q2RF_FULLBRIGHT|RF_NOSHADOW;
ex->start = cl.q2frame.servertime - 100; ex->start = cl.q2frame.servertime - 100;
CL_NewDlightRGB(0, pos, 350, 0.5, 0.2, 0, 0.2); CL_NewDlightRGB(0, pos, 350, 0.5, 0.2, 0, 0.2);
P_RunParticleEffectTypeString(pos, NULL, 1, "te_deathfield"); P_RunParticleEffectTypeString(pos, NULL, 1, "te_deathfield");
@ -2824,7 +2824,7 @@ void CL_UpdateExplosions (void)
for (i=0, ex=cl_explosions; i < explosions_running; i++, ex++) for (i=0, ex=cl_explosions; i < explosions_running; i++, ex++)
{ {
if (!ex->model) if (!ex->model && !ex->flags)
continue; continue;
lastrunningexplosion = i; lastrunningexplosion = i;
@ -2844,6 +2844,7 @@ void CL_UpdateExplosions (void)
if ((int)f >= numframes || (int)f < 0) if ((int)f >= numframes || (int)f < 0)
{ {
ex->model = NULL; ex->model = NULL;
ex->flags = 0;
continue; continue;
} }
if (of < 0) if (of < 0)

View file

@ -685,7 +685,7 @@ void UI_RegisterFont(char *fontName, int pointSize, fontInfo_t *font)
#ifndef _DEBUG #ifndef _DEBUG
static static
#endif #endif
int UI_SystemCallsEx(void *offset, unsigned int mask, int fn, const int *arg) int UI_SystemCallsEx(void *offset, quintptr_t mask, int fn, const int *arg)
{ {
int ret=0; int ret=0;
char adrbuf[MAX_ADR_SIZE]; char adrbuf[MAX_ADR_SIZE];
@ -1333,21 +1333,21 @@ static int UI_SystemCallsExWrapper(void *offset, unsigned int mask, int fn, cons
//I'm not keen on this. //I'm not keen on this.
//but dlls call it without saying what sort of vm it comes from, so I've got to have them as specifics //but dlls call it without saying what sort of vm it comes from, so I've got to have them as specifics
static int EXPORT_FN UI_SystemCalls(int arg, ...) static qintptr_t EXPORT_FN UI_SystemCalls(qintptr_t arg, ...)
{ {
int args[9]; qintptr_t args[9];
va_list argptr; va_list argptr;
va_start(argptr, arg); va_start(argptr, arg);
args[0]=va_arg(argptr, int); args[0]=va_arg(argptr, qintptr_t);
args[1]=va_arg(argptr, int); args[1]=va_arg(argptr, qintptr_t);
args[2]=va_arg(argptr, int); args[2]=va_arg(argptr, qintptr_t);
args[3]=va_arg(argptr, int); args[3]=va_arg(argptr, qintptr_t);
args[4]=va_arg(argptr, int); args[4]=va_arg(argptr, qintptr_t);
args[5]=va_arg(argptr, int); args[5]=va_arg(argptr, qintptr_t);
args[6]=va_arg(argptr, int); args[6]=va_arg(argptr, qintptr_t);
args[7]=va_arg(argptr, int); args[7]=va_arg(argptr, qintptr_t);
args[8]=va_arg(argptr, int); args[8]=va_arg(argptr, qintptr_t);
va_end(argptr); va_end(argptr);
return UI_SystemCallsEx(NULL, ~0, arg, args); return UI_SystemCallsEx(NULL, ~0, arg, args);

View file

@ -270,7 +270,6 @@ typedef struct dlight_s
} face [6]; } face [6];
int style; //multiply by style values if > 0 int style; //multiply by style values if > 0
float fov; //spotlight float fov; //spotlight
int refresh;
float dist; float dist;
struct dlight_s *next; struct dlight_s *next;
} dlight_t; } dlight_t;
@ -582,7 +581,6 @@ typedef struct
// refresh related state // refresh related state
struct model_s *worldmodel; // cl_entitites[0].model struct model_s *worldmodel; // cl_entitites[0].model
struct efrag_s *free_efrags;
int num_entities; // stored bottom up in cl_entities array int num_entities; // stored bottom up in cl_entities array
int num_statics; // stored top down in cl_entitiers int num_statics; // stored top down in cl_entitiers
@ -701,11 +699,16 @@ extern cvar_t ruleset_allow_shaders;
extern client_state_t cl; extern client_state_t cl;
typedef struct
{
entity_t ent;
trailstate_t *emit;
pvscache_t pvscache;
} static_entity_t;
// FIXME, allocate dynamically // FIXME, allocate dynamically
extern entity_state_t *cl_baselines; extern entity_state_t *cl_baselines;
extern efrag_t cl_efrags[MAX_EFRAGS]; extern static_entity_t cl_static_entities[MAX_STATIC_ENTITIES];
extern entity_t cl_static_entities[MAX_STATIC_ENTITIES];
extern trailstate_t *cl_static_emit[MAX_STATIC_ENTITIES];
extern lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES]; extern lightstyle_t cl_lightstyle[MAX_LIGHTSTYLES];
extern dlight_t *cl_dlights; extern dlight_t *cl_dlights;
extern unsigned int cl_maxdlights; extern unsigned int cl_maxdlights;
@ -956,6 +959,7 @@ void CLDP_ParsePointParticles(qboolean compact);
// //
void CL_SetSolidPlayers (int playernum); void CL_SetSolidPlayers (int playernum);
void CL_SetUpPlayerPrediction(qboolean dopred); void CL_SetUpPlayerPrediction(qboolean dopred);
void CL_LinkStaticEntities(void *pvs);
void CL_EmitEntities (void); void CL_EmitEntities (void);
void CL_ClearProjectiles (void); void CL_ClearProjectiles (void);
void CL_ParseProjectiles (int modelindex, qboolean nails2); void CL_ParseProjectiles (int modelindex, qboolean nails2);
@ -998,7 +1002,7 @@ qboolean CSQC_Init (unsigned int checksum);
void CSQC_RegisterCvarsAndThings(void); void CSQC_RegisterCvarsAndThings(void);
qboolean CSQC_DrawView(void); qboolean CSQC_DrawView(void);
void CSQC_Shutdown(void); void CSQC_Shutdown(void);
qboolean CSQC_StuffCmd(int lplayernum, char *cmd); qboolean CSQC_StuffCmd(int lplayernum, char *cmd, char *cmdend);
qboolean CSQC_LoadResource(char *resname, char *restype); qboolean CSQC_LoadResource(char *resname, char *restype);
qboolean CSQC_ParsePrint(char *message, int printlevel); qboolean CSQC_ParsePrint(char *message, int printlevel);
qboolean CSQC_ParseGamePacket(void); qboolean CSQC_ParseGamePacket(void);
@ -1184,15 +1188,16 @@ int SCR_StringToPalIndex (char *rgbstring, float rgbinputscale);
struct model_s; struct model_s;
void CL_AddVWeapModel(entity_t *player, struct model_s *model); void CL_AddVWeapModel(entity_t *player, struct model_s *model);
/*q2 cinematics*/
struct cinematics_s;
void CIN_StopCinematic (struct cinematics_s *cin);
struct cinematics_s *CIN_PlayCinematic (char *arg);
int CIN_RunCinematic (struct cinematics_s *cin, qbyte **outdata, int *outwidth, int *outheight, qbyte **outpalette);
/*media playing system*/
qboolean Media_PlayingFullScreen(void); qboolean Media_PlayingFullScreen(void);
void Media_Init(void); void Media_Init(void);
qboolean Media_PlayFilm(char *name); qboolean Media_PlayFilm(char *name);
void CIN_FinishCinematic (void);
qboolean CIN_PlayCinematic (char *arg);
qboolean CIN_DrawCinematic (void);
qboolean CIN_RunCinematic (void);
typedef struct cin_s cin_t; typedef struct cin_s cin_t;
struct cin_s *Media_StartCin(char *name); struct cin_s *Media_StartCin(char *name);
texid_t Media_UpdateForShader(cin_t *cin); texid_t Media_UpdateForShader(cin_t *cin);

View file

@ -7,7 +7,7 @@ typedef struct
int count; int count;
} cblock_t; } cblock_t;
typedef struct typedef struct cinematics_s
{ {
qboolean restart_sound; qboolean restart_sound;
int s_rate; int s_rate;
@ -35,66 +35,32 @@ typedef struct
int cinematicframe; int cinematicframe;
} cinematics_t; } cinematics_t;
cinematics_t cin;
void CIN_StopCinematic (cinematics_t *cin)
void CIN_StopCinematic (void)
{ {
Media_PlayFilm(""); cin->cinematictime = 0; // done
cin.cinematictime = 0; // done if (cin->pic)
if (cin.pic)
{ {
Z_Free (cin.pic); Z_Free (cin->pic);
cin.pic = NULL; cin->pic = NULL;
} }
if (cin.pic_pending) if (cin->pic_pending)
{ {
Z_Free (cin.pic_pending); Z_Free (cin->pic_pending);
cin.pic_pending = NULL; cin->pic_pending = NULL;
} }
if (cin.cinematicpalette_active) if (cin->cinematic_file)
{ {
// re.CinematicSetPalette(NULL); VFS_CLOSE (cin->cinematic_file);
cin.cinematicpalette_active = false; cin->cinematic_file = NULL;
} }
if (cin.cinematic_file) if (cin->hnodes1)
{ {
VFS_CLOSE (cin.cinematic_file); Z_Free (cin->hnodes1);
cin.cinematic_file = NULL; cin->hnodes1 = NULL;
}
if (cin.hnodes1)
{
Z_Free (cin.hnodes1);
cin.hnodes1 = NULL;
} }
// switch back down to 11 khz sound if necessary Z_Free(cin);
if (cin.restart_sound)
{
cin.restart_sound = false;
S_Restart_f ();
}
}
/*
====================
SCR_FinishCinematic
Called when either the cinematic completes, or it is aborted
====================
*/
void CIN_FinishCinematic (void)
{
// tell the server to advance to the next map / cinematic (a q2 hack)
if (cls.state == ca_active)
{
CL_SendClientCommand(true, "nextserver %i", cl.servercount);
}
S_RawAudio(0, NULL, 0, 0, 0, 0);
} }
//========================================================================== //==========================================================================
@ -104,7 +70,7 @@ void CIN_FinishCinematic (void)
SmallestNode1 SmallestNode1
================== ==================
*/ */
static int SmallestNode1 (int numhnodes) static int SmallestNode1 (cinematics_t *cin, int numhnodes)
{ {
int i; int i;
int best, bestnode; int best, bestnode;
@ -113,13 +79,13 @@ static int SmallestNode1 (int numhnodes)
bestnode = -1; bestnode = -1;
for (i=0 ; i<numhnodes ; i++) for (i=0 ; i<numhnodes ; i++)
{ {
if (cin.h_used[i]) if (cin->h_used[i])
continue; continue;
if (!cin.h_count[i]) if (!cin->h_count[i])
continue; continue;
if (cin.h_count[i] < best) if (cin->h_count[i] < best)
{ {
best = cin.h_count[i]; best = cin->h_count[i];
bestnode = i; bestnode = i;
} }
} }
@ -127,7 +93,7 @@ static int SmallestNode1 (int numhnodes)
if (bestnode == -1) if (bestnode == -1)
return -1; return -1;
cin.h_used[bestnode] = true; cin->h_used[bestnode] = true;
return bestnode; return bestnode;
} }
@ -139,7 +105,7 @@ Huff1TableInit
Reads the 64k counts table and initializes the node trees Reads the 64k counts table and initializes the node trees
================== ==================
*/ */
static void Huff1TableInit (void) static void Huff1TableInit (cinematics_t *cin)
{ {
int prev; int prev;
int j; int j;
@ -147,41 +113,41 @@ static void Huff1TableInit (void)
qbyte counts[256]; qbyte counts[256];
int numhnodes; int numhnodes;
cin.hnodes1 = Z_Malloc (256*256*2*4); cin->hnodes1 = Z_Malloc (256*256*2*4);
memset (cin.hnodes1, 0, 256*256*2*4); memset (cin->hnodes1, 0, 256*256*2*4);
for (prev=0 ; prev<256 ; prev++) for (prev=0 ; prev<256 ; prev++)
{ {
memset (cin.h_count,0,sizeof(cin.h_count)); memset (cin->h_count,0,sizeof(cin->h_count));
memset (cin.h_used,0,sizeof(cin.h_used)); memset (cin->h_used,0,sizeof(cin->h_used));
// read a row of counts // read a row of counts
VFS_READ (cin.cinematic_file, counts, sizeof(counts)); VFS_READ (cin->cinematic_file, counts, sizeof(counts));
for (j=0 ; j<256 ; j++) for (j=0 ; j<256 ; j++)
cin.h_count[j] = counts[j]; cin->h_count[j] = counts[j];
// build the nodes // build the nodes
numhnodes = 256; numhnodes = 256;
nodebase = cin.hnodes1 + prev*256*2; nodebase = cin->hnodes1 + prev*256*2;
while (numhnodes != 511) while (numhnodes != 511)
{ {
node = nodebase + (numhnodes-256)*2; node = nodebase + (numhnodes-256)*2;
// pick two lowest counts // pick two lowest counts
node[0] = SmallestNode1 (numhnodes); node[0] = SmallestNode1 (cin, numhnodes);
if (node[0] == -1) if (node[0] == -1)
break; // no more break; // no more
node[1] = SmallestNode1 (numhnodes); node[1] = SmallestNode1 (cin, numhnodes);
if (node[1] == -1) if (node[1] == -1)
break; break;
cin.h_count[numhnodes] = cin.h_count[node[0]] + cin.h_count[node[1]]; cin->h_count[numhnodes] = cin->h_count[node[0]] + cin->h_count[node[1]];
numhnodes++; numhnodes++;
} }
cin.numhnodes1[prev] = numhnodes-1; cin->numhnodes1[prev] = numhnodes-1;
} }
} }
@ -190,7 +156,7 @@ static void Huff1TableInit (void)
Huff1Decompress Huff1Decompress
================== ==================
*/ */
static cblock_t Huff1Decompress (cblock_t in) static cblock_t Huff1Decompress (cinematics_t *cin, cblock_t in)
{ {
qbyte *input; qbyte *input;
qbyte *out_p; qbyte *out_p;
@ -208,10 +174,10 @@ static cblock_t Huff1Decompress (cblock_t in)
// read bits // read bits
hnodesbase = cin.hnodes1 - 256*2; // nodes 0-255 aren't stored hnodesbase = cin->hnodes1 - 256*2; // nodes 0-255 aren't stored
hnodes = hnodesbase; hnodes = hnodesbase;
nodenum = cin.numhnodes1[0]; nodenum = cin->numhnodes1[0];
while (count) while (count)
{ {
inbyte = *input++; inbyte = *input++;
@ -222,7 +188,7 @@ static cblock_t Huff1Decompress (cblock_t in)
*out_p++ = nodenum; *out_p++ = nodenum;
if (!--count) if (!--count)
break; break;
nodenum = cin.numhnodes1[nodenum]; nodenum = cin->numhnodes1[nodenum];
} }
nodenum = hnodes[nodenum*2 + (inbyte&1)]; nodenum = hnodes[nodenum*2 + (inbyte&1)];
inbyte >>=1; inbyte >>=1;
@ -233,7 +199,7 @@ static cblock_t Huff1Decompress (cblock_t in)
*out_p++ = nodenum; *out_p++ = nodenum;
if (!--count) if (!--count)
break; break;
nodenum = cin.numhnodes1[nodenum]; nodenum = cin->numhnodes1[nodenum];
} }
nodenum = hnodes[nodenum*2 + (inbyte&1)]; nodenum = hnodes[nodenum*2 + (inbyte&1)];
inbyte >>=1; inbyte >>=1;
@ -244,7 +210,7 @@ static cblock_t Huff1Decompress (cblock_t in)
*out_p++ = nodenum; *out_p++ = nodenum;
if (!--count) if (!--count)
break; break;
nodenum = cin.numhnodes1[nodenum]; nodenum = cin->numhnodes1[nodenum];
} }
nodenum = hnodes[nodenum*2 + (inbyte&1)]; nodenum = hnodes[nodenum*2 + (inbyte&1)];
inbyte >>=1; inbyte >>=1;
@ -255,7 +221,7 @@ static cblock_t Huff1Decompress (cblock_t in)
*out_p++ = nodenum; *out_p++ = nodenum;
if (!--count) if (!--count)
break; break;
nodenum = cin.numhnodes1[nodenum]; nodenum = cin->numhnodes1[nodenum];
} }
nodenum = hnodes[nodenum*2 + (inbyte&1)]; nodenum = hnodes[nodenum*2 + (inbyte&1)];
inbyte >>=1; inbyte >>=1;
@ -266,7 +232,7 @@ static cblock_t Huff1Decompress (cblock_t in)
*out_p++ = nodenum; *out_p++ = nodenum;
if (!--count) if (!--count)
break; break;
nodenum = cin.numhnodes1[nodenum]; nodenum = cin->numhnodes1[nodenum];
} }
nodenum = hnodes[nodenum*2 + (inbyte&1)]; nodenum = hnodes[nodenum*2 + (inbyte&1)];
inbyte >>=1; inbyte >>=1;
@ -277,7 +243,7 @@ static cblock_t Huff1Decompress (cblock_t in)
*out_p++ = nodenum; *out_p++ = nodenum;
if (!--count) if (!--count)
break; break;
nodenum = cin.numhnodes1[nodenum]; nodenum = cin->numhnodes1[nodenum];
} }
nodenum = hnodes[nodenum*2 + (inbyte&1)]; nodenum = hnodes[nodenum*2 + (inbyte&1)];
inbyte >>=1; inbyte >>=1;
@ -288,7 +254,7 @@ static cblock_t Huff1Decompress (cblock_t in)
*out_p++ = nodenum; *out_p++ = nodenum;
if (!--count) if (!--count)
break; break;
nodenum = cin.numhnodes1[nodenum]; nodenum = cin->numhnodes1[nodenum];
} }
nodenum = hnodes[nodenum*2 + (inbyte&1)]; nodenum = hnodes[nodenum*2 + (inbyte&1)];
inbyte >>=1; inbyte >>=1;
@ -299,7 +265,7 @@ static cblock_t Huff1Decompress (cblock_t in)
*out_p++ = nodenum; *out_p++ = nodenum;
if (!--count) if (!--count)
break; break;
nodenum = cin.numhnodes1[nodenum]; nodenum = cin->numhnodes1[nodenum];
} }
nodenum = hnodes[nodenum*2 + (inbyte&1)]; nodenum = hnodes[nodenum*2 + (inbyte&1)];
inbyte >>=1; inbyte >>=1;
@ -319,7 +285,7 @@ static cblock_t Huff1Decompress (cblock_t in)
SCR_ReadNextFrame SCR_ReadNextFrame
================== ==================
*/ */
qbyte *CIN_ReadNextFrame (void) qbyte *CIN_ReadNextFrame (cinematics_t *cin)
{ {
int r; int r;
int command; int command;
@ -331,9 +297,9 @@ qbyte *CIN_ReadNextFrame (void)
int start, end, count; int start, end, count;
// read the next frame // read the next frame
r = VFS_READ (cin.cinematic_file, &command, 4); r = VFS_READ (cin->cinematic_file, &command, 4);
if (r == 0) // we'll give it one more chance if (r == 0) // we'll give it one more chance
r = VFS_READ (cin.cinematic_file, &command, 4); r = VFS_READ (cin->cinematic_file, &command, 4);
if (r != 4) if (r != 4)
return NULL; return NULL;
@ -343,39 +309,38 @@ qbyte *CIN_ReadNextFrame (void)
if (command == 1) if (command == 1)
{ // read palette { // read palette
VFS_READ (cin.cinematic_file, cin.cinematicpalette, sizeof(cin.cinematicpalette)); VFS_READ (cin->cinematic_file, cin->cinematicpalette, sizeof(cin->cinematicpalette));
cin.cinematicpalette_active=0; // dubious.... exposes an edge case
} }
// decompress the next frame // decompress the next frame
VFS_READ (cin.cinematic_file, &size, 4); VFS_READ (cin->cinematic_file, &size, 4);
size = LittleLong(size); size = LittleLong(size);
if (size > sizeof(compressed) || size < 1) if (size > sizeof(compressed) || size < 1)
Host_Error ("Bad compressed frame size"); Host_Error ("Bad compressed frame size");
VFS_READ (cin.cinematic_file, compressed, size); VFS_READ (cin->cinematic_file, compressed, size);
// read sound // read sound
start = cin.cinematicframe*cin.s_rate/14; start = cin->cinematicframe*cin->s_rate/14;
end = (cin.cinematicframe+1)*cin.s_rate/14; end = (cin->cinematicframe+1)*cin->s_rate/14;
count = end - start; count = end - start;
VFS_READ (cin.cinematic_file, samples, count*cin.s_width*cin.s_channels); VFS_READ (cin->cinematic_file, samples, count*cin->s_width*cin->s_channels);
if (cin.s_width == 1) if (cin->s_width == 1)
COM_CharBias(samples, count*cin.s_channels); COM_CharBias(samples, count*cin->s_channels);
else if (cin.s_width == 2) else if (cin->s_width == 2)
COM_SwapLittleShortBlock((short *)samples, count*cin.s_channels); COM_SwapLittleShortBlock((short *)samples, count*cin->s_channels);
S_RawAudio (0, samples, cin.s_rate, count, cin.s_channels, cin.s_width); S_RawAudio (0, samples, cin->s_rate, count, cin->s_channels, cin->s_width);
in.data = compressed; in.data = compressed;
in.count = size; in.count = size;
huf1 = Huff1Decompress (in); huf1 = Huff1Decompress (cin, in);
pic = huf1.data; pic = huf1.data;
cin.cinematicframe++; cin->cinematicframe++;
return pic; return pic;
} }
@ -385,52 +350,51 @@ qbyte *CIN_ReadNextFrame (void)
================== ==================
SCR_RunCinematic SCR_RunCinematic
0 = error
1 = success
2 = success but nothing changed
================== ==================
*/ */
qboolean CIN_DrawCinematic (void); int CIN_RunCinematic (cinematics_t *cin, qbyte **outdata, int *outwidth, int *outheight, qbyte **outpalette)
qboolean CIN_RunCinematic (void)
{ {
int frame; int frame;
if (cin.cinematictime <= 0) if (cin->cinematictime <= 0)
{ {
CIN_StopCinematic (); cin->cinematictime = realtime;
return false; cin->cinematicframe = -1;
} }
if (cin.cinematictime-3 > realtime*1000) if (cin->cinematictime-3 > realtime*1000)
cin.cinematictime = realtime*1000; cin->cinematictime = realtime*1000;
/* if (key_dest != key_game) frame = (realtime*1000 - cin->cinematictime)*14/1000;
{ // pause if menu or console is up if (frame <= cin->cinematicframe)
cin.cinematictime = realtime - cin.cinematicframe*1000/14;
return true;
}*/
frame = (realtime*1000 - cin.cinematictime)*14/1000;
if (frame <= cin.cinematicframe)
return true;
if (frame > cin.cinematicframe+1)
{ {
Con_Printf ("Dropped frame: %i > %i\n", frame, cin.cinematicframe+1); *outdata = cin->pic;
cin.cinematictime = realtime*1000 - cin.cinematicframe*1000/14; *outwidth = cin->width;
*outheight = cin->height;
*outpalette = cin->cinematicpalette;
return 2;
} }
if (cin.pic) if (frame > cin->cinematicframe+1)
Z_Free (cin.pic);
cin.pic = cin.pic_pending;
cin.pic_pending = NULL;
cin.pic_pending = CIN_ReadNextFrame ();
if (!cin.pic_pending)
{ {
CIN_StopCinematic (); Con_Printf ("Dropped frame: %i > %i\n", frame, cin->cinematicframe+1);
CIN_FinishCinematic (); cin->cinematictime = realtime*1000 - cin->cinematicframe*1000/14;
cin.cinematictime = 1; // hack to get the black screen behind loading }
SCR_BeginLoadingPlaque (); if (cin->pic)
cin.cinematictime = 0; Z_Free (cin->pic);
return false; cin->pic = CIN_ReadNextFrame (cin);
if (!cin->pic)
{
return 0;
} }
return true; *outdata = cin->pic;
*outwidth = cin->width;
*outheight = cin->height;
*outpalette = cin->cinematicpalette;
return 1;
} }
/* /*
@ -441,9 +405,10 @@ Returns true if a cinematic is active, meaning the view rendering
should be skipped should be skipped
================== ==================
*/ */
/*
qboolean CIN_DrawCinematic (void) qboolean CIN_DrawCinematic (void)
{ {
if (cin.cinematictime <= 0) if (cin->cinematictime <= 0)
{ {
return false; return false;
} }
@ -472,6 +437,7 @@ qboolean CIN_DrawCinematic (void)
return true; return true;
} }
*/
/* /*
================== ==================
@ -479,67 +445,54 @@ SCR_PlayCinematic
================== ==================
*/ */
qboolean CIN_PlayCinematic (char *arg) cinematics_t *CIN_PlayCinematic (char *arg)
{ {
int width, height; int width, height;
char name[MAX_OSPATH]; char name[MAX_OSPATH];
// int old_khz; // int old_khz;
vfsfile_t *file;
// make sure CD isn't playing music cinematics_t *cin = NULL;
CDAudio_Stop();
cin.cinematicframe = 0; file = FS_OpenVFS(arg, "rb", FS_GAME);
cin.cinematic_file = FS_OpenVFS(arg, "rb", FS_GAME); if (!file)
if (!cin.cinematic_file)
{ {
snprintf (name, sizeof(name), "video/%s", arg); snprintf (name, sizeof(name), "video/%s", arg);
cin.cinematic_file = FS_OpenVFS(name, "rb", FS_GAME); file = FS_OpenVFS(name, "rb", FS_GAME);
} }
if (!cin.cinematic_file) if (file)
cin = Z_Malloc(sizeof(*cin));
if (cin)
{ {
// Com_Error (ERR_DROP, "Cinematic %s not found.\n", name); cin->cinematicframe = 0;
cin->cinematic_file = file;
CIN_FinishCinematic (); VFS_READ (cin->cinematic_file, &width, 4);
VFS_READ (cin->cinematic_file, &height, 4);
cin->width = LittleLong(width);
cin->height = LittleLong(height);
cin.cinematictime = 0; // done VFS_READ (cin->cinematic_file, &cin->s_rate, 4);
cin->s_rate = LittleLong(cin->s_rate);
VFS_READ (cin->cinematic_file, &cin->s_width, 4);
cin->s_width = LittleLong(cin->s_width);
VFS_READ (cin->cinematic_file, &cin->s_channels, 4);
cin->s_channels = LittleLong(cin->s_channels);
Huff1TableInit (cin);
cin->cinematicframe = 0;
cin->pic = CIN_ReadNextFrame (cin);
cin->cinematictime = Sys_DoubleTime ()*1000+0.001;
}
else
{
cin->cinematictime = 0; // done
Con_Printf(CON_WARNING "Cinematic %s not found.\n", name); Con_Printf(CON_WARNING "Cinematic %s not found.\n", name);
return true;
} }
return cin;
SCR_EndLoadingPlaque ();
VFS_READ (cin.cinematic_file, &width, 4);
VFS_READ (cin.cinematic_file, &height, 4);
cin.width = LittleLong(width);
cin.height = LittleLong(height);
VFS_READ (cin.cinematic_file, &cin.s_rate, 4);
cin.s_rate = LittleLong(cin.s_rate);
VFS_READ (cin.cinematic_file, &cin.s_width, 4);
cin.s_width = LittleLong(cin.s_width);
VFS_READ (cin.cinematic_file, &cin.s_channels, 4);
cin.s_channels = LittleLong(cin.s_channels);
Huff1TableInit ();
// switch up to 22 khz sound if necessary
/*old_khz = Cvar_VariableValue ("snd_khz");
if (old_khz != cin.s_rate/1000)
{
cin.restart_sound = true;
Cvar_SetValue ("snd_khz", cin.s_rate/1000);
S_Restart_f ();
Cvar_SetValue ("snd_khz", old_khz);
}*/
cin.cinematicframe = 0;
cin.pic = CIN_ReadNextFrame ();
cin.cinematictime = Sys_DoubleTime ()*1000+0.001;
return true;
} }
#endif #endif

View file

@ -880,7 +880,8 @@ void CLQ3_SendCmd(usercmd_t *cmd)
CLQ3_SendClientCommand("userinfo \"%s\"", cls.userinfo); CLQ3_SendClientCommand("userinfo \"%s\"", cls.userinfo);
} }
cl.gametime = ccs.serverTime = ccs.snap.serverTime + (Sys_Milliseconds()-ccs.snap.localTime); ccs.serverTime = ccs.snap.serverTime + (Sys_Milliseconds()-ccs.snap.localTime);
cl.servertime = ccs.serverTime / 1000.0f;
//reuse the q1 array //reuse the q1 array
cmd->servertime = ccs.serverTime; cmd->servertime = ccs.serverTime;

View file

@ -569,23 +569,6 @@ void Con_PrintCon (console_t *con, char *txt)
cr = true; cr = true;
break; break;
case '\n': case '\n':
#pragma message("Really inefficient consistancy checking, with no side effects other than sys_errors")
{
conline_t *cl;
cl = con->oldest;
if (cl->older)
Sys_Error("older?\n");
while(cl->newer)
{
if (cl->newer->older != cl)
Sys_Error("bad backlink\n");
cl = cl->newer;
}
if (cl != con->current)
Sys_Error("not newest?\n");
}
cr = false; cr = false;
while (con->linecount >= con_maxlines.value) while (con->linecount >= con_maxlines.value)
{ {
@ -1416,7 +1399,13 @@ void Con_DrawConsole (int lines, qboolean noback)
if (!haveprogress && lines == vid.height) if (!haveprogress && lines == vid.height)
{ {
char *version = va(DISTRIBUTION " Quake %i", build_number()); #ifdef SVNREVISION
#define STRINGIFY2(arg) #arg
#define STRINGIFY(arg) STRINGIFY2(arg)
char *version = va(DISTRIBUTION " Quake B%i" IFMINIMAL("m","") " (R%s)\n", build_number(), STRINGIFY(SVNREVISION));
#else
char *version = va(DISTRIBUTION " Quake %i" IFMINIMAL("m",""), build_number());
#endif
int i; int i;
Font_BeginString(font_conchar, vid.width, lines, &x, &y); Font_BeginString(font_conchar, vid.width, lines, &x, &y);
y -= Font_CharHeight(); y -= Font_CharHeight();

View file

@ -57,8 +57,8 @@ qboolean deltaused[K_MAX][KEY_MODIFIERSTATES];
void Con_Selectioncolour_Callback(struct cvar_s *var, char *oldvalue); void Con_Selectioncolour_Callback(struct cvar_s *var, char *oldvalue);
extern cvar_t con_displaypossibilities; extern cvar_t con_displaypossibilities;
cvar_t con_selectioncolour = SCVARFC("con_selectioncolour", "0", CVAR_RENDERERCALLBACK, Con_Selectioncolour_Callback); cvar_t con_selectioncolour = CVARFC("con_selectioncolour", "0", CVAR_RENDERERCALLBACK, Con_Selectioncolour_Callback);
cvar_t con_echochat = SCVAR("con_echochat", "0"); cvar_t con_echochat = CVAR("con_echochat", "0");
extern cvar_t cl_chatmode; extern cvar_t cl_chatmode;
static int KeyModifier (qboolean shift, qboolean alt, qboolean ctrl) static int KeyModifier (qboolean shift, qboolean alt, qboolean ctrl)

View file

@ -205,7 +205,7 @@ void MenuTooltipSplit(menu_t *menu, const char *text)
return; return;
// calc a line maximum, use a third of the screen or 30 characters, whichever is bigger // calc a line maximum, use a third of the screen or 30 characters, whichever is bigger
lnmax = (vid.width / 24) - 2; lnmax = (vid.width / 24) - 2;
if (lnmax < 30) if (lnmax < 30)
lnmax = 30; lnmax = 30;
// word wrap // word wrap
@ -329,12 +329,18 @@ qboolean MI_Selectable(menuoption_t *op)
void MenuDrawItems(int xpos, int ypos, menuoption_t *option, menu_t *menu) void MenuDrawItems(int xpos, int ypos, menuoption_t *option, menu_t *menu)
{ {
int i; int i;
mpic_t *p; mpic_t *p;
int mgt;
mgt = M_GameType();
while (option) while (option)
{ {
if (mousemoved && !bindingactive) if (mousemoved && !bindingactive)
{ {
if (omousex > xpos+option->common.posx && omousex < xpos+option->common.posx+option->common.width) if (omousex > xpos+option->common.posx && omousex < xpos+option->common.posx+option->common.width)
{
if (omousey > ypos+option->common.posy && omousey < ypos+option->common.posy+option->common.height) if (omousey > ypos+option->common.posy && omousey < ypos+option->common.posy+option->common.height)
{ {
if (MI_Selectable(option)) if (MI_Selectable(option))
@ -342,7 +348,13 @@ void MenuDrawItems(int xpos, int ypos, menuoption_t *option, menu_t *menu)
if (menu->selecteditem != option) if (menu->selecteditem != option)
{ {
if (!option->common.noselectionsound) if (!option->common.noselectionsound)
S_LocalSound ("misc/menu1.wav"); {
if (mgt == MGT_HEXEN2)
S_LocalSound ("raven/menu1.wav");
else
S_LocalSound ("misc/menu1.wav");
}
menu->selecteditem = option; menu->selecteditem = option;
menu->tooltiptime = realtime + 1; menu->tooltiptime = realtime + 1;
MenuTooltipSplit(menu, menu->selecteditem->common.tooltip); MenuTooltipSplit(menu, menu->selecteditem->common.tooltip);
@ -351,6 +363,7 @@ void MenuDrawItems(int xpos, int ypos, menuoption_t *option, menu_t *menu)
menu->cursoritem->common.posy = menu->selecteditem->common.posy; menu->cursoritem->common.posy = menu->selecteditem->common.posy;
} }
} }
}
} }
if (!option->common.ishidden) if (!option->common.ishidden)
switch(option->common.type) switch(option->common.type)
@ -396,7 +409,7 @@ void MenuDrawItems(int xpos, int ypos, menuoption_t *option, menu_t *menu)
if (!p) if (!p)
p = Draw_SafeCachePic(option->picture.picturename); p = Draw_SafeCachePic(option->picture.picturename);
Draw_ScalePic(xpos+option->common.posx, ypos+option->common.posy, option->common.width, option->common.height, p); Draw_ScalePic(xpos+option->common.posx, ypos+option->common.posy, option->common.width?option->common.width:p->width, option->common.height?option->common.height:p->height, p);
break; break;
case mt_picture: case mt_picture:
p = Draw_SafeCachePic(option->picture.picturename); p = Draw_SafeCachePic(option->picture.picturename);
@ -524,9 +537,9 @@ void MenuDrawItems(int xpos, int ypos, menuoption_t *option, menu_t *menu)
x += strlen(option->bind.caption)*8+28; x += strlen(option->bind.caption)*8+28;
{ {
l = strlen (option->bind.command); l = strlen (option->bind.command);
M_FindKeysForCommand (option->bind.command, keys); M_FindKeysForCommand (option->bind.command, keys);
if (bindingactive && menu->selecteditem == option) if (bindingactive && menu->selecteditem == option)
{ {
Draw_FunString (x, y, "Press key"); Draw_FunString (x, y, "Press key");
@ -625,7 +638,7 @@ menutext_t *MC_AddWhiteText(menu_t *menu, int x, int y, const char *text, qboole
{ {
menutext_t *n = Z_Malloc(sizeof(menutext_t)); menutext_t *n = Z_Malloc(sizeof(menutext_t));
n->common.type = mt_text; n->common.type = mt_text;
n->common.iszone = true; n->common.iszone = true;
n->common.posx = x; n->common.posx = x;
n->common.posy = y; n->common.posy = y;
n->text = text; n->text = text;
@ -642,7 +655,7 @@ menutext_t *MC_AddBufferedText(menu_t *menu, int x, int y, const char *text, qbo
{ {
menutext_t *n = Z_Malloc(sizeof(menutext_t) + strlen(text)+1); menutext_t *n = Z_Malloc(sizeof(menutext_t) + strlen(text)+1);
n->common.type = mt_text; n->common.type = mt_text;
n->common.iszone = true; n->common.iszone = true;
n->common.posx = x; n->common.posx = x;
n->common.posy = y; n->common.posy = y;
n->text = (char *)(n+1); n->text = (char *)(n+1);
@ -669,7 +682,7 @@ menubind_t *MC_AddBind(menu_t *menu, int x, int y, const char *caption, char *co
{ {
menubind_t *n = Z_Malloc(sizeof(menutext_t) + strlen(caption)+1 + strlen(command)+1); menubind_t *n = Z_Malloc(sizeof(menutext_t) + strlen(caption)+1 + strlen(command)+1);
n->common.type = mt_bind; n->common.type = mt_bind;
n->common.iszone = true; n->common.iszone = true;
n->common.posx = x; n->common.posx = x;
n->common.posy = y; n->common.posy = y;
n->caption = (char *)(n+1); n->caption = (char *)(n+1);
@ -800,7 +813,7 @@ menuedit_t *MC_AddEdit(menu_t *menu, int x, int y, char *text, char *def)
{ {
menuedit_t *n = Z_Malloc(sizeof(menuedit_t)); menuedit_t *n = Z_Malloc(sizeof(menuedit_t));
n->common.type = mt_edit; n->common.type = mt_edit;
n->common.iszone = true; n->common.iszone = true;
n->common.posx = x; n->common.posx = x;
n->common.posy = y; n->common.posy = y;
n->modified = true; n->modified = true;
@ -818,11 +831,12 @@ menuedit_t *MC_AddEditCvar(menu_t *menu, int x, int y, char *text, char *name)
cvar_t *cvar; cvar_t *cvar;
cvar = Cvar_Get(name, "", CVAR_USERCREATED|CVAR_ARCHIVE, NULL); //well, this is a menu/ cvar = Cvar_Get(name, "", CVAR_USERCREATED|CVAR_ARCHIVE, NULL); //well, this is a menu/
n->common.type = mt_edit; n->common.type = mt_edit;
n->common.iszone = true; n->common.iszone = true;
n->common.posx = x; n->common.posx = x;
n->common.posy = y; n->common.posy = y;
n->common.width = (strlen(text)+17)*8; n->common.width = (strlen(text)+17)*8;
n->common.height = 8; n->common.height = 8;
n->common.tooltip = cvar->description;
n->modified = true; n->modified = true;
n->caption = (char *)(n+1); n->caption = (char *)(n+1);
strcpy((char *)(n+1), text); strcpy((char *)(n+1), text);
@ -869,19 +883,24 @@ menucheck_t *MC_AddCheckBox(menu_t *menu, int x, int y, const char *text, cvar_t
{ {
menucheck_t *n = Z_Malloc(sizeof(menucheck_t)+strlen(text)+1); menucheck_t *n = Z_Malloc(sizeof(menucheck_t)+strlen(text)+1);
n->common.type = mt_checkbox; n->common.type = mt_checkbox;
n->common.iszone = true; n->common.iszone = true;
n->common.posx = x; n->common.posx = x;
n->common.posy = y; n->common.posy = y;
n->common.height = 8; n->common.height = 8;
n->common.width = (strlen(text)+7)*8; n->common.width = (strlen(text)+7)*8;
n->common.tooltip = var?var->description:NULL;
n->text = (char *)(n+1); n->text = (char *)(n+1);
strcpy((char *)(n+1), text); strcpy((char *)(n+1), text);
n->var = var; n->var = var;
n->bits = bits; n->bits = bits;
#ifdef _DEBUG
if (var) if (var)
if (!(var->flags & CVAR_ARCHIVE)) if (!(var->flags & CVAR_ARCHIVE))
Con_Printf("Warning: %s is not set for archiving\n", var->name); Con_Printf("Warning: %s is not set for archiving\n", var->name);
else if (var->flags & CVAR_RENDERERLATCH)
Con_Printf("Warning: %s requires a vid_restart\n", var->name);
#endif
n->common.next = menu->options; n->common.next = menu->options;
menu->options = (menuoption_t *)n; menu->options = (menuoption_t *)n;
@ -891,7 +910,7 @@ menucheck_t *MC_AddCheckBoxFunc(menu_t *menu, int x, int y, const char *text, qb
{ {
menucheck_t *n = Z_Malloc(sizeof(menucheck_t)+strlen(text)+1); menucheck_t *n = Z_Malloc(sizeof(menucheck_t)+strlen(text)+1);
n->common.type = mt_checkbox; n->common.type = mt_checkbox;
n->common.iszone = true; n->common.iszone = true;
n->common.posx = x; n->common.posx = x;
n->common.posy = y; n->common.posy = y;
n->common.height = 8; n->common.height = 8;
@ -908,14 +927,15 @@ menucheck_t *MC_AddCheckBoxFunc(menu_t *menu, int x, int y, const char *text, qb
//delta may be 0 //delta may be 0
menuslider_t *MC_AddSlider(menu_t *menu, int x, int y, const char *text, cvar_t *var, float min, float max, float delta) menuslider_t *MC_AddSlider(menu_t *menu, int x, int y, const char *text, cvar_t *var, float min, float max, float delta)
{ {
menuslider_t *n = Z_Malloc(sizeof(menuslider_t)+strlen(text)+1); menuslider_t *n = Z_Malloc(sizeof(menuslider_t)+strlen(text)+1);
n->common.type = mt_slider; n->common.type = mt_slider;
n->common.iszone = true; n->common.iszone = true;
n->common.posx = x; n->common.posx = x;
n->common.posy = y; n->common.posy = y;
n->common.height = 8; n->common.height = 8;
n->common.width = (strlen(text)+SLIDER_RANGE+5)*8; n->common.width = (strlen(text)+SLIDER_RANGE+5)*8;
n->common.tooltip = var->description;
n->var = var; n->var = var;
n->text = (char *)(n+1); n->text = (char *)(n+1);
strcpy((char *)(n+1), text); strcpy((char *)(n+1), text);
@ -924,8 +944,10 @@ menuslider_t *MC_AddSlider(menu_t *menu, int x, int y, const char *text, cvar_t
{ {
n->current = var->value; n->current = var->value;
#ifdef _DEBUG
if (!(var->flags & CVAR_ARCHIVE)) if (!(var->flags & CVAR_ARCHIVE))
Con_Printf("Warning: %s is not set for archiving\n", var->name); Con_Printf("Warning: %s is not set for archiving\n", var->name);
#endif
} }
n->min = min; n->min = min;
@ -962,15 +984,15 @@ menucombo_t *MC_AddCombo(menu_t *menu, int x, int y, const char *caption, const
optbufsize += optlen+1+sizeof(char*); optbufsize += optlen+1+sizeof(char*);
numopts++; numopts++;
} }
n = Z_Malloc(sizeof(*n) + optbufsize); n = Z_Malloc(sizeof(*n) + optbufsize);
newops = (char **)(n+1); newops = (char **)(n+1);
optbuf = (char*)(newops + numopts+1); optbuf = (char*)(newops + numopts+1);
n->common.type = mt_combo; n->common.type = mt_combo;
n->common.iszone = true; n->common.iszone = true;
n->common.posx = x; n->common.posx = x;
n->common.posy = y; n->common.posy = y;
n->common.height = 8; n->common.height = 8;
n->common.width = strlen(caption)*8 + maxoptlen*8; n->common.width = strlen(caption)*8 + maxoptlen*8;
n->caption = caption; n->caption = caption;
@ -988,7 +1010,7 @@ menucombo_t *MC_AddCombo(menu_t *menu, int x, int y, const char *caption, const
} }
newops[i] = NULL; newops[i] = NULL;
if (initialvalue >= n->numoptions) if (initialvalue >= n->numoptions)
{ {
Con_Printf("WARNING: Fixed initialvalue for %s\n", caption); Con_Printf("WARNING: Fixed initialvalue for %s\n", caption);
initialvalue = n->numoptions-1; initialvalue = n->numoptions-1;
@ -1022,19 +1044,20 @@ menucombo_t *MC_AddCvarCombo(menu_t *menu, int x, int y, const char *caption, cv
optbufsize += strlen(values[numopts])+1+sizeof(char*); optbufsize += strlen(values[numopts])+1+sizeof(char*);
numopts++; numopts++;
} }
n = Z_Malloc(sizeof(*n) + optbufsize); n = Z_Malloc(sizeof(*n) + optbufsize);
newops = (char **)(n+1); newops = (char **)(n+1);
newvalues = (char**)(newops + numopts+1); newvalues = (char**)(newops + numopts+1);
optbuf = (char*)(newvalues + numopts+1); optbuf = (char*)(newvalues + numopts+1);
n->common.type = mt_combo; n->common.type = mt_combo;
n->common.iszone = true; n->common.iszone = true;
n->common.posx = x; n->common.posx = x;
n->common.posy = y; n->common.posy = y;
n->common.height = 8; n->common.height = 8;
n->common.width = strlen(caption)*8 + maxoptlen*8; n->common.width = strlen(caption)*8 + maxoptlen*8;
n->common.tooltip = cvar->description;
strcpy(optbuf, caption); strcpy(optbuf, caption);
n->caption = optbuf; n->caption = optbuf;
@ -1076,7 +1099,7 @@ menubutton_t *MC_AddConsoleCommand(menu_t *menu, int x, int y, const char *text,
{ {
menubutton_t *n = Z_Malloc(sizeof(menubutton_t)+strlen(text)+1+strlen(command)+1); menubutton_t *n = Z_Malloc(sizeof(menubutton_t)+strlen(text)+1+strlen(command)+1);
n->common.type = mt_button; n->common.type = mt_button;
n->common.iszone = true; n->common.iszone = true;
n->common.posx = x; n->common.posx = x;
n->common.posy = y; n->common.posy = y;
n->common.height = 8; n->common.height = 8;
@ -1095,7 +1118,7 @@ menubutton_t *MC_AddConsoleCommandQBigFont(menu_t *menu, int x, int y, const cha
{ {
menubutton_t *n = Z_Malloc(sizeof(menubutton_t)+strlen(text)+1+strlen(command)+1); menubutton_t *n = Z_Malloc(sizeof(menubutton_t)+strlen(text)+1+strlen(command)+1);
n->common.type = mt_qbuttonbigfont; n->common.type = mt_qbuttonbigfont;
n->common.iszone = true; n->common.iszone = true;
n->common.posx = x; n->common.posx = x;
n->common.posy = y; n->common.posy = y;
n->common.height = 20; n->common.height = 20;
@ -1113,7 +1136,7 @@ menubutton_t *MC_AddConsoleCommandHexen2BigFont(menu_t *menu, int x, int y, cons
{ {
menubutton_t *n = Z_Malloc(sizeof(menubutton_t)+strlen(text)+1+strlen(command)+1); menubutton_t *n = Z_Malloc(sizeof(menubutton_t)+strlen(text)+1+strlen(command)+1);
n->common.type = mt_hexen2buttonbigfont; n->common.type = mt_hexen2buttonbigfont;
n->common.iszone = true; n->common.iszone = true;
n->common.posx = x; n->common.posx = x;
n->common.posy = y; n->common.posy = y;
n->common.height = 8; n->common.height = 8;
@ -1132,7 +1155,7 @@ menubutton_t *MC_AddCommand(menu_t *menu, int x, int y, char *text, qboolean (*c
{ {
menubutton_t *n = Z_Malloc(sizeof(menubutton_t)); menubutton_t *n = Z_Malloc(sizeof(menubutton_t));
n->common.type = mt_button; n->common.type = mt_button;
n->common.iszone = true; n->common.iszone = true;
n->common.posx = x; n->common.posx = x;
n->common.posy = y; n->common.posy = y;
n->text = text; n->text = text;
@ -1151,17 +1174,17 @@ menubutton_t *VARGS MC_AddConsoleCommandf(menu_t *menu, int x, int y, const char
va_list argptr; va_list argptr;
static char string[1024]; static char string[1024];
menubutton_t *n; menubutton_t *n;
va_start (argptr, command); va_start (argptr, command);
vsnprintf (string,sizeof(string)-1, command,argptr); vsnprintf (string,sizeof(string)-1, command,argptr);
va_end (argptr); va_end (argptr);
n = Z_Malloc(sizeof(menubutton_t) + strlen(string)+1); n = Z_Malloc(sizeof(menubutton_t) + strlen(string)+1);
n->common.type = mt_button; n->common.type = mt_button;
n->common.iszone = true; n->common.iszone = true;
n->common.posx = x; n->common.posx = x;
n->common.posy = y; n->common.posy = y;
n->text = text; n->text = text;
n->command = (char *)(n+1); n->command = (char *)(n+1);
strcpy((char *)(n+1), string); strcpy((char *)(n+1), string);
@ -1368,7 +1391,7 @@ void M_HideMenu (menu_t *menu)
} }
} }
void M_RemoveMenu (menu_t *menu) void M_RemoveMenu (menu_t *menu)
{ {
menuoption_t *op, *oop; menuoption_t *op, *oop;
if (menu->remove) if (menu->remove)
menu->remove(menu); menu->remove(menu);
@ -1499,7 +1522,7 @@ menuoption_t *M_NextSelectableItem(menu_t *m, menuoption_t *old)
if (!old) if (!old)
old = M_NextItem(m, old); old = M_NextItem(m, old);
op = old; op = old;
while (1) while (1)
@ -1526,11 +1549,11 @@ menuoption_t *M_NextSelectableItem(menu_t *m, menuoption_t *old)
menuoption_t *M_PrevSelectableItem(menu_t *m, menuoption_t *old) menuoption_t *M_PrevSelectableItem(menu_t *m, menuoption_t *old)
{ {
menuoption_t *op; menuoption_t *op;
if (!old) if (!old)
old = currentmenu->options; old = currentmenu->options;
op = old; op = old;
while (1) while (1)
@ -1553,9 +1576,12 @@ menuoption_t *M_PrevSelectableItem(menu_t *m, menuoption_t *old)
void M_Complex_Key(int key, int unicode) void M_Complex_Key(int key, int unicode)
{ {
int mgt;
mgt = M_GameType();
if (!currentmenu) if (!currentmenu)
return; //erm... return; //erm...
if (currentmenu->key) if (currentmenu->key)
if (currentmenu->key(key, currentmenu)) if (currentmenu->key(key, currentmenu))
return; return;
@ -1569,7 +1595,10 @@ void M_Complex_Key(int key, int unicode)
{ {
if (bindingactive) if (bindingactive)
{ {
S_LocalSound ("misc/menu1.wav"); if (mgt == MGT_HEXEN2)
S_LocalSound ("raven/menu1.wav");
else
S_LocalSound ("misc/menu1.wav");
if (key != K_ESCAPE && key != '`') if (key != K_ESCAPE && key != '`')
{ {
@ -1579,22 +1608,29 @@ void M_Complex_Key(int key, int unicode)
return; return;
} }
} }
switch(key) switch(key)
{ {
case K_MOUSE2: case K_MOUSE2:
case K_ESCAPE: case K_ESCAPE:
//remove //remove
M_RemoveMenu(currentmenu); M_RemoveMenu(currentmenu);
S_LocalSound ("misc/menu3.wav"); if (mgt == MGT_HEXEN2)
S_LocalSound ("raven/menu3.wav");
else
S_LocalSound ("misc/menu3.wav");
break; break;
case K_TAB: case K_TAB:
case K_DOWNARROW: case K_DOWNARROW:
currentmenu->selecteditem = M_NextSelectableItem(currentmenu, currentmenu->selecteditem); currentmenu->selecteditem = M_NextSelectableItem(currentmenu, currentmenu->selecteditem);
if (currentmenu->selecteditem) if (currentmenu->selecteditem)
{ {
S_LocalSound ("misc/menu1.wav"); if (mgt == MGT_HEXEN2)
S_LocalSound ("raven/menu1.wav");
else
S_LocalSound ("misc/menu1.wav");
if (currentmenu->cursoritem) if (currentmenu->cursoritem)
currentmenu->cursoritem->common.posy = currentmenu->selecteditem->common.posy; currentmenu->cursoritem->common.posy = currentmenu->selecteditem->common.posy;
} }
@ -1602,9 +1638,13 @@ void M_Complex_Key(int key, int unicode)
case K_UPARROW: case K_UPARROW:
currentmenu->selecteditem = M_PrevSelectableItem(currentmenu, currentmenu->selecteditem); currentmenu->selecteditem = M_PrevSelectableItem(currentmenu, currentmenu->selecteditem);
if (currentmenu->selecteditem) if (currentmenu->selecteditem)
{ {
S_LocalSound ("misc/menu1.wav"); if (mgt == MGT_HEXEN2)
S_LocalSound ("raven/menu1.wav");
else
S_LocalSound ("misc/menu1.wav");
if (currentmenu->cursoritem) if (currentmenu->cursoritem)
currentmenu->cursoritem->common.posy = currentmenu->selecteditem->common.posy; currentmenu->cursoritem->common.posy = currentmenu->selecteditem->common.posy;
} }
@ -1632,7 +1672,10 @@ void M_Complex_Key(int key, int unicode)
else if (key == K_ENTER || key == K_MOUSE1) else if (key == K_ENTER || key == K_MOUSE1)
{ {
Cbuf_AddText(currentmenu->selecteditem->button.command, RESTRICT_LOCAL); Cbuf_AddText(currentmenu->selecteditem->button.command, RESTRICT_LOCAL);
S_LocalSound ("misc/menu2.wav"); if (mgt == MGT_HEXEN2)
S_LocalSound ("raven/menu2.wav");
else
S_LocalSound ("misc/menu2.wav");
} }
break; break;
case mt_custom: case mt_custom:
@ -1675,7 +1718,7 @@ qboolean MC_GuiKey(int key, menu_t *menu)
guiinfo_t *info = (guiinfo_t *)menu->data; guiinfo_t *info = (guiinfo_t *)menu->data;
switch(key) switch(key)
{ {
case K_ESCAPE: case K_ESCAPE:
if (info->dropout) if (info->dropout)
MC_GuiKey(key, info->dropout); MC_GuiKey(key, info->dropout);
else else
@ -1715,7 +1758,7 @@ qboolean MC_GuiKey(int key, menu_t *menu)
gui->text[1] = "Hello again"; gui->text[1] = "Hello again";
gui->text[2] = "Hello yet again"; gui->text[2] = "Hello yet again";
for (y = 0, i = 0; gui->text[i]; i++, y+=1*8) for (y = 0, i = 0; gui->text[i]; i++, y+=1*8)
{ {
info->op[i] = MC_AddRedText(info->dropout, 0, y, gui->text[i], false); info->op[i] = MC_AddRedText(info->dropout, 0, y, gui->text[i], false);
} }
} }
@ -1798,7 +1841,7 @@ void M_Menu_Main_f (void)
mainm = M_CreateMenu(sizeof(guiinfo_t)); mainm = M_CreateMenu(sizeof(guiinfo_t));
mainm->key = MC_GuiKey; mainm->key = MC_GuiKey;
mainm->xpos=0; mainm->xpos=0;
gui = (guiinfo_t *)mainm->data; gui = (guiinfo_t *)mainm->data;
gui->text[0] = "Single"; gui->text[0] = "Single";
gui->text[1] = "Multiplayer"; gui->text[1] = "Multiplayer";
gui->text[2] = "Quit"; gui->text[2] = "Quit";
@ -1806,7 +1849,7 @@ void M_Menu_Main_f (void)
{ {
gui->op[i] = MC_AddRedText(mainm, x, 0, gui->text[i], false); gui->op[i] = MC_AddRedText(mainm, x, 0, gui->text[i], false);
x+=(strlen(gui->text[i])+1)*8; x+=(strlen(gui->text[i])+1)*8;
} }
return; return;
} }
*/ */
@ -1817,12 +1860,12 @@ void M_Menu_Main_f (void)
if (mgt == MGT_QUAKE2) //quake2 main menu. if (mgt == MGT_QUAKE2) //quake2 main menu.
{ {
if (Draw_SafeCachePic("pics/m_main_game")) if (Draw_SafeCachePic("pics/m_main_game"))
{ {
m_state = m_complex; m_state = m_complex;
key_dest = key_menu; key_dest = key_menu;
mainm = M_CreateMenu(0); mainm = M_CreateMenu(0);
mainm->key = MC_Main_Key; mainm->key = MC_Main_Key;
MC_AddPicture(mainm, 0, 4, 38, 166, "pics/m_main_plaque"); MC_AddPicture(mainm, 0, 4, 38, 166, "pics/m_main_plaque");
p = Draw_SafeCachePic("pics/m_main_logo"); p = Draw_SafeCachePic("pics/m_main_logo");
@ -1867,8 +1910,8 @@ void M_Menu_Main_f (void)
{ {
m_state = m_complex; m_state = m_complex;
key_dest = key_menu; key_dest = key_menu;
mainm = M_CreateMenu(0); mainm = M_CreateMenu(0);
mainm->key = MC_Main_Key; mainm->key = MC_Main_Key;
MC_AddPicture(mainm, 16, 0, 35, 176, "gfx/menu/hplaque.lmp"); MC_AddPicture(mainm, 16, 0, 35, 176, "gfx/menu/hplaque.lmp");
p = Draw_SafeCachePic("gfx/menu/title0.lmp"); p = Draw_SafeCachePic("gfx/menu/title0.lmp");
@ -1901,7 +1944,7 @@ void M_Menu_Main_f (void)
{ {
m_state = m_complex; m_state = m_complex;
key_dest = key_menu; key_dest = key_menu;
mainm = M_CreateMenu(0); mainm = M_CreateMenu(0);
p = Draw_SafeCachePic("gfx/ttl_main.lmp"); p = Draw_SafeCachePic("gfx/ttl_main.lmp");
if (!p) if (!p)
@ -1935,7 +1978,7 @@ void M_Menu_Main_f (void)
{ {
m_state = m_complex; m_state = m_complex;
key_dest = key_menu; key_dest = key_menu;
mainm = M_CreateMenu(0); mainm = M_CreateMenu(0);
p = Draw_SafeCachePic("gfx/ttl_main.lmp"); p = Draw_SafeCachePic("gfx/ttl_main.lmp");
if (!p) if (!p)

View file

@ -801,12 +801,14 @@ struct cin_s {
qbyte *outdata; qbyte *outdata;
qbyte *outpalette; qbyte *outpalette;
int outunchanged; int outunchanged;
qboolean ended;
texid_t texture; texid_t texture;
qboolean (*decodeframe)(cin_t *cin, qboolean nosound); qboolean (*decodeframe)(cin_t *cin, qboolean nosound);
void (*doneframe)(cin_t *cin); void (*doneframe)(cin_t *cin);
void (*shutdown)(cin_t *cin); //warning: don't free cin_t void (*shutdown)(cin_t *cin); //warning: doesn't free cin_t
void (*rewind)(cin_t *cin);
//these are any interactivity functions you might want... //these are any interactivity functions you might want...
void (*cursormove) (struct cin_s *cin, float posx, float posy); //pos is 0-1 void (*cursormove) (struct cin_s *cin, float posx, float posy); //pos is 0-1
void (*key) (struct cin_s *cin, int code, int unicode, int event); void (*key) (struct cin_s *cin, int code, int unicode, int event);
@ -856,6 +858,10 @@ struct cin_s {
roq_info *roqfilm; roq_info *roqfilm;
} roq; } roq;
struct {
struct cinematics_s *cin;
} q2cin;
float filmstarttime; float filmstarttime;
float nextframetime; float nextframetime;
float filmlasttime; float filmlasttime;
@ -864,7 +870,7 @@ struct cin_s {
qbyte *framedata; //Z_Malloced buffer qbyte *framedata; //Z_Malloced buffer
}; };
cin_t *fullscreenvid; shader_t *videoshader;
////////////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////////////
//AVI Support (windows) //AVI Support (windows)
@ -1159,6 +1165,7 @@ qboolean Media_Roq_DecodeFrame (cin_t *cin, qboolean nosound)
} }
else else
{ {
cin->ended = true;
cin->roq.roqfilm->frame_num = 0; cin->roq.roqfilm->frame_num = 0;
cin->roq.roqfilm->aud_pos = cin->roq.roqfilm->roq_start; cin->roq.roqfilm->aud_pos = cin->roq.roqfilm->roq_start;
cin->roq.roqfilm->vid_pos = cin->roq.roqfilm->roq_start; cin->roq.roqfilm->vid_pos = cin->roq.roqfilm->roq_start;
@ -1275,33 +1282,44 @@ cin_t *Media_Static_TryLoad(char *name)
#ifdef Q2CLIENT #ifdef Q2CLIENT
void Media_Cin_Shutdown(struct cin_s *cin) void Media_Cin_Shutdown(struct cin_s *cin)
{ {
CIN_FinishCinematic(); CIN_StopCinematic(cin->q2cin.cin);
} }
qboolean Media_Cin_DecodeFrame(cin_t *cin, qboolean nosound) qboolean Media_Cin_DecodeFrame(cin_t *cin, qboolean nosound)
{ {
//FIXME! cin->outunchanged = cin->outdata!=NULL;
if (CIN_RunCinematic()) switch (CIN_RunCinematic(cin->q2cin.cin, &cin->outdata, &cin->outwidth, &cin->outheight, &cin->outpalette))
{ {
CIN_DrawCinematic(); default:
return true; case 0:
cin->ended = true;
return cin->outdata!=NULL;
case 1:
cin->outunchanged = false;
return cin->outdata!=NULL;
case 2:
return cin->outdata!=NULL;
} }
return false;
} }
cin_t *Media_Cin_TryLoad(char *name) cin_t *Media_Cin_TryLoad(char *name)
{ {
struct cinematics_s *q2cin;
cin_t *cin; cin_t *cin;
char *dot = strrchr(name, '.'); char *dot = strrchr(name, '.');
if (dot && (!strcmp(dot, ".cin"))) if (dot && (!strcmp(dot, ".cin")))
{ {
if (CIN_PlayCinematic(name)) q2cin = CIN_PlayCinematic(name);
if (q2cin)
{ {
cin = Z_Malloc(sizeof(cin_t)); cin = Z_Malloc(sizeof(cin_t));
cin->q2cin.cin = q2cin;
cin->filmtype = MFT_CIN; cin->filmtype = MFT_CIN;
cin->decodeframe = Media_Cin_DecodeFrame; cin->decodeframe = Media_Cin_DecodeFrame;
cin->shutdown = Media_Cin_Shutdown; cin->shutdown = Media_Cin_Shutdown;
cin->outtype = TF_8PAL24;
return cin; return cin;
} }
} }
@ -1598,7 +1616,7 @@ cin_t *Media_Gecko_TryLoad(char *name)
qboolean Media_PlayingFullScreen(void) qboolean Media_PlayingFullScreen(void)
{ {
return fullscreenvid!=NULL; return videoshader!=NULL;
} }
void Media_ShutdownCin(cin_t *cin) void Media_ShutdownCin(cin_t *cin)
@ -1659,11 +1677,46 @@ qboolean Media_DecodeFrame(cin_t *cin, qboolean nosound)
qboolean Media_PlayFilm(char *name) qboolean Media_PlayFilm(char *name)
{ {
Media_ShutdownCin(fullscreenvid); cin_t *cin;
fullscreenvid = Media_StartCin(name); static char sname[MAX_QPATH];
if (fullscreenvid) if (videoshader)
{ {
R_UnloadShader(videoshader);
videoshader = NULL;
}
if (!*name)
{
if (cls.state == ca_active)
{
CL_SendClientCommand(true, "nextserver %i", cl.servercount);
}
S_RawAudio(0, NULL, 0, 0, 0, 0);
videoshader = NULL;
}
else
{
snprintf(sname, sizeof(sname), "cinematic/%s", name);
videoshader = R_RegisterCustom(sname, Shader_DefaultCinematic, sname+10);
cin = R_ShaderGetCinematic(videoshader);
if (cin)
{
cin->ended = false;
if (cin->rewind)
cin->rewind(cin);
}
}
// Media_ShutdownCin(fullscreenvid);
// fullscreenvid = Media_StartCin(name);
if (videoshader)
{
CDAudio_Stop();
SCR_EndLoadingPlaque();
Con_ClearNotify(); Con_ClearNotify();
if (key_dest == key_menu) if (key_dest == key_menu)
{ {
@ -1679,39 +1732,23 @@ qboolean Media_PlayFilm(char *name)
} }
qboolean Media_ShowFilm(void) qboolean Media_ShowFilm(void)
{ {
if (!fullscreenvid) if (videoshader)
return false;
if (!Media_DecodeFrame(fullscreenvid, false))
{ {
Media_ShutdownCin(fullscreenvid); cin_t *cin = R_ShaderGetCinematic(videoshader);
fullscreenvid = NULL; if (cin && cin->ended)
return false; Media_PlayFilm("");
else
{
Draw_ImageColours(1, 1, 1, 1);
Draw_ScalePic(0, 0, vid.width, vid.height, videoshader);
SCR_SetUpToDrawConsole();
if (scr_con_current)
SCR_DrawConsole (false);
return true;
}
} }
return false;
switch(fullscreenvid->outtype)
{
case TF_RGBA32:
if (Media_ShowFrameRGBA_32)
Media_ShowFrameRGBA_32(fullscreenvid->outdata, fullscreenvid->outwidth, fullscreenvid->outheight);
break;
case TF_TRANS8:
case TF_SOLID8:
Media_ShowFrame8bit(fullscreenvid->outdata, fullscreenvid->outwidth, fullscreenvid->outheight, fullscreenvid->outpalette);
break;
case TF_BGR24_FLIP:
Media_ShowFrameBGR_24_Flip(fullscreenvid->outdata, fullscreenvid->outwidth, fullscreenvid->outheight);
break;
case TF_BGRA32:
#pragma message("Media_ShowFilm: BGRA comes out as RGBA")
// Media_ShowFrameBGRA_32
Media_ShowFrameRGBA_32(fullscreenvid->outdata, fullscreenvid->outwidth, fullscreenvid->outheight);
break;
}
if (fullscreenvid->doneframe)
fullscreenvid->doneframe(fullscreenvid);
return true;
} }
#if defined(GLQUAKE) || defined(D3DQUAKE) #if defined(GLQUAKE) || defined(D3DQUAKE)
@ -1728,7 +1765,7 @@ texid_t Media_UpdateForShader(cin_t *cin)
{ {
if (!TEXVALID(cin->texture)) if (!TEXVALID(cin->texture))
cin->texture = R_AllocNewTexture(cin->outwidth, cin->outheight); cin->texture = R_AllocNewTexture(cin->outwidth, cin->outheight);
R_Upload(cin->texture, "cin", cin->outtype, cin->outdata, cin->outwidth, cin->outheight, IF_NOMIPMAP|IF_NOALPHA|IF_NOGAMMA); R_Upload(cin->texture, "cin", cin->outtype, cin->outdata, cin->outpalette, cin->outwidth, cin->outheight, IF_NOMIPMAP|IF_NOALPHA|IF_NOGAMMA);
} }
if (cin->doneframe) if (cin->doneframe)
@ -1742,7 +1779,7 @@ texid_t Media_UpdateForShader(cin_t *cin)
void Media_Send_Command(cin_t *cin, char *command) void Media_Send_Command(cin_t *cin, char *command)
{ {
if (!cin) if (!cin)
cin = fullscreenvid; cin = R_ShaderGetCinematic(videoshader);
if (!cin || !cin->key) if (!cin || !cin->key)
return; return;
cin->changestream(cin, command); cin->changestream(cin, command);
@ -1750,7 +1787,7 @@ void Media_Send_Command(cin_t *cin, char *command)
void Media_Send_KeyEvent(cin_t *cin, int button, int unicode, int event) void Media_Send_KeyEvent(cin_t *cin, int button, int unicode, int event)
{ {
if (!cin) if (!cin)
cin = fullscreenvid; cin = R_ShaderGetCinematic(videoshader);
if (!cin || !cin->key) if (!cin || !cin->key)
return; return;
cin->key(cin, button, unicode, event); cin->key(cin, button, unicode, event);
@ -1758,7 +1795,7 @@ void Media_Send_KeyEvent(cin_t *cin, int button, int unicode, int event)
void Media_Send_MouseMove(cin_t *cin, float x, float y) void Media_Send_MouseMove(cin_t *cin, float x, float y)
{ {
if (!cin) if (!cin)
cin = fullscreenvid; cin = R_ShaderGetCinematic(videoshader);
if (!cin || !cin->key) if (!cin || !cin->key)
return; return;
cin->cursormove(cin, x, y); cin->cursormove(cin, x, y);
@ -1770,7 +1807,7 @@ void Media_Send_Resize(cin_t *cin, int x, int y)
void Media_Send_GetSize(cin_t *cin, int *x, int *y) void Media_Send_GetSize(cin_t *cin, int *x, int *y)
{ {
if (!cin) if (!cin)
cin = fullscreenvid; cin = R_ShaderGetCinematic(videoshader);
if (!cin || !cin->key) if (!cin || !cin->key)
return; return;
cin->getsize(cin, x, y); cin->getsize(cin, x, y);

File diff suppressed because it is too large Load diff

View file

@ -700,6 +700,22 @@ void M_QuickConnect_f(void);
void M_Menu_MediaFiles_f (void); void M_Menu_MediaFiles_f (void);
void M_Menu_FPS_f (void); void M_Menu_FPS_f (void);
void M_Menu_Shadow_Lighting_f (void);
void M_Menu_3D_f (void);
void M_Menu_Textures_f (void);
void M_Menu_Teamplay_f (void);
void M_Menu_Teamplay_Locations_f (void);
void M_Menu_Teamplay_Needs_f (void);
void M_Menu_Teamplay_Items_f (void);
void M_Menu_Teamplay_Items_Armor_f (void);
void M_Menu_Teamplay_Items_Weapons_f (void);
void M_Menu_Teamplay_Items_Powerups_f (void);
void M_Menu_Teamplay_Items_Ammo_Health_f (void);
void M_Menu_Teamplay_Items_Team_Fortress_f (void);
void M_Menu_Teamplay_Items_Status_Location_Misc_f (void);
void M_Menu_Singleplayer_Cheats_f (void);
void M_Menu_Singleplayer_Cheats_Quake2_f (void);
void M_Menu_Singleplayer_Cheats_Hexen2_f (void);
void M_Menu_Particles_f (void); void M_Menu_Particles_f (void);
void M_Menu_ParticleSets_f (void); void M_Menu_ParticleSets_f (void);
void M_Menu_Audio_Speakers_f (void); void M_Menu_Audio_Speakers_f (void);
@ -747,7 +763,23 @@ void M_Init_Internal (void)
#ifndef __CYGWIN__ #ifndef __CYGWIN__
Cmd_AddRemCommand ("menu_speakers", M_Menu_Audio_Speakers_f); Cmd_AddRemCommand ("menu_speakers", M_Menu_Audio_Speakers_f);
#endif #endif
Cmd_AddRemCommand ("menu_spcheats", M_Menu_Singleplayer_Cheats_f);
Cmd_AddRemCommand ("menu_quake2_spcheats", M_Menu_Singleplayer_Cheats_Quake2_f);
Cmd_AddRemCommand ("menu_hexen2_spcheats", M_Menu_Singleplayer_Cheats_Hexen2_f);
Cmd_AddRemCommand ("menu_fps", M_Menu_FPS_f); Cmd_AddRemCommand ("menu_fps", M_Menu_FPS_f);
Cmd_AddRemCommand ("menu_3d" , M_Menu_3D_f);
Cmd_AddRemCommand ("menu_shadow_lighting", M_Menu_Shadow_Lighting_f);
Cmd_AddRemCommand ("menu_textures", M_Menu_Textures_f);
Cmd_AddRemCommand ("menu_teamplay", M_Menu_Teamplay_f);
Cmd_AddRemCommand ("menu_teamplay_locations", M_Menu_Teamplay_Locations_f);
Cmd_AddRemCommand ("menu_teamplay_needs", M_Menu_Teamplay_Needs_f);
Cmd_AddRemCommand ("menu_teamplay_items", M_Menu_Teamplay_Items_f);
Cmd_AddRemCommand ("menu_teamplay_armor", M_Menu_Teamplay_Items_Armor_f);
Cmd_AddRemCommand ("menu_teamplay_weapons", M_Menu_Teamplay_Items_Weapons_f);
Cmd_AddRemCommand ("menu_teamplay_powerups", M_Menu_Teamplay_Items_Powerups_f);
Cmd_AddRemCommand ("menu_teamplay_ammo_health", M_Menu_Teamplay_Items_Ammo_Health_f);
Cmd_AddRemCommand ("menu_teamplay_team_fortress", M_Menu_Teamplay_Items_Team_Fortress_f);
Cmd_AddRemCommand ("menu_teamplay_status_location_misc", M_Menu_Teamplay_Items_Status_Location_Misc_f);
Cmd_AddRemCommand ("menu_particles", M_Menu_Particles_f); Cmd_AddRemCommand ("menu_particles", M_Menu_Particles_f);
Cmd_AddRemCommand ("menu_particlesets", M_Menu_ParticleSets_f); Cmd_AddRemCommand ("menu_particlesets", M_Menu_ParticleSets_f);
@ -793,7 +825,23 @@ void M_DeInit_Internal (void)
Cmd_RemoveCommand ("menu_video"); Cmd_RemoveCommand ("menu_video");
Cmd_RemoveCommand ("menu_audio"); Cmd_RemoveCommand ("menu_audio");
Cmd_RemoveCommand ("menu_speakers"); Cmd_RemoveCommand ("menu_speakers");
Cmd_RemoveCommand ("menu_teamplay");
Cmd_RemoveCommand ("menu_teamplay_locations");
Cmd_RemoveCommand ("menu_teamplay_needs");
Cmd_RemoveCommand ("menu_teamplay_items");
Cmd_RemoveCommand ("menu_teamplay_armor");
Cmd_RemoveCommand ("menu_teamplay_weapons");
Cmd_RemoveCommand ("menu_teamplay_powerups");
Cmd_RemoveCommand ("menu_teamplay_ammo_health");
Cmd_RemoveCommand ("menu_teamplay_team_fortress");
Cmd_RemoveCommand ("menu_teamplay_status_location_misc");
Cmd_RemoveCommand ("menu_spcheats");
Cmd_RemoveCommand ("menu_hexen2_spcheats");
Cmd_RemoveCommand ("menu_quake2_spcheats");
Cmd_RemoveCommand ("menu_fps"); Cmd_RemoveCommand ("menu_fps");
Cmd_RemoveCommand ("menu_3d");
Cmd_RemoveCommand ("menu_shadow_lighting");
Cmd_RemoveCommand ("menu_textures");
Cmd_RemoveCommand ("menu_particles"); Cmd_RemoveCommand ("menu_particles");
Cmd_RemoveCommand ("menu_particlesets"); Cmd_RemoveCommand ("menu_particlesets");
@ -953,21 +1001,26 @@ void M_Keyup (int key, int unicode)
// Generic function to choose which game menu to draw // Generic function to choose which game menu to draw
int M_GameType (void) int M_GameType (void)
{ {
int cached; static int cached;
static unsigned int cachedrestarts;
if (FS_Restarted(&cachedrestarts))
{
#if defined(Q2CLIENT) #if defined(Q2CLIENT)
int q1, h2, q2; int q1, h2, q2;
q1 = COM_FDepthFile("gfx/sp_menu.lmp", true); q1 = COM_FDepthFile("gfx/sp_menu.lmp", true);
h2 = COM_FDepthFile("gfx/menu/title2.lmp", true); h2 = COM_FDepthFile("gfx/menu/title2.lmp", true);
q2 = COM_FDepthFile("pics/m_banner_game.pcx", true); q2 = COM_FDepthFile("pics/m_banner_game.pcx", true);
if (q2 < h2 && q2 < q1) if (q2 < h2 && q2 < q1)
cached = MGT_QUAKE2; cached = MGT_QUAKE2;
else if (h2 < q1) else if (h2 < q1)
cached = MGT_HEXEN2; cached = MGT_HEXEN2;
else else
#endif #endif
cached = MGT_QUAKE1; cached = MGT_QUAKE1;
}
return cached; return cached;
} }

View file

@ -302,6 +302,7 @@ menuedit_t *MC_AddEditCvar(menu_t *menu, int x, int y, char *text, char *name);
menucustom_t *MC_AddCustom(menu_t *menu, int x, int y, void *data); menucustom_t *MC_AddCustom(menu_t *menu, int x, int y, void *data);
menucombo_t *MC_AddCvarCombo(menu_t *menu, int x, int y, const char *caption, cvar_t *cvar, const char **ops, const char **values); menucombo_t *MC_AddCvarCombo(menu_t *menu, int x, int y, const char *caption, cvar_t *cvar, const char **ops, const char **values);
menu_t *M_Options_Title(int *y, int infosize); /*Create a menu with the default options titlebar*/
menu_t *M_CreateMenu (int extrasize); menu_t *M_CreateMenu (int extrasize);
void M_AddMenu (menu_t *menu); void M_AddMenu (menu_t *menu);
void M_AddMenuFront (menu_t *menu); void M_AddMenuFront (menu_t *menu);

View file

@ -86,10 +86,6 @@ extern void (*R_PushDlights) (void);
extern void (*R_AddStain) (vec3_t org, float red, float green, float blue, float radius); extern void (*R_AddStain) (vec3_t org, float red, float green, float blue, float radius);
extern void (*R_LessenStains) (void); extern void (*R_LessenStains) (void);
extern void (*Media_ShowFrameBGR_24_Flip) (qbyte *framedata, int inwidth, int inheight); //input is bottom up...
extern void (*Media_ShowFrameRGBA_32) (qbyte *framedata, int inwidth, int inheight); //top down
extern void (*Media_ShowFrame8bit) (qbyte *framedata, int inwidth, int inheight, qbyte *palette); //paletted topdown (framedata is 8bit indexes into palette)
extern qboolean (*VID_Init) (rendererstate_t *info, unsigned char *palette); extern qboolean (*VID_Init) (rendererstate_t *info, unsigned char *palette);
extern void (*VID_DeInit) (void); extern void (*VID_DeInit) (void);
extern void (*VID_LockBuffer) (void); extern void (*VID_LockBuffer) (void);
@ -113,6 +109,17 @@ extern void SCR_SetUpToDrawConsole (void);
extern void SCR_EraseCenterString (void); extern void SCR_EraseCenterString (void);
extern void SCR_CenterPrint (int pnum, char *str, qboolean skipgamecode); extern void SCR_CenterPrint (int pnum, char *str, qboolean skipgamecode);
void R_DrawTextField(int x, int y, int w, int h, char *text, unsigned int defaultmask, unsigned int fieldflags);
#define CPRINT_BALIGN (1<<0) //B
#define CPRINT_TALIGN (1<<1) //T
#define CPRINT_LALIGN (1<<2) //L
#define CPRINT_RALIGN (1<<3) //R
#define CPRINT_BACKGROUND (1<<4) //P
#define CPRINT_OBITUARTY (1<<16) //O (show at 2/3rds from top)
#define CPRINT_PERSIST (1<<17) //P (doesn't time out)
#define CPRINT_TYPEWRITER (1<<18) // (char at a time)
#endif #endif
extern void FNC(Mod_Init) (void); extern void FNC(Mod_Init) (void);
@ -188,10 +195,6 @@ typedef struct rendererinfo_s {
void (*R_AddStain) (vec3_t org, float red, float green, float blue, float radius); void (*R_AddStain) (vec3_t org, float red, float green, float blue, float radius);
void (*R_LessenStains) (void); void (*R_LessenStains) (void);
void (*Media_ShowFrameBGR_24_Flip) (qbyte *framedata, int inwidth, int inheight); //input is bottom up...
void (*Media_ShowFrameRGBA_32) (qbyte *framedata, int inwidth, int inheight); //top down
void (*Media_ShowFrame8bit) (qbyte *framedata, int inwidth, int inheight, qbyte *palette); //paletted topdown (framedata is 8bit indexes into palette)
void (*Mod_Init) (void); void (*Mod_Init) (void);
void (*Mod_ClearAll) (void); void (*Mod_ClearAll) (void);
struct model_s *(*Mod_ForName) (char *name, qboolean crash); struct model_s *(*Mod_ForName) (char *name, qboolean crash);

View file

@ -28,10 +28,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
void D_DrawParticleTrans (vec3_t porg, float palpha, float pscale, unsigned int pcolour, blendmode_t blendmode); void D_DrawParticleTrans (vec3_t porg, float palpha, float pscale, unsigned int pcolour, blendmode_t blendmode);
cvar_t gl_solidparticles = SCVAR("gl_solidparticles", "0");
typedef enum { typedef enum {
DODGY, DODGY,
@ -94,8 +90,8 @@ static union c
unsigned int i; unsigned int i;
} classiccolours[BUFFERVERTS]; } classiccolours[BUFFERVERTS];
static vec2_t classictexcoords[BUFFERVERTS]; static vec2_t classictexcoords[BUFFERVERTS];
index_t classicindexes[BUFFERVERTS]; static index_t classicindexes[BUFFERVERTS];
static mesh_t classicmesh; mesh_t classicmesh;
static shader_t *classicshader; static shader_t *classicshader;
@ -184,7 +180,7 @@ static void PClassic_EmitSkyEffectTris(model_t *mod, msurface_t *fa)
} }
//the one-time initialisation function, called no mater which renderer is active. //the one-time initialisation function, called no mater which renderer is active.
static void PClassic_InitParticles (void) static qboolean PClassic_InitParticles (void)
{ {
int i; int i;
model_t *mod; model_t *mod;
@ -238,6 +234,8 @@ static void PClassic_InitParticles (void)
"}\n" "}\n"
); );
classicshader->defaulttextures.base = particlecqtexture; classicshader->defaulttextures.base = particlecqtexture;
return true;
} }
static void PClassic_ShutdownParticles(void) static void PClassic_ShutdownParticles(void)
@ -296,7 +294,7 @@ static void PClassic_DrawParticles(void)
VectorScale (vright, 1.5, right); VectorScale (vright, 1.5, right);
frametime = host_frametime; frametime = host_frametime;
if (cl.paused) if (cl.paused || r_secondaryview || r_refdef.recurse)
frametime = 0; frametime = 0;
time3 = frametime * 15; time3 = frametime * 15;
time2 = frametime * 10; // 15; time2 = frametime * 10; // 15;
@ -335,7 +333,7 @@ static void PClassic_DrawParticles(void)
if (classicmesh.numvertexes >= BUFFERVERTS-3) if (classicmesh.numvertexes >= BUFFERVERTS-3)
{ {
classicmesh.numindexes = classicmesh.numvertexes; classicmesh.numindexes = classicmesh.numvertexes;
BE_DrawMeshChain(classicshader, &classicmesh, NULL, &classicshader->defaulttextures); BE_DrawMesh_Single(classicshader, &classicmesh, NULL, &classicshader->defaulttextures);
classicmesh.numvertexes = 0; classicmesh.numvertexes = 0;
} }
@ -418,7 +416,7 @@ static void PClassic_DrawParticles(void)
if (classicmesh.numvertexes) if (classicmesh.numvertexes)
{ {
classicmesh.numindexes = classicmesh.numvertexes; classicmesh.numindexes = classicmesh.numvertexes;
BE_DrawMeshChain(classicshader, &classicmesh, NULL, &classicshader->defaulttextures); BE_DrawMesh_Single(classicshader, &classicmesh, NULL, &classicshader->defaulttextures);
classicmesh.numvertexes = 0; classicmesh.numvertexes = 0;
} }

View file

@ -47,7 +47,7 @@ static void PNULL_DrawParticles(void)
RSpeedLocals(); RSpeedLocals();
RSpeedRemark(); RSpeedRemark();
RQ_RenderDistAndClear(); RQ_RenderBatchClear();
RSpeedEnd(RSPEED_PARTICLESDRAW); RSpeedEnd(RSPEED_PARTICLESDRAW);
} }

View file

@ -299,7 +299,6 @@ extern cvar_t r_part_sparks;
extern cvar_t r_part_sparks_trifan; extern cvar_t r_part_sparks_trifan;
extern cvar_t r_part_sparks_textured; extern cvar_t r_part_sparks_textured;
extern cvar_t r_part_beams; extern cvar_t r_part_beams;
extern cvar_t r_part_beams_textured;
extern cvar_t r_part_contentswitch; extern cvar_t r_part_contentswitch;
static float particletime; static float particletime;
@ -1351,12 +1350,12 @@ static void P_PartInfo_f (void)
R_InitParticles R_InitParticles
=============== ===============
*/ */
static void PScript_InitParticles (void) static qboolean PScript_InitParticles (void)
{ {
int i; int i;
if (r_numparticles) //already inited if (r_numparticles) //already inited
return; return true;
buildsintable(); buildsintable();
@ -1437,6 +1436,7 @@ static void PScript_InitParticles (void)
pscripttmesh.st_array = pscripttexcoords; pscripttmesh.st_array = pscripttexcoords;
pscripttmesh.colors4f_array = pscriptcolours; pscripttmesh.colors4f_array = pscriptcolours;
pscripttmesh.indexes = pscripttriindexes; pscripttmesh.indexes = pscripttriindexes;
return true;
} }
static void PScript_Shutdown (void) static void PScript_Shutdown (void)
@ -3240,7 +3240,7 @@ static void GL_DrawTexturedParticle(int count, particle_t **plist, plooks_t *typ
if (pscriptmesh.numvertexes >= BUFFERVERTS-4) if (pscriptmesh.numvertexes >= BUFFERVERTS-4)
{ {
pscriptmesh.numindexes = pscriptmesh.numvertexes/4*6; pscriptmesh.numindexes = pscriptmesh.numvertexes/4*6;
BE_DrawMeshChain(type->shader, &pscriptmesh, NULL, &type->shader->defaulttextures); BE_DrawMesh_Single(type->shader, &pscriptmesh, NULL, &type->shader->defaulttextures);
pscriptmesh.numvertexes = 0; pscriptmesh.numvertexes = 0;
} }
@ -3298,7 +3298,7 @@ static void GL_DrawTexturedParticle(int count, particle_t **plist, plooks_t *typ
if (pscriptmesh.numvertexes) if (pscriptmesh.numvertexes)
{ {
pscriptmesh.numindexes = pscriptmesh.numvertexes/4*6; pscriptmesh.numindexes = pscriptmesh.numvertexes/4*6;
BE_DrawMeshChain(type->shader, &pscriptmesh, NULL, &type->shader->defaulttextures); BE_DrawMesh_Single(type->shader, &pscriptmesh, NULL, &type->shader->defaulttextures);
pscriptmesh.numvertexes = 0; pscriptmesh.numvertexes = 0;
} }
} }
@ -3316,7 +3316,7 @@ static void GL_DrawTrifanParticle(int count, particle_t **plist, plooks_t *type)
if (pscripttmesh.numvertexes >= BUFFERVERTS-3) if (pscripttmesh.numvertexes >= BUFFERVERTS-3)
{ {
pscripttmesh.numindexes = pscripttmesh.numvertexes; pscripttmesh.numindexes = pscripttmesh.numvertexes;
BE_DrawMeshChain(type->shader, &pscripttmesh, NULL, &type->shader->defaulttextures); BE_DrawMesh_Single(type->shader, &pscripttmesh, NULL, &type->shader->defaulttextures);
pscripttmesh.numvertexes = 0; pscripttmesh.numvertexes = 0;
} }
@ -3352,7 +3352,7 @@ static void GL_DrawTrifanParticle(int count, particle_t **plist, plooks_t *type)
if (pscripttmesh.numvertexes) if (pscripttmesh.numvertexes)
{ {
pscripttmesh.numindexes = pscripttmesh.numvertexes; pscripttmesh.numindexes = pscripttmesh.numvertexes;
BE_DrawMeshChain(type->shader, &pscripttmesh, NULL, &type->shader->defaulttextures); BE_DrawMesh_Single(type->shader, &pscripttmesh, NULL, &type->shader->defaulttextures);
pscripttmesh.numvertexes = 0; pscripttmesh.numvertexes = 0;
} }
} }
@ -3400,7 +3400,7 @@ static void GL_DrawTexturedSparkParticle(int count, particle_t **plist, plooks_t
if (pscriptmesh.numvertexes >= BUFFERVERTS-4) if (pscriptmesh.numvertexes >= BUFFERVERTS-4)
{ {
pscriptmesh.numindexes = pscriptmesh.numvertexes/4*6; pscriptmesh.numindexes = pscriptmesh.numvertexes/4*6;
BE_DrawMeshChain(type->shader, &pscriptmesh, NULL, &type->shader->defaulttextures); BE_DrawMesh_Single(type->shader, &pscriptmesh, NULL, &type->shader->defaulttextures);
pscriptmesh.numvertexes = 0; pscriptmesh.numvertexes = 0;
} }
@ -3439,7 +3439,7 @@ static void GL_DrawTexturedSparkParticle(int count, particle_t **plist, plooks_t
if (pscriptmesh.numvertexes) if (pscriptmesh.numvertexes)
{ {
pscriptmesh.numindexes = pscriptmesh.numvertexes/4*6; pscriptmesh.numindexes = pscriptmesh.numvertexes/4*6;
BE_DrawMeshChain(type->shader, &pscriptmesh, NULL, &type->shader->defaulttextures); BE_DrawMesh_Single(type->shader, &pscriptmesh, NULL, &type->shader->defaulttextures);
pscriptmesh.numvertexes = 0; pscriptmesh.numvertexes = 0;
} }
} }
@ -3461,7 +3461,7 @@ static void GL_DrawParticleBeam(int count, beamseg_t **blist, plooks_t *type)
if (pscriptmesh.numvertexes >= BUFFERVERTS-4) if (pscriptmesh.numvertexes >= BUFFERVERTS-4)
{ {
pscriptmesh.numindexes = pscriptmesh.numvertexes/4*6; pscriptmesh.numindexes = pscriptmesh.numvertexes/4*6;
BE_DrawMeshChain(type->shader, &pscriptmesh, NULL, &type->shader->defaulttextures); BE_DrawMesh_Single(type->shader, &pscriptmesh, NULL, &type->shader->defaulttextures);
pscriptmesh.numvertexes = 0; pscriptmesh.numvertexes = 0;
} }
@ -3498,7 +3498,7 @@ static void GL_DrawParticleBeam(int count, beamseg_t **blist, plooks_t *type)
if (pscriptmesh.numvertexes) if (pscriptmesh.numvertexes)
{ {
pscriptmesh.numindexes = pscriptmesh.numvertexes/4*6; pscriptmesh.numindexes = pscriptmesh.numvertexes/4*6;
BE_DrawMeshChain(type->shader, &pscriptmesh, NULL, &type->shader->defaulttextures); BE_DrawMesh_Single(type->shader, &pscriptmesh, NULL, &type->shader->defaulttextures);
pscriptmesh.numvertexes = 0; pscriptmesh.numvertexes = 0;
} }
} }
@ -3514,7 +3514,7 @@ static void GL_DrawClippedDecal(int count, clippeddecal_t **dlist, plooks_t *typ
if (pscripttmesh.numvertexes >= BUFFERVERTS-3) if (pscripttmesh.numvertexes >= BUFFERVERTS-3)
{ {
pscripttmesh.numindexes = pscripttmesh.numvertexes; pscripttmesh.numindexes = pscripttmesh.numvertexes;
BE_DrawMeshChain(type->shader, &pscripttmesh, NULL, &type->shader->defaulttextures); BE_DrawMesh_Single(type->shader, &pscripttmesh, NULL, &type->shader->defaulttextures);
pscripttmesh.numvertexes = 0; pscripttmesh.numvertexes = 0;
} }
@ -3537,15 +3537,13 @@ static void GL_DrawClippedDecal(int count, clippeddecal_t **dlist, plooks_t *typ
if (pscriptmesh.numvertexes) if (pscriptmesh.numvertexes)
{ {
pscripttmesh.numindexes = pscripttmesh.numvertexes; pscripttmesh.numindexes = pscripttmesh.numvertexes;
BE_DrawMeshChain(type->shader, &pscriptmesh, NULL, &type->shader->defaulttextures); BE_DrawMesh_Single(type->shader, &pscriptmesh, NULL, &type->shader->defaulttextures);
pscripttmesh.numvertexes = 0; pscripttmesh.numvertexes = 0;
} }
} }
static void PScript_DrawParticleTypes (void (*texturedparticles)(int count, particle_t **,plooks_t*), void (*sparklineparticles)(int count, particle_t **,plooks_t*), void (*sparkfanparticles)(int count, particle_t **,plooks_t*), void (*sparktexturedparticles)(int count, particle_t **,plooks_t*), void (*beamparticles)(int count, beamseg_t**,plooks_t*), void (*drawdecalparticles)(int count, clippeddecal_t**,plooks_t*)) static void PScript_DrawParticleTypes (void (*texturedparticles)(int count, particle_t **,plooks_t*), void (*sparklineparticles)(int count, particle_t **,plooks_t*), void (*sparkfanparticles)(int count, particle_t **,plooks_t*), void (*sparktexturedparticles)(int count, particle_t **,plooks_t*), void (*beamparticles)(int count, beamseg_t**,plooks_t*), void (*drawdecalparticles)(int count, clippeddecal_t**,plooks_t*))
{ {
RSpeedMark();
qboolean (*tr) (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal); qboolean (*tr) (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal);
void *pdraw, *bdraw; void *pdraw, *bdraw;
@ -3565,6 +3563,7 @@ static void PScript_DrawParticleTypes (void (*texturedparticles)(int count, part
int traces=r_particle_tracelimit.ival; int traces=r_particle_tracelimit.ival;
int rampind; int rampind;
RSpeedMark();
if (r_plooksdirty) if (r_plooksdirty)
{ {
@ -3586,7 +3585,7 @@ static void PScript_DrawParticleTypes (void (*texturedparticles)(int count, part
} }
pframetime = host_frametime; pframetime = host_frametime;
if (cl.paused || r_secondaryview) if (cl.paused || r_secondaryview || r_refdef.recurse)
pframetime = 0; pframetime = 0;
VectorScale (vup, 1.5, pup); VectorScale (vup, 1.5, pup);

View file

@ -58,10 +58,10 @@ static qboolean csqc_isdarkplaces;
static char csqc_printbuffer[8192]; static char csqc_printbuffer[8192];
#define CSQCPROGSGROUP "CSQC progs control" #define CSQCPROGSGROUP "CSQC progs control"
cvar_t pr_csmaxedicts = SCVAR("pr_csmaxedicts", "3072"); //not tied to protocol nor server. cvar_t pr_csmaxedicts = CVAR("pr_csmaxedicts", "3072"); //not tied to protocol nor server.
cvar_t cl_csqcdebug = SCVAR("cl_csqcdebug", "0"); //prints entity numbers which arrive (so I can tell people not to apply it to players...) cvar_t cl_csqcdebug = CVAR("cl_csqcdebug", "0"); //prints entity numbers which arrive (so I can tell people not to apply it to players...)
cvar_t cl_nocsqc = SCVAR("cl_nocsqc", "0"); cvar_t cl_nocsqc = CVAR("cl_nocsqc", "0");
cvar_t pr_csqc_coreonerror = SCVAR("pr_csqc_coreonerror", "1"); cvar_t pr_csqc_coreonerror = CVAR("pr_csqc_coreonerror", "1");
#define MASK_DELTA 1 #define MASK_DELTA 1
@ -153,7 +153,7 @@ typedef enum
\ \
/*These are pointers to the csqc's globals.*/ \ /*These are pointers to the csqc's globals.*/ \
globalfloat(svtime, "time"); /*float Written before entering most qc functions*/ \ globalfloat(svtime, "time"); /*float Written before entering most qc functions*/ \
globalfloat(frametime, "frametime"); /*float Written before entering most qc functions*/ \ globalfloat(frametime, "frametime"); /*float Written before entering most qc functions*/ \
globalfloat(cltime, "cltime"); /*float Written before entering most qc functions*/ \ globalfloat(cltime, "cltime"); /*float Written before entering most qc functions*/ \
globalentity(self, "self"); /*entity Written before entering most qc functions*/ \ globalentity(self, "self"); /*entity Written before entering most qc functions*/ \
globalentity(other, "other"); /*entity Written before entering most qc functions*/ \ globalentity(other, "other"); /*entity Written before entering most qc functions*/ \
@ -777,11 +777,11 @@ static void PF_cs_makestatic (progfuncs_t *prinst, struct globalvars_s *pr_globa
return; return;
} }
ent = &cl_static_entities[cl.num_statics]; ent = &cl_static_entities[cl.num_statics].ent;
if (CopyCSQCEdictToEntity(in, ent)) if (CopyCSQCEdictToEntity(in, ent))
{ {
#pragma message("Link static entity")
cl.num_statics++; cl.num_statics++;
R_AddEfrags(ent);
} }
PF_cs_remove(prinst, pr_globals); PF_cs_remove(prinst, pr_globals);
@ -1352,7 +1352,7 @@ static void PF_R_GetViewFlag(progfuncs_t *prinst, struct globalvars_s *pr_global
break; break;
case VF_DRAWWORLD: case VF_DRAWWORLD:
*r = !(r_refdef.flags&Q2RDF_NOWORLDMODEL);; *r = !(r_refdef.flags&Q2RDF_NOWORLDMODEL);
break; break;
case VF_ENGINESBAR: case VF_ENGINESBAR:
*r = csqc_drawsbar; *r = csqc_drawsbar;
@ -2373,6 +2373,11 @@ static void PF_cs_getplayerkey (progfuncs_t *prinst, struct globalvars_s *pr_glo
ret = buffer; ret = buffer;
sprintf(ret, "%i", (int)cl.players[pnum].entertime); sprintf(ret, "%i", (int)cl.players[pnum].entertime);
} }
else if (!strcmp(keyname, "viewentity")) //compat with DP
{
ret = buffer;
sprintf(ret, "%i", pnum+1);
}
else else
{ {
ret = Info_ValueForKey(cl.players[pnum].userinfo, keyname); ret = Info_ValueForKey(cl.players[pnum].userinfo, keyname);
@ -3103,7 +3108,7 @@ static void PF_cs_gecko_create (progfuncs_t *prinst, struct globalvars_s *pr_glo
{ {
char *shader = PR_GetStringOfs(prinst, OFS_PARM0); char *shader = PR_GetStringOfs(prinst, OFS_PARM0);
cin_t *cin; cin_t *cin;
cin = R_ShaderGetCinematic(shader); cin = R_ShaderFindCinematic(shader);
if (!cin) if (!cin)
G_FLOAT(OFS_RETURN) = 0; G_FLOAT(OFS_RETURN) = 0;
@ -3120,7 +3125,7 @@ static void PF_cs_gecko_navigate (progfuncs_t *prinst, struct globalvars_s *pr_g
char *shader = PR_GetStringOfs(prinst, OFS_PARM0); char *shader = PR_GetStringOfs(prinst, OFS_PARM0);
char *command = PR_GetStringOfs(prinst, OFS_PARM1); char *command = PR_GetStringOfs(prinst, OFS_PARM1);
cin_t *cin; cin_t *cin;
cin = R_ShaderGetCinematic(shader); cin = R_ShaderFindCinematic(shader);
if (!cin) if (!cin)
return; return;
@ -3134,7 +3139,7 @@ static void PF_cs_gecko_keyevent (progfuncs_t *prinst, struct globalvars_s *pr_g
int key = G_FLOAT(OFS_PARM1); int key = G_FLOAT(OFS_PARM1);
int eventtype = G_FLOAT(OFS_PARM2); int eventtype = G_FLOAT(OFS_PARM2);
cin_t *cin; cin_t *cin;
cin = R_ShaderGetCinematic(shader); cin = R_ShaderFindCinematic(shader);
if (!cin) if (!cin)
return; return;
@ -3147,7 +3152,7 @@ static void PF_cs_gecko_mousemove (progfuncs_t *prinst, struct globalvars_s *pr_
float posx = G_FLOAT(OFS_PARM1); float posx = G_FLOAT(OFS_PARM1);
float posy = G_FLOAT(OFS_PARM2); float posy = G_FLOAT(OFS_PARM2);
cin_t *cin; cin_t *cin;
cin = R_ShaderGetCinematic(shader); cin = R_ShaderFindCinematic(shader);
if (!cin) if (!cin)
return; return;
@ -3160,7 +3165,7 @@ static void PF_cs_gecko_resize (progfuncs_t *prinst, struct globalvars_s *pr_glo
float sizex = G_FLOAT(OFS_PARM1); float sizex = G_FLOAT(OFS_PARM1);
float sizey = G_FLOAT(OFS_PARM2); float sizey = G_FLOAT(OFS_PARM2);
cin_t *cin; cin_t *cin;
cin = R_ShaderGetCinematic(shader); cin = R_ShaderFindCinematic(shader);
if (!cin) if (!cin)
return; return;
Media_Send_Resize(cin, sizex, sizey); Media_Send_Resize(cin, sizex, sizey);
@ -3172,7 +3177,7 @@ static void PF_cs_gecko_get_texture_extent (progfuncs_t *prinst, struct globalva
float *ret = G_VECTOR(OFS_RETURN); float *ret = G_VECTOR(OFS_RETURN);
int sx, sy; int sx, sy;
cin_t *cin; cin_t *cin;
cin = R_ShaderGetCinematic(shader); cin = R_ShaderFindCinematic(shader);
if (cin) if (cin)
{ {
Media_Send_GetSize(cin, &sx, &sy); Media_Send_GetSize(cin, &sx, &sy);
@ -3553,7 +3558,7 @@ static void PF_skel_create (progfuncs_t *prinst, struct globalvars_s *pr_globals
G_FLOAT(OFS_RETURN) = (skelobj - skelobjects) + 1; G_FLOAT(OFS_RETURN) = (skelobj - skelobjects) + 1;
} }
//float(float skel, entity ent, float modelindex, float retainfrac, float firstbone, float lastbone) skel_get_numbones (FTE_CSQC_SKELETONOBJECTS) //float(float skel, entity ent, float modelindex, float retainfrac, float firstbone, float lastbone) skel_build (FTE_CSQC_SKELETONOBJECTS)
static void PF_skel_build(progfuncs_t *prinst, struct globalvars_s *pr_globals) static void PF_skel_build(progfuncs_t *prinst, struct globalvars_s *pr_globals)
{ {
#define MAX_BONES 256 #define MAX_BONES 256
@ -4845,20 +4850,20 @@ static struct {
{"htos", PF_htos, 262}, {"htos", PF_htos, 262},
{"skel_create", PF_skel_create, 263},//float(float modlindex) skel_create = #263; // (FTE_CSQC_SKELETONOBJECTS) {"skel_create", PF_skel_create, 263},//float(float modlindex) skel_create = #263; // (FTE_CSQC_SKELETONOBJECTS)
{"skel_build", PF_skel_build, 264},//float(float skel, entity ent, float modlindex, float firstbone, float lastbone) skel_build = #263; // (FTE_CSQC_SKELETONOBJECTS) {"skel_build", PF_skel_build, 264},//float(float skel, entity ent, float modelindex, float retainfrac, float firstbone, float lastbone) skel_build = #264; // (FTE_CSQC_SKELETONOBJECTS)
{"skel_get_numbones", PF_skel_get_numbones, 265},//float(float skel) skel_get_numbones = #264; // (FTE_CSQC_SKELETONOBJECTS) {"skel_get_numbones", PF_skel_get_numbones, 265},//float(float skel) skel_get_numbones = #265; // (FTE_CSQC_SKELETONOBJECTS)
{"skel_get_bonename", PF_skel_get_bonename, 266},//string(float skel, float bonenum) skel_get_bonename = #265; // (FTE_CSQC_SKELETONOBJECTS) (returns tempstring) {"skel_get_bonename", PF_skel_get_bonename, 266},//string(float skel, float bonenum) skel_get_bonename = #266; // (FTE_CSQC_SKELETONOBJECTS) (returns tempstring)
{"skel_get_boneparent", PF_skel_get_boneparent, 267},//float(float skel, float bonenum) skel_get_boneparent = #266; // (FTE_CSQC_SKELETONOBJECTS) {"skel_get_boneparent", PF_skel_get_boneparent, 267},//float(float skel, float bonenum) skel_get_boneparent = #267; // (FTE_CSQC_SKELETONOBJECTS)
{"skel_find_bone", PF_skel_find_bone, 268},//float(float skel, string tagname) skel_get_boneidx = #267; // (FTE_CSQC_SKELETONOBJECTS) {"skel_find_bone", PF_skel_find_bone, 268},//float(float skel, string tagname) skel_get_boneidx = #268; // (FTE_CSQC_SKELETONOBJECTS)
{"skel_get_bonerel", PF_skel_get_bonerel, 269},//vector(float skel, float bonenum) skel_get_bonerel = #268; // (FTE_CSQC_SKELETONOBJECTS) (sets v_forward etc) {"skel_get_bonerel", PF_skel_get_bonerel, 269},//vector(float skel, float bonenum) skel_get_bonerel = #269; // (FTE_CSQC_SKELETONOBJECTS) (sets v_forward etc)
{"skel_get_boneabs", PF_skel_get_boneabs, 270},//vector(float skel, float bonenum) skel_get_boneabs = #269; // (FTE_CSQC_SKELETONOBJECTS) (sets v_forward etc) {"skel_get_boneabs", PF_skel_get_boneabs, 270},//vector(float skel, float bonenum) skel_get_boneabs = #270; // (FTE_CSQC_SKELETONOBJECTS) (sets v_forward etc)
{"skel_set_bone", PF_skel_set_bone, 271},//void(float skel, float bonenum, vector org) skel_set_bone = #270; // (FTE_CSQC_SKELETONOBJECTS) (reads v_forward etc) {"skel_set_bone", PF_skel_set_bone, 271},//void(float skel, float bonenum, vector org) skel_set_bone = #271; // (FTE_CSQC_SKELETONOBJECTS) (reads v_forward etc)
{"skel_mul_bone", PF_skel_mul_bone, 272},//void(float skel, float bonenum, vector org) skel_mul_bone = #271; // (FTE_CSQC_SKELETONOBJECTS) (reads v_forward etc) {"skel_mul_bone", PF_skel_mul_bone, 272},//void(float skel, float bonenum, vector org) skel_mul_bone = #272; // (FTE_CSQC_SKELETONOBJECTS) (reads v_forward etc)
{"skel_mul_bones", PF_skel_mul_bones, 273},//void(float skel, float startbone, float endbone, vector org) skel_mul_bone = #272; // (FTE_CSQC_SKELETONOBJECTS) (reads v_forward etc) {"skel_mul_bones", PF_skel_mul_bones, 273},//void(float skel, float startbone, float endbone, vector org) skel_mul_bone = #273; // (FTE_CSQC_SKELETONOBJECTS) (reads v_forward etc)
{"skel_copybones", PF_skel_copybones, 274},//void(float skeldst, float skelsrc, float startbone, float entbone) skel_copybones = #273; // (FTE_CSQC_SKELETONOBJECTS) {"skel_copybones", PF_skel_copybones, 274},//void(float skeldst, float skelsrc, float startbone, float entbone) skel_copybones = #274; // (FTE_CSQC_SKELETONOBJECTS)
{"skel_delete", PF_skel_delete, 275},//void(float skel) skel_delete = #274; // (FTE_CSQC_SKELETONOBJECTS) {"skel_delete", PF_skel_delete, 275},//void(float skel) skel_delete = #275; // (FTE_CSQC_SKELETONOBJECTS)
{"frameforname", PF_frameforname, 276},//void(float modidx, string framename) frameforname = #275 (FTE_CSQC_SKELETONOBJECTS) {"frameforname", PF_frameforname, 276},//void(float modidx, string framename) frameforname = #276 (FTE_CSQC_SKELETONOBJECTS)
{"frameduration", PF_frameduration, 277},//void(float modidx, float framenum) frameduration = #276 (FTE_CSQC_SKELETONOBJECTS) {"frameduration", PF_frameduration, 277},//void(float modidx, float framenum) frameduration = #277 (FTE_CSQC_SKELETONOBJECTS)
//300 //300
{"clearscene", PF_R_ClearScene, 300}, // #300 void() clearscene (EXT_CSQC) {"clearscene", PF_R_ClearScene, 300}, // #300 void() clearscene (EXT_CSQC)
@ -4882,9 +4887,9 @@ static struct {
// {"?", PF_Fixme, 312}, // #312 // {"?", PF_Fixme, 312}, // #312
// {"?", PF_Fixme, 313}, // #313 // {"?", PF_Fixme, 313}, // #313
// {"?", PF_Fixme, 314}, // #314
//2d (immediate) operations //2d (immediate) operations
// {"drawtextfield", PF_CL_DrawTextField, 314},
{"drawline", PF_CL_drawline, 315}, // #315 void(float width, vector pos1, vector pos2) drawline (EXT_CSQC) {"drawline", PF_CL_drawline, 315}, // #315 void(float width, vector pos1, vector pos2) drawline (EXT_CSQC)
{"iscachedpic", PF_CL_is_cached_pic, 316}, // #316 float(string name) iscachedpic (EXT_CSQC) {"iscachedpic", PF_CL_is_cached_pic, 316}, // #316 float(string name) iscachedpic (EXT_CSQC)
{"precache_pic", PF_CL_precache_pic, 317}, // #317 string(string name, float trywad) precache_pic (EXT_CSQC) {"precache_pic", PF_CL_precache_pic, 317}, // #317 string(string name, float trywad) precache_pic (EXT_CSQC)
@ -5139,8 +5144,14 @@ static struct {
//DP_QC_URI_GET //DP_QC_URI_GET
{"uri_get", PF_uri_get, 513}, // #513 float(string uril, float id) uri_get {"uri_get", PF_uri_get, 513}, // #513 float(string uril, float id) uri_get
{"keynumtostring", PF_cl_keynumtostring, 520}, // #520 {"tokenize_console", PF_tokenize_console, 514},
{"findkeysforcommand", PF_cl_findkeysforcommand, 521}, // #521 {"argv_start_index", PF_argv_start_index, 515},
{"argv_end_index", PF_argv_end_index, 516},
{"buf_cvarlist", PF_buf_cvarlist, 517},
{"cvar_description", PF_cvar_description, 518},
{"keynumtostring", PF_cl_keynumtostring, 520},
{"findkeysforcommand", PF_cl_findkeysforcommand, 521},
{NULL} {NULL}
}; };
@ -5499,14 +5510,10 @@ qboolean CSQC_Init (unsigned int checksum)
csqcentsize = PR_InitEnts(csqcprogs, pr_csmaxedicts.value); csqcentsize = PR_InitEnts(csqcprogs, pr_csmaxedicts.value);
ED_Alloc(csqcprogs); //we need a world entity. ED_Alloc(csqcprogs); //we need a world entity.
//world edict becomes readonly //world edict becomes readonly
worldent = (csqcedict_t *)EDICT_NUM(csqcprogs, 0); worldent = (csqcedict_t *)EDICT_NUM(csqcprogs, 0);
worldent->readonly = true;
worldent->isfree = false; worldent->isfree = false;
worldent->v->modelindex = 1;
worldent->v->model = PR_SetString(csqcprogs, cl.model_name[(int)worldent->v->modelindex]);
worldent->v->solid = SOLID_BSP;
str = (string_t*)csqcprogs->GetEdictFieldValue(csqcprogs, (edict_t*)worldent, "message", NULL); str = (string_t*)csqcprogs->GetEdictFieldValue(csqcprogs, (edict_t*)worldent, "message", NULL);
if (str) if (str)
@ -5539,6 +5546,8 @@ qboolean CSQC_Init (unsigned int checksum)
void CSQC_WorldLoaded(void) void CSQC_WorldLoaded(void)
{ {
csqcedict_t *worldent;
if (!csqcprogs) if (!csqcprogs)
return; return;
if (csqcmapentitydataloaded) if (csqcmapentitydataloaded)
@ -5551,9 +5560,16 @@ void CSQC_WorldLoaded(void)
World_Physics_Start(&csqc_world); World_Physics_Start(&csqc_world);
#endif #endif
worldent = (csqcedict_t *)EDICT_NUM(csqcprogs, 0);
worldent->v->modelindex = 1;
worldent->v->model = PR_SetString(csqcprogs, cl.model_name[(int)worldent->v->modelindex]);
worldent->v->solid = SOLID_BSP;
if (csqcg.worldloaded) if (csqcg.worldloaded)
PR_ExecuteProgram(csqcprogs, csqcg.worldloaded); PR_ExecuteProgram(csqcprogs, csqcg.worldloaded);
csqcmapentitydata = NULL; csqcmapentitydata = NULL;
worldent->readonly = true;
} }
void CSQC_CoreDump(void) void CSQC_CoreDump(void)
@ -5911,16 +5927,23 @@ qboolean CSQC_ParsePrint(char *message, int printlevel)
return true; return true;
} }
qboolean CSQC_StuffCmd(int lplayernum, char *cmd) qboolean CSQC_StuffCmd(int lplayernum, char *cmd, char *cmdend)
{ {
void *pr_globals; void *pr_globals;
char tmp[2];
if (!csqcprogs || !csqcg.parse_stuffcmd) if (!csqcprogs || !csqcg.parse_stuffcmd)
return false; return false;
CSQC_ChangeLocalPlayer(lplayernum); CSQC_ChangeLocalPlayer(lplayernum);
pr_globals = PR_globals(csqcprogs, PR_CURRENT); pr_globals = PR_globals(csqcprogs, PR_CURRENT);
tmp[0] = cmdend[0];
tmp[1] = cmdend[1];
cmdend[0] = '\n';
cmdend[1] = 0;
(((string_t *)pr_globals)[OFS_PARM0] = PR_TempString(csqcprogs, cmd)); (((string_t *)pr_globals)[OFS_PARM0] = PR_TempString(csqcprogs, cmd));
cmdend[0] = tmp[0];
cmdend[1] = tmp[1];
PR_ExecuteProgram (csqcprogs, csqcg.parse_stuffcmd); PR_ExecuteProgram (csqcprogs, csqcg.parse_stuffcmd);
return true; return true;
@ -6062,7 +6085,7 @@ void CSQC_ParseEntities(void)
CSQC_EntityCheck(entnum); CSQC_EntityCheck(entnum);
if (cl_csqcdebug.value) if (cl_csqcdebug.ival)
Con_Printf("Remove %i\n", entnum); Con_Printf("Remove %i\n", entnum);
ent = csqcent[entnum]; ent = csqcent[entnum];
@ -6098,13 +6121,13 @@ void CSQC_ParseEntities(void)
ent->xv->entnum = entnum; ent->xv->entnum = entnum;
G_FLOAT(OFS_PARM0) = true; G_FLOAT(OFS_PARM0) = true;
if (cl_csqcdebug.value) if (cl_csqcdebug.ival)
Con_Printf("Add %i\n", entnum); Con_Printf("Add %i\n", entnum);
} }
else else
{ {
G_FLOAT(OFS_PARM0) = false; G_FLOAT(OFS_PARM0) = false;
if (cl_csqcdebug.value) if (cl_csqcdebug.ival)
Con_Printf("Update %i\n", entnum); Con_Printf("Update %i\n", entnum);
} }

View file

@ -328,7 +328,14 @@ void PF_CL_drawresetcliparea (progfuncs_t *prinst, struct globalvars_s *pr_globa
G_FLOAT(OFS_RETURN) = 0; G_FLOAT(OFS_RETURN) = 0;
} }
void PF_CL_DrawTextField (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
float *pos = G_VECTOR(OFS_PARM0);
float *size = G_VECTOR(OFS_PARM1);
unsigned int flags = G_FLOAT(OFS_PARM2);
char *text = PR_GetStringOfs(prinst, OFS_PARM3);
R_DrawTextField(pos[0], pos[1], size[0], size[1], text, CON_WHITEMASK, flags);
}
//float drawstring(vector position, string text, vector scale, float alpha, float flag) = #455; //float drawstring(vector position, string text, vector scale, float alpha, float flag) = #455;
void PF_CL_drawcolouredstring (progfuncs_t *prinst, struct globalvars_s *pr_globals) void PF_CL_drawcolouredstring (progfuncs_t *prinst, struct globalvars_s *pr_globals)
@ -336,16 +343,29 @@ void PF_CL_drawcolouredstring (progfuncs_t *prinst, struct globalvars_s *pr_glob
float *pos = G_VECTOR(OFS_PARM0); float *pos = G_VECTOR(OFS_PARM0);
char *text = PR_GetStringOfs(prinst, OFS_PARM1); char *text = PR_GetStringOfs(prinst, OFS_PARM1);
float *size = G_VECTOR(OFS_PARM2); float *size = G_VECTOR(OFS_PARM2);
// float *alpha = G_FLOAT(OFS_PARM3); float alpha = G_FLOAT(OFS_PARM3);
// float flag = G_FLOAT(OFS_PARM4); // float flag = G_FLOAT(OFS_PARM4);
conchar_t buffer[2048], *str;
float px, py;
if (!text) if (!text)
{ {
G_FLOAT(OFS_RETURN) = -1; //was null.. G_FLOAT(OFS_RETURN) = -1; //was null..
return; return;
} }
Draw_FunString(pos[0], pos[1], text); COM_ParseFunString(CON_WHITEMASK, text, buffer, sizeof(buffer), false);
str = buffer;
Font_BeginScaledString(font_conchar, pos[0], pos[1], &px, &py);
Font_ForceColour(1, 1, 1, alpha);
while(*str)
{
px = Font_DrawScaleChar(px, py, size[0], size[1], *str++);
}
Font_InvalidateColour();
Font_EndString(font_conchar);
} }
void PF_CL_stringwidth(progfuncs_t *prinst, struct globalvars_s *pr_globals) void PF_CL_stringwidth(progfuncs_t *prinst, struct globalvars_s *pr_globals)
@ -503,7 +523,7 @@ void PF_CL_drawcharacter (progfuncs_t *prinst, struct globalvars_s *pr_globals)
float alpha = G_FLOAT(OFS_PARM4); float alpha = G_FLOAT(OFS_PARM4);
// float flag = G_FLOAT(OFS_PARM5); // float flag = G_FLOAT(OFS_PARM5);
int x, y; float x, y;
if (!chara) if (!chara)
{ {
@ -511,10 +531,9 @@ void PF_CL_drawcharacter (progfuncs_t *prinst, struct globalvars_s *pr_globals)
return; return;
} }
#pragma message("fixme: this doesn't scale") Font_BeginScaledString(font_conchar, pos[0], pos[1], &x, &y);
Font_BeginString(font_conchar, pos[0], pos[1], &x, &y);
Font_ForceColour(rgb[0], rgb[1], rgb[2], alpha); Font_ForceColour(rgb[0], rgb[1], rgb[2], alpha);
Font_DrawChar(x, y, CON_WHITEMASK | 0xe000|(chara&0xff)); Font_DrawScaleChar(x, y, size[0], size[1], CON_WHITEMASK | 0xe000|(chara&0xff));
Font_InvalidateColour(); Font_InvalidateColour();
Font_EndString(font_conchar); Font_EndString(font_conchar);
@ -529,7 +548,7 @@ void PF_CL_drawrawstring (progfuncs_t *prinst, struct globalvars_s *pr_globals)
float *rgb = G_VECTOR(OFS_PARM3); float *rgb = G_VECTOR(OFS_PARM3);
float alpha = G_FLOAT(OFS_PARM4); float alpha = G_FLOAT(OFS_PARM4);
// float flag = G_FLOAT(OFS_PARM5); // float flag = G_FLOAT(OFS_PARM5);
int x, y; float x, y;
if (!text) if (!text)
{ {
@ -537,12 +556,11 @@ void PF_CL_drawrawstring (progfuncs_t *prinst, struct globalvars_s *pr_globals)
return; return;
} }
#pragma message("fixme: this doesn't scale") Font_BeginScaledString(font_conchar, pos[0], pos[1], &x, &y);
Font_BeginString(font_conchar, pos[0], pos[1], &x, &y);
Font_ForceColour(rgb[0], rgb[1], rgb[2], alpha); Font_ForceColour(rgb[0], rgb[1], rgb[2], alpha);
while(*text) while(*text)
{ {
x = Font_DrawChar(x, y, CON_WHITEMASK|0xe000|(*text++&0xff)); x = Font_DrawScaleChar(x, y, size[0], size[1], CON_WHITEMASK|0xe000|(*text++&0xff));
} }
Font_InvalidateColour(); Font_InvalidateColour();
Font_EndString(font_conchar); Font_EndString(font_conchar);
@ -1125,6 +1143,17 @@ void PF_M_getextresponse(progfuncs_t *prinst, struct globalvars_s *pr_globals)
//this does something weird //this does something weird
G_INT(OFS_RETURN) = 0; G_INT(OFS_RETURN) = 0;
} }
void PF_netaddress_resolve(progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
char *address = PR_GetStringOfs(prinst, OFS_PARM0);
netadr_t adr;
char result[256];
if (NET_StringToAdr(address, &adr))
RETURN_TSTRING(NET_AdrToString (result, sizeof(result), adr));
else
RETURN_TSTRING("");
}
#else #else
void PF_gethostcachevalue (progfuncs_t *prinst, struct globalvars_s *pr_globals){G_FLOAT(OFS_RETURN) = 0;} void PF_gethostcachevalue (progfuncs_t *prinst, struct globalvars_s *pr_globals){G_FLOAT(OFS_RETURN) = 0;}
@ -1595,7 +1624,7 @@ builtin_t menu_builtins[] = {
//480 //480
PF_strtolower, // #480 string(string s) VM_strtolower : DRESK - Return string as lowercase PF_strtolower, // #480 string(string s) VM_strtolower : DRESK - Return string as lowercase
PF_strtoupper, // #481 string(string s) VM_strtoupper : DRESK - Return string as uppercase PF_strtoupper, // #481 string(string s) VM_strtoupper : DRESK - Return string as uppercase
skip1 // #482 PF_cvar_defstring, // #482
skip1 // #483 skip1 // #483
PF_strreplace, // #484 string(string search, string replace, string subject) strreplace (DP_QC_STRREPLACE) PF_strreplace, // #484 string(string search, string replace, string subject) strreplace (DP_QC_STRREPLACE)
PF_strireplace, // #485 string(string search, string replace, string subject) strireplace (DP_QC_STRREPLACE) PF_strireplace, // #485 string(string search, string replace, string subject) strireplace (DP_QC_STRREPLACE)
@ -1633,11 +1662,11 @@ builtin_t menu_builtins[] = {
PF_uri_unescape, // #511 string(string in) uri_unescape = #511; PF_uri_unescape, // #511 string(string in) uri_unescape = #511;
PF_etof, // #512 float(entity ent) num_for_edict = #512 (DP_QC_NUM_FOR_EDICT) PF_etof, // #512 float(entity ent) num_for_edict = #512 (DP_QC_NUM_FOR_EDICT)
PF_uri_get, // #513 float(string uril, float id) uri_get = #513; (DP_QC_URI_GET) PF_uri_get, // #513 float(string uril, float id) uri_get = #513; (DP_QC_URI_GET)
skip1 // #514 PF_tokenize_console, // #514
skip1 // #515 PF_argv_start_index, // #515
skip1 // #516 PF_argv_end_index, // #516
skip1 // #517 PF_buf_cvarlist, // #517
skip1 // #518 PF_cvar_description, // #518
skip1 // #519 skip1 // #519
//520 //520
@ -1672,7 +1701,8 @@ builtin_t menu_builtins[] = {
PF_M_gethostcachenumber, PF_M_gethostcachenumber,
PF_M_gethostcacheindexforkey, PF_M_gethostcacheindexforkey,
PF_M_addwantedhostcachekey, PF_M_addwantedhostcachekey,
PF_M_getextresponse // #624 PF_M_getextresponse, // #624
PF_netaddress_resolve
}; };
int menu_numbuiltins = sizeof(menu_builtins)/sizeof(menu_builtins[0]); int menu_numbuiltins = sizeof(menu_builtins)/sizeof(menu_builtins[0]);

View file

@ -22,8 +22,7 @@ extern cvar_t scr_conalpha;
extern cvar_t gl_conback; extern cvar_t gl_conback;
extern cvar_t gl_font; extern cvar_t gl_font;
extern cvar_t gl_contrast; extern cvar_t gl_contrast;
extern cvar_t vid_conautoscale;
void R2D_Conback_Callback(struct cvar_s *var, char *oldvalue);
//We need this for minor things though, so we'll just use the slow accurate method. //We need this for minor things though, so we'll just use the slow accurate method.
@ -61,6 +60,8 @@ Image loading code must be ready for use at this point.
*/ */
void R2D_Init(void) void R2D_Init(void)
{ {
conback = NULL;
Shader_Init(); Shader_Init();
BE_Init(); BE_Init();
@ -77,13 +78,6 @@ void R2D_Init(void)
#pragma message("Fixme: move conwidth handling into here") #pragma message("Fixme: move conwidth handling into here")
if (font_conchar)
Font_Free(font_conchar);
font_conchar = Font_LoadFont(8*vid.pixelheight/vid.height, gl_font.string);
if (!font_conchar && *gl_font.string)
font_conchar = Font_LoadFont(8*vid.pixelheight/vid.height, "");
missing_texture = R_LoadTexture8("no_texture", 16, 16, (unsigned char*)r_notexture_mip + r_notexture_mip->offsets[0], IF_NOALPHA|IF_NOGAMMA, 0); missing_texture = R_LoadTexture8("no_texture", 16, 16, (unsigned char*)r_notexture_mip + r_notexture_mip->offsets[0], IF_NOALPHA|IF_NOGAMMA, 0);
draw_backtile = Draw_SafePicFromWad ("backtile"); draw_backtile = Draw_SafePicFromWad ("backtile");
@ -127,7 +121,9 @@ void R2D_Init(void)
"}\n" "}\n"
); );
Cvar_Hook(&gl_conback, R2D_Conback_Callback); Cvar_ForceCallback(&gl_conback);
Cvar_ForceCallback(&vid_conautoscale);
Cvar_ForceCallback(&gl_font);
} }
mpic_t *R2D_SafeCachePic (char *path) mpic_t *R2D_SafeCachePic (char *path)
@ -206,7 +202,7 @@ void R2D_Image(float x, float y, float w, float h, float s1, float t1, float s2,
draw_mesh_st[3][0] = s1; draw_mesh_st[3][0] = s1;
draw_mesh_st[3][1] = t2; draw_mesh_st[3][1] = t2;
BE_DrawMeshChain(pic, &draw_mesh, NULL, &pic->defaulttextures); BE_DrawMesh_Single(pic, &draw_mesh, NULL, &pic->defaulttextures);
} }
/*draws a block of the current colour on the screen*/ /*draws a block of the current colour on the screen*/
@ -225,9 +221,9 @@ void R2D_FillBlock(int x, int y, int w, int h)
draw_mesh_xyz[3][1] = y+h; draw_mesh_xyz[3][1] = y+h;
if (draw_mesh_colors[0][3] != 1) if (draw_mesh_colors[0][3] != 1)
BE_DrawMeshChain(draw_fill_trans, &draw_mesh, NULL, &draw_fill_trans->defaulttextures); BE_DrawMesh_Single(draw_fill_trans, &draw_mesh, NULL, &draw_fill_trans->defaulttextures);
else else
BE_DrawMeshChain(draw_fill, &draw_mesh, NULL, &draw_fill->defaulttextures); BE_DrawMesh_Single(draw_fill, &draw_mesh, NULL, &draw_fill->defaulttextures);
} }
void R2D_ScalePic (int x, int y, int width, int height, mpic_t *pic) void R2D_ScalePic (int x, int y, int width, int height, mpic_t *pic)
@ -261,8 +257,8 @@ void R2D_ConsoleBackground (int firstline, int lastline, qboolean forceopaque)
if (!conback) if (!conback)
return; return;
w = vid.conwidth; w = vid.width;
h = vid.conheight; h = vid.height;
if (forceopaque) if (forceopaque)
{ {
@ -284,19 +280,19 @@ void R2D_ConsoleBackground (int firstline, int lastline, qboolean forceopaque)
if (a >= 1) if (a >= 1)
{ {
R2D_ImageColours(1, 1, 1, 1); R2D_ImageColours(1, 1, 1, 1);
R2D_ScalePic(0, lastline-(int)vid.conheight, w, h, conback); R2D_ScalePic(0, lastline-(int)vid.height, w, h, conback);
} }
else else
{ {
R2D_ImageColours(1, 1, 1, a); R2D_ImageColours(1, 1, 1, a);
R2D_ScalePic (0, lastline - (int)vid.conheight, w, h, conback); R2D_ScalePic (0, lastline - (int)vid.height, w, h, conback);
R2D_ImageColours(1, 1, 1, 1); R2D_ImageColours(1, 1, 1, 1);
} }
} }
void R2D_EditorBackground (void) void R2D_EditorBackground (void)
{ {
R2D_ScalePic(0, 0, vid.conwidth, vid.conheight, conback); R2D_ScalePic(0, 0, vid.width, vid.height, conback);
} }
/* /*
@ -338,17 +334,33 @@ void R2D_TileClear (int x, int y, int w, int h)
draw_mesh_st[3][0] = newsl; draw_mesh_st[3][0] = newsl;
draw_mesh_st[3][1] = newth; draw_mesh_st[3][1] = newth;
BE_DrawMeshChain(draw_backtile, &draw_mesh, NULL, NULL); BE_DrawMesh_Single(draw_backtile, &draw_mesh, NULL, NULL);
} }
void R2D_Conback_Callback(struct cvar_s *var, char *oldvalue) void R2D_Conback_Callback(struct cvar_s *var, char *oldvalue)
{ {
if (*var->string) if (*var->string)
conback = R_RegisterPic(var->string); conback = R_RegisterPic(var->string);
if (!conback) if (!conback || !conback->width)
{
conback = R_RegisterCustom("console", NULL, NULL); conback = R_RegisterCustom("console", NULL, NULL);
if (!conback) if (!conback)
conback = R_RegisterPic("gfx/conback.lmp"); {
if (M_GameType() == MGT_QUAKE2)
conback = R_RegisterPic("pics/conback.pcx");
else
conback = R_RegisterPic("gfx/conback.lmp");
}
}
}
void R2D_Font_Callback(struct cvar_s *var, char *oldvalue)
{
if (font_conchar)
Font_Free(font_conchar);
font_conchar = Font_LoadFont(8*vid.pixelheight/vid.height, var->string);
if (!font_conchar && *var->string)
font_conchar = Font_LoadFont(8*vid.pixelheight/vid.height, "");
} }

View file

@ -1,265 +0,0 @@
/*
Copyright (C) 1996-1997 Id Software, Inc.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// r_efrag.c
#include "quakedef.h"
extern int r_framecount;
mnode_t *r_pefragtopnode;
//===========================================================================
/*
===============================================================================
ENTITY FRAGMENT FUNCTIONS
===============================================================================
*/
efrag_t **lastlink;
vec3_t r_emins, r_emaxs;
entity_t *r_addent;
/*
================
R_RemoveEfrags
Call when removing an object from the world or moving it to another position
================
*/
void R_RemoveEfrags (entity_t *ent)
{
efrag_t *ef, *old, *walk, **prev;
ef = ent->efrag;
while (ef)
{
prev = &ef->leaf->efrags;
while (1)
{
walk = *prev;
if (!walk)
break;
if (walk == ef)
{ // remove this fragment
*prev = ef->leafnext;
break;
}
else
prev = &walk->leafnext;
}
old = ef;
ef = ef->entnext;
// put it on the free list
old->entnext = cl.free_efrags;
cl.free_efrags = old;
}
ent->efrag = NULL;
}
/*
===================
R_SplitEntityOnNode
===================
*/
void R_Q1Q2BSP_SplitEntityOnNode (mnode_t *node)
{
efrag_t *ef;
mplane_t *splitplane;
mleaf_t *leaf;
int sides;
if (cl.worldmodel->fromgame == fg_quake2 || cl.worldmodel->fromgame == fg_quake3)
{
if (node->contents & Q2CONTENTS_SOLID)
{
return;
}
}
else
{
if (node->contents == Q1CONTENTS_SOLID)
{
return;
}
}
// add an efrag if the node is a leaf
if ( node->contents < 0)
{
if (!r_pefragtopnode)
r_pefragtopnode = node;
leaf = (mleaf_t *)node;
// grab an efrag off the free list
ef = cl.free_efrags;
if (!ef)
{
Con_Printf ("Too many efrags!\n");
return; // no free fragments...
}
cl.free_efrags = cl.free_efrags->entnext;
ef->entity = r_addent;
// add the entity link
*lastlink = ef;
lastlink = &ef->entnext;
ef->entnext = NULL;
// set the leaf links
ef->leaf = leaf;
ef->leafnext = leaf->efrags;
leaf->efrags = ef;
return;
}
// NODE_MIXED
splitplane = node->plane;
sides = BOX_ON_PLANE_SIDE(r_emins, r_emaxs, splitplane);
if (sides == 3)
{
// split on this plane
// if this is the first splitter of this bmodel, remember it
if (!r_pefragtopnode)
r_pefragtopnode = node;
}
// recurse down the contacted sides
if (sides & 1)
R_Q1Q2BSP_SplitEntityOnNode (node->children[0]);
if (sides & 2)
R_Q1Q2BSP_SplitEntityOnNode (node->children[1]);
}
/*
===========
R_AddEfrags
===========
*/
void R_AddEfrags (entity_t *ent)
{
model_t *entmodel;
int i;
if (!ent->model)
return;
if (ent == &r_worldentity)
return; // never add the world
r_addent = ent;
lastlink = &ent->efrag;
r_pefragtopnode = NULL;
entmodel = ent->model;
for (i=0 ; i<3 ; i++)
{
r_emins[i] = ent->origin[i] + entmodel->mins[i];
r_emaxs[i] = ent->origin[i] + entmodel->maxs[i];
}
if (cl.worldmodel->nodes)
R_Q1Q2BSP_SplitEntityOnNode (cl.worldmodel->nodes);
ent->topnode = r_pefragtopnode;
}
/*
================
R_StoreEfrags
// FIXME: a lot of this goes away with edge-based
================
*/
void R_StoreEfrags (efrag_t **ppefrag)
{
entity_t *pent;
model_t *clmodel;
efrag_t *pefrag;
extern cvar_t gl_part_flame;
extern cvar_t r_drawflame;
while ((pefrag = *ppefrag) != NULL)
{
pent = pefrag->entity;
clmodel = pent->model;
if ((!r_drawflame.ival) && (clmodel->engineflags & MDLF_FLAME))
break;
// switch (clmodel->type)
// {
// case mod_alias:
// case mod_brush:
// case mod_sprite:
// pent = pefrag->entity;
if ((pent->visframe != r_framecount) &&
(cl_numvisedicts < MAX_VISEDICTS))
{
pent->framestate.g[FS_REG].frametime[0] = cl.time;
pent->framestate.g[FS_REG].frametime[1] = cl.time;
cl_visedicts[cl_numvisedicts++] = *pent;
// mark that we've recorded this entity for this frame
pent->visframe = r_framecount;
// emit particles for statics (we don't need to cheat check statics)
if (clmodel->particleeffect >= 0 && gl_part_flame.ival)
{
// TODO: this is ugly.. assumes ent is in static entities, and subtracts
// pointer math to get an index to use in cl_static emit
// there needs to be a cleaner method for this
int i = (int)(pent - cl_static_entities);
P_EmitEffect(pent->origin, clmodel->particleeffect, &(cl_static_emit[i]));
}
}
ppefrag = &pefrag->leafnext;
// break;
// default:
// Con_Printf ("R_StoreEfrags: Bad entity type %d\n", clmodel->type);
// }
}
}

View file

@ -62,12 +62,14 @@ void R_Grenadetrail_Callback(struct cvar_s *var, char *oldvalue)
particleengine_t pe_null; particleengine_t pe_null;
particleengine_t pe_classic; particleengine_t pe_classic;
particleengine_t pe_darkplaces; particleengine_t pe_darkplaces;
particleengine_t pe_qmb;
particleengine_t pe_script; particleengine_t pe_script;
particleengine_t *particlesystem[] = particleengine_t *particlesystem[] =
{ {
&pe_script, &pe_script,
&pe_darkplaces, &pe_darkplaces,
&pe_qmb,
&pe_classic, &pe_classic,
&pe_null, &pe_null,
NULL, NULL,
@ -100,32 +102,32 @@ void R_ParticleSystem_Callback(struct cvar_s *var, char *oldvalue)
if (!pe) if (!pe)
Sys_Error("No particle system available. Please recompile."); Sys_Error("No particle system available. Please recompile.");
pe->InitParticles(); if (!pe->InitParticles())
{
Con_Printf("Particlesystem %s failed to init\n", pe->name1);
pe = &pe_null;
pe->InitParticles();
}
pe->ClearParticles(); pe->ClearParticles();
CL_RegisterParticles(); CL_RegisterParticles();
} }
cvar_t r_rockettrail = SCVARFC("r_rockettrail", "1", CVAR_SEMICHEAT, R_Rockettrail_Callback); cvar_t r_rockettrail = CVARFC("r_rockettrail", "1", CVAR_SEMICHEAT, R_Rockettrail_Callback);
cvar_t r_grenadetrail = SCVARFC("r_grenadetrail", "1", CVAR_SEMICHEAT, R_Grenadetrail_Callback); cvar_t r_grenadetrail = CVARFC("r_grenadetrail", "1", CVAR_SEMICHEAT, R_Grenadetrail_Callback);
#ifdef MINIMAL cvar_t r_particlesystem = CVARFC("r_particlesystem", IFMINIMAL("classic", "script"), CVAR_SEMICHEAT, R_ParticleSystem_Callback);
//minimal builds get a different default. cvar_t r_particlesdesc = CVARF("r_particlesdesc", "spikeset tsshaft", CVAR_SEMICHEAT);
cvar_t r_particlesystem = SCVARFC("r_particlesystem", "classic", CVAR_SEMICHEAT, R_ParticleSystem_Callback);
#else
cvar_t r_particlesystem = SCVARFC("r_particlesystem", "script", CVAR_SEMICHEAT, R_ParticleSystem_Callback);
#endif
cvar_t r_particlesdesc = SCVARF("r_particlesdesc", "spikeset tsshaft", CVAR_SEMICHEAT);
extern cvar_t r_bouncysparks; extern cvar_t r_bouncysparks;
extern cvar_t r_part_rain; extern cvar_t r_part_rain;
extern cvar_t r_bloodstains; extern cvar_t r_bloodstains;
extern cvar_t gl_part_flame; extern cvar_t gl_part_flame;
cvar_t r_part_rain_quantity = SCVAR("r_part_rain_quantity", "1"); cvar_t r_part_rain_quantity = CVAR("r_part_rain_quantity", "1");
cvar_t r_particle_tracelimit = SCVAR("r_particle_tracelimit", "250"); cvar_t r_particle_tracelimit = CVAR("r_particle_tracelimit", "250");
cvar_t r_part_sparks = SCVAR("r_part_sparks", "1"); cvar_t r_part_sparks = CVAR("r_part_sparks", "1");
cvar_t r_part_sparks_trifan = SCVAR("r_part_sparks_trifan", "1"); cvar_t r_part_sparks_trifan = CVAR("r_part_sparks_trifan", "1");
cvar_t r_part_sparks_textured = SCVAR("r_part_sparks_textured", "1"); cvar_t r_part_sparks_textured = CVAR("r_part_sparks_textured", "1");
cvar_t r_part_beams = SCVAR("r_part_beams", "1"); cvar_t r_part_beams = CVAR("r_part_beams", "1");
cvar_t r_part_contentswitch = SCVAR("r_part_contentswitch", "1"); cvar_t r_part_contentswitch = CVAR("r_part_contentswitch", "1");
particleengine_t *pe; particleengine_t *pe;
@ -206,7 +208,8 @@ qboolean TraceLineN (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal)
if (len < bestlen) if (len < bestlen)
{ {
bestlen = len; bestlen = len;
VectorCopy (trace.plane.normal, normal); if (normal)
VectorCopy (trace.plane.normal, normal);
VectorAdd (pe->origin, trace.endpos, impact); VectorAdd (pe->origin, trace.endpos, impact);
} }
@ -215,9 +218,12 @@ qboolean TraceLineN (vec3_t start, vec3_t end, vec3_t impact, vec3_t normal)
if (trace.startsolid) if (trace.startsolid)
{ {
VectorNormalize(delta); VectorNormalize(delta);
normal[0] = -delta[0]; if (normal)
normal[1] = -delta[1]; {
normal[2] = -delta[2]; normal[0] = -delta[0];
normal[1] = -delta[1];
normal[2] = -delta[2];
}
VectorCopy (start, impact); VectorCopy (start, impact);
return true; return true;
} }

View file

@ -32,7 +32,6 @@ static vec3_t modelorg; /*set before recursively entering the visible surface
static qbyte areabits[MAX_Q2MAP_AREAS/8]; static qbyte areabits[MAX_Q2MAP_AREAS/8];
model_t *currentmodel; model_t *currentmodel;
mesh_t nullmesh;
int lightmap_bytes; // 1, 3 or 4 int lightmap_bytes; // 1, 3 or 4
qboolean lightmap_bgra; qboolean lightmap_bgra;
@ -1795,10 +1794,6 @@ static qbyte *R_MarkLeafSurfaces_Q1 (void)
*surf->mark = surf; *surf->mark = surf;
} }
//deal with static ents.
if (leaf->efrags)
R_StoreEfrags (&leaf->efrags);
} }
} }
@ -1820,8 +1815,7 @@ static qbyte *R_MarkLeafSurfaces_Q1 (void)
Surf_RenderDynamicLightmaps (surf, shift); Surf_RenderDynamicLightmaps (surf, shift);
tex->vbo.meshlist[j] = NULL; tex->vbo.meshlist[j] = NULL;
surf->texturechain = surf->texinfo->texture->texturechain; surf->sbatch->mesh[surf->sbatch->meshes++] = surf->mesh;
surf->texinfo->texture->texturechain = surf;
} }
} }
} }
@ -1878,10 +1872,6 @@ start:
(*mark++)->visframe = r_framecount; (*mark++)->visframe = r_framecount;
} while (--c); } while (--c);
} }
// deal with model fragments in this leaf
if (pleaf->efrags)
R_StoreEfrags (&pleaf->efrags);
return; return;
} }
@ -1937,9 +1927,7 @@ start:
continue; // wrong side continue; // wrong side
Surf_RenderDynamicLightmaps (surf, shift); Surf_RenderDynamicLightmaps (surf, shift);
// if sorting by texture, just store it out surf->sbatch->mesh[surf->sbatch->meshes++] = surf->mesh;
surf->texturechain = surf->texinfo->texture->texturechain;
surf->texinfo->texture->texturechain = surf;
} }
} }
} }
@ -2046,8 +2034,7 @@ static void Surf_RecursiveQ2WorldNode (mnode_t *node)
Surf_RenderDynamicLightmaps (surf, shift); Surf_RenderDynamicLightmaps (surf, shift);
surf->texturechain = surf->texinfo->texture->texturechain; surf->sbatch->mesh[surf->sbatch->meshes++] = surf->mesh;
surf->texinfo->texture->texturechain = surf;
} }
@ -2114,10 +2101,6 @@ static void Surf_LeafWorldNode (void)
surf->visframe = r_framecount; surf->visframe = r_framecount;
if (surf->mark) if (surf->mark)
*surf->mark = surf; *surf->mark = surf;
/*
surf->texturechain = surf->texinfo->texture->texturechain;
surf->texinfo->texture->texturechain = surf;#
*/
} }
} while (--i); } while (--i);
@ -2141,8 +2124,7 @@ static void Surf_LeafWorldNode (void)
if (surf) if (surf)
{ {
tex->vbo.meshlist[j] = NULL; tex->vbo.meshlist[j] = NULL;
surf->texturechain = surf->texinfo->texture->texturechain; surf->sbatch->mesh[surf->sbatch->meshes++] = surf->mesh;
surf->texinfo->texture->texturechain = surf;
} }
} }
} }
@ -2150,26 +2132,24 @@ static void Surf_LeafWorldNode (void)
} }
#endif #endif
static void Surf_ClearChains(void)
{
int i;
for (i = 0; i < cl.worldmodel->numtextures; i++)
{
if (!cl.worldmodel->textures[i])
continue;
cl.worldmodel->textures[i]->texturechain = NULL;
cl.worldmodel->textures[i]->texturechain_tail = &cl.worldmodel->textures[i]->texturechain;
}
}
static void Surf_CleanChains(void) static void Surf_CleanChains(void)
{ {
int i;
model_t *model = cl.worldmodel; model_t *model = cl.worldmodel;
batch_t *batch;
for (i=0 ; i<model->numtextures ; i++) if (r_refdef.recurse)
{ {
model->textures[i]->texturechain = NULL; for (batch = model->batches; batch; batch = batch->next)
{
batch->meshes = batch->firstmesh;
}
}
else
{
for (batch = model->batches; batch; batch = batch->next)
{
batch->meshes = batch->firstmesh;
}
} }
} }
@ -2229,7 +2209,10 @@ void Surf_SetupFrame(void)
{ {
r_oldviewleaf = r_viewleaf; r_oldviewleaf = r_viewleaf;
r_oldviewleaf2 = r_viewleaf2; r_oldviewleaf2 = r_viewleaf2;
r_viewleaf = RMod_PointInLeaf (cl.worldmodel, r_origin); if (r_refdef.recurse)
r_viewleaf = RMod_PointInLeaf (cl.worldmodel, r_refdef.pvsorigin);
else
r_viewleaf = RMod_PointInLeaf (cl.worldmodel, r_origin);
if (!r_viewleaf) if (!r_viewleaf)
{ {
@ -2271,29 +2254,25 @@ R_DrawWorld
void Surf_DrawWorld (void) void Surf_DrawWorld (void)
{ {
int tmp;
qbyte *vis; qbyte *vis;
RSpeedLocals(); RSpeedLocals();
entity_t ent;
Surf_SetupFrame(); Surf_SetupFrame();
memset (&ent, 0, sizeof(ent));
ent.model = cl.worldmodel;
currentmodel = cl.worldmodel; currentmodel = cl.worldmodel;
currententity = &r_worldentity;
currententity = &ent;
#ifdef TERRAIN #ifdef TERRAIN
if (currentmodel->type == mod_heightmap) if (currentmodel->type == mod_heightmap)
GL_DrawHeightmapModel(currententity); GL_DrawHeightmapModel(currententity);
else else
#endif #endif
{ {
Surf_ClearChains();
RSpeedRemark(); RSpeedRemark();
#ifdef Q2BSPS #ifdef Q2BSPS
if (ent.model->fromgame == fg_quake2 || ent.model->fromgame == fg_quake3) if (currententity->model->fromgame == fg_quake2 || currententity->model->fromgame == fg_quake3)
{ {
int leafnum; int leafnum;
int clientarea; int clientarea;
@ -2308,7 +2287,7 @@ void Surf_DrawWorld (void)
CM_WriteAreaBits(cl.worldmodel, areabits, clientarea); CM_WriteAreaBits(cl.worldmodel, areabits, clientarea);
} }
#ifdef Q3BSPS #ifdef Q3BSPS
if (ent.model->fromgame == fg_quake3) if (currententity->model->fromgame == fg_quake3)
{ {
vis = R_MarkLeaves_Q3 (); vis = R_MarkLeaves_Q3 ();
Surf_LeafWorldNode (); Surf_LeafWorldNode ();
@ -2335,13 +2314,19 @@ void Surf_DrawWorld (void)
} }
} }
tmp = cl_numvisedicts;
CL_LinkStaticEntities(vis);
RSpeedEnd(RSPEED_WORLDNODE); RSpeedEnd(RSPEED_WORLDNODE);
TRACE(("dbg: calling BE_DrawWorld\n")); TRACE(("dbg: calling BE_DrawWorld\n"));
BE_DrawWorld(vis); BE_DrawWorld(vis);
Surf_CleanChains(); cl_numvisedicts = tmp;
/*FIXME: move this away*/
Surf_LessenStains(); Surf_LessenStains();
Surf_CleanChains();
} }
} }
@ -2514,6 +2499,7 @@ static int nColinElim;
================ ================
BuildSurfaceDisplayList BuildSurfaceDisplayList
FIXME: this is probably misplaced FIXME: this is probably misplaced
lightmaps are already built by the time this is called
================ ================
*/ */
void Surf_BuildSurfaceDisplayList (model_t *model, msurface_t *fa) void Surf_BuildSurfaceDisplayList (model_t *model, msurface_t *fa)
@ -2630,7 +2616,10 @@ static void Surf_CreateSurfaceLightmap (msurface_t *surf, int shift)
if (surf->texinfo->flags & TEX_SPECIAL) if (surf->texinfo->flags & TEX_SPECIAL)
surf->lightmaptexturenum = -1; surf->lightmaptexturenum = -1;
if (surf->lightmaptexturenum<0) if (surf->lightmaptexturenum<0)
{
surf->lightmaptexturenum = -1;
return; return;
}
smax = (surf->extents[0]>>4)+1; smax = (surf->extents[0]>>4)+1;
tmax = (surf->extents[1]>>4)+1; tmax = (surf->extents[1]>>4)+1;
@ -2691,6 +2680,7 @@ GL_BuildLightmaps
Builds the lightmap texture Builds the lightmap texture
with all the surfaces from all brush models with all the surfaces from all brush models
Groups surfaces into their respective batches (based on the lightmap number).
================== ==================
*/ */
void Surf_BuildLightmaps (void) void Surf_BuildLightmaps (void)
@ -2698,6 +2688,9 @@ void Surf_BuildLightmaps (void)
int i, j, t; int i, j, t;
model_t *m; model_t *m;
int shift; int shift;
msurface_t *surf;
batch_t *batch, *bstop;
vec3_t sn;
r_framecount = 1; // no dlightcache r_framecount = 1; // no dlightcache
@ -2735,23 +2728,70 @@ void Surf_BuildLightmaps (void)
currentmodel = m; currentmodel = m;
shift = Surf_LightmapShift(currentmodel); shift = Surf_LightmapShift(currentmodel);
for (t = 0; t < m->numtextures; t++) for (t = m->numtextures-1; t >= 0; t--)
{ {
m->textures[t]->wtexno = t;
bstop = m->batches;
batch = NULL;
for (i=0 ; i<m->numsurfaces ; i++) for (i=0 ; i<m->numsurfaces ; i++)
{//extra texture loop so we get slightly less texture switches {//extra texture loop so we get slightly less texture switches
if (m->surfaces[i].texinfo->texture == m->textures[t]) surf = m->surfaces + i;
if (surf->texinfo->texture == m->textures[t])
{ {
P_EmitSkyEffectTris(m, &m->surfaces[i]); P_EmitSkyEffectTris(m, surf);
Surf_CreateSurfaceLightmap (surf, shift);
if (m->textures[t]->shader->sort == SHADER_SORT_PORTAL)
{
if (surf->flags & SURF_PLANEBACK)
VectorNegate(surf->plane->normal, sn);
else
VectorCopy(surf->plane->normal, sn);
}
else
VectorClear(sn);
if (!batch || batch->lightmap != surf->lightmaptexturenum || (m->textures[t]->shader->sort == SHADER_SORT_PORTAL && !VectorCompare(sn, batch->normal)))
{
if (m->textures[t]->shader->sort == SHADER_SORT_PORTAL)
{
for (batch = m->batches; batch != bstop; batch = batch->next)
{
if (batch->lightmap == surf->lightmaptexturenum && VectorCompare(sn, batch->normal))
break;
}
}
else
{
for (batch = m->batches; batch != bstop; batch = batch->next)
{
if (batch->lightmap == surf->lightmaptexturenum)
break;
}
}
if (batch == bstop)
{
batch = Z_Malloc(sizeof(*batch));
batch->lightmap = surf->lightmaptexturenum;
batch->texture = m->textures[t];
batch->next = m->batches;
VectorCopy(sn, batch->normal);
m->batches = batch;
}
}
surf->sbatch = batch;
batch->maxmeshes++;
/*FIXME: move this into model-specific code*/
Surf_CreateSurfaceLightmap (m->surfaces + i, shift);
if (m->surfaces[i].mesh) //there are some surfaces that have a display list already (q3 ones) if (m->surfaces[i].mesh) //there are some surfaces that have a display list already (q3 ones)
continue; continue;
Surf_BuildSurfaceDisplayList (m, m->surfaces + i); Surf_BuildSurfaceDisplayList (m, surf);
} }
} }
} }
for (batch = m->batches; batch != NULL; batch = batch->next)
{
batch->mesh = BZ_Malloc(sizeof(*batch->mesh)*batch->maxmeshes*2);
}
BE_GenBrushModelVBO(m); BE_GenBrushModelVBO(m);
} }

View file

@ -38,7 +38,7 @@ typedef union {
#endif #endif
} texid_t; } texid_t;
static const texid_t r_nulltex = {0}; static const texid_t r_nulltex = {0};
#define TEXVALID(t) (t.num!=0) #define TEXVALID(t) ((t).num!=0)
#ifdef D3DQUAKE #ifdef D3DQUAKE
@ -58,14 +58,6 @@ static const texid_t r_nulltex = {0};
//============================================================================= //=============================================================================
typedef struct efrag_s
{
struct mleaf_s *leaf;
struct efrag_s *leafnext;
struct entity_s *entity;
struct efrag_s *entnext;
} efrag_t;
typedef enum { typedef enum {
RT_MODEL, RT_MODEL,
RT_POLY, RT_POLY,
@ -132,35 +124,17 @@ typedef struct entity_s
#endif #endif
} entity_t; } entity_t;
// !!! if this is changed, it must be changed in asm_draw.h too !!!
typedef struct typedef struct
{ {
vrect_t vrect; // subwindow in video for refresh vrect_t vrect; // subwindow in video for refresh
// FIXME: not need vrect next field here? // FIXME: not need vrect next field here?
vrect_t aliasvrect; // scaled Alias version
int vrectright, vrectbottom; // right & bottom screen coords
int aliasvrectright, aliasvrectbottom; // scaled Alias versions
float vrectrightedge; // rightmost right edge we care about,
// for use in edge list
float fvrectx, fvrecty; // for floating-point compares
float fvrectx_adj, fvrecty_adj; // left and top edges, for clamping
int vrect_x_adj_shift20; // (vrect.x + 0.5 - epsilon) << 20
int vrectright_adj_shift20; // (vrectright + 0.5 - epsilon) << 20
float fvrectright_adj, fvrectbottom_adj;
// right and bottom edges, for clamping
float fvrectright; // rightmost edge, for Alias clamping
float fvrectbottom; // bottommost edge, for Alias clamping
float horizontalFieldOfView; // at Z = 1.0, this many X is visible
// 2.0 = 90 degrees
float xOrigin; // should probably always be 0.5
float yOrigin; // between be around 0.3 to 0.5
vec3_t vieworg; vec3_t pvsorigin; /*render the view using this point for pvs (useful for mirror views)*/
vec3_t vieworg; /*logical view center*/
vec3_t viewangles; vec3_t viewangles;
vec3_t viewaxis[3]; /*forward, left, up (NOT RIGHT)*/
float fov_x, fov_y; float fov_x, fov_y;
int ambientlight;
int flags; int flags;
@ -168,7 +142,14 @@ typedef struct
float time; float time;
qboolean useperspective; float m_projection[16];
float m_view[16];
vrect_t pxrect; /*vrect, but in pixels rather than virtual coords*/
qboolean externalview; /*draw external models and not viewmodels*/
qboolean recurse; /*in a mirror/portal/half way through drawing something else*/
qboolean flipcull; /*reflected/flipped view, requires inverted culling*/
qboolean useperspective; /*not orthographic*/
} refdef_t; } refdef_t;
extern refdef_t r_refdef; extern refdef_t r_refdef;
@ -223,7 +204,7 @@ extern int lightmap_bytes; // 1, 3(, or 4)
void R_SetSky(char *skyname); /*override all sky shaders*/
#if defined(GLQUAKE) #if defined(GLQUAKE)
void GLR_Init (void); void GLR_Init (void);
@ -232,9 +213,7 @@ void GLR_InitTextures (void);
void GLR_InitEfrags (void); void GLR_InitEfrags (void);
void GLR_RenderView (void); // must set r_refdef first void GLR_RenderView (void); // must set r_refdef first
// called whenever r_refdef or vid change // called whenever r_refdef or vid change
void R_DrawPortal(struct batch_s *batch);
void GLR_AddEfrags (entity_t *ent);
void GLR_RemoveEfrags (entity_t *ent);
void GLR_PreNewMap(void); void GLR_PreNewMap(void);
void GLR_NewMap (void); void GLR_NewMap (void);
@ -254,10 +233,6 @@ void GLVID_Console_Resize(void);
int GLR_LightPoint (vec3_t p); int GLR_LightPoint (vec3_t p);
#endif #endif
void R_AddEfrags (entity_t *ent);
void R_RemoveEfrags (entity_t *ent);
enum imageflags enum imageflags
{ {
/*warning: many of these flags only apply the first time it is requested*/ /*warning: many of these flags only apply the first time it is requested*/
@ -283,7 +258,12 @@ enum uploadfmt
TF_HEIGHT8PAL, /*source data is palette values rather than actual heights, generate a fallback heightmap*/ TF_HEIGHT8PAL, /*source data is palette values rather than actual heights, generate a fallback heightmap*/
TF_H2_T7G1, /*8bit data, odd indexes give greyscale transparence*/ TF_H2_T7G1, /*8bit data, odd indexes give greyscale transparence*/
TF_H2_TRANS8_0, /*8bit data, 0 is transparent, not 255*/ TF_H2_TRANS8_0, /*8bit data, 0 is transparent, not 255*/
TF_H2_T4A4 /*8bit data, weird packing*/ TF_H2_T4A4, /*8bit data, weird packing*/
/*anything below requires a palette*/
TF_PALETTES,
TF_8PAL24,
TF_8PAL32
}; };
@ -326,7 +306,7 @@ enum uploadfmt
/*it seems a little excessive to have to include glquake (and windows headers), just to load some textures/shaders for the backend*/ /*it seems a little excessive to have to include glquake (and windows headers), just to load some textures/shaders for the backend*/
#ifdef GLQUAKE #ifdef GLQUAKE
texid_t GL_AllocNewTexture(void); texid_t GL_AllocNewTexture(void);
void GL_UploadFmt(texid_t tex, char *name, enum uploadfmt fmt, void *data, int width, int height, unsigned int flags); void GL_UploadFmt(texid_t tex, char *name, enum uploadfmt fmt, void *data, void *palette, int width, int height, unsigned int flags);
texid_t GL_LoadTextureFmt (char *identifier, int width, int height, enum uploadfmt fmt, void *data, unsigned int flags); texid_t GL_LoadTextureFmt (char *identifier, int width, int height, enum uploadfmt fmt, void *data, unsigned int flags);
#endif #endif
#ifdef D3DQUAKE #ifdef D3DQUAKE
@ -353,8 +333,6 @@ extern texid_t balltexture;
extern texid_t beamtexture; extern texid_t beamtexture;
extern texid_t ptritexture; extern texid_t ptritexture;
extern float r_projection_matrix[16];
extern float r_view_matrix[16];
void GL_ParallelPerspective(double xmin, double xmax, double ymax, double ymin, double znear, double zfar); void GL_ParallelPerspective(double xmin, double xmax, double ymax, double ymin, double znear, double zfar);
void GL_InfinatePerspective(double fovx, double fovy, double zNear); void GL_InfinatePerspective(double fovx, double fovy, double zNear);
@ -461,7 +439,6 @@ extern cvar_t r_xflip;
#endif #endif
extern cvar_t gl_clear; extern cvar_t gl_clear;
extern cvar_t gl_cull;
extern cvar_t gl_poly; extern cvar_t gl_poly;
extern cvar_t gl_smoothmodels; extern cvar_t gl_smoothmodels;
extern cvar_t gl_affinemodels; extern cvar_t gl_affinemodels;
@ -518,6 +495,12 @@ int rquant[RQUANT_MAX];
#define RQuantAdd(type,quant) rquant[type] += quant; #define RQuantAdd(type,quant) rquant[type] += quant;
#if defined(NDEBUG) || !defined(_WIN32)
#define RSpeedLocals()
#define RSpeedMark()
#define RSpeedRemark()
#define RSpeedEnd(spt)
#else
#define RSpeedLocals() int rsp #define RSpeedLocals() int rsp
#define RSpeedMark() int rsp = r_speeds.ival?Sys_DoubleTime()*1000000:0 #define RSpeedMark() int rsp = r_speeds.ival?Sys_DoubleTime()*1000000:0
#define RSpeedRemark() rsp = r_speeds.ival?Sys_DoubleTime()*1000000:0 #define RSpeedRemark() rsp = r_speeds.ival?Sys_DoubleTime()*1000000:0
@ -528,3 +511,4 @@ extern void (_stdcall *qglFinish) (void);
#else #else
#define RSpeedEnd(spt) rspeeds[spt] += r_speeds.value?Sys_DoubleTime()*1000000 - rsp:0 #define RSpeedEnd(spt) rspeeds[spt] += r_speeds.value?Sys_DoubleTime()*1000000 - rsp:0
#endif #endif
#endif

View file

@ -1,6 +1,8 @@
#include "quakedef.h" #include "quakedef.h"
#include "winquake.h" #include "winquake.h"
#include "pr_common.h" #include "pr_common.h"
#include "gl_draw.h"
#include <string.h>
refdef_t r_refdef; refdef_t r_refdef;
@ -38,59 +40,56 @@ void GL_Texturemode2d_Callback (struct cvar_s *var, char *oldvalue);
void GL_Texture_Anisotropic_Filtering_Callback (struct cvar_s *var, char *oldvalue); void GL_Texture_Anisotropic_Filtering_Callback (struct cvar_s *var, char *oldvalue);
#endif #endif
cvar_t _vid_wait_override = FCVAR ("vid_wait", "_vid_wait_override", "", cvar_t _vid_wait_override = CVARAF ("vid_wait", "",
CVAR_ARCHIVE); "_vid_wait_override", CVAR_ARCHIVE);
cvar_t _windowed_mouse = SCVARF ("_windowed_mouse","1", CVAR_ARCHIVE); cvar_t _windowed_mouse = CVARF ("_windowed_mouse","1",
CVAR_ARCHIVE);
cvar_t con_ocranaleds = SCVAR ("con_ocranaleds", "2"); cvar_t con_ocranaleds = CVAR ("con_ocranaleds", "2");
cvar_t d_palconvwrite = SCVAR ("d_palconvwrite", "1"); cvar_t d_palconvwrite = CVAR ("d_palconvwrite", "1");
cvar_t d_palremapsize = SCVARF ("d_palremapsize", "64", cvar_t d_palremapsize = CVARF ("d_palremapsize", "64",
CVAR_RENDERERLATCH); CVAR_RENDERERLATCH);
cvar_t cl_cursor = SCVAR ("cl_cursor", ""); cvar_t cl_cursor = CVAR ("cl_cursor", "");
cvar_t cl_cursorsize = SCVAR ("cl_cursorsize", "32"); cvar_t cl_cursorsize = CVAR ("cl_cursorsize", "32");
cvar_t cl_cursorbias = SCVAR ("cl_cursorbias", "4"); cvar_t cl_cursorbias = CVAR ("cl_cursorbias", "4");
cvar_t gl_nocolors = SCVAR ("gl_nocolors", "0"); cvar_t gl_nocolors = CVAR ("gl_nocolors", "0");
cvar_t gl_part_flame = SCVAR ("gl_part_flame", "1"); cvar_t gl_part_flame = CVAR ("gl_part_flame", "1");
//opengl library, blank means try default. //opengl library, blank means try default.
static cvar_t gl_driver = SCVARF ("gl_driver", "", static cvar_t gl_driver = CVARF ("gl_driver", "",
CVAR_ARCHIVE | CVAR_RENDERERLATCH); CVAR_ARCHIVE | CVAR_RENDERERLATCH);
cvar_t gl_shadeq1_name = SCVAR ("gl_shadeq1_name", "*"); cvar_t gl_shadeq1_name = CVAR ("gl_shadeq1_name", "*");
extern cvar_t r_vertexlight; extern cvar_t r_vertexlight;
cvar_t mod_md3flags = SCVAR ("mod_md3flags", "1"); cvar_t mod_md3flags = CVAR ("mod_md3flags", "1");
cvar_t r_ambient = SCVARF ("r_ambient", "0", cvar_t r_ambient = CVARF ("r_ambient", "0",
CVAR_CHEAT); CVAR_CHEAT);
cvar_t r_bloodstains = SCVAR ("r_bloodstains", "1"); cvar_t r_bloodstains = CVAR ("r_bloodstains", "1");
cvar_t r_bouncysparks = SCVARF ("r_bouncysparks", "0", cvar_t r_bouncysparks = CVARF ("r_bouncysparks", "0",
CVAR_ARCHIVE); CVAR_ARCHIVE);
cvar_t r_drawdisk = SCVAR ("r_drawdisk", "1"); cvar_t r_drawentities = CVAR ("r_drawentities", "1");
cvar_t r_drawentities = SCVAR ("r_drawentities", "1"); cvar_t r_drawflat = CVARF ("r_drawflat", "0",
cvar_t r_drawflat = SCVARF ("r_drawflat", "0",
CVAR_SEMICHEAT | CVAR_RENDERERCALLBACK | CVAR_SHADERSYSTEM); CVAR_SEMICHEAT | CVAR_RENDERERCALLBACK | CVAR_SHADERSYSTEM);
cvar_t gl_miptexLevel = SCVAR ("gl_miptexLevel", "0"); cvar_t gl_miptexLevel = CVAR ("gl_miptexLevel", "0");
cvar_t r_drawviewmodel = SCVAR ("r_drawviewmodel", "1"); cvar_t r_drawviewmodel = CVAR ("r_drawviewmodel", "1");
cvar_t r_drawviewmodelinvis = SCVAR ("r_drawviewmodelinvis", "0"); cvar_t r_drawviewmodelinvis = CVAR ("r_drawviewmodelinvis", "0");
#ifdef MINIMAL cvar_t r_dynamic = CVARF ("r_dynamic", IFMINIMAL("0","1"),
cvar_t r_dynamic = SCVARF ("r_dynamic", "0",
CVAR_ARCHIVE); CVAR_ARCHIVE);
#else cvar_t r_fastturb = CVARF ("r_fastturb", "0",
cvar_t r_dynamic = SCVARF ("r_dynamic", "1",
CVAR_ARCHIVE);
#endif
cvar_t r_fastsky = SCVARF ("r_fastsky", "0",
CVAR_SHADERSYSTEM); CVAR_SHADERSYSTEM);
cvar_t r_fastskycolour = SCVARF ("r_fastskycolour", "0", cvar_t r_fastsky = CVARF ("r_fastsky", "0",
CVAR_SHADERSYSTEM);
cvar_t r_fastskycolour = CVARF ("r_fastskycolour", "0",
CVAR_RENDERERCALLBACK|CVAR_SHADERSYSTEM); CVAR_RENDERERCALLBACK|CVAR_SHADERSYSTEM);
cvar_t r_fb_bmodels = SCVARF("gl_fb_bmodels", "1", cvar_t r_fb_bmodels = CVARF("gl_fb_bmodels", "1",
CVAR_SEMICHEAT|CVAR_RENDERERLATCH);
cvar_t r_fb_models = FCVAR ("r_fb_models", "gl_fb_models", "1",
CVAR_SEMICHEAT|CVAR_RENDERERLATCH); CVAR_SEMICHEAT|CVAR_RENDERERLATCH);
cvar_t r_fb_models = CVARAF ("r_fb_models", "1",
"gl_fb_models", CVAR_SEMICHEAT|CVAR_RENDERERLATCH);
cvar_t r_skin_overlays = SCVARF ("r_skin_overlays", "1", cvar_t r_skin_overlays = SCVARF ("r_skin_overlays", "1",
CVAR_SEMICHEAT|CVAR_RENDERERLATCH); CVAR_SEMICHEAT|CVAR_RENDERERLATCH);
cvar_t r_flashblend = SCVARF ("gl_flashblend", "0", cvar_t r_flashblend = SCVARF ("gl_flashblend", "0",
@ -115,39 +114,38 @@ cvar_t r_nolightdir = SCVAR ("r_nolightdir", "0");
cvar_t r_novis = SCVAR ("r_novis", "0"); cvar_t r_novis = SCVAR ("r_novis", "0");
cvar_t r_part_rain = SCVARF ("r_part_rain", "0", cvar_t r_part_rain = SCVARF ("r_part_rain", "0",
CVAR_ARCHIVE); CVAR_ARCHIVE);
//whack in a value of 2 and you get easily visible players.
cvar_t r_skyboxname = SCVARF ("r_skybox", "", cvar_t r_skyboxname = SCVARF ("r_skybox", "",
CVAR_RENDERERCALLBACK | CVAR_SHADERSYSTEM); CVAR_RENDERERCALLBACK | CVAR_SHADERSYSTEM);
cvar_t r_speeds = SCVAR ("r_speeds", "0"); cvar_t r_speeds = SCVAR ("r_speeds", "0");
cvar_t r_stainfadeammount = SCVAR ("r_stainfadeammount", "1"); cvar_t r_stainfadeammount = SCVAR ("r_stainfadeammount", "1");
cvar_t r_stainfadetime = SCVAR ("r_stainfadetime", "1"); cvar_t r_stainfadetime = SCVAR ("r_stainfadetime", "1");
cvar_t r_stains = SCVARFC("r_stains", "0.75", cvar_t r_stains = CVARFC("r_stains", IFMINIMAL("0","0.75"),
CVAR_ARCHIVE, CVAR_ARCHIVE,
Cvar_Limiter_ZeroToOne_Callback); Cvar_Limiter_ZeroToOne_Callback);
cvar_t r_wallcolour = SCVARF ("r_wallcolour", "255 255 255", cvar_t r_wallcolour = CVARF ("r_wallcolour", "255 255 255",
CVAR_RENDERERCALLBACK|CVAR_SHADERSYSTEM);//FIXME: broken CVAR_RENDERERCALLBACK|CVAR_SHADERSYSTEM);//FIXME: broken
cvar_t r_walltexture = SCVARF ("r_walltexture", "", cvar_t r_walltexture = CVARF ("r_walltexture", "",
CVAR_RENDERERCALLBACK|CVAR_SHADERSYSTEM); //FIXME: broken CVAR_RENDERERCALLBACK|CVAR_SHADERSYSTEM); //FIXME: broken
cvar_t r_wateralpha = SCVARF ("r_wateralpha", "1", cvar_t r_wateralpha = CVARF ("r_wateralpha", "1",
CVAR_SHADERSYSTEM); CVAR_SHADERSYSTEM);
cvar_t r_waterwarp = SCVARF ("r_waterwarp", "1", cvar_t r_waterwarp = CVARF ("r_waterwarp", "1",
CVAR_ARCHIVE); CVAR_ARCHIVE);
cvar_t r_replacemodels = SCVARF ("r_replacemodels", "md3 md2", cvar_t r_replacemodels = CVARF ("r_replacemodels", IFMINIMAL("","md3 md2"),
CVAR_ARCHIVE); CVAR_ARCHIVE);
//otherwise it would defeat the point. //otherwise it would defeat the point.
cvar_t scr_allowsnap = SCVARF ("scr_allowsnap", "1", cvar_t scr_allowsnap = CVARF ("scr_allowsnap", "1",
CVAR_NOTFROMSERVER); CVAR_NOTFROMSERVER);
cvar_t scr_centersbar = SCVAR ("scr_centersbar", "0"); cvar_t scr_centersbar = CVAR ("scr_centersbar", "0");
cvar_t scr_centertime = SCVAR ("scr_centertime", "2"); cvar_t scr_centertime = CVAR ("scr_centertime", "2");
cvar_t scr_chatmodecvar = SCVAR ("scr_chatmode", "0"); cvar_t scr_chatmodecvar = CVAR ("scr_chatmode", "0");
cvar_t scr_conalpha = SCVARC ("scr_conalpha", "0.7", cvar_t scr_conalpha = CVARC ("scr_conalpha", "0.7",
Cvar_Limiter_ZeroToOne_Callback); Cvar_Limiter_ZeroToOne_Callback);
cvar_t scr_consize = SCVAR ("scr_consize", "0.5"); cvar_t scr_consize = CVAR ("scr_consize", "0.5");
cvar_t scr_conspeed = SCVAR ("scr_conspeed", "300"); cvar_t scr_conspeed = CVAR ("scr_conspeed", "300");
// 10 - 170 // 10 - 170
cvar_t scr_fov = SCVARFC("fov", "90", cvar_t scr_fov = CVARFC("fov", "90",
CVAR_ARCHIVE, CVAR_ARCHIVE,
SCR_Fov_Callback); SCR_Fov_Callback);
cvar_t scr_printspeed = SCVAR ("scr_printspeed", "8"); cvar_t scr_printspeed = SCVAR ("scr_printspeed", "8");
@ -156,44 +154,44 @@ cvar_t scr_showturtle = SCVAR ("showturtle", "0");
cvar_t scr_turtlefps = SCVAR ("scr_turtlefps", "10"); cvar_t scr_turtlefps = SCVAR ("scr_turtlefps", "10");
cvar_t scr_sshot_compression = SCVAR ("scr_sshot_compression", "75"); cvar_t scr_sshot_compression = SCVAR ("scr_sshot_compression", "75");
cvar_t scr_sshot_type = SCVAR ("scr_sshot_type", "jpg"); cvar_t scr_sshot_type = SCVAR ("scr_sshot_type", "jpg");
cvar_t scr_viewsize = SCVARFC("viewsize", "100", cvar_t scr_viewsize = CVARFC("viewsize", "100",
CVAR_ARCHIVE, CVAR_ARCHIVE,
SCR_Viewsize_Callback); SCR_Viewsize_Callback);
cvar_t vid_conautoscale = SCVARF ("vid_conautoscale", "0", cvar_t vid_conautoscale = CVARF ("vid_conautoscale", "0",
CVAR_ARCHIVE | CVAR_RENDERERCALLBACK); CVAR_ARCHIVE | CVAR_RENDERERCALLBACK);
cvar_t vid_conheight = SCVARF ("vid_conheight", "0", cvar_t vid_conheight = CVARF ("vid_conheight", "0",
CVAR_ARCHIVE); CVAR_ARCHIVE);
cvar_t vid_conwidth = SCVARF ("vid_conwidth", "0", cvar_t vid_conwidth = CVARF ("vid_conwidth", "0",
CVAR_ARCHIVE | CVAR_RENDERERCALLBACK); CVAR_ARCHIVE | CVAR_RENDERERCALLBACK);
//see R_RestartRenderer_f for the effective default 'if (newr.renderer == -1)'. //see R_RestartRenderer_f for the effective default 'if (newr.renderer == -1)'.
cvar_t vid_renderer = SCVARF ("vid_renderer", "", cvar_t vid_renderer = CVARF ("vid_renderer", "",
CVAR_ARCHIVE | CVAR_RENDERERLATCH); CVAR_ARCHIVE | CVAR_RENDERERLATCH);
static cvar_t vid_allow_modex = SCVARF ("vid_allow_modex", "1", static cvar_t vid_allow_modex = CVARF ("vid_allow_modex", "1",
CVAR_ARCHIVE | CVAR_RENDERERLATCH); //FIXME: remove CVAR_ARCHIVE | CVAR_RENDERERLATCH); //FIXME: remove
static cvar_t vid_bpp = SCVARF ("vid_bpp", "32", static cvar_t vid_bpp = CVARF ("vid_bpp", "32",
CVAR_ARCHIVE | CVAR_RENDERERLATCH); CVAR_ARCHIVE | CVAR_RENDERERLATCH);
static cvar_t vid_desktopsettings = SCVARF ("vid_desktopsettings", "0", static cvar_t vid_desktopsettings = CVARF ("vid_desktopsettings", "0",
CVAR_ARCHIVE | CVAR_RENDERERLATCH); CVAR_ARCHIVE | CVAR_RENDERERLATCH);
#ifdef NPQTV #ifdef NPQTV
static cvar_t vid_fullscreen_npqtv = SCVARF ("vid_fullscreen", "1", static cvar_t vid_fullscreen_npqtv = CVARF ("vid_fullscreen", "1",
CVAR_ARCHIVE | CVAR_RENDERERLATCH); CVAR_ARCHIVE | CVAR_RENDERERLATCH);
cvar_t vid_fullscreen = SCVARF ("vid_fullscreen_embedded", "0", cvar_t vid_fullscreen = CVARF ("vid_fullscreen_embedded", "0",
CVAR_ARCHIVE | CVAR_RENDERERLATCH); CVAR_ARCHIVE | CVAR_RENDERERLATCH);
#else #else
static cvar_t vid_fullscreen = SCVARF ("vid_fullscreen", "1", static cvar_t vid_fullscreen = CVARF ("vid_fullscreen", "1",
CVAR_ARCHIVE | CVAR_RENDERERLATCH); CVAR_ARCHIVE | CVAR_RENDERERLATCH);
#endif #endif
cvar_t vid_height = SCVARF ("vid_height", "0", cvar_t vid_height = CVARF ("vid_height", "0",
CVAR_ARCHIVE | CVAR_RENDERERLATCH); CVAR_ARCHIVE | CVAR_RENDERERLATCH);
static cvar_t vid_multisample = SCVARF ("vid_multisample", "0", cvar_t vid_multisample = CVARF ("vid_multisample", "0",
CVAR_ARCHIVE | CVAR_RENDERERLATCH); CVAR_ARCHIVE | CVAR_RENDERERLATCH);
static cvar_t vid_refreshrate = SCVARF ("vid_displayfrequency", "0", static cvar_t vid_refreshrate = CVARF ("vid_displayfrequency", "0",
CVAR_ARCHIVE | CVAR_RENDERERLATCH); CVAR_ARCHIVE | CVAR_RENDERERLATCH);
cvar_t vid_wndalpha = SCVAR ("vid_wndalpha", "1"); cvar_t vid_wndalpha = CVAR ("vid_wndalpha", "1");
//more readable defaults to match conwidth/conheight. //more readable defaults to match conwidth/conheight.
cvar_t vid_width = SCVARF ("vid_width", "0", cvar_t vid_width = CVARF ("vid_width", "0",
CVAR_ARCHIVE | CVAR_RENDERERLATCH); CVAR_ARCHIVE | CVAR_RENDERERLATCH);
extern cvar_t bul_backcol; extern cvar_t bul_backcol;
@ -223,7 +221,6 @@ extern cvar_t r_mirroralpha;
extern cvar_t r_netgraph; extern cvar_t r_netgraph;
extern cvar_t r_norefresh; extern cvar_t r_norefresh;
extern cvar_t r_novis; extern cvar_t r_novis;
extern cvar_t r_shadows;
extern cvar_t r_speeds; extern cvar_t r_speeds;
extern cvar_t r_waterwarp; extern cvar_t r_waterwarp;
@ -251,15 +248,14 @@ cvar_t gl_bump = SCVARF ("gl_bump", "0",
CVAR_ARCHIVE | CVAR_RENDERERLATCH); CVAR_ARCHIVE | CVAR_RENDERERLATCH);
cvar_t gl_compress = SCVARF ("gl_compress", "0", cvar_t gl_compress = SCVARF ("gl_compress", "0",
CVAR_ARCHIVE); CVAR_ARCHIVE);
cvar_t gl_conback = SCVARF ("gl_conback", "", cvar_t gl_conback = CVARFC ("gl_conback", "",
CVAR_RENDERERCALLBACK); CVAR_RENDERERCALLBACK, R2D_Conback_Callback);
cvar_t gl_contrast = SCVAR ("gl_contrast", "1"); cvar_t gl_contrast = SCVAR ("gl_contrast", "1");
cvar_t gl_detail = SCVARF ("gl_detail", "0", cvar_t gl_detail = SCVARF ("gl_detail", "0",
CVAR_ARCHIVE); CVAR_ARCHIVE);
cvar_t gl_detailscale = SCVAR ("gl_detailscale", "5"); cvar_t gl_detailscale = SCVAR ("gl_detailscale", "5");
cvar_t gl_font = SCVARF ("gl_font", "", cvar_t gl_font = SCVARF ("gl_font", "",
CVAR_RENDERERCALLBACK); CVAR_RENDERERCALLBACK);
cvar_t gl_fontinwardstep = SCVAR ("gl_fontinwardstep", "0");
cvar_t gl_lateswap = SCVAR ("gl_lateswap", "0"); cvar_t gl_lateswap = SCVAR ("gl_lateswap", "0");
cvar_t gl_lerpimages = SCVAR ("gl_lerpimages", "1"); cvar_t gl_lerpimages = SCVAR ("gl_lerpimages", "1");
cvar_t gl_lightmap_shift = SCVARF ("gl_lightmap_shift", "0", cvar_t gl_lightmap_shift = SCVARF ("gl_lightmap_shift", "0",
@ -269,7 +265,7 @@ cvar_t gl_lightmap_shift = SCVARF ("gl_lightmap_shift", "0",
cvar_t gl_load24bit = SCVARF ("gl_load24bit", "1", cvar_t gl_load24bit = SCVARF ("gl_load24bit", "1",
CVAR_ARCHIVE); CVAR_ARCHIVE);
cvar_t gl_max_size = SCVAR ("gl_max_size", "1024"); cvar_t gl_max_size = SCVARF ("gl_max_size", "1024", CVAR_RENDERERLATCH);
cvar_t gl_maxshadowlights = SCVARF ("gl_maxshadowlights", "2", cvar_t gl_maxshadowlights = SCVARF ("gl_maxshadowlights", "2",
CVAR_ARCHIVE); CVAR_ARCHIVE);
cvar_t gl_menutint_shader = SCVAR ("gl_menutint_shader", "1"); cvar_t gl_menutint_shader = SCVAR ("gl_menutint_shader", "1");
@ -281,8 +277,6 @@ cvar_t gl_mindist = SCVARF ("gl_mindist", "4",
cvar_t gl_motionblur = SCVARF ("gl_motionblur", "0", cvar_t gl_motionblur = SCVARF ("gl_motionblur", "0",
CVAR_ARCHIVE); CVAR_ARCHIVE);
cvar_t gl_motionblurscale = SCVAR ("gl_motionblurscale", "1"); cvar_t gl_motionblurscale = SCVAR ("gl_motionblurscale", "1");
cvar_t gl_mylumassuck = SCVAR ("gl_mylumassuck", "0");
cvar_t gl_nobind = SCVAR ("gl_nobind", "0");
cvar_t gl_overbright = SCVARF ("gl_overbright", "0", cvar_t gl_overbright = SCVARF ("gl_overbright", "0",
CVAR_ARCHIVE); CVAR_ARCHIVE);
cvar_t gl_overbright_all = SCVARF ("gl_overbright_all", "0", cvar_t gl_overbright_all = SCVARF ("gl_overbright_all", "0",
@ -295,23 +289,19 @@ cvar_t gl_schematics = SCVAR ("gl_schematics", "0");
cvar_t gl_skyboxdist = SCVAR ("gl_skyboxdist", "0"); //0 = guess. cvar_t gl_skyboxdist = SCVAR ("gl_skyboxdist", "0"); //0 = guess.
cvar_t gl_smoothcrosshair = SCVAR ("gl_smoothcrosshair", "1"); cvar_t gl_smoothcrosshair = SCVAR ("gl_smoothcrosshair", "1");
//gl blends. Set this to 1 to stop the outside of your conchars from being visible
cvar_t gl_smoothfont = SCVARF ("gl_smoothfont", "1",
CVAR_RENDERERCALLBACK);
#ifdef SPECULAR #ifdef SPECULAR
cvar_t gl_specular = SCVAR ("gl_specular", "0"); cvar_t gl_specular = SCVAR ("gl_specular", "0");
#endif #endif
// The callbacks are not in D3D yet (also ugly way of seperating this) // The callbacks are not in D3D yet (also ugly way of seperating this)
#ifdef GLQUAKE #ifdef GLQUAKE
cvar_t gl_texture_anisotropic_filtering = SCVARFC("gl_texture_anisotropic_filtering", "0", cvar_t gl_texture_anisotropic_filtering = CVARFC("gl_texture_anisotropic_filtering", "0",
CVAR_ARCHIVE | CVAR_RENDERERCALLBACK, CVAR_ARCHIVE | CVAR_RENDERERCALLBACK,
GL_Texture_Anisotropic_Filtering_Callback); GL_Texture_Anisotropic_Filtering_Callback);
cvar_t gl_texturemode = SCVARFC("gl_texturemode", "GL_LINEAR_MIPMAP_NEAREST", cvar_t gl_texturemode = CVARFC("gl_texturemode", "GL_LINEAR_MIPMAP_NEAREST",
CVAR_ARCHIVE | CVAR_RENDERERCALLBACK, CVAR_ARCHIVE | CVAR_RENDERERCALLBACK,
GL_Texturemode_Callback); GL_Texturemode_Callback);
cvar_t gl_texturemode2d = SCVARFC("gl_texturemode2d", "GL_LINEAR", cvar_t gl_texturemode2d = CVARFC("gl_texturemode2d", "GL_LINEAR",
CVAR_ARCHIVE | CVAR_RENDERERCALLBACK, CVAR_ARCHIVE | CVAR_RENDERERCALLBACK,
GL_Texturemode2d_Callback); GL_Texturemode2d_Callback);
#endif #endif
@ -320,6 +310,7 @@ cvar_t gl_triplebuffer = SCVARF ("gl_triplebuffer", "1",
CVAR_ARCHIVE); CVAR_ARCHIVE);
cvar_t gl_ztrick = SCVAR ("gl_ztrick", "0"); cvar_t gl_ztrick = SCVAR ("gl_ztrick", "0");
cvar_t r_noportals = SCVAR ("r_noportals", "0");
cvar_t r_noaliasshadows = SCVARF ("r_noaliasshadows", "0", cvar_t r_noaliasshadows = SCVARF ("r_noaliasshadows", "0",
CVAR_ARCHIVE); CVAR_ARCHIVE);
@ -335,7 +326,6 @@ cvar_t r_shadow_realtime_world_shadows = SCVARF ("r_shadow_realtime_world_shado
cvar_t r_shadow_realtime_dlight = SCVARF ("r_shadow_realtime_dlight", "1", CVAR_ARCHIVE); cvar_t r_shadow_realtime_dlight = SCVARF ("r_shadow_realtime_dlight", "1", CVAR_ARCHIVE);
cvar_t r_shadow_realtime_dlight_shadows = SCVARF ("r_shadow_realtime_dlight_shadows", "1", CVAR_ARCHIVE); cvar_t r_shadow_realtime_dlight_shadows = SCVARF ("r_shadow_realtime_dlight_shadows", "1", CVAR_ARCHIVE);
cvar_t r_shadow_realtime_world_lightmaps = SCVARF ("r_shadow_realtime_world_lightmaps", "0.8", 0); cvar_t r_shadow_realtime_world_lightmaps = SCVARF ("r_shadow_realtime_world_lightmaps", "0.8", 0);
cvar_t r_shadows = SCVARF ("r_shadows", "0", CVAR_ARCHIVE | CVAR_RENDERERLATCH);
cvar_t r_vertexdlights = SCVAR ("r_vertexdlights", "0"); cvar_t r_vertexdlights = SCVAR ("r_vertexdlights", "0");
@ -383,7 +373,6 @@ void GLRenderer_Init(void)
Cvar_Register (&gl_clear, GLRENDEREROPTIONS); Cvar_Register (&gl_clear, GLRENDEREROPTIONS);
Cvar_Register (&gl_cull, GLRENDEREROPTIONS);
Cvar_Register (&gl_smoothmodels, GRAPHICALNICETIES); Cvar_Register (&gl_smoothmodels, GRAPHICALNICETIES);
Cvar_Register (&gl_affinemodels, GLRENDEREROPTIONS); Cvar_Register (&gl_affinemodels, GLRENDEREROPTIONS);
Cvar_Register (&gl_nohwblend, GLRENDEREROPTIONS); Cvar_Register (&gl_nohwblend, GLRENDEREROPTIONS);
@ -394,7 +383,7 @@ void GLRenderer_Init(void)
Cvar_Register (&gl_lateswap, GLRENDEREROPTIONS); Cvar_Register (&gl_lateswap, GLRENDEREROPTIONS);
Cvar_Register (&gl_lerpimages, GLRENDEREROPTIONS); Cvar_Register (&gl_lerpimages, GLRENDEREROPTIONS);
Cvar_Register (&r_shadows, GLRENDEREROPTIONS); Cvar_Register (&r_noportals, GLRENDEREROPTIONS);
Cvar_Register (&r_noaliasshadows, GLRENDEREROPTIONS); Cvar_Register (&r_noaliasshadows, GLRENDEREROPTIONS);
Cvar_Register (&gl_maxshadowlights, GLRENDEREROPTIONS); Cvar_Register (&gl_maxshadowlights, GLRENDEREROPTIONS);
Cvar_Register (&r_shadow_bumpscale_basetexture, GLRENDEREROPTIONS); Cvar_Register (&r_shadow_bumpscale_basetexture, GLRENDEREROPTIONS);
@ -416,8 +405,6 @@ void GLRenderer_Init(void)
Cvar_Register (&gl_maxdist, GLRENDEREROPTIONS); Cvar_Register (&gl_maxdist, GLRENDEREROPTIONS);
Cvar_Register (&vid_multisample, GLRENDEREROPTIONS); Cvar_Register (&vid_multisample, GLRENDEREROPTIONS);
Cvar_Register (&gl_fontinwardstep, GRAPHICALNICETIES);
Cvar_Register (&gl_smoothfont, GRAPHICALNICETIES);
Cvar_Register (&gl_smoothcrosshair, GRAPHICALNICETIES); Cvar_Register (&gl_smoothcrosshair, GRAPHICALNICETIES);
Cvar_Register (&gl_bump, GRAPHICALNICETIES); Cvar_Register (&gl_bump, GRAPHICALNICETIES);
@ -440,10 +427,8 @@ void GLRenderer_Init(void)
Cvar_Register (&r_polygonoffset_submodel_factor, GLRENDEREROPTIONS); Cvar_Register (&r_polygonoffset_submodel_factor, GLRENDEREROPTIONS);
Cvar_Register (&r_polygonoffset_submodel_offset, GLRENDEREROPTIONS); Cvar_Register (&r_polygonoffset_submodel_offset, GLRENDEREROPTIONS);
Cvar_Register (&gl_nobind, GLRENDEREROPTIONS);
Cvar_Register (&gl_picmip, GLRENDEREROPTIONS); Cvar_Register (&gl_picmip, GLRENDEREROPTIONS);
Cvar_Register (&gl_picmip2d, GLRENDEREROPTIONS); Cvar_Register (&gl_picmip2d, GLRENDEREROPTIONS);
Cvar_Register (&r_drawdisk, GLRENDEREROPTIONS);
Cvar_Register (&gl_texturemode, GLRENDEREROPTIONS); Cvar_Register (&gl_texturemode, GLRENDEREROPTIONS);
Cvar_Register (&gl_texturemode2d, GLRENDEREROPTIONS); Cvar_Register (&gl_texturemode2d, GLRENDEREROPTIONS);
@ -480,8 +465,6 @@ void GLRenderer_Init(void)
Cvar_Register (&gl_blendsprites, GLRENDEREROPTIONS); Cvar_Register (&gl_blendsprites, GLRENDEREROPTIONS);
Cvar_Register (&gl_mylumassuck, GLRENDEREROPTIONS);
Cvar_Register (&gl_lightmap_shift, GLRENDEREROPTIONS); Cvar_Register (&gl_lightmap_shift, GLRENDEREROPTIONS);
Cvar_Register (&gl_menutint_shader, GLRENDEREROPTIONS); Cvar_Register (&gl_menutint_shader, GLRENDEREROPTIONS);
@ -625,6 +608,7 @@ void Renderer_Init(void)
Cvar_Register (&r_nolerp, GRAPHICALNICETIES); Cvar_Register (&r_nolerp, GRAPHICALNICETIES);
Cvar_Register (&r_nolightdir, GRAPHICALNICETIES); Cvar_Register (&r_nolightdir, GRAPHICALNICETIES);
Cvar_Register (&r_fastturb, GRAPHICALNICETIES);
Cvar_Register (&r_fastsky, GRAPHICALNICETIES); Cvar_Register (&r_fastsky, GRAPHICALNICETIES);
Cvar_Register (&r_fastskycolour, GRAPHICALNICETIES); Cvar_Register (&r_fastskycolour, GRAPHICALNICETIES);
Cvar_Register (&r_wateralpha, GRAPHICALNICETIES); Cvar_Register (&r_wateralpha, GRAPHICALNICETIES);
@ -733,10 +717,6 @@ void (*R_PushDlights) (void);
void (*R_AddStain) (vec3_t org, float red, float green, float blue, float radius); void (*R_AddStain) (vec3_t org, float red, float green, float blue, float radius);
void (*R_LessenStains) (void); void (*R_LessenStains) (void);
void (*Media_ShowFrameBGR_24_Flip) (qbyte *framedata, int inwidth, int inheight); //input is bottom up...
void (*Media_ShowFrameRGBA_32) (qbyte *framedata, int inwidth, int inheight); //top down
void (*Media_ShowFrame8bit) (qbyte *framedata, int inwidth, int inheight, qbyte *palette); //paletted topdown (framedata is 8bit indexes into palette)
void (*Mod_Init) (void); void (*Mod_Init) (void);
void (*Mod_ClearAll) (void); void (*Mod_ClearAll) (void);
struct model_s *(*Mod_ForName) (char *name, qboolean crash); struct model_s *(*Mod_ForName) (char *name, qboolean crash);
@ -818,10 +798,6 @@ rendererinfo_t dedicatedrendererinfo = {
NULL, //R_AddStain; NULL, //R_AddStain;
NULL, //R_LessenStains; NULL, //R_LessenStains;
NULL, //Media_ShowFrameBGR_24_Flip;
NULL, //Media_ShowFrameRGBA_32;
NULL, //Media_ShowFrame8bit;
#if defined(GLQUAKE) || defined(D3DQUAKE) #if defined(GLQUAKE) || defined(D3DQUAKE)
RMod_Init, RMod_Init,
RMod_ClearAll, RMod_ClearAll,
@ -951,7 +927,7 @@ typedef struct {
menucombo_t *conscalecombo; menucombo_t *conscalecombo;
menucombo_t *bppcombo; menucombo_t *bppcombo;
menucombo_t *refreshratecombo; menucombo_t *refreshratecombo;
menucombo_t *texturefiltercombo; menucombo_t *vsynccombo;
menuedit_t *customwidth; menuedit_t *customwidth;
menuedit_t *customheight; menuedit_t *customheight;
} videomenuinfo_t; } videomenuinfo_t;
@ -1023,19 +999,20 @@ qboolean M_VideoApply (union menuoption_s *op,struct menu_s *menu,int key)
break; break;
} }
switch(info->texturefiltercombo->selectedoption) switch(info->vsynccombo->selectedoption)
{ {
case 0: case 0:
Cbuf_AddText("gl_texturemode gl_nearest_mipmap_nearest\n", RESTRICT_LOCAL); Cbuf_AddText(va("vid_wait %i\n", 0), RESTRICT_LOCAL);
break; break;
case 1: case 1:
Cbuf_AddText("gl_texturemode gl_linear_mipmap_nearest\n", RESTRICT_LOCAL); Cbuf_AddText(va("vid_wait %i\n", 1), RESTRICT_LOCAL);
break; break;
case 2: case 2:
Cbuf_AddText("gl_texturemode gl_linear_mipmap_linear\n", RESTRICT_LOCAL); Cbuf_AddText(va("vid_wait %i\n", 2), RESTRICT_LOCAL);
break; break;
} }
Cbuf_AddText(va("vid_bpp %i\n", selectedbpp), RESTRICT_LOCAL); Cbuf_AddText(va("vid_bpp %i\n", selectedbpp), RESTRICT_LOCAL);
switch(info->refreshratecombo->selectedoption) switch(info->refreshratecombo->selectedoption)
@ -1085,11 +1062,9 @@ qboolean M_VideoApply (union menuoption_s *op,struct menu_s *menu,int key)
} }
void M_Menu_Video_f (void) void M_Menu_Video_f (void)
{ {
extern cvar_t r_stains, v_contrast; extern cvar_t v_contrast;
#if defined(GLQUAKE) #if defined(GLQUAKE)
extern cvar_t r_bloom;
#endif #endif
extern cvar_t r_bouncysparks;
static const char *modenames[128] = {"Custom"}; static const char *modenames[128] = {"Custom"};
static const char *rendererops[] = { static const char *rendererops[] = {
#ifdef GLQUAKE #ifdef GLQUAKE
@ -1114,6 +1089,7 @@ void M_Menu_Video_f (void)
"Trilinear", "Trilinear",
NULL NULL
}; };
static const char *refreshrates[] = static const char *refreshrates[] =
{ {
"0Hz (OS Driver refresh rate)", "0Hz (OS Driver refresh rate)",
@ -1127,17 +1103,38 @@ void M_Menu_Video_f (void)
NULL NULL
}; };
static const char *vsyncoptions[] =
{
"Off",
"Wait for Vertical Sync",
"Wait for Display Enable",
NULL
};
videomenuinfo_t *info; videomenuinfo_t *info;
menu_t *menu;
int prefabmode; int prefabmode;
int prefab2dmode; int prefab2dmode;
int currentbpp; int currentbpp;
int currentrefreshrate; int currentrefreshrate;
#ifdef GLQUAKE int currentvsync;
int currenttexturefilter; int aspectratio3d;
#endif int aspectratio2d;
char *aspectratio23d;
char *aspectratio22d;
char *rendererstring;
static char current3dres[10]; // enough to fit 1920x1200
static char current2dres[10]; // same as above
static char currenthz[6]; // enough to fit 120hz
static char currentcolordepth[6];
extern cvar_t _vid_wait_override;
float vidwidth = vid.pixelwidth;
float vidheight = vid.pixelheight;
int i, y; int i, y;
menu_t *menu = M_Options_Title(&y, sizeof(videomenuinfo_t));
info = menu->data;
prefabmode = -1; prefabmode = -1;
prefab2dmode = -1; prefab2dmode = -1;
for (i = 0; i < sizeof(vid_modes)/sizeof(vidmode_t); i++) for (i = 0; i < sizeof(vid_modes)/sizeof(vidmode_t); i++)
@ -1150,13 +1147,7 @@ void M_Menu_Video_f (void)
} }
modenames[i+1] = NULL; modenames[i+1] = NULL;
key_dest = key_menu; #if defined(GLQUAKE) && defined(D3DQUAKE)
m_state = m_complex;
menu = M_CreateMenu(sizeof(videomenuinfo_t));
info = menu->data;
#if defined(GLQUAKE) && defined(USE_D3D)
if (!strcmp(vid_renderer.string, "d3d9")) if (!strcmp(vid_renderer.string, "d3d9"))
i = 1; i = 1;
else else
@ -1164,9 +1155,15 @@ void M_Menu_Video_f (void)
i = 0; i = 0;
if (vid_bpp.value >= 32) if (vid_bpp.value >= 32)
{
currentbpp = 2; currentbpp = 2;
strcpy(currentcolordepth, va("%sbit (16.7m colors)",vid_bpp.string) );
}
else if (vid_bpp.value >= 16) else if (vid_bpp.value >= 16)
{
currentbpp = 1; currentbpp = 1;
strcpy(currentcolordepth, va("%sbit (65.5k colors)",vid_bpp.string) );
}
else else
currentbpp = 0; currentbpp = 0;
@ -1189,50 +1186,119 @@ void M_Menu_Video_f (void)
else else
currentrefreshrate = 0; currentrefreshrate = 0;
#ifdef GLQUAKE strcpy(currenthz, va("%sHz",vid_refreshrate.string) );
if (!Q_strcasecmp(gl_texturemode.string, "gl_nearest_mipmap_nearest"))
currenttexturefilter = 0; aspectratio3d = (vidwidth / vidheight * 100); // times by 100 so don't have to deal with floats
else if (!Q_strcasecmp(gl_texturemode.string, "gl_linear_mipmap_linear"))
currenttexturefilter = 2; if (aspectratio3d == 125) // 1.25
else if (!Q_strcasecmp(gl_texturemode.string, "gl_linear_mipmap_nearest")) aspectratio23d = "5:4";
currenttexturefilter = 1; else if (aspectratio3d == 160) // 1.6
aspectratio23d = "16:10";
else if (aspectratio3d == 133) // 1.333333
aspectratio23d = "4:3";
else if (aspectratio3d == 177) // 1.777778
aspectratio23d = "16:9";
else else
currenttexturefilter = 1; {
#endif aspectratio23d = "Non-standard Ratio";
Con_Printf("Ratio: %i, width: %i, height: %i\n", aspectratio3d, vid.pixelwidth, vid.pixelheight);
}
aspectratio2d = (vid_conwidth.value / vid_conheight.value * 100); // times by 100 so don't have to deal with floats
MC_AddCenterPicture(menu, 4, 24, "vidmodes"); if (aspectratio2d == 125) // 1.25
aspectratio22d = "5:4";
else if (aspectratio2d == 160) // 1.6
aspectratio22d = "16:10";
else if (aspectratio2d == 133) // 1.333333
aspectratio22d = "4:3";
else if (aspectratio2d == 177) // 1.777778
aspectratio22d = "16:9";
else
aspectratio22d = "Non-standard Ratio";
y = 32; currentvsync = _vid_wait_override.value;
info->renderer = MC_AddCombo(menu, 16, y, " Renderer ", rendererops, i); y+=8;
info->bppcombo = MC_AddCombo(menu, 16, y, " Color Depth ", bppnames, currentbpp); y+=8; if ( stricmp(vid_renderer.string,"gl" ) == 0 )
info->refreshratecombo = MC_AddCombo(menu, 16, y, " Refresh Rate ", refreshrates, currentrefreshrate); y+=8; rendererstring = "OpenGL";
info->modecombo = MC_AddCombo(menu, 16, y, " Video Size ", modenames, prefabmode+1); y+=8; else if ( stricmp(vid_renderer.string,"d3d7") == 0 )
info->conscalecombo = MC_AddCombo(menu, 16, y, " 2d Size ", modenames, prefab2dmode+1); y+=8; rendererstring = "DirectX 7";
MC_AddCheckBox(menu, 16, y, " Fullscreen ", &vid_fullscreen,0); y+=8; else if ( stricmp(vid_renderer.string,"d3d9") == 0 )
y+=4;info->customwidth = MC_AddEdit(menu, 16, y, " Custom width ", vid_width.string); y+=8; rendererstring = "DirectX 9";
y+=4;info->customheight = MC_AddEdit(menu, 16, y, " Custom height", vid_height.string); y+=12; else if ( stricmp(vid_renderer.string,"d3d") == 0)
rendererstring = "DirectX";
else if ( stricmp(vid_renderer.string,"sw") == 0)
rendererstring = "Software";
else
rendererstring = "Unknown Renderer?";
strcpy(current3dres, va("%ix%i", vid.pixelwidth, vid.pixelheight) );
strcpy(current2dres, va("%sx%s", vid_conwidth.string, vid_conheight.string) );
y += 40;
MC_AddRedText(menu, 0, y, " Current Renderer", false);
MC_AddRedText(menu, 225, y, rendererstring, false); y+=8;
MC_AddRedText(menu, 0, y, " Current Color Depth", false);
MC_AddRedText(menu, 225, y, currentcolordepth, false); y+=8;
if ( ( vidwidth == 0) || ( vidheight == 0) )
y+=16;
else
{
MC_AddRedText(menu, 0, y, " Current 3D Res", false);
MC_AddRedText(menu, 225, y, current3dres, false); y+=8;
MC_AddRedText(menu, 0, y, " Current 3D A/R", false);
MC_AddRedText(menu, 225, y, aspectratio23d, false); y+=8;
}
if ( ( vid_conwidth.value == 0) || ( vid_conheight.value == 0) ) // same as 3d resolution
{
MC_AddRedText(menu, 0, y, " Current 2D Res", false);
MC_AddRedText(menu, 225, y, current3dres, false); y+=8;
MC_AddRedText(menu, 0, y, " Current 2D A/R", false);
MC_AddRedText(menu, 225, y, aspectratio23d, false); y+=8;
}
else
{
MC_AddRedText(menu, 0, y, " Current 2D Res", false);
MC_AddRedText(menu, 225, y, current2dres, false); y+=8;
MC_AddRedText(menu, 0, y, " Current 2D A/R", false);
MC_AddRedText(menu, 225, y, aspectratio22d, false); y+=8;
}
MC_AddRedText(menu, 0, y, " Current Refresh Rate", false);
MC_AddRedText(menu, 225, y, currenthz, false); y+=8;
y+=8;
MC_AddRedText(menu, 0, y, "<><E282AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> ", false); y+=8;
y+=8; y+=8;
MC_AddCommand(menu, 16, y, " Apply", M_VideoApply); y+=8; info->renderer = MC_AddCombo(menu, 16, y, " Renderer", rendererops, i); y+=8;
info->bppcombo = MC_AddCombo(menu, 16, y, " Color Depth", bppnames, currentbpp); y+=8;
info->refreshratecombo = MC_AddCombo(menu, 16, y, " Refresh Rate", refreshrates, currentrefreshrate); y+=8;
info->modecombo = MC_AddCombo(menu, 16, y, " Video Size", modenames, prefabmode+1); y+=8;
MC_AddWhiteText(menu, 16, y, " 3D Aspect Ratio", false); y+=8;
info->conscalecombo = MC_AddCombo(menu, 16, y, " 2D Size", modenames, prefab2dmode+1); y+=8;
MC_AddWhiteText(menu, 16, y, " 2D Aspect Ratio", false); y+=8;
MC_AddCheckBox(menu, 16, y, " Fullscreen", &vid_fullscreen,0); y+=8;
y+=4;info->customwidth = MC_AddEdit(menu, 16, y, " Custom width", vid_width.string); y+=8;
y+=4;info->customheight = MC_AddEdit(menu, 16, y, " Custom height", vid_height.string); y+=12;
info->vsynccombo = MC_AddCombo(menu, 16, y, " VSync", vsyncoptions, currentvsync); y+=8;
//MC_AddCheckBox(menu, 16, y, " Override VSync", &_vid_wait_override,0); y+=8;
MC_AddCheckBox(menu, 16, y, " Desktop Settings", &vid_desktopsettings,0); y+=8;
y+=8; y+=8;
MC_AddCheckBox(menu, 16, y, " Stain maps", &r_stains,0); y+=8; MC_AddCommand(menu, 16, y, "= Apply Changes =", M_VideoApply); y+=8;
MC_AddCheckBox(menu, 16, y, " Bouncy sparks", &r_bouncysparks,0); y+=8; y+=8;
MC_AddCheckBox(menu, 16, y, " Rain", &r_part_rain,0); y+=8; MC_AddSlider(menu, 16, y, " Screen size", &scr_viewsize, 30, 120, 1);y+=8;
#ifdef GLQUAKE MC_AddSlider(menu, 16, y, "Console Autoscale",&vid_conautoscale, 0, 6, 0.25); y+=8;
MC_AddCheckBox(menu, 16, y, " GL Bumpmapping", &gl_bump,0); y+=8; MC_AddSlider(menu, 16, y, " Gamma", &v_gamma, 0.3, 1, 0.05); y+=8;
MC_AddCheckBox(menu, 16, y, " Bloom", &r_bloom,0); y+=8; MC_AddCheckBox(menu, 16, y, " Desktop Gamma", &vid_desktopgamma,0); y+=8;
#endif MC_AddCheckBox(menu, 16, y, " Hardware Gamma", &vid_hardwaregamma,0); y+=8;
MC_AddCheckBox(menu, 16, y, " Dynamic lights", &r_dynamic,0); y+=8; MC_AddCheckBox(menu, 16, y, " Preserve Gamma", &vid_preservegamma,0); y+=8;
MC_AddSlider(menu, 16, y, " Screen size", &scr_viewsize, 30, 120, 0.1);y+=8; MC_AddSlider(menu, 16, y, " Contrast", &v_contrast, 1, 3, 0.05); y+=8;
MC_AddSlider(menu, 16, y, " Gamma", &v_gamma, 0.3, 1, 0.05); y+=8; y+=8;
MC_AddSlider(menu, 16, y, " Contrast", &v_contrast, 1, 3, 0.05); y+=8; MC_AddCheckBox(menu, 16, y, " Allow ModeX", &vid_allow_modex,0); y+=8;
#ifdef GLQUAKE MC_AddCheckBox(menu, 16, y, " Windowed Mouse", &_windowed_mouse,0); y+=8;
info->texturefiltercombo = MC_AddCombo(menu, 16, y, " Texture Filter ", texturefilternames, currenttexturefilter); y+=8;
MC_AddSlider(menu, 16, y, "Anisotropy Level", &gl_texture_anisotropic_filtering, 1, 16, 1); y+=8; //urm, this shouldn't really be a slider, but should be a combo instead
#endif
menu->cursoritem = (menuoption_t*)MC_AddWhiteText(menu, 152, 32, NULL, false);
menu->selecteditem = (union menuoption_s *)info->renderer; menu->selecteditem = (union menuoption_s *)info->renderer;
menu->cursoritem = (menuoption_t*)MC_AddWhiteText(menu, 152, menu->selecteditem->common.posy, NULL, false);
menu->event = CheckCustomMode; menu->event = CheckCustomMode;
} }
@ -1289,10 +1355,6 @@ void R_SetRenderer(rendererinfo_t *ri)
VID_GetRGBInfo = ri->VID_GetRGBInfo; VID_GetRGBInfo = ri->VID_GetRGBInfo;
VID_SetWindowCaption = ri->VID_SetWindowCaption; VID_SetWindowCaption = ri->VID_SetWindowCaption;
Media_ShowFrame8bit = ri->Media_ShowFrame8bit;
Media_ShowFrameRGBA_32 = ri->Media_ShowFrameRGBA_32;
Media_ShowFrameBGR_24_Flip = ri->Media_ShowFrameBGR_24_Flip;
Mod_Init = ri->Mod_Init; Mod_Init = ri->Mod_Init;
Mod_Think = ri->Mod_Think; Mod_Think = ri->Mod_Think;
Mod_ClearAll = ri->Mod_ClearAll; Mod_ClearAll = ri->Mod_ClearAll;
@ -1612,7 +1674,7 @@ TRACE(("dbg: R_ApplyRenderer: starting on client state\n"));
{ {
staticmodelindex[i] = 0; staticmodelindex[i] = 0;
for (j = 1; j < MAX_MODELS; j++) for (j = 1; j < MAX_MODELS; j++)
if (cl_static_entities[i].model == cl.model_precache[j]) if (cl_static_entities[i].ent.model == cl.model_precache[j])
{ {
staticmodelindex[i] = j; staticmodelindex[i] = j;
break; break;
@ -1701,11 +1763,10 @@ TRACE(("dbg: R_ApplyRenderer: R_NewMap\n"));
TRACE(("dbg: R_ApplyRenderer: efrags\n")); TRACE(("dbg: R_ApplyRenderer: efrags\n"));
for (i = 0; i < cl.num_statics; i++) //make the static entities reappear. for (i = 0; i < cl.num_statics; i++) //make the static entities reappear.
{ {
cl_static_entities[i].model = cl.model_precache[staticmodelindex[i]]; cl_static_entities[i].ent.model = cl.model_precache[staticmodelindex[i]];
if (staticmodelindex[i]) //make sure it's worthwhile. if (cl_static_entities[i].ent.model)
{ cl.worldmodel->funcs.FindTouchedLeafs(cl.worldmodel, &cl_static_entities[i].pvscache, NULL, NULL);
R_AddEfrags(&cl_static_entities[i]); #pragma message("STATIC ENTITITES --- relink")
}
} }
} }
#ifdef VM_UI #ifdef VM_UI
@ -2031,43 +2092,10 @@ mspriteframe_t *R_GetSpriteFrame (entity_t *currententity)
return pspriteframe; return pspriteframe;
} }
/*
float r_projection_matrix[16];
float r_view_matrix[16];
void MYgluPerspective(double fovx, double fovy, double zNear, double zFar) void MYgluPerspective(double fovx, double fovy, double zNear, double zFar)
{ {
Matrix4_Projection_Far(r_projection_matrix, fovx, fovy, zNear, zFar); Matrix4_Projection_Far(r_refdef.m_projection, fovx, fovy, zNear, zFar);
/*
double xmin, xmax, ymin, ymax;
ymax = zNear * tan( fovy * M_PI / 360.0 );
ymin = -ymax;
xmax = zNear * tan( fovx * M_PI / 360.0 );
xmin = -xmax;
r_projection_matrix[0] = (2*zNear) / (xmax - xmin);
r_projection_matrix[4] = 0;
r_projection_matrix[8] = (xmax + xmin) / (xmax - xmin);
r_projection_matrix[12] = 0;
r_projection_matrix[1] = 0;
r_projection_matrix[5] = (2*zNear) / (ymax - ymin);
r_projection_matrix[9] = (ymax + ymin) / (ymax - ymin);
r_projection_matrix[13] = 0;
r_projection_matrix[2] = 0;
r_projection_matrix[6] = 0;
r_projection_matrix[10] = - (zFar+zNear)/(zFar-zNear);
r_projection_matrix[14] = - (2.0f*zFar*zNear)/(zFar-zNear);
r_projection_matrix[3] = 0;
r_projection_matrix[7] = 0;
r_projection_matrix[11] = -1;
r_projection_matrix[15] = 0;
*/
} }
void GL_InfinatePerspective(double fovx, double fovy, void GL_InfinatePerspective(double fovx, double fovy,
@ -2128,7 +2156,7 @@ void GL_ParallelPerspective(double xmin, double xmax, double ymax, double ymin,
r_projection_matrix[11] = 0; r_projection_matrix[11] = 0;
r_projection_matrix[15] = 1; r_projection_matrix[15] = 1;
} }
*/
/* /*
@ -2350,9 +2378,6 @@ qbyte *R_MarkLeaves_Q1 (void)
if (((r_oldviewleaf == r_viewleaf && r_oldviewleaf2 == r_viewleaf2) && !r_novis.ival) || r_novis.ival & 2) if (((r_oldviewleaf == r_viewleaf && r_oldviewleaf2 == r_viewleaf2) && !r_novis.ival) || r_novis.ival & 2)
return vis; return vis;
// if (mirror)
// return;
r_visframecount++; r_visframecount++;
r_oldviewleaf = r_viewleaf; r_oldviewleaf = r_viewleaf;
@ -2714,5 +2739,7 @@ void R_InitParticleTexture (void)
} }
} }
ptritexture = R_LoadTexture32("", PARTICLETEXTURESIZE, PARTICLETEXTURESIZE, data, IF_NOMIPMAP|IF_NOPICMIP); ptritexture = R_LoadTexture32("", PARTICLETEXTURESIZE, PARTICLETEXTURESIZE, data, IF_NOMIPMAP|IF_NOPICMIP);
Cvar_ForceCallback(&r_particlesystem);
} }

View file

@ -14,11 +14,16 @@ static renderque_t *distrque[NUMGRADUATIONS];
int rqmaxgrad, rqmingrad; int rqmaxgrad, rqmingrad;
int rquesize = 0x2000; int rquesize = 0x2000;
float rquepivot;
void RQ_BeginFrame(void)
{
rquepivot = DotProduct(r_refdef.vieworg, vpn);
}
void RQ_AddDistReorder(void (*render) (int count, void **objects, void *objtype), void *object, void *objtype, float *pos) void RQ_AddDistReorder(void (*render) (int count, void **objects, void *objtype), void *object, void *objtype, float *pos)
{ {
int dist; int dist;
vec3_t delta;
renderque_t *rq; renderque_t *rq;
if (!freerque) if (!freerque)
{ {
@ -26,8 +31,7 @@ void RQ_AddDistReorder(void (*render) (int count, void **objects, void *objtype)
return; return;
} }
VectorSubtract(pos, r_refdef.vieworg, delta); dist = DotProduct(pos, vpn)-rquepivot;
dist = Length(delta)/4;
if (dist > rqmaxgrad) if (dist > rqmaxgrad)
{ {
@ -38,7 +42,8 @@ void RQ_AddDistReorder(void (*render) (int count, void **objects, void *objtype)
if (dist < rqmingrad) if (dist < rqmingrad)
{ {
if (dist < 0) //hmm... value wrapped? shouldn't happen if (dist < 0) //hmm... value wrapped? shouldn't happen
dist = 0; return;
// dist = 0;
rqmingrad = dist; rqmingrad = dist;
} }
@ -56,7 +61,7 @@ void RQ_AddDistReorder(void (*render) (int count, void **objects, void *objtype)
if (!distrque[dist]) if (!distrque[dist])
distrque[dist] = rq; distrque[dist] = rq;
} }
/*
void RQ_RenderDistAndClear(void) void RQ_RenderDistAndClear(void)
{ {
int i; int i;
@ -79,6 +84,7 @@ void RQ_RenderDistAndClear(void)
rqmaxgrad=0; rqmaxgrad=0;
rqmingrad = NUMGRADUATIONS-1; rqmingrad = NUMGRADUATIONS-1;
} }
*/
void RQ_RenderBatchClear(void) void RQ_RenderBatchClear(void)
{ {
#define SLOTS 512 #define SLOTS 512

View file

@ -1,9 +1,9 @@
#ifndef RENDERQUE_H #ifndef RENDERQUE_H
#define RENDERQUE_H #define RENDERQUE_H
void RQ_BeginFrame(void);
void RQ_AddDistReorder(void (*render) (int count, void **objects, void *objtype), void *object, void *objtype, float *pos); void RQ_AddDistReorder(void (*render) (int count, void **objects, void *objtype), void *object, void *objtype, float *pos);
FTE_DEPRECATED void RQ_RenderDistAndClear(void);
void RQ_RenderBatchClear(void); void RQ_RenderBatchClear(void);
typedef struct renderque_s typedef struct renderque_s

View file

@ -27,6 +27,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern cvar_t hud_tracking_show; extern cvar_t hud_tracking_show;
extern cvar_t com_parseutf8;
#define CON_ALTMASK (com_parseutf8.ival?(COLOR_MAGENTA<<CON_FGSHIFT):(CON_WHITEMASK|0x80))
cvar_t scr_scoreboard_drawtitle = SCVAR("scr_scoreboard_drawtitle", "1"); cvar_t scr_scoreboard_drawtitle = SCVAR("scr_scoreboard_drawtitle", "1");
cvar_t scr_scoreboard_forcecolors = SCVAR("scr_scoreboard_forcecolors", "0"); //damn americans cvar_t scr_scoreboard_forcecolors = SCVAR("scr_scoreboard_forcecolors", "0"); //damn americans
cvar_t scr_scoreboard_newstyle = SCVAR("scr_scoreboard_newstyle", "1"); // New scoreboard style ported from Electro, by Molgrum cvar_t scr_scoreboard_newstyle = SCVAR("scr_scoreboard_newstyle", "1"); // New scoreboard style ported from Electro, by Molgrum
@ -173,7 +176,7 @@ void Draw_FunString(int x, int y, const unsigned char *str)
void Draw_AltFunString(int x, int y, const unsigned char *str) void Draw_AltFunString(int x, int y, const unsigned char *str)
{ {
conchar_t buffer[2048]; conchar_t buffer[2048];
COM_ParseFunString(COLOR_MAGENTA<<CON_FGSHIFT, str, buffer, sizeof(buffer), false); COM_ParseFunString(CON_ALTMASK, str, buffer, sizeof(buffer), false);
Draw_ExpandedString(x, y, buffer); Draw_ExpandedString(x, y, buffer);
} }
@ -223,49 +226,13 @@ static qboolean largegame = false;
#ifdef Q2CLIENT #ifdef Q2CLIENT
void DrawHUDString (char *string, int x, int y, int centerwidth, int xor) static void DrawHUDString (char *string, int x, int y, int centerwidth, qboolean alt)
{ {
#pragma message("q2: reimplement me") R_DrawTextField(x, y, centerwidth, 1024, string, alt?CON_ALTMASK:CON_WHITEMASK, CPRINT_TALIGN);
/*
int margin;
char line[1024];
int width;
int i;
margin = x;
while (*string)
{
// scan out one line of text from the string
width = 0;
while (*string && *string != '\n')
line[width++] = *string++;
line[width] = 0;
if (centerwidth)
x = margin + (centerwidth - width*8)/2;
else
x = margin;
for (i=0 ; i<width ; i++)
{
Draw_Character (x, y, line[i]^xor);
x += 8;
}
if (*string)
{
string++; // skip the \n
x = margin;
y += 8;
}
}
*/
} }
#define STAT_MINUS 10 // num frame for '-' stats digit #define STAT_MINUS 10 // num frame for '-' stats digit
char *q2sb_nums[2][11] = static char *q2sb_nums[2][11] =
{ {
{"num_0", "num_1", "num_2", "num_3", "num_4", "num_5", {"num_0", "num_1", "num_2", "num_3", "num_4", "num_5",
"num_6", "num_7", "num_8", "num_9", "num_minus"}, "num_6", "num_7", "num_8", "num_9", "num_minus"},
@ -282,7 +249,7 @@ static mpic_t *Sbar_Q2CachePic(char *name)
#define ICON_HEIGHT 24 #define ICON_HEIGHT 24
#define CHAR_WIDTH 16 #define CHAR_WIDTH 16
#define ICON_SPACE 8 #define ICON_SPACE 8
void SCR_DrawField (int x, int y, int color, int width, int value) static void SCR_DrawField (int x, int y, int color, int width, int value)
{ {
char num[16], *ptr; char num[16], *ptr;
int l; int l;
@ -330,6 +297,8 @@ char *Get_Q2ConfigString(int i)
return cl.model_name [i-Q2CS_MODELS]; return cl.model_name [i-Q2CS_MODELS];
if (i >= Q2CS_SOUNDS && i < Q2CS_SOUNDS + Q2MAX_SOUNDS) if (i >= Q2CS_SOUNDS && i < Q2CS_SOUNDS + Q2MAX_SOUNDS)
return cl.model_name [i-Q2CS_SOUNDS]; return cl.model_name [i-Q2CS_SOUNDS];
if (i == Q2CS_AIRACCEL)
return "4";
//#define Q2CS_LIGHTS (Q2CS_IMAGES +Q2MAX_IMAGES) //#define Q2CS_LIGHTS (Q2CS_IMAGES +Q2MAX_IMAGES)
//#define Q2CS_ITEMS (Q2CS_LIGHTS +Q2MAX_LIGHTSTYLES) //#define Q2CS_ITEMS (Q2CS_LIGHTS +Q2MAX_LIGHTSTYLES)
//#define Q2CS_PLAYERSKINS (Q2CS_ITEMS +Q2MAX_ITEMS) //#define Q2CS_PLAYERSKINS (Q2CS_ITEMS +Q2MAX_ITEMS)
@ -491,7 +460,7 @@ void Sbar_ExecuteLayoutString (char *s)
s = COM_Parse (s); s = COM_Parse (s);
// SCR_AddDirtyPoint (x, y); // SCR_AddDirtyPoint (x, y);
// SCR_AddDirtyPoint (x+23, y+23); // SCR_AddDirtyPoint (x+23, y+23);
p = Draw_SafeCachePic(com_token); p = Sbar_Q2CachePic(com_token);
if (p) if (p)
Draw_ScalePic (x, y, p->width, p->height, p); Draw_ScalePic (x, y, p->width, p->height, p);
continue; continue;
@ -522,7 +491,7 @@ void Sbar_ExecuteLayoutString (char *s)
if (cl.q2frame.playerstate.stats[Q2STAT_FLASHES] & 1) if (cl.q2frame.playerstate.stats[Q2STAT_FLASHES] & 1)
{ {
p = Draw_SafeCachePic("field_3"); p = Sbar_Q2CachePic("field_3");
if (p) if (p)
Draw_ScalePic (x, y, p->width, p->height, p); Draw_ScalePic (x, y, p->width, p->height, p);
} }
@ -546,7 +515,7 @@ void Sbar_ExecuteLayoutString (char *s)
if (cl.q2frame.playerstate.stats[Q2STAT_FLASHES] & 4) if (cl.q2frame.playerstate.stats[Q2STAT_FLASHES] & 4)
{ {
p = Draw_SafeCachePic("field_3"); p = Sbar_Q2CachePic("field_3");
if (p) if (p)
Draw_ScalePic (x, y, p->width, p->height, p); Draw_ScalePic (x, y, p->width, p->height, p);
} }
@ -590,7 +559,7 @@ void Sbar_ExecuteLayoutString (char *s)
if (!strcmp(com_token, "cstring")) if (!strcmp(com_token, "cstring"))
{ {
s = COM_Parse (s); s = COM_Parse (s);
DrawHUDString (com_token, x, y, 320, 0); DrawHUDString (com_token, x, y, 320, false);
continue; continue;
} }
@ -604,7 +573,7 @@ void Sbar_ExecuteLayoutString (char *s)
if (!strcmp(com_token, "cstring2")) if (!strcmp(com_token, "cstring2"))
{ {
s = COM_Parse (s); s = COM_Parse (s);
DrawHUDString (com_token, x, y, 320,0x80); DrawHUDString (com_token, x, y, 320, true);
continue; continue;
} }
@ -2155,7 +2124,7 @@ void Sbar_Draw (void)
if (cls.protocol == CP_QUAKE2) if (cls.protocol == CP_QUAKE2)
{ {
SCR_VRectForPlayer(&sbar_rect, 0); SCR_VRectForPlayer(&sbar_rect, 0);
Draw_ImageColours(1, 1, 1, 1);
if (*cl.q2statusbar) if (*cl.q2statusbar)
Sbar_ExecuteLayoutString(cl.q2statusbar); Sbar_ExecuteLayoutString(cl.q2statusbar);
if (*cl.q2layout) if (*cl.q2layout)

View file

@ -102,12 +102,15 @@ void Font_Shutdown(void);
struct font_s *Font_LoadFont(int height, char *fontfilename); struct font_s *Font_LoadFont(int height, char *fontfilename);
void Font_Free(struct font_s *f); void Font_Free(struct font_s *f);
void Font_BeginString(struct font_s *font, int vx, int vy, int *px, int *py); void Font_BeginString(struct font_s *font, int vx, int vy, int *px, int *py);
void Font_BeginScaledString(struct font_s *font, float vx, float vy, float *px, float *py); /*avoid using*/
int Font_CharHeight(void); int Font_CharHeight(void);
int Font_CharWidth(unsigned int charcode); int Font_CharWidth(unsigned int charcode);
int Font_CharEndCoord(int x, unsigned int charcode);
int Font_DrawChar(int px, int py, unsigned int charcode); int Font_DrawChar(int px, int py, unsigned int charcode);
float Font_DrawScaleChar(float px, float py, float cw, float ch, unsigned int charcode); /*avoid using*/
void Font_EndString(struct font_s *font);
void Font_ForceColour(float r, float g, float b, float a); //This colour will be applied while the char mask remains WHITE. If you print char by char, make sure to include the mask. void Font_ForceColour(float r, float g, float b, float a); //This colour will be applied while the char mask remains WHITE. If you print char by char, make sure to include the mask.
void Font_InvalidateColour(void); void Font_InvalidateColour(void);
void Font_EndString(struct font_s *font);
/*these three functions deal with formatted blocks of text (including tabs and new lines)*/ /*these three functions deal with formatted blocks of text (including tabs and new lines)*/
int Font_LineBreaks(conchar_t *start, conchar_t *end, int maxpixelwidth, int maxlines, conchar_t **starts, conchar_t **ends); int Font_LineBreaks(conchar_t *start, conchar_t *end, int maxpixelwidth, int maxlines, conchar_t **starts, conchar_t **ends);
int Font_LineWidth(conchar_t *start, conchar_t *end); int Font_LineWidth(conchar_t *start, conchar_t *end);

View file

@ -61,32 +61,51 @@ int desired_bits = 16;
int sound_started=0; int sound_started=0;
cvar_t bgmvolume = SCVARF("musicvolume", "0", CVAR_ARCHIVE); cvar_t bgmvolume = CVARF( "musicvolume", "0", CVAR_ARCHIVE);
cvar_t volume = SCVARF("volume", "0.7", CVAR_ARCHIVE); cvar_t volume = CVARF( "volume", "0.7", CVAR_ARCHIVE);
cvar_t nosound = SCVAR("nosound", "0"); cvar_t nosound = CVAR( "nosound", "0");
cvar_t precache = FCVAR("s_precache", "precache", "1", 0); cvar_t precache = CVARAF( "s_precache", "1",
cvar_t loadas8bit = FCVAR("s_loadas8bit", "loadas8bit", "0", 0); "precache", 0);
cvar_t bgmbuffer = SCVAR("bgmbuffer", "4096"); cvar_t loadas8bit = CVARAF( "s_loadas8bit", "0",
cvar_t ambient_level = FCVAR("s_ambientlevel", "ambient_level", "0.3", 0); "loadas8bit", 0);
cvar_t ambient_fade = FCVAR("s_ambientfade", "ambient_fade", "100", 0); cvar_t bgmbuffer = CVAR( "bgmbuffer", "4096");
cvar_t snd_noextraupdate = FCVAR("s_noextraupdate", "snd_noextraupdate", "0", 0); cvar_t ambient_level = CVARAF( "s_ambientlevel", "0.3",
cvar_t snd_show = FCVAR("s_show", "snd_show", "0", 0); "ambient_level", 0);
cvar_t snd_khz = FCVAR("s_khz", "snd_khz", "11", CVAR_ARCHIVE); cvar_t ambient_fade = CVARAF( "s_ambientfade", "100",
cvar_t snd_inactive = FCVAR("s_inactive", "snd_inactive", "0", 0); //set if you want sound even when tabbed out. "ambient_fade", 0);
cvar_t _snd_mixahead = FCVAR("s_mixahead", "_snd_mixahead", "0.2", CVAR_ARCHIVE); cvar_t snd_noextraupdate = CVARAF( "s_noextraupdate", "0",
cvar_t snd_leftisright = FCVAR("s_swapstereo", "snd_leftisright", "0", CVAR_ARCHIVE); "snd_noextraupdate", 0);
cvar_t snd_eax = FCVAR("s_eax", "snd_eax", "0", 0); cvar_t snd_show = CVARAF( "s_show", "0",
cvar_t snd_speakers = FCVAR("s_numspeakers", "snd_numspeakers", "2", 0); "snd_show", 0);
cvar_t snd_buffersize = FCVAR("s_buffersize", "snd_buffersize", "0", 0); cvar_t snd_khz = CVARAF( "s_khz", "11",
cvar_t snd_samplebits = FCVAR("s_bits", "snd_samplebits", "16", CVAR_ARCHIVE); "snd_khz", CVAR_ARCHIVE);
cvar_t snd_playersoundvolume = FCVAR("s_localvolume", "snd_localvolume", "1", 0); //sugested by crunch cvar_t snd_inactive = CVARAF( "s_inactive", "0",
"snd_inactive", 0); //set if you want sound even when tabbed out.
cvar_t _snd_mixahead = CVARAF( "s_mixahead", "0.2",
"_snd_mixahead", CVAR_ARCHIVE);
cvar_t snd_leftisright = CVARAF( "s_swapstereo", "0",
"snd_leftisright", CVAR_ARCHIVE);
cvar_t snd_eax = CVARAF( "s_eax", "0",
"snd_eax", 0);
cvar_t snd_speakers = CVARAF( "s_numspeakers", "2",
"snd_numspeakers", 0);
cvar_t snd_buffersize = CVARAF( "s_buffersize", "0",
"snd_buffersize", 0);
cvar_t snd_samplebits = CVARAF( "s_bits", "16",
"snd_samplebits", CVAR_ARCHIVE);
cvar_t snd_playersoundvolume = CVARAF( "s_localvolume", "1",
"snd_localvolume", 0); //sugested by crunch
cvar_t snd_capture = FCVAR("s_capture", "snd_capture", "0", 0); cvar_t snd_capture = CVARAF( "s_capture", "0",
cvar_t snd_linearresample = FCVAR("s_linearresample", "snd_linearresample", "1", 0); "snd_capture", 0);
cvar_t snd_linearresample_stream = FCVAR("s_linearresample_stream", "snd_linearresample_stream", "0", 0); cvar_t snd_linearresample = CVARAF( "s_linearresample", "1",
"snd_linearresample", 0);
cvar_t snd_linearresample_stream = CVARAF( "s_linearresample_stream", "0",
"snd_linearresample_stream", 0);
cvar_t snd_usemultipledevices = FCVAR("s_multipledevices", "snd_multipledevices", "0", 0); cvar_t snd_usemultipledevices = CVARAF( "s_multipledevices", "0",
"snd_multipledevices", 0);
extern vfsfile_t *rawwritefile; extern vfsfile_t *rawwritefile;

View file

@ -32,6 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#include <dlfcn.h> #include <dlfcn.h>
#include <dirent.h>
#ifndef __CYGWIN__ #ifndef __CYGWIN__
#include <sys/ipc.h> #include <sys/ipc.h>
#include <sys/shm.h> #include <sys/shm.h>
@ -244,13 +245,13 @@ int Sys_DebugLog(char *file, char *fmt, ...)
int Sys_EnumerateFiles (const char *gpath, const char *match, int (*func)(const char *, int, void *), void *parm) int Sys_EnumerateFiles (const char *gpath, const char *match, int (*func)(const char *, int, void *), void *parm)
{ {
#include <dirent.h> DIR *dir;
DIR *dir, *dir2;
char apath[MAX_OSPATH]; char apath[MAX_OSPATH];
char file[MAX_OSPATH]; char file[MAX_OSPATH];
char truepath[MAX_OSPATH]; char truepath[MAX_OSPATH];
char *s; char *s;
struct dirent *ent; struct dirent *ent;
struct stat st;
//printf("path = %s\n", gpath); //printf("path = %s\n", gpath);
//printf("match = %s\n", match); //printf("match = %s\n", match);
@ -291,29 +292,25 @@ int Sys_EnumerateFiles (const char *gpath, const char *match, int (*func)(const
if (!ent) if (!ent)
break; break;
if (*ent->d_name != '.') if (*ent->d_name != '.')
{
if (wildcmp(match, ent->d_name)) if (wildcmp(match, ent->d_name))
{ {
Q_snprintfz(file, sizeof(file), "%s/%s", gpath, ent->d_name); Q_snprintfz(file, sizeof(file), "%s/%s", truepath, ent->d_name);
//would use stat, but it breaks on fat32.
if ((dir2 = opendir(file))) if (stat(file, &st) == 0)
{ {
closedir(dir2); Q_snprintfz(file, sizeof(file), "%s%s%s", apath, ent->d_name, S_ISDIR(st.st_mode)?"/":"");
Q_snprintfz(file, sizeof(file), "%s%s/", apath, ent->d_name);
//printf("is directory = %s\n", file); if (!func(file, st.st_size, parm))
{
closedir(dir);
return false;
}
} }
else else
{ printf("Stat failed for \"%s\"\n", file);
Q_snprintfz(file, sizeof(file), "%s%s", apath, ent->d_name);
//printf("file = %s\n", file);
}
if (!func(file, -2, parm))
{
closedir(dir);
return false;
}
} }
}
} while(1); } while(1);
closedir(dir); closedir(dir);

View file

@ -56,11 +56,6 @@ typedef struct
int numpages; int numpages;
int recalc_refdef; // if true, recalc vid-based stuff int recalc_refdef; // if true, recalc vid-based stuff
FTE_DEPRECATED pixel_t *conbuffer;
FTE_DEPRECATED int conrowbytes;
FTE_DEPRECATED unsigned conwidth;
FTE_DEPRECATED unsigned conheight;
unsigned pixelwidth; unsigned pixelwidth;
unsigned pixelheight; unsigned pixelheight;
} viddef_t; } viddef_t;

View file

@ -1363,7 +1363,7 @@ void V_RenderPlayerViews(int plnum)
r_refdef.viewangles[2]=e->angles[2];//*s+(1-s)*e->msg_angles[1][2]; r_refdef.viewangles[2]=e->angles[2];//*s+(1-s)*e->msg_angles[1][2];
r_refdef.viewangles[PITCH] *= -1; r_refdef.viewangles[PITCH] *= -1;
r_secondaryview = 3; //show the player r_refdef.externalview = true; //show the player
R_RenderView (); R_RenderView ();
// r_framecount = old_framecount; // r_framecount = old_framecount;
@ -1390,7 +1390,7 @@ void V_RenderPlayerViews(int plnum)
vid.recalc_refdef=true; vid.recalc_refdef=true;
} }
#endif #endif
r_secondaryview = 0; r_refdef.externalview = false;
} }
void V_RenderView (void) void V_RenderView (void)

View file

@ -163,8 +163,8 @@ void TP_SkinCvar_Callback(struct cvar_s *var, char *oldvalue);
TP_CVAR(loc_name_suit, "suit") TP_CVAR(loc_name_suit, "suit")
//create the globals for all the TP cvars. //create the globals for all the TP cvars.
#define TP_CVAR(name,def) cvar_t name = SCVAR(#name, def) #define TP_CVAR(name,def) cvar_t name = CVAR(#name, def)
#define TP_CVARC(name,def,call) cvar_t name = SCVARC(#name, def, call) #define TP_CVARC(name,def,call) cvar_t name = CVARC(#name, def, call)
TP_CVARS; TP_CVARS;
#undef TP_CVAR #undef TP_CVAR
#undef TP_CVARC #undef TP_CVARC

View file

@ -125,7 +125,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define PSET_CLASSIC #define PSET_CLASSIC
#define CSQC_DAT //support for csqc //#define CSQC_DAT //support for csqc
#ifndef SERVERONLY //don't be stupid, stupid. #ifndef SERVERONLY //don't be stupid, stupid.
#ifndef CLIENTONLY #ifndef CLIENTONLY
@ -298,6 +298,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define PROTOCOLEXTENSIONS #define PROTOCOLEXTENSIONS
#ifdef MINIMAL
#define IFMINIMAL(x,y) x
#else
#define IFMINIMAL(x,y) y
#endif
//#define PRE_SAYONE 2.487 //FIXME: remove. //#define PRE_SAYONE 2.487 //FIXME: remove.
// defs common to client and server // defs common to client and server
@ -361,6 +367,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define MSVCDISABLEWARNINGS #define MSVCDISABLEWARNINGS
#if _MSC_VER >= 1300 #if _MSC_VER >= 1300
#define FTE_DEPRECATED __declspec(deprecated) #define FTE_DEPRECATED __declspec(deprecated)
#define _CRT_SECURE_NO_WARNINGS
#define _CRT_NONSTDC_NO_WARNINGS
#endif #endif
#define NORETURN __declspec(noreturn) #define NORETURN __declspec(noreturn)
#endif #endif

View file

@ -768,3 +768,15 @@ typedef struct
int patchwidth; int patchwidth;
int patchheight; int patchheight;
} rbspface_t; } rbspface_t;
#define MAX_ENT_LEAFS 16
typedef struct pvscache_s
{
int num_leafs;
short leafnums[MAX_ENT_LEAFS];
#ifdef Q2BSPS
int areanum; //q2bsp
int areanum2; //q2bsp
int headnode; //q2bsp
#endif
} pvscache_t;

View file

@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "quakedef.h" #include "quakedef.h"
cvar_t com_fs_cache = SCVARF("fs_cache", "1", CVAR_ARCHIVE); cvar_t com_fs_cache = SCVARF("fs_cache", IFMINIMAL("2","1"), CVAR_ARCHIVE);
cvar_t rcon_level = SCVAR("rcon_level", "20"); cvar_t rcon_level = SCVAR("rcon_level", "20");
cvar_t cmd_maxbuffersize = SCVAR("cmd_maxbuffersize", "65536"); cvar_t cmd_maxbuffersize = SCVAR("cmd_maxbuffersize", "65536");
int Cmd_ExecLevel; int Cmd_ExecLevel;
@ -2607,7 +2607,7 @@ void Cmd_set_f(void)
else else
docalc = false; docalc = false;
var = Cvar_Get (Cmd_Argv(1), "0", 0, "Custom variables"); var = Cvar_Get (Cmd_Argv(1), "", 0, "Custom variables");
if (Cmd_FromGamecode()) //AAHHHH!!! Q2 set command is different if (Cmd_FromGamecode()) //AAHHHH!!! Q2 set command is different
{ {

View file

@ -1380,7 +1380,7 @@ void Mod_CompileTriangleNeighbours(galiasinfo_t *galias)
#ifdef GLQUAKE #ifdef GLQUAKE
if (qrenderer != QR_OPENGL) if (qrenderer != QR_OPENGL)
return; return;
if (r_shadow_realtime_dlight_shadows.value || r_shadow_realtime_world_shadows.value) if (r_shadow_realtime_dlight_shadows.ival || r_shadow_realtime_world_shadows.ival)
{ {
int *neighbours; int *neighbours;
neighbours = Hunk_Alloc(sizeof(int)*galias->numindexes/3*3); neighbours = Hunk_Alloc(sizeof(int)*galias->numindexes/3*3);
@ -2612,7 +2612,7 @@ qboolean Mod_LoadQ2Model (model_t *mod, void *buffer)
{ {
pose = (galiaspose_t *)Hunk_Alloc(sizeof(galiaspose_t) + sizeof(vecV_t)*numverts pose = (galiaspose_t *)Hunk_Alloc(sizeof(galiaspose_t) + sizeof(vecV_t)*numverts
#ifndef SERVERONLY #ifndef SERVERONLY
+ sizeof(vec3_t)*numverts + 3*sizeof(vec3_t)*numverts
#endif #endif
); );
poutframe->poseofs = (char *)pose - (char *)poutframe; poutframe->poseofs = (char *)pose - (char *)poutframe;
@ -2624,6 +2624,9 @@ qboolean Mod_LoadQ2Model (model_t *mod, void *buffer)
#ifndef SERVERONLY #ifndef SERVERONLY
normals = (vec3_t*)&verts[galias->numverts]; normals = (vec3_t*)&verts[galias->numverts];
pose->ofsnormals = (char *)normals - (char *)pose; pose->ofsnormals = (char *)normals - (char *)pose;
pose->ofssvector = (char *)&normals[galias->numverts] - (char *)pose;
pose->ofstvector = (char *)&normals[galias->numverts*2] - (char *)pose;
#endif #endif

View file

@ -38,7 +38,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//#define ODE_DYNAMIC 1 //#define ODE_DYNAMIC 1
//#endif //#endif
cvar_t physics_ode_enable = SCVAR("physics_ode_enable", "1"); cvar_t physics_ode_enable = CVARD("physics_ode_enable", IFMINIMAL("0", "1"), "Enables the use of ODE physics, but only if the mod supports it.");
cvar_t physics_ode_quadtree_depth = CVARDP4(0, "physics_ode_quadtree_depth","5", "desired subdivision level of quadtree culling space"); cvar_t physics_ode_quadtree_depth = CVARDP4(0, "physics_ode_quadtree_depth","5", "desired subdivision level of quadtree culling space");
cvar_t physics_ode_contactsurfacelayer = CVARDP4(0, "physics_ode_contactsurfacelayer","0", "allows objects to overlap this many units to reduce jitter"); cvar_t physics_ode_contactsurfacelayer = CVARDP4(0, "physics_ode_contactsurfacelayer","0", "allows objects to overlap this many units to reduce jitter");
cvar_t physics_ode_worldquickstep = CVARDP4(0, "physics_ode_worldquickstep","1", "use dWorldQuickStep rather than dWorldStep"); cvar_t physics_ode_worldquickstep = CVARDP4(0, "physics_ode_worldquickstep","1", "use dWorldQuickStep rather than dWorldStep");

View file

@ -44,11 +44,11 @@ static char *argvdummy = " ";
static char *safeargvs[NUM_SAFE_ARGVS] = static char *safeargvs[NUM_SAFE_ARGVS] =
{"-stdvid", "-nolan", "-nosound", "-nocdaudio", "-nojoy", "-nomouse"}; {"-stdvid", "-nolan", "-nosound", "-nocdaudio", "-nojoy", "-nomouse"};
cvar_t registered = SCVAR("registered","0"); cvar_t registered = CVARD("registered","0","Set if quake's pak1.pak is available");
cvar_t gameversion = SCVARF("gameversion","", CVAR_SERVERINFO); cvar_t gameversion = CVARFD("gameversion","", CVAR_SERVERINFO, "gamecode version for server browsers");
cvar_t com_gamename = SCVAR("com_gamename", ""); cvar_t com_gamename = CVARD("com_gamename", "", "The game name used for dpmaster queries");
cvar_t com_modname = SCVAR("com_modname", ""); cvar_t com_modname = CVARD("com_modname", "", "dpmaster information");
cvar_t com_parseutf8 = SCVAR("com_parseutf8", "0"); //1 parse. 2 parse, but stop parsing that string if a char was malformed. cvar_t com_parseutf8 = CVARD("com_parseutf8", "0", "Interpret console messages/playernames/etc as UTF-8. Requires special fonts."); //1 parse. 2 parse, but stop parsing that string if a char was malformed.
qboolean com_modified; // set true if using non-id files qboolean com_modified; // set true if using non-id files
@ -2003,7 +2003,7 @@ conchar_t *COM_ParseFunString(conchar_t defaultflags, const char *str, conchar_t
ext = extstack[extstackdepth]; ext = extstack[extstackdepth];
} }
} }
else if (str[1] == 'U') //restore from stack (it's great for names) else if (str[1] == 'U') //unicode (16bit) char ^Uxxxx
{ {
if (!keepmarkup) if (!keepmarkup)
{ {

View file

@ -378,6 +378,7 @@ char *COM_GetPathInfo (int i, int *crc);
char *COM_NextPath (char *prevpath); char *COM_NextPath (char *prevpath);
void COM_FlushFSCache(void); //a file was written using fopen void COM_FlushFSCache(void); //a file was written using fopen
void COM_RefreshFSCache_f(void); void COM_RefreshFSCache_f(void);
qboolean FS_Restarted(unsigned int *since);
void COM_InitFilesystem (void); void COM_InitFilesystem (void);
void FS_Shutdown(void); void FS_Shutdown(void);
@ -402,7 +403,7 @@ char *COM_Effectinfo_ForNumber(unsigned int efnum);
unsigned int COM_RemapMapChecksum(unsigned int checksum); unsigned int COM_RemapMapChecksum(unsigned int checksum);
#define MAX_INFO_KEY 64 #define MAX_INFO_KEY 256
char *Info_ValueForKey (char *s, const char *key); char *Info_ValueForKey (char *s, const char *key);
void Info_RemoveKey (char *s, const char *key); void Info_RemoveKey (char *s, const char *key);
char *Info_KeyForNumber (char *s, int num); char *Info_KeyForNumber (char *s, int num);

View file

@ -24,6 +24,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
cvar_group_t *cvar_groups; cvar_group_t *cvar_groups;
hashtable_t cvar_hash;
bucket_t *cvar_buckets[1024];
//cvar_t *cvar_vars; //cvar_t *cvar_vars;
static char *cvar_null_string = ""; static char *cvar_null_string = "";
static char *cvar_zero_string = "0"; static char *cvar_zero_string = "0";
@ -65,6 +68,8 @@ Cvar_FindVar
*/ */
cvar_t *Cvar_FindVar (const char *var_name) cvar_t *Cvar_FindVar (const char *var_name)
{ {
return Hash_GetInsensative(&cvar_hash, var_name);
/*
cvar_group_t *grp; cvar_group_t *grp;
cvar_t *var; cvar_t *var;
@ -76,7 +81,7 @@ cvar_t *Cvar_FindVar (const char *var_name)
if (var->name2 && !Q_strcasecmp (var_name, var->name2)) if (var->name2 && !Q_strcasecmp (var_name, var->name2))
return var; return var;
} }
*/
return NULL; return NULL;
} }
@ -885,6 +890,9 @@ unlinked:
Cvar_DefaultFree(tbf->defaultstr); Cvar_DefaultFree(tbf->defaultstr);
if (tbf->latched_string) if (tbf->latched_string)
Z_Free(tbf->latched_string); Z_Free(tbf->latched_string);
Hash_RemoveData(&cvar_hash, tbf->name, tbf);
if (tbf->name2)
Hash_RemoveData(&cvar_hash, tbf->name2, tbf);
Z_Free(tbf); Z_Free(tbf);
} }
@ -939,6 +947,11 @@ qboolean Cvar_Register (cvar_t *variable, const char *groupname)
Cvar_SetCore (variable, old->string, true); Cvar_SetCore (variable, old->string, true);
Cvar_Free(old); Cvar_Free(old);
Hash_AddInsensative(&cvar_hash, variable->name, variable, &variable->hbn1);
if (variable->name2)
Hash_AddInsensative(&cvar_hash, variable->name2, variable, &variable->hbn2);
return false; return false;
} }
@ -960,6 +973,10 @@ qboolean Cvar_Register (cvar_t *variable, const char *groupname)
variable->restriction = 0; //exe registered vars variable->restriction = 0; //exe registered vars
group->cvars = variable; group->cvars = variable;
Hash_AddInsensative(&cvar_hash, variable->name, variable, &variable->hbn1);
if (variable->name2)
Hash_AddInsensative(&cvar_hash, variable->name2, variable, &variable->hbn2);
variable->string = (char*)Z_Malloc (1); variable->string = (char*)Z_Malloc (1);
if (variable->flags & CVAR_FREEDEFAULT) if (variable->flags & CVAR_FREEDEFAULT)
@ -1209,6 +1226,12 @@ void Cvar_Limiter_ZeroToOne_Callback(struct cvar_s *var, char *oldvalue)
} }
} }
void Cvar_Init(void)
{
memset(cvar_buckets, 0, sizeof(cvar_buckets));
Hash_InitTable(&cvar_hash, sizeof(cvar_buckets)/Hash_BytesForBuckets(1), cvar_buckets);
}
void Cvar_Shutdown(void) void Cvar_Shutdown(void)
{ {
cvar_t *var; cvar_t *var;

View file

@ -53,6 +53,8 @@ Cvars are restricted from having the same names as commands to keep this
interface from being ambiguous. interface from being ambiguous.
*/ */
#include "hash.h"
typedef struct cvar_s typedef struct cvar_s
{ {
//must match q2's definition //must match q2's definition
@ -68,6 +70,7 @@ typedef struct cvar_s
char *name2; char *name2;
void (*callback) (struct cvar_s *var, char *oldvalue); void (*callback) (struct cvar_s *var, char *oldvalue);
char *description;
int ival; int ival;
@ -78,15 +81,23 @@ typedef struct cvar_s
#ifdef HLSERVER #ifdef HLSERVER
struct hlcvar_s *hlcvar; struct hlcvar_s *hlcvar;
#endif #endif
bucket_t hbn1, hbn2;
} cvar_t; } cvar_t;
#define FCVARC(ConsoleName,ConsoleName2,Value,Flags,Callback) {ConsoleName, Value, NULL, Flags, 0, 0, 0, ConsoleName2, Callback} #define CVARAFDC(ConsoleName,Value,ConsoleName2,Flags,Description,Callback) {ConsoleName, Value, NULL, Flags, 0, 0, 0, ConsoleName2, Callback, Description}
#define FCVAR(ConsoleName,ConsoleName2,Value,Flags) FCVARC(ConsoleName, ConsoleName2, Value, Flags, NULL) #define CVARAFC(ConsoleName,Value,ConsoleName2,Flags,Callback) CVARAFC(ConsoleName, Value, ConsoleName2, Flags, NULL, Callback)
#define SCVARFC(ConsoleName, Value, Flags, Callback) FCVARC(ConsoleName, NULL, Value, Flags, Callback) #define CVARAFD(ConsoleName,Value,ConsoleName2,Flags,Description)CVARAFDC(ConsoleName, Value, ConsoleName2, Flags, Description, NULL)
#define SCVARF(ConsoleName,Value, Flags) FCVAR(ConsoleName, NULL, Value, Flags) #define CVARAF(ConsoleName,Value,ConsoleName2,Flags) CVARAFDC(ConsoleName, Value, ConsoleName2, Flags, NULL, NULL)
#define SCVARC(ConsoleName,Value,Callback) FCVARC(ConsoleName, NULL, Value, 0, Callback) #define CVARFC(ConsoleName,Value,Flags,Callback) CVARAFDC(ConsoleName, Value, NULL, Flags, NULL, Callback)
#define SCVAR(ConsoleName,Value) FCVAR(ConsoleName, NULL, Value, 0) #define CVARFD(ConsoleName,Value,Flags,Description) CVARAFDC(ConsoleName, Value, NULL, Flags, Description, NULL)
#define CVARDP4(Flags,ConsoleName,Value,Description) FCVAR(ConsoleName, NULL, Value, Flags) #define CVARF(ConsoleName,Value,Flags) CVARFC(ConsoleName, Value, Flags, NULL)
#define CVARC(ConsoleName,Value,Callback) CVARFC(ConsoleName, Value, 0, Callback)
#define CVARD(ConsoleName,Value,Description) CVARAFDC(ConsoleName, Value, NULL, 0, Description, NULL)
#define CVAR(ConsoleName,Value) CVARD(ConsoleName, Value, NULL)
#define SCVAR(ConsoleName,Value) CVAR(ConsoleName,Value)
#define SCVARF(ConsoleName,Value,Flags) CVARF(ConsoleName,Value,Flags)
#define CVARDP4(Flags,ConsoleName,Value,Description) CVARFD(ConsoleName, Value, Flags,Description)
typedef struct cvar_group_s typedef struct cvar_group_s
{ {
@ -182,6 +193,7 @@ void Cvar_WriteVariables (vfsfile_t *f, qboolean all);
cvar_t *Cvar_FindVar (const char *var_name); cvar_t *Cvar_FindVar (const char *var_name);
void Cvar_Init(void);
void Cvar_Shutdown(void); void Cvar_Shutdown(void);
void Cvar_ForceCheatVars(qboolean semicheats, qboolean absolutecheats); //locks/unlocks cheat cvars depending on weather we are allowed them. void Cvar_ForceCheatVars(qboolean semicheats, qboolean absolutecheats); //locks/unlocks cheat cvars depending on weather we are allowed them.

View file

@ -19,6 +19,7 @@
hashtable_t filesystemhash; hashtable_t filesystemhash;
qboolean com_fschanged = true; qboolean com_fschanged = true;
static unsigned int fs_restarts;
extern cvar_t com_fs_cache; extern cvar_t com_fs_cache;
int active_fs_cachetype; int active_fs_cachetype;
@ -491,7 +492,7 @@ int FS_FLocateFile(const char *filename, FSLF_ReturnType_e returntype, flocation
goto fail; goto fail;
} }
if (com_fs_cache.value) if (com_fs_cache.ival)
{ {
if (com_fschanged) if (com_fschanged)
FS_RebuildFSHash(); FS_RebuildFSHash();
@ -987,9 +988,11 @@ vfsfile_t *FS_OpenVFS(const char *filename, const char *mode, enum fs_relative r
if (strcmp(mode, "rb")) if (strcmp(mode, "rb"))
if (strcmp(mode, "wb")) if (strcmp(mode, "r+b"))
if (strcmp(mode, "ab")) if (strcmp(mode, "wb"))
return NULL; //urm, unable to write/append if (strcmp(mode, "w+b"))
if (strcmp(mode, "ab"))
return NULL; //urm, unable to write/append
//if there can only be one file (eg: write access) find out where it is. //if there can only be one file (eg: write access) find out where it is.
switch (relativeto) switch (relativeto)
@ -1527,9 +1530,21 @@ void COM_RefreshFSCache_f(void)
void COM_FlushFSCache(void) void COM_FlushFSCache(void)
{ {
if (com_fs_cache.value != 2) if (com_fs_cache.ival != 2)
com_fschanged=true; com_fschanged=true;
} }
/*since should start as 0, otherwise this can be used to poll*/
qboolean FS_Restarted(unsigned int *since)
{
if (*since < fs_restarts)
{
*since = fs_restarts;
return true;
}
return false;
}
/* /*
================ ================
FS_AddGameDirectory FS_AddGameDirectory
@ -1544,6 +1559,8 @@ void FS_AddGameDirectory (const char *puredir, const char *dir, unsigned int loa
char *p; char *p;
fs_restarts++;
if ((p = strrchr(dir, '/')) != NULL) if ((p = strrchr(dir, '/')) != NULL)
strcpy(gamedirfile, ++p); strcpy(gamedirfile, ++p);
else else
@ -2164,8 +2181,6 @@ qboolean Sys_FindGameData(const char *poshname, const char *gamename, char *base
} }
#if !defined(NPQTV) && !defined(SERVERONLY) //this is *really* unfortunate, but doing this crashes the browser #if !defined(NPQTV) && !defined(SERVERONLY) //this is *really* unfortunate, but doing this crashes the browser
//I assume its because the client
if (poshname) if (poshname)
{ {
char resultpath[MAX_PATH]; char resultpath[MAX_PATH];

View file

@ -112,6 +112,8 @@ vfsfile_t *VFSW32_Open(const char *osname, const char *mode)
qboolean append = !!strchr(mode, 'a'); qboolean append = !!strchr(mode, 'a');
qboolean text = !!strchr(mode, 't'); qboolean text = !!strchr(mode, 't');
write |= append; write |= append;
if (strchr(mode, '+'))
read = write = true;
if (write && read) if (write && read)
h = CreateFileA(osname, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_DELETE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); h = CreateFileA(osname, GENERIC_READ|GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_DELETE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);

View file

@ -32,12 +32,6 @@ qboolean RMod_LoadMarksurfaces (lump_t *l);
qboolean RMod_LoadSurfedges (lump_t *l); qboolean RMod_LoadSurfedges (lump_t *l);
void RMod_LoadLighting (lump_t *l); void RMod_LoadLighting (lump_t *l);
qboolean SWMod_LoadVertexes (lump_t *l);
qboolean SWMod_LoadEdges (lump_t *l);
qboolean SWMod_LoadMarksurfaces (lump_t *l);
qboolean SWMod_LoadSurfedges (lump_t *l);
void SWMod_LoadLighting (lump_t *l);
void Q2BSP_SetHullFuncs(hull_t *hull); void Q2BSP_SetHullFuncs(hull_t *hull);
qboolean CM_Trace(model_t *model, int forcehullnum, int frame, vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs, trace_t *trace); qboolean CM_Trace(model_t *model, int forcehullnum, int frame, vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs, trace_t *trace);
@ -131,6 +125,28 @@ void ClearBounds (vec3_t mins, vec3_t maxs)
} }
void Mod_SortShaders(void)
{
texture_t *textemp;
int i, j;
//sort loadmodel->textures
for (i = 0; i < loadmodel->numtextures; i++)
{
for (j = i+1; j < loadmodel->numtextures; j++)
{
if ((loadmodel->textures[i]->shader && loadmodel->textures[j]->shader) && (loadmodel->textures[j]->shader->sort < loadmodel->textures[i]->shader->sort))
{
textemp = loadmodel->textures[j];
loadmodel->textures[j] = loadmodel->textures[i];
loadmodel->textures[i] = textemp;
}
}
}
}
#ifdef Q2BSPS #ifdef Q2BSPS
qbyte *ReadPCXPalette(qbyte *buf, int len, qbyte *out); qbyte *ReadPCXPalette(qbyte *buf, int len, qbyte *out);
@ -256,15 +272,13 @@ typedef struct
int patch_cp[2]; int patch_cp[2];
} q3cface_t; } q3cface_t;
/*used to trace*/
int checkcount; int checkcount;
//FIXME: Unlimit these.
char map_name[MAX_QPATH];
int numbrushsides; int numbrushsides;
q2cbrushside_t map_brushsides[MAX_Q2MAP_BRUSHSIDES]; q2cbrushside_t map_brushsides[MAX_Q2MAP_BRUSHSIDES];
int numtexinfo; int numtexinfo;
q2mapsurface_t *map_surfaces; q2mapsurface_t *map_surfaces;
int numplanes; int numplanes;
@ -363,10 +377,6 @@ int numleaffaces;
int PlaneTypeForNormal ( vec3_t normal ) int PlaneTypeForNormal ( vec3_t normal )
{ {
vec_t ax, ay, az; vec_t ax, ay, az;
@ -624,7 +634,6 @@ static void SnapPlane( vec3_t normal, vec_t *dist )
=============================================================================== ===============================================================================
*/ */
#if 1
#define MAX_FACET_PLANES 32 #define MAX_FACET_PLANES 32
#define cm_subdivlevel 15 #define cm_subdivlevel 15
@ -810,7 +819,7 @@ static void CM_CreatePatch( q3cpatch_t *patch, q2mapsurface_t *shaderref, const
data = BZ_Malloc( size[0] * size[1] * sizeof( vecV_t ) + data = BZ_Malloc( size[0] * size[1] * sizeof( vecV_t ) +
( size[0]-1 ) * ( size[1]-1 ) * 2 * ( sizeof( q2cbrush_t ) + 32 * sizeof( mplane_t ) ) ); ( size[0]-1 ) * ( size[1]-1 ) * 2 * ( sizeof( q2cbrush_t ) + 32 * sizeof( mplane_t ) ) );
points = ( vec3_t * )data; data += size[0] * size[1] * sizeof( vecV_t ); points = ( vecV_t * )data; data += size[0] * size[1] * sizeof( vecV_t );
facets = ( q2cbrush_t * )data; data += ( size[0]-1 ) * ( size[1]-1 ) * 2 * sizeof( q2cbrush_t ); facets = ( q2cbrush_t * )data; data += ( size[0]-1 ) * ( size[1]-1 ) * 2 * sizeof( q2cbrush_t );
brushplanes = ( mplane_t * )data; data += ( size[0]-1 ) * ( size[1]-1 ) * 2 * MAX_FACET_PLANES * sizeof( mplane_t ); brushplanes = ( mplane_t * )data; data += ( size[0]-1 ) * ( size[1]-1 ) * 2 * MAX_FACET_PLANES * sizeof( mplane_t );
@ -899,218 +908,6 @@ static void CM_CreatePatch( q3cpatch_t *patch, q2mapsurface_t *shaderref, const
BZ_Free( points ); BZ_Free( points );
} }
#else
#define cm_subdivlevel 15
qboolean CM_CreateBrush ( q2cbrush_t *brush, vec3_t *verts, q2mapsurface_t *surface )
{
int i, j, k, sign;
vec3_t v1, v2;
vec3_t absmins, absmaxs;
q2cbrushside_t *side;
mplane_t *plane;
static mplane_t mainplane, patchplanes[20];
qboolean skip[20];
int numpatchplanes = 0;
// calc absmins & absmaxs
ClearBounds ( absmins, absmaxs );
for (i = 0; i < 3; i++)
AddPointToBounds ( verts[i], absmins, absmaxs );
PlaneFromPoints ( verts, &mainplane );
// front plane
plane = &patchplanes[numpatchplanes++];
*plane = mainplane;
// back plane
plane = &patchplanes[numpatchplanes++];
VectorNegate (mainplane.normal, plane->normal);
plane->dist = -mainplane.dist;
// axial planes
for ( i = 0; i < 3; i++ )
{
for (sign = -1; sign <= 1; sign += 2)
{
plane = &patchplanes[numpatchplanes++];
if (numpatchplanes > 20)
return false;
VectorClear ( plane->normal );
plane->normal[i] = sign;
plane->dist = sign > 0 ? absmaxs[i] : -absmins[i];
}
}
// edge planes
for ( i = 0; i < 3; i++ )
{
vec3_t normal;
VectorCopy (verts[i], v1);
VectorCopy (verts[(i + 1) % 3], v2);
for ( k = 0; k < 3; k++ )
{
normal[k] = 0;
normal[(k+1)%3] = v1[(k+2)%3] - v2[(k+2)%3];
normal[(k+2)%3] = -(v1[(k+1)%3] - v2[(k+1)%3]);
if (VectorEquals (normal, vec3_origin))
continue;
plane = &patchplanes[numpatchplanes++];
if (numpatchplanes > 20)
return false;
VectorNormalize ( normal );
VectorCopy ( normal, plane->normal );
plane->dist = DotProduct (plane->normal, v1);
if ( DotProduct(verts[(i + 2) % 3], normal) - plane->dist > 0 )
{ // invert
VectorInverse ( plane->normal );
plane->dist = -plane->dist;
}
}
}
// set plane->type and mark duplicate planes for removal
for (i = 0; i < numpatchplanes; i++)
{
CategorizePlane ( &patchplanes[i] );
skip[i] = false;
for (j = i + 1; j < numpatchplanes; j++)
if ( patchplanes[j].dist == patchplanes[i].dist
&& VectorEquals (patchplanes[j].normal, patchplanes[i].normal) )
{
skip[i] = true;
break;
}
}
brush->numsides = 0;
brush->brushside = Hunk_Alloc((sizeof(*plane) + sizeof(*side))*numpatchplanes);
plane = (mplane_t*)(brush->brushside+numpatchplanes);
for (k = 0; k < 2; k++)
{
for (i = 0; i < numpatchplanes; i++)
{
if (skip[i])
continue;
// first, store all axially aligned planes
// then store everything else
// does it give a noticeable speedup?
if (!k && patchplanes[i].type >= 3)
continue;
skip[i] = true;
side = brush->brushside + brush->numsides;
side->plane = plane+brush->numsides;
plane[brush->numsides] = patchplanes[i];
brush->numsides++;
if (DotProduct(plane->normal, mainplane.normal) >= 0)
side->surface = surface;
else
side->surface = NULL; // don't clip against this side
}
}
return true;
}
qboolean CM_CreatePatch ( q3cpatch_t *patch, int numverts, const vec_t *verts, int *patch_cp )
{
int step[2], size[2], flat[2], i, u, v;
vec4_t points[MAX_CM_PATCH_VERTS], pointss[MAX_CM_PATCH_VERTS];
vec3_t tverts[4], tverts2[4];
q2cbrush_t *brush;
mplane_t mainplane;
// find the degree of subdivision in the u and v directions
Patch_GetFlatness ( cm_subdivlevel, verts, patch_cp, flat );
step[0] = (1 << flat[0]);
step[1] = (1 << flat[1]);
size[0] = (patch_cp[0] / 2) * step[0] + 1;
size[1] = (patch_cp[1] / 2) * step[1] + 1;
if ( size[0] * size[1] > MAX_CM_PATCH_VERTS )
{
return true;
Con_Printf (CON_ERROR "CM_CreatePatch: patch has too many vertices\n");
return false;
}
for (i = 0; i < numverts; i++)
VectorCopy(verts[i], pointss[i]);
// fill in
//gcc warns without this cast
Patch_Evaluate ( (const vec4_t *)pointss, patch_cp, step, points );
/*
for (i = 0; i < numverts; i++)
{
points[i][0] = (int)(points[i][0]*20)/20.0f;
points[i][1] = (int)(points[i][1]*20)/20.0f;
points[i][2] = (int)(points[i][2]*20)/20.0f;
}
*/
patch->brushes = brush = map_brushes + numbrushes;
patch->numbrushes = 0;
ClearBounds (patch->absmins, patch->absmaxs);
// create a set of brushes
for (v = 0; v < size[1]-1; v++)
{
for (u = 0; u < size[0]-1; u++)
{
if (numbrushes >= MAX_CM_BRUSHES)
{
Con_Printf (CON_ERROR "CM_CreatePatch: too many patch brushes\n");
return false;
}
i = v * size[0] + u;
VectorCopy (points[i], tverts[0]);
VectorCopy (points[i + size[0]], tverts[1]);
VectorCopy (points[i + 1], tverts[2]);
VectorCopy (points[i + size[0] + 1], tverts[3]);
for (i = 0; i < 4; i++)
AddPointToBounds (tverts[i], patch->absmins, patch->absmaxs);
PlaneFromPoints (tverts, &mainplane);
// create two brushes
if (!CM_CreateBrush (brush, tverts, patch->surface))
return false;
brush->contents = patch->surface->c.value;
brush++; numbrushes++; patch->numbrushes++;
VectorCopy (tverts[2], tverts2[0]);
VectorCopy (tverts[1], tverts2[1]);
VectorCopy (tverts[3], tverts2[2]);
if (!CM_CreateBrush (brush, tverts2, patch->surface))
return false;
brush->contents = patch->surface->c.value;
brush++; numbrushes++; patch->numbrushes++;
}
}
return true;
}
#endif
//====================================================== //======================================================
/* /*
@ -1154,7 +951,7 @@ qboolean CM_CreatePatchesForLeafs (void)
continue; continue;
if (face->patch_cp[0] <= 0 || face->patch_cp[1] <= 0) if (face->patch_cp[0] <= 0 || face->patch_cp[1] <= 0)
continue; continue;
if (face->shadernum < 0 || face->shadernum >= numtexinfo) if (face->shadernum < 0 || face->shadernum >= loadmodel->numtextures)
continue; continue;
surf = &map_surfaces[face->shadernum]; surf = &map_surfaces[face->shadernum];
@ -1186,7 +983,7 @@ qboolean CM_CreatePatchesForLeafs (void)
checkout[k] = numpatches++; checkout[k] = numpatches++;
//gcc warns without this cast //gcc warns without this cast
CM_CreatePatch ( patch, surf, (const vec_t *)map_verts + face->firstvert, face->patch_cp ); CM_CreatePatch ( patch, surf, (const vec_t *)(map_verts + face->firstvert), face->patch_cp );
} }
leaf->contents |= patch->surface->c.value; leaf->contents |= patch->surface->c.value;
@ -1302,13 +1099,7 @@ qboolean CMod_LoadSurfaces (lump_t *l)
return true; return true;
} }
#ifndef SERVERONLY #ifndef SERVERONLY
qbyte *ReadPCXFile(qbyte *buf, int length, int *width, int *height); texture_t *Mod_LoadWall(char *name, char *sname)
qbyte *ReadTargaFile(qbyte *buf, int length, int *width, int *height, int asgrey);
qbyte *ReadTargaFile(qbyte *buf, int length, int *width, int *height, int asgrey);
qbyte *ReadPCXFile(qbyte *buf, int length, int *width, int *height);
texture_t *Mod_LoadWall(char *name)
{ {
qbyte *in, *oin; qbyte *in, *oin;
texture_t *tex; texture_t *tex;
@ -1363,7 +1154,7 @@ texture_t *Mod_LoadWall(char *name)
BZ_Free(wal); BZ_Free(wal);
tex->shader = R_RegisterShader_Lightmap(name); tex->shader = R_RegisterCustom (sname, Shader_DefaultBSPQ2, NULL);
R_BuildDefaultTexnums(&tn, tex->shader); R_BuildDefaultTexnums(&tn, tex->shader);
return tex; return tex;
@ -1375,6 +1166,7 @@ qboolean CMod_LoadTexInfo (lump_t *l) //yes I know these load from the same plac
mtexinfo_t *out; mtexinfo_t *out;
int i, j, count; int i, j, count;
char name[MAX_QPATH], *lwr; char name[MAX_QPATH], *lwr;
char sname[MAX_QPATH];
float len1, len2; float len1, len2;
int texcount; int texcount;
@ -1411,10 +1203,17 @@ qboolean CMod_LoadTexInfo (lump_t *l) //yes I know these load from the same plac
else else
out->mipadjust = 1; out->mipadjust = 1;
//damn q2... compact the textures. if (out->flags & TI_SKY)
snprintf(sname, sizeof(sname), "sky/%s", in->texture);
else if (out->flags & (TI_WARP|TI_TRANS33|TI_TRANS66))
snprintf(sname, sizeof(sname), "%s%s/%s", ((out->flags&TI_WARP)?"warp":"trans"), ((out->flags&TI_TRANS66)?"66":(out->flags&TI_TRANS33?"33":"")), in->texture);
else
snprintf(sname, sizeof(sname), "wall/%s", in->texture);
//compact the textures.
for (j=0; j < texcount; j++) for (j=0; j < texcount; j++)
{ {
if (!strcmp(in->texture, loadmodel->textures[j]->name)) if (!strcmp(sname, loadmodel->textures[j]->name))
{ {
out->texture = loadmodel->textures[j]; out->texture = loadmodel->textures[j];
break; break;
@ -1429,24 +1228,24 @@ qboolean CMod_LoadTexInfo (lump_t *l) //yes I know these load from the same plac
} }
snprintf (name, sizeof(name), "textures/%s.wal", in->texture); snprintf (name, sizeof(name), "textures/%s.wal", in->texture);
out->texture = Mod_LoadWall (name); out->texture = Mod_LoadWall (name, sname);
if (!out->texture || !out->texture->width || !out->texture->height) if (!out->texture || !out->texture->width || !out->texture->height)
{ {
out->texture = Hunk_Alloc(sizeof(texture_t) + 16*16+8*8+4*4+2*2); out->texture = Hunk_Alloc(sizeof(texture_t) + 16*16+8*8+4*4+2*2);
Con_Printf (CON_WARNING "Couldn't load %s\n", name); Con_Printf (CON_WARNING "Couldn't load %s\n", name);
memcpy(out->texture, r_notexture_mip, sizeof(texture_t) + 16*16+8*8+4*4+2*2); memcpy(out->texture, r_notexture_mip, sizeof(texture_t) + 16*16+8*8+4*4+2*2);
// out->texture = r_notexture_mip; // texture not found
// out->flags = 0;
} }
Q_strncpyz(out->texture->name, in->texture, sizeof(out->texture->name)); Q_strncpyz(out->texture->name, sname, sizeof(out->texture->name));
loadmodel->textures[texcount++] = out->texture; loadmodel->textures[texcount++] = out->texture;
} }
} }
loadmodel->numtextures = texcount; loadmodel->numtextures = texcount;
Mod_SortShaders();
return true; return true;
} }
#endif #endif
@ -2660,28 +2459,6 @@ mesh_t *GL_CreateMeshForPatch (model_t *mod, int patchwidth, int patchheight, in
return mesh; return mesh;
} }
void CModQ3_SortShaders(void)
{
texture_t *textemp;
int i, j;
//sort loadmodel->textures
for (i = 0; i < numtexinfo; i++)
{
for (j = i+1; j < numtexinfo; j++)
{
if ((loadmodel->textures[i]->shader && loadmodel->textures[j]->shader) && (loadmodel->textures[j]->shader->sort < loadmodel->textures[i]->shader->sort))
{
textemp = loadmodel->textures[j];
loadmodel->textures[j] = loadmodel->textures[i];
loadmodel->textures[i] = textemp;
}
}
}
}
mesh_t nullmesh;
qboolean CModQ3_LoadRFaces (lump_t *l) qboolean CModQ3_LoadRFaces (lump_t *l)
{ {
q3dface_t *in; q3dface_t *in;
@ -2834,7 +2611,7 @@ qboolean CModQ3_LoadRFaces (lump_t *l)
Mod_NormaliseTextureVectors(map_normals_array, map_svector_array, map_tvector_array, numvertexes); Mod_NormaliseTextureVectors(map_normals_array, map_svector_array, map_tvector_array, numvertexes);
CModQ3_SortShaders(); Mod_SortShaders();
return true; return true;
} }
@ -2977,7 +2754,7 @@ qboolean CModRBSP_LoadRFaces (lump_t *l)
*/ } */ }
} }
CModQ3_SortShaders(); Mod_SortShaders();
return true; return true;
} }
@ -3786,7 +3563,6 @@ q2cmodel_t *CM_LoadMap (char *name, char *filein, qboolean clientload, unsigned
numvisibility = 0; numvisibility = 0;
numentitychars = 0; numentitychars = 0;
map_entitystring = NULL; map_entitystring = NULL;
map_name[0] = 0;
loadmodel->type = mod_brush; loadmodel->type = mod_brush;
@ -3940,7 +3716,7 @@ q2cmodel_t *CM_LoadMap (char *name, char *filein, qboolean clientload, unsigned
#ifndef CLIENTONLY #ifndef CLIENTONLY
loadmodel->funcs.FatPVS = Q2BSP_FatPVS; loadmodel->funcs.FatPVS = Q2BSP_FatPVS;
loadmodel->funcs.EdictInFatPVS = Q2BSP_EdictInFatPVS; loadmodel->funcs.EdictInFatPVS = Q2BSP_EdictInFatPVS;
loadmodel->funcs.FindTouchedLeafs_Q1 = Q2BSP_FindTouchedLeafs; loadmodel->funcs.FindTouchedLeafs = Q2BSP_FindTouchedLeafs;
#endif #endif
loadmodel->funcs.LeafPVS = CM_LeafnumPVS; loadmodel->funcs.LeafPVS = CM_LeafnumPVS;
loadmodel->funcs.LeafnumForPoint = CM_PointLeafnum; loadmodel->funcs.LeafnumForPoint = CM_PointLeafnum;
@ -4040,7 +3816,7 @@ q2cmodel_t *CM_LoadMap (char *name, char *filein, qboolean clientload, unsigned
#ifndef CLIENTONLY #ifndef CLIENTONLY
loadmodel->funcs.FatPVS = Q2BSP_FatPVS; loadmodel->funcs.FatPVS = Q2BSP_FatPVS;
loadmodel->funcs.EdictInFatPVS = Q2BSP_EdictInFatPVS; loadmodel->funcs.EdictInFatPVS = Q2BSP_EdictInFatPVS;
loadmodel->funcs.FindTouchedLeafs_Q1 = Q2BSP_FindTouchedLeafs; loadmodel->funcs.FindTouchedLeafs = Q2BSP_FindTouchedLeafs;
#endif #endif
loadmodel->funcs.LightPointValues = NULL; loadmodel->funcs.LightPointValues = NULL;
loadmodel->funcs.StainNode = NULL; loadmodel->funcs.StainNode = NULL;
@ -4090,7 +3866,7 @@ q2cmodel_t *CM_LoadMap (char *name, char *filein, qboolean clientload, unsigned
#ifndef CLIENTONLY #ifndef CLIENTONLY
loadmodel->funcs.FatPVS = Q2BSP_FatPVS; loadmodel->funcs.FatPVS = Q2BSP_FatPVS;
loadmodel->funcs.EdictInFatPVS = Q2BSP_EdictInFatPVS; loadmodel->funcs.EdictInFatPVS = Q2BSP_EdictInFatPVS;
loadmodel->funcs.FindTouchedLeafs_Q1 = Q2BSP_FindTouchedLeafs; loadmodel->funcs.FindTouchedLeafs = Q2BSP_FindTouchedLeafs;
#endif #endif
loadmodel->funcs.LightPointValues = GLQ2BSP_LightPointValues; loadmodel->funcs.LightPointValues = GLQ2BSP_LightPointValues;
loadmodel->funcs.StainNode = GLR_Q2BSP_StainNode; loadmodel->funcs.StainNode = GLR_Q2BSP_StainNode;
@ -4122,10 +3898,6 @@ q2cmodel_t *CM_LoadMap (char *name, char *filein, qboolean clientload, unsigned
memset (portalopen, 0, sizeof(portalopen)); //make them start closed. memset (portalopen, 0, sizeof(portalopen)); //make them start closed.
FloodAreaConnections (); FloodAreaConnections ();
strcpy (map_name, name);
loadmodel->checksum = loadmodel->checksum2 = *checksum; loadmodel->checksum = loadmodel->checksum2 = *checksum;
@ -4278,7 +4050,7 @@ void CM_InitBoxHull (void)
#ifndef CLIENTONLY #ifndef CLIENTONLY
box_model.funcs.FatPVS = Q2BSP_FatPVS; box_model.funcs.FatPVS = Q2BSP_FatPVS;
box_model.funcs.EdictInFatPVS = Q2BSP_EdictInFatPVS; box_model.funcs.EdictInFatPVS = Q2BSP_EdictInFatPVS;
box_model.funcs.FindTouchedLeafs_Q1 = Q2BSP_FindTouchedLeafs; box_model.funcs.FindTouchedLeafs = Q2BSP_FindTouchedLeafs;
#endif #endif
#ifndef SERVERONLY #ifndef SERVERONLY

View file

@ -8,16 +8,16 @@ void Log_Name_Callback (struct cvar_s *var, char *oldvalue);
// cvars // cvars
#define CONLOGGROUP "Console logging" #define CONLOGGROUP "Console logging"
cvar_t log_enable[LOG_TYPES] = { SCVARF("log_enable", "0", CVAR_NOTFROMSERVER), cvar_t log_enable[LOG_TYPES] = { CVARF("log_enable", "0", CVAR_NOTFROMSERVER),
SCVARF("log_enable_players", "0", CVAR_NOTFROMSERVER)}; CVARF("log_enable_players", "0", CVAR_NOTFROMSERVER)};
cvar_t log_name[LOG_TYPES] = { SCVARFC("log_name", "", CVAR_NOTFROMSERVER, Log_Name_Callback), cvar_t log_name[LOG_TYPES] = { CVARFC("log_name", "", CVAR_NOTFROMSERVER, Log_Name_Callback),
SCVARFC("log_name_players", "", CVAR_NOTFROMSERVER, Log_Name_Callback)}; CVARFC("log_name_players", "", CVAR_NOTFROMSERVER, Log_Name_Callback)};
cvar_t log_dir = SCVARFC("log_dir", "", CVAR_NOTFROMSERVER, Log_Dir_Callback); cvar_t log_dir = CVARFC("log_dir", "", CVAR_NOTFROMSERVER, Log_Dir_Callback);
cvar_t log_readable = SCVARF("log_readable", "0", CVAR_NOTFROMSERVER); cvar_t log_readable = CVARF("log_readable", "0", CVAR_NOTFROMSERVER);
cvar_t log_developer = SCVARF("log_developer", "0", CVAR_NOTFROMSERVER); cvar_t log_developer = CVARF("log_developer", "0", CVAR_NOTFROMSERVER);
cvar_t log_rotate_files = SCVARF("log_rotate_files", "0", CVAR_NOTFROMSERVER); cvar_t log_rotate_files = CVARF("log_rotate_files", "0", CVAR_NOTFROMSERVER);
cvar_t log_rotate_size = SCVARF("log_rotate_size", "131072", CVAR_NOTFROMSERVER); cvar_t log_rotate_size = CVARF("log_rotate_size", "131072", CVAR_NOTFROMSERVER);
cvar_t log_dosformat = SCVARF("log_dosformat", "0", CVAR_NOTFROMSERVER); cvar_t log_dosformat = CVARF("log_dosformat", "0", CVAR_NOTFROMSERVER);
// externals // externals
extern char gamedirfile[]; extern char gamedirfile[];

View file

@ -167,6 +167,7 @@ void R_ConcatRotations (float in1[3][3], float in2[3][3], float out[3][3]);
void R_ConcatRotationsPad (float in1[3][4], float in2[3][4], float out[3][4]); void R_ConcatRotationsPad (float in1[3][4], float in2[3][4], float out[3][4]);
void R_ConcatTransforms (matrix3x4 in1, matrix3x4 in2, matrix3x4 out); void R_ConcatTransforms (matrix3x4 in1, matrix3x4 in2, matrix3x4 out);
void RotatePointAroundVector (vec3_t dst, const vec3_t dir, const vec3_t point, float degrees); void RotatePointAroundVector (vec3_t dst, const vec3_t dir, const vec3_t point, float degrees);
void RotateLightVector(const vec3_t *axis, const vec3_t origin, const vec3_t lightpoint, vec3_t result);
int VectorCompare (const vec3_t v1, const vec3_t v2); int VectorCompare (const vec3_t v1, const vec3_t v2);
void VectorInverse (vec3_t v); void VectorInverse (vec3_t v);
void _VectorMA (const vec3_t veca, const float scale, const vec3_t vecb, vec3_t vecc); void _VectorMA (const vec3_t veca, const float scale, const vec3_t vecb, vec3_t vecc);

View file

@ -89,6 +89,7 @@ typedef enum { BM_BLEND, BM_BLENDCOLOUR, BM_ADD, BM_SUBTRACT } blendmode_t;
// used for callback // used for callback
extern cvar_t r_particlesdesc; extern cvar_t r_particlesdesc;
extern cvar_t r_particlesystem;
struct model_s; struct model_s;
struct msurface_s; struct msurface_s;
@ -137,7 +138,7 @@ typedef struct {
void (*ParticleTrailIndex) (vec3_t start, vec3_t end, int color, int crnd, trailstate_t **tsk); void (*ParticleTrailIndex) (vec3_t start, vec3_t end, int color, int crnd, trailstate_t **tsk);
void (*EmitSkyEffectTris) (struct model_s *mod, struct msurface_s *fa); void (*EmitSkyEffectTris) (struct model_s *mod, struct msurface_s *fa);
void (*InitParticles) (void); qboolean (*InitParticles) (void);
void (*ShutdownParticles) (void); void (*ShutdownParticles) (void);
void (*DelinkTrailstate) (trailstate_t **tsk); void (*DelinkTrailstate) (trailstate_t **tsk);
void (*ClearParticles) (void); void (*ClearParticles) (void);

View file

@ -385,6 +385,14 @@ void PF_cvar_defstring (progfuncs_t *prinst, struct globalvars_s *pr_globals)
RETURN_CSTRING(cv->defaultstr); RETURN_CSTRING(cv->defaultstr);
} }
//string(string cvarname) cvar_description
void PF_cvar_description (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
char *str = PR_GetStringOfs(prinst, OFS_PARM0);
cvar_t *cv = Cvar_Get(str, "", 0, "QC variables");
RETURN_CSTRING(cv->description);
}
//float(string name) cvar_type //float(string name) cvar_type
void PF_cvar_type (progfuncs_t *prinst, struct globalvars_s *pr_globals) void PF_cvar_type (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{ {
@ -1510,6 +1518,65 @@ void PF_instr (progfuncs_t *prinst, struct globalvars_s *pr_globals)
RETURN_SSTRING(sub); //last as long as the original string RETURN_SSTRING(sub); //last as long as the original string
} }
void PF_strreplace (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
char resultbuf[4096];
char *result = resultbuf;
char *search = PR_GetStringOfs(prinst, OFS_PARM0);
char *replace = PR_GetStringOfs(prinst, OFS_PARM1);
char *subject = PR_GetStringOfs(prinst, OFS_PARM2);
int searchlen = strlen(search);
int replacelen = strlen(replace);
if (searchlen)
{
while (*subject && result < resultbuf + sizeof(resultbuf) - replacelen - 2)
{
if (!strncmp(subject, search, searchlen))
{
subject += searchlen;
memcpy(result, replace, replacelen);
result += replacelen;
}
else
*result++ = *subject++;
}
*result = 0;
RETURN_TSTRING(resultbuf);
}
else
RETURN_TSTRING(subject);
}
void PF_strireplace (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
char resultbuf[4096];
char *result = resultbuf;
char *search = PR_GetStringOfs(prinst, OFS_PARM0);
char *replace = PR_GetStringOfs(prinst, OFS_PARM1);
char *subject = PR_GetStringOfs(prinst, OFS_PARM2);
int searchlen = strlen(search);
int replacelen = strlen(replace);
if (searchlen)
{
while (*subject && result < resultbuf + sizeof(resultbuf) - replacelen - 2)
{
if (!strnicmp(subject, search, searchlen))
{
subject += searchlen;
memcpy(result, replace, replacelen);
result += replacelen;
}
else
*result++ = *subject++;
}
*result = 0;
RETURN_TSTRING(resultbuf);
}
else
RETURN_TSTRING(subject);
}
//string(entity ent) etos = #65 //string(entity ent) etos = #65
void PF_etos (progfuncs_t *prinst, struct globalvars_s *pr_globals) void PF_etos (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{ {
@ -1668,7 +1735,7 @@ void PF_buf_copy (progfuncs_t *prinst, struct globalvars_s *pr_globals)
if (strbuflist[bufto].prinst != prinst) if (strbuflist[bufto].prinst != prinst)
return; return;
//codeme Con_Printf("PF_buf_copy: stub\n");
} }
// #444 void(float bufhandle, float sortpower, float backward) buf_sort (DP_QC_STRINGBUFFERS) // #444 void(float bufhandle, float sortpower, float backward) buf_sort (DP_QC_STRINGBUFFERS)
void PF_buf_sort (progfuncs_t *prinst, struct globalvars_s *pr_globals) void PF_buf_sort (progfuncs_t *prinst, struct globalvars_s *pr_globals)
@ -1682,7 +1749,7 @@ void PF_buf_sort (progfuncs_t *prinst, struct globalvars_s *pr_globals)
if (strbuflist[bufno].prinst != prinst) if (strbuflist[bufno].prinst != prinst)
return; return;
//codeme Con_Printf("PF_buf_sort: stub\n");
} }
// #445 string(float bufhandle, string glue) buf_implode (DP_QC_STRINGBUFFERS) // #445 string(float bufhandle, string glue) buf_implode (DP_QC_STRINGBUFFERS)
void PF_buf_implode (progfuncs_t *prinst, struct globalvars_s *pr_globals) void PF_buf_implode (progfuncs_t *prinst, struct globalvars_s *pr_globals)
@ -1695,7 +1762,7 @@ void PF_buf_implode (progfuncs_t *prinst, struct globalvars_s *pr_globals)
if (strbuflist[bufno].prinst != prinst) if (strbuflist[bufno].prinst != prinst)
return; return;
//codeme Con_Printf("PF_buf_implode: stub\n");
RETURN_TSTRING(""); RETURN_TSTRING("");
} }
@ -1762,7 +1829,7 @@ void PF_bufstr_add (progfuncs_t *prinst, struct globalvars_s *pr_globals)
if (strbuflist[bufno].prinst != prinst) if (strbuflist[bufno].prinst != prinst)
return; return;
//codeme Con_Printf("PF_bufstr_add: stub\n");
G_FLOAT(OFS_RETURN) = 0; G_FLOAT(OFS_RETURN) = 0;
} }
@ -1777,7 +1844,21 @@ void PF_bufstr_free (progfuncs_t *prinst, struct globalvars_s *pr_globals)
if (strbuflist[bufno].prinst != prinst) if (strbuflist[bufno].prinst != prinst)
return; return;
//codeme Con_Printf("PF_bufstr_free: stub\n");
}
void PF_buf_cvarlist (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
int bufno = G_FLOAT(OFS_PARM0)-1;
char *pattern = PR_GetStringOfs(prinst, OFS_PARM1);
char *antipattern = PR_GetStringOfs(prinst, OFS_PARM2);
if ((unsigned int)bufno >= NUMSTRINGBUFS)
return;
if (strbuflist[bufno].prinst != prinst)
return;
Con_Printf("PF_buf_cvarlist: stub\n");
} }
//515's String functions //515's String functions
@ -1826,9 +1907,10 @@ void PF_uri_escape (progfuncs_t *prinst, struct globalvars_s *pr_globals)
void PF_uri_unescape (progfuncs_t *prinst, struct globalvars_s *pr_globals) void PF_uri_unescape (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{ {
unsigned char *s = (unsigned char*)PR_GetStringOfs(prinst, OFS_PARM0); unsigned char *s = (unsigned char*)PR_GetStringOfs(prinst, OFS_PARM0);
unsigned char resultbuf[8192];
unsigned char *i, *o; unsigned char *i, *o;
unsigned char hex; unsigned char hex;
i = s; o = s; i = s; o = resultbuf;
while (*i) while (*i)
{ {
if (*i == '%') if (*i == '%')
@ -1860,43 +1942,180 @@ void PF_uri_unescape (progfuncs_t *prinst, struct globalvars_s *pr_globals)
*o++ = hex; *o++ = hex;
i += 3; i += 3;
} }
*o++ = *i++; else
*o++ = *i++;
} }
*o = 0; *o = 0;
RETURN_TSTRING(s); RETURN_TSTRING(resultbuf);
} }
//////////////////////////////////////////////////// ////////////////////////////////////////////////////
//Console functions //Console functions
#define MAXQCTOKENS 64
static struct {
char *token;
unsigned int start;
unsigned int end;
} qctoken[MAXQCTOKENS];
unsigned int qctoken_count;
void PF_ArgC (progfuncs_t *prinst, struct globalvars_s *pr_globals) //85 //float() argc; void PF_ArgC (progfuncs_t *prinst, struct globalvars_s *pr_globals) //85 //float() argc;
{ {
G_FLOAT(OFS_RETURN) = Cmd_Argc(); G_FLOAT(OFS_RETURN) = qctoken_count;
} }
//KRIMZON_SV_PARSECLIENTCOMMAND added these two. int tokenizeqc(char *str, qboolean dpfuckage)
{
char *start = str;
while(qctoken_count > 0)
{
qctoken_count--;
free(qctoken[qctoken_count].token);
}
qctoken_count = 0;
while (qctoken_count < MAXQCTOKENS)
{
/*skip whitespace here so the token's start is accurate*/
while (*str && *(unsigned char*)str <= ' ')
str++;
if (!*str)
break;
qctoken[qctoken_count].start = str - start;
str = COM_StringParse (str, false, dpfuckage);
if (!str)
break;
qctoken[qctoken_count].token = strdup(com_token);
qctoken[qctoken_count].end = str - start;
qctoken_count++;
}
return qctoken_count;
}
/*KRIMZON_SV_PARSECLIENTCOMMAND added these two - note that for compatibility with DP, this tokenize builtin is veeery vauge and doesn't match the console*/
void PF_Tokenize (progfuncs_t *prinst, struct globalvars_s *pr_globals) //84 //void(string str) tokanize; void PF_Tokenize (progfuncs_t *prinst, struct globalvars_s *pr_globals) //84 //void(string str) tokanize;
{ {
Cmd_TokenizeString(PR_GetStringOfs(prinst, OFS_PARM0), false, true); G_FLOAT(OFS_RETURN) = tokenizeqc(PR_GetStringOfs(prinst, OFS_PARM0), true);
G_FLOAT(OFS_RETURN) = Cmd_Argc(); }
void PF_tokenize_console (progfuncs_t *prinst, struct globalvars_s *pr_globals) //84 //void(string str) tokanize;
{
G_FLOAT(OFS_RETURN) = tokenizeqc(PR_GetStringOfs(prinst, OFS_PARM0), false);
} }
void PF_tokenizebyseparator (progfuncs_t *prinst, struct globalvars_s *pr_globals) void PF_tokenizebyseparator (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{ {
Cmd_TokenizePunctation(PR_GetStringOfs(prinst, OFS_PARM0), PR_GetStringOfs(prinst, OFS_PARM1)); char *str = PR_GetStringOfs(prinst, OFS_PARM0);
G_FLOAT(OFS_RETURN) = Cmd_Argc(); char *sep[7];
int seplen[7];
int seps = 0, s;
char *start = str;
int tlen;
qboolean found = true;
while (seps < *prinst->callargc - 1 && seps < 7)
{
sep[seps] = PR_GetStringOfs(prinst, OFS_PARM1 + seps*3);
seplen[seps] = strlen(sep[seps]);
seps++;
}
/*flush the old lot*/
while(qctoken_count > 0)
{
qctoken_count--;
free(qctoken[qctoken_count].token);
}
qctoken_count = 0;
qctoken[qctoken_count].start = 0;
if (*str)
for(;;)
{
found = false;
/*see if its a separator*/
if (!*str)
{
qctoken[qctoken_count].end = str - start;
found = true;
}
else
{
for (s = 0; s < seps; s++)
{
if (!strncmp(str, sep[s], seplen[s]))
{
qctoken[qctoken_count].end = str - start;
str += seplen[s];
found = true;
break;
}
}
}
/*it was, split it out*/
if (found)
{
tlen = qctoken[qctoken_count].end - qctoken[qctoken_count].start;
qctoken[qctoken_count].token = malloc(tlen + 1);
memcpy(qctoken[qctoken_count].token, start + qctoken[qctoken_count].start, tlen);
qctoken[qctoken_count].token[tlen] = 0;
qctoken_count++;
if (*str && qctoken_count < MAXQCTOKENS)
qctoken[qctoken_count].start = str - start;
else
break;
}
str++;
}
G_FLOAT(OFS_RETURN) = qctoken_count;
}
void PF_argv_start_index (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
int idx = G_FLOAT(OFS_PARM0);
/*negative indexes are relative to the end*/
if (idx < 0)
idx += qctoken_count;
if ((unsigned int)idx >= qctoken_count)
G_FLOAT(OFS_RETURN) = -1;
else
G_FLOAT(OFS_RETURN) = qctoken[idx].start;
}
void PF_argv_end_index (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
int idx = G_FLOAT(OFS_PARM0);
/*negative indexes are relative to the end*/
if (idx < 0)
idx += qctoken_count;
if ((unsigned int)idx >= qctoken_count)
G_FLOAT(OFS_RETURN) = -1;
else
G_FLOAT(OFS_RETURN) = qctoken[idx].end;
} }
void PF_ArgV (progfuncs_t *prinst, struct globalvars_s *pr_globals) //86 //string(float num) argv; void PF_ArgV (progfuncs_t *prinst, struct globalvars_s *pr_globals) //86 //string(float num) argv;
{ {
int i = G_FLOAT(OFS_PARM0); int idx = G_FLOAT(OFS_PARM0);
if (i < 0)
{ /*negative indexes are relative to the end*/
PR_BIError(prinst, "pr_argv with i < 0"); if (idx < 0)
idx += qctoken_count;
if ((unsigned int)idx >= qctoken_count)
G_INT(OFS_RETURN) = 0; G_INT(OFS_RETURN) = 0;
return; else
} RETURN_TSTRING(qctoken[idx].token);
RETURN_TSTRING(Cmd_Argv(i));
} }
//Console functions //Console functions

View file

@ -29,13 +29,8 @@ struct wedict_s
#endif #endif
/*the above is shared with qclib*/ /*the above is shared with qclib*/
link_t area; link_t area;
int num_leafs; pvscache_t pvsinfo;
short leafnums[MAX_ENT_LEAFS];
#ifdef Q2BSPS
int areanum; //q2bsp
int areanum2; //q2bsp
int headnode; //q2bsp
#endif
#ifdef USEODE #ifdef USEODE
entityode_t ode; entityode_t ode;
#endif #endif
@ -51,8 +46,6 @@ struct wedict_s
#define PF_drawline PF_Fixme #define PF_drawline PF_Fixme
#define PF_drawcolorcodedstring PF_Fixme #define PF_drawcolorcodedstring PF_Fixme
#define PF_uri_get PF_Fixme #define PF_uri_get PF_Fixme
#define PF_strreplace PF_Fixme
#define PF_strireplace PF_Fixme
#define PF_gecko_create PF_Fixme #define PF_gecko_create PF_Fixme
#define PF_gecko_destroy PF_Fixme #define PF_gecko_destroy PF_Fixme
#define PF_gecko_navigate PF_Fixme #define PF_gecko_navigate PF_Fixme
@ -115,7 +108,10 @@ void PF_floor (progfuncs_t *prinst, struct globalvars_s *pr_globals);
void PF_ceil (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_ceil (progfuncs_t *prinst, struct globalvars_s *pr_globals);
void PF_Tokenize (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_Tokenize (progfuncs_t *prinst, struct globalvars_s *pr_globals);
void PF_tokenizebyseparator (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_tokenizebyseparator (progfuncs_t *prinst, struct globalvars_s *pr_globals);
void PF_tokenize_console (progfuncs_t *prinst, struct globalvars_s *pr_globals);
void PF_ArgV (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_ArgV (progfuncs_t *prinst, struct globalvars_s *pr_globals);
void PF_argv_start_index (progfuncs_t *prinst, struct globalvars_s *pr_globals);
void PF_argv_end_index (progfuncs_t *prinst, struct globalvars_s *pr_globals);
void PF_FindString (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_FindString (progfuncs_t *prinst, struct globalvars_s *pr_globals);
void PF_FindFloat (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_FindFloat (progfuncs_t *prinst, struct globalvars_s *pr_globals);
void PF_nextent (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_nextent (progfuncs_t *prinst, struct globalvars_s *pr_globals);
@ -219,6 +215,8 @@ void PF_etos (progfuncs_t *prinst, struct globalvars_s *pr_globals);
void PF_stof (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_stof (progfuncs_t *prinst, struct globalvars_s *pr_globals);
void PF_mod (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_mod (progfuncs_t *prinst, struct globalvars_s *pr_globals);
void PF_substring (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_substring (progfuncs_t *prinst, struct globalvars_s *pr_globals);
void PF_strreplace (progfuncs_t *prinst, struct globalvars_s *pr_globals);
void PF_strireplace (progfuncs_t *prinst, struct globalvars_s *pr_globals);
void PF_stov (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_stov (progfuncs_t *prinst, struct globalvars_s *pr_globals);
void PF_dupstring(progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_dupstring(progfuncs_t *prinst, struct globalvars_s *pr_globals);
void PF_forgetstring(progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_forgetstring(progfuncs_t *prinst, struct globalvars_s *pr_globals);
@ -277,6 +275,7 @@ void PF_strpad (progfuncs_t *prinst, struct globalvars_s *pr_globals);
void PF_edict_for_num (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_edict_for_num (progfuncs_t *prinst, struct globalvars_s *pr_globals);
void PF_num_for_edict (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_num_for_edict (progfuncs_t *prinst, struct globalvars_s *pr_globals);
void PF_cvar_defstring (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_cvar_defstring (progfuncs_t *prinst, struct globalvars_s *pr_globals);
void PF_cvar_description (progfuncs_t *prinst, struct globalvars_s *pr_globals);
//these functions are from pr_menu.dat //these functions are from pr_menu.dat
void PF_CL_is_cached_pic (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_CL_is_cached_pic (progfuncs_t *prinst, struct globalvars_s *pr_globals);
@ -315,6 +314,7 @@ void PF_bufstr_get (progfuncs_t *prinst, struct globalvars_s *pr_globals);
void PF_bufstr_set (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_bufstr_set (progfuncs_t *prinst, struct globalvars_s *pr_globals);
void PF_bufstr_add (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_bufstr_add (progfuncs_t *prinst, struct globalvars_s *pr_globals);
void PF_bufstr_free (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_bufstr_free (progfuncs_t *prinst, struct globalvars_s *pr_globals);
void PF_buf_cvarlist (progfuncs_t *prinst, struct globalvars_s *pr_globals);
void PF_whichpack (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_whichpack (progfuncs_t *prinst, struct globalvars_s *pr_globals);

View file

@ -679,17 +679,18 @@ typedef struct entity_state_s
unsigned short modelindex2; //q2 unsigned short modelindex2; //q2
#endif #endif
unsigned short frame; unsigned short frame;
unsigned int skinnum; /*q2 needs 32 bits, which is quite impressive*/
unsigned short colormap; unsigned short colormap;
unsigned short skinnum; //pad 2 bytes
qbyte glowsize; qbyte glowsize;
qbyte glowcolour; qbyte glowcolour;
qbyte scale; qbyte scale;
char fatness; char fatness;
qbyte hexen2flags; qbyte hexen2flags;
qbyte abslight; qbyte abslight;
qbyte dpflags; qbyte dpflags;
//pad
qbyte colormod[3];//multiply this by 8 to read as 0 to 1... qbyte colormod[3];//multiply this by 8 to read as 0 to 1...
qbyte trans; qbyte trans;

View file

@ -549,6 +549,7 @@ void Fragment_ClipTriangle(fragmentdecal_t *dec, float *a, float *b, float *c)
#define MAXFRAGMENTVERTS 360 #define MAXFRAGMENTVERTS 360
int Fragment_ClipPolyToPlane(float *inverts, float *outverts, int incount, float *plane, float planedist) int Fragment_ClipPolyToPlane(float *inverts, float *outverts, int incount, float *plane, float planedist)
{ {
#define C 4
float dotv[MAXFRAGMENTVERTS+1]; float dotv[MAXFRAGMENTVERTS+1];
char keep[MAXFRAGMENTVERTS+1]; char keep[MAXFRAGMENTVERTS+1];
#define KEEP_KILL 0 #define KEEP_KILL 0
@ -562,7 +563,7 @@ int Fragment_ClipPolyToPlane(float *inverts, float *outverts, int incount, float
for (i = 0; i < incount; i++) for (i = 0; i < incount; i++)
{ {
dotv[i] = DotProduct((inverts+i*3), plane) - planedist; dotv[i] = DotProduct((inverts+i*C), plane) - planedist;
if (dotv[i]<-FRAG_EPSILON) if (dotv[i]<-FRAG_EPSILON)
{ {
keep[i] = KEEP_KILL; keep[i] = KEEP_KILL;
@ -580,32 +581,33 @@ int Fragment_ClipPolyToPlane(float *inverts, float *outverts, int incount, float
return 0; //all were clipped return 0; //all were clipped
if (clippedcount == 0) if (clippedcount == 0)
{ //none were clipped { //none were clipped
memcpy(outverts, inverts, sizeof(float)*3*incount); for (i = 0; i < incount; i++)
VectorCopy((inverts+i*C), (outverts+i*C));
return incount; return incount;
} }
for (i = 0; i < incount; i++) for (i = 0; i < incount; i++)
{ {
p1 = inverts+i*3; p1 = inverts+i*C;
if (keep[i] == KEEP_BORDER) if (keep[i] == KEEP_BORDER)
{ {
out = outverts+outcount++*3; out = outverts+outcount++*C;
VectorCopy(p1, out); VectorCopy(p1, out);
continue; continue;
} }
if (keep[i] == KEEP_KEEP) if (keep[i] == KEEP_KEEP)
{ {
out = outverts+outcount++*3; out = outverts+outcount++*C;
VectorCopy(p1, out); VectorCopy(p1, out);
} }
if (keep[i+1] == KEEP_BORDER || keep[i] == keep[i+1]) if (keep[i+1] == KEEP_BORDER || keep[i] == keep[i+1])
continue; continue;
p2 = inverts+((i+1)%incount)*3; p2 = inverts+((i+1)%incount)*C;
d = dotv[i] - dotv[i+1]; d = dotv[i] - dotv[i+1];
if (d) if (d)
d = dotv[i] / d; d = dotv[i] / d;
out = outverts+outcount++*3; out = outverts+outcount++*C;
VectorInterpolate(p1, d, p2, out); VectorInterpolate(p1, d, p2, out);
} }
return outcount; return outcount;
@ -615,8 +617,8 @@ void Fragment_ClipPoly(fragmentdecal_t *dec, int numverts, float *inverts)
{ {
//emit the triangle, and clip it's fragments. //emit the triangle, and clip it's fragments.
int p; int p;
float verts[MAXFRAGMENTVERTS*3]; float verts[MAXFRAGMENTVERTS*C];
float verts2[MAXFRAGMENTVERTS*3]; float verts2[MAXFRAGMENTVERTS*C];
float *cverts; float *cverts;
int flip; int flip;
@ -656,9 +658,9 @@ void Fragment_ClipPoly(fragmentdecal_t *dec, int numverts, float *inverts)
numverts--; numverts--;
VectorCopy((cverts+3*0), decalfragmentverts[dec->numtris*3+0]); VectorCopy((cverts+C*0), decalfragmentverts[dec->numtris*3+0]);
VectorCopy((cverts+3*(numverts-1)), decalfragmentverts[dec->numtris*3+1]); VectorCopy((cverts+C*(numverts-1)), decalfragmentverts[dec->numtris*3+1]);
VectorCopy((cverts+3*numverts), decalfragmentverts[dec->numtris*3+2]); VectorCopy((cverts+C*numverts), decalfragmentverts[dec->numtris*3+2]);
dec->numtris++; dec->numtris++;
} }
} }
@ -670,7 +672,7 @@ void Fragment_Mesh (fragmentdecal_t *dec, mesh_t *mesh)
{ {
int i; int i;
vec3_t verts[3]; vecV_t verts[3];
/*if its a triangle fan/poly/quad then we can just submit the entire thing without generating extra fragments*/ /*if its a triangle fan/poly/quad then we can just submit the entire thing without generating extra fragments*/
if (mesh->istrifan) if (mesh->istrifan)
@ -975,7 +977,7 @@ unsigned int Q1BSP_FatPVS (model_t *mod, vec3_t org, qbyte *pvsbuffer, unsigned
return fatbytes; return fatbytes;
} }
qboolean Q1BSP_EdictInFatPVS(model_t *mod, wedict_t *ent, qbyte *pvs) qboolean Q1BSP_EdictInFatPVS(model_t *mod, struct pvscache_s *ent, qbyte *pvs)
{ {
int i; int i;
@ -996,7 +998,7 @@ SV_FindTouchedLeafs
Links the edict to the right leafs so we can get it's potential visability. Links the edict to the right leafs so we can get it's potential visability.
=============== ===============
*/ */
void Q1BSP_RFindTouchedLeafs (world_t *w, wedict_t *ent, mnode_t *node, float *mins, float *maxs) void Q1BSP_RFindTouchedLeafs (model_t *wm, struct pvscache_s *ent, mnode_t *node, float *mins, float *maxs)
{ {
mplane_t *splitplane; mplane_t *splitplane;
mleaf_t *leaf; mleaf_t *leaf;
@ -1017,7 +1019,7 @@ void Q1BSP_RFindTouchedLeafs (world_t *w, wedict_t *ent, mnode_t *node, float *m
} }
leaf = (mleaf_t *)node; leaf = (mleaf_t *)node;
leafnum = leaf - w->worldmodel->leafs - 1; leafnum = leaf - wm->leafs - 1;
ent->leafnums[ent->num_leafs] = leafnum; ent->leafnums[ent->num_leafs] = leafnum;
ent->num_leafs++; ent->num_leafs++;
@ -1031,16 +1033,16 @@ void Q1BSP_RFindTouchedLeafs (world_t *w, wedict_t *ent, mnode_t *node, float *m
// recurse down the contacted sides // recurse down the contacted sides
if (sides & 1) if (sides & 1)
Q1BSP_RFindTouchedLeafs (w, ent, node->children[0], mins, maxs); Q1BSP_RFindTouchedLeafs (wm, ent, node->children[0], mins, maxs);
if (sides & 2) if (sides & 2)
Q1BSP_RFindTouchedLeafs (w, ent, node->children[1], mins, maxs); Q1BSP_RFindTouchedLeafs (wm, ent, node->children[1], mins, maxs);
} }
void Q1BSP_FindTouchedLeafs(world_t *w, model_t *mod, wedict_t *ent, float *mins, float *maxs) void Q1BSP_FindTouchedLeafs(model_t *mod, struct pvscache_s *ent, float *mins, float *maxs)
{ {
ent->num_leafs = 0; ent->num_leafs = 0;
if (ent->v->modelindex) if (mins && maxs)
Q1BSP_RFindTouchedLeafs (w, ent, mod->nodes, mins, maxs); Q1BSP_RFindTouchedLeafs (mod, ent, mod->nodes, mins, maxs);
} }
#endif #endif
@ -1186,7 +1188,7 @@ void Q1BSP_SetModelFuncs(model_t *mod)
#ifndef CLIENTONLY #ifndef CLIENTONLY
mod->funcs.FatPVS = Q1BSP_FatPVS; mod->funcs.FatPVS = Q1BSP_FatPVS;
mod->funcs.EdictInFatPVS = Q1BSP_EdictInFatPVS; mod->funcs.EdictInFatPVS = Q1BSP_EdictInFatPVS;
mod->funcs.FindTouchedLeafs_Q1 = Q1BSP_FindTouchedLeafs; mod->funcs.FindTouchedLeafs = Q1BSP_FindTouchedLeafs;
#endif #endif
mod->funcs.LightPointValues = NULL; mod->funcs.LightPointValues = NULL;
mod->funcs.StainNode = NULL; mod->funcs.StainNode = NULL;

View file

@ -115,16 +115,16 @@ typedef struct
vec3_t laggedpos; vec3_t laggedpos;
} laggedentinfo_t; } laggedentinfo_t;
struct world_s { struct world_s
{
void (*Event_Touch)(struct world_s *w, wedict_t *s, wedict_t *o); void (*Event_Touch)(struct world_s *w, wedict_t *s, wedict_t *o);
model_t *(*GetCModel)(struct world_s *w, int modelindex); model_t *(*GetCModel)(struct world_s *w, int modelindex);
int *global_self;
unsigned int max_edicts; //limiting factor... 1024 fields*4*MAX_EDICTS == a heck of a lot. unsigned int max_edicts; //limiting factor... 1024 fields*4*MAX_EDICTS == a heck of a lot.
unsigned int num_edicts; // increases towards MAX_EDICTS unsigned int num_edicts; // increases towards MAX_EDICTS
FTE_DEPRECATED unsigned int edict_size; FTE_DEPRECATED unsigned int edict_size; //still used in copyentity
wedict_t *edicts; // can NOT be array indexed, because wedict_t *edicts; // can NOT be array indexed.
// edict_t is variable sized, but can
// be used to reference the world ent
struct progfuncs_s *progs; struct progfuncs_s *progs;
model_t *worldmodel; model_t *worldmodel;
areanode_t areanodes[AREA_NODES]; areanode_t areanodes[AREA_NODES];
@ -203,8 +203,8 @@ int VARGS WorldQ2_AreaEdicts (world_t *w, vec3_t mins, vec3_t maxs, q2edict_t **
trace_t WorldQ2_Move (world_t *w, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int type, q2edict_t *passedict); trace_t WorldQ2_Move (world_t *w, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t end, int type, q2edict_t *passedict);
unsigned int Q2BSP_FatPVS (model_t *mod, vec3_t org, qbyte *buffer, unsigned int buffersize, qboolean add); unsigned int Q2BSP_FatPVS (model_t *mod, vec3_t org, qbyte *buffer, unsigned int buffersize, qboolean add);
qboolean Q2BSP_EdictInFatPVS(model_t *mod, wedict_t *ent, qbyte *pvs); qboolean Q2BSP_EdictInFatPVS(model_t *mod, struct pvscache_s *ent, qbyte *pvs);
void Q2BSP_FindTouchedLeafs(world_t *w, model_t *mod, wedict_t *ent, float *mins, float *maxs); void Q2BSP_FindTouchedLeafs(model_t *mod, struct pvscache_s *ent, float *mins, float *maxs);
#endif #endif

View file

@ -123,7 +123,6 @@ int D3D9_R_LightPoint (vec3_t point);
void D3D9_R_NewMap (void); void D3D9_R_NewMap (void);
void D3D9_R_PreNewMap (void); void D3D9_R_PreNewMap (void);
void D3D9_R_PushDlights (void); void D3D9_R_PushDlights (void);
void D3D9_R_SetSky (char *name, float rotate, vec3_t axis);
void D3D9_SCR_UpdateScreen (void); void D3D9_SCR_UpdateScreen (void);
void D3D9_Set2D (void); void D3D9_Set2D (void);
void D3D9_VID_DeInit (void); void D3D9_VID_DeInit (void);

View file

@ -201,6 +201,6 @@ Global
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
AMDCaProjectFile = C:\Games\Quake\ftesrc\engine\dotnet2005\CodeAnalyst\ftequake.caw AMDCaProjectFile = C:\Games\Quake\wip\engine\dotnet2005\CodeAnalyst\ftequake.caw
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View file

@ -430,6 +430,7 @@
UseOfMFC="0" UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false" ATLMinimizesCRunTimeLibraryUsage="false"
CharacterSet="2" CharacterSet="2"
WholeProgramOptimization="1"
> >
<Tool <Tool
Name="VCPreBuildEventTool" Name="VCPreBuildEventTool"
@ -455,12 +456,16 @@
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="2" Optimization="2"
InlineFunctionExpansion="1" InlineFunctionExpansion="2"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
AdditionalIncludeDirectories="..\client,../libs/freetype2/include,../common,../server,../gl,../sw,../qclib,../libs,../libs/dxsdk7/include" AdditionalIncludeDirectories="..\client,../libs/freetype2/include,../common,../server,../gl,../sw,../qclib,../libs,../libs/dxsdk7/include"
PreprocessorDefinitions="MINIMAL;NDEBUG;GLQUAKE;WIN32;_WINDOWS" PreprocessorDefinitions="MINIMAL;NDEBUG;GLQUAKE;WIN32;_WINDOWS"
StringPooling="true" StringPooling="true"
ExceptionHandling="0"
RuntimeLibrary="0" RuntimeLibrary="0"
EnableFunctionLevelLinking="true" BufferSecurityCheck="false"
FloatingPointModel="2" FloatingPointModel="2"
UsePrecompiledHeader="2" UsePrecompiledHeader="2"
PrecompiledHeaderThrough="quakedef.h" PrecompiledHeaderThrough="quakedef.h"
@ -493,8 +498,9 @@
SuppressStartupBanner="true" SuppressStartupBanner="true"
AdditionalLibraryDirectories="../libs/dxsdk7/lib" AdditionalLibraryDirectories="../libs/dxsdk7/lib"
IgnoreDefaultLibraryNames="libc.lib;msvcrt.lib" IgnoreDefaultLibraryNames="libc.lib;msvcrt.lib"
GenerateMapFile="true"
SubSystem="2" SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1" TargetMachine="1"
/> />
<Tool <Tool
@ -677,7 +683,6 @@
DebugInformationFormat="4" DebugInformationFormat="4"
CallingConvention="1" CallingConvention="1"
CompileAs="1" CompileAs="1"
DisableSpecificWarnings="4996"
/> />
<Tool <Tool
Name="VCManagedResourceCompilerTool" Name="VCManagedResourceCompilerTool"
@ -11491,176 +11496,6 @@
/> />
</FileConfiguration> </FileConfiguration>
</File> </File>
<File
RelativePath="..\client\r_efrag.c"
>
<FileConfiguration
Name="MinGLDebug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="MinGLDebug|x64"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="D3DDebug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="D3DDebug|x64"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="MinGLRelease|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="MinGLRelease|x64"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="GLDebug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="GLDebug|x64"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release Dedicated Server|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Release Dedicated Server|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="MRelease|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="MRelease|x64"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug Dedicated Server|Win32"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="Debug Dedicated Server|x64"
ExcludedFromBuild="true"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="MDebug|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="MDebug|x64"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="GLRelease|Win32"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
<FileConfiguration
Name="GLRelease|x64"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories=""
PreprocessorDefinitions=""
/>
</FileConfiguration>
</File>
<File <File
RelativePath="..\client\r_part.c" RelativePath="..\client\r_part.c"
> >

View file

@ -0,0 +1,144 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ftequake", "ftequake.vcproj", "{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}"
ProjectSection(ProjectDependencies) = postProject
{382E6790-D1CA-48F5-8E53-D114635EB61D} = {382E6790-D1CA-48F5-8E53-D114635EB61D}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gas2masm", "gas2masm.vcproj", "{382E6790-D1CA-48F5-8E53-D114635EB61D}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "npqtv", "npqtv.vcproj", "{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}"
ProjectSection(ProjectDependencies) = postProject
{382E6790-D1CA-48F5-8E53-D114635EB61D} = {382E6790-D1CA-48F5-8E53-D114635EB61D}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
D3DDebug|Win32 = D3DDebug|Win32
D3DDebug|x64 = D3DDebug|x64
Debug Dedicated Server|Win32 = Debug Dedicated Server|Win32
Debug Dedicated Server|x64 = Debug Dedicated Server|x64
GLDebug|Win32 = GLDebug|Win32
GLDebug|x64 = GLDebug|x64
GLRelease|Win32 = GLRelease|Win32
GLRelease|x64 = GLRelease|x64
MDebug|Win32 = MDebug|Win32
MDebug|x64 = MDebug|x64
MinGLDebug|Win32 = MinGLDebug|Win32
MinGLDebug|x64 = MinGLDebug|x64
MinGLRelease|Win32 = MinGLRelease|Win32
MinGLRelease|x64 = MinGLRelease|x64
MRelease|Win32 = MRelease|Win32
MRelease|x64 = MRelease|x64
Release Dedicated Server|Win32 = Release Dedicated Server|Win32
Release Dedicated Server|x64 = Release Dedicated Server|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.D3DDebug|Win32.ActiveCfg = D3DDebug|Win32
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.D3DDebug|Win32.Build.0 = D3DDebug|Win32
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.D3DDebug|x64.ActiveCfg = D3DDebug|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.D3DDebug|x64.Build.0 = D3DDebug|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.Debug Dedicated Server|Win32.ActiveCfg = MRelease|Win32
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.Debug Dedicated Server|Win32.Build.0 = MRelease|Win32
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.Debug Dedicated Server|x64.ActiveCfg = GLDebug|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.Debug Dedicated Server|x64.Build.0 = GLDebug|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.GLDebug|Win32.ActiveCfg = GLDebug|Win32
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.GLDebug|Win32.Build.0 = GLDebug|Win32
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.GLDebug|x64.ActiveCfg = GLDebug|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.GLDebug|x64.Build.0 = GLDebug|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.GLRelease|Win32.ActiveCfg = GLRelease|Win32
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.GLRelease|Win32.Build.0 = GLRelease|Win32
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.GLRelease|x64.ActiveCfg = GLRelease|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.GLRelease|x64.Build.0 = GLRelease|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.MDebug|Win32.ActiveCfg = MDebug|Win32
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.MDebug|Win32.Build.0 = MDebug|Win32
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.MDebug|x64.ActiveCfg = GLRelease|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.MDebug|x64.Build.0 = GLRelease|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.MinGLDebug|Win32.ActiveCfg = MinGLDebug|Win32
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.MinGLDebug|Win32.Build.0 = MinGLDebug|Win32
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.MinGLDebug|x64.ActiveCfg = MinGLDebug|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.MinGLDebug|x64.Build.0 = MinGLDebug|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.MinGLRelease|Win32.ActiveCfg = MinGLRelease|Win32
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.MinGLRelease|Win32.Build.0 = MinGLRelease|Win32
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.MinGLRelease|x64.ActiveCfg = MinGLDebug|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.MinGLRelease|x64.Build.0 = MinGLDebug|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.MRelease|Win32.ActiveCfg = MRelease|Win32
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.MRelease|Win32.Build.0 = MRelease|Win32
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.MRelease|x64.ActiveCfg = MRelease|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.MRelease|x64.Build.0 = MRelease|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.Release Dedicated Server|Win32.ActiveCfg = Release Dedicated Server|Win32
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.Release Dedicated Server|Win32.Build.0 = Release Dedicated Server|Win32
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.Release Dedicated Server|x64.ActiveCfg = Release Dedicated Server|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1364}.Release Dedicated Server|x64.Build.0 = Release Dedicated Server|x64
{382E6790-D1CA-48F5-8E53-D114635EB61D}.D3DDebug|Win32.ActiveCfg = Debug|Win32
{382E6790-D1CA-48F5-8E53-D114635EB61D}.D3DDebug|Win32.Build.0 = Debug|Win32
{382E6790-D1CA-48F5-8E53-D114635EB61D}.D3DDebug|x64.ActiveCfg = Debug|x64
{382E6790-D1CA-48F5-8E53-D114635EB61D}.D3DDebug|x64.Build.0 = Debug|x64
{382E6790-D1CA-48F5-8E53-D114635EB61D}.Debug Dedicated Server|Win32.ActiveCfg = Debug|Win32
{382E6790-D1CA-48F5-8E53-D114635EB61D}.Debug Dedicated Server|Win32.Build.0 = Debug|Win32
{382E6790-D1CA-48F5-8E53-D114635EB61D}.Debug Dedicated Server|x64.ActiveCfg = Debug|Win32
{382E6790-D1CA-48F5-8E53-D114635EB61D}.GLDebug|Win32.ActiveCfg = Debug|Win32
{382E6790-D1CA-48F5-8E53-D114635EB61D}.GLDebug|Win32.Build.0 = Debug|Win32
{382E6790-D1CA-48F5-8E53-D114635EB61D}.GLDebug|x64.ActiveCfg = Debug|Win32
{382E6790-D1CA-48F5-8E53-D114635EB61D}.GLDebug|x64.Build.0 = Debug|Win32
{382E6790-D1CA-48F5-8E53-D114635EB61D}.GLRelease|Win32.ActiveCfg = Debug|Win32
{382E6790-D1CA-48F5-8E53-D114635EB61D}.GLRelease|Win32.Build.0 = Debug|Win32
{382E6790-D1CA-48F5-8E53-D114635EB61D}.GLRelease|x64.ActiveCfg = Debug|x64
{382E6790-D1CA-48F5-8E53-D114635EB61D}.GLRelease|x64.Build.0 = Debug|x64
{382E6790-D1CA-48F5-8E53-D114635EB61D}.MDebug|Win32.ActiveCfg = Debug|Win32
{382E6790-D1CA-48F5-8E53-D114635EB61D}.MDebug|Win32.Build.0 = Debug|Win32
{382E6790-D1CA-48F5-8E53-D114635EB61D}.MDebug|x64.ActiveCfg = Debug|Win32
{382E6790-D1CA-48F5-8E53-D114635EB61D}.MDebug|x64.Build.0 = Debug|Win32
{382E6790-D1CA-48F5-8E53-D114635EB61D}.MinGLDebug|Win32.ActiveCfg = Debug|Win32
{382E6790-D1CA-48F5-8E53-D114635EB61D}.MinGLDebug|Win32.Build.0 = Debug|Win32
{382E6790-D1CA-48F5-8E53-D114635EB61D}.MinGLDebug|x64.ActiveCfg = Debug|x64
{382E6790-D1CA-48F5-8E53-D114635EB61D}.MinGLDebug|x64.Build.0 = Debug|x64
{382E6790-D1CA-48F5-8E53-D114635EB61D}.MinGLRelease|Win32.ActiveCfg = Debug|Win32
{382E6790-D1CA-48F5-8E53-D114635EB61D}.MinGLRelease|Win32.Build.0 = Debug|Win32
{382E6790-D1CA-48F5-8E53-D114635EB61D}.MinGLRelease|x64.ActiveCfg = Debug|Win32
{382E6790-D1CA-48F5-8E53-D114635EB61D}.MinGLRelease|x64.Build.0 = Debug|Win32
{382E6790-D1CA-48F5-8E53-D114635EB61D}.MRelease|Win32.ActiveCfg = Debug|Win32
{382E6790-D1CA-48F5-8E53-D114635EB61D}.MRelease|Win32.Build.0 = Debug|Win32
{382E6790-D1CA-48F5-8E53-D114635EB61D}.MRelease|x64.ActiveCfg = Debug|Win32
{382E6790-D1CA-48F5-8E53-D114635EB61D}.MRelease|x64.Build.0 = Debug|Win32
{382E6790-D1CA-48F5-8E53-D114635EB61D}.Release Dedicated Server|Win32.ActiveCfg = Debug|Win32
{382E6790-D1CA-48F5-8E53-D114635EB61D}.Release Dedicated Server|Win32.Build.0 = Debug|Win32
{382E6790-D1CA-48F5-8E53-D114635EB61D}.Release Dedicated Server|x64.ActiveCfg = Debug|Win32
{382E6790-D1CA-48F5-8E53-D114635EB61D}.Release Dedicated Server|x64.Build.0 = Debug|Win32
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.D3DDebug|Win32.ActiveCfg = GLRelease|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.D3DDebug|x64.ActiveCfg = GLRelease|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.D3DDebug|x64.Build.0 = GLRelease|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.Debug Dedicated Server|Win32.ActiveCfg = GLDebug|Win32
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.Debug Dedicated Server|x64.ActiveCfg = GLRelease|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.Debug Dedicated Server|x64.Build.0 = GLRelease|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.GLDebug|Win32.ActiveCfg = GLDebug|Win32
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.GLDebug|Win32.Build.0 = GLDebug|Win32
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.GLDebug|x64.ActiveCfg = GLDebug|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.GLDebug|x64.Build.0 = GLDebug|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.GLRelease|Win32.ActiveCfg = GLRelease|Win32
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.GLRelease|Win32.Build.0 = GLRelease|Win32
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.GLRelease|x64.ActiveCfg = GLRelease|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.GLRelease|x64.Build.0 = GLRelease|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.MDebug|Win32.ActiveCfg = GLDebug|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.MDebug|x64.ActiveCfg = GLRelease|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.MDebug|x64.Build.0 = GLRelease|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.MinGLDebug|Win32.ActiveCfg = GLDebug|Win32
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.MinGLDebug|Win32.Build.0 = GLDebug|Win32
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.MinGLDebug|x64.ActiveCfg = GLDebug|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.MinGLDebug|x64.Build.0 = GLDebug|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.MinGLRelease|Win32.ActiveCfg = GLRelease|Win32
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.MinGLRelease|Win32.Build.0 = GLRelease|Win32
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.MinGLRelease|x64.ActiveCfg = GLRelease|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.MinGLRelease|x64.Build.0 = GLRelease|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.MRelease|Win32.ActiveCfg = GLRelease|Win32
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.MRelease|x64.ActiveCfg = GLRelease|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.MRelease|x64.Build.0 = GLRelease|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.Release Dedicated Server|Win32.ActiveCfg = GLRelease|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.Release Dedicated Server|x64.ActiveCfg = GLRelease|x64
{88BFEE0E-7BC0-43AD-9CCC-6B1A6E4C1365}.Release Dedicated Server|x64.Build.0 = GLRelease|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,225 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="gas2masm"
ProjectGUID="{382E6790-D1CA-48F5-8E53-D114635EB61D}"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="..\gas2masm\Debug"
IntermediateDirectory="..\gas2masm\Debug"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Debug/gas2masm.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
RuntimeLibrary="1"
PrecompiledHeaderFile="..\gas2masm\Debug\gas2masm.pch"
AssemblerListingLocation="..\gas2masm\Debug\"
ObjectFile="..\gas2masm\Debug\"
ProgramDataBaseFileName="..\gas2masm\Debug\"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="4"
CompileAs="1"
DisableSpecificWarnings="4996"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="..\gas2masm\Debug\gas2masm.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
GenerateDebugInformation="true"
ProgramDatabaseFile="..\gas2masm\Debug\gas2masm.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Debug/gas2masm.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="false"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
TypeLibraryName=".\Debug/gas2masm.tlb"
HeaderFileName=""
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
RuntimeLibrary="1"
PrecompiledHeaderFile="..\gas2masm\Debug\gas2masm.pch"
AssemblerListingLocation="..\gas2masm\Debug\"
ObjectFile="..\gas2masm\Debug\"
ProgramDataBaseFileName="..\gas2masm\Debug\"
WarningLevel="3"
SuppressStartupBanner="true"
DebugInformationFormat="3"
CompileAs="1"
DisableSpecificWarnings="4996"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1033"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="..\gas2masm\Debug\gas2masm.exe"
LinkIncremental="2"
SuppressStartupBanner="true"
GenerateDebugInformation="true"
ProgramDatabaseFile="..\gas2masm\Debug\gas2masm.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
SuppressStartupBanner="true"
OutputFile=".\Debug/gas2masm.bsc"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;rc;def;r;odl;hpj;bat;for;f90"
>
<File
RelativePath="..\gas2masm\gas2masm.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;fi;fd"
>
</Filter>
<Filter
Name="Resource Files"
Filter="ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

43499
engine/dotnet2008/npqtv.vcproj Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,14 @@
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by npqtv.rc
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View file

@ -639,69 +639,6 @@ SOURCE=..\server\svq3_game.c
!ENDIF !ENDIF
# End Source File
# Begin Source File
SOURCE=..\server\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"quakedef.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 # End Source File
# End Group # End Group
# Begin Group "client" # Begin Group "client"
@ -2180,6 +2117,10 @@ SOURCE=..\client\p_null.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\client\p_qmb.c
# End Source File
# Begin Source File
SOURCE=..\client\p_script.c SOURCE=..\client\p_script.c
!IF "$(CFG)" == "ftequake - Win32 Release" !IF "$(CFG)" == "ftequake - Win32 Release"
@ -2355,50 +2296,6 @@ SOURCE=..\client\r_bulleten.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\client\r_efrag.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 BASE Exclude_From_Build 1
# PROP Exclude_From_Build 1
# ADD CPP /G6 /O1
!ELSEIF "$(CFG)" == "ftequake - Win32 MinSW"
!ELSEIF "$(CFG)" == "ftequake - Win32 GLDebugQ3"
!ELSEIF "$(CFG)" == "ftequake - Win32 Debug Dedicated ServerQ3"
# PROP BASE Exclude_From_Build 1
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 D3DDebug"
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\client\r_part.c SOURCE=..\client\r_part.c
!IF "$(CFG)" == "ftequake - Win32 Release" !IF "$(CFG)" == "ftequake - Win32 Release"
@ -3803,52 +3700,6 @@ SOURCE=..\gl\gl_ngraph.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\gl\gl_ppl.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 BASE Exclude_From_Build 1
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 MinSW"
# PROP BASE Exclude_From_Build 1
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 GLDebugQ3"
!ELSEIF "$(CFG)" == "ftequake - Win32 Debug Dedicated ServerQ3"
# PROP BASE Exclude_From_Build 1
# PROP Exclude_From_Build 1
!ELSEIF "$(CFG)" == "ftequake - Win32 D3DDebug"
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\common\gl_q2bsp.c SOURCE=..\common\gl_q2bsp.c
!IF "$(CFG)" == "ftequake - Win32 Release" !IF "$(CFG)" == "ftequake - Win32 Release"
@ -4391,6 +4242,14 @@ SOURCE=..\gl\LTFACE.C
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\client\r_2d.c
# End Source File
# Begin Source File
SOURCE=..\client\r_surf.c
# End Source File
# Begin Source File
SOURCE=..\gl\shader.h SOURCE=..\gl\shader.h
# End Source File # End Source File
# End Group # End Group
@ -4544,6 +4403,69 @@ SOURCE=..\common\translate.c
# End Source File # End Source File
# Begin Source File # Begin Source File
SOURCE=..\server\world.c
!IF "$(CFG)" == "ftequake - Win32 Release"
# ADD CPP /Yu"quekdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 Debug"
# ADD CPP /Yu"quekdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 GLDebug"
# ADD CPP /Yu"quakedef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 GLRelease"
# ADD CPP /Yu"quekdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 MDebug"
# ADD CPP /Yu"quekdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 MRelease"
# ADD CPP /Yu"quekdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 MinGLDebug"
# ADD CPP /Yu"quekdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 MinGLRelease"
# ADD CPP /Yu"quekdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 Debug Dedicated Server"
# ADD CPP /Yu"quekdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 Release Dedicated Server"
# ADD CPP /Yu"quekdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 MinSW"
# ADD CPP /Yu"quekdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 GLDebugQ3"
# ADD CPP /Yu"quekdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 Debug Dedicated ServerQ3"
# ADD CPP /Yu"quekdef.h"
!ELSEIF "$(CFG)" == "ftequake - Win32 D3DDebug"
# ADD CPP /Yu"quekdef.h"
!ENDIF
# End Source File
# Begin Source File
SOURCE=..\common\zone.c SOURCE=..\common\zone.c
# End Source File # End Source File
# End Group # End Group

View file

@ -223,12 +223,12 @@ static texnums_t *GL_ChooseSkin(galiasinfo_t *inf, char *modelname, int surfnum,
unsigned int tc, bc; unsigned int tc, bc;
qboolean forced; qboolean forced;
if ((e->model->engineflags & MDLF_NOTREPLACEMENTS) && !ruleset_allow_sensative_texture_replacements.value) if ((e->model->engineflags & MDLF_NOTREPLACEMENTS) && !ruleset_allow_sensative_texture_replacements.ival)
forced = true; forced = true;
else else
forced = false; forced = false;
if (!gl_nocolors.value || forced) if (!gl_nocolors.ival || forced)
{ {
if (e->scoreboard) if (e->scoreboard)
{ {
@ -517,7 +517,7 @@ static texnums_t *GL_ChooseSkin(galiasinfo_t *inf, char *modelname, int surfnum,
} }
} }
texnums->base = R_AllocNewTexture(scaled_width, scaled_height); texnums->base = R_AllocNewTexture(scaled_width, scaled_height);
R_Upload(texnums->base, "", TF_RGBX32, pixels, scaled_width, scaled_height, IF_NOMIPMAP); R_Upload(texnums->base, "", TF_RGBX32, pixels, NULL, scaled_width, scaled_height, IF_NOMIPMAP);
//now do the fullbrights. //now do the fullbrights.
out = pixels; out = pixels;
@ -534,7 +534,7 @@ static texnums_t *GL_ChooseSkin(galiasinfo_t *inf, char *modelname, int surfnum,
} }
} }
texnums->fullbright = R_AllocNewTexture(scaled_width, scaled_height); texnums->fullbright = R_AllocNewTexture(scaled_width, scaled_height);
R_Upload(texnums->fullbright, "", TF_RGBA32, pixels, scaled_width, scaled_height, IF_NOMIPMAP); R_Upload(texnums->fullbright, "", TF_RGBA32, pixels, NULL, scaled_width, scaled_height, IF_NOMIPMAP);
} }
else else
{ {
@ -905,7 +905,7 @@ void R_DrawGAliasModel (entity_t *e, unsigned int rmode)
// if (e->flags & Q2RF_VIEWERMODEL && e->keynum == cl.playernum[r_refdef.currentplayernum]+1) // if (e->flags & Q2RF_VIEWERMODEL && e->keynum == cl.playernum[r_refdef.currentplayernum]+1)
// return; // return;
if (r_secondaryview && e->flags & Q2RF_WEAPONMODEL) if (r_refdef.externalview && e->flags & Q2RF_WEAPONMODEL)
return; return;
{ {
@ -1139,7 +1139,7 @@ void R_DrawGAliasModel (entity_t *e, unsigned int rmode)
} }
} }
BE_DrawMeshChain(shader, &mesh, NULL, skin); BE_DrawMesh_Single(shader, &mesh, NULL, skin);
} }
if (e->flags & Q2RF_WEAPONMODEL) if (e->flags & Q2RF_WEAPONMODEL)
@ -1160,7 +1160,7 @@ void R_DrawGAliasModel (entity_t *e, unsigned int rmode)
#endif #endif
} }
//returns result in the form of the result vector //returns the rotated offset of the two points in result
void RotateLightVector(const vec3_t *axis, const vec3_t origin, const vec3_t lightpoint, vec3_t result) void RotateLightVector(const vec3_t *axis, const vec3_t origin, const vec3_t lightpoint, vec3_t result)
{ {
vec3_t offs; vec3_t offs;

File diff suppressed because it is too large Load diff

View file

@ -8,7 +8,7 @@ of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details. See the GNU General Public License for more details.
@ -27,47 +27,21 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifdef GLQUAKE #ifdef GLQUAKE
#include "glquake.h" #include "glquake.h"
extern vrect_t gl_truescreenrect; /*
==============================================================================
/*
==============================================================================
LIGHT BLOOMS LIGHT BLOOMS
==============================================================================
*/
static float Diamond8x[8][8] = { ==============================================================================
{0.0f, 0.0f, 0.0f, 0.1f, 0.1f, 0.0f, 0.0f, 0.0f}, */
{0.0f, 0.0f, 0.2f, 0.3f, 0.3f, 0.2f, 0.0f, 0.0f},
{0.0f, 0.2f, 0.4f, 0.6f, 0.6f, 0.4f, 0.2f, 0.0f},
{0.1f, 0.3f, 0.6f, 0.9f, 0.9f, 0.6f, 0.3f, 0.1f},
{0.1f, 0.3f, 0.6f, 0.9f, 0.9f, 0.6f, 0.3f, 0.1f},
{0.0f, 0.2f, 0.4f, 0.6f, 0.6f, 0.4f, 0.2f, 0.0f},
{0.0f, 0.0f, 0.2f, 0.3f, 0.3f, 0.2f, 0.0f, 0.0f},
{0.0f, 0.0f, 0.0f, 0.1f, 0.1f, 0.0f, 0.0f, 0.0f} };
static float Diamond6x[6][6] = { cvar_t r_bloom = CVARAFD("r_bloom", "0", "gl_bloom", CVAR_ARCHIVE, "Enables bloom (light bleeding from bright objects)");
{0.0f, 0.0f, 0.1f, 0.1f, 0.0f, 0.0f}, cvar_t r_bloom_alpha = CVAR("r_bloom_alpha", "0.5");
{0.0f, 0.3f, 0.5f, 0.5f, 0.3f, 0.0f}, cvar_t r_bloom_diamond_size = CVAR("r_bloom_diamond_size", "8");
{0.1f, 0.5f, 0.9f, 0.9f, 0.5f, 0.1f}, cvar_t r_bloom_intensity = CVAR("r_bloom_intensity", "1");
{0.1f, 0.5f, 0.9f, 0.9f, 0.5f, 0.1f}, cvar_t r_bloom_darken = CVAR("r_bloom_darken", "3");
{0.0f, 0.3f, 0.5f, 0.5f, 0.3f, 0.0f}, cvar_t r_bloom_sample_size = CVARF("r_bloom_sample_size", "256", CVAR_RENDERERLATCH);
{0.0f, 0.0f, 0.1f, 0.1f, 0.0f, 0.0f} }; cvar_t r_bloom_fast_sample = CVARF("r_bloom_fast_sample", "0", CVAR_RENDERERLATCH);
static float Diamond4x[4][4] = {
{0.3f, 0.4f, 0.4f, 0.3f},
{0.4f, 0.9f, 0.9f, 0.4f},
{0.4f, 0.9f, 0.9f, 0.4f},
{0.3f, 0.4f, 0.4f, 0.3f} };
cvar_t r_bloom = FCVAR("r_bloom", "gl_bloom", "0", CVAR_ARCHIVE);
static cvar_t r_bloom_alpha = SCVAR("r_bloom_alpha", "0.5");
static cvar_t r_bloom_diamond_size = SCVAR("r_bloom_diamond_size", "8");
static cvar_t r_bloom_intensity = SCVAR("r_bloom_intensity", "1");
static cvar_t r_bloom_darken = SCVAR("r_bloom_darken", "3");
static cvar_t r_bloom_sample_size = SCVARF("r_bloom_sample_size", "256", CVAR_RENDERERLATCH);
static cvar_t r_bloom_fast_sample = SCVARF("r_bloom_fast_sample", "0", CVAR_RENDERERLATCH);
typedef struct { typedef struct {
//texture numbers //texture numbers
@ -139,12 +113,12 @@ R_Bloom_InitBackUpTexture
void R_Bloom_InitBackUpTexture(int widthheight) void R_Bloom_InitBackUpTexture(int widthheight)
{ {
qbyte *data; qbyte *data;
data = Z_Malloc(widthheight * widthheight * 4); data = Z_Malloc(widthheight * widthheight * 4);
bs.size_backup = widthheight; bs.size_backup = widthheight;
bs.tx_backup = GL_LoadTexture32("***bs.tx_backup***", bs.size_backup, bs.size_backup, (unsigned int*)data, IF_NOMIPMAP|IF_NOALPHA|IF_NOGAMMA); bs.tx_backup = GL_LoadTexture32("***bs.tx_backup***", bs.size_backup, bs.size_backup, (unsigned int*)data, IF_NOMIPMAP|IF_NOALPHA|IF_NOGAMMA);
Z_Free (data); Z_Free (data);
} }
@ -157,12 +131,12 @@ void R_Bloom_InitEffectTexture(void)
{ {
qbyte *data; qbyte *data;
float bloomsizecheck; float bloomsizecheck;
if (r_bloom_sample_size.value < 32) if (r_bloom_sample_size.value < 32)
Cvar_SetValue (&r_bloom_sample_size, 32); Cvar_SetValue (&r_bloom_sample_size, 32);
//make sure bloom size is a power of 2 //make sure bloom size is a power of 2
bs.size_sample = r_bloom_sample_size.value; bs.size_sample = min(r_bloom_sample_size.value, gl_max_size.value);
bloomsizecheck = (float)bs.size_sample; bloomsizecheck = (float)bs.size_sample;
while (bloomsizecheck > 1.0f) bloomsizecheck /= 2.0f; while (bloomsizecheck > 1.0f) bloomsizecheck /= 2.0f;
if (bloomsizecheck != 1.0f) if (bloomsizecheck != 1.0f)
@ -183,7 +157,7 @@ void R_Bloom_InitEffectTexture(void)
data = Z_Malloc(bs.size_sample * bs.size_sample * 4); data = Z_Malloc(bs.size_sample * bs.size_sample * 4);
bs.tx_effect = GL_LoadTexture32("***bs.tx_effect***", bs.size_sample, bs.size_sample, (unsigned int*)data, IF_NOMIPMAP|IF_NOALPHA|IF_NOGAMMA); bs.tx_effect = GL_LoadTexture32("***bs.tx_effect***", bs.size_sample, bs.size_sample, (unsigned int*)data, IF_NOMIPMAP|IF_NOALPHA|IF_NOGAMMA);
Z_Free (data); Z_Free (data);
} }
@ -198,7 +172,7 @@ void R_Bloom_InitTextures(void)
int size; int size;
int maxtexsize; int maxtexsize;
//find closer power of 2 to screen size //find closer power of 2 to screen size
for (bs.scr_w = 1;bs.scr_w < vid.pixelwidth;bs.scr_w *= 2); for (bs.scr_w = 1;bs.scr_w < vid.pixelwidth;bs.scr_w *= 2);
for (bs.scr_h = 1;bs.scr_h < vid.pixelheight;bs.scr_h *= 2); for (bs.scr_h = 1;bs.scr_h < vid.pixelheight;bs.scr_h *= 2);
@ -286,7 +260,7 @@ void R_Bloom_DrawEffect(void)
qglBlendFunc(GL_ONE, GL_ONE); qglBlendFunc(GL_ONE, GL_ONE);
qglColor4f(r_bloom_alpha.value, r_bloom_alpha.value, r_bloom_alpha.value, 1.0f); qglColor4f(r_bloom_alpha.value, r_bloom_alpha.value, r_bloom_alpha.value, 1.0f);
GL_TexEnv(GL_MODULATE); GL_TexEnv(GL_MODULATE);
qglBegin(GL_QUADS); qglBegin(GL_QUADS);
qglTexCoord2f (0, bs.smp_t); qglTexCoord2f (0, bs.smp_t);
qglVertex2f (bs.vp_x, bs.vp_y); qglVertex2f (bs.vp_x, bs.vp_y);
qglTexCoord2f (0, 0); qglTexCoord2f (0, 0);
@ -296,7 +270,7 @@ void R_Bloom_DrawEffect(void)
qglTexCoord2f (bs.smp_s, bs.smp_t); qglTexCoord2f (bs.smp_s, bs.smp_t);
qglVertex2f (bs.vp_x + bs.vp_w, bs.vp_y); qglVertex2f (bs.vp_x + bs.vp_w, bs.vp_y);
qglEnd(); qglEnd();
qglDisable(GL_BLEND); qglDisable(GL_BLEND);
} }
@ -337,7 +311,7 @@ void R_Bloom_GeneratexCross(void)
{ {
qglBlendFunc(GL_DST_COLOR, GL_ZERO); qglBlendFunc(GL_DST_COLOR, GL_ZERO);
GL_TexEnv(GL_MODULATE); GL_TexEnv(GL_MODULATE);
for(i=0; i<r_bloom_darken->integer ;i++) { for(i=0; i<r_bloom_darken->integer ;i++) {
R_Bloom_SamplePass( 0, 0 ); R_Bloom_SamplePass( 0, 0 );
} }
@ -346,7 +320,7 @@ void R_Bloom_GeneratexCross(void)
//bluring passes //bluring passes
if( BLOOM_BLUR_RADIUS ) { if( BLOOM_BLUR_RADIUS ) {
qglBlendFunc(GL_ONE, GL_ONE); qglBlendFunc(GL_ONE, GL_ONE);
range = (float)BLOOM_BLUR_RADIUS; range = (float)BLOOM_BLUR_RADIUS;
@ -381,7 +355,7 @@ void R_Bloom_GeneratexCross(void)
qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, bs.smp_w, bs.smp_h); qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, bs.smp_w, bs.smp_h);
} }
//restore full screen workspace //restore full screen workspace
qglViewport( 0, 0, glState.width, glState.height ); qglViewport( 0, 0, glState.width, glState.height );
qglMatrixMode( GL_PROJECTION ); qglMatrixMode( GL_PROJECTION );
@ -424,7 +398,7 @@ void R_Bloom_GeneratexDiamonds(void)
{ {
qglBlendFunc(GL_DST_COLOR, GL_ZERO); qglBlendFunc(GL_DST_COLOR, GL_ZERO);
GL_TexEnv(GL_MODULATE); GL_TexEnv(GL_MODULATE);
for (i=0; i<r_bloom_darken.value ;i++) for (i=0; i<r_bloom_darken.value ;i++)
{ {
R_Bloom_SamplePass(0, 0); R_Bloom_SamplePass(0, 0);
@ -435,59 +409,28 @@ void R_Bloom_GeneratexDiamonds(void)
//bluring passes //bluring passes
//qglBlendFunc(GL_ONE, GL_ONE); //qglBlendFunc(GL_ONE, GL_ONE);
qglBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR); qglBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);
if (r_bloom_diamond_size.value > 7 || r_bloom_diamond_size.value <= 3)
{
if (r_bloom_diamond_size.value != 8)
Cvar_SetValue(&r_bloom_diamond_size, 8);
for (i=0; i<r_bloom_diamond_size.value; i++) {
int size = r_bloom_diamond_size.value;
float rad = r_bloom_diamond_size.value / 2.0f;
float point = (r_bloom_diamond_size.value - 1) / 2.0f;
float mult = min(1.0f, r_bloom_intensity.value * 2.0f / rad);
for (i=0; i<size; i++)
{ {
for (j=0; j<r_bloom_diamond_size.value; j++) for (j=0; j<size; j++)
{ {
intensity = r_bloom_intensity.value * 0.3 * Diamond8x[i][j]; float f = ((point + 1.0f) - (fabs(point - i) + fabs(point - j))) / (point + 1.0f);
if (intensity < 0.01f) //float f = 1.0f - (fabs(point - i) * fabs(point - j) / (point * point)); // circle/cross?
intensity = mult * f;
if (intensity < 0.005f)
continue; continue;
qglColor4f(intensity, intensity, intensity, 1.0); qglColor4f(intensity, intensity, intensity, 1.0);
R_Bloom_SamplePass(i-4, j-4); R_Bloom_SamplePass( i-rad, j-rad );
} }
} }
} }
else if (r_bloom_diamond_size.value > 5)
{
if (r_bloom_diamond_size.value != 6)
Cvar_SetValue(&r_bloom_diamond_size, 6);
for(i=0; i<r_bloom_diamond_size.value; i++)
{
for(j=0; j<r_bloom_diamond_size.value; j++)
{
intensity = r_bloom_intensity.value * 0.5 * Diamond6x[i][j];
if (intensity < 0.01f)
continue;
qglColor4f(intensity, intensity, intensity, 1.0);
R_Bloom_SamplePass(i-3, j-3);
}
}
}
else if (r_bloom_diamond_size.value > 3)
{
if (r_bloom_diamond_size.value != 4)
Cvar_SetValue(&r_bloom_diamond_size, 4);
for (i=0; i<r_bloom_diamond_size.value; i++)
{
for (j=0; j<r_bloom_diamond_size.value; j++)
{
intensity = r_bloom_intensity.value * 0.8f * Diamond4x[i][j];
if (intensity < 0.01f)
continue;
qglColor4f(intensity, intensity, intensity, 1.0);
R_Bloom_SamplePass( i-2, j-2 );
}
}
}
qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, bs.smp_w, bs.smp_h); qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, bs.smp_w, bs.smp_h);
//restore full screen workspace //restore full screen workspace
@ -497,7 +440,7 @@ void R_Bloom_GeneratexDiamonds(void)
qglOrtho(0, vid.pixelwidth, vid.pixelheight, 0, -10, 100); qglOrtho(0, vid.pixelwidth, vid.pixelheight, 0, -10, 100);
qglMatrixMode(GL_MODELVIEW); qglMatrixMode(GL_MODELVIEW);
qglLoadIdentity (); qglLoadIdentity ();
} }
/* /*
================= =================
@ -514,7 +457,7 @@ void R_Bloom_DownsampleView( void )
{ {
int midsample_width = bs.size_downsample * bs.smp_s; int midsample_width = bs.size_downsample * bs.smp_s;
int midsample_height = bs.size_downsample * bs.smp_t; int midsample_height = bs.size_downsample * bs.smp_t;
//copy the screen and draw resized //copy the screen and draw resized
GL_Bind(bs.tx_screen); GL_Bind(bs.tx_screen);
qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, bs.vp_x, vid.pixelheight - (bs.vp_y + bs.vp_h), bs.vp_w, bs.vp_h); qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, bs.vp_x, vid.pixelheight - (bs.vp_y + bs.vp_h), bs.vp_w, bs.vp_h);
@ -552,11 +495,9 @@ void R_Bloom_DownsampleView( void )
R_BloomBlend R_BloomBlend
================= =================
*/ */
void R_BloomBlend (void)//refdef_t *fd, meshlist_t *meshlist ) void R_BloomBlend (void)
{ {
int buw, buh; int buw, buh;
if (!r_bloom.value)
return;
if (!bs.size_sample || bs.scr_w < vid.pixelwidth || bs.scr_h < vid.pixelheight) if (!bs.size_sample || bs.scr_w < vid.pixelwidth || bs.scr_h < vid.pixelheight)
R_Bloom_InitTextures(); R_Bloom_InitTextures();
@ -584,10 +525,10 @@ void R_BloomBlend (void)//refdef_t *fd, meshlist_t *meshlist )
qglColor4f(1, 1, 1, 1); qglColor4f(1, 1, 1, 1);
//set up current sizes //set up current sizes
bs.vp_x = gl_truescreenrect.x; bs.vp_x = r_refdef.pxrect.x;
bs.vp_y = vid.pixelheight - gl_truescreenrect.y; bs.vp_y = vid.pixelheight - r_refdef.pxrect.y;
bs.vp_w = gl_truescreenrect.width; bs.vp_w = r_refdef.pxrect.width;
bs.vp_h = gl_truescreenrect.height; bs.vp_h = r_refdef.pxrect.height;
bs.scr_s = (float)bs.vp_w / (float)bs.scr_w; bs.scr_s = (float)bs.vp_w / (float)bs.scr_w;
bs.scr_t = (float)bs.vp_h / (float)bs.scr_h; bs.scr_t = (float)bs.vp_h / (float)bs.scr_h;
if (bs.vp_h > bs.vp_w) if (bs.vp_h > bs.vp_w)
@ -606,9 +547,9 @@ void R_BloomBlend (void)//refdef_t *fd, meshlist_t *meshlist )
bs.smp_s = (float)bs.smp_w/bs.size_sample; bs.smp_s = (float)bs.smp_w/bs.size_sample;
bs.smp_t = (float)bs.smp_h/bs.size_sample; bs.smp_t = (float)bs.smp_h/bs.size_sample;
buw = bs.size_downsample * bs.smp_s; buw = bs.size_backup * bs.smp_s;
buh = bs.size_downsample * bs.smp_t; buh = bs.size_backup * bs.smp_t;
//copy the screen space we'll use to work into the backup texture //copy the screen space we'll use to work into the backup texture
GL_Bind(bs.tx_backup); GL_Bind(bs.tx_backup);
qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, buw, buh); qglCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, buw, buh);
@ -623,7 +564,7 @@ void R_BloomBlend (void)//refdef_t *fd, meshlist_t *meshlist )
qglDisable(GL_BLEND); qglDisable(GL_BLEND);
GL_Bind(bs.tx_backup); GL_Bind(bs.tx_backup);
qglColor4f(1, 1, 1, 1); qglColor4f(1, 1, 1, 1);
R_Bloom_Quad(0, R_Bloom_Quad(0,
vid.pixelheight - (buh), vid.pixelheight - (buh),
buw, buw,
buh, buh,

View file

@ -37,8 +37,9 @@ static void GL_Upload32 (char *name, unsigned *data, int width, int height, unsi
static void GL_Upload32_BGRA (char *name, unsigned *data, int width, int height, unsigned int flags); static void GL_Upload32_BGRA (char *name, unsigned *data, int width, int height, unsigned int flags);
static void GL_Upload24BGR_Flip (char *name, qbyte *framedata, int inwidth, int inheight, unsigned int flags); static void GL_Upload24BGR_Flip (char *name, qbyte *framedata, int inwidth, int inheight, unsigned int flags);
static void GL_Upload8 (char *name, qbyte *data, int width, int height, unsigned int flags, unsigned int alpha); static void GL_Upload8 (char *name, qbyte *data, int width, int height, unsigned int flags, unsigned int alpha);
static void GL_Upload8Pal32 (qbyte *data, qbyte *pal, int width, int height, unsigned int flags);
void GL_UploadFmt(texid_t tex, char *name, enum uploadfmt fmt, void *data, int width, int height, unsigned int flags) void GL_UploadFmt(texid_t tex, char *name, enum uploadfmt fmt, void *data, void *palette, int width, int height, unsigned int flags)
{ {
GL_Bind(tex); GL_Bind(tex);
switch(fmt) switch(fmt)
@ -72,6 +73,13 @@ void GL_UploadFmt(texid_t tex, char *name, enum uploadfmt fmt, void *data, int w
GL_Upload8(name, data, width, height, flags, 1); GL_Upload8(name, data, width, height, flags, 1);
break; break;
case TF_8PAL24:
GL_Upload8Pal24(data, palette, width, height, flags);
break;
case TF_8PAL32:
GL_Upload8Pal32(data, palette, width, height, flags);
break;
#ifdef _MSC_VER #ifdef _MSC_VER
default: default:
Sys_Error("Unsupported image format type\n"); Sys_Error("Unsupported image format type\n");
@ -79,6 +87,7 @@ void GL_UploadFmt(texid_t tex, char *name, enum uploadfmt fmt, void *data, int w
#endif #endif
} }
} }
texid_t GL_LoadTextureFmt (char *name, int width, int height, enum uploadfmt fmt, void *data, unsigned int flags) texid_t GL_LoadTextureFmt (char *name, int width, int height, enum uploadfmt fmt, void *data, unsigned int flags)
{ {
extern cvar_t r_shadow_bumpscale_basetexture; extern cvar_t r_shadow_bumpscale_basetexture;
@ -122,40 +131,30 @@ static index_t r_quad_indexes[6] = {0, 1, 2, 0, 2, 3};
extern qbyte gammatable[256]; extern qbyte gammatable[256];
#ifdef GL_USE8BITTEX
unsigned char *d_15to8table; unsigned char *d_15to8table;
qboolean inited15to8; qboolean inited15to8;
#endif
extern cvar_t crosshair, crosshairimage, crosshairalpha, cl_crossx, cl_crossy, crosshaircolor, crosshairsize; extern cvar_t crosshair, crosshairimage, crosshairalpha, cl_crossx, cl_crossy, crosshaircolor, crosshairsize;
static texid_t filmtexture; static texid_t filmtexture;
extern cvar_t gl_nobind;
extern cvar_t gl_max_size; extern cvar_t gl_max_size;
extern cvar_t gl_picmip; extern cvar_t gl_picmip;
extern cvar_t gl_lerpimages; extern cvar_t gl_lerpimages;
extern cvar_t gl_picmip2d; extern cvar_t gl_picmip2d;
extern cvar_t r_drawdisk;
extern cvar_t gl_compress; extern cvar_t gl_compress;
extern cvar_t gl_smoothfont, gl_smoothcrosshair, gl_fontinwardstep; extern cvar_t gl_smoothcrosshair;
extern cvar_t gl_texturemode, gl_texture_anisotropic_filtering; extern cvar_t gl_texturemode, gl_texture_anisotropic_filtering;
extern cvar_t cl_noblink;
extern cvar_t gl_savecompressedtex; extern cvar_t gl_savecompressedtex;
extern cvar_t gl_load24bit;
extern cvar_t con_ocranaleds;
extern cvar_t gl_blend2d;
extern cvar_t scr_conalpha;
texid_t translate_texture; texid_t translate_texture;
texid_t missing_texture; //texture used when one is missing. texid_t missing_texture; //texture used when one is missing.
texid_t cs_texture; // crosshair texture texid_t cs_texture; // crosshair texture
shader_t *crosshair_shader; shader_t *crosshair_shader;
float custom_char_instep, default_char_instep; //to avoid blending issues
float char_instep;
static unsigned cs_data[16*16]; static unsigned cs_data[16*16];
static texid_t externalhair; static texid_t externalhair;
int gl_anisotropy_factor; int gl_anisotropy_factor;
@ -172,8 +171,6 @@ int gl_filter_min = GL_LINEAR_MIPMAP_NEAREST;
int gl_filter_max = GL_LINEAR; int gl_filter_max = GL_LINEAR;
int gl_filter_max_2d = GL_LINEAR; int gl_filter_max_2d = GL_LINEAR;
int texels;
typedef struct gltexture_s typedef struct gltexture_s
{ {
texid_t texnum; texid_t texnum;
@ -407,7 +404,9 @@ TRACE(("dbg: GLDraw_ReInit: Allocating upload buffers\n"));
TRACE(("dbg: GLDraw_ReInit: Draw_SafePicFromWad\n")); TRACE(("dbg: GLDraw_ReInit: Draw_SafePicFromWad\n"));
draw_disc = Draw_SafePicFromWad ("disc"); draw_disc = Draw_SafePicFromWad ("disc");
#ifdef GL_USE8BITTEX
inited15to8 = false; inited15to8 = false;
#endif
qglClearColor (1,0,0,0); qglClearColor (1,0,0,0);
@ -449,6 +448,9 @@ void GLDraw_DeInit (void)
sizeofuploadmemorybuffer = 0; //and give a nice safe sys_error if we try using it. sizeofuploadmemorybuffer = 0; //and give a nice safe sys_error if we try using it.
sizeofuploadmemorybufferintermediate = 0; sizeofuploadmemorybufferintermediate = 0;
#ifdef RTLIGHTS
Sh_Shutdown();
#endif
Shader_Shutdown(); Shader_Shutdown();
} }
@ -490,7 +492,7 @@ void GLCrosshair_Callback(struct cvar_s *var, char *oldvalue)
} }
#undef Pix #undef Pix
R_Upload(cs_texture, NULL, TF_RGBA32, cs_data, 16, 16, IF_NOMIPMAP|IF_NOGAMMA); R_Upload(cs_texture, NULL, TF_RGBA32, cs_data, NULL, 16, 16, IF_NOMIPMAP|IF_NOGAMMA);
if (gl_smoothcrosshair.ival) if (gl_smoothcrosshair.ival)
{ {
@ -744,7 +746,7 @@ void GLDraw_FadeScreen (void)
if (!faderender) if (!faderender)
return; return;
#pragma message("Warning: This doesn't use the backend")
if (scenepp_mt_program && gl_menutint_shader.ival) if (scenepp_mt_program && gl_menutint_shader.ival)
{ {
float vwidth = 1, vheight = 1; float vwidth = 1, vheight = 1;
@ -858,8 +860,6 @@ Call before beginning any disc IO.
*/ */
void GLDraw_BeginDisc (void) void GLDraw_BeginDisc (void)
{ {
if (!draw_disc || !r_drawdisk.value)
return;
} }
@ -902,7 +902,7 @@ void GL_Set2D (void)
#if 0
void MediaGL_ShowFrame8bit(qbyte *framedata, int inwidth, int inheight, qbyte *palette) //bottom up void MediaGL_ShowFrame8bit(qbyte *framedata, int inwidth, int inheight, qbyte *palette) //bottom up
{ {
if (!TEXVALID(filmtexture)) if (!TEXVALID(filmtexture))
@ -1079,7 +1079,7 @@ void MediaGL_ShowFrameBGR_24_Flip(qbyte *framedata, int inwidth, int inheight)
if (scr_con_current) if (scr_con_current)
SCR_DrawConsole (false); SCR_DrawConsole (false);
} }
#endif
//==================================================================== //====================================================================
@ -1289,7 +1289,7 @@ void GL_ResampleTexture (unsigned *in, int inwidth, int inheight, unsigned *out,
unsigned *inrow; unsigned *inrow;
unsigned frac, fracstep; unsigned frac, fracstep;
if (gl_lerpimages.value) if (gl_lerpimages.ival)
{ {
Image_Resample32Lerp(in, inwidth, inheight, out, outwidth, outheight); Image_Resample32Lerp(in, inwidth, inheight, out, outwidth, outheight);
return; return;
@ -1611,8 +1611,6 @@ void GL_Upload32_Int (char *name, unsigned *data, int width, int height, unsigne
if (gl_config.arb_texture_compression && gl_compress.value && name && !(flags&IF_NOMIPMAP)) if (gl_config.arb_texture_compression && gl_compress.value && name && !(flags&IF_NOMIPMAP))
samples = (flags&IF_NOALPHA) ? GL_COMPRESSED_RGB_ARB : GL_COMPRESSED_RGBA_ARB; samples = (flags&IF_NOALPHA) ? GL_COMPRESSED_RGB_ARB : GL_COMPRESSED_RGBA_ARB;
texels += scaled_width * scaled_height;
if (gl_config.sgis_generate_mipmap && !(flags&IF_NOMIPMAP)) if (gl_config.sgis_generate_mipmap && !(flags&IF_NOMIPMAP))
{ {
TRACE(("dbg: GL_Upload32: GL_SGIS_generate_mipmap\n")); TRACE(("dbg: GL_Upload32: GL_SGIS_generate_mipmap\n"));
@ -1900,8 +1898,6 @@ void GL_Upload8Grey (unsigned char*data, int width, int height, unsigned int fla
samples = 1;//alpha ? gl_alpha_format : gl_solid_format; samples = 1;//alpha ? gl_alpha_format : gl_solid_format;
texels += scaled_width * scaled_height;
if (scaled_width == width && scaled_height == height) if (scaled_width == width && scaled_height == height)
{ {
if (flags&IF_NOMIPMAP) if (flags&IF_NOMIPMAP)
@ -2185,8 +2181,6 @@ void GL_Upload8_EXT (qbyte *data, int width, int height, qboolean mipmap, qbool
samples = 1; // alpha ? gl_alpha_format : gl_solid_format; samples = 1; // alpha ? gl_alpha_format : gl_solid_format;
texels += scaled_width * scaled_height;
if (scaled_width == width && scaled_height == height) if (scaled_width == width && scaled_height == height)
{ {
if (!mipmap) if (!mipmap)
@ -2457,7 +2451,7 @@ void GL_Upload8Pal24 (qbyte *data, qbyte *pal, int width, int height, unsigned i
} }
GL_Upload32 (NULL, (unsigned*)trans, width, height, flags); GL_Upload32 (NULL, (unsigned*)trans, width, height, flags);
} }
void GL_Upload8Pal32 (qbyte *data, qbyte *pal, int width, int height, unsigned int flags) static void GL_Upload8Pal32 (qbyte *data, qbyte *pal, int width, int height, unsigned int flags)
{ {
qbyte *trans = uploadmemorybufferintermediate; qbyte *trans = uploadmemorybufferintermediate;
int i, s; int i, s;

View file

@ -49,3 +49,5 @@ void R2D_Shutdown(void);
void R2D_PolyBlend (void); void R2D_PolyBlend (void);
void R2D_BrightenScreen (void); void R2D_BrightenScreen (void);
void R2D_Conback_Callback(struct cvar_s *var, char *oldvalue);

View file

@ -12,10 +12,12 @@ void Font_Shutdown(void);
struct font_s *Font_LoadFont(int height, char *fontfilename); struct font_s *Font_LoadFont(int height, char *fontfilename);
void Font_Free(struct font_s *f); void Font_Free(struct font_s *f);
void Font_BeginString(struct font_s *font, int vx, int vy, int *px, int *py); void Font_BeginString(struct font_s *font, int vx, int vy, int *px, int *py);
void Font_BeginScaledString(struct font_s *font, float vx, float vy, float *px, float *py); /*avoid using*/
int Font_CharHeight(void); int Font_CharHeight(void);
int Font_CharWidth(unsigned int charcode); int Font_CharWidth(unsigned int charcode);
int Font_CharEndCoord(int x, unsigned int charcode); int Font_CharEndCoord(int x, unsigned int charcode);
int Font_DrawChar(int px, int py, unsigned int charcode); int Font_DrawChar(int px, int py, unsigned int charcode);
float Font_DrawScaleChar(float px, float py, float cw, float ch, unsigned int charcode); /*avoid using*/
void Font_EndString(struct font_s *font); void Font_EndString(struct font_s *font);
int Font_LineBreaks(conchar_t *start, conchar_t *end, int maxpixelwidth, int maxlines, conchar_t **starts, conchar_t **ends); int Font_LineBreaks(conchar_t *start, conchar_t *end, int maxpixelwidth, int maxlines, conchar_t **starts, conchar_t **ends);
struct font_s *font_conchar; struct font_s *font_conchar;
@ -157,7 +159,6 @@ static const char *imgs[] =
#define GEN_CONCHAR_GLYPHS 0 //set to 0 or 1 to define whether to generate glyphs from conchars too, or if it should just draw them as glquake always used to #define GEN_CONCHAR_GLYPHS 0 //set to 0 or 1 to define whether to generate glyphs from conchars too, or if it should just draw them as glquake always used to
extern cvar_t cl_noblink; extern cvar_t cl_noblink;
extern cvar_t gl_smoothfont;
extern cvar_t con_ocranaleds; extern cvar_t con_ocranaleds;
typedef struct font_s typedef struct font_s
@ -278,7 +279,7 @@ static void Font_Flush(void)
if (fontplanes.planechanged) if (fontplanes.planechanged)
{ {
R_Upload(fontplanes.texnum[fontplanes.activeplane], NULL, TF_RGBA32, (void*)fontplanes.plane, PLANEWIDTH, PLANEHEIGHT, IF_NOPICMIP|IF_NOMIPMAP|IF_NOGAMMA); R_Upload(fontplanes.texnum[fontplanes.activeplane], NULL, TF_RGBA32, (void*)fontplanes.plane, NULL, PLANEWIDTH, PLANEHEIGHT, IF_NOPICMIP|IF_NOMIPMAP|IF_NOGAMMA);
fontplanes.planechanged = false; fontplanes.planechanged = false;
} }
@ -286,15 +287,15 @@ static void Font_Flush(void)
if (font_colourmask & CON_NONCLEARBG) if (font_colourmask & CON_NONCLEARBG)
{ {
fontplanes.backshader->defaulttextures.base = r_nulltex; fontplanes.backshader->defaulttextures.base = r_nulltex;
BE_DrawMeshChain(fontplanes.backshader, &font_mesh, NULL, &fontplanes.backshader->defaulttextures); BE_DrawMesh_Single(fontplanes.backshader, &font_mesh, NULL, &fontplanes.backshader->defaulttextures);
fontplanes.shader->defaulttextures.base = font_texture; fontplanes.shader->defaulttextures.base = font_texture;
BE_DrawMeshChain(fontplanes.shader, &font_mesh, NULL, &fontplanes.shader->defaulttextures); BE_DrawMesh_Single(fontplanes.shader, &font_mesh, NULL, &fontplanes.shader->defaulttextures);
} }
else else
{ {
fontplanes.shader->defaulttextures.base = font_texture; fontplanes.shader->defaulttextures.base = font_texture;
BE_DrawMeshChain(fontplanes.shader, &font_mesh, NULL, &fontplanes.shader->defaulttextures); BE_DrawMesh_Single(fontplanes.shader, &font_mesh, NULL, &fontplanes.shader->defaulttextures);
} }
font_mesh.numindexes = 0; font_mesh.numindexes = 0;
@ -448,13 +449,14 @@ static struct charcache_s *Font_TryLoadGlyph(font_t *f, CHARIDXTYPE charidx)
struct charcache_s *c; struct charcache_s *c;
#if GEN_CONCHAR_GLYPHS != 0 #if GEN_CONCHAR_GLYPHS != 0
if (charidx >= 0xe000 && charidx <= 0xe0ff && draw_chars) if (charidx >= 0xe000 && charidx <= 0xe0ff)
{ {
int cpos = charidx & 0xff; int cpos = charidx & 0xff;
unsigned int img[64*64], *d; unsigned int img[64*64], *d;
unsigned char *s; unsigned char *s;
int scale; int scale;
int x,y, ys; int x,y, ys;
qbyte *draw_chars = W_GetLumpName("conchars");
if (draw_chars) if (draw_chars)
{ {
d = img; d = img;
@ -881,6 +883,12 @@ void Font_BeginString(struct font_s *font, int vx, int vy, int *px, int *py)
*px = (vx*vid.pixelwidth) / (float)vid.width; *px = (vx*vid.pixelwidth) / (float)vid.width;
*py = (vy*vid.pixelheight) / (float)vid.height; *py = (vy*vid.pixelheight) / (float)vid.height;
} }
void Font_BeginScaledString(struct font_s *font, float vx, float vy, float *px, float *py)
{
curfont = font;
*px = (vx*vid.pixelwidth) / (float)vid.width;
*py = (vy*vid.pixelheight) / (float)vid.height;
}
void Font_EndString(struct font_s *font) void Font_EndString(struct font_s *font)
{ {
@ -1098,8 +1106,8 @@ int Font_DrawChar(int px, int py, unsigned int charcode)
{ {
sx = ((px+c->left)*(int)vid.width) / (float)vid.pixelwidth; sx = ((px+c->left)*(int)vid.width) / (float)vid.pixelwidth;
sy = ((py+c->top)*(int)vid.height) / (float)vid.pixelheight; sy = ((py+c->top)*(int)vid.height) / (float)vid.pixelheight;
sw = ((c->bmw+1)*vid.width) / (float)vid.pixelwidth; sw = ((c->bmw)*vid.width) / (float)vid.pixelwidth;
sh = ((c->bmh+1)*vid.height) / (float)vid.pixelheight; sh = ((c->bmh)*vid.height) / (float)vid.pixelheight;
v = Font_BeginChar(fontplanes.texnum[c->texplane]); v = Font_BeginChar(fontplanes.texnum[c->texplane]);
} }
@ -1123,4 +1131,107 @@ int Font_DrawChar(int px, int py, unsigned int charcode)
return nextx; return nextx;
} }
/*there is no sane way to make this pixel-correct*/
float Font_DrawScaleChar(float px, float py, float cw, float ch, unsigned int charcode)
{
struct charcache_s *c;
float s0, s1;
float t0, t1;
float nextx;
float sx, sy, sw, sh;
int col;
int v;
cw /= curfont->charheight;
ch /= curfont->charheight;
//crash if there is no current font.
c = Font_GetChar(curfont, (CHARIDXTYPE)(charcode&CON_CHARMASK));
if (!c)
{
c = Font_TryLoadGlyph(curfont, (CHARIDXTYPE)(charcode&CON_CHARMASK));
if (!c)
return px;
}
nextx = px + c->advance*cw;
if ((charcode & CON_CHARMASK) == ' ')
return nextx;
if (charcode & CON_BLINKTEXT)
{
if (!cl_noblink.ival)
if ((int)(realtime*3) & 1)
return nextx;
}
col = charcode & (CON_NONCLEARBG|CON_BGMASK|CON_FGMASK|CON_HALFALPHA);
if (col != font_colourmask)
{
Font_Flush();
font_colourmask = col;
col = (charcode&CON_FGMASK)>>CON_FGSHIFT;
fontplanes.shader->passes[0].rgbgen_func.args[0] = consolecolours[col].fr;
fontplanes.shader->passes[0].rgbgen_func.args[1] = consolecolours[col].fg;
fontplanes.shader->passes[0].rgbgen_func.args[2] = consolecolours[col].fb;
fontplanes.shader->passes[0].alphagen_func.args[0] = (charcode & CON_HALFALPHA)?0.5:1;
col = (charcode&CON_BGMASK)>>CON_BGSHIFT;
fontplanes.backshader->passes[0].rgbgen_func.args[0] = consolecolours[col].fr;
fontplanes.backshader->passes[0].rgbgen_func.args[1] = consolecolours[col].fg;
fontplanes.backshader->passes[0].rgbgen_func.args[2] = consolecolours[col].fb;
fontplanes.backshader->passes[0].alphagen_func.args[0] = (charcode & CON_NONCLEARBG)?0.5:0;
}
s0 = (float)c->bmx/PLANEWIDTH;
t0 = (float)c->bmy/PLANEWIDTH;
s1 = (float)(c->bmx+c->bmw)/PLANEWIDTH;
t1 = (float)(c->bmy+c->bmh)/PLANEWIDTH;
if (c->texplane >= DEFAULTPLANE)
{
sx = ((px+c->left)*(int)vid.width) / (float)vid.pixelwidth;
sy = ((py+c->top)*(int)vid.height) / (float)vid.pixelheight;
sw = ((curfont->charheight*cw)*vid.width) / (float)vid.pixelwidth;
sh = ((curfont->charheight*ch)*vid.height) / (float)vid.pixelheight;
if (c->texplane == DEFAULTPLANE)
v = Font_BeginChar(fontplanes.defaultfont);
else
v = Font_BeginChar(curfont->singletexture);
}
else
{
sx = ((px+c->left)*(int)vid.width) / (float)vid.pixelwidth;
sy = ((py+c->top)*(int)vid.height) / (float)vid.pixelheight;
sw = ((c->bmw*cw)*vid.width) / (float)vid.pixelwidth;
sh = ((c->bmh*ch)*vid.height) / (float)vid.pixelheight;
v = Font_BeginChar(fontplanes.texnum[c->texplane]);
}
font_texcoord[v+0][0] = s0;
font_texcoord[v+0][1] = t0;
font_texcoord[v+1][0] = s1;
font_texcoord[v+1][1] = t0;
font_texcoord[v+2][0] = s1;
font_texcoord[v+2][1] = t1;
font_texcoord[v+3][0] = s0;
font_texcoord[v+3][1] = t1;
font_coord[v+0][0] = sx;
font_coord[v+0][1] = sy;
font_coord[v+1][0] = sx+sw;
font_coord[v+1][1] = sy;
font_coord[v+2][0] = sx+sw;
font_coord[v+2][1] = sy+sh;
font_coord[v+3][0] = sx;
font_coord[v+3][1] = sy+sh;
return nextx;
}
#endif //!SERVERONLY #endif //!SERVERONLY

View file

@ -587,12 +587,12 @@ unsigned int Heightmap_FatPVS (model_t *mod, vec3_t org, qbyte *pvsbuffer, unsi
} }
#ifndef CLIENTONLY #ifndef CLIENTONLY
qboolean Heightmap_EdictInFatPVS (model_t *mod, wedict_t *edict, qbyte *pvsdata) qboolean Heightmap_EdictInFatPVS (model_t *mod, struct pvscache_s *edict, qbyte *pvsdata)
{ {
return true; return true;
} }
void Heightmap_FindTouchedLeafs (world_t *w, model_t *mod, wedict_t *ent, float *mins, float *maxs) void Heightmap_FindTouchedLeafs (model_t *mod, pvscache_t *ent, float *mins, float *maxs)
{ {
} }
#endif #endif
@ -790,7 +790,7 @@ qboolean GL_LoadHeightmapModel (model_t *mod, void *buffer)
mod->funcs.LeafPVS = Heightmap_LeafnumPVS; mod->funcs.LeafPVS = Heightmap_LeafnumPVS;
#ifndef CLIENTONLY #ifndef CLIENTONLY
mod->funcs.FindTouchedLeafs_Q1 = Heightmap_FindTouchedLeafs; mod->funcs.FindTouchedLeafs = Heightmap_FindTouchedLeafs;
mod->funcs.EdictInFatPVS = Heightmap_EdictInFatPVS; mod->funcs.EdictInFatPVS = Heightmap_EdictInFatPVS;
mod->funcs.FatPVS = Heightmap_FatPVS; mod->funcs.FatPVS = Heightmap_FatPVS;
#endif #endif

View file

@ -67,7 +67,8 @@ extern cvar_t r_loadlits;
extern cvar_t gl_specular; extern cvar_t gl_specular;
#endif #endif
extern cvar_t r_fb_bmodels; extern cvar_t r_fb_bmodels;
mesh_t nullmesh;
void Mod_SortShaders(void);
#ifdef RUNTIMELIGHTING #ifdef RUNTIMELIGHTING
model_t *lightmodel; model_t *lightmodel;
@ -152,7 +153,7 @@ void RMod_BlockTextureColour_f (void)
{ {
memset(&tn, 0, sizeof(tn)); memset(&tn, 0, sizeof(tn));
tn.base = R_LoadTexture32(texname, 8, 8, colour, IF_NOALPHA|IF_NOGAMMA); tn.base = R_LoadTexture32(texname, 8, 8, colour, IF_NOALPHA|IF_NOGAMMA);
s = R_RegisterCustom (texname, Shader_DefaultBSP, NULL); s = R_RegisterCustom (texname, Shader_DefaultBSPQ1, NULL);
} }
for (i = 0; i < sizeof(colour)/sizeof(colour[0]); i++) for (i = 0; i < sizeof(colour)/sizeof(colour[0]); i++)
@ -923,16 +924,16 @@ void Mod_FinishTexture(texture_t *tx, texnums_t tn)
char *star; char *star;
//find the * //find the *
if (!*gl_shadeq1_name.string || !strcmp(gl_shadeq1_name.string, "*")) if (!*gl_shadeq1_name.string || !strcmp(gl_shadeq1_name.string, "*"))
tx->shader = R_RegisterShader_Lightmap(tx->name); //just load the regular name. tx->shader = R_RegisterCustom (tx->name, Shader_DefaultBSPQ1, NULL); //just load the regular name.
else if (!(star = strchr(gl_shadeq1_name.string, '*')) || (strlen(gl_shadeq1_name.string)+strlen(tx->name)+1>=sizeof(altname))) //it's got to fit. else if (!(star = strchr(gl_shadeq1_name.string, '*')) || (strlen(gl_shadeq1_name.string)+strlen(tx->name)+1>=sizeof(altname))) //it's got to fit.
tx->shader = R_RegisterShader_Lightmap(gl_shadeq1_name.string); tx->shader = R_RegisterCustom (gl_shadeq1_name.string, Shader_DefaultBSPQ1, NULL);
else else
{ {
strncpy(altname, gl_shadeq1_name.string, star-gl_shadeq1_name.string); //copy the left strncpy(altname, gl_shadeq1_name.string, star-gl_shadeq1_name.string); //copy the left
altname[star-gl_shadeq1_name.string] = '\0'; altname[star-gl_shadeq1_name.string] = '\0';
strcat(altname, tx->name); //insert the * strcat(altname, tx->name); //insert the *
strcat(altname, star+1); //add any final text. strcat(altname, star+1); //add any final text.
tx->shader = R_RegisterShader_Lightmap(altname); tx->shader = R_RegisterCustom (altname, Shader_DefaultBSPQ1, NULL);
} }
R_BuildDefaultTexnums(&tn, tx->shader); R_BuildDefaultTexnums(&tn, tx->shader);
@ -1996,7 +1997,6 @@ qboolean RMod_LoadFaces (lump_t *l)
}*/ }*/
if (!Q_strncmp(out->texinfo->texture->name,"{",1)) // alpha if (!Q_strncmp(out->texinfo->texture->name,"{",1)) // alpha
{ {
out->texinfo->flags |= TI_ALPHATEST;
out->flags |= (SURF_DRAWALPHA); out->flags |= (SURF_DRAWALPHA);
continue; continue;
} }
@ -2124,7 +2124,6 @@ qboolean RMod_LoadLeafs (lump_t *l)
out->compressed_vis = NULL; out->compressed_vis = NULL;
else else
out->compressed_vis = loadmodel->visdata + p; out->compressed_vis = loadmodel->visdata + p;
out->efrags = NULL;
for (j=0 ; j<4 ; j++) for (j=0 ; j<4 ; j++)
out->ambient_sound_level[j] = in->ambient_level[j]; out->ambient_sound_level[j] = in->ambient_level[j];
@ -2915,6 +2914,9 @@ qboolean RMod_LoadBrushModel (model_t *mod, void *buffer)
RMod_MakeHull0 (); RMod_MakeHull0 ();
} }
if (!isDedicated && noerrors)
Mod_SortShaders();
if (crouchhullfile) if (crouchhullfile)
{ {
FS_FreeFile(crouchhullfile); FS_FreeFile(crouchhullfile);

View file

@ -49,8 +49,8 @@ typedef struct {
unsigned int (*NativeContents)(struct model_s *model, int hulloverride, int frame, vec3_t p, vec3_t mins, vec3_t maxs); unsigned int (*NativeContents)(struct model_s *model, int hulloverride, int frame, vec3_t p, vec3_t mins, vec3_t maxs);
unsigned int (*FatPVS) (struct model_s *model, vec3_t org, qbyte *pvsbuffer, unsigned int buffersize, qboolean merge); unsigned int (*FatPVS) (struct model_s *model, vec3_t org, qbyte *pvsbuffer, unsigned int buffersize, qboolean merge);
qboolean (*EdictInFatPVS) (struct model_s *model, struct wedict_s *edict, qbyte *pvsbuffer); qboolean (*EdictInFatPVS) (struct model_s *model, struct pvscache_s *edict, qbyte *pvsbuffer);
void (*FindTouchedLeafs_Q1) (struct world_s *w, struct model_s *model, struct wedict_s *ent, vec3_t cullmins, vec3_t cullmaxs); //edict system as opposed to q2 game dll system. void (*FindTouchedLeafs) (struct model_s *model, struct pvscache_s *ent, vec3_t cullmins, vec3_t cullmaxs); //edict system as opposed to q2 game dll system.
void (*LightPointValues) (struct model_s *model, vec3_t point, vec3_t res_diffuse, vec3_t res_ambient, vec3_t res_dir); void (*LightPointValues) (struct model_s *model, vec3_t point, vec3_t res_diffuse, vec3_t res_ambient, vec3_t res_dir);
void (*StainNode) (struct mnode_s *node, float *parms); void (*StainNode) (struct mnode_s *node, float *parms);
@ -62,41 +62,49 @@ typedef struct {
typedef struct mesh_s typedef struct mesh_s
{ {
int numvertexes;
int numindexes;
/*position within its vbo*/
unsigned int vbofirstvert; unsigned int vbofirstvert;
unsigned int vbofirstelement; unsigned int vbofirstelement;
/*arrays used for rendering*/
int numvertexes;
vecV_t *xyz_array; vecV_t *xyz_array;
vec3_t *normals_array; vec3_t *normals_array; /*required for lighting*/
vec3_t *snormals_array; vec3_t *snormals_array;/*required for rtlighting*/
vec3_t *tnormals_array; vec3_t *tnormals_array;/*required for rtlighting*/
vec2_t *st_array; vec2_t *st_array; /*texture coords*/
vec2_t *lmst_array; vec2_t *lmst_array; /*second texturecoord set (merely dubbed lightmap)*/
avec4_t *colors4f_array; avec4_t *colors4f_array;/*floating point colours array*/
byte_vec4_t *colors4b_array; byte_vec4_t *colors4b_array;/*byte colours array*/
int numindexes;
index_t *indexes; index_t *indexes;
//required for shadow volumes
int *trneighbors; int *trneighbors;
vec3_t *trnormals; vec3_t *trnormals;
vec3_t mins, maxs; qboolean istrifan; /*if its a fan/poly/single quad (permits optimisations)*/
float radius;
qboolean istrifan; /*if its a fan/poly/single quad*/
struct mesh_s *next;
} mesh_t; } mesh_t;
FTE_DEPRECATED struct meshbuffer_s; extern mesh_t nullmesh;
void FTE_DEPRECATED R_PushMesh ( mesh_t *mesh, int features );
void FTE_DEPRECATED R_RenderMeshBuffer ( struct meshbuffer_s *mb, qboolean shadowpass );
qboolean FTE_DEPRECATED R_MeshWillExceed(mesh_t *mesh);
extern int gl_canbumpmap; extern int gl_canbumpmap;
typedef struct batch_s
{
mesh_t **mesh; /*list must be long enough for all surfaces that will form part of this batch times two, for mirrors/portals*/
unsigned int firstmesh;
unsigned int meshes;
struct batch_s *next;
shader_t *shader;
struct texture_s *texture;
struct vbo_s *vbo;
int lightmap;
unsigned int maxmeshes;
vec3_t normal;
} batch_t;
/* /*
d*_t structures are on-disk representations d*_t structures are on-disk representations
@ -166,8 +174,11 @@ typedef struct {
struct shader_s *shader; //fixme: remove... struct shader_s *shader; //fixme: remove...
} texnums_t; } texnums_t;
typedef struct typedef struct vbo_s
{ {
int numvisible;
struct msurface_s **vislist;
int meshcount; int meshcount;
struct msurface_s **meshlist; struct msurface_s **meshlist;
@ -205,11 +216,10 @@ typedef struct texture_s
int parttype; int parttype;
struct shader_s *shader; struct shader_s *shader;
int wtexno;
vbo_t vbo; vbo_t vbo;
struct msurface_s *texturechain; // for gl_texsort drawing
struct msurface_s **texturechain_tail; //so we can link them in depth order
int anim_total; // total tenths in sequence ( 0 = no) int anim_total; // total tenths in sequence ( 0 = no)
int anim_min, anim_max; // time for this frame min <=time< max int anim_min, anim_max; // time for this frame min <=time< max
struct texture_s *anim_next; // in the animation sequence struct texture_s *anim_next; // in the animation sequence
@ -295,8 +305,6 @@ typedef struct msurface_s
int firstedge; // look up in model->surfedges[], negative numbers int firstedge; // look up in model->surfedges[], negative numbers
int numedges; // are backwards edges int numedges; // are backwards edges
struct msurface_s *nextalphasurface;
short texturemins[2]; short texturemins[2];
short extents[2]; short extents[2];
@ -306,7 +314,7 @@ typedef struct msurface_s
mesh_t *mesh; mesh_t *mesh;
entity_t *ownerent; entity_t *ownerent;
struct msurface_s *texturechain; batch_t *sbatch;
mtexinfo_t *texinfo; mtexinfo_t *texinfo;
struct msurface_s **mark; struct msurface_s **mark;
int visframe; // should be drawn when node is crossed int visframe; // should be drawn when node is crossed
@ -369,7 +377,6 @@ typedef struct mleaf_s
// leaf specific // leaf specific
qbyte *compressed_vis; qbyte *compressed_vis;
struct efrag_s *efrags;
msurface_t **firstmarksurface; msurface_t **firstmarksurface;
int nummarksurfaces; int nummarksurfaces;
@ -429,12 +436,11 @@ int Q1BSP_ClipDecal(vec3_t center, vec3_t normal, vec3_t tangent1, vec3_t tangen
qboolean Q1BSP_Trace(struct model_s *model, int forcehullnum, int frame, vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs, struct trace_s *trace); qboolean Q1BSP_Trace(struct model_s *model, int forcehullnum, int frame, vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs, struct trace_s *trace);
qboolean Q1BSP_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, vec3_t p1, vec3_t p2, struct trace_s *trace); qboolean Q1BSP_RecursiveHullCheck (hull_t *hull, int num, float p1f, float p2f, vec3_t p1, vec3_t p2, struct trace_s *trace);
unsigned int Q1BSP_FatPVS (struct model_s *mod, vec3_t org, qbyte *pvsbuffer, unsigned int buffersize, qboolean add); unsigned int Q1BSP_FatPVS (struct model_s *mod, vec3_t org, qbyte *pvsbuffer, unsigned int buffersize, qboolean add);
qboolean Q1BSP_EdictInFatPVS(struct model_s *mod, struct wedict_s *ent, qbyte *pvs); qboolean Q1BSP_EdictInFatPVS(struct model_s *mod, struct pvscache_s *ent, qbyte *pvs);
void Q1BSP_FindTouchedLeafs(struct world_s *w, struct model_s *mod, struct wedict_s *ent, float *mins, float *maxs); void Q1BSP_FindTouchedLeafs(struct model_s *mod, struct pvscache_s *ent, float *mins, float *maxs);
qbyte *Q1BSP_LeafPVS (struct model_s *model, mleaf_t *leaf, qbyte *buffer, unsigned int buffersize); qbyte *Q1BSP_LeafPVS (struct model_s *model, mleaf_t *leaf, qbyte *buffer, unsigned int buffersize);
texnums_t R_InitSky (struct texture_s *mt);
FTE_DEPRECATED texnums_t R_InitSky (struct texture_s *mt);
/* /*
============================================================================== ==============================================================================
@ -830,6 +836,7 @@ typedef struct model_s
char *entities; char *entities;
void *terrain; void *terrain;
batch_t *batches;
unsigned checksum; unsigned checksum;
unsigned checksum2; unsigned checksum2;

View file

@ -166,6 +166,7 @@ void R_RenderDlight (dlight_t *light)
bub_sin = bubble_sintable; bub_sin = bubble_sintable;
bub_cos = bubble_costable; bub_cos = bubble_costable;
rad = light->radius * 0.35; rad = light->radius * 0.35;
rad = 16;
VectorCopy(light->color, colour); VectorCopy(light->color, colour);
@ -202,7 +203,7 @@ void R_RenderDlight (dlight_t *light)
bub_cos++; bub_cos++;
} }
BE_DrawMeshChain(flashblend_shader, &flashblend_mesh, NULL, &flashblend_shader->defaulttextures); BE_DrawMesh_Single(flashblend_shader, &flashblend_mesh, NULL, &flashblend_shader->defaulttextures);
} }
/* /*

File diff suppressed because it is too large Load diff

View file

@ -67,74 +67,6 @@ void GLR_InitTextures (void)
} }
}*/ }*/
/*
===============
R_Envmap_f
Grab six views for environment mapping tests
===============
*/
void R_Envmap_f (void)
{
qbyte buffer[256*256*4];
qglDrawBuffer (GL_FRONT);
qglReadBuffer (GL_FRONT);
envmap = true;
r_refdef.vrect.x = 0;
r_refdef.vrect.y = 0;
r_refdef.vrect.width = 256;
r_refdef.vrect.height = 256;
r_refdef.viewangles[0] = 0;
r_refdef.viewangles[1] = 0;
r_refdef.viewangles[2] = 0;
GL_BeginRendering ();
R_RenderView ();
qglReadPixels (0, 0, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
COM_WriteFile ("env0.rgb", buffer, sizeof(buffer));
r_refdef.viewangles[1] = 90;
GL_BeginRendering ();
R_RenderView ();
qglReadPixels (0, 0, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
COM_WriteFile ("env1.rgb", buffer, sizeof(buffer));
r_refdef.viewangles[1] = 180;
GL_BeginRendering ();
R_RenderView ();
qglReadPixels (0, 0, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
COM_WriteFile ("env2.rgb", buffer, sizeof(buffer));
r_refdef.viewangles[1] = 270;
GL_BeginRendering ();
R_RenderView ();
qglReadPixels (0, 0, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
COM_WriteFile ("env3.rgb", buffer, sizeof(buffer));
r_refdef.viewangles[0] = -90;
r_refdef.viewangles[1] = 0;
GL_BeginRendering ();
R_RenderView ();
qglReadPixels (0, 0, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
COM_WriteFile ("env4.rgb", buffer, sizeof(buffer));
r_refdef.viewangles[0] = 90;
r_refdef.viewangles[1] = 0;
GL_BeginRendering ();
R_RenderView ();
qglReadPixels (0, 0, 256, 256, GL_RGBA, GL_UNSIGNED_BYTE, buffer);
COM_WriteFile ("env5.rgb", buffer, sizeof(buffer));
envmap = false;
qglDrawBuffer (GL_BACK);
qglReadBuffer (GL_BACK);
GL_EndRendering ();
GL_DoSwap();
}
@ -522,7 +454,7 @@ extern cvar_t gl_bump, v_contrast, r_drawflat;
extern cvar_t r_stains, r_stainfadetime, r_stainfadeammount; extern cvar_t r_stains, r_stainfadetime, r_stainfadeammount;
// callback defines // callback defines
extern cvar_t gl_conback, gl_font, gl_smoothfont, gl_fontinwardstep, r_menutint; extern cvar_t gl_font, r_menutint;
extern cvar_t vid_conautoscale, vid_conheight, vid_conwidth; extern cvar_t vid_conautoscale, vid_conheight, vid_conwidth;
extern cvar_t crosshair, crosshairimage, crosshaircolor, r_skyboxname; extern cvar_t crosshair, crosshairimage, crosshaircolor, r_skyboxname;
extern cvar_t r_floorcolour, r_wallcolour, r_floortexture, r_walltexture; extern cvar_t r_floorcolour, r_wallcolour, r_floortexture, r_walltexture;
@ -531,10 +463,6 @@ void GLCrosshairimage_Callback(struct cvar_s *var, char *oldvalue);
void GLCrosshair_Callback(struct cvar_s *var, char *oldvalue); void GLCrosshair_Callback(struct cvar_s *var, char *oldvalue);
void GLCrosshaircolor_Callback(struct cvar_s *var, char *oldvalue); void GLCrosshaircolor_Callback(struct cvar_s *var, char *oldvalue);
void GLR_Menutint_Callback (struct cvar_s *var, char *oldvalue); void GLR_Menutint_Callback (struct cvar_s *var, char *oldvalue);
void GL_Conback_Callback (struct cvar_s *var, char *oldvalue);
void GL_Font_Callback (struct cvar_s *var, char *oldvalue);
void GL_Smoothfont_Callback (struct cvar_s *var, char *oldvalue);
void GL_Fontinwardstep_Callback (struct cvar_s *var, char *oldvalue);
void GLVID_Conwidth_Callback(struct cvar_s *var, char *oldvalue); void GLVID_Conwidth_Callback(struct cvar_s *var, char *oldvalue);
void GLVID_Conautoscale_Callback(struct cvar_s *var, char *oldvalue); void GLVID_Conautoscale_Callback(struct cvar_s *var, char *oldvalue);
void GLVID_Conheight_Callback(struct cvar_s *var, char *oldvalue); void GLVID_Conheight_Callback(struct cvar_s *var, char *oldvalue);
@ -554,10 +482,7 @@ void GLR_DeInit (void)
Cvar_Unhook(&crosshaircolor); Cvar_Unhook(&crosshaircolor);
Cvar_Unhook(&r_skyboxname); Cvar_Unhook(&r_skyboxname);
Cvar_Unhook(&r_menutint); Cvar_Unhook(&r_menutint);
Cvar_Unhook(&gl_conback);
Cvar_Unhook(&gl_font); Cvar_Unhook(&gl_font);
Cvar_Unhook(&gl_smoothfont);
Cvar_Unhook(&gl_fontinwardstep);
Cvar_Unhook(&vid_conautoscale); Cvar_Unhook(&vid_conautoscale);
Cvar_Unhook(&vid_conheight); Cvar_Unhook(&vid_conheight);
Cvar_Unhook(&vid_conwidth); Cvar_Unhook(&vid_conwidth);
@ -578,7 +503,6 @@ void GLR_DeInit (void)
void GLR_Init (void) void GLR_Init (void)
{ {
Cmd_AddRemCommand ("timerefresh", GLR_TimeRefresh_f); Cmd_AddRemCommand ("timerefresh", GLR_TimeRefresh_f);
Cmd_AddRemCommand ("envmap", R_Envmap_f);
#ifdef RTLIGHTS #ifdef RTLIGHTS
Cmd_AddRemCommand ("r_editlights_reload", R_ReloadRTLights_f); Cmd_AddRemCommand ("r_editlights_reload", R_ReloadRTLights_f);
Cmd_AddRemCommand ("r_editlights_save", R_SaveRTLights_f); Cmd_AddRemCommand ("r_editlights_save", R_SaveRTLights_f);
@ -590,11 +514,6 @@ void GLR_Init (void)
Cvar_Hook(&crosshairimage, GLCrosshairimage_Callback); Cvar_Hook(&crosshairimage, GLCrosshairimage_Callback);
Cvar_Hook(&crosshaircolor, GLCrosshaircolor_Callback); Cvar_Hook(&crosshaircolor, GLCrosshaircolor_Callback);
Cvar_Hook(&r_menutint, GLR_Menutint_Callback); Cvar_Hook(&r_menutint, GLR_Menutint_Callback);
Cvar_ForceCallback(&gl_conback);
Cvar_Hook(&gl_conback, GL_Conback_Callback);
Cvar_Hook(&gl_font, GL_Font_Callback);
Cvar_Hook(&gl_smoothfont, GL_Smoothfont_Callback);
Cvar_Hook(&gl_fontinwardstep, GL_Fontinwardstep_Callback);
Cvar_Hook(&vid_conautoscale, GLVID_Conautoscale_Callback); Cvar_Hook(&vid_conautoscale, GLVID_Conautoscale_Callback);
Cvar_Hook(&vid_conheight, GLVID_Conheight_Callback); Cvar_Hook(&vid_conheight, GLVID_Conheight_Callback);
Cvar_Hook(&vid_conwidth, GLVID_Conwidth_Callback); Cvar_Hook(&vid_conwidth, GLVID_Conwidth_Callback);
@ -840,6 +759,7 @@ static void R_LoadRTLights(void)
{ {
dlight_t *dl; dlight_t *dl;
char fname[MAX_QPATH]; char fname[MAX_QPATH];
char cubename[MAX_QPATH];
char *file; char *file;
char *end; char *end;
int style; int style;
@ -876,11 +796,6 @@ static void R_LoadRTLights(void)
flags = LFLAG_NOSHADOWS; flags = LFLAG_NOSHADOWS;
file++; file++;
} }
else if (*file == '#')
{
flags = LFLAG_SHADOWMAP;
file++;
}
else else
flags = 0; flags = 0;
@ -906,6 +821,7 @@ static void R_LoadRTLights(void)
file = COM_Parse(file); file = COM_Parse(file);
//cubemap //cubemap
Q_strncpyz(cubename, com_token, sizeof(cubename));
file = COM_Parse(file); file = COM_Parse(file);
//corona //corona
@ -946,6 +862,11 @@ static void R_LoadRTLights(void)
VectorCopy(rgb, dl->color); VectorCopy(rgb, dl->color);
dl->die = 0; dl->die = 0;
dl->flags = flags|LFLAG_ALLOW_PPL; dl->flags = flags|LFLAG_ALLOW_PPL;
if (*cubename)
{
dl->fov = 90;
dl->flags |= LFLAG_SHADOWMAP;
}
AngleVectors(angles, dl->axis[0], dl->axis[1], dl->axis[2]); AngleVectors(angles, dl->axis[0], dl->axis[1], dl->axis[2]);
dl->style = style+1; dl->style = style+1;
@ -1029,19 +950,6 @@ void GLR_NewMap (void)
char namebuf[MAX_QPATH]; char namebuf[MAX_QPATH];
extern cvar_t host_mapname, r_shadow_realtime_dlight, r_shadow_realtime_world; extern cvar_t host_mapname, r_shadow_realtime_dlight, r_shadow_realtime_world;
int i; int i;
/*
if (cl.worldmodel->fromgame == fg_quake3 && cls.netchan.remote_address.type != NA_LOOPBACK)
{
if (!cls.allow_cheats)
{
CL_Disconnect();
Host_EndGame("\n\nThe quake3 map implementation is still experimental and contains many bugs that could be considered cheats. Therefore, the engine is handicapped to quake3 maps only when hosting - it's single player only.\n\nYou can allow it on the server by activating cheats, at which point this check will be ignored\n");
return;
}
// Cbuf_AddText("disconnect\n", RESTRICT_LOCAL);
}
*/
for (i=0 ; i<256 ; i++) for (i=0 ; i<256 ; i++)
d_lightstylevalue[i] = 264; // normal light value d_lightstylevalue[i] = 264; // normal light value
@ -1055,11 +963,6 @@ void GLR_NewMap (void)
COM_StripExtension(COM_SkipPath(cl.worldmodel->name), namebuf, sizeof(namebuf)); COM_StripExtension(COM_SkipPath(cl.worldmodel->name), namebuf, sizeof(namebuf));
Cvar_Set(&host_mapname, namebuf); Cvar_Set(&host_mapname, namebuf);
// clear out efrags in case the level hasn't been reloaded
// FIXME: is this one short?
for (i=0 ; i<cl.worldmodel->numleafs ; i++)
cl.worldmodel->leafs[i].efrags = NULL;
Surf_DeInit(); Surf_DeInit();
r_viewleaf = NULL; r_viewleaf = NULL;
@ -1072,20 +975,6 @@ TRACE(("dbg: GLR_NewMap: wiping them stains (getting the cloth out)\n"));
Surf_WipeStains(); Surf_WipeStains();
TRACE(("dbg: GLR_NewMap: building lightmaps\n")); TRACE(("dbg: GLR_NewMap: building lightmaps\n"));
Surf_BuildLightmaps (); Surf_BuildLightmaps ();
TRACE(("dbg: GLR_NewMap: figuring out skys and mirrors\n"));
// identify sky texture
if (cl.worldmodel->fromgame != fg_quake2 && cl.worldmodel->fromgame != fg_quake3)
{
mirrortexturenum = -1;
}
for (i=0 ; i<cl.worldmodel->numtextures ; i++)
{
if (!cl.worldmodel->textures[i])
continue;
if (!Q_strncmp(cl.worldmodel->textures[i]->name,"window02_1",10) )
mirrortexturenum = i;
cl.worldmodel->textures[i]->texturechain = NULL;
}
TRACE(("dbg: GLR_NewMap: ui\n")); TRACE(("dbg: GLR_NewMap: ui\n"));
#ifdef VM_UI #ifdef VM_UI
@ -1093,9 +982,10 @@ TRACE(("dbg: GLR_NewMap: ui\n"));
#endif #endif
TRACE(("dbg: GLR_NewMap: tp\n")); TRACE(("dbg: GLR_NewMap: tp\n"));
TP_NewMap(); TP_NewMap();
R_SetSky(cl.skyname);
#ifdef RTLIGHTS #ifdef RTLIGHTS
if (r_shadow_realtime_dlight.value || r_shadow_realtime_world.value) if (r_shadow_realtime_dlight.ival || r_shadow_realtime_world.ival)
{ {
R_LoadRTLights(); R_LoadRTLights();
if (rtlights_first == rtlights_max) if (rtlights_first == rtlights_max)

View file

@ -266,11 +266,11 @@ void BE_GenBrushModelVBO(model_t *mod)
BZ_Free(vboedata); BZ_Free(vboedata);
} }
} }
for (i=0 ; i<mod->numsurfaces ; i++) /* for (i=0 ; i<mod->numsurfaces ; i++)
{ {
if (!mod->surfaces[i].mark) if (!mod->surfaces[i].mark)
Host_EndGame("Surfaces with bad textures detected\n"); Host_EndGame("Surfaces with bad textures detected\n");
} }*/
} }
void BE_UploadAllLightmaps(void) void BE_UploadAllLightmaps(void)
@ -294,8 +294,8 @@ void BE_UploadAllLightmaps(void)
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
qglTexImage2D (GL_TEXTURE_2D, 0, lightmap_bytes qglTexImage2D (GL_TEXTURE_2D, 0, lightmap_bytes
, LMBLOCK_WIDTH, LMBLOCK_HEIGHT, 0, , LMBLOCK_WIDTH, LMBLOCK_HEIGHT, 0,
((lightmap_bytes==3)?GL_RGB:GL_LUMINANCE), GL_UNSIGNED_BYTE, lightmap[i]->lightmaps); ((lightmap_bytes==3)?GL_RGB:GL_LUMINANCE), GL_UNSIGNED_BYTE, lightmap[i]->lightmaps);
if (gl_bump.ival) if (gl_bump.ival)
{ {
@ -308,8 +308,8 @@ void BE_UploadAllLightmaps(void)
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
qglTexImage2D (GL_TEXTURE_2D, 0, 3 qglTexImage2D (GL_TEXTURE_2D, 0, 3
, LMBLOCK_WIDTH, LMBLOCK_HEIGHT, 0, , LMBLOCK_WIDTH, LMBLOCK_HEIGHT, 0,
GL_RGB, GL_UNSIGNED_BYTE, lightmap[i]->deluxmaps); GL_RGB, GL_UNSIGNED_BYTE, lightmap[i]->deluxmaps);
} }
} }
} }

View file

@ -94,8 +94,8 @@ void GLVID_Console_Resize(void)
if (cheight < 200) if (cheight < 200)
cheight = 200; cheight = 200;
vid.width = vid.conwidth = cwidth; vid.width = cwidth;
vid.height = vid.conheight = cheight; vid.height = cheight;
vid.recalc_refdef = true; vid.recalc_refdef = true;

View file

@ -18,6 +18,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/ */
// r_shader.c - based on code by Stephen C. Taylor // r_shader.c - based on code by Stephen C. Taylor
// Ported to FTE from qfusion, there are numerous changes since then.
#include "quakedef.h" #include "quakedef.h"
@ -37,10 +38,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern texid_t missing_texture; extern texid_t missing_texture;
static qboolean shader_reload_needed; static qboolean shader_reload_needed;
static qboolean shader_rescan_needed;
//cvars that affect shader generation //cvars that affect shader generation
cvar_t r_vertexlight = SCVAR("r_vertexlight", "0"); cvar_t r_vertexlight = SCVAR("r_vertexlight", "0");
extern cvar_t r_fastsky, r_skyboxname; extern cvar_t r_fastturb, r_fastsky, r_skyboxname;
extern cvar_t r_drawflat; extern cvar_t r_drawflat;
//backend fills this in to say the max pass count //backend fills this in to say the max pass count
@ -191,6 +193,8 @@ static char shaderbuf[MAX_QPATH * 256];
int shaderbuflen; int shaderbuflen;
shader_t *r_shaders; shader_t *r_shaders;
static hashtable_t shader_active_hash;
void *shader_active_hash_mem;
//static char r_skyboxname[MAX_QPATH]; //static char r_skyboxname[MAX_QPATH];
//static float r_skyheight; //static float r_skyheight;
@ -222,6 +226,22 @@ static char *Shader_ParseString ( char **ptr )
return token; return token;
} }
static char *Shader_ParseSensString ( char **ptr )
{
char *token;
if ( !ptr || !(*ptr) ) {
return "";
}
if ( !**ptr || **ptr == '}' ) {
return "";
}
token = COM_ParseExt ( ptr, false );
return token;
}
static float Shader_ParseFloat ( char **ptr ) static float Shader_ParseFloat ( char **ptr )
{ {
if ( !ptr || !(*ptr) ) { if ( !ptr || !(*ptr) ) {
@ -254,6 +274,8 @@ static void Shader_ParseVector ( char **ptr, vec3_t v )
} }
ptr = &scratch; ptr = &scratch;
scratch = var->string; scratch = var->string;
token = Shader_ParseString ( ptr );
} }
if ( !Q_stricmp (token, "(") ) { if ( !Q_stricmp (token, "(") ) {
bracket = true; bracket = true;
@ -287,10 +309,10 @@ static void Shader_ParseVector ( char **ptr, vec3_t v )
} }
} }
static void Shader_ParseSkySides ( shader_t *shader, char **ptr, texid_t *images ) qboolean Shader_ParseSkySides (char *shadername, char *texturename, texid_t *images)
{ {
qboolean allokay = true;
int i, ss, sp; int i, ss, sp;
char *token;
char path[MAX_QPATH]; char path[MAX_QPATH];
static char *skyname_suffix[][6] = { static char *skyname_suffix[][6] = {
@ -309,24 +331,29 @@ static void Shader_ParseSkySides ( shader_t *shader, char **ptr, texid_t *images
"gfx/env/%s%s" "gfx/env/%s%s"
}; };
token = Shader_ParseString ( ptr ); if (*texturename == '$')
if (*token == '$')
{ {
cvar_t *v; cvar_t *v;
v = Cvar_FindVar(token+1); v = Cvar_FindVar(texturename+1);
if (v) if (v)
token = v->string; texturename = v->string;
} }
if (!*texturename)
texturename = "-";
for ( i = 0; i < 6; i++ ) for ( i = 0; i < 6; i++ )
{ {
if ( token[0] == '-' ) { if ( texturename[0] == '-' )
{
images[i] = r_nulltex; images[i] = r_nulltex;
} else { }
else
{
for (sp = 0; sp < sizeof(skyname_pattern)/sizeof(skyname_pattern[0]); sp++) for (sp = 0; sp < sizeof(skyname_pattern)/sizeof(skyname_pattern[0]); sp++)
{ {
for (ss = 0; ss < sizeof(skyname_suffix)/sizeof(skyname_suffix[0]); ss++) for (ss = 0; ss < sizeof(skyname_suffix)/sizeof(skyname_suffix[0]); ss++)
{ {
Com_sprintf ( path, sizeof(path), skyname_pattern[sp], token, skyname_suffix[ss][i] ); Com_sprintf ( path, sizeof(path), skyname_pattern[sp], texturename, skyname_suffix[ss][i] );
images[i] = R_LoadHiResTexture ( path, NULL, IF_NOALPHA); images[i] = R_LoadHiResTexture ( path, NULL, IF_NOALPHA);
if (TEXVALID(images[i])) if (TEXVALID(images[i]))
break; break;
@ -336,11 +363,13 @@ static void Shader_ParseSkySides ( shader_t *shader, char **ptr, texid_t *images
} }
if (!TEXVALID(images[i])) if (!TEXVALID(images[i]))
{ {
Con_Printf("Shader \"%s\" missing texture: %s\n", shader->name, path); Con_Printf("Sky \"%s\" missing texture: %s\n", shadername, path);
images[i] = missing_texture; images[i] = missing_texture;
allokay = false;
} }
} }
} }
return allokay;
} }
static void Shader_ParseFunc ( char **ptr, shaderfunc_t *func ) static void Shader_ParseFunc ( char **ptr, shaderfunc_t *func )
@ -472,34 +501,39 @@ static void Shader_DeformVertexes ( shader_t *shader, shaderpass_t *pass, char *
} }
static void Shader_SkyParms ( shader_t *shader, shaderpass_t *pass, char **ptr ) static void Shader_SkyParms(shader_t *shader, shaderpass_t *pass, char **ptr)
{ {
int i; int i;
skydome_t *skydome; skydome_t *skydome;
float skyheight; float skyheight;
char *boxname;
if (shader->skydome) if (shader->skydome)
{ {
for ( i = 0; i < 5; i++ ) { for (i = 0; i < 5; i++)
Z_Free ( shader->skydome->meshes[i].xyz_array ); {
Z_Free ( shader->skydome->meshes[i].normals_array ); Z_Free(shader->skydome->meshes[i].xyz_array);
Z_Free ( shader->skydome->meshes[i].st_array ); Z_Free(shader->skydome->meshes[i].normals_array);
Z_Free(shader->skydome->meshes[i].st_array);
} }
Z_Free ( shader->skydome ); Z_Free(shader->skydome);
} }
skydome = (skydome_t *)Z_Malloc ( sizeof(skydome_t) ); skydome = (skydome_t *)Z_Malloc(sizeof(skydome_t));
shader->skydome = skydome; shader->skydome = skydome;
Shader_ParseSkySides ( shader, ptr, skydome->farbox_textures ); boxname = Shader_ParseString(ptr);
Shader_ParseSkySides(shader->name, boxname, skydome->farbox_textures);
skyheight = Shader_ParseFloat ( ptr ); skyheight = Shader_ParseFloat(ptr);
if ( !skyheight ) { if (!skyheight)
{
skyheight = 512.0f; skyheight = 512.0f;
} }
Shader_ParseSkySides ( shader, ptr, skydome->nearbox_textures ); boxname = Shader_ParseString(ptr);
Shader_ParseSkySides(shader->name, boxname, skydome->nearbox_textures);
shader->flags |= SHADER_SKY; shader->flags |= SHADER_SKY;
shader->sort = SHADER_SORT_SKY; shader->sort = SHADER_SORT_SKY;
@ -553,12 +587,16 @@ static void Shader_Sort ( shader_t *shader, shaderpass_t *pass, char **ptr )
shader->sort = SHADER_SORT_SKY; shader->sort = SHADER_SORT_SKY;
} else if( !Q_stricmp( token, "opaque" ) ) { } else if( !Q_stricmp( token, "opaque" ) ) {
shader->sort = SHADER_SORT_OPAQUE; shader->sort = SHADER_SORT_OPAQUE;
} else if( !Q_stricmp( token, "decal" ) ) {
shader->sort = SHADER_SORT_DECAL;
} else if( !Q_stricmp( token, "seethrough" ) ) {
shader->sort = SHADER_SORT_SEETHROUGH;
} else if( !Q_stricmp( token, "banner" ) ) { } else if( !Q_stricmp( token, "banner" ) ) {
shader->sort = SHADER_SORT_BANNER; shader->sort = SHADER_SORT_BANNER;
} else if( !Q_stricmp( token, "underwater" ) ) {
shader->sort = SHADER_SORT_UNDERWATER;
} else if( !Q_stricmp( token, "additive" ) ) { } else if( !Q_stricmp( token, "additive" ) ) {
shader->sort = SHADER_SORT_ADDITIVE; shader->sort = SHADER_SORT_ADDITIVE;
} else if( !Q_stricmp( token, "underwater" ) ) {
shader->sort = SHADER_SORT_UNDERWATER;
} else if( !Q_stricmp( token, "nearest" ) ) { } else if( !Q_stricmp( token, "nearest" ) ) {
shader->sort = SHADER_SORT_NEAREST; shader->sort = SHADER_SORT_NEAREST;
} else { } else {
@ -586,6 +624,16 @@ static void Shader_EntityMergable ( shader_t *shader, shaderpass_t *pass, char *
static void Shader_SLProgramName (shader_t *shader, shaderpass_t *pass, char **ptr, int qrtype) static void Shader_SLProgramName (shader_t *shader, shaderpass_t *pass, char **ptr, int qrtype)
{ {
/*accepts:
program
{
BLAH
}
where BLAH is both vertex+frag with #ifdefs
or
program vert frag
on one line.
*/
void *vert, *frag; void *vert, *frag;
char *token; char *token;
if (shader->programhandle.glsl) if (shader->programhandle.glsl)
@ -701,7 +749,7 @@ static void Shader_ProgramParam ( shader_t *shader, shaderpass_t *pass, char **p
} }
else if (!Q_stricmp(token, "cvari")) else if (!Q_stricmp(token, "cvari"))
{ {
token = Shader_ParseString(ptr); token = Shader_ParseSensString(ptr);
cv = Cvar_Get(token, "", 0, "GLSL Shader parameters"); cv = Cvar_Get(token, "", 0, "GLSL Shader parameters");
if (cv) if (cv)
{ //Cvar_Get returns null if the cvar is the name of a command { //Cvar_Get returns null if the cvar is the name of a command
@ -712,7 +760,7 @@ static void Shader_ProgramParam ( shader_t *shader, shaderpass_t *pass, char **p
} }
else if (!Q_stricmp(token, "cvarf")) else if (!Q_stricmp(token, "cvarf"))
{ {
token = Shader_ParseString(ptr); token = Shader_ParseSensString(ptr);
cv = Cvar_Get(token, "", 0, "GLSL Shader parameters"); cv = Cvar_Get(token, "", 0, "GLSL Shader parameters");
if (cv) if (cv)
{ //Cvar_Get returns null if the cvar is the name of a command { //Cvar_Get returns null if the cvar is the name of a command
@ -742,7 +790,7 @@ static void Shader_ProgramParam ( shader_t *shader, shaderpass_t *pass, char **p
else else
Con_Printf("shader %s: parameter type \"%s\" not known\n", shader->name, token); Con_Printf("shader %s: parameter type \"%s\" not known\n", shader->name, token);
token = Shader_ParseString(ptr); token = Shader_ParseSensString(ptr);
#ifdef GLQUAKE #ifdef GLQUAKE
if (qrenderer == QR_OPENGL) if (qrenderer == QR_OPENGL)
@ -1027,6 +1075,9 @@ static void Shaderpass_AlphaGen (shader_t *shader, shaderpass_t *pass, char **pt
if (!Q_stricmp (token, "portal")) if (!Q_stricmp (token, "portal"))
{ {
pass->alphagen = ALPHA_GEN_PORTAL; pass->alphagen = ALPHA_GEN_PORTAL;
shader->portaldist = Shader_ParseFloat(ptr);
if (!shader->portaldist)
shader->portaldist = 256;
shader->flags |= SHADER_AGEN_PORTAL; shader->flags |= SHADER_AGEN_PORTAL;
} }
else if (!Q_stricmp (token, "vertex")) else if (!Q_stricmp (token, "vertex"))
@ -1432,12 +1483,11 @@ qboolean Shader_Init (void)
shader_hash = calloc (HASH_SIZE, sizeof(*shader_hash)); shader_hash = calloc (HASH_SIZE, sizeof(*shader_hash));
Con_Printf ( "Initializing Shaders.\n" ); shader_active_hash_mem = malloc(Hash_BytesForBuckets(1024));
memset(shader_active_hash_mem, 0, Hash_BytesForBuckets(1024));
COM_EnumerateFiles("shaders/*.shader", Shader_InitCallback, NULL); Hash_InitTable(&shader_active_hash, 1024, shader_active_hash_mem);
COM_EnumerateFiles("scripts/*.shader", Shader_InitCallback, NULL);
// COM_EnumerateFiles("scripts/*.rscript", Shader_InitCallback, NULL);
shader_rescan_needed = true;
Shader_NeedReload(); Shader_NeedReload();
Shader_DoReload(); Shader_DoReload();
return true; return true;
@ -1474,7 +1524,7 @@ static void Shader_MakeCache ( char *path )
t = NULL; t = NULL;
Shader_GetPathAndOffset ( token, &t, &i ); Shader_GetPathAndOffset ( token, &t, &i );
if ( t ) if (t)
{ {
ptr = Shader_Skip ( ptr ); ptr = Shader_Skip ( ptr );
continue; continue;
@ -1567,6 +1617,8 @@ void Shader_Free (shader_t *shader)
int i; int i;
shaderpass_t *pass; shaderpass_t *pass;
Hash_RemoveData(&shader_active_hash, shader->name, shader);
#ifdef GLQUAKE #ifdef GLQUAKE
if (qrenderer == QR_OPENGL) if (qrenderer == QR_OPENGL)
if (shader->programhandle.glsl) if (shader->programhandle.glsl)
@ -1594,6 +1646,7 @@ void Shader_Free (shader_t *shader)
{ {
Shader_FreePass (pass); Shader_FreePass (pass);
} }
shader->numpasses = 0;
} }
void Shader_Shutdown (void) void Shader_Shutdown (void)
@ -1605,7 +1658,7 @@ void Shader_Shutdown (void)
shader = r_shaders; shader = r_shaders;
for (i = 0; i < MAX_SHADERS; i++, shader++) for (i = 0; i < MAX_SHADERS; i++, shader++)
{ {
if ( !shader->registration_sequence ) if ( !shader->uses )
continue; continue;
Shader_Free ( shader ); Shader_Free ( shader );
@ -1623,10 +1676,12 @@ void Shader_Shutdown (void)
} }
} }
Z_Free(r_shaders); free(r_shaders);
r_shaders = NULL; r_shaders = NULL;
Z_Free(shader_hash); free(shader_hash);
shader_hash = NULL; shader_hash = NULL;
free(shader_active_hash_mem);
shader_active_hash_mem = NULL;
shader_reload_needed = false; shader_reload_needed = false;
} }
@ -1703,7 +1758,7 @@ void Shader_Readpass (shader_t *shader, char **ptr)
pass->numtcmods = 0; pass->numtcmods = 0;
pass->numMergedPasses = 1; pass->numMergedPasses = 1;
while ( ptr ) while ( *ptr )
{ {
token = COM_ParseExt (ptr, true); token = COM_ParseExt (ptr, true);
@ -2013,7 +2068,7 @@ void Shader_Finish (shader_t *s)
"{\n" "{\n"
"{\n" "{\n"
"map $whiteimage\n" "map $whiteimage\n"
"rgbgen $r_fastskycolour\n" "rgbgen const $r_fastskycolour\n"
"}\n" "}\n"
"}\n" "}\n"
); );
@ -2161,7 +2216,7 @@ done:;
pass = s->passes; pass = s->passes;
for (i = 0; i < s->numpasses; i++, pass++ ) for (i = 0; i < s->numpasses; i++, pass++ )
{ {
if ((pass->shaderbits&SBITS_BLEND_BITS) == (SBITS_SRCBLEND_DST_COLOR|SBITS_DSTBLEND_ZERO)) if (pass->shaderbits & SBITS_ATEST_BITS)
{ {
opaque = i; opaque = i;
} }
@ -2180,11 +2235,9 @@ done:;
if (!(s->flags & SHADER_SKY ) && !s->sort) if (!(s->flags & SHADER_SKY ) && !s->sort)
{ {
if (opaque == -1) if (opaque == -1)
s->sort = SHADER_SORT_ADDITIVE; s->sort = SHADER_SORT_BLEND;
else if (s->passes[opaque].shaderbits & SBITS_ATEST_BITS)
s->sort = SHADER_SORT_OPAQUE + 1;
else else
s->sort = SHADER_SORT_OPAQUE; s->sort = SHADER_SORT_SEETHROUGH;
} }
} }
else else
@ -2206,7 +2259,7 @@ done:;
if (!s->sort) if (!s->sort)
{ {
if (pass->shaderbits & SBITS_ATEST_BITS) if (pass->shaderbits & SBITS_ATEST_BITS)
s->sort = SHADER_SORT_OPAQUE + 1; s->sort = SHADER_SORT_SEETHROUGH;
} }
if (!( s->flags & SHADER_DEPTHWRITE) && if (!( s->flags & SHADER_DEPTHWRITE) &&
@ -2314,6 +2367,11 @@ void R_BuildDefaultTexnums(texnums_t *tn, shader_t *shader)
if (!TEXVALID(tn->bump) && gl_bump.ival) if (!TEXVALID(tn->bump) && gl_bump.ival)
tn->bump = R_LoadHiResTexture(va("normalmaps/%s", shader->name), NULL, IF_NOALPHA); tn->bump = R_LoadHiResTexture(va("normalmaps/%s", shader->name), NULL, IF_NOALPHA);
if (!TEXVALID(tn->loweroverlay))
tn->loweroverlay = R_LoadHiResTexture(va("%s_pants", shader->name), NULL, 0); /*how rude*/
if (!TEXVALID(tn->upperoverlay))
tn->upperoverlay = R_LoadHiResTexture(va("%s_shirt", shader->name), NULL, 0);
shader->defaulttextures = *tn; shader->defaulttextures = *tn;
} }
@ -2331,24 +2389,211 @@ void Shader_DefaultScript(char *shortname, shader_t *s, const void *args)
} }
}; };
void Shader_DefaultBSP(char *shortname, shader_t *s, const void *args) void Shader_DefaultBSPLM(char *shortname, shader_t *s, const void *args)
{ {
char *builtin = NULL; char *builtin = NULL;
if (!builtin && r_drawflat.value)
builtin = (
"{\n"
"{\n"
"map $lightmap\n"
"tcgen lightmap\n"
"rgbgen const $r_floorcolour\n"
"}\n"
"}\n"
);
if (!builtin)
builtin = (
"{\n"
"if $deluxmap\n"
"[\n"
"{\n"
"map $normalmap\n"
"tcgen base\n"
"}\n"
"{\n"
"map $deluxmap\n"
"tcgen lightmap\n"
"}\n"
"]\n"
"{\n"
"map $diffuse\n"
"tcgen base\n"
"}\n"
"if $lightmap\n"
"[\n"
"{\n"
"map $lightmap\n"
"blendfunc gl_dst_color gl_zero\n"
"}\n"
"]\n"
"{\n"
"map $fullbright\n"
"blendfunc add\n"
"depthfunc equal\n"
"}\n"
"}\n"
);
Shader_DefaultScript(shortname, s, builtin);
}
void Shader_DefaultCinematic(char *shortname, shader_t *s, const void *args)
{
Shader_DefaultScript(shortname, s,
va(
"{\n"
"{\n"
"videomap %s\n"
"}\n"
"}\n"
, args)
);
}
/*shortname should begin with 'skybox_'*/
void Shader_DefaultSkybox(char *shortname, shader_t *s, const void *args)
{
Shader_DefaultScript(shortname, s,
va(
"{\n"
"skyparms %s - -\n"
"}\n"
, shortname+7)
);
}
void Shader_DefaultBSPQ2(char *shortname, shader_t *s, const void *args)
{
if (!strncmp(shortname, "sky/", 4))
{
Shader_DefaultScript(shortname, s,
"{\n"
"skyparms - - -\n"
"}\n"
);
}
else if (!strncmp(shortname, "warp/", 7))
{
Shader_DefaultScript(shortname, s,
"{\n"
"{\n"
"map $diffuse\n"
"tcmod turb 0 0.01 0.5 0\n"
"}\n"
"}\n"
);
}
else if (!strncmp(shortname, "warp33/", 7))
{
Shader_DefaultScript(shortname, s,
"{\n"
"{\n"
"map $diffuse\n"
"tcmod turb 0 0.01 0.5 0\n"
"alphagen const 0.333\n"
"blendfunc blend\n"
"}\n"
"}\n"
);
}
else if (!strncmp(shortname, "warp66/", 7))
{
Shader_DefaultScript(shortname, s,
"{\n"
"{\n"
"map $diffuse\n"
"tcmod turb 0 0.01 0.5 0\n"
"alphagen const 0.666\n"
"blendfunc blend\n"
"}\n"
"}\n"
);
}
else if (!strncmp(shortname, "trans/", 7))
Shader_DefaultScript(shortname, s,
"{\n"
"{\n"
"map $diffuse\n"
"alphagen const 1\n"
"blendfunc blend\n"
"}\n"
"}\n"
);
else if (!strncmp(shortname, "trans33/", 7))
Shader_DefaultScript(shortname, s,
"{\n"
"{\n"
"map $diffuse\n"
"alphagen const 0.333\n"
"blendfunc blend\n"
"}\n"
"}\n"
);
else if (!strncmp(shortname, "trans66/", 7))
Shader_DefaultScript(shortname, s,
"{\n"
"{\n"
"map $diffuse\n"
"alphagen const 0.666\n"
"blendfunc blend\n"
"}\n"
"}\n"
);
else
Shader_DefaultBSPLM(shortname, s, args);
}
void Shader_DefaultBSPQ1(char *shortname, shader_t *s, const void *args)
{
char *builtin = NULL;
if (r_mirroralpha.value < 1 && !strcmp(shortname, "window02_1"))
{
if (r_mirroralpha.value < 0)
{
builtin = "{\n"
"portal\n"
"{\n"
"map $diffuse\n"
"blendfunc blend\n"
"alphagen portal 512\n"
"depthwrite\n"
"}\n"
"}\n";
}
else
{
builtin = "{\n"
"portal\n"
"{\n"
"map $diffuse\n"
"blendfunc blend\n"
"alphagen const $r_mirroralpha\n"
"depthwrite\n"
"}\n"
"}\n";
}
}
if (!builtin && (*shortname == '*')) if (!builtin && (*shortname == '*'))
{ {
//q1 water //q1 water
/* if (r_fastturb.value) if (r_fastturb.ival)
{ {
builtin = ( builtin = (
"{\n"
"{\n" "{\n"
"{\n" "map $whiteimage\n"
"map $whiteimage\n" "rgbgen $r_fastturbcolour\n"
"rgbgen $r_fastturbcolour\n"
"}\n"
"}\n" "}\n"
); "}\n"
);
} }
else*/ #ifdef GLQUAKE
else if (qrenderer == QR_OPENGL && gl_config.arb_shader_objects)
{
builtin = ( builtin = (
"{\n" "{\n"
"program\n" "program\n"
@ -2388,6 +2633,19 @@ void Shader_DefaultBSP(char *shortname, shader_t *s, const void *args)
"}\n" "}\n"
"}\n" "}\n"
); );
}
#endif
else
{
builtin = (
"{\n"
"{\n"
"map $diffuse\n"
"tcmod turb 0 0.01 0.5 0\n"
"}\n"
"}\n"
);
}
} }
if (!builtin && !strncmp(shortname, "sky", 3)) if (!builtin && !strncmp(shortname, "sky", 3))
{ {
@ -2397,7 +2655,7 @@ void Shader_DefaultBSP(char *shortname, shader_t *s, const void *args)
"{\n" "{\n"
"{\n" "{\n"
"map $whiteimage\n" "map $whiteimage\n"
"rgbgen $r_fastskycolour\n" "rgbgen const $r_fastskycolour\n"
"}\n" "}\n"
"}\n" "}\n"
); );
@ -2407,7 +2665,8 @@ void Shader_DefaultBSP(char *shortname, shader_t *s, const void *args)
"skyparms $r_skybox - -\n" "skyparms $r_skybox - -\n"
"}\n" "}\n"
); );
else #ifdef GLQUAKE
else if (qrenderer == QR_OPENGL && gl_config.arb_shader_objects)
builtin = ( builtin = (
"{\n" "{\n"
"program\n" "program\n"
@ -2464,6 +2723,25 @@ void Shader_DefaultBSP(char *shortname, shader_t *s, const void *args)
"}\n" "}\n"
"}\n" "}\n"
); );
#endif
else
builtin = (
"{\n"
"skyparms - 512 -\n"
/*WARNING: these values are not authentic quake, only close aproximations*/
"{\n"
"map $diffuse\n"
"tcmod scale 10 10\n"
"tcmod scroll 0.04 0.04\n"
"}\n"
"{\n"
"map $fullbright\n"
"blendfunc blend\n"
"tcmod scale 10 10\n"
"tcmod scroll 0.02 0.02\n"
"}\n"
"}\n"
);
} }
if (!builtin && *shortname == '{') if (!builtin && *shortname == '{')
{ {
@ -2504,7 +2782,7 @@ void Shader_DefaultBSP(char *shortname, shader_t *s, const void *args)
} }
/*Hack: note that halflife would normally expect you to use rendermode/renderampt*/ /*Hack: note that halflife would normally expect you to use rendermode/renderampt*/
if (!builtin && (!strncmp(shortname, "glass", 5) || !strncmp(shortname, "window", 6))) if (!builtin && (!strncmp(shortname, "glass", 5)/* || !strncmp(shortname, "window", 6)*/))
{ {
/*alpha bended*/ /*alpha bended*/
builtin = ( builtin = (
@ -2518,51 +2796,10 @@ void Shader_DefaultBSP(char *shortname, shader_t *s, const void *args)
); );
} }
if (!builtin && r_drawflat.value) if (builtin)
builtin = ( Shader_DefaultScript(shortname, s, builtin);
"{\n" else
"{\n" Shader_DefaultBSPLM(shortname, s, args);
"map $lightmap\n"
"tcgen lightmap\n"
"rgbgen const $r_floorcolour\n"
"}\n"
"}\n"
);
if (!builtin)
builtin = (
"{\n"
"if $deluxmap\n"
"[\n"
"{\n"
"map $normalmap\n"
"tcgen base\n"
"}\n"
"{\n"
"map $deluxmap\n"
"tcgen lightmap\n"
"}\n"
"]\n"
"{\n"
"map $diffuse\n"
"tcgen base\n"
"}\n"
"if $lightmap\n"
"[\n"
"{\n"
"map $lightmap\n"
"blendfunc gl_dst_color gl_zero\n"
"}\n"
"]\n"
"{\n"
"map $fullbright\n"
"blendfunc add\n"
"depthfunc equal\n"
"}\n"
"}\n"
);
Shader_DefaultScript(shortname, s, builtin);
} }
void Shader_DefaultBSPVertex(char *shortname, shader_t *s, const void *args) void Shader_DefaultBSPVertex(char *shortname, shader_t *s, const void *args)
@ -2588,7 +2825,7 @@ void Shader_DefaultBSPVertex(char *shortname, shader_t *s, const void *args)
s->flags = SHADER_DEPTHWRITE|SHADER_CULL_FRONT; s->flags = SHADER_DEPTHWRITE|SHADER_CULL_FRONT;
s->features = MF_STCOORDS|MF_COLORS; s->features = MF_STCOORDS|MF_COLORS;
s->sort = SHADER_SORT_OPAQUE; s->sort = SHADER_SORT_OPAQUE;
s->registration_sequence = 1;//fizme: registration_sequence; s->uses = 1;
} }
void Shader_DefaultBSPFlare(char *shortname, shader_t *s, const void *args) void Shader_DefaultBSPFlare(char *shortname, shader_t *s, const void *args)
{ {
@ -2615,7 +2852,7 @@ void Shader_DefaultBSPFlare(char *shortname, shader_t *s, const void *args)
s->flags = SHADER_FLARE; s->flags = SHADER_FLARE;
s->features = MF_STCOORDS|MF_COLORS; s->features = MF_STCOORDS|MF_COLORS;
s->sort = SHADER_SORT_ADDITIVE; s->sort = SHADER_SORT_ADDITIVE;
s->registration_sequence = 1;//fizme: registration_sequence; s->uses = 1;
} }
void Shader_DefaultSkin(char *shortname, shader_t *s, const void *args) void Shader_DefaultSkin(char *shortname, shader_t *s, const void *args)
{ {
@ -2628,10 +2865,12 @@ void Shader_DefaultSkin(char *shortname, shader_t *s, const void *args)
"{\n" "{\n"
"map $loweroverlay\n" "map $loweroverlay\n"
"rgbgen bottomcolor\n" "rgbgen bottomcolor\n"
"blendfunc gl_src_alpha gl_one\n"
"}\n" "}\n"
"{\n" "{\n"
"map $upperoverlay\n" "map $upperoverlay\n"
"rgbgen uppercolor\n" "rgbgen topcolor\n"
"blendfunc gl_src_alpha gl_one\n"
"}\n" "}\n"
"{\n" "{\n"
"map $fullbright\n" "map $fullbright\n"
@ -2668,7 +2907,7 @@ void Shader_DefaultSkinShell(char *shortname, shader_t *s, const void *args)
s->flags = SHADER_DEPTHWRITE|SHADER_CULL_FRONT; s->flags = SHADER_DEPTHWRITE|SHADER_CULL_FRONT;
s->features = MF_STCOORDS|MF_NORMALS; s->features = MF_STCOORDS|MF_NORMALS;
s->sort = SHADER_SORT_OPAQUE; s->sort = SHADER_SORT_OPAQUE;
s->registration_sequence = 1;//fizme: registration_sequence; s->uses = 1;
} }
void Shader_Default2D(char *shortname, shader_t *s, const void *genargs) void Shader_Default2D(char *shortname, shader_t *s, const void *genargs)
{ {
@ -2698,7 +2937,7 @@ void Shader_Default2D(char *shortname, shader_t *s, const void *genargs)
s->flags = SHADER_NOPICMIP|SHADER_NOMIPMAPS|SHADER_BLEND; s->flags = SHADER_NOPICMIP|SHADER_NOMIPMAPS|SHADER_BLEND;
s->features = MF_STCOORDS|MF_COLORS; s->features = MF_STCOORDS|MF_COLORS;
s->sort = SHADER_SORT_ADDITIVE; s->sort = SHADER_SORT_ADDITIVE;
s->registration_sequence = 1;//fizme: registration_sequence; s->uses = 1;
} }
//loads a shader string into an existing shader object, and finalises it and stuff //loads a shader string into an existing shader object, and finalises it and stuff
@ -2708,7 +2947,7 @@ static void Shader_ReadShader(shader_t *s, char *shadersource)
// set defaults // set defaults
s->flags = SHADER_CULL_FRONT; s->flags = SHADER_CULL_FRONT;
s->registration_sequence = 1;//fizme: registration_sequence; s->uses = 1;
while (shadersource) while (shadersource)
{ {
@ -2747,7 +2986,7 @@ static void Shader_ReadShader(shader_t *s, char *shadersource)
Shader_Finish ( s ); Shader_Finish ( s );
} }
qboolean Shader_ParseShader(char *shortname, char *usename, shader_t *s) static qboolean Shader_ParseShader(char *shortname, char *usename, shader_t *s)
{ {
unsigned int offset = 0, length; unsigned int offset = 0, length;
char path[MAX_QPATH]; char path[MAX_QPATH];
@ -2780,6 +3019,7 @@ qboolean Shader_ParseShader(char *shortname, char *usename, shader_t *s)
Shader_Free(s); Shader_Free(s);
memset ( s, 0, sizeof( shader_t ) ); memset ( s, 0, sizeof( shader_t ) );
Com_sprintf ( s->name, MAX_QPATH, usename ); Com_sprintf ( s->name, MAX_QPATH, usename );
Hash_Add(&shader_active_hash, s->name, s, &s->bucket);
Shader_ReadShader(s, file); Shader_ReadShader(s, file);
@ -2792,8 +3032,12 @@ qboolean Shader_ParseShader(char *shortname, char *usename, shader_t *s)
return false; return false;
} }
void R_UnloadShader(shader_t *shader)
int R_LoadShader ( char *name, shader_gen_t *defaultgen, const char *genargs) {
if (shader->uses-- == 1)
Shader_Free(shader);
}
static int R_LoadShader ( char *name, shader_gen_t *defaultgen, const char *genargs)
{ {
int i, f = -1; int i, f = -1;
char shortname[MAX_QPATH]; char shortname[MAX_QPATH];
@ -2803,20 +3047,25 @@ int R_LoadShader ( char *name, shader_gen_t *defaultgen, const char *genargs)
COM_CleanUpPath(shortname); COM_CleanUpPath(shortname);
// test if already loaded // check the hash first
s = Hash_Get(&shader_active_hash, shortname);
if (s)
{
i = s - r_shaders;
r_shaders[i].uses++;
return i;
}
// not loaded, find a free slot
for (i = 0; i < MAX_SHADERS; i++) for (i = 0; i < MAX_SHADERS; i++)
{ {
if (!r_shaders[i].generator) if (!r_shaders[i].uses)
{ {
if ( f == -1 ) // free shader if ( f == -1 ) // free shader
{
f = i; f = i;
continue; break;
} }
if (!Q_stricmp (shortname, r_shaders[i].name) )
{
r_shaders[i].registration_sequence = 1;//fizme: registration_sequence;
return i;
} }
} }
@ -2857,6 +3106,7 @@ int R_LoadShader ( char *name, shader_gen_t *defaultgen, const char *genargs)
s->generator = defaultgen; s->generator = defaultgen;
s->genargs = genargs; s->genargs = genargs;
Com_sprintf ( s->name, MAX_QPATH, shortname ); Com_sprintf ( s->name, MAX_QPATH, shortname );
Hash_Add(&shader_active_hash, s->name, s, &s->bucket);
defaultgen(shortname, s, genargs); defaultgen(shortname, s, genargs);
return f; return f;
@ -2873,6 +3123,18 @@ void Shader_DoReload(void)
const char *genargs; const char *genargs;
texnums_t oldtn; texnums_t oldtn;
if (shader_rescan_needed && ruleset_allow_shaders.ival)
{
Con_Printf ( "Initializing Shaders.\n" );
COM_EnumerateFiles("shaders/*.shader", Shader_InitCallback, NULL);
COM_EnumerateFiles("scripts/*.shader", Shader_InitCallback, NULL);
//COM_EnumerateFiles("scripts/*.rscript", Shader_InitCallback, NULL);
shader_reload_needed = true;
shader_rescan_needed = false;
}
if (!shader_reload_needed) if (!shader_reload_needed)
return; return;
shader_reload_needed = false; shader_reload_needed = false;
@ -2881,7 +3143,7 @@ void Shader_DoReload(void)
for (s = r_shaders, i = 0; i < MAX_SHADERS; i++, s++) for (s = r_shaders, i = 0; i < MAX_SHADERS; i++, s++)
{ {
if (!s->generator) if (!s->uses)
continue; continue;
defaultgen = s->generator; defaultgen = s->generator;
@ -2918,6 +3180,7 @@ void Shader_DoReload(void)
s->generator = defaultgen; s->generator = defaultgen;
s->genargs = genargs; s->genargs = genargs;
Com_sprintf ( s->name, MAX_QPATH, shortname ); Com_sprintf ( s->name, MAX_QPATH, shortname );
Hash_Add(&shader_active_hash, s->name, s, &s->bucket);
s->generator(shortname, s, s->genargs); s->generator(shortname, s, s->genargs);
R_BuildDefaultTexnums(&oldtn, s); R_BuildDefaultTexnums(&oldtn, s);
} }
@ -2929,14 +3192,27 @@ void Shader_NeedReload(void)
shader_reload_needed = true; shader_reload_needed = true;
} }
cin_t *R_ShaderGetCinematic(char *name) cin_t *R_ShaderGetCinematic(shader_t *s)
{
#ifndef NOMEDIA
int j;
if (!s)
return NULL;
for (j = 0; j < s->numpasses; j++)
if (s->passes[j].cin)
return s->passes[j].cin;
#endif
/*no cinematic in this shader!*/
return NULL;
}
cin_t *R_ShaderFindCinematic(char *name)
{ {
#ifdef NOMEDIA #ifdef NOMEDIA
return NULL; return NULL;
#else #else
int i, j; int i;
char shortname[MAX_QPATH]; char shortname[MAX_QPATH];
shader_t *s;
COM_StripExtension ( name, shortname, sizeof(shortname)); COM_StripExtension ( name, shortname, sizeof(shortname));
@ -2945,7 +3221,7 @@ cin_t *R_ShaderGetCinematic(char *name)
//try and find it //try and find it
for (i = 0; i < MAX_SHADERS; i++) for (i = 0; i < MAX_SHADERS; i++)
{ {
if (!r_shaders[i].registration_sequence) if (!r_shaders[i].uses)
continue; continue;
if (!Q_stricmp (shortname, r_shaders[i].name) ) if (!Q_stricmp (shortname, r_shaders[i].name) )
@ -2954,14 +3230,8 @@ cin_t *R_ShaderGetCinematic(char *name)
if (i == MAX_SHADERS) if (i == MAX_SHADERS)
return NULL; return NULL;
//we have a currently-loaded shader. //found the named shader.
s = &r_shaders[i]; return R_ShaderGetCinematic(&r_shaders[i]);
for (j = 0; j < s->numpasses; j++)
if (s->passes[j].cin)
return s->passes[j].cin;
//but it has no cinematic passes.
return NULL;
#endif #endif
} }
@ -2977,7 +3247,7 @@ shader_t *R_RegisterShader (char *name, const char *shaderscript)
shader_t *R_RegisterShader_Lightmap (char *name) shader_t *R_RegisterShader_Lightmap (char *name)
{ {
return &r_shaders[R_LoadShader (name, Shader_DefaultBSP, NULL)]; return &r_shaders[R_LoadShader (name, Shader_DefaultBSPLM, NULL)];
} }
shader_t *R_RegisterShader_Vertex (char *name) shader_t *R_RegisterShader_Vertex (char *name)

View file

@ -6,15 +6,18 @@
#include "glquake.h" #include "glquake.h"
#include "shader.h" #include "shader.h"
#define lradius l->radius #define SHADOWMAP_SIZE 512
#define nearplane (16) #define nearplane (16)
#if 0//def _DEBUG #if 1//def _DEBUG
#define checkerror() if (qglGetError()) Con_Printf("Error detected at line %s:%i\n", __FILE__, __LINE__) #define checkerror() if (qglGetError()) Con_Printf("Error detected at line %s:%i\n", __FILE__, __LINE__)
#else #else
#define checkerror() #define checkerror()
#endif #endif
static int shadow_fbo_id;
static void Sh_DrawEntLighting(dlight_t *light, vec3_t colour); static void Sh_DrawEntLighting(dlight_t *light, vec3_t colour);
@ -37,7 +40,7 @@ struct {
typedef struct { typedef struct {
unsigned int count; unsigned int count;
unsigned int max; unsigned int max;
msurface_t **s; mesh_t **s;
} shadowmeshsurfs_t; } shadowmeshsurfs_t;
typedef struct shadowmesh_s { typedef struct shadowmesh_s {
unsigned int numindicies; unsigned int numindicies;
@ -185,21 +188,17 @@ static void SHM_Shadow_Cache_Surface(msurface_t *surf)
{ {
int i; int i;
#pragma message("Remove this loop ffs!") i = surf->texinfo->texture->wtexno;
for (i = 0; i < cl.worldmodel->numtextures; i++) if (i < 0)
return;
if (sh_shmesh->litsurfs[i].count == sh_shmesh->litsurfs[i].max)
{ {
if (surf->texinfo->texture == cl.worldmodel->textures[i]) sh_shmesh->litsurfs[i].max += 64;
{ sh_shmesh->litsurfs[i].s = BZ_Realloc(sh_shmesh->litsurfs[i].s, sizeof(void*)*(sh_shmesh->litsurfs[i].max));
if (sh_shmesh->litsurfs[i].count == sh_shmesh->litsurfs[i].max)
{
sh_shmesh->litsurfs[i].max += 64;
sh_shmesh->litsurfs[i].s = BZ_Realloc(sh_shmesh->litsurfs[i].s, sizeof(void*)*(sh_shmesh->litsurfs[i].max));
}
sh_shmesh->litsurfs[i].s[sh_shmesh->litsurfs[i].count] = surf;
sh_shmesh->litsurfs[i].count++;
break;
}
} }
sh_shmesh->litsurfs[i].s[sh_shmesh->litsurfs[i].count] = surf->mesh;
sh_shmesh->litsurfs[i].count++;
} }
static void SHM_Shadow_Cache_Leaf(mleaf_t *leaf) static void SHM_Shadow_Cache_Leaf(mleaf_t *leaf)
@ -862,7 +861,7 @@ static SHM_ComposeVolume_BruteForce(dlight_t *dl)
continue; continue;
for (sno = 0; sno < sms->count; sno++) for (sno = 0; sno < sms->count; sno++)
{ {
sm = sms->s[sno]->mesh; sm = sms->s[sno];
if (sm->istrifan) if (sm->istrifan)
{ {
@ -1259,19 +1258,17 @@ static qboolean Sh_ScissorForBox(vec3_t mins, vec3_t maxs)
void GL_BeginRenderBuffer_DepthOnly(texid_t depthtexture) void GL_BeginRenderBuffer_DepthOnly(texid_t depthtexture)
{ {
static int fboid; if (gl_config.ext_framebuffer_objects)
if (qglGenRenderbuffersEXT)
{ {
if (!fboid) if (!shadow_fbo_id)
{ {
qglGenRenderbuffersEXT(1, &fboid); qglGenRenderbuffersEXT(1, &shadow_fbo_id);
qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboid); qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, shadow_fbo_id);
qglDrawBuffer(GL_NONE); qglDrawBuffer(GL_NONE);
qglReadBuffer(GL_NONE); qglReadBuffer(GL_NONE);
} }
else else
qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fboid); qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, shadow_fbo_id);
if (TEXVALID(depthtexture)) if (TEXVALID(depthtexture))
qglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, depthtexture.num, 0); qglFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, depthtexture.num, 0);
@ -1279,7 +1276,7 @@ void GL_BeginRenderBuffer_DepthOnly(texid_t depthtexture)
} }
void GL_EndRenderBuffer_DepthOnly(texid_t depthtexture, int texsize) void GL_EndRenderBuffer_DepthOnly(texid_t depthtexture, int texsize)
{ {
if (qglGenRenderbuffersEXT) if (gl_config.ext_framebuffer_objects)
{ {
qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); qglBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
} }
@ -1290,43 +1287,66 @@ void GL_EndRenderBuffer_DepthOnly(texid_t depthtexture, int texsize)
} }
} }
static void Sh_GenShadowFace(dlight_t *l, shadowmesh_t *smesh, int face) static void Sh_GenShadowFace(dlight_t *l, shadowmesh_t *smesh, int face, float proj[16])
{ {
float mvm[16], proj[16]; float mvm[16];
vec3_t t1,t2;
int smsize = 512; int smsize = SHADOWMAP_SIZE;
int tno, sno; int tno;
mesh_t *m, *sm; mesh_t *m;
texture_t *tex; texture_t *tex;
// qglDepthRange(0, 1); // qglDepthRange(0, 1);
BE_SetupForShadowMap();
checkerror(); checkerror();
if (1) if (l->fov)
{
qglViewport (0, 0, smsize, smsize); qglViewport (0, 0, smsize, smsize);
else
qglViewport (((face/2)*smsize)/3, ((face&1)*smsize)/2, smsize/3, smsize/2);
if (!l->fov) switch(face)
l->fov = 90; {
case 0:
Matrix4_Projection_Far(proj, l->fov, l->fov, nearplane, lradius); //forward
Matrix4_ModelViewMatrixFromAxis(mvm, l->axis[0], l->axis[1], l->axis[2], l->origin); Matrix4_ModelViewMatrixFromAxis(mvm, l->axis[0], l->axis[1], l->axis[2], l->origin);
break;
qglMatrixMode(GL_PROJECTION); case 1:
qglLoadMatrixf(proj); //back
qglMatrixMode(GL_MODELVIEW); VectorNegate(l->axis[0], t1);
qglLoadMatrixf(mvm); VectorNegate(l->axis[1], t2);
Matrix4_ModelViewMatrixFromAxis(mvm, t1, t2, l->axis[2], l->origin);
R_SetFrustum(proj, mvm); break;
case 2:
//left
VectorNegate(l->axis[1], t1);
VectorNegate(l->axis[0], t2);
Matrix4_ModelViewMatrixFromAxis(mvm, l->axis[1], t2, l->axis[2], l->origin);
break;
case 3:
//right
VectorNegate(l->axis[1], t1);
Matrix4_ModelViewMatrixFromAxis(mvm, t1, l->axis[0], l->axis[2], l->origin);
break;
case 4:
//up
VectorNegate(l->axis[0], t2);
Matrix4_ModelViewMatrixFromAxis(mvm, l->axis[2], l->axis[1], t2, l->origin);
break;
case 5:
//down
VectorNegate(l->axis[2], t1);
Matrix4_ModelViewMatrixFromAxis(mvm, t1, l->axis[1], l->axis[0], l->origin);
break;
} }
checkerror();
BE_SelectMode(BEM_DEPTHONLY, 0); qglMatrixMode(GL_MODELVIEW);
qglLoadMatrixf(mvm);
GL_BeginRenderBuffer_DepthOnly(l->stexture); R_SetFrustum(proj, mvm);
qglClear (GL_DEPTH_BUFFER_BIT);
checkerror();
if (smesh) if (smesh)
for (tno = 0; tno < smesh->numsurftextures; tno++) for (tno = 0; tno < smesh->numsurftextures; tno++)
@ -1334,30 +1354,19 @@ checkerror();
m = NULL; m = NULL;
if (!smesh->litsurfs[tno].count) if (!smesh->litsurfs[tno].count)
continue; continue;
tex = smesh->litsurfs[tno].s[0]->texinfo->texture; tex = cl.worldmodel->textures[tno];
for (sno = 0; sno < smesh->litsurfs[tno].count; sno++) BE_DrawMesh_List(tex->shader, smesh->litsurfs[tno].count, smesh->litsurfs[tno].s, &tex->vbo, &tex->shader->defaulttextures);
{
sm = smesh->litsurfs[tno].s[sno]->mesh;
if (!sm)
continue;
sm->next = m;
m = sm;
}
if (m)
BE_DrawMeshChain(tex->shader, m, &tex->vbo, &tex->shader->defaulttextures);
} }
BE_BaseEntShadowDepth(); BE_BaseEntShadowDepth();
GL_EndRenderBuffer_DepthOnly(l->stexture, smsize);
if (0) if (0)
{ {
int i; int i;
static float depth[512*512]; static float depth[SHADOWMAP_SIZE*SHADOWMAP_SIZE];
qglReadPixels(0, 0, smsize, smsize, qglReadPixels(0, 0, smsize, smsize,
GL_DEPTH_COMPONENT, GL_FLOAT, depth); GL_DEPTH_COMPONENT, GL_FLOAT, depth);
for (i = 512*512; i --> 0; ) for (i = SHADOWMAP_SIZE*SHADOWMAP_SIZE; i --> 0; )
{ {
if (depth[i] == 1) if (depth[i] == 1)
*((unsigned int*)depth+i) = 0; *((unsigned int*)depth+i) = 0;
@ -1377,69 +1386,96 @@ checkerror();
checkerror(); checkerror();
} }
void Sh_GenShadowMaps (void) void Sh_Shutdown(void)
{
if (shadow_fbo_id)
{
qglDeleteRenderbuffersEXT(1, &shadow_fbo_id);
shadow_fbo_id = 0;
}
}
void Sh_GenShadowMap (dlight_t *l)
{ {
dlight_t *l;
int i;
int f; int f;
int smsize = 512; int smsize = SHADOWMAP_SIZE;
float proj[16];
shadowmesh_t *smesh; shadowmesh_t *smesh;
//FIXME: push dynamic shadow volume generation to another thread. if (!TEXVALID(l->stexture))
//FIXME: cull lights here.
for (l = cl_dlights+rtlights_first, i=rtlights_first; i<rtlights_max; i++, l++)
{ {
if (!(l->flags & LFLAG_SHADOWMAP)) l->stexture = GL_AllocNewTexture();
continue;
if (!l->radius || l->flags & LFLAG_NOSHADOWS) checkerror();
continue;
if (l->color[0]<0)
continue; //quick check for darklight
if (!TEXVALID(l->stexture)) GL_Bind(l->stexture);
{ checkerror();
l->stexture = GL_AllocNewTexture(); qglTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32_ARB, smsize, smsize, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
// qglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, smsize, smsize, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
checkerror(); checkerror();
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
GL_Bind(l->stexture); checkerror();
checkerror();
qglTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT32_ARB, smsize, smsize, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
// qglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, smsize, smsize, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
checkerror();
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
checkerror();
}
else if (l->refresh-->0)
continue; //FIXME: need to optimise GenShadowFace first
l->refresh = 0;
if (l->worldshadowmesh)
smesh = l->worldshadowmesh;
else
{
unsigned int leaf;
qbyte lvisb[MAX_MAP_LEAFS/8];
qbyte *lvis;
leaf = cl.worldmodel->funcs.LeafnumForPoint(cl.worldmodel, l->origin);
lvis = cl.worldmodel->funcs.LeafPVS(cl.worldmodel, leaf, lvisb, sizeof(lvisb));
smesh = SHM_BuildShadowVolumeMesh(l, lvis, NULL);
}
qglEnable(GL_POLYGON_OFFSET_FILL);
qglPolygonOffset(5, 25);
for (f = 0; f < 1; f++)
{
Sh_GenShadowFace(l, smesh, f);
}
qglDisable(GL_POLYGON_OFFSET_FILL);
} }
if (l->worldshadowmesh)
smesh = l->worldshadowmesh;
else
{
unsigned int leaf;
qbyte lvisb[MAX_MAP_LEAFS/8];
qbyte *lvis;
leaf = cl.worldmodel->funcs.LeafnumForPoint(cl.worldmodel, l->origin);
lvis = cl.worldmodel->funcs.LeafPVS(cl.worldmodel, leaf, lvisb, sizeof(lvisb));
smesh = SHM_BuildShadowVolumeMesh(l, lvis, NULL);
}
/*polygon offsets. urgh.*/
qglEnable(GL_POLYGON_OFFSET_FILL);
qglPolygonOffset(5, 25);
BE_SetupForShadowMap();
/*set framebuffer*/
GL_BeginRenderBuffer_DepthOnly(l->stexture);
qglClear (GL_DEPTH_BUFFER_BIT);
if (l->fov)
{
Matrix4_Projection_Far(proj, l->fov, l->fov, nearplane, l->radius);
qglMatrixMode(GL_PROJECTION);
qglLoadMatrixf(proj);
/*single face*/
Sh_GenShadowFace(l, smesh, 0, proj);
}
else
{
Matrix4_Projection_Far(proj, 90, 90, nearplane, l->radius);
qglMatrixMode(GL_PROJECTION);
qglLoadMatrixf(proj);
/*generate faces*/
for (f = 0; f < 6; f++)
{
Sh_GenShadowFace(l, smesh, f, proj);
}
}
/*end framebuffer*/
GL_EndRenderBuffer_DepthOnly(l->stexture, smsize);
qglDisable(GL_POLYGON_OFFSET_FILL);
qglMatrixMode(GL_PROJECTION);
qglLoadMatrixf(r_refdef.m_projection);
qglMatrixMode(GL_MODELVIEW);
qglLoadMatrixf(r_refdef.m_view);
qglViewport(r_refdef.pxrect.x, vid.pixelheight - r_refdef.pxrect.y, r_refdef.pxrect.width, r_refdef.pxrect.height);
} }
static float shadowprojectionbias[16] = static float shadowprojectionbias[16] =
@ -1450,15 +1486,41 @@ static float shadowprojectionbias[16] =
0.5f, 0.5f, 0.4993f, 1.0f 0.5f, 0.5f, 0.4993f, 1.0f
}; };
static void Sh_DrawLameSpotLightShadowMap(dlight_t *l, vec3_t colour) static void Sh_DrawShadowMapLight(dlight_t *l, vec3_t colour)
{ {
float t[16]; float t[16];
float bp[16]; float bp[16];
float proj[16], view[16]; float proj[16], view[16];
vec3_t biasorg; vec3_t biasorg;
int ve; int ve;
vec3_t mins, maxs;
Matrix4_Projection_Far(proj, l->fov, l->fov, nearplane, lradius); if (R_CullSphere(l->origin, l->radius))
{
bench.numfrustumculled++;
return; //this should be the more common case
}
mins[0] = l->origin[0] - l->radius;
mins[1] = l->origin[1] - l->radius;
mins[2] = l->origin[2] - l->radius;
maxs[0] = l->origin[0] + l->radius;
maxs[1] = l->origin[1] + l->radius;
maxs[2] = l->origin[2] + l->radius;
if (Sh_ScissorForBox(mins, maxs))
{
bench.numscissorculled++;
return;
}
Sh_GenShadowMap(l);
if (l->fov)
Matrix4_Projection_Far(proj, l->fov, l->fov, nearplane, l->radius);
else
Matrix4_Projection_Far(proj, 90, 90, nearplane, l->radius);
VectorMA(l->origin, 0, l->axis[0], biasorg); VectorMA(l->origin, 0, l->axis[0], biasorg);
Matrix4_ModelViewMatrixFromAxis(view, l->axis[0], l->axis[1], l->axis[2], l->origin); Matrix4_ModelViewMatrixFromAxis(view, l->axis[0], l->axis[1], l->axis[2], l->origin);
@ -1486,7 +1548,6 @@ checkerror();
bench.numlights++; bench.numlights++;
#if 1
qglMatrixMode(GL_TEXTURE); qglMatrixMode(GL_TEXTURE);
GL_MBind(7, l->stexture); GL_MBind(7, l->stexture);
// qglEnable(GL_TEXTURE_2D); // qglEnable(GL_TEXTURE_2D);
@ -1495,7 +1556,6 @@ checkerror();
qglTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_LUMINANCE); qglTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_LUMINANCE);
qglLoadMatrixf(bp); qglLoadMatrixf(bp);
qglMatrixMode(GL_MODELVIEW); qglMatrixMode(GL_MODELVIEW);
PPL_RevertToKnownState();
GL_SelectTexture(0); GL_SelectTexture(0);
@ -1503,7 +1563,7 @@ checkerror();
ve = 0; ve = 0;
BE_SelectDLight(l, colour); BE_SelectDLight(l, colour);
BE_SelectMode(BEM_SMAPLIGHT, 0); BE_SelectMode(l->fov?BEM_SMAPLIGHTSPOT:BEM_SMAPLIGHT, 0);
Sh_DrawEntLighting(l, colour); Sh_DrawEntLighting(l, colour);
GL_SelectTexture(7); GL_SelectTexture(7);
@ -1511,118 +1571,9 @@ checkerror();
qglMatrixMode(GL_TEXTURE); qglMatrixMode(GL_TEXTURE);
qglLoadIdentity(); qglLoadIdentity();
qglMatrixMode(GL_MODELVIEW); qglMatrixMode(GL_MODELVIEW);
// PPL_RevertToKnownState();
checkerror(); checkerror();
#else
GL_MBind(0, l->stexture);
qglEnable(GL_TEXTURE_2D);
//Set up texture coordinate generation.
qglTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
qglTexGenfv(GL_S, GL_EYE_PLANE, &t[0]);
qglEnable(GL_TEXTURE_GEN_S);
qglTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
qglTexGenfv(GL_T, GL_EYE_PLANE, &t[4]);
qglEnable(GL_TEXTURE_GEN_T);
qglTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
qglTexGenfv(GL_R, GL_EYE_PLANE, &t[8]);
qglEnable(GL_TEXTURE_GEN_R);
qglTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
qglTexGenfv(GL_Q, GL_EYE_PLANE, &t[12]);
qglEnable(GL_TEXTURE_GEN_Q);
checkerror();
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE_ARB);
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL);
qglTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_ALPHA);
checkerror();
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
if (1)
{
GL_MBind(1, balltexture);
qglEnable(GL_TEXTURE_2D);
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
qglTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
qglTexGenfv(GL_S, GL_EYE_PLANE, &t[0]);
qglEnable(GL_TEXTURE_GEN_S);
qglTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
qglTexGenfv(GL_T, GL_EYE_PLANE, &t[4]);
qglEnable(GL_TEXTURE_GEN_T);
qglTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
qglTexGenfv(GL_R, GL_EYE_PLANE, &t[8]);
qglEnable(GL_TEXTURE_GEN_R);
qglTexGeni(GL_Q, GL_TEXTURE_GEN_MODE, GL_EYE_LINEAR);
qglTexGenfv(GL_Q, GL_EYE_PLANE, &t[12]);
qglEnable(GL_TEXTURE_GEN_Q);
}
else
{
qglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_NONE);
qglTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_ALPHA);
}
qglEnable(GL_BLEND);
qglBlendFunc (GL_SRC_ALPHA, GL_ONE);
qglDisable(GL_ALPHA_TEST);
qglColor3f(colour[0], colour[1], colour[2]);
qglEnableClientState(GL_VERTEX_ARRAY);
qglDisableClientState(GL_COLOR_ARRAY);
checkerror();
qglDepthMask(0);
GL_TexEnv(GL_MODULATE);
ve = 0;
//qglEnable(GL_POLYGON_OFFSET_FILL);
qglPolygonOffset(-0.5, -25);
for (i = 0; i < cl.worldmodel->numsurfaces; i++)
{
s = &cl.worldmodel->surfaces[i];
// if(s->visframe != r_framecount)
// continue;
if (ve != s->texinfo->texture->vbo.vboe)
{
ve = s->texinfo->texture->vbo.vboe;
GL_SelectVBO(s->texinfo->texture->vbo.vbocoord);
GL_SelectEBO(s->texinfo->texture->vbo.vboe);
qglVertexPointer(3, GL_FLOAT, sizeof(vecV_t), s->texinfo->texture->vbo.coord);
}
qglDrawRangeElements(GL_TRIANGLES, s->mesh->vbofirstvert, s->mesh->numvertexes, s->mesh->numindexes, GL_INDEX_TYPE, (index_t*)(s->mesh->vbofirstelement*sizeof(index_t)));
}
checkerror();
qglDisable(GL_POLYGON_OFFSET_FILL);
GL_SelectVBO(0);
GL_SelectEBO(0);
GL_MBind(1, 0);
qglDisable(GL_TEXTURE_2D);
qglDisable(GL_TEXTURE_GEN_S);
qglDisable(GL_TEXTURE_GEN_T);
qglDisable(GL_TEXTURE_GEN_R);
qglDisable(GL_TEXTURE_GEN_Q);
GL_MBind(0, 0);
qglDisable(GL_TEXTURE_GEN_S);
qglDisable(GL_TEXTURE_GEN_T);
qglDisable(GL_TEXTURE_GEN_R);
qglDisable(GL_TEXTURE_GEN_Q);
checkerror();
#endif
} }
@ -1655,21 +1606,13 @@ static void Sh_WorldLightingPass(void)
} }
} }
#pragma message("move to header")
void BE_BaseEntTextures(void);
/* /*
draws faces facing the light draws faces facing the light
Note: Backend mode must have been selected in advance, as must the light to light from Note: Backend mode must have been selected in advance, as must the light to light from
*/ */
static void Sh_DrawEntLighting(dlight_t *light, vec3_t colour) static void Sh_DrawEntLighting(dlight_t *light, vec3_t colour)
{ {
mesh_t *meshchain, *surfmesh; int tno;
int tno, sno;
msurface_t *surf;
texture_t *tex; texture_t *tex;
shadowmesh_t *sm; shadowmesh_t *sm;
@ -1681,21 +1624,8 @@ static void Sh_DrawEntLighting(dlight_t *light, vec3_t colour)
{ {
if (!sm->litsurfs[tno].count) if (!sm->litsurfs[tno].count)
continue; continue;
meshchain = NULL; tex = cl.worldmodel->textures[tno];
tex = sm->litsurfs[tno].s[0]->texinfo->texture; BE_DrawMesh_List(tex->shader, sm->litsurfs[tno].count, sm->litsurfs[tno].s, &tex->vbo, &tex->shader->defaulttextures);
for (sno = 0; sno < sm->litsurfs[tno].count; sno++)
{
surf = sm->litsurfs[tno].s[sno];
// if (surf->visframe == r_visframecount)
{
/*was visible this frame*/
surfmesh = surf->mesh;
surfmesh->next = meshchain;
meshchain = surfmesh;
}
}
if (meshchain)
BE_DrawMeshChain(tex->shader, meshchain, &tex->vbo, &tex->shader->defaulttextures);
} }
BE_BaseEntTextures(); BE_BaseEntTextures();
@ -1709,8 +1639,8 @@ static void Sh_DrawEntLighting(dlight_t *light, vec3_t colour)
#pragma message "move to header"
void BE_PushOffsetShadow(qboolean foobar);
#define PROJECTION_DISTANCE (float)(dl->radius*2)//0x7fffffff #define PROJECTION_DISTANCE (float)(dl->radius*2)//0x7fffffff
@ -1739,6 +1669,8 @@ static void Sh_DrawBrushModelShadow(dlight_t *dl, entity_t *e)
qglEnableClientState(GL_VERTEX_ARRAY); qglEnableClientState(GL_VERTEX_ARRAY);
qglEnable(GL_VERTEX_ARRAY); qglEnable(GL_VERTEX_ARRAY);
BE_PushOffsetShadow(true);
model = e->model; model = e->model;
surf = model->surfaces+model->firstmodelsurface; surf = model->surfaces+model->firstmodelsurface;
for (i = 0; i < model->nummodelsurfaces; i++, surf++) for (i = 0; i < model->nummodelsurfaces; i++, surf++)
@ -1807,6 +1739,8 @@ static void Sh_DrawBrushModelShadow(dlight_t *dl, entity_t *e)
qglEnd(); qglEnd();
} }
qglPopMatrix(); qglPopMatrix();
BE_PushOffsetShadow(false);
} }
@ -1819,6 +1753,8 @@ static void Sh_DrawStencilLightShadows(dlight_t *dl, qbyte *lvis, qbyte *vvis, q
int i; int i;
struct shadowmesh_s *sm; struct shadowmesh_s *sm;
BE_PushOffsetShadow(false);
sm = SHM_BuildShadowVolumeMesh(dl, lvis, vvis); sm = SHM_BuildShadowVolumeMesh(dl, lvis, vvis);
if (!sm) if (!sm)
Sh_DrawBrushModelShadow(dl, &r_worldentity); Sh_DrawBrushModelShadow(dl, &r_worldentity);
@ -1848,19 +1784,13 @@ static void Sh_DrawStencilLightShadows(dlight_t *dl, qbyte *lvis, qbyte *vvis, q
{ {
currententity = &cl_visedicts[i]; currententity = &cl_visedicts[i];
if (currententity->flags & RF_NOSHADOW) if (currententity->flags & (RF_NOSHADOW|Q2RF_BEAM))
continue; continue;
{ {
if (currententity->keynum == dl->key && currententity->keynum) if (currententity->keynum == dl->key && currententity->keynum)
continue; continue;
} }
if (currententity->flags & Q2RF_BEAM)
{
R_DrawBeam(currententity);
continue;
}
if (!currententity->model) if (!currententity->model)
continue; continue;
@ -2065,7 +1995,7 @@ static qboolean Sh_DrawStencilLight(dlight_t *dl, vec3_t colour, qbyte *vvis)
} }
else if (qglActiveStencilFaceEXT) else if (qglActiveStencilFaceEXT)
{ {
/*personally I prefer the ATI way*/ /*personally I prefer the ATI way (nvidia method)*/
qglClearStencil(0); qglClearStencil(0);
qglClear(GL_STENCIL_BUFFER_BIT); qglClear(GL_STENCIL_BUFFER_BIT);
GL_CullFace(0); GL_CullFace(0);
@ -2089,7 +2019,7 @@ static qboolean Sh_DrawStencilLight(dlight_t *dl, vec3_t colour, qbyte *vvis)
qglActiveStencilFaceEXT(GL_FRONT); qglActiveStencilFaceEXT(GL_FRONT);
qglStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); qglStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
qglStencilFunc( GL_EQUAL, 0, ~0 ); qglStencilFunc( GL_EQUAL, 0, ~0 );
#pragma message("fixme: does this work properly on ati cards? cull front, but leave front as equals?")
qglDisable(GL_STENCIL_TEST_TWO_SIDE_EXT); qglDisable(GL_STENCIL_TEST_TWO_SIDE_EXT);
GL_CullFace(SHADER_CULL_FRONT); GL_CullFace(SHADER_CULL_FRONT);
@ -2150,27 +2080,7 @@ static qboolean Sh_DrawStencilLight(dlight_t *dl, vec3_t colour, qbyte *vvis)
qglDisable(GL_STENCIL_TEST); qglDisable(GL_STENCIL_TEST);
qglStencilFunc( GL_ALWAYS, 0, ~0 ); qglStencilFunc( GL_ALWAYS, 0, ~0 );
/*
if (developer.ival)
{
PPL_RevertToKnownState();
qglEnable(GL_BLEND);
qglBlendFunc(GL_ONE, GL_ONE);
qglDisable(GL_DEPTH_TEST);
qglDepthMask(0);
qglShadeModel (GL_SMOOTH);
qglDepthMask (0);
qglDisable (GL_TEXTURE_2D);
qglShadeModel (GL_SMOOTH);
qglEnable (GL_BLEND);
qglBlendFunc (GL_ONE, GL_ONE);
R_RenderDlight (dl);
qglEnable(GL_DEPTH_TEST);
qglShadeModel (GL_FLAT);
PPL_RevertToKnownState();
}
*/
checkerror(); checkerror();
return true; return true;
} }
@ -2231,7 +2141,10 @@ static void Sh_DrawShadowlessLight(dlight_t *dl, vec3_t colour, qbyte *vvis)
//sets up the gl scissor (and culls to view) //sets up the gl scissor (and culls to view)
if (Sh_ScissorForBox(mins, maxs)) if (Sh_ScissorForBox(mins, maxs))
{
bench.numscissorculled++;
return; //was culled. return; //was culled.
}
bench.numlights++; bench.numlights++;
@ -2296,13 +2209,13 @@ void Sh_DrawLights(qbyte *vis)
if (colour[0] < 0.001 && colour[1] < 0.001 && colour[2] < 0.001) if (colour[0] < 0.001 && colour[1] < 0.001 && colour[2] < 0.001)
continue; //just switch these off. continue; //just switch these off.
if (((!dl->die)?!r_shadow_realtime_world_shadows.value:!r_shadow_realtime_dlight_shadows.value) || dl->flags & LFLAG_NOSHADOWS) if (((!dl->die)?!r_shadow_realtime_world_shadows.ival:!r_shadow_realtime_dlight_shadows.ival) || dl->flags & LFLAG_NOSHADOWS)
{ {
Sh_DrawShadowlessLight(dl, colour, vis); Sh_DrawShadowlessLight(dl, colour, vis);
} }
else if (dl->flags & LFLAG_SHADOWMAP) else if (dl->flags & LFLAG_SHADOWMAP)
{ {
Sh_DrawLameSpotLightShadowMap(dl, colour); Sh_DrawShadowMapLight(dl, colour);
} }
else else
{ {
@ -2313,9 +2226,9 @@ void Sh_DrawLights(qbyte *vis)
qglDisable(GL_SCISSOR_TEST); qglDisable(GL_SCISSOR_TEST);
BE_SelectMode(BEM_STANDARD, 0); BE_SelectMode(BEM_STANDARD, 0);
if (developer.value) // if (developer.value)
Con_Printf("%i lights drawn, %i frustum culled, %i pvs culled, %i scissor culled\n", bench.numlights, bench.numfrustumculled, bench.numpvsculled, bench.numscissorculled); // Con_Printf("%i lights drawn, %i frustum culled, %i pvs culled, %i scissor culled\n", bench.numlights, bench.numfrustumculled, bench.numpvsculled, bench.numscissorculled);
memset(&bench, 0, sizeof(bench)); // memset(&bench, 0, sizeof(bench));
} }
#endif #endif
#endif #endif

View file

@ -12,6 +12,7 @@ void (APIENTRY *qglClear) (GLbitfield mask);
void (APIENTRY *qglClearColor) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); void (APIENTRY *qglClearColor) (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha);
void (APIENTRY *qglClearDepth) (GLclampd depth); void (APIENTRY *qglClearDepth) (GLclampd depth);
void (APIENTRY *qglClearStencil) (GLint s); void (APIENTRY *qglClearStencil) (GLint s);
void (APIENTRY *qglClipPlane) (GLenum plane, const GLdouble *equation);
void (APIENTRY *qglColor3f) (GLfloat red, GLfloat green, GLfloat blue); void (APIENTRY *qglColor3f) (GLfloat red, GLfloat green, GLfloat blue);
void (APIENTRY *qglColor3ub) (GLubyte red, GLubyte green, GLubyte blue); void (APIENTRY *qglColor3ub) (GLubyte red, GLubyte green, GLubyte blue);
void (APIENTRY *qglColor4f) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); void (APIENTRY *qglColor4f) (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha);
@ -200,6 +201,10 @@ static unsigned int gl_num_extensions;
qboolean GL_CheckExtension(char *extname) qboolean GL_CheckExtension(char *extname)
{ {
int i; int i;
cvar_t *v = Cvar_Get(va("gl_ext_%s", extname), "1", 0, "GL Extensions");
if (v && !v->ival)
return false;
if (gl_num_extensions && qglGetStringi) if (gl_num_extensions && qglGetStringi)
{ {
for (i = 0; i < gl_num_extensions; i++) for (i = 0; i < gl_num_extensions; i++)
@ -290,6 +295,7 @@ void GL_CheckExtensions (void *(*getglfunction) (char *name))
gl_config.arb_texture_cube_map = false; gl_config.arb_texture_cube_map = false;
gl_config.arb_shader_objects = false; gl_config.arb_shader_objects = false;
gl_config.ext_framebuffer_objects = false;
gl_config.ext_texture_filter_anisotropic = 0; gl_config.ext_texture_filter_anisotropic = 0;
@ -389,17 +395,19 @@ void GL_CheckExtensions (void *(*getglfunction) (char *name))
qglUnlockArraysEXT = (void *)getglext("glUnlockArraysEXT"); qglUnlockArraysEXT = (void *)getglext("glUnlockArraysEXT");
} }
/*various combiner features*/
gl_config.tex_env_combine = GL_CheckExtension("GL_EXT_texture_env_combine"); gl_config.tex_env_combine = GL_CheckExtension("GL_EXT_texture_env_combine");
gl_config.env_add = GL_CheckExtension("GL_EXT_texture_env_add"); gl_config.env_add = GL_CheckExtension("GL_EXT_texture_env_add");
gl_config.nv_tex_env_combine4 = GL_CheckExtension("GL_NV_texture_env_combine4"); gl_config.nv_tex_env_combine4 = GL_CheckExtension("GL_NV_texture_env_combine4");
gl_config.arb_texture_env_combine = GL_CheckExtension("GL_ARB_texture_env_combine"); gl_config.arb_texture_env_combine = GL_CheckExtension("GL_ARB_texture_env_combine");
gl_config.arb_texture_env_dot3 = GL_CheckExtension("GL_ARB_texture_env_dot3"); gl_config.arb_texture_env_dot3 = GL_CheckExtension("GL_ARB_texture_env_dot3");
gl_config.arb_texture_cube_map = GL_CheckExtension("GL_ARB_texture_cube_map"); gl_config.arb_texture_cube_map = GL_CheckExtension("GL_ARB_texture_cube_map");
if (gl_mtexarbable && gl_config.arb_texture_cube_map && gl_config.arb_texture_env_combine && gl_config.arb_texture_env_dot3 && !COM_CheckParm("-nobump") && gl_bump.value) if (gl_mtexarbable && gl_config.arb_texture_cube_map && gl_config.arb_texture_env_combine && gl_config.arb_texture_env_dot3 && !COM_CheckParm("-nobump") && gl_bump.value)
gl_bumpmappingpossible = true; gl_bumpmappingpossible = true;
/*vbos*/
if (GL_CheckExtension("GL_ARB_vertex_buffer_object")) if (GL_CheckExtension("GL_ARB_vertex_buffer_object"))
{ {
qglGenBuffersARB = (void *)getglext("glGenBuffersARB"); qglGenBuffersARB = (void *)getglext("glGenBuffersARB");
@ -425,9 +433,9 @@ void GL_CheckExtensions (void *(*getglfunction) (char *name))
// glslang // glslang
//the gf2 to gf4 cards emulate vertex_shader and thus supports shader_objects. //the gf2 to gf4 cards emulate vertex_shader and thus supports shader_objects.
//but our code kinda requires both for clean workings. //but our code kinda requires both for clean workings.
if (GL_CheckExtension("GL_ARB_fragment_shader")) if (GL_CheckExtension("GL_ARB_fragment_shader")
if (GL_CheckExtension("GL_ARB_vertex_shader")) && GL_CheckExtension("GL_ARB_vertex_shader")
if (GL_CheckExtension("GL_ARB_shader_objects")) && GL_CheckExtension("GL_ARB_shader_objects"))
{ {
gl_config.arb_shader_objects = true; gl_config.arb_shader_objects = true;
qglCreateProgramObjectARB = (void *)getglext("glCreateProgramObjectARB"); qglCreateProgramObjectARB = (void *)getglext("glCreateProgramObjectARB");
@ -450,8 +458,9 @@ void GL_CheckExtensions (void *(*getglfunction) (char *name))
qglUniform1fARB = (void *)getglext("glUniform1fARB"); qglUniform1fARB = (void *)getglext("glUniform1fARB");
} }
if (GL_CheckExtension("GL_ARB_fragment_shader")) if (GL_CheckExtension("GL_EXT_framebuffer_object"))
{ {
gl_config.ext_framebuffer_objects = true;
qglGenFramebuffersEXT = (void *)getglext("glGenFramebuffersEXT"); qglGenFramebuffersEXT = (void *)getglext("glGenFramebuffersEXT");
qglDeleteFramebuffersEXT = (void *)getglext("glDeleteFramebuffersEXT"); qglDeleteFramebuffersEXT = (void *)getglext("glDeleteFramebuffersEXT");
qglBindFramebufferEXT = (void *)getglext("glBindFramebufferEXT"); qglBindFramebufferEXT = (void *)getglext("glBindFramebufferEXT");
@ -603,6 +612,7 @@ void GL_Init(void *(*getglfunction) (char *name))
qglClearColor = (void *)getglcore("glClearColor"); qglClearColor = (void *)getglcore("glClearColor");
qglClearDepth = (void *)getglcore("glClearDepth"); qglClearDepth = (void *)getglcore("glClearDepth");
qglClearStencil = (void *)getglcore("glClearStencil"); qglClearStencil = (void *)getglcore("glClearStencil");
qglClipPlane = (void *)getglcore("glClipPlane");
qglColor3f = (void *)getglcore("glColor3f"); qglColor3f = (void *)getglcore("glColor3f");
qglColor3ub = (void *)getglcore("glColor3ub"); qglColor3ub = (void *)getglcore("glColor3ub");
qglColor4f = (void *)getglcore("glColor4f"); qglColor4f = (void *)getglcore("glColor4f");
@ -818,11 +828,6 @@ rendererinfo_t openglrendererinfo = {
Surf_AddStain, Surf_AddStain,
Surf_LessenStains, Surf_LessenStains,
MediaGL_ShowFrameBGR_24_Flip,
MediaGL_ShowFrameRGBA_32,
MediaGL_ShowFrame8bit,
RMod_Init, RMod_Init,
RMod_ClearAll, RMod_ClearAll,
RMod_ForName, RMod_ForName,

View file

@ -132,8 +132,6 @@ unsigned char vid_curpal[256*3];
HGLRC baseRC; HGLRC baseRC;
HDC maindc; HDC maindc;
glvert_t glv;
HWND WINAPI InitializeWindow (HINSTANCE hInstance, int nCmdShow); HWND WINAPI InitializeWindow (HINSTANCE hInstance, int nCmdShow);
@ -199,6 +197,7 @@ void *getwglfunc(char *name)
{ {
FARPROC proc; FARPROC proc;
TRACE(("dbg: getwglfunc: %s: getting\n", name)); TRACE(("dbg: getwglfunc: %s: getting\n", name));
proc = GetProcAddress(hInstGL, name); proc = GetProcAddress(hInstGL, name);
if (!proc) if (!proc)
{ {
@ -267,9 +266,12 @@ qboolean GLInitialise (char *renderer)
if (!hInstGL) if (!hInstGL)
{ {
unsigned int emode;
strcpy(opengldllname, "opengl32"); strcpy(opengldllname, "opengl32");
Con_DPrintf ("Loading renderer dll \"%s\"", opengldllname); Con_DPrintf ("Loading renderer dll \"%s\"", opengldllname);
emode = SetErrorMode(SEM_FAILCRITICALERRORS); /*no annoying errors if they use glide*/
hInstGL = LoadLibrary(opengldllname); hInstGL = LoadLibrary(opengldllname);
SetErrorMode(emode);
if (hInstGL) if (hInstGL)
Con_DPrintf (" Success\n"); Con_DPrintf (" Success\n");
@ -476,31 +478,29 @@ qboolean VID_SetWindowedMode (rendererstate_t *info)
if ((i = COM_CheckParm("-conwidth")) != 0) if ((i = COM_CheckParm("-conwidth")) != 0)
vid.conwidth = Q_atoi(com_argv[i+1]); vid.width = Q_atoi(com_argv[i+1]);
else else
{ {
vid.conwidth = 640; vid.width = 640;
} }
vid.conwidth &= 0xfff8; // make it a multiple of eight vid.width &= 0xfff8; // make it a multiple of eight
if (vid.conwidth < 320) if (vid.width < 320)
vid.conwidth = 320; vid.width = 320;
// pick a conheight that matches with correct aspect // pick a conheight that matches with correct aspect
vid.conheight = vid.conwidth*3 / 4; vid.height = vid.width*3 / 4;
if ((i = COM_CheckParm("-conheight")) != 0) if ((i = COM_CheckParm("-conheight")) != 0)
vid.conheight = Q_atoi(com_argv[i+1]); vid.height = Q_atoi(com_argv[i+1]);
if (vid.conheight < 200) if (vid.height < 200)
vid.conheight = 200; vid.height = 200;
if (vid.conheight > info->height) if (vid.height > info->height)
vid.conheight = info->height; vid.height = info->height;
if (vid.conwidth > info->width) if (vid.width > info->width)
vid.conwidth = info->width; vid.width = info->width;
vid.width = vid.conwidth;
vid.height = vid.conheight;
vid.numpages = 2; vid.numpages = 2;
@ -601,29 +601,27 @@ qboolean VID_SetFullDIBMode (rendererstate_t *info)
if ((i = COM_CheckParm("-conwidth")) != 0) if ((i = COM_CheckParm("-conwidth")) != 0)
vid.conwidth = Q_atoi(com_argv[i+1]); vid.width = Q_atoi(com_argv[i+1]);
else else
vid.conwidth = 640; vid.width = 640;
vid.conwidth &= 0xfff8; // make it a multiple of eight vid.width &= 0xfff8; // make it a multiple of eight
if (vid.conwidth < 320) if (vid.width < 320)
vid.conwidth = 320; vid.width = 320;
// pick a conheight that matches with correct aspect // pick a conheight that matches with correct aspect
vid.conheight = vid.conwidth*3 / 4; vid.height = vid.width*3 / 4;
if ((i = COM_CheckParm("-conheight")) != 0) if ((i = COM_CheckParm("-conheight")) != 0)
vid.conheight = Q_atoi(com_argv[i+1]); vid.height = Q_atoi(com_argv[i+1]);
if (vid.conheight < 200) if (vid.height < 200)
vid.conheight = 200; vid.height = 200;
if (vid.conheight > info->height) if (vid.height > info->height)
vid.conheight = info->height; vid.height = info->height;
if (vid.conwidth > info->width) if (vid.width > info->width)
vid.conwidth = info->width; vid.width = info->width;
vid.width = vid.conwidth;
vid.height = vid.conheight;
vid.numpages = 2; vid.numpages = 2;
@ -1781,21 +1779,24 @@ qboolean GLVID_Is8bit(void) {
return is8bit; return is8bit;
} }
#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB
void VID_Init8bitPalette(void) void VID_Init8bitPalette(void)
{ {
#ifdef GL_USE8BITTEX
#ifdef GL_EXT_paletted_texture
#define GL_SHARED_TEXTURE_PALETTE_EXT 0x81FB
// Check for 8bit Extensions and initialize them. // Check for 8bit Extensions and initialize them.
int i; int i;
char thePalette[256*3]; char thePalette[256*3];
char *oldPalette, *newPalette; char *oldPalette, *newPalette;
qglColorTableEXT = (void *)qwglGetProcAddress("glColorTableEXT"); qglColorTableEXT = (void *)qwglGetProcAddress("glColorTableEXT");
if (!qglColorTableEXT || !GL_CheckExtension("GL_EXT_shared_texture_palette") || COM_CheckParm("-no8bit")) if (!qglColorTableEXT || !GL_CheckExtension("GL_EXT_shared_texture_palette") || COM_CheckParm("-no8bit"))
return; return;
Con_SafePrintf("8-bit GL extensions enabled.\n"); Con_SafePrintf("8-bit GL extensions enabled.\n");
qglEnable(GL_SHARED_TEXTURE_PALETTE_EXT); qglEnable(GL_SHARED_TEXTURE_PALETTE_EXT);
oldPalette = (char *) d_8to24rgbtable; //d_8to24table3dfx; oldPalette = (char *) d_8to24rgbtable; //d_8to24table3dfx;
newPalette = thePalette; newPalette = thePalette;
for (i=0;i<256;i++) for (i=0;i<256;i++)
@ -1808,6 +1809,9 @@ void VID_Init8bitPalette(void)
qglColorTableEXT(GL_SHARED_TEXTURE_PALETTE_EXT, GL_RGB, 256, GL_RGB, GL_UNSIGNED_BYTE, qglColorTableEXT(GL_SHARED_TEXTURE_PALETTE_EXT, GL_RGB, 256, GL_RGB, GL_UNSIGNED_BYTE,
(void *) thePalette); (void *) thePalette);
is8bit = TRUE; is8bit = TRUE;
#endif
#endif
} }
void GLVID_DeInit (void) void GLVID_DeInit (void)

View file

@ -25,44 +25,40 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#include "shader.h" #include "shader.h"
#include <ctype.h> #include <ctype.h>
static void R_CalcSkyChainBounds (msurface_t *s); static void R_CalcSkyChainBounds (batch_t *s);
static void GL_DrawSkyGrid (texture_t *tex); static void GL_DrawSkyGrid (texture_t *tex);
static void GL_DrawSkySphere (msurface_t *fa); static void GL_DrawSkySphere (batch_t *fa, shader_t *shader);
static void GL_SkyForceDepth(msurface_t *fa); static void GL_SkyForceDepth(batch_t *fa);
static void GL_DrawSkyBox (texid_t *texnums, msurface_t *s); static void GL_DrawSkyBox (texid_t *texnums, batch_t *s);
//static int skytexturenum;
static float speedscale; // for top sky and bottom sky static float speedscale; // for top sky and bottom sky
//static float skyrotate;
//static vec3_t skyaxis;
//static qboolean usingskybox;
//static msurface_t *warpface;
//extern cvar_t r_skyboxname;
extern cvar_t gl_skyboxdist; extern cvar_t gl_skyboxdist;
extern cvar_t r_fastsky; extern cvar_t r_fastsky;
extern cvar_t r_fastskycolour; extern cvar_t r_fastskycolour;
//static char defaultskybox[MAX_QPATH];
//static int skyprogram; static shader_t *forcedskyshader;
//static int skyprogram_time; static shader_t *skyboxface;
//static int skyprogram_eyepos;
//static int waterprogram;
//static int waterprogram_time;
static qboolean overrideskybox;
static texid_t overrideskyboxtex[6];
//static vec3_t glskycolor;
//========================================================= //=========================================================
void R_SetSky(char *skyname)
{
if (*skyname)
forcedskyshader = R_RegisterCustom(va("skybox_%s", skyname), Shader_DefaultSkybox, NULL);
else
forcedskyshader = NULL;
skyboxface = R_RegisterShader("skyboxface",
"{\n"
"{\n"
"map $diffuse\n"
"}\n"
"}\n"
);
}
/* /*
================= =================
@ -70,36 +66,45 @@ GL_DrawSkyChain
================= =================
*/ */
#ifdef GLQUAKE #ifdef GLQUAKE
static void R_DrawSkyBoxChain (msurface_t *s); void R_DrawSkyChain (batch_t *batch)
void R_DrawSkyChain (msurface_t *s)
{ {
shader_t *skyshader;
texid_t *skyboxtex; texid_t *skyboxtex;
skyboxtex = s->texinfo->texture->shader->skydome->farbox_textures; if (forcedskyshader)
skyshader = forcedskyshader;
else
skyshader = batch->shader;
R_CalcSkyChainBounds(s); if (skyshader->skydome)
skyboxtex = skyshader->skydome->farbox_textures;
else
skyboxtex = NULL;
#ifdef GLQUAKE if (qrenderer == QR_OPENGL && skyboxtex && TEXVALID(*skyboxtex))
if (qrenderer == QR_OPENGL)
{ {
GL_DrawSkyBox (skyboxtex, s); R_CalcSkyChainBounds(batch);
GL_SkyForceDepth(s); GL_DrawSkyBox (skyboxtex, batch);
GL_SkyForceDepth(batch);
return; return;
} }
#endif
if (*r_fastsky.string) if (*r_fastsky.string)
{ {
GL_DrawSkyGrid(s->texinfo->texture); R_CalcSkyChainBounds(batch);
GL_SkyForceDepth(s);
R_IBrokeTheArrays();
GL_DrawSkyGrid(batch->texture);
R_IBrokeTheArrays();
GL_SkyForceDepth(batch);
} }
else else
{ {
GL_DrawSkySphere(s); GL_DrawSkySphere(batch, skyshader);
GL_SkyForceDepth(s); GL_SkyForceDepth(batch);
} }
R_IBrokeTheArrays();
} }
#endif #endif
@ -119,7 +124,6 @@ static vec3_t skyclip[6] = {
{1,0,1}, {1,0,1},
{-1,0,1} {-1,0,1}
}; };
static int c_sky;
// 1 = s, 2 = t, 3 = 2048 // 1 = s, 2 = t, 3 = 2048
static int st_to_vec[6][3] = static int st_to_vec[6][3] =
@ -163,8 +167,6 @@ static void DrawSkyPolygon (int nump, vec3_t vecs)
int axis; int axis;
float *vp; float *vp;
c_sky++;
// decide which face it maps to // decide which face it maps to
VectorClear (v); VectorClear (v);
for (i=0, vp=vecs ; i<nump ; i++, vp+=3) for (i=0, vp=vecs ; i<nump ; i++, vp+=3)
@ -327,15 +329,13 @@ static void ClipSkyPolygon (int nump, vec3_t vecs, int stage)
R_DrawSkyBoxChain R_DrawSkyBoxChain
================= =================
*/ */
static void R_CalcSkyChainBounds (msurface_t *s) static void R_CalcSkyChainBounds (batch_t *batch)
{ {
msurface_t *fa; mesh_t *mesh;
int i; int i, m;
vec3_t verts[MAX_CLIP_VERTS]; vec3_t verts[MAX_CLIP_VERTS];
c_sky = 0;
for (i=0 ; i<6 ; i++) for (i=0 ; i<6 ; i++)
{ {
skymins[0][i] = skymins[1][i] = 9999; skymins[0][i] = skymins[1][i] = 9999;
@ -343,15 +343,15 @@ static void R_CalcSkyChainBounds (msurface_t *s)
} }
// calculate vertex values for sky box // calculate vertex values for sky box
for (m = batch->firstmesh; m < batch->meshes; m++)
for (fa=s ; fa ; fa=fa->texturechain)
{ {
mesh = batch->mesh[m];
//triangulate //triangulate
for (i=2 ; i<fa->mesh->numvertexes ; i++) for (i=2 ; i<mesh->numvertexes ; i++)
{ {
VectorSubtract (fa->mesh->xyz_array[0], r_origin, verts[0]); VectorSubtract (mesh->xyz_array[0], r_origin, verts[0]);
VectorSubtract (fa->mesh->xyz_array[i-1], r_origin, verts[1]); VectorSubtract (mesh->xyz_array[i-1], r_origin, verts[1]);
VectorSubtract (fa->mesh->xyz_array[i], r_origin, verts[2]); VectorSubtract (mesh->xyz_array[i], r_origin, verts[2]);
ClipSkyPolygon (3, verts[0], 0); ClipSkyPolygon (3, verts[0], 0);
} }
} }
@ -370,92 +370,6 @@ static int skymade;
static index_t skysphere_element3i[skysphere_numtriangles * 3]; static index_t skysphere_element3i[skysphere_numtriangles * 3];
static float skysphere_texcoord2f[skysphere_numverts * 2]; static float skysphere_texcoord2f[skysphere_numverts * 2];
#ifdef D3DQUAKE
static float skysphere_d3dvertex[skysphere_numverts * 5];
static d3d_animateskysphere(float time)
{
int i;
float *d3dvert, *texcoord2f;
d3dvert = skysphere_d3dvertex;
texcoord2f = skysphere_texcoord2f;
for (i = 0; i < skysphere_numverts; i++)
{
d3dvert[3] = time+*texcoord2f++;
d3dvert[4] = time+*texcoord2f++;
d3dvert+=5;
}
}
static void d3d_skyspherecalc(int skytype)
{ //yes, this is basically stolen from DarkPlaces
int i, j;
index_t *e;
float a, b, x, ax, ay, v[3], length, *d3dvert, *texcoord2f;
float dx, dy, dz;
float texscale;
if (skymade == skytype+500)
return;
skymade = skytype+500;
if (skytype == 2)
texscale = 1/16.0f;
else
texscale = 1/1.5f;
texscale*=3;
dx = 16;
dy = 16;
dz = 16 / 3;
d3dvert = skysphere_d3dvertex;
texcoord2f = skysphere_texcoord2f;
for (j = 0;j <= skygridy;j++)
{
a = j * skygridyrecip;
ax = cos(a * M_PI * 2);
ay = -sin(a * M_PI * 2);
for (i = 0;i <= skygridx;i++)
{
b = i * skygridxrecip;
x = cos((b + 0.5) * M_PI);
v[0] = ax*x * dx;
v[1] = ay*x * dy;
v[2] = -sin((b + 0.5) * M_PI) * dz;
length = texscale / sqrt(v[0]*v[0]+v[1]*v[1]+(v[2]*v[2]*9));
*d3dvert++ = v[0]*1000;
*d3dvert++ = v[1]*1000;
*d3dvert++ = v[2]*1000;
d3dvert+=2;
*texcoord2f++ = v[0] * length;
*texcoord2f++ = v[1] * length;
}
}
e = skysphere_element3i;
for (j = 0;j < skygridy;j++)
{
for (i = 0;i < skygridx;i++)
{
*e++ = j * skygridx1 + i;
*e++ = j * skygridx1 + i + 1;
*e++ = (j + 1) * skygridx1 + i;
*e++ = j * skygridx1 + i + 1;
*e++ = (j + 1) * skygridx1 + i + 1;
*e++ = (j + 1) * skygridx1 + i;
}
}
}
#endif
#ifdef GLQUAKE #ifdef GLQUAKE
static vecV_t skysphere_vertex3f[skysphere_numverts]; static vecV_t skysphere_vertex3f[skysphere_numverts];
static mesh_t skymesh; static mesh_t skymesh;
@ -533,53 +447,17 @@ static void gl_skyspherecalc(int skytype)
} }
} }
static void GL_SkyForceDepth(msurface_t *fa) static void GL_SkyForceDepth(batch_t *batch)
{ {
vbo_t *v;
mesh_t *m;
if (!cls.allow_skyboxes) //allow a little extra fps. if (!cls.allow_skyboxes) //allow a little extra fps.
{//Draw the texture chain to only the depth buffer. {
v = &fa->texinfo->texture->vbo; BE_SelectMode(BEM_DEPTHONLY, 0);
qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, v->vboe); BE_DrawMesh_List(batch->shader, batch->meshes-batch->firstmesh, batch->mesh+batch->firstmesh, &batch->texture->vbo, &batch->shader->defaulttextures);
qglBindBufferARB(GL_ARRAY_BUFFER_ARB, v->vbocoord); BE_SelectMode(BEM_STANDARD, 0); /*skys only render in standard mode anyway, so this is safe*/
qglVertexPointer(3, GL_FLOAT, 0, v->coord);
qglDisable(GL_TEXTURE_2D);
if (qglColorMask)
qglColorMask(0,0,0,0);
for (; fa; fa = fa->texturechain)
{
m = fa->mesh;
qglDrawRangeElements(GL_TRIANGLES, m->vbofirstvert, m->vbofirstvert+m->numvertexes, m->numindexes, GL_INDEX_TYPE, v->indicies+m->vbofirstelement);
}
if (qglColorMask)
qglColorMask(1,1,1,1);
qglBindBufferARB(GL_ELEMENT_ARRAY_BUFFER_ARB, 0);
qglBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
R_IBrokeTheArrays();
} }
} }
static void FTE_DEPRECATED GL_DrawAliasMesh (mesh_t *mesh, texid_t texnum) static void GL_DrawSkySphere (batch_t *batch, shader_t *shader)
{
shader_t shader;
memset(&shader, 0, sizeof(shader));
shader.numpasses = 1;
shader.passes[0].numMergedPasses = 1;
shader.passes[0].anim_frames[0] = texnum;
shader.passes[0].rgbgen = RGB_GEN_IDENTITY;
shader.passes[0].alphagen = ALPHA_GEN_IDENTITY;
shader.passes[0].shaderbits |= SBITS_MISC_DEPTHWRITE;
shader.passes[0].blendmode = GL_MODULATE;
shader.passes[0].texgen = T_GEN_SINGLEMAP;
BE_DrawMeshChain(&shader, mesh, NULL, NULL);
}
static void GL_DrawSkySphere (msurface_t *fa)
{ {
extern cvar_t gl_maxdist; extern cvar_t gl_maxdist;
float time = cl.gametime+realtime-cl.gametimemark; float time = cl.gametime+realtime-cl.gametimemark;
@ -594,36 +472,9 @@ static void GL_DrawSkySphere (msurface_t *fa)
qglTranslatef(r_refdef.vieworg[0], r_refdef.vieworg[1], r_refdef.vieworg[2]); qglTranslatef(r_refdef.vieworg[0], r_refdef.vieworg[1], r_refdef.vieworg[2]);
qglScalef(skydist, skydist, skydist); qglScalef(skydist, skydist, skydist);
//draw in bulk? this is eeevil
//FIXME: We should use the skybox clipping code and split the sphere into 6 sides. //FIXME: We should use the skybox clipping code and split the sphere into 6 sides.
if (fa->texinfo->texture->shader) gl_skyspherecalc(2);
{ //the shader route. BE_DrawMesh_Single(shader, &skymesh, NULL, &batch->shader->defaulttextures);
meshbuffer_t mb;
gl_skyspherecalc(2);
mb.infokey = -1;
mb.dlightbits = 0;
mb.entity = &r_worldentity;
mb.shader = fa->texinfo->texture->shader;
mb.fog = NULL;
mb.mesh = &skymesh;
R_PushMesh(mb.mesh, mb.shader->features);
R_RenderMeshBuffer(&mb, false);
}
else
{ //the boring route.
gl_skyspherecalc(1);
qglMatrixMode(GL_TEXTURE);
qglPushMatrix();
qglTranslatef(time*8/128, time*8/128, 0);
GL_DrawAliasMesh(&skymesh, fa->texinfo->texture->shader->defaulttextures.base);
qglColor4f(1,1,1,0.5);
qglEnable(GL_BLEND);
qglTranslatef(time*8/128, time*8/128, 0);
GL_DrawAliasMesh(&skymesh, fa->texinfo->texture->shader->defaulttextures.fullbright);
qglDisable(GL_BLEND);
qglPopMatrix();
qglMatrixMode(GL_MODELVIEW);
}
qglPopMatrix(); qglPopMatrix();
} }
#endif #endif
@ -631,19 +482,16 @@ static void GL_DrawSkySphere (msurface_t *fa)
#ifdef GLQUAKE #ifdef GLQUAKE
static void GL_MakeSkyVec (float s, float t, int axis) static void GL_MakeSkyVec (float s, float t, int axis, float *vc, float *tc)
{ {
vec3_t v, b; vec3_t b;
int j, k; int j, k;
float skydist = gl_skyboxdist.value; float skydist = gl_skyboxdist.value;
extern cvar_t gl_maxdist; extern cvar_t gl_maxdist;
if (!skydist) if (!skydist)
{ {
// if (r_shadows.value || !gl_maxdist.value) skydist = gl_maxdist.value * 0.577;
// skydist = 1000000; //inifite distance
// else
skydist = gl_maxdist.value * 0.577;
} }
b[0] = s*skydist; b[0] = s*skydist;
@ -654,9 +502,9 @@ static void GL_MakeSkyVec (float s, float t, int axis)
{ {
k = st_to_vec[axis][j]; k = st_to_vec[axis][j];
if (k < 0) if (k < 0)
v[j] = -b[-k - 1]; vc[j] = -b[-k - 1];
else else
v[j] = b[k - 1]; vc[j] = b[k - 1];
} }
// avoid bilerp seam // avoid bilerp seam
@ -672,9 +520,8 @@ static void GL_MakeSkyVec (float s, float t, int axis)
else if (t > 511.0/512) else if (t > 511.0/512)
t = 511.0/512; t = 511.0/512;
t = 1.0 - t; tc[0] = s;
qglTexCoord2f (s, t); tc[1] = 1.0 - t;
qglVertex3fv (v);
} }
@ -714,10 +561,7 @@ static void MakeSkyGridVec2 (float s, float t, int axis, vec3_t v)
if (!skydist) if (!skydist)
{ {
// if (r_shadows.value || !gl_maxdist.value) skydist = gl_maxdist.value * 0.577;
// skydist = 1000000; //inifite distance
// else
skydist = gl_maxdist.value * 0.577;
} }
b[0] = s*skydist; b[0] = s*skydist;
@ -819,10 +663,15 @@ R_DrawSkyBox
*/ */
static int skytexorder[6] = {0,2,1,3,4,5}; static int skytexorder[6] = {0,2,1,3,4,5};
#ifdef GLQUAKE #ifdef GLQUAKE
static void GL_DrawSkyBox (texid_t *texnums, msurface_t *s) static void GL_DrawSkyBox (texid_t *texnums, batch_t *s)
{ {
int i; int i;
vecV_t skyface_vertex[4];
vec2_t skyface_texcoord[4];
index_t skyface_index[6] = {0, 1, 2, 0, 2, 3};
mesh_t skyfacemesh = {0};
if (cl.skyrotate) if (cl.skyrotate)
{ {
for (i=0 ; i<6 ; i++) for (i=0 ; i<6 ; i++)
@ -852,20 +701,25 @@ static void GL_DrawSkyBox (texid_t *texnums, msurface_t *s)
if (cl.skyrotate) if (cl.skyrotate)
qglRotatef (cl.time * cl.skyrotate, cl.skyaxis[0], cl.skyaxis[1], cl.skyaxis[2]); qglRotatef (cl.time * cl.skyrotate, cl.skyaxis[0], cl.skyaxis[1], cl.skyaxis[2]);
skyfacemesh.indexes = skyface_index;
skyfacemesh.st_array = skyface_texcoord;
skyfacemesh.xyz_array = skyface_vertex;
skyfacemesh.numindexes = 6;
skyfacemesh.numvertexes = 4;
for (i=0 ; i<6 ; i++) for (i=0 ; i<6 ; i++)
{ {
if (skymins[0][i] >= skymaxs[0][i] if (skymins[0][i] >= skymaxs[0][i]
|| skymins[1][i] >= skymaxs[1][i]) || skymins[1][i] >= skymaxs[1][i])
continue; continue;
GL_Bind (texnums[skytexorder[i]]); GL_MakeSkyVec (skymins[0][i], skymins[1][i], i, skyface_vertex[0], skyface_texcoord[0]);
GL_MakeSkyVec (skymins[0][i], skymaxs[1][i], i, skyface_vertex[1], skyface_texcoord[1]);
GL_MakeSkyVec (skymaxs[0][i], skymaxs[1][i], i, skyface_vertex[2], skyface_texcoord[2]);
GL_MakeSkyVec (skymaxs[0][i], skymins[1][i], i, skyface_vertex[3], skyface_texcoord[3]);
qglBegin (GL_QUADS); skyboxface->defaulttextures.base = texnums[skytexorder[i]];
GL_MakeSkyVec (skymins[0][i], skymins[1][i], i); BE_DrawMesh_Single(skyboxface, &skyfacemesh, NULL, &skyboxface->defaulttextures);
GL_MakeSkyVec (skymins[0][i], skymaxs[1][i], i);
GL_MakeSkyVec (skymaxs[0][i], skymaxs[1][i], i);
GL_MakeSkyVec (skymaxs[0][i], skymins[1][i], i);
qglEnd ();
} }
qglPopMatrix (); qglPopMatrix ();

View file

@ -129,6 +129,7 @@ typedef struct {
qboolean arb_texture_compression; qboolean arb_texture_compression;
// qboolean arb_fragment_program; // qboolean arb_fragment_program;
qboolean arb_shader_objects; qboolean arb_shader_objects;
qboolean ext_framebuffer_objects;
qboolean ext_stencil_wrap; qboolean ext_stencil_wrap;
int ext_texture_filter_anisotropic; int ext_texture_filter_anisotropic;
int maxtmus; //max texture units int maxtmus; //max texture units
@ -158,7 +159,7 @@ texid_t GL_FindTexture (char *identifier);
texid_t GL_LoadTextureFB (char *identifier, int width, int height, qbyte *data, unsigned int flags); texid_t GL_LoadTextureFB (char *identifier, int width, int height, qbyte *data, unsigned int flags);
void GL_Upload8Pal24 (qbyte *data, qbyte *pal, int width, int height, unsigned int flags); void GL_Upload8Pal24 (qbyte *data, qbyte *pal, int width, int height, unsigned int flags);
/*
typedef struct typedef struct
{ {
float x, y, z; float x, y, z;
@ -167,7 +168,7 @@ typedef struct
} glvert_t; } glvert_t;
FTE_DEPRECATED extern glvert_t glv; FTE_DEPRECATED extern glvert_t glv;
*/
#endif #endif
// r_local.h -- private refresh defs // r_local.h -- private refresh defs
@ -187,7 +188,6 @@ FTE_DEPRECATED extern glvert_t glv;
void R_TimeRefresh_f (void); void R_TimeRefresh_f (void);
FTE_DEPRECATED texture_t *SWR_TextureAnimation (texture_t *base);
#include "particles.h" #include "particles.h"
@ -220,7 +220,6 @@ extern int r_viewcluster, r_viewcluster2, r_oldviewcluster, r_oldviewcluster2;
extern texture_t *r_notexture_mip; extern texture_t *r_notexture_mip;
extern int d_lightstylevalue[256]; // 8.8 fraction of base light value extern int d_lightstylevalue[256]; // 8.8 fraction of base light value
FTE_DEPRECATED extern qboolean envmap;
extern texid_t netgraphtexture; // netgraph texture extern texid_t netgraphtexture; // netgraph texture
extern int gl_lightmap_format; extern int gl_lightmap_format;
@ -293,24 +292,13 @@ void FTE_DEPRECATED R_BackendInit(void);
void FTE_DEPRECATED R_IBrokeTheArrays(void); void FTE_DEPRECATED R_IBrokeTheArrays(void);
#endif #endif
void R_DrawSkyChain (msurface_t *s);
texnums_t R_InitSky (texture_t *mt);
// //
// gl_warp.c // gl_warp.c
// //
#ifdef GLQUAKE void R_DrawSkyChain (batch_t *batch); /*called from the backend, and calls back into it*/
void FTE_DEPRECATED GL_SubdivideSurface (msurface_t *fa, float dividesize); texnums_t R_InitSky (texture_t *mt); /*generate q1 sky texnums*/
void FTE_DEPRECATED GL_EmitBothSkyLayers (msurface_t *fa);
void R_DrawSkyBox (msurface_t *s);
void R_ForceSkyBox (void);
void R_AddSkySurface (msurface_t *fa);
#endif
#ifdef D3DQUAKE
void D3D7_DrawSkyChain (msurface_t *s);
void D3D9_DrawSkyChain (msurface_t *s);
#endif
// //
// gl_draw.c // gl_draw.c
@ -323,6 +311,7 @@ void GL_Set2D (void);
// //
// gl_rmain.c // gl_rmain.c
// //
qboolean R_ShouldDraw(entity_t *e);
qboolean R_CullBox (vec3_t mins, vec3_t maxs); qboolean R_CullBox (vec3_t mins, vec3_t maxs);
#ifdef GLQUAKE #ifdef GLQUAKE
qboolean R_CullSphere (vec3_t origin, float radius); qboolean R_CullSphere (vec3_t origin, float radius);
@ -378,23 +367,10 @@ void R_InitBloomTextures(void);
// gl_rsurf.c // gl_rsurf.c
// //
#ifdef GLQUAKE #ifdef GLQUAKE
FTE_DEPRECATED void R_DrawBrushModel (entity_t *e);
void GL_LoadShaders(void); void GL_LoadShaders(void);
#endif #endif
//gl_ppl.c
FTE_DEPRECATED void PPL_DrawWorld (qbyte *viewvis);
FTE_DEPRECATED qboolean PPL_ShouldDraw(void);
FTE_DEPRECATED void RotateLightVector(const vec3_t *angles, const vec3_t origin, const vec3_t lightpoint, vec3_t result);
//
// gl_refrag.c
//
void R_StoreEfrags (efrag_t **ppefrag);
// //
// gl_ngraph.c // gl_ngraph.c
// //

View file

@ -20,12 +20,14 @@ typedef enum {
typedef enum { typedef enum {
SHADER_SORT_NONE, SHADER_SORT_NONE,
SHADER_SORT_SKY,
SHADER_SORT_PORTAL, SHADER_SORT_PORTAL,
SHADER_SORT_SKY,
SHADER_SORT_OPAQUE, SHADER_SORT_OPAQUE,
SHADER_SORT_DECAL,
SHADER_SORT_SEETHROUGH,
SHADER_SORT_BANNER, SHADER_SORT_BANNER,
SHADER_SORT_UNDERWATER, SHADER_SORT_UNDERWATER,
SHADER_SORT_DECAL, SHADER_SORT_BLEND,
SHADER_SORT_ADDITIVE, SHADER_SORT_ADDITIVE,
SHADER_SORT_NEAREST SHADER_SORT_NEAREST
} shadersort_t; } shadersort_t;
@ -56,17 +58,6 @@ typedef struct
float args[4]; // offset, amplitude, phase_offset, rate float args[4]; // offset, amplitude, phase_offset, rate
} shaderfunc_t; } shaderfunc_t;
typedef struct meshbuffer_s
{
int infokey; // lightmap number or mesh number
unsigned int dlightbits;
entity_t *entity;
struct shader_s *shader;
mesh_t *mesh;
struct mfog_s *fog;
} meshbuffer_t;
//tecture coordinate manipulation //tecture coordinate manipulation
typedef struct typedef struct
{ {
@ -282,6 +273,7 @@ typedef struct {
} polyoffset_t; } polyoffset_t;
struct shader_s struct shader_s
{ {
int uses;
int width; int width;
int height; int height;
int numpasses; int numpasses;
@ -292,6 +284,7 @@ struct shader_s
byte_vec4_t fog_color; byte_vec4_t fog_color;
float fog_dist; float fog_dist;
float portaldist;
int numdeforms; int numdeforms;
deformv_t deforms[SHADER_DEFORM_MAX]; deformv_t deforms[SHADER_DEFORM_MAX];
@ -334,14 +327,14 @@ struct shader_s
const char *genargs; const char *genargs;
meshfeatures_t features; meshfeatures_t features;
bucket_t bucket;
int registration_sequence;
}; };
extern shader_t *r_shaders; extern shader_t *r_shaders;
extern int be_maxpasses; extern int be_maxpasses;
void R_UnloadShader(shader_t *shader);
shader_t *R_RegisterPic (char *name); shader_t *R_RegisterPic (char *name);
shader_t *R_RegisterShader (char *name, const char *shaderscript); shader_t *R_RegisterShader (char *name, const char *shaderscript);
shader_t *R_RegisterShader_Lightmap (char *name); shader_t *R_RegisterShader_Lightmap (char *name);
@ -351,10 +344,15 @@ shader_t *R_RegisterSkin (char *name);
shader_t *R_RegisterCustom (char *name, shader_gen_t *defaultgen, const void *args); shader_t *R_RegisterCustom (char *name, shader_gen_t *defaultgen, const void *args);
void R_BuildDefaultTexnums(texnums_t *tn, shader_t *shader); void R_BuildDefaultTexnums(texnums_t *tn, shader_t *shader);
cin_t *R_ShaderGetCinematic(char *name); cin_t *R_ShaderGetCinematic(shader_t *s);
cin_t *R_ShaderFindCinematic(char *name);
void Shader_DefaultSkinShell(char *shortname, shader_t *s, const void *args); void Shader_DefaultSkinShell(char *shortname, shader_t *s, const void *args);
void Shader_DefaultBSP(char *shortname, shader_t *s, const void *args); void Shader_DefaultBSPLM(char *shortname, shader_t *s, const void *args);
void Shader_DefaultBSPQ1(char *shortname, shader_t *s, const void *args);
void Shader_DefaultBSPQ2(char *shortname, shader_t *s, const void *args);
void Shader_DefaultSkybox(char *shortname, shader_t *s, const void *args);
void Shader_DefaultCinematic(char *shortname, shader_t *s, const void *args);
void Shader_DefaultScript(char *shortname, shader_t *s, const void *args); void Shader_DefaultScript(char *shortname, shader_t *s, const void *args);
void Shader_DoReload(void); void Shader_DoReload(void);
@ -373,6 +371,7 @@ typedef enum
BEM_STENCIL, //used for drawing shadow volumes to the stencil buffer. BEM_STENCIL, //used for drawing shadow volumes to the stencil buffer.
BEM_DEPTHDARK, //a quick depth pass. textures used only for alpha test. additive textures still shown as normal. BEM_DEPTHDARK, //a quick depth pass. textures used only for alpha test. additive textures still shown as normal.
BEM_LIGHT, //we have a valid light BEM_LIGHT, //we have a valid light
BEM_SMAPLIGHTSPOT, //we have a spot light using a shadowmap
BEM_SMAPLIGHT //we have a light using a shadowmap BEM_SMAPLIGHT //we have a light using a shadowmap
} backendmode_t; } backendmode_t;
@ -386,8 +385,10 @@ typedef enum
//Select the current render mode and modifier flags //Select the current render mode and modifier flags
void BE_SelectMode(backendmode_t mode, unsigned int flags); void BE_SelectMode(backendmode_t mode, unsigned int flags);
//Draws an entire mesh chain from a VBO. vbo can be null, in which case the chain may be drawn without batching. /*Draws an entire mesh list from a VBO. vbo can be null, in which case the chain may be drawn without batching.
void BE_DrawMeshChain(shader_t *shader, mesh_t *meshchain, vbo_t *vbo, texnums_t *texnums); Rules for using a list: Every mesh must be part of the same VBO, shader, lightmap, and must have the same pointers set*/
void BE_DrawMesh_List(shader_t *shader, int nummeshes, mesh_t **mesh, vbo_t *vbo, texnums_t *texnums);
void BE_DrawMesh_Single(shader_t *shader, mesh_t *meshchain, vbo_t *vbo, texnums_t *texnums);
//Asks the backend to invoke DrawMeshChain for each surface, and to upload lightmaps as required //Asks the backend to invoke DrawMeshChain for each surface, and to upload lightmaps as required
void BE_DrawWorld (qbyte *vis); void BE_DrawWorld (qbyte *vis);
@ -407,10 +408,11 @@ void BE_UploadAllLightmaps(void);
void BE_SubmitMeshes (void); void BE_SubmitMeshes (void);
//sets up gl for depth-only FIXME //sets up gl for depth-only FIXME
void BE_SetupForShadowMap(void); void BE_SetupForShadowMap(void);
//Generates shadow maps (called before anything is drawn in case it needs to clobber the normal view) //Called from shadowmapping code into backend
void Sh_GenShadowMaps (void); void BE_BaseEntTextures(void);
//Draws lights, called from the backend //Draws lights, called from the backend
void Sh_DrawLights(qbyte *vis); void Sh_DrawLights(qbyte *vis);
void Sh_Shutdown(void);
//Draws the depth of ents in the world near the current light //Draws the depth of ents in the world near the current light
void BE_BaseEntShadowDepth(void); void BE_BaseEntShadowDepth(void);
//Sets the given light+colour to be the current one that everything is to be lit/culled by. //Sets the given light+colour to be the current one that everything is to be lit/culled by.

View file

@ -225,7 +225,7 @@ static qboolean HTTP_DL_Work(struct dl_download *dl)
if (*dl->localname) if (*dl->localname)
{ {
FS_CreatePath(dl->localname, FS_GAME); FS_CreatePath(dl->localname, FS_GAME);
dl->file = FS_OpenVFS(dl->localname, "wb", FS_GAME); dl->file = FS_OpenVFS(dl->localname, "w+b", FS_GAME);
} }
else else
dl->file = FS_OpenTemp(); dl->file = FS_OpenTemp();

View file

@ -5,7 +5,7 @@
#ifndef HASH_H__ #ifndef HASH_H__
#define HASH_H__ #define HASH_H__
#define Hash_BytesForBuckets(b) (sizeof(bucket_t)*b) #define Hash_BytesForBuckets(b) (sizeof(bucket_t*)*b)
#define STRCMP(s1,s2) (((*s1)!=(*s2)) || strcmp(s1+1,s2+1)) //saves about 2-6 out of 120 - expansion of idea from fastqcc #define STRCMP(s1,s2) (((*s1)!=(*s2)) || strcmp(s1+1,s2+1)) //saves about 2-6 out of 120 - expansion of idea from fastqcc
typedef struct bucket_s { typedef struct bucket_s {

View file

@ -500,7 +500,10 @@ char *PR_ValueString (progfuncs_t *progfuncs, etype_t type, eval_t *val)
sprintf (line, "%s", PR_StringToNative(progfuncs, val->string)); sprintf (line, "%s", PR_StringToNative(progfuncs, val->string));
break; break;
case ev_entity: case ev_entity:
sprintf (line, "entity %i", NUM_FOR_EDICT(progfuncs, (struct edict_s *)PROG_TO_EDICT(progfuncs, val->edict)) ); // if (val->edict >= maxedicts)
sprintf (line, "entity %i", val->edict);
// else
// sprintf (line, "entity %i", NUM_FOR_EDICT(progfuncs, (struct edict_s *)PROG_TO_EDICT(progfuncs, val->edict)) );
break; break;
case ev_function: case ev_function:
if (!val->function) if (!val->function)
@ -511,8 +514,13 @@ char *PR_ValueString (progfuncs_t *progfuncs, etype_t type, eval_t *val)
sprintf (line, "Bad function"); sprintf (line, "Bad function");
else else
{ {
f = pr_progstate[(val->function & 0xff000000)>>24].functions + (val->function & ~0xff000000); if ((val->function &~0xff000000) >= pr_progs->numfunctions)
sprintf (line, "%i:%s()", (val->function & 0xff000000)>>24, f->s_name+progfuncs->stringtable); sprintf(line, "bad function %i:%i\n", (val->function & 0xff000000)>>24, val->function & ~0xff000000);
else
{
f = pr_progstate[(val->function & 0xff000000)>>24].functions + (val->function & ~0xff000000);
sprintf (line, "%i:%s()", (val->function & 0xff000000)>>24, f->s_name+progfuncs->stringtable);
}
} }
} }
break; break;
@ -1166,7 +1174,7 @@ char *ED_ParseEdict (progfuncs_t *progfuncs, char *data, edictrun_t *ent)
break; break;
if (!data) if (!data)
{ {
printf ("ED_ParseEntity: EOF without closing brace"); printf ("ED_ParseEntity: EOF without closing brace\n");
return NULL; return NULL;
} }
@ -1191,7 +1199,7 @@ char *ED_ParseEdict (progfuncs_t *progfuncs, char *data, edictrun_t *ent)
if (qcc_token[0] == '}') if (qcc_token[0] == '}')
{ {
printf ("ED_ParseEntity: closing brace without data"); printf ("ED_ParseEntity: closing brace without data\n");
return NULL; return NULL;
} }
@ -2827,8 +2835,12 @@ retry:
if (st16[i].op >= OP_CALL1 && st16[i].op <= OP_CALL8) if (st16[i].op >= OP_CALL1 && st16[i].op <= OP_CALL8)
{ {
if (st16[i].b) if (st16[i].b)
{
hexencalling = true; hexencalling = true;
#ifdef NOENDIAN
break;
#endif
}
} }
} }
if (hexencalling) if (hexencalling)

View file

@ -231,7 +231,7 @@ int QC_RegisterFieldVar(progfuncs_t *progfuncs, unsigned int type, char *name, i
{ {
if (field[i].type != type) if (field[i].type != type)
{ {
printf("Field type mismatch on \"%s\"\n", name); printf("Field type mismatch on \"%s\". %i != %i\n", name, field[i].type, type);
continue; continue;
} }
if (!progfuncs->fieldadjust && engineofs>=0) if (!progfuncs->fieldadjust && engineofs>=0)

View file

@ -1,5 +1,6 @@
#ifdef _WIN32 #ifdef _WIN32
#define _CRT_SECURE_NO_WARNINGS
#define _CRT_NONSTDC_NO_WARNINGS
#ifndef AVAIL_ZLIB #ifndef AVAIL_ZLIB
#ifdef _MSC_VER #ifdef _MSC_VER
//#define AVAIL_ZLIB //#define AVAIL_ZLIB

View file

@ -742,7 +742,7 @@ pbool QCC_WriteData (int crc)
// numfunctions++; // numfunctions++;
} }
else if (def->type->type == ev_field)// && !def->constant) else if (def->type->type == ev_field && def->constant)
{ {
dd = &fields[numfielddefs]; dd = &fields[numfielddefs];
numfielddefs++; numfielddefs++;

View file

@ -479,7 +479,7 @@ void NPP_NQWriteByte(int dest, qbyte data) //replacement write func (nq to qw)
default: default:
protocollen = sizeof(buffer); protocollen = sizeof(buffer);
Con_Printf("NQWriteByte: bad tempentity\n"); Con_Printf("NQWriteByte: bad tempentity %i\n", data);
PR_StackTrace(svprogfuncs); PR_StackTrace(svprogfuncs);
break; break;
} }

View file

@ -520,7 +520,7 @@ void PR_LoadGlabalStruct(void)
#define globalstring(need,name) ((nqglobalvars_t*)pr_globals)->name = (int *)PR_FindGlobal(svprogfuncs, #name, 0); if (need && !((nqglobalvars_t*)pr_globals)->name) SV_Error("Could not find export \""#name"\" in progs\n"); #define globalstring(need,name) ((nqglobalvars_t*)pr_globals)->name = (int *)PR_FindGlobal(svprogfuncs, #name, 0); if (need && !((nqglobalvars_t*)pr_globals)->name) SV_Error("Could not find export \""#name"\" in progs\n");
#define globalvec(need,name) ((nqglobalvars_t*)pr_globals)->V_##name = (vec3_t *)PR_FindGlobal(svprogfuncs, #name, 0); if (need && !((nqglobalvars_t*)pr_globals)->V_##name) SV_Error("Could not find export \""#name"\" in progs\n"); #define globalvec(need,name) ((nqglobalvars_t*)pr_globals)->V_##name = (vec3_t *)PR_FindGlobal(svprogfuncs, #name, 0); if (need && !((nqglobalvars_t*)pr_globals)->V_##name) SV_Error("Could not find export \""#name"\" in progs\n");
#define globalvec_(need,name) ((nqglobalvars_t*)pr_globals)->name = (vec3_t *)PR_FindGlobal(svprogfuncs, #name, 0); if (need && !((nqglobalvars_t*)pr_globals)->name) SV_Error("Could not find export \""#name"\" in progs\n"); #define globalvec_(need,name) ((nqglobalvars_t*)pr_globals)->name = (vec3_t *)PR_FindGlobal(svprogfuncs, #name, 0); if (need && !((nqglobalvars_t*)pr_globals)->name) SV_Error("Could not find export \""#name"\" in progs\n");
#define globalfunc(need,name) ((nqglobalvars_t*)pr_globals)->name = (func_t *)PR_FindGlobal(svprogfuncs, #name, 0); if (need && !((nqglobalvars_t*)pr_globals)->name) SV_Error("Could not find export \""#name"\" in progs\n"); #define globalfunc(need,name) ((nqglobalvars_t*)pr_globals)->name = (func_t *)PR_FindGlobal(svprogfuncs, #name, 0); if (need && !((nqglobalvars_t*)pr_globals)->name) {static func_t strippedout; strippedout = PR_FindFunction(svprogfuncs, #name, 0); if (strippedout) ((nqglobalvars_t*)pr_globals)->name = &strippedout; else SV_Error("Could not find function \""#name"\" in progs\n"); }
// globalint(pad); // globalint(pad);
globalint (true, self); //we need the qw ones, but any in standard quake and not quakeworld, we don't really care about. globalint (true, self); //we need the qw ones, but any in standard quake and not quakeworld, we don't really care about.
globalint (true, other); globalint (true, other);
@ -624,7 +624,7 @@ void PR_LoadGlabalStruct(void)
gfuncs.ClassChangeWeapon = PR_FindFunction(svprogfuncs, "ClassChangeWeapon", PR_ANY); gfuncs.ClassChangeWeapon = PR_FindFunction(svprogfuncs, "ClassChangeWeapon", PR_ANY);
gfuncs.RunClientCommand = PR_FindFunction(svprogfuncs, "SV_RunClientCommand", PR_ANY); gfuncs.RunClientCommand = PR_FindFunction(svprogfuncs, "SV_RunClientCommand", PR_ANY);
if (pr_no_playerphysics.value) if (pr_no_playerphysics.ival)
SV_PlayerPhysicsQC = 0; SV_PlayerPhysicsQC = 0;
else else
SV_PlayerPhysicsQC = PR_FindFunction(svprogfuncs, "SV_PlayerPhysics", PR_ANY); SV_PlayerPhysicsQC = PR_FindFunction(svprogfuncs, "SV_PlayerPhysics", PR_ANY);
@ -3145,6 +3145,8 @@ static void PF_cvar (progfuncs_t *prinst, struct globalvars_s *pr_globals)
char *def = ""; char *def = "";
if (!strcmp(str, "sv_maxairspeed")) if (!strcmp(str, "sv_maxairspeed"))
def = "30"; def = "30";
else if (!strcmp(str, "sv_jumpvelocity"))
def = "270";
else else
def = ""; def = "";
@ -8926,7 +8928,7 @@ void PF_checkpvs(progfuncs_t *prinst, struct globalvars_s *pr_globals)
//and yeah, this is overkill what with the whole fat thing and all. //and yeah, this is overkill what with the whole fat thing and all.
sv.world.worldmodel->funcs.FatPVS(sv.world.worldmodel, viewpos, qcpvs, sizeof(qcpvs), false); sv.world.worldmodel->funcs.FatPVS(sv.world.worldmodel, viewpos, qcpvs, sizeof(qcpvs), false);
G_FLOAT(OFS_RETURN) = sv.world.worldmodel->funcs.EdictInFatPVS(sv.world.worldmodel, (wedict_t*)ent, qcpvs); G_FLOAT(OFS_RETURN) = sv.world.worldmodel->funcs.EdictInFatPVS(sv.world.worldmodel, &((wedict_t*)ent)->pvsinfo, qcpvs);
} }
//entity(string match [, float matchnum]) matchclient = #241; //entity(string match [, float matchnum]) matchclient = #241;
@ -9508,6 +9510,7 @@ BuiltinList_t BuiltinList[] = { //nq qw h2 ebfs
//DP_QC_WHICHPACK //DP_QC_WHICHPACK
{"whichpack", PF_whichpack, 0, 0, 0, 503}, // #503 string(string filename) whichpack {"whichpack", PF_whichpack, 0, 0, 0, 503}, // #503 string(string filename) whichpack
//no 504
//DP_QC_URI_ESCAPE //DP_QC_URI_ESCAPE
{"uri_escape", PF_uri_escape, 0, 0, 0, 510}, // #510 string(string in) uri_escape {"uri_escape", PF_uri_escape, 0, 0, 0, 510}, // #510 string(string in) uri_escape
@ -9519,7 +9522,11 @@ BuiltinList_t BuiltinList[] = { //nq qw h2 ebfs
//DP_QC_URI_GET //DP_QC_URI_GET
{"uri_get", PF_uri_get, 0, 0, 0, 513}, // #513 float(string uril, float id) uri_get {"uri_get", PF_uri_get, 0, 0, 0, 513}, // #513 float(string uril, float id) uri_get
//no 504 {"tokenize_console",PF_tokenize_console,0, 0, 0, 514},
{"argv_start_index",PF_argv_start_index,0, 0, 0, 515},
{"argv_end_index", PF_argv_end_index, 0, 0, 0, 516},
{"buf_cvarlist", PF_buf_cvarlist, 0, 0, 0, 517},
{"cvar_description",PF_cvar_description,0, 0, 0, 518},
//end dp extras //end dp extras
{"precache_vwep_model",PF_precache_vwep_model,0,0, 0, 532}, // #532 float(string mname) precache_vwep_model {"precache_vwep_model",PF_precache_vwep_model,0,0, 0, 532}, // #532 float(string mname) precache_vwep_model

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