1
0
Fork 0
forked from fte/fteqw

CSQC support changes and some small bugfixes.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@874 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2005-02-12 18:56:04 +00:00
parent f4cfc008e1
commit acde8ade44
41 changed files with 861 additions and 444 deletions

View file

@ -2198,6 +2198,89 @@ void CL_LinkPlayers (void)
} }
} }
void CL_LinkViewModel(void)
{
entity_t ent;
// float ambient[4], diffuse[4];
// int j;
// int lnum;
// vec3_t dist;
// float add;
// dlight_t *dl;
// int ambientlight, shadelight;
static struct model_s *oldmodel[MAX_SPLITS];
static float lerptime[MAX_SPLITS];
static int prevframe[MAX_SPLITS];
static int oldframe[MAX_SPLITS];
#ifdef SIDEVIEWS
extern qboolean r_secondaryview;
if (r_secondaryview==1)
return;
#endif
if (!r_drawviewmodel.value || !Cam_DrawViewModel(r_refdef.currentplayernum))
return;
#ifdef Q2CLIENT
if (cls.q2server)
return;
#endif
if (!r_drawentities.value)
return;
if (cl.stats[r_refdef.currentplayernum][STAT_ITEMS] & IT_INVISIBILITY)
return;
if (cl.stats[r_refdef.currentplayernum][STAT_HEALTH] <= 0)
return;
memset(&ent, 0, sizeof(ent));
ent.model = cl.viewent[r_refdef.currentplayernum].model;
if (!ent.model)
return;
#ifdef PEXT_SCALE
ent.scale = 1;
#endif
if (r_drawviewmodel.value > 0 && r_drawviewmodel.value < 1)
ent.alpha = r_drawviewmodel.value;
else
ent.alpha = 1;
ent.frame = cl.viewent[r_refdef.currentplayernum].frame;
ent.oldframe = oldframe[r_refdef.currentplayernum];
if (ent.frame != prevframe[r_refdef.currentplayernum])
{
oldframe[r_refdef.currentplayernum] = ent.oldframe = prevframe[r_refdef.currentplayernum];
lerptime[r_refdef.currentplayernum] = realtime;
}
prevframe[r_refdef.currentplayernum] = ent.frame;
if (ent.model != oldmodel[r_refdef.currentplayernum])
{
oldmodel[r_refdef.currentplayernum] = ent.model;
oldframe[r_refdef.currentplayernum] = ent.oldframe = ent.frame;
lerptime[r_refdef.currentplayernum] = realtime;
}
ent.lerptime = 1-(realtime-lerptime[r_refdef.currentplayernum])*10;
if (ent.lerptime<0)ent.lerptime=0;
if (ent.lerptime>1)ent.lerptime=1;
#define Q2RF_VIEWERMODEL 2 // don't draw through eyes, only mirrors
#define Q2RF_WEAPONMODEL 4 // only draw through eyes
#define Q2RF_DEPTHHACK 16 // for view weapon Z crunching
ent.flags = Q2RF_WEAPONMODEL|Q2RF_DEPTHHACK;
V_AddEntity(&ent);
}
//====================================================================== //======================================================================
/* /*
@ -2401,6 +2484,20 @@ Builds the visedicts array for cl.time
Made up of: clients, packet_entities, nails, and tents Made up of: clients, packet_entities, nails, and tents
=============== ===============
*/ */
void CL_SwapEntityLists(void)
{
cl_oldnumvisedicts = cl_numvisedicts;
cl_oldvisedicts = cl_visedicts;
if (cl_visedicts == cl_visedicts_list[0])
cl_visedicts = cl_visedicts_list[1];
else
cl_visedicts = cl_visedicts_list[0];
// cl_oldvisedicts = cl_visedicts_list[(cls.netchan.incoming_sequence-1)&1];
// cl_visedicts = cl_visedicts_list[cls.netchan.incoming_sequence&1];
cl_numvisedicts = 0;
}
void CL_EmitEntities (void) void CL_EmitEntities (void)
{ {
if (cls.state != ca_active) if (cls.state != ca_active)
@ -2418,17 +2515,9 @@ void CL_EmitEntities (void)
if (!cl.validsequence) if (!cl.validsequence)
return; return;
cl_oldnumvisedicts = cl_numvisedicts; CL_SwapEntityLists();
cl_oldvisedicts = cl_visedicts;
if (cl_visedicts == cl_visedicts_list[0])
cl_visedicts = cl_visedicts_list[1];
else
cl_visedicts = cl_visedicts_list[0];
// cl_oldvisedicts = cl_visedicts_list[(cls.netchan.incoming_sequence-1)&1];
// cl_visedicts = cl_visedicts_list[cls.netchan.incoming_sequence&1];
cl_numvisedicts = 0;
CL_LinkViewModel ();
CL_LinkPlayers (); CL_LinkPlayers ();
CL_LinkPacketEntities (); CL_LinkPacketEntities ();
CL_LinkProjectiles (); CL_LinkProjectiles ();

View file

@ -2722,22 +2722,13 @@ CL_RequestNextDownload();
{ {
CL_SendCmd (); CL_SendCmd ();
if (cl.worldmodel) if (cls.state == ca_onserver && cl.validsequence && cl.worldmodel)
{ { // first update is the final signon stage
//work out which packet entities are solid cls.state = ca_active;
CL_SetSolidEntities (); if (VID_SetWindowCaption)
VID_SetWindowCaption(va("FTE QuakeWorld: %s", cls.servername));
// Set up prediction for other players SCR_EndLoadingPlaque();
CL_SetUpPlayerPrediction(false);
// do client side motion prediction
CL_PredictMove ();
// Set up prediction for other players
CL_SetUpPlayerPrediction(true);
// build a refresh entity list
CL_EmitEntities ();
} }
} }

View file

@ -3627,11 +3627,16 @@ void CL_ParseStuffCmd(char *msg, int destsplit) //this protects stuffcmds from n
*msg = '\0'; *msg = '\0';
Con_DPrintf("stufftext: %s\n", stufftext); Con_DPrintf("stufftext: %s\n", stufftext);
if (!strncmp(stufftext, "fullserverinfo ", 15)) if (!strncmp(stufftext, "fullserverinfo ", 15))
Cmd_ExecuteString(stufftext, RESTRICT_SERVER+destsplit); Cmd_ExecuteString(stufftext, RESTRICT_SERVER+destsplit); //do this NOW so that it's done before any models or anything are loaded
else else
{ {
Cbuf_AddText (stufftext, RESTRICT_SERVER+destsplit); #ifdef CSQC_DAT
Cbuf_AddText ("\n", RESTRICT_SERVER+destsplit); if (!CSQC_StuffCmd(stufftext))
#endif
{
Cbuf_AddText (stufftext, RESTRICT_SERVER+destsplit);
Cbuf_AddText ("\n", RESTRICT_SERVER+destsplit);
}
} }
msg++; msg++;

View file

@ -584,15 +584,6 @@ void CL_PredictMovePNum (int pnum)
return; return;
} }
if (cls.state == ca_onserver)
{ // first update is the final signon stage
cls.state = ca_active;
if (VID_SetWindowCaption)
VID_SetWindowCaption(va("FTE QuakeWorld: %s", cls.servername));
SCR_EndLoadingPlaque();
}
// this is the last frame received from the server // this is the last frame received from the server
from = &cl.frames[cl.validsequence & UPDATE_MASK]; from = &cl.frames[cl.validsequence & UPDATE_MASK];

View file

@ -184,6 +184,11 @@ for a few moments
*/ */
void SCR_CenterPrint (int pnum, char *str) void SCR_CenterPrint (int pnum, char *str)
{ {
#ifdef CSQC_DAT
if (CSQC_CenterPrint(str)) //csqc nabbed it.
return;
#endif
Q_strncpyz (scr_centerstring[pnum], str, sizeof(scr_centerstring[pnum])); Q_strncpyz (scr_centerstring[pnum], str, sizeof(scr_centerstring[pnum]));
scr_centertime_off[pnum] = scr_centertime.value; scr_centertime_off[pnum] = scr_centertime.value;
scr_centertime_start[pnum] = cl.time; scr_centertime_start[pnum] = cl.time;
@ -1153,8 +1158,8 @@ void SCR_BeginLoadingPlaque (void)
void SCR_EndLoadingPlaque (void) void SCR_EndLoadingPlaque (void)
{ {
if (!scr_initialized) // if (!scr_initialized)
return; // return;
scr_disabled_for_loading = false; scr_disabled_for_loading = false;
scr_fullupdate = 0; scr_fullupdate = 0;

View file

@ -344,9 +344,11 @@ void VQ3_AddEntity(const q3refEntity_t *q3)
ent.lerpfrac = ent.lerptime = q3->backlerp; ent.lerpfrac = ent.lerptime = q3->backlerp;
ent.alpha = 1; ent.alpha = 1;
ent.scale = 1; ent.scale = 1;
ent.forcedshader = q3->customShader; #ifdef Q3SHADERS
ent.forcedshader = (void*)q3->customShader;
*(int*)ent.shaderRGBA = *(int*)q3->shaderRGBA; *(int*)ent.shaderRGBA = *(int*)q3->shaderRGBA;
ent.shaderTime = q3->shaderTime; ent.shaderTime = q3->shaderTime;
#endif
if (q3->renderfx & Q3RF_DEPTHHACK) if (q3->renderfx & Q3RF_DEPTHHACK)
ent.flags |= Q2RF_DEPTHHACK; ent.flags |= Q2RF_DEPTHHACK;
if (q3->renderfx & Q3RF_THIRD_PERSON) if (q3->renderfx & Q3RF_THIRD_PERSON)

View file

@ -466,6 +466,9 @@ typedef struct
struct model_s *model_precache[MAX_MODELS]; struct model_s *model_precache[MAX_MODELS];
struct sfx_s *sound_precache[MAX_SOUNDS]; struct sfx_s *sound_precache[MAX_SOUNDS];
char model_csqcname[MAX_CSQCMODELS][MAX_QPATH];
struct model_s *model_csqcprecache[MAX_CSQCMODELS];
char skyname[MAX_QPATH]; char skyname[MAX_QPATH];
char levelname[40]; // for display on solo scoreboard char levelname[40]; // for display on solo scoreboard
int playernum[MAX_SPLITS]; int playernum[MAX_SPLITS];
@ -720,6 +723,38 @@ void CL_ParsePacketEntities (qboolean delta);
void CL_SetSolidEntities (void); void CL_SetSolidEntities (void);
void CL_ParsePlayerinfo (void); void CL_ParsePlayerinfo (void);
void CL_ParseClientPersist(void); void CL_ParseClientPersist(void);
//these last ones are needed for csqc handling of engine-bound ents.
void CL_SwapEntityLists(void);
void CL_LinkViewModel(void);
void CL_LinkPlayers (void);
void CL_LinkPacketEntities (void);
void CL_LinkProjectiles (void);
//
//clq3_parse.c
//
#ifdef Q3CLIENT
void CLQ3_SendClientCommand(const char *fmt, ...);
void CLQ3_SendConnectPacket(netadr_t to);
void CLQ3_SendCmd(usercmd_t *cmd);
qboolean CLQ3_Netchan_Process(void);
void CLQ3_ParseServerMessage (void);
qboolean CG_FillQ3Snapshot(int snapnum, struct snapshot_s *snapshot);
void CG_InsertIntoGameState(int num, char *str);
void CG_Restart_f(void);
#endif
//
//pr_csqc.c
//
#ifdef CSQC_DAT
void CSQC_Init (void);
qboolean CSQC_DrawView(void);
void CSQC_Shutdown(void);
qboolean CSQC_StuffCmd(char *cmd);
qboolean CSQC_CenterPrint(char *cmd);
#endif
// //
// cl_pred.c // cl_pred.c
@ -871,6 +906,7 @@ qboolean CIN_RunCinematic (void);
void MVD_Interpolate(void); void MVD_Interpolate(void);
void TP_Init(void); void TP_Init(void);
void TP_CheckVars(void);
void TP_CheckPickupSound(char *s, vec3_t org); void TP_CheckPickupSound(char *s, vec3_t org);
void Stats_NewMap(void); void Stats_NewMap(void);

View file

@ -28,26 +28,6 @@ float LerpAngle (float a2, float a1, float frac)
return a2 + frac * (a1 - a2); return a2 + frac * (a1 - a2);
} }
#define Q2PS_M_TYPE (1<<0)
#define Q2PS_M_ORIGIN (1<<1)
#define Q2PS_M_VELOCITY (1<<2)
#define Q2PS_M_TIME (1<<3)
#define Q2PS_M_FLAGS (1<<4)
#define Q2PS_M_GRAVITY (1<<5)
#define Q2PS_M_DELTA_ANGLES (1<<6)
#define Q2PS_VIEWOFFSET (1<<7)
#define Q2PS_VIEWANGLES (1<<8)
#define Q2PS_KICKANGLES (1<<9)
#define Q2PS_BLEND (1<<10)
#define Q2PS_FOV (1<<11)
#define Q2PS_WEAPONINDEX (1<<12)
#define Q2PS_WEAPONFRAME (1<<13)
#define Q2PS_RDFLAGS (1<<14)
// entity_state_t->effects // entity_state_t->effects
// Effects are things handled on the client side (lights, particles, frame animations) // Effects are things handled on the client side (lights, particles, frame animations)
// that happen constantly on the given entity. // that happen constantly on the given entity.
@ -89,37 +69,6 @@ float LerpAngle (float a2, float a1, float frac)
#define Q2EF_TRACKERTRAIL 0x80000000 #define Q2EF_TRACKERTRAIL 0x80000000
//ROGUE //ROGUE
// entity_state_t->renderfx flags
#define Q2RF_MINLIGHT 1 // allways have some light (viewmodel)
#define Q2RF_VIEWERMODEL 2 // don't draw through eyes, only mirrors
#define Q2RF_WEAPONMODEL 4 // only draw through eyes
#define Q2RF_FULLBRIGHT 8 // allways draw full intensity
#define Q2RF_DEPTHHACK 16 // for view weapon Z crunching
#define Q2RF_TRANSLUCENT 32
#define Q2RF_FRAMELERP 64
#define Q2RF_BEAM 128
#define Q2RF_CUSTOMSKIN 256 // skin is an index in image_precache
#define Q2RF_GLOW 512 // pulse lighting for bonus items
#define Q2RF_SHELL_RED 1024
#define Q2RF_SHELL_GREEN 2048
#define Q2RF_SHELL_BLUE 4096
//ROGUE
#define Q2RF_IR_VISIBLE 0x00008000 // 32768
#define Q2RF_SHELL_DOUBLE 0x00010000 // 65536
#define Q2RF_SHELL_HALF_DAM 0x00020000
#define Q2RF_USE_DISGUISE 0x00040000
//ROGUE
// player_state_t->refdef flags
#define Q2RDF_UNDERWATER 1 // warp the screen as apropriate
#define Q2RDF_NOWORLDMODEL 2 // used for player configuration screen
//ROGUE
#define Q2RDF_IRGOGGLES 4
#define Q2RDF_UVGOGGLES 8
//ROGUE

View file

@ -480,6 +480,7 @@ menuedit_t *MC_AddEdit(menu_t *menu, int x, int y, char *text, char *def)
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->caption = text; n->caption = text;
Q_strncpyz(n->text, def, sizeof(n->text)); Q_strncpyz(n->text, def, sizeof(n->text));
@ -499,6 +500,7 @@ menuedit_t *MC_AddEditCvar(menu_t *menu, int x, int y, char *text, char *name)
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->modified = true;
n->caption = (char *)(n+1); n->caption = (char *)(n+1);
strcpy((char *)(n+1), text); strcpy((char *)(n+1), text);
n->cvar = cvar; n->cvar = cvar;
@ -811,6 +813,8 @@ void MC_EditBox_Key(menuedit_t *edit, int key)
edit->text[len+1] = '\0'; edit->text[len+1] = '\0';
} }
edit->modified = true;
if (edit->cvar) if (edit->cvar)
{ {
Cvar_Set(edit->cvar, edit->text); Cvar_Set(edit->cvar, edit->text);

View file

@ -56,6 +56,9 @@ typedef struct {
menuedit_t *skinedit; menuedit_t *skinedit;
int topcolour; int topcolour;
int lowercolour; int lowercolour;
int tiwidth, tiheight;
qbyte translationimage[64*64];
} setupmenu_t; } setupmenu_t;
qboolean ApplySetupMenu (union menuoption_s *option,struct menu_s *menu, int key) qboolean ApplySetupMenu (union menuoption_s *option,struct menu_s *menu, int key)
{ {
@ -119,14 +122,30 @@ void MSetup_TransDraw (int x, int y, menucustom_t *option, menu_t *menu)
extern qbyte translationTable[256]; extern qbyte translationTable[256];
setupmenu_t *info = menu->data; setupmenu_t *info = menu->data;
mpic_t *p; mpic_t *p;
qbyte *f;
if (info->skinedit->modified)
{
info->skinedit->modified = false;
f = COM_LoadMallocFile (va("gfx/player/%s.lmp", info->skinedit->text));
if (!f)
f = COM_LoadMallocFile("gfx/menuplyr.lmp");
if (f)
{
info->tiwidth = ((int*)f)[0];
info->tiheight = ((int*)f)[1];
memcpy(info->translationimage, f+8, info->tiwidth*info->tiheight);
BZ_Free(f);
}
}
p = Draw_CachePic ("gfx/bigbox.lmp"); p = Draw_CachePic ("gfx/bigbox.lmp");
Draw_TransPic (x-12, y-8, p); Draw_TransPic (x-12, y-8, p);
p = Draw_SafeCachePic (va("gfx/player/%s.lmp", info->skinedit->text));
if (!p) //fallback
p = Draw_CachePic ("gfx/menuplyr.lmp");
M_BuildTranslationTable(info->topcolour*16, info->lowercolour*16); M_BuildTranslationTable(info->topcolour*16, info->lowercolour*16);
Draw_TransPicTranslate (x, y, p, translationTable); Draw_TransPicTranslate (x, y, info->tiwidth, info->tiheight, info->translationimage, translationTable);
} }
void M_Menu_Setup_f (void) void M_Menu_Setup_f (void)
@ -164,6 +183,7 @@ void M_Menu_Setup_f (void)
info->lowercolour = bottomcolor.value; info->lowercolour = bottomcolor.value;
info->topcolour = topcolor.value; info->topcolour = topcolor.value;
info->skinedit->modified = true;
} }

View file

@ -132,11 +132,11 @@ void M_BuildTranslationTable(int top, int bottom)
dest[BOTTOM_RANGE+j] = source[bottom+15-j]; dest[BOTTOM_RANGE+j] = source[bottom+15-j];
} }
/*
void M_DrawTransPicTranslate (int x, int y, mpic_t *pic) void M_DrawTransPicTranslate (int x, int y, mpic_t *pic)
{ {
Draw_TransPicTranslate (x + ((vid.width - 320)>>1), y, pic, translationTable); Draw_TransPicTranslate (x + ((vid.width - 320)>>1), y, pic, translationTable);
} }*/
void M_DrawTextBox (int x, int y, int width, int lines) void M_DrawTextBox (int x, int y, int width, int lines)

View file

@ -81,6 +81,7 @@ typedef struct {
cvar_t *cvar; cvar_t *cvar;
char text[MAX_EDIT_LENGTH]; char text[MAX_EDIT_LENGTH];
int cursorpos; int cursorpos;
qboolean modified;
} menuedit_t; } menuedit_t;
typedef struct { typedef struct {
menucommon_t common; menucommon_t common;

View file

@ -30,7 +30,7 @@ extern void (*Draw_Pic) (int x, int y, mpic_t *pic);
extern void (*Draw_ScalePic) (int x, int y, int width, int height, mpic_t *pic); extern void (*Draw_ScalePic) (int x, int y, int width, int height, mpic_t *pic);
extern void (*Draw_SubPic) (int x, int y, mpic_t *pic, int srcx, int srcy, int width, int height); extern void (*Draw_SubPic) (int x, int y, mpic_t *pic, int srcx, int srcy, int width, int height);
extern void (*Draw_TransPic) (int x, int y, mpic_t *pic); extern void (*Draw_TransPic) (int x, int y, mpic_t *pic);
extern void (*Draw_TransPicTranslate) (int x, int y, mpic_t *pic, qbyte *translation); extern void (*Draw_TransPicTranslate) (int x, int y, int width, int height, qbyte *image, qbyte *translation);
extern void (*Draw_ConsoleBackground) (int lines); extern void (*Draw_ConsoleBackground) (int lines);
extern void (*Draw_EditorBackground) (int lines); extern void (*Draw_EditorBackground) (int lines);
extern void (*Draw_TileClear) (int x, int y, int w, int h); extern void (*Draw_TileClear) (int x, int y, int w, int h);

View file

@ -25,6 +25,8 @@ typedef struct {
float lerpfrac; float lerpfrac;
float drawmask; //drawentities uses this mask for it. float drawmask; //drawentities uses this mask for it.
string_t model;
} csqcentvars_t; } csqcentvars_t;
typedef struct csqcedict_s typedef struct csqcedict_s
@ -39,11 +41,11 @@ typedef struct csqcedict_s
void CSQC_InitFields(void) void CSQC_InitFields(void)
{ //CHANGING THIS FUNCTION REQUIRES CHANGES TO csqcentvars_t { //CHANGING THIS FUNCTION REQUIRES CHANGES TO csqcentvars_t
#define fieldfloat(name) QC_RegisterFieldVar(csqcprogs, ev_float, #name, (int)&((csqcedict_t*)0)->v.name - (int)&((csqcedict_t*)0)->v, -1) #define fieldfloat(name) PR_RegisterFieldVar(csqcprogs, ev_float, #name, (int)&((csqcedict_t*)0)->v.name - (int)&((csqcedict_t*)0)->v, -1)
#define fieldvector(name) QC_RegisterFieldVar(csqcprogs, ev_vector, #name, (int)&((csqcedict_t*)0)->v.name - (int)&((csqcedict_t*)0)->v, -1) #define fieldvector(name) PR_RegisterFieldVar(csqcprogs, ev_vector, #name, (int)&((csqcedict_t*)0)->v.name - (int)&((csqcedict_t*)0)->v, -1)
#define fieldentity(name) QC_RegisterFieldVar(csqcprogs, ev_entity, #name, (int)&((csqcedict_t*)0)->v.name - (int)&((csqcedict_t*)0)->v, -1) #define fieldentity(name) PR_RegisterFieldVar(csqcprogs, ev_entity, #name, (int)&((csqcedict_t*)0)->v.name - (int)&((csqcedict_t*)0)->v, -1)
#define fieldstring(name) QC_RegisterFieldVar(csqcprogs, ev_string, #name, (int)&((csqcedict_t*)0)->v.name - (int)&((csqcedict_t*)0)->v, -1) #define fieldstring(name) PR_RegisterFieldVar(csqcprogs, ev_string, #name, (int)&((csqcedict_t*)0)->v.name - (int)&((csqcedict_t*)0)->v, -1)
#define fieldfunction(name) QC_RegisterFieldVar(csqcprogs, ev_function, #name, (int)&((csqcedict_t*)0)->v.name - (int)&((csqcedict_t*)0)->v, -1) #define fieldfunction(name) PR_RegisterFieldVar(csqcprogs, ev_function, #name, (int)&((csqcedict_t*)0)->v.name - (int)&((csqcedict_t*)0)->v, -1)
fieldfloat(modelindex); fieldfloat(modelindex);
fieldvector(origin); fieldvector(origin);
@ -58,6 +60,8 @@ void CSQC_InitFields(void)
fieldfloat(lerpfrac); fieldfloat(lerpfrac);
fieldfloat(drawmask); fieldfloat(drawmask);
fieldstring(model);
} }
#define RETURN_SSTRING(s) (*(char **)&((int *)pr_globals)[OFS_RETURN] = PR_SetString(prinst, s)) //static - exe will not change it. #define RETURN_SSTRING(s) (*(char **)&((int *)pr_globals)[OFS_RETURN] = PR_SetString(prinst, s)) //static - exe will not change it.
@ -141,6 +145,8 @@ void PF_CL_drawsetcliparea (progfuncs_t *prinst, struct globalvars_s *pr_globals
void PF_CL_drawresetcliparea (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_CL_drawresetcliparea (progfuncs_t *prinst, struct globalvars_s *pr_globals);
void PF_CL_drawgetimagesize (progfuncs_t *prinst, struct globalvars_s *pr_globals); void PF_CL_drawgetimagesize (progfuncs_t *prinst, struct globalvars_s *pr_globals);
#define MAXTEMPBUFFERLEN 1024
void PF_fclose_progs (progfuncs_t *prinst); void PF_fclose_progs (progfuncs_t *prinst);
char *PF_VarString (progfuncs_t *prinst, int first, struct globalvars_s *pr_globals); char *PF_VarString (progfuncs_t *prinst, int first, struct globalvars_s *pr_globals);
@ -181,15 +187,24 @@ static void PF_R_AddEntity(progfuncs_t *prinst, struct globalvars_s *pr_globals)
entity_t ent; entity_t ent;
int i; int i;
if (!cl_visedicts)
cl_visedicts = cl_visedicts_list[0];
memset(&ent, 0, sizeof(ent)); memset(&ent, 0, sizeof(ent));
i = in->v.modelindex; i = in->v.modelindex;
if (i <= 0 || i >= MAX_MODELS) //whoops, no model, no draw. if (i == 0)
return;
else if (i > 0 && i < MAX_MODELS)
ent.model = cl.model_precache[i];
else if (i < 0 && i > -MAX_CSQCMODELS)
ent.model = cl.model_csqcprecache[-i];
else
return; //there might be other ent types later as an extension that stop this. return; //there might be other ent types later as an extension that stop this.
ent.model = cl.model_precache[i]; if (!ent.model)
{
Con_Printf("PF_R_AddEntity: model wasn't precached!\n");
return;
}
ent.frame = in->v.frame; ent.frame = in->v.frame;
ent.oldframe = in->v.oldframe; ent.oldframe = in->v.oldframe;
@ -227,20 +242,41 @@ static void PF_R_AddEntityMask(progfuncs_t *prinst, struct globalvars_s *pr_glob
} }
} }
if (mask & MASK_ENGINE) if (mask & MASK_ENGINE && cl.worldmodel)
{ {
CL_EmitEntities(); CL_LinkViewModel ();
CL_LinkPlayers ();
CL_LinkPacketEntities ();
CL_LinkProjectiles ();
CL_UpdateTEnts ();
} }
} }
float CalcFov (float fov_x, float width, float height); //float CalcFov (float fov_x, float width, float height);
//clear scene, and set up the default stuff. //clear scene, and set up the default stuff.
static void PF_R_ClearScene (progfuncs_t *prinst, struct globalvars_s *pr_globals) static void PF_R_ClearScene (progfuncs_t *prinst, struct globalvars_s *pr_globals)
{ {
extern frame_t *view_frame; extern frame_t *view_frame;
extern player_state_t *view_message; extern player_state_t *view_message;
cl_numvisedicts = 0; CL_DecayLights ();
if (cl.worldmodel)
{
//work out which packet entities are solid
CL_SetSolidEntities ();
// Set up prediction for other players
CL_SetUpPlayerPrediction(false);
// do client side motion prediction
CL_PredictMove ();
// Set up prediction for other players
CL_SetUpPlayerPrediction(true);
}
CL_SwapEntityLists();
view_frame = &cl.frames[cls.netchan.incoming_sequence & UPDATE_MASK]; view_frame = &cl.frames[cls.netchan.incoming_sequence & UPDATE_MASK];
view_message = &view_frame->playerstate[cl.playernum[0]]; view_message = &view_frame->playerstate[cl.playernum[0]];
@ -417,19 +453,24 @@ static void PF_cs_getstatf(progfuncs_t *prinst, struct globalvars_s *pr_globals)
G_FLOAT(OFS_RETURN) = val; G_FLOAT(OFS_RETURN) = val;
} }
static void PF_cs_getstati(progfuncs_t *prinst, struct globalvars_s *pr_globals) static void PF_cs_getstati(progfuncs_t *prinst, struct globalvars_s *pr_globals)
{ { //convert an int stat into a qc float.
int stnum = G_FLOAT(OFS_PARM0); int stnum = G_FLOAT(OFS_PARM0);
unsigned int val = cl.stats[0][stnum]; int val = cl.stats[0][stnum];
if (G_FLOAT(OFS_PARM1)) if (*prinst->callargc > 1)
G_FLOAT(OFS_RETURN) = (val&(((1<<9)-1)<<23))>>23; {
int first, count;
first = G_FLOAT(OFS_PARM1);
count = G_FLOAT(OFS_PARM2);
G_FLOAT(OFS_RETURN) = (((unsigned int)val)&(((1<<count)-1)<<first))>>first;
}
else else
G_FLOAT(OFS_RETURN) = val&((1<<24)-1); G_FLOAT(OFS_RETURN) = val;
} }
static void PF_cs_getstats(progfuncs_t *prinst, struct globalvars_s *pr_globals) static void PF_cs_getstats(progfuncs_t *prinst, struct globalvars_s *pr_globals)
{ {
int stnum = G_FLOAT(OFS_PARM0); int stnum = G_FLOAT(OFS_PARM0);
char *out; char *out;
unsigned int val;
out = PF_TempStr(); out = PF_TempStr();
@ -444,14 +485,116 @@ static void PF_cs_getstats(progfuncs_t *prinst, struct globalvars_s *pr_globals)
RETURN_SSTRING(out); RETURN_SSTRING(out);
} }
static void PF_CSQC_SetOrigin(progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
csqcedict_t *ent = (void*)G_EDICT(prinst, OFS_PARM0);
float *org = G_VECTOR(OFS_PARM1);
VectorCopy(org, ent->v.origin);
//fixme: add some sort of fast area grid
}
static int FindModel(char *name, int *free)
{
int i;
*free = 0;
for (i = 1; i < MAX_CSQCMODELS; i++)
{
if (!*cl.model_csqcname[i])
{
*free = -i;
break;
}
if (!strcmp(cl.model_csqcname[i], name))
return -i;
}
for (i = 1; i < MAX_MODELS; i++)
{
if (!strcmp(cl.model_name[i], name))
return i;
}
return 0;
}
static void PF_CSQC_SetModel(progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
csqcedict_t *ent = (void*)G_EDICT(prinst, OFS_PARM0);
char *modelname = PR_GetStringOfs(prinst, OFS_PARM1);
int freei;
int modelindex = FindModel(modelname, &freei);
if (!modelindex)
{
if (!freei)
Host_EndGame("CSQC ran out of model slots\n");
Con_DPrintf("Late caching model \"%s\"\n", modelname);
Q_strncpyz(cl.model_csqcname[-freei], modelname, sizeof(cl.model_csqcname[-freei])); //allocate a slot now
modelindex = freei;
cl.model_csqcprecache[-freei] = Mod_ForName(cl.model_csqcname[-freei], false);
}
ent->v.modelindex = modelindex;
if (modelindex < 0)
ent->v.model = PR_SetString(prinst, cl.model_csqcname[-modelindex]);
else
ent->v.model = PR_SetString(prinst, cl.model_name[modelindex]);
}
static void PF_CSQC_SetModelIndex(progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
csqcedict_t *ent = (void*)G_EDICT(prinst, OFS_PARM0);
int modelindex = G_FLOAT(OFS_PARM1);
ent->v.modelindex = modelindex;
if (modelindex < 0)
ent->v.model = PR_SetString(prinst, cl.model_csqcname[-modelindex]);
else
ent->v.model = PR_SetString(prinst, cl.model_name[modelindex]);
}
static void PF_CSQC_PrecacheModel(progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
char *modelname = PR_GetStringOfs(prinst, OFS_PARM0);
int i;
for (i = 1; i < MAX_CSQCMODELS; i++)
{
if (!*cl.model_csqcname[i])
break;
if (!strcmp(cl.model_csqcname[i], modelname))
{
cl.model_csqcprecache[i] = Mod_ForName(cl.model_csqcname[i], false);
break;
}
}
for (i = 1; i < MAX_MODELS; i++) //I regret this.
{
if (!*cl.model_name[i])
break;
if (!strcmp(cl.model_name[i], modelname))
{
cl.model_precache[i] = Mod_ForName(cl.model_name[i], false);
break;
}
}
}
static void PF_CSQC_ModelnameForIndex(progfuncs_t *prinst, struct globalvars_s *pr_globals)
{
int modelindex = G_FLOAT(OFS_PARM0);
if (modelindex < 0)
G_INT(OFS_RETURN) = (int)PR_SetString(prinst, cl.model_csqcname[-modelindex]);
else
G_INT(OFS_RETURN) = (int)PR_SetString(prinst, cl.model_name[modelindex]);
}
//warning: functions that depend on globals are bad, mkay? //warning: functions that depend on globals are bad, mkay?
builtin_t csqc_builtins[] = { builtin_t csqc_builtins[] = {
//0 //0
PF_Fixme, PF_Fixme,
PF_makevectors, PF_makevectors,
PF_Fixme, //PF_setorigin PF_CSQC_SetOrigin, //PF_setorigin
PF_Fixme, //PF_setmodel PF_CSQC_SetModel, //PF_setmodel
PF_Fixme, //PF_setsize PF_Fixme, //PF_setsize
PF_Fixme, PF_Fixme,
PF_Fixme, //PF_break, PF_Fixme, //PF_break,
@ -466,14 +609,14 @@ builtin_t csqc_builtins[] = {
PF_Spawn, PF_Spawn,
PF_Fixme, //PF_Remove, PF_Fixme, //PF_Remove,
PF_Fixme, //PF_traceline, PF_Fixme, //PF_traceline,
PF_Fixme, //PF_checkclient, PF_Fixme, //PF_checkclient, (don't support)
PF_FindString, PF_FindString,
PF_Fixme, //PF_precache_sound, PF_Fixme, //PF_precache_sound,
//20 //20
PF_Fixme, //PF_precache_model, PF_CSQC_PrecacheModel, //PF_precache_model,
PF_Fixme, //PF_stuffcmd, PF_Fixme, //PF_stuffcmd, (don't support)
PF_Fixme, //PF_findradius, PF_Fixme, //PF_findradius,
PF_Fixme, //PF_bprint, PF_Fixme, //PF_bprint, (don't support)
PF_Fixme, //PF_sprint, PF_Fixme, //PF_sprint,
PF_dprint, PF_dprint,
PF_ftos, PF_ftos,
@ -483,7 +626,7 @@ builtin_t csqc_builtins[] = {
//30 //30
PF_traceoff, PF_traceoff,
PF_eprint, PF_eprint,
PF_Fixme, //PF_walkmove, PF_Fixme, //PF_walkmove, (don't support yet)
PF_Fixme, PF_Fixme,
PF_Fixme, //PF_droptofloor, PF_Fixme, //PF_droptofloor,
PF_Fixme, //PF_lightstyle, PF_Fixme, //PF_lightstyle,
@ -496,7 +639,7 @@ PF_Fixme, //PF_checkbottom,
PF_Fixme, //PF_pointcontents, PF_Fixme, //PF_pointcontents,
PF_Fixme, PF_Fixme,
PF_fabs, PF_fabs,
PF_Fixme, //PF_aim, hehehe... PF_Fixme, //PF_aim, hehehe... (don't support)
PF_cvar, PF_cvar,
PF_localcmd, PF_localcmd,
PF_nextent, PF_nextent,
@ -526,10 +669,10 @@ PF_Fixme,
PF_Fixme, PF_Fixme,
PF_Fixme, PF_Fixme,
SV_MoveToGoal, SV_MoveToGoal,
PF_Fixme, //PF_precache_file, PF_Fixme, //PF_precache_file, (don't support)
PF_Fixme, //PF_makestatic, PF_Fixme, //PF_makestatic,
//70 //70
PF_Fixme, //PF_changelevel, PF_Fixme, //PF_changelevel, (don't support)
PF_Fixme, PF_Fixme,
PF_cvar_set, PF_cvar_set,
PF_Fixme, //PF_centerprint, PF_Fixme, //PF_centerprint,
@ -539,11 +682,11 @@ PF_Fixme, //PF_precache_model,
PF_Fixme, //PF_precache_sound, PF_Fixme, //PF_precache_sound,
PF_Fixme, //PF_precache_file, PF_Fixme, //PF_precache_file,
PF_Fixme, //PF_setspawnparms, PF_Fixme, //PF_setspawnparms,
PF_Fixme, //PF_logfrag, PF_Fixme, //PF_logfrag, (don't support)
//80 //80
PF_Fixme, //PF_infokey, PF_Fixme, //PF_infokey,
PF_stof, PF_stof,
PF_Fixme, //PF_multicast, PF_Fixme, //PF_multicast, (don't support)
PF_Fixme, PF_Fixme,
PF_Fixme, PF_Fixme,
@ -775,7 +918,8 @@ func_t csqc_shutdown_function;
func_t csqc_draw_function; func_t csqc_draw_function;
func_t csqc_keydown_function; func_t csqc_keydown_function;
func_t csqc_keyup_function; func_t csqc_keyup_function;
func_t csqc_toggle_function; func_t csqc_parse_stuffcmd;
func_t csqc_parse_centerprint;
float *csqc_time; float *csqc_time;
@ -832,6 +976,9 @@ void CSQC_FindGlobals(void)
csqc_draw_function = PR_FindFunction(csqcprogs, "CSQC_UpdateView", PR_ANY); csqc_draw_function = PR_FindFunction(csqcprogs, "CSQC_UpdateView", PR_ANY);
csqc_keydown_function = PR_FindFunction(csqcprogs, "CSQC_KeyDown", PR_ANY); csqc_keydown_function = PR_FindFunction(csqcprogs, "CSQC_KeyDown", PR_ANY);
csqc_keyup_function = PR_FindFunction(csqcprogs, "CSQC_KeyUp", PR_ANY); csqc_keyup_function = PR_FindFunction(csqcprogs, "CSQC_KeyUp", PR_ANY);
csqc_parse_stuffcmd = PR_FindFunction(csqcprogs, "CSQC_Parse_StuffCmd", PR_ANY);
csqc_parse_centerprint = PR_FindFunction(csqcprogs, "CSQC_Parse_CenterPrint", PR_ANY);
} }
double csqctime; double csqctime;
@ -844,6 +991,9 @@ void CSQC_Init (void)
return; return;
} }
memset(cl.model_csqcname, 0, sizeof(cl.model_csqcname));
memset(cl.model_csqcprecache, 0, sizeof(cl.model_csqcprecache));
csqcprogparms.progsversion = PROGSTRUCT_VERSION; csqcprogparms.progsversion = PROGSTRUCT_VERSION;
csqcprogparms.ReadFile = COM_LoadStackFile;//char *(*ReadFile) (char *fname, void *buffer, int *len); csqcprogparms.ReadFile = COM_LoadStackFile;//char *(*ReadFile) (char *fname, void *buffer, int *len);
csqcprogparms.FileSize = COM_FileSize;//int (*FileSize) (char *fname); //-1 if file does not exist csqcprogparms.FileSize = COM_FileSize;//int (*FileSize) (char *fname); //-1 if file does not exist
@ -920,15 +1070,99 @@ qboolean CSQC_DrawView(void)
if (!csqc_draw_function || !csqcprogs) if (!csqc_draw_function || !csqcprogs)
return false; return false;
R_LessenStains(); r_secondaryview = 0;
if (cl.worldmodel)
R_LessenStains();
PR_ExecuteProgram(csqcprogs, csqc_draw_function); PR_ExecuteProgram(csqcprogs, csqc_draw_function);
return true; return true;
} }
qboolean CSQC_StuffCmd(char *cmd)
{
void *pr_globals;
char *str;
if (!csqcprogs || !csqc_parse_stuffcmd)
return false;
str = PF_TempStr();
Q_strncpyz(str, cmd, MAXTEMPBUFFERLEN);
pr_globals = PR_globals(csqcprogs, PR_CURRENT);
(*(char **)&((int *)pr_globals)[OFS_PARM0] = PR_SetString(csqcprogs, str));
PR_ExecuteProgram (csqcprogs, csqc_parse_stuffcmd);
return true;
}
qboolean CSQC_CenterPrint(char *cmd)
{
void *pr_globals;
char *str;
if (!csqcprogs || !csqc_parse_centerprint)
return false;
str = PF_TempStr();
Q_strncpyz(str, cmd, MAXTEMPBUFFERLEN);
pr_globals = PR_globals(csqcprogs, PR_CURRENT);
(*(char **)&((int *)pr_globals)[OFS_PARM0] = PR_SetString(csqcprogs, str));
PR_ExecuteProgram (csqcprogs, csqc_parse_centerprint);
return G_FLOAT(OFS_RETURN);
}
//this protocol allows up to 32767 edicts.
void CSQC_ParseEntities(void) void CSQC_ParseEntities(void)
{ {
/*
csqcedict_t *ent;
unsigned short entnum;
if (!csqcprogs)
Host_EndGame
for(;;)
{
entnum = MSG_ReadShort();
if (!entnum)
break;
if (entnum & 0x8000)
{ //remove
entnum &= ~0x8000;
if (!entnum)
{
Con_Printf("CSQC cannot remove world!\n");
continue;
}
ent = csqcent[entnum];
if (!ent) //hrm.
continue;
*csqc_globals->self = EDICT_TO_PROG(svprogfuncs, ent);
PR_ExecuteProgram(csqcprogs, csqc_ent_remove);
csqcent[entnum] = NULL;
//the csqc is expected to call the remove builtin.
}
else
{
ent = csqcent[entnum];
if (!ent)
{
ent = ED_Alloc(csqcprogs);
G_FLOAT(OFS_PARM0) = true;
}
else
G_FLOAT(OFS_PARM0) = false;
*csqc_globals->self = EDICT_TO_PROG(svprogfuncs, ent);
PR_ExecuteProgram(csqcprogs, csqc_ent_update);
}
}*/
} }
#endif #endif

View file

@ -76,7 +76,7 @@ int R_RunParticleEffectType (vec3_t org, vec3_t dir, float count, int typenum);
#define crand() (rand()%32767/16383.5f-1) #define crand() (rand()%32767/16383.5f-1)
void D_DrawParticleTrans (particle_t *pparticle); void D_DrawParticleTrans (particle_t *pparticle);
void D_DrawSparkTrans (particle_t *pparticle); void D_DrawSparkTrans (particle_t *pparticle, vec3_t src, vec3_t dest);
#define MAX_BEAMS 2048 // default max # of beam segments #define MAX_BEAMS 2048 // default max # of beam segments
#define MAX_PARTICLES 32768 // default max # of particles at one #define MAX_PARTICLES 32768 // default max # of particles at one
@ -2867,6 +2867,9 @@ void GL_DrawParticleBeam_Untextured(beamseg_t *b, part_type_t *type)
#ifdef SWQUAKE #ifdef SWQUAKE
void SWD_DrawParticleSpark(particle_t *p, part_type_t *type) void SWD_DrawParticleSpark(particle_t *p, part_type_t *type)
{ {
float speed;
vec3_t src, dest;
int r,g,b; //if you have a cpu with mmx, good for you... int r,g,b; //if you have a cpu with mmx, good for you...
r = p->rgb[0]*255; r = p->rgb[0]*255;
if (r < 0) if (r < 0)
@ -2884,7 +2887,22 @@ void SWD_DrawParticleSpark(particle_t *p, part_type_t *type)
else if (b > 255) else if (b > 255)
b = 255; b = 255;
p->color = GetPalette(r, g, b); p->color = GetPalette(r, g, b);
D_DrawSparkTrans(p);
speed = Length(p->vel);
if ((speed) < 1)
{
VectorCopy(p->org, src);
VectorCopy(p->org, dest);
}
else
{ //causes flickers with lower vels (due to bouncing in physics)
if (speed < 50)
speed *= 50/speed;
VectorMA(p->org, 2.5/(speed), p->vel, src);
VectorMA(p->org, -2.5/(speed), p->vel, dest);
}
D_DrawSparkTrans(p, src, dest);
} }
void SWD_DrawParticleBlob(particle_t *p, part_type_t *type) void SWD_DrawParticleBlob(particle_t *p, part_type_t *type)
{ {
@ -2907,6 +2925,46 @@ void SWD_DrawParticleBlob(particle_t *p, part_type_t *type)
p->color = GetPalette(r, g, b); p->color = GetPalette(r, g, b);
D_DrawParticleTrans(p); D_DrawParticleTrans(p);
} }
void SWD_DrawParticleBeam(beamseg_t *beam, part_type_t *type)
{
int r,g,b; //if you have a cpu with mmx, good for you...
vec3_t v;
vec3_t cr;
beamseg_t *c;
particle_t *p;
particle_t *q;
vec3_t point[4];
// if (!b->next)
// return;
c = beam->next;
q = c->p;
// if (!q)
// return;
p = beam->p;
r = p->rgb[0]*255;
if (r < 0)
r = 0;
else if (r > 255)
r = 255;
g = p->rgb[1]*255;
if (g < 0)
g = 0;
else if (g > 255)
g = 255;
b = p->rgb[2]*255;
if (b < 0)
b = 0;
else if (b > 255)
b = 255;
p->color = GetPalette(r, g, b);
D_DrawSparkTrans(p, p->org, q->org );
}
#endif #endif
void DrawParticleTypes (void texturedparticles(particle_t *,part_type_t*), void sparkparticles(particle_t*,part_type_t*), void beamparticlest(beamseg_t*,part_type_t*), void beamparticlesut(beamseg_t*,part_type_t*)) void DrawParticleTypes (void texturedparticles(particle_t *,part_type_t*), void sparkparticles(particle_t*,part_type_t*), void beamparticlest(beamseg_t*,part_type_t*), void beamparticlesut(beamseg_t*,part_type_t*))
@ -3310,7 +3368,7 @@ void R_DrawParticles (void)
if (qrenderer == QR_SOFTWARE) if (qrenderer == QR_SOFTWARE)
{ {
D_StartParticles(); D_StartParticles();
DrawParticleTypes(SWD_DrawParticleBlob, SWD_DrawParticleSpark, NULL, NULL);//SWD_DrawParticleBeam); DrawParticleTypes(SWD_DrawParticleBlob, SWD_DrawParticleSpark, SWD_DrawParticleBeam, SWD_DrawParticleBeam);
D_EndParticles(); D_EndParticles();
return; return;
} }

View file

@ -560,7 +560,7 @@ void (*Draw_Pic) (int x, int y, mpic_t *pic);
void (*Draw_ScalePic) (int x, int y, int width, int height, mpic_t *pic); void (*Draw_ScalePic) (int x, int y, int width, int height, mpic_t *pic);
void (*Draw_SubPic) (int x, int y, mpic_t *pic, int srcx, int srcy, int width, int height); void (*Draw_SubPic) (int x, int y, mpic_t *pic, int srcx, int srcy, int width, int height);
void (*Draw_TransPic) (int x, int y, mpic_t *pic); void (*Draw_TransPic) (int x, int y, mpic_t *pic);
void (*Draw_TransPicTranslate) (int x, int y, mpic_t *pic, qbyte *translation); void (*Draw_TransPicTranslate) (int x, int y, int w, int h, qbyte *image, qbyte *translation);
void (*Draw_ConsoleBackground) (int lines); void (*Draw_ConsoleBackground) (int lines);
void (*Draw_EditorBackground) (int lines); void (*Draw_EditorBackground) (int lines);
void (*Draw_TileClear) (int x, int y, int w, int h); void (*Draw_TileClear) (int x, int y, int w, int h);
@ -650,7 +650,7 @@ struct {
void (*Draw_ScalePic) (int x, int y, int width, int height, mpic_t *pic); void (*Draw_ScalePic) (int x, int y, int width, int height, mpic_t *pic);
void (*Draw_SubPic) (int x, int y, mpic_t *pic, int srcx, int srcy, int width, int height); void (*Draw_SubPic) (int x, int y, mpic_t *pic, int srcx, int srcy, int width, int height);
void (*Draw_TransPic) (int x, int y, mpic_t *pic); void (*Draw_TransPic) (int x, int y, mpic_t *pic);
void (*Draw_TransPicTranslate) (int x, int y, mpic_t *pic, qbyte *translation); void (*Draw_TransPicTranslate) (int x, int y, int w, int h, qbyte *pic, qbyte *translation);
void (*Draw_ConsoleBackground) (int lines); void (*Draw_ConsoleBackground) (int lines);
void (*Draw_EditorBackground) (int lines); void (*Draw_EditorBackground) (int lines);
void (*Draw_TileClear) (int x, int y, int w, int h); void (*Draw_TileClear) (int x, int y, int w, int h);

View file

@ -1408,6 +1408,24 @@ void V_RenderView (void)
if (cls.state != ca_active) if (cls.state != ca_active)
return; return;
if (cl.worldmodel)
{
//work out which packet entities are solid
CL_SetSolidEntities ();
// Set up prediction for other players
CL_SetUpPlayerPrediction(false);
// do client side motion prediction
CL_PredictMove ();
// Set up prediction for other players
CL_SetUpPlayerPrediction(true);
// build a refresh entity list
CL_EmitEntities ();
}
view_frame = &cl.frames[cls.netchan.incoming_sequence & UPDATE_MASK]; view_frame = &cl.frames[cls.netchan.incoming_sequence & UPDATE_MASK];
R_PushDlights (); R_PushDlights ();

View file

@ -109,6 +109,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define PLUGINS #define PLUGINS
#ifdef _DEBUG
#define CSQC_DAT //support for csqc
#endif
#define MENU_DAT //support for menu.dat #define MENU_DAT //support for menu.dat
#define Q3SHADERS #define Q3SHADERS
@ -292,6 +295,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define MAX_MODELS 512 // these are sent over the net as bytes #define MAX_MODELS 512 // these are sent over the net as bytes
#define MAX_SOUNDS 256 // so they cannot be blindly increased #define MAX_SOUNDS 256 // so they cannot be blindly increased
#define MAX_CSQCMODELS 256 // these live entirly clientside
#define SAVEGAME_COMMENT_LENGTH 39 #define SAVEGAME_COMMENT_LENGTH 39
#define MAX_STYLESTRING 64 #define MAX_STYLESTRING 64

View file

@ -143,6 +143,7 @@ extern qboolean msg_badread; // set if a read goes beyond end of message
void MSG_BeginReading (void); void MSG_BeginReading (void);
int MSG_GetReadCount(void); int MSG_GetReadCount(void);
int MSG_ReadChar (void); int MSG_ReadChar (void);
int MSG_ReadBits(int bits);
int MSG_ReadByte (void); int MSG_ReadByte (void);
int MSG_ReadShort (void); int MSG_ReadShort (void);
int MSG_ReadLong (void); int MSG_ReadLong (void);

View file

@ -46,9 +46,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifdef Q3BSPS #ifdef Q3BSPS
#define PEXT_Q3BSP 0x00040000 #define PEXT_Q3BSP 0x00040000
#endif #endif
#define PEXT_SEEF1 0x00080000 //#define PEXT_SEEF1 0x00080000
#define PEXT_SPLITSCREEN 0x00100000 #define PEXT_SPLITSCREEN 0x00100000
#define PEXT_HEXEN2 0x00200000 #define PEXT_HEXEN2 0x00200000 //more stats and working particle builtin.
#define PEXT_SPAWNSTATIC2 0x00400000 //Sends an entity delta instead of a baseline. #define PEXT_SPAWNSTATIC2 0x00400000 //Sends an entity delta instead of a baseline.
#define PEXT_CUSTOMTEMPEFFECTS 0x00800000 //supports custom temp ents. #define PEXT_CUSTOMTEMPEFFECTS 0x00800000 //supports custom temp ents.
#define PEXT_256PACKETENTITIES 0x01000000 //Client can recieve 256 packet entities. #define PEXT_256PACKETENTITIES 0x01000000 //Client can recieve 256 packet entities.
@ -803,8 +803,61 @@ typedef struct q1usercmd_s
#define Q2MAX_STATS 32 #define Q2MAX_STATS 32
//for the local player
#define Q2PS_M_TYPE (1<<0)
#define Q2PS_M_ORIGIN (1<<1)
#define Q2PS_M_VELOCITY (1<<2)
#define Q2PS_M_TIME (1<<3)
#define Q2PS_M_FLAGS (1<<4)
#define Q2PS_M_GRAVITY (1<<5)
#define Q2PS_M_DELTA_ANGLES (1<<6)
// edict->drawflags #define Q2PS_VIEWOFFSET (1<<7)
#define Q2PS_VIEWANGLES (1<<8)
#define Q2PS_KICKANGLES (1<<9)
#define Q2PS_BLEND (1<<10)
#define Q2PS_FOV (1<<11)
#define Q2PS_WEAPONINDEX (1<<12)
#define Q2PS_WEAPONFRAME (1<<13)
#define Q2PS_RDFLAGS (1<<14)
// entity_state_t->renderfx flags
#define Q2RF_MINLIGHT 1 // allways have some light (viewmodel)
#define Q2RF_VIEWERMODEL 2 // don't draw through eyes, only mirrors
#define Q2RF_WEAPONMODEL 4 // only draw through eyes
#define Q2RF_FULLBRIGHT 8 // allways draw full intensity
#define Q2RF_DEPTHHACK 16 // for view weapon Z crunching
#define Q2RF_TRANSLUCENT 32
#define Q2RF_FRAMELERP 64
#define Q2RF_BEAM 128
#define Q2RF_CUSTOMSKIN 256 // skin is an index in image_precache
#define Q2RF_GLOW 512 // pulse lighting for bonus items
#define Q2RF_SHELL_RED 1024
#define Q2RF_SHELL_GREEN 2048
#define Q2RF_SHELL_BLUE 4096
//ROGUE
#define Q2RF_IR_VISIBLE 0x00008000 // 32768
#define Q2RF_SHELL_DOUBLE 0x00010000 // 65536
#define Q2RF_SHELL_HALF_DAM 0x00020000
#define Q2RF_USE_DISGUISE 0x00040000
//ROGUE
// player_state_t->refdef flags
#define Q2RDF_UNDERWATER 1 // warp the screen as apropriate
#define Q2RDF_NOWORLDMODEL 2 // used for player configuration screen
//ROGUE
#define Q2RDF_IRGOGGLES 4
#define Q2RDF_UVGOGGLES 8
//ROGUE
// edict->drawflags (hexen2 stuff)
#define MLS_MASKIN 7 // Model Light Style #define MLS_MASKIN 7 // Model Light Style
#define MLS_MASKOUT 248 #define MLS_MASKOUT 248
#define MLS_NONE 0 #define MLS_NONE 0
@ -825,3 +878,6 @@ typedef struct q1usercmd_s
#define SCALE_ORIGIN_TOP 64 // Scaling origin at object top #define SCALE_ORIGIN_TOP 64 // Scaling origin at object top
#define DRF_TRANSLUCENT 128 #define DRF_TRANSLUCENT 128

View file

@ -64,6 +64,7 @@ int UI_MenuState(void);
void CG_Stop (void); void CG_Stop (void);
void CG_Start (void); void CG_Start (void);
int CG_Refresh(void); int CG_Refresh(void);
qboolean CG_Command(void);
#endif #endif
#endif #endif

View file

@ -199,8 +199,6 @@ typedef struct glcachepic_s
glcachepic_t glmenu_cachepics[MAX_CACHED_PICS]; glcachepic_t glmenu_cachepics[MAX_CACHED_PICS];
int glmenu_numcachepics; int glmenu_numcachepics;
qbyte menuplyr_pixels[4096];
int pic_texels; int pic_texels;
int pic_count; int pic_count;
@ -498,13 +496,6 @@ mpic_t *GLDraw_SafeCachePic (char *path)
SwapPic (qpic); SwapPic (qpic);
} }
// HACK HACK HACK --- we need to keep the bytes for
// the translatable player picture just for the menu
// configuration dialog
if (!strncmp (path, "gfx/player/", 11) || !strcmp (path, "gfx/menuplyr.lmp")) //these arn't cached. I hate hacks.
memcpy (menuplyr_pixels, qpic->data, qpic->width*qpic->height);
else
{ {
glmenu_numcachepics++; glmenu_numcachepics++;
Q_strncpyz (pic->name, path, sizeof(pic->name)); Q_strncpyz (pic->name, path, sizeof(pic->name));
@ -1588,7 +1579,7 @@ Draw_TransPicTranslate
Only used for the player color selection menu Only used for the player color selection menu
============= =============
*/ */
void GLDraw_TransPicTranslate (int x, int y, mpic_t *pic, qbyte *translation) void GLDraw_TransPicTranslate (int x, int y, int width, int height, qbyte *pic, qbyte *translation)
{ {
int v, u, c; int v, u, c;
unsigned trans[64*64], *dest; unsigned trans[64*64], *dest;
@ -1597,15 +1588,15 @@ void GLDraw_TransPicTranslate (int x, int y, mpic_t *pic, qbyte *translation)
GL_Bind (translate_texture); GL_Bind (translate_texture);
c = pic->width * pic->height; c = width * height;
dest = trans; dest = trans;
for (v=0 ; v<64 ; v++, dest += 64) for (v=0 ; v<64 ; v++, dest += 64)
{ {
src = &menuplyr_pixels[ ((v*pic->height)>>6) *pic->width]; src = &pic[ ((v*height)>>6) *width];
for (u=0 ; u<64 ; u++) for (u=0 ; u<64 ; u++)
{ {
p = src[(u*pic->width)>>6]; p = src[(u*width)>>6];
if (p == 255) if (p == 255)
dest[u] = p; dest[u] = p;
else else
@ -1623,11 +1614,11 @@ void GLDraw_TransPicTranslate (int x, int y, mpic_t *pic, qbyte *translation)
qglTexCoord2f (0, 0); qglTexCoord2f (0, 0);
qglVertex2f (x, y); qglVertex2f (x, y);
qglTexCoord2f (1, 0); qglTexCoord2f (1, 0);
qglVertex2f (x+pic->width, y); qglVertex2f (x+width, y);
qglTexCoord2f (1, 1); qglTexCoord2f (1, 1);
qglVertex2f (x+pic->width, y+pic->height); qglVertex2f (x+width, y+height);
qglTexCoord2f (0, 1); qglTexCoord2f (0, 1);
qglVertex2f (x, y+pic->height); qglVertex2f (x, y+height);
qglEnd (); qglEnd ();
} }

View file

@ -32,7 +32,7 @@ void GLDraw_SubPic(int x, int y, mpic_t *pic, int srcx, int srcy, int width, int
void GLDraw_Pic (int x, int y, mpic_t *pic); void GLDraw_Pic (int x, int y, mpic_t *pic);
void GLDraw_ScalePic (int x, int y, int width, int height, mpic_t *pic); void GLDraw_ScalePic (int x, int y, int width, int height, mpic_t *pic);
void GLDraw_TransPic (int x, int y, mpic_t *pic); void GLDraw_TransPic (int x, int y, mpic_t *pic);
void GLDraw_TransPicTranslate (int x, int y, mpic_t *pic, qbyte *translation); void GLDraw_TransPicTranslate (int x, int y, int w, int h, qbyte *pic, qbyte *translation);
void GLDraw_ConsoleBackground (int lines); void GLDraw_ConsoleBackground (int lines);
void GLDraw_EditorBackground (int lines); void GLDraw_EditorBackground (int lines);
void GLDraw_BeginDisc (void); void GLDraw_BeginDisc (void);

View file

@ -810,6 +810,7 @@ int CM_PointContents (vec3_t p, int headnode);
struct trace_s CM_BoxTrace (vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs, int headnode, int brushmask); struct trace_s CM_BoxTrace (vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs, int headnode, int brushmask);
int CM_HeadnodeForBox (vec3_t mins, vec3_t maxs); int CM_HeadnodeForBox (vec3_t mins, vec3_t maxs);
struct trace_s CM_TransformedBoxTrace (vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs, int headnode, int brushmask, vec3_t origin, vec3_t angles); struct trace_s CM_TransformedBoxTrace (vec3_t start, vec3_t end, vec3_t mins, vec3_t maxs, int headnode, int brushmask, vec3_t origin, vec3_t angles);
struct model_s *CM_TempBoxModel(vec3_t mins, vec3_t maxs);
void Mod_ParseInfoFromEntityLump(char *data); void Mod_ParseInfoFromEntityLump(char *data);

View file

@ -229,6 +229,9 @@ void GL_SetupSceneProcessingTextures (void)
unsigned char pp_warp_tex[PP_WARP_TEX_SIZE*PP_WARP_TEX_SIZE*3]; unsigned char pp_warp_tex[PP_WARP_TEX_SIZE*PP_WARP_TEX_SIZE*3];
unsigned char pp_edge_tex[PP_AMP_TEX_SIZE*PP_AMP_TEX_SIZE*3]; unsigned char pp_edge_tex[PP_AMP_TEX_SIZE*PP_AMP_TEX_SIZE*3];
if (!gl_config.arb_shader_objects)
return;
scenepp_texture = texture_extension_number++; scenepp_texture = texture_extension_number++;
scenepp_texture_warp = texture_extension_number++; scenepp_texture_warp = texture_extension_number++;
scenepp_texture_edge = texture_extension_number++; scenepp_texture_edge = texture_extension_number++;
@ -254,7 +257,7 @@ void GL_SetupSceneProcessingTextures (void)
GL_Bind(scenepp_texture_warp); GL_Bind(scenepp_texture_warp);
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); qglTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
qglTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, PP_WARP_TEX_SIZE, PP_WARP_TEX_SIZE, 0, GL_RGB, GL_UNSIGNED_BYTE, pp_warp_tex); qglTexImage2D(GL_TEXTURE_2D, 0, 3, PP_WARP_TEX_SIZE, PP_WARP_TEX_SIZE, 0, GL_RGB, GL_UNSIGNED_BYTE, pp_warp_tex);
// TODO: init edge texture - this is ampscale * 2, with ampscale calculated // TODO: init edge texture - this is ampscale * 2, with ampscale calculated
// init warp texture - this specifies offset in // init warp texture - this specifies offset in
@ -337,6 +340,31 @@ qboolean R_CullSphere (vec3_t org, float radius)
void R_RotateForEntity (entity_t *e) void R_RotateForEntity (entity_t *e)
{ {
float m[16]; float m[16];
if (e->flags & Q2RF_WEAPONMODEL)
{ //rotate to view first
m[0] = cl.viewent[r_refdef.currentplayernum].axis[0][0];
m[1] = cl.viewent[r_refdef.currentplayernum].axis[0][1];
m[2] = cl.viewent[r_refdef.currentplayernum].axis[0][2];
m[3] = 0;
m[4] = cl.viewent[r_refdef.currentplayernum].axis[1][0];
m[5] = cl.viewent[r_refdef.currentplayernum].axis[1][1];
m[6] = cl.viewent[r_refdef.currentplayernum].axis[1][2];
m[7] = 0;
m[8] = cl.viewent[r_refdef.currentplayernum].axis[2][0];
m[9] = cl.viewent[r_refdef.currentplayernum].axis[2][1];
m[10] = cl.viewent[r_refdef.currentplayernum].axis[2][2];
m[11] = 0;
m[12] = cl.viewent[r_refdef.currentplayernum].origin[0];
m[13] = cl.viewent[r_refdef.currentplayernum].origin[1];
m[14] = cl.viewent[r_refdef.currentplayernum].origin[2];
m[15] = 1;
qglMultMatrixf(m);
}
m[0] = e->axis[0][0]; m[0] = e->axis[0][0];
m[1] = e->axis[0][1]; m[1] = e->axis[0][1];
m[2] = e->axis[0][2]; m[2] = e->axis[0][2];
@ -357,26 +385,7 @@ void R_RotateForEntity (entity_t *e)
m[14] = e->origin[2]; m[14] = e->origin[2];
m[15] = 1; m[15] = 1;
#if 1
#if 0
{
void Matrix4_Multiply(float *a, float *b, float *out);
float new[16];
Matrix4_Multiply(m, r_world_matrix, new);
qglLoadMatrixf(new);
}
#endif
qglMultMatrixf(m); qglMultMatrixf(m);
#else
qglTranslatef (e->origin[0], e->origin[1], e->origin[2]);
qglRotatef (e->angles[1], 0, 0, 1);
qglRotatef (-e->angles[0], 0, 1, 0);
//ZOID: fixed z angle
qglRotatef (e->angles[2], 1, 0, 0);
#endif
} }
/* /*
@ -814,6 +823,7 @@ R_DrawViewModel
*/ */
void GLR_DrawViewModel (void) void GLR_DrawViewModel (void)
{ {
/*
// float ambient[4], diffuse[4]; // float ambient[4], diffuse[4];
// int j; // int j;
// int lnum; // int lnum;
@ -933,6 +943,7 @@ void GLR_DrawViewModel (void)
case mod_dummy: case mod_dummy:
break; break;
} }
*/
} }
@ -1862,9 +1873,12 @@ void GLR_RenderView (void)
// Con_Printf ("%3i ms %4i wpoly %4i epoly\n", (int)((time2-time1)*1000), c_brush_polys, c_alias_polys); // Con_Printf ("%3i ms %4i wpoly %4i epoly\n", (int)((time2-time1)*1000), c_brush_polys, c_alias_polys);
} }
if (!gl_config.arb_shader_objects)
return;
// SCENE POST PROCESSING // SCENE POST PROCESSING
// we check if we need to use any shaders - currently it's just waterwarp // we check if we need to use any shaders - currently it's just waterwarp
if ((gl_config.arb_shader_objects) && (r_waterwarp.value && r_viewleaf && r_viewleaf->contents <= Q1CONTENTS_WATER)) if ( (r_waterwarp.value && r_viewleaf && r_viewleaf->contents <= Q1CONTENTS_WATER))
{ {
float vwidth = 1, vheight = 1; float vwidth = 1, vheight = 1;
float vs, vt; float vs, vt;

View file

@ -176,13 +176,13 @@ void GLSCR_UpdateScreen (void)
if (scr_disabled_for_loading) if (scr_disabled_for_loading)
{ {
/* if (Sys_DoubleTime() - scr_disabled_time > 60 || key_dest != key_game) extern float scr_disabled_time;
if (Sys_DoubleTime() - scr_disabled_time > 60 || key_dest != key_game)
{ {
scr_disabled_for_loading = false; scr_disabled_for_loading = false;
Con_Printf ("load failed.\n");
} }
else else
*/ { {
GL_BeginRendering (&glx, &gly, &glwidth, &glheight); GL_BeginRendering (&glx, &gly, &glwidth, &glheight);
SCR_DrawLoading (); SCR_DrawLoading ();
GL_EndRendering (); GL_EndRendering ();

View file

@ -1765,7 +1765,7 @@ public:
RELEASENULL(m_textureMatrixStack); RELEASENULL(m_textureMatrixStack);
} }
void glAlphaFunc (GLenum func, GLclampf ref){ void cglAlphaFunc (GLenum func, GLclampf ref){
if ( m_glAlphaFunc != func || m_glAlphaFuncRef != ref ) { if ( m_glAlphaFunc != func || m_glAlphaFuncRef != ref ) {
SetRenderStateDirty(); SetRenderStateDirty();
m_glAlphaFunc = func; m_glAlphaFunc = func;
@ -1774,7 +1774,7 @@ public:
} }
} }
void glBegin (GLenum mode){ void cglBegin (GLenum mode){
if ( m_needBeginScene ){ if ( m_needBeginScene ){
HRESULT hr = m_pD3DDev->BeginScene(); HRESULT hr = m_pD3DDev->BeginScene();
if ( FAILED(hr) ) { if ( FAILED(hr) ) {
@ -1814,7 +1814,7 @@ public:
} }
} }
void glBindTexture(GLenum target, GLuint texture){ void cglBindTexture(GLenum target, GLuint texture){
if ( target != GL_TEXTURE_2D ) { if ( target != GL_TEXTURE_2D ) {
LocalDebugBreak(); LocalDebugBreak();
return; return;
@ -1826,19 +1826,19 @@ public:
} }
} }
inline void glMTexCoord2fSGIS(GLenum target, GLfloat s, GLfloat t){ inline void cglMTexCoord2fSGIS(GLenum target, GLfloat s, GLfloat t){
int textStage = target - TEXTURE0_SGIS; int textStage = target - TEXTURE0_SGIS;
m_OGLPrimitiveVertexBuffer.SetTextureCoord(textStage, s, t); m_OGLPrimitiveVertexBuffer.SetTextureCoord(textStage, s, t);
} }
void glSelectTextureSGIS(GLenum target){ void cglSelectTextureSGIS(GLenum target){
int textStage = target - TEXTURE0_SGIS; int textStage = target - TEXTURE0_SGIS;
m_textureState.SetCurrentStage(textStage); m_textureState.SetCurrentStage(textStage);
m_textures.BindTexture(m_textureState.GetCurrentTexture()); m_textures.BindTexture(m_textureState.GetCurrentTexture());
// Does not, by itself, dirty the render state // Does not, by itself, dirty the render state
} }
void glBlendFunc (GLenum sfactor, GLenum dfactor){ void cglBlendFunc (GLenum sfactor, GLenum dfactor){
if ( m_glBlendFuncSFactor != sfactor || m_glBlendFuncDFactor != dfactor ) { if ( m_glBlendFuncSFactor != sfactor || m_glBlendFuncDFactor != dfactor ) {
SetRenderStateDirty(); SetRenderStateDirty();
m_glBlendFuncSFactor = sfactor; m_glBlendFuncSFactor = sfactor;
@ -1847,7 +1847,7 @@ public:
} }
} }
void glClear (GLbitfield mask){ void cglClear (GLbitfield mask){
HRESULT hr; HRESULT hr;
internalEnd(); internalEnd();
SetGLRenderState(); SetGLRenderState();
@ -1871,7 +1871,7 @@ public:
} }
} }
void glClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha){ void cglClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha){
D3DCOLOR clearColor = D3DRGBA(Clamp(red), Clamp(green), Clamp(blue), Clamp(alpha)); D3DCOLOR clearColor = D3DRGBA(Clamp(red), Clamp(green), Clamp(blue), Clamp(alpha));
#ifdef USE_D3DXCONTEXT #ifdef USE_D3DXCONTEXT
HRESULT hr = m_pD3DX->SetClearColor(clearColor); HRESULT hr = m_pD3DX->SetClearColor(clearColor);
@ -1884,32 +1884,32 @@ public:
#endif #endif
} }
inline void glColor3f (GLfloat red, GLfloat green, GLfloat blue){ inline void cglColor3f (GLfloat red, GLfloat green, GLfloat blue){
// Note: On x86 architectures this function will chew up a lot of time // Note: On x86 architectures this function will chew up a lot of time
// converting floating point to integer by calling _ftol // converting floating point to integer by calling _ftol
// unless the /QIfist flag is specified. // unless the /QIfist flag is specified.
m_OGLPrimitiveVertexBuffer.SetColor(D3DRGB(Clamp(red), Clamp(green), Clamp(blue))); m_OGLPrimitiveVertexBuffer.SetColor(D3DRGB(Clamp(red), Clamp(green), Clamp(blue)));
} }
inline void glColor3ubv (const GLubyte *v){ inline void cglColor3ubv (const GLubyte *v){
m_OGLPrimitiveVertexBuffer.SetColor(RGBA_MAKE(v[0], v[1], v[2], 0xff)); m_OGLPrimitiveVertexBuffer.SetColor(RGBA_MAKE(v[0], v[1], v[2], 0xff));
} }
inline void glColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha){ inline void cglColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha){
// Note: On x86 architectures this function will chew up a lot of time // Note: On x86 architectures this function will chew up a lot of time
// converting floating point to integer by calling _ftol // converting floating point to integer by calling _ftol
// unless the /QIfist flag is specified. // unless the /QIfist flag is specified.
m_OGLPrimitiveVertexBuffer.SetColor(D3DRGBA(Clamp(red), Clamp(green), Clamp(blue), Clamp(alpha))); m_OGLPrimitiveVertexBuffer.SetColor(D3DRGBA(Clamp(red), Clamp(green), Clamp(blue), Clamp(alpha)));
} }
inline void glColor4fv (const GLfloat *v){ inline void cglColor4fv (const GLfloat *v){
// Note: On x86 architectures this function will chew up a lot of time // Note: On x86 architectures this function will chew up a lot of time
// converting floating point to integer by calling _ftol // converting floating point to integer by calling _ftol
// unless the /QIfist flag is specified. // unless the /QIfist flag is specified.
m_OGLPrimitiveVertexBuffer.SetColor(D3DRGBA(Clamp(v[0]), Clamp(v[1]), Clamp(v[2]), Clamp(v[3]))); m_OGLPrimitiveVertexBuffer.SetColor(D3DRGBA(Clamp(v[0]), Clamp(v[1]), Clamp(v[2]), Clamp(v[3])));
} }
void glCullFace (GLenum mode){ void cglCullFace (GLenum mode){
if ( m_glCullFaceMode != mode ) { if ( m_glCullFaceMode != mode ) {
SetRenderStateDirty(); SetRenderStateDirty();
m_glCullFaceMode = mode; m_glCullFaceMode = mode;
@ -1917,7 +1917,7 @@ public:
} }
} }
void glDepthFunc (GLenum func){ void cglDepthFunc (GLenum func){
if ( m_glDepthFunc != func ) { if ( m_glDepthFunc != func ) {
SetRenderStateDirty(); SetRenderStateDirty();
m_glDepthFunc = func; m_glDepthFunc = func;
@ -1925,7 +1925,7 @@ public:
} }
} }
void glDepthMask (GLboolean flag){ void cglDepthMask (GLboolean flag){
if ( m_glDepthMask != (flag != 0) ) { if ( m_glDepthMask != (flag != 0) ) {
SetRenderStateDirty(); SetRenderStateDirty();
m_glDepthMask = flag != 0 ? true : false; m_glDepthMask = flag != 0 ? true : false;
@ -1933,7 +1933,7 @@ public:
} }
} }
void glDepthRange (GLclampd zNear, GLclampd zFar){ void cglDepthRange (GLclampd zNear, GLclampd zFar){
if ( m_glDepthRangeNear != zNear || m_glDepthRangeFar != zFar ) { if ( m_glDepthRangeNear != zNear || m_glDepthRangeFar != zFar ) {
SetRenderStateDirty(); SetRenderStateDirty();
m_glDepthRangeNear = zNear; m_glDepthRangeNear = zNear;
@ -1942,19 +1942,19 @@ public:
} }
} }
void glDisable (GLenum cap){ void cglDisable (GLenum cap){
glEnableDisableSet(cap, false); EnableDisableSet(cap, false);
} }
void glDrawBuffer (GLenum /* mode */){ void cglDrawBuffer (GLenum /* mode */){
// Do nothing. (Can DirectX render to the front buffer at all?) // Do nothing. (Can DirectX render to the front buffer at all?)
} }
void glEnable (GLenum cap){ void cglEnable (GLenum cap){
glEnableDisableSet(cap, true); EnableDisableSet(cap, true);
} }
void glEnableDisableSet(GLenum cap, bool value){ void EnableDisableSet(GLenum cap, bool value){
switch ( cap ) { switch ( cap ) {
case GL_ALPHA_TEST: case GL_ALPHA_TEST:
if ( m_glAlphaTest != value ) { if ( m_glAlphaTest != value ) {
@ -2002,13 +2002,15 @@ public:
case GL_DITHER: case GL_DITHER:
case GL_FOG: case GL_FOG:
break; break;
case GL_POLYGON_OFFSET_FILL: // I fear for the shaders.
break;
default: default:
LocalDebugBreak(); LocalDebugBreak();
break; break;
} }
} }
void glEnd (void){ void cglEnd (void){
// internalEnd(); // internalEnd();
} }
@ -2016,12 +2018,12 @@ public:
m_OGLPrimitiveVertexBuffer.End(); m_OGLPrimitiveVertexBuffer.End();
} }
void glFinish (void){ void cglFinish (void){
// To Do: This is supposed to flush all pending commands // To Do: This is supposed to flush all pending commands
internalEnd(); internalEnd();
} }
void glFrustum (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar){ void cglFrustum (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar){
SetRenderStateDirty(); SetRenderStateDirty();
D3DXMATRIX m; D3DXMATRIX m;
// Note that D3D takes top, bottom arguments in opposite order // Note that D3D takes top, bottom arguments in opposite order
@ -2030,7 +2032,7 @@ public:
*m_currentMatrixStateDirty = true; *m_currentMatrixStateDirty = true;
} }
void glGetFloatv (GLenum pname, GLfloat *params){ void cglGetFloatv (GLenum pname, GLfloat *params){
switch(pname){ switch(pname){
case GL_MODELVIEW_MATRIX: case GL_MODELVIEW_MATRIX:
memcpy(params,m_modelViewMatrixStack->GetTop(), sizeof(D3DMATRIX)); memcpy(params,m_modelViewMatrixStack->GetTop(), sizeof(D3DMATRIX));
@ -2041,7 +2043,7 @@ public:
} }
} }
const GLubyte * glGetString (GLenum name){ const GLubyte * cglGetString (GLenum name){
const char* result = ""; const char* result = "";
EnsureDriverInfo(); EnsureDriverInfo();
switch ( name ) { switch ( name ) {
@ -2063,28 +2065,28 @@ public:
return (const GLubyte *) result; return (const GLubyte *) result;
} }
void glHint (GLenum /* target */, GLenum /* mode */){ void cglHint (GLenum /* target */, GLenum /* mode */){
LocalDebugBreak(); LocalDebugBreak();
} }
void glLoadIdentity (void){ void cglLoadIdentity (void){
SetRenderStateDirty(); SetRenderStateDirty();
m_currentMatrixStack->LoadIdentity(); m_currentMatrixStack->LoadIdentity();
*m_currentMatrixStateDirty = true; *m_currentMatrixStateDirty = true;
} }
void glLoadMatrixf (const GLfloat *m){ void cglLoadMatrixf (const GLfloat *m){
SetRenderStateDirty(); SetRenderStateDirty();
m_currentMatrixStack->LoadMatrix((D3DXMATRIX*) m); m_currentMatrixStack->LoadMatrix((D3DXMATRIX*) m);
*m_currentMatrixStateDirty = true; *m_currentMatrixStateDirty = true;
} }
void glMultMatrixf (const GLfloat *m){ void cglMultMatrixf (const GLfloat *m){
SetRenderStateDirty(); SetRenderStateDirty();
m_currentMatrixStack->MultMatrixLocal((D3DXMATRIX*) m); m_currentMatrixStack->MultMatrixLocal((D3DXMATRIX*) m);
*m_currentMatrixStateDirty = true; *m_currentMatrixStateDirty = true;
} }
void glMatrixMode (GLenum mode){ void cglMatrixMode (GLenum mode){
m_glMatrixMode = mode; m_glMatrixMode = mode;
switch ( mode ) { switch ( mode ) {
case GL_MODELVIEW: case GL_MODELVIEW:
@ -2105,7 +2107,7 @@ public:
} }
} }
void glOrtho (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar){ void cglOrtho (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar){
SetRenderStateDirty(); SetRenderStateDirty();
D3DXMATRIX m; D3DXMATRIX m;
qD3DXMatrixOrthoOffCenter(&m, left, right, top, bottom, zNear, zFar); qD3DXMatrixOrthoOffCenter(&m, left, right, top, bottom, zNear, zFar);
@ -2113,7 +2115,7 @@ public:
*m_currentMatrixStateDirty = true; *m_currentMatrixStateDirty = true;
} }
void glPolygonMode (GLenum face, GLenum mode){ void cglPolygonMode (GLenum face, GLenum mode){
SetRenderStateDirty(); SetRenderStateDirty();
switch ( face ) { switch ( face ) {
case GL_FRONT: case GL_FRONT:
@ -2132,22 +2134,22 @@ public:
} }
} }
void glPopMatrix (void){ void cglPopMatrix (void){
SetRenderStateDirty(); SetRenderStateDirty();
m_currentMatrixStack->Pop(); m_currentMatrixStack->Pop();
*m_currentMatrixStateDirty = true; *m_currentMatrixStateDirty = true;
} }
void glPushMatrix (void){ void cglPushMatrix (void){
m_currentMatrixStack->Push(); m_currentMatrixStack->Push();
// Doesn't dirty matrix state // Doesn't dirty matrix state
} }
void glReadBuffer (GLenum /* mode */){ void cglReadBuffer (GLenum /* mode */){
// Not that we allow reading from various buffers anyway. // Not that we allow reading from various buffers anyway.
} }
void glReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels){ void cglReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels){
if ( format != GL_RGB || type != GL_UNSIGNED_BYTE) { if ( format != GL_RGB || type != GL_UNSIGNED_BYTE) {
LocalDebugBreak(); LocalDebugBreak();
return; return;
@ -2258,7 +2260,7 @@ public:
} }
} }
void glRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z){ void cglRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z){
SetRenderStateDirty(); SetRenderStateDirty();
D3DXMATRIX m; D3DXMATRIX m;
D3DXVECTOR3 v; D3DXVECTOR3 v;
@ -2271,7 +2273,7 @@ public:
*m_currentMatrixStateDirty = true; *m_currentMatrixStateDirty = true;
} }
void glScalef (GLfloat x, GLfloat y, GLfloat z){ void cglScalef (GLfloat x, GLfloat y, GLfloat z){
SetRenderStateDirty(); SetRenderStateDirty();
D3DXMATRIX m; D3DXMATRIX m;
qD3DXMatrixScaling(&m, x, y, z); qD3DXMatrixScaling(&m, x, y, z);
@ -2279,7 +2281,7 @@ public:
*m_currentMatrixStateDirty = true; *m_currentMatrixStateDirty = true;
} }
void glShadeModel (GLenum mode){ void cglShadeModel (GLenum mode){
if ( m_glShadeModel != mode ) { if ( m_glShadeModel != mode ) {
SetRenderStateDirty(); SetRenderStateDirty();
m_glShadeModel = mode; m_glShadeModel = mode;
@ -2287,11 +2289,11 @@ public:
} }
} }
inline void glTexCoord2f (GLfloat s, GLfloat t){ inline void cglTexCoord2f (GLfloat s, GLfloat t){
m_OGLPrimitiveVertexBuffer.SetTextureCoord0(s, t); m_OGLPrimitiveVertexBuffer.SetTextureCoord0(s, t);
} }
void glTexEnvf (GLenum /* target */, GLenum /* pname */, GLfloat param){ void cglTexEnvf (GLenum /* target */, GLenum /* pname */, GLfloat param){
// ignore target, which must be GL_TEXTURE_ENV // ignore target, which must be GL_TEXTURE_ENV
// ignore pname, which must be GL_TEXTURE_ENV_MODE // ignore pname, which must be GL_TEXTURE_ENV_MODE
if ( m_textureState.GetTextEnvMode() != param ) { if ( m_textureState.GetTextEnvMode() != param ) {
@ -2311,7 +2313,7 @@ public:
#define LOAD_OURSELVES #define LOAD_OURSELVES
void glTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, void cglTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width,
GLsizei height, GLint /* border */, GLenum format, GLenum type, const GLvoid *pixels){ GLsizei height, GLint /* border */, GLenum format, GLenum type, const GLvoid *pixels){
HRESULT hr; HRESULT hr;
if ( target != GL_TEXTURE_2D || type != GL_UNSIGNED_BYTE) { if ( target != GL_TEXTURE_2D || type != GL_UNSIGNED_BYTE) {
@ -2478,7 +2480,7 @@ public:
} }
} }
void glTexParameterf (GLenum target, GLenum pname, GLfloat param){ void cglTexParameterf (GLenum target, GLenum pname, GLfloat param){
switch(target){ switch(target){
case GL_TEXTURE_2D: case GL_TEXTURE_2D:
@ -2513,7 +2515,7 @@ public:
} }
} }
void glTexSubImage2D (GLenum target, GLint level, void cglTexSubImage2D (GLenum target, GLint level,
GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height,
GLenum format, GLenum type, const GLvoid *pixels){ GLenum format, GLenum type, const GLvoid *pixels){
if ( target != GL_TEXTURE_2D ) { if ( target != GL_TEXTURE_2D ) {
@ -2626,7 +2628,7 @@ public:
} }
} }
void glTranslatef (GLfloat x, GLfloat y, GLfloat z){ void cglTranslatef (GLfloat x, GLfloat y, GLfloat z){
SetRenderStateDirty(); SetRenderStateDirty();
D3DXMATRIX m; D3DXMATRIX m;
qD3DXMatrixTranslation(&m, x, y, z); qD3DXMatrixTranslation(&m, x, y, z);
@ -2634,19 +2636,19 @@ public:
*m_currentMatrixStateDirty = true; *m_currentMatrixStateDirty = true;
} }
inline void glVertex2f (GLfloat x, GLfloat y){ inline void cglVertex2f (GLfloat x, GLfloat y){
m_OGLPrimitiveVertexBuffer.SetVertex(x, y, 0); m_OGLPrimitiveVertexBuffer.SetVertex(x, y, 0);
} }
inline void glVertex3f (GLfloat x, GLfloat y, GLfloat z){ inline void cglVertex3f (GLfloat x, GLfloat y, GLfloat z){
m_OGLPrimitiveVertexBuffer.SetVertex(x, y, z); m_OGLPrimitiveVertexBuffer.SetVertex(x, y, z);
} }
inline void glVertex3fv (const GLfloat *v){ inline void cglVertex3fv (const GLfloat *v){
m_OGLPrimitiveVertexBuffer.SetVertex(v[0], v[1], v[2]); m_OGLPrimitiveVertexBuffer.SetVertex(v[0], v[1], v[2]);
} }
void glViewport (GLint x, GLint y, GLsizei width, GLsizei height){ void cglViewport (GLint x, GLint y, GLsizei width, GLsizei height){
if ( m_glViewPortX != x || m_glViewPortY != y || if ( m_glViewPortX != x || m_glViewPortY != y ||
m_glViewPortWidth != width || m_glViewPortHeight != height ) { m_glViewPortWidth != width || m_glViewPortHeight != height ) {
SetRenderStateDirty(); SetRenderStateDirty();
@ -3350,23 +3352,23 @@ private:
#pragma warning(disable:4273) #pragma warning(disable:4273)
void APIENTRY D3DAlphaFunc (GLenum func, GLclampf ref){ void APIENTRY D3DAlphaFunc (GLenum func, GLclampf ref){
gFakeGL->glAlphaFunc(func, ref); gFakeGL->cglAlphaFunc(func, ref);
} }
void APIENTRY D3DBegin (GLenum mode){ void APIENTRY D3DBegin (GLenum mode){
gFakeGL->glBegin(mode); gFakeGL->cglBegin(mode);
} }
void APIENTRY D3DBlendFunc (GLenum sfactor, GLenum dfactor){ void APIENTRY D3DBlendFunc (GLenum sfactor, GLenum dfactor){
gFakeGL->glBlendFunc(sfactor, dfactor); gFakeGL->cglBlendFunc(sfactor, dfactor);
} }
void APIENTRY D3DClear (GLbitfield mask){ void APIENTRY D3DClear (GLbitfield mask){
gFakeGL->glClear(mask); gFakeGL->cglClear(mask);
} }
void APIENTRY D3DClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha){ void APIENTRY D3DClearColor (GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha){
gFakeGL->glClearColor(red, green, blue, alpha); gFakeGL->cglClearColor(red, green, blue, alpha);
} }
void APIENTRY D3DColor3f (GLfloat red, GLfloat green, GLfloat blue){ void APIENTRY D3DColor3f (GLfloat red, GLfloat green, GLfloat blue){
@ -3376,15 +3378,15 @@ void APIENTRY D3DColor3f (GLfloat red, GLfloat green, GLfloat blue){
if (red < 0) red = 0; if (red < 0) red = 0;
if (green < 0) green = 0; if (green < 0) green = 0;
if (blue < 0) blue = 0; if (blue < 0) blue = 0;
gFakeGL->glColor3f(red, green, blue); gFakeGL->cglColor3f(red, green, blue);
} }
void APIENTRY D3DColor3ubv (const GLubyte *v){ void APIENTRY D3DColor3ubv (const GLubyte *v){
gFakeGL->glColor3ubv(v); gFakeGL->cglColor3ubv(v);
} }
void APIENTRY D3DColor3ub (GLubyte v1, GLubyte v2, GLubyte v3) void APIENTRY D3DColor3ub (GLubyte v1, GLubyte v2, GLubyte v3)
{ {
gFakeGL->glColor3f(v1/255.0, v2/255.0, v3/255.0); gFakeGL->cglColor3f(v1/255.0, v2/255.0, v3/255.0);
} }
void APIENTRY D3DColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha){ void APIENTRY D3DColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha){
if (red>1) red = 1; if (red>1) red = 1;
@ -3395,48 +3397,48 @@ void APIENTRY D3DColor4f (GLfloat red, GLfloat green, GLfloat blue, GLfloat alph
if (green < 0) green = 0; if (green < 0) green = 0;
if (blue < 0) blue = 0; if (blue < 0) blue = 0;
if (alpha < 0) alpha = 0; if (alpha < 0) alpha = 0;
gFakeGL->glColor4f(red, green, blue, alpha); gFakeGL->cglColor4f(red, green, blue, alpha);
} }
void APIENTRY D3DColor4fv (const GLfloat *v){ void APIENTRY D3DColor4fv (const GLfloat *v){
gFakeGL->glColor4fv(v); gFakeGL->cglColor4fv(v);
} }
void APIENTRY D3DColor4ubv (const GLubyte *v) //no bounds checking needed void APIENTRY D3DColor4ubv (const GLubyte *v) //no bounds checking needed
{ {
gFakeGL->glColor4f(v[0]/255.0, v[1]/255.0, v[2]/255.0, v[3]/255.0); gFakeGL->cglColor4f(v[0]/255.0, v[1]/255.0, v[2]/255.0, v[3]/255.0);
} }
void APIENTRY D3DColor4ub (GLubyte v1, GLubyte v2, GLubyte v3, GLubyte v4) void APIENTRY D3DColor4ub (GLubyte v1, GLubyte v2, GLubyte v3, GLubyte v4)
{ {
gFakeGL->glColor4f(v1/255.0, v2/255.0, v3/255.0, v4/255.0); gFakeGL->cglColor4f(v1/255.0, v2/255.0, v3/255.0, v4/255.0);
} }
void APIENTRY D3DCullFace (GLenum mode){ void APIENTRY D3DCullFace (GLenum mode){
gFakeGL->glCullFace(mode); gFakeGL->cglCullFace(mode);
} }
void APIENTRY D3DDepthFunc (GLenum func){ void APIENTRY D3DDepthFunc (GLenum func){
gFakeGL->glDepthFunc(func); gFakeGL->cglDepthFunc(func);
} }
void APIENTRY D3DDepthMask (GLboolean flag){ void APIENTRY D3DDepthMask (GLboolean flag){
gFakeGL->glDepthMask(flag); gFakeGL->cglDepthMask(flag);
} }
void APIENTRY D3DDepthRange (GLclampd zNear, GLclampd zFar){ void APIENTRY D3DDepthRange (GLclampd zNear, GLclampd zFar){
gFakeGL->glDepthRange(zNear, zFar); gFakeGL->cglDepthRange(zNear, zFar);
} }
void APIENTRY D3DDisable (GLenum cap){ void APIENTRY D3DDisable (GLenum cap){
gFakeGL->glDisable(cap); gFakeGL->cglDisable(cap);
} }
void APIENTRY D3DDrawBuffer (GLenum mode){ void APIENTRY D3DDrawBuffer (GLenum mode){
gFakeGL->glDrawBuffer(mode); gFakeGL->cglDrawBuffer(mode);
} }
void APIENTRY D3DEnable (GLenum cap){ void APIENTRY D3DEnable (GLenum cap){
gFakeGL->glEnable(cap); gFakeGL->cglEnable(cap);
} }
void APIENTRY D3DEnd (void){ void APIENTRY D3DEnd (void){
@ -3445,111 +3447,111 @@ void APIENTRY D3DEnd (void){
} }
void APIENTRY D3DFinish (void){ void APIENTRY D3DFinish (void){
gFakeGL->glFinish(); gFakeGL->cglFinish();
} }
void APIENTRY D3DFrustum (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar){ void APIENTRY D3DFrustum (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar){
gFakeGL->glFrustum(left, right, bottom, top, zNear, zFar); gFakeGL->cglFrustum(left, right, bottom, top, zNear, zFar);
} }
void APIENTRY D3DGetFloatv (GLenum pname, GLfloat *params){ void APIENTRY D3DGetFloatv (GLenum pname, GLfloat *params){
gFakeGL->glGetFloatv(pname, params); gFakeGL->cglGetFloatv(pname, params);
} }
const GLubyte * APIENTRY D3DGetString (GLenum name){ const GLubyte * APIENTRY D3DGetString (GLenum name){
return gFakeGL->glGetString(name); return gFakeGL->cglGetString(name);
} }
void APIENTRY D3DHint (GLenum target, GLenum mode){ void APIENTRY D3DHint (GLenum target, GLenum mode){
gFakeGL->glHint(target, mode); gFakeGL->cglHint(target, mode);
} }
void APIENTRY D3DLoadIdentity (void){ void APIENTRY D3DLoadIdentity (void){
gFakeGL->glLoadIdentity(); gFakeGL->cglLoadIdentity();
} }
void APIENTRY D3DLoadMatrixf (const GLfloat *m){ void APIENTRY D3DLoadMatrixf (const GLfloat *m){
gFakeGL->glLoadMatrixf(m); gFakeGL->cglLoadMatrixf(m);
} }
void APIENTRY D3DMatrixMode (GLenum mode){ void APIENTRY D3DMatrixMode (GLenum mode){
gFakeGL->glMatrixMode(mode); gFakeGL->cglMatrixMode(mode);
} }
void APIENTRY D3DOrtho (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar){ void APIENTRY D3DOrtho (GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble zNear, GLdouble zFar){
gFakeGL->glOrtho(left, right, top, bottom, zNear, zFar); gFakeGL->cglOrtho(left, right, top, bottom, zNear, zFar);
} }
void APIENTRY D3DPolygonMode (GLenum face, GLenum mode){ void APIENTRY D3DPolygonMode (GLenum face, GLenum mode){
gFakeGL->glPolygonMode(face, mode); gFakeGL->cglPolygonMode(face, mode);
} }
void APIENTRY D3DPopMatrix (void){ void APIENTRY D3DPopMatrix (void){
gFakeGL->glPopMatrix(); gFakeGL->cglPopMatrix();
} }
void APIENTRY D3DPushMatrix (void){ void APIENTRY D3DPushMatrix (void){
gFakeGL->glPushMatrix(); gFakeGL->cglPushMatrix();
} }
void APIENTRY D3DReadBuffer (GLenum mode){ void APIENTRY D3DReadBuffer (GLenum mode){
gFakeGL->glReadBuffer(mode); gFakeGL->cglReadBuffer(mode);
} }
void APIENTRY D3DReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels){ void APIENTRY D3DReadPixels (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels){
gFakeGL->glReadPixels(x, y, width, height, format, type, pixels); gFakeGL->cglReadPixels(x, y, width, height, format, type, pixels);
} }
void APIENTRY D3DRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z){ void APIENTRY D3DRotatef (GLfloat angle, GLfloat x, GLfloat y, GLfloat z){
gFakeGL->glRotatef(angle, x, y, z); gFakeGL->cglRotatef(angle, x, y, z);
} }
void APIENTRY D3DScalef (GLfloat x, GLfloat y, GLfloat z){ void APIENTRY D3DScalef (GLfloat x, GLfloat y, GLfloat z){
gFakeGL->glScalef(x, y, z); gFakeGL->cglScalef(x, y, z);
} }
void APIENTRY D3DShadeModel (GLenum mode){ void APIENTRY D3DShadeModel (GLenum mode){
gFakeGL->glShadeModel(mode); gFakeGL->cglShadeModel(mode);
} }
void APIENTRY D3DTexCoord2f (GLfloat s, GLfloat t){ void APIENTRY D3DTexCoord2f (GLfloat s, GLfloat t){
gFakeGL->glTexCoord2f(s, t); gFakeGL->cglTexCoord2f(s, t);
} }
void APIENTRY D3DTexEnvf (GLenum target, GLenum pname, GLfloat param){ void APIENTRY D3DTexEnvf (GLenum target, GLenum pname, GLfloat param){
gFakeGL->glTexEnvf(target, pname, param); gFakeGL->cglTexEnvf(target, pname, param);
} }
void APIENTRY D3DTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels){ void APIENTRY D3DTexImage2D (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels){
gFakeGL->glTexImage2D(target, level, internalformat, width, height, border, format, type, pixels); gFakeGL->cglTexImage2D(target, level, internalformat, width, height, border, format, type, pixels);
} }
void APIENTRY D3DTexParameterf (GLenum target, GLenum pname, GLfloat param){ void APIENTRY D3DTexParameterf (GLenum target, GLenum pname, GLfloat param){
gFakeGL->glTexParameterf(target, pname, param); gFakeGL->cglTexParameterf(target, pname, param);
} }
void APIENTRY D3DTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels){ void APIENTRY D3DTexSubImage2D (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels){
gFakeGL->glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels); gFakeGL->cglTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels);
} }
void APIENTRY D3DTranslatef (GLfloat x, GLfloat y, GLfloat z){ void APIENTRY D3DTranslatef (GLfloat x, GLfloat y, GLfloat z){
gFakeGL->glTranslatef(x, y, z); gFakeGL->cglTranslatef(x, y, z);
} }
void APIENTRY D3DVertex2f (GLfloat x, GLfloat y){ void APIENTRY D3DVertex2f (GLfloat x, GLfloat y){
gFakeGL->glVertex2f(x, y); gFakeGL->cglVertex2f(x, y);
} }
void APIENTRY D3DVertex3f (GLfloat x, GLfloat y, GLfloat z){ void APIENTRY D3DVertex3f (GLfloat x, GLfloat y, GLfloat z){
gFakeGL->glVertex3f(x, y, z); gFakeGL->cglVertex3f(x, y, z);
} }
void APIENTRY D3DVertex3fv (const GLfloat *v){ void APIENTRY D3DVertex3fv (const GLfloat *v){
gFakeGL->glVertex3fv(v); gFakeGL->cglVertex3fv(v);
} }
void APIENTRY D3DViewport (GLint x, GLint y, GLsizei width, GLsizei height){ void APIENTRY D3DViewport (GLint x, GLint y, GLsizei width, GLsizei height){
gFakeGL->glViewport(x, y, width, height); gFakeGL->cglViewport(x, y, width, height);
} }
HDC gHDC; HDC gHDC;
@ -3581,15 +3583,15 @@ HDC WINAPI D3DwglGetCurrentDC(VOID){
} }
static void APIENTRY D3DBindTextureExt(GLenum target, GLuint texture){ static void APIENTRY D3DBindTextureExt(GLenum target, GLuint texture){
gFakeGL->glBindTexture(target, texture); gFakeGL->cglBindTexture(target, texture);
} }
static void APIENTRY D3DMTexCoord2fSGIS(GLenum target, GLfloat s, GLfloat t){ static void APIENTRY D3DMTexCoord2fSGIS(GLenum target, GLfloat s, GLfloat t){
gFakeGL->glMTexCoord2fSGIS(target, s, t); gFakeGL->cglMTexCoord2fSGIS(target, s, t);
} }
static void APIENTRY D3DSelectTextureSGIS(GLenum target){ static void APIENTRY D3DSelectTextureSGIS(GLenum target){
gFakeGL->glSelectTextureSGIS(target); gFakeGL->cglSelectTextureSGIS(target);
} }
// type cast unsafe conversion from // type cast unsafe conversion from
@ -3704,7 +3706,7 @@ void APIENTRY D3DTexEnvi (GLenum target, GLenum pname, GLint param)
} }
void APIENTRY D3DMultMatrixf (const GLfloat *m) void APIENTRY D3DMultMatrixf (const GLfloat *m)
{ {
gFakeGL->glMultMatrixf(m); gFakeGL->cglMultMatrixf(m);
} }
void APIENTRY D3DNormal3f(GLfloat x, GLfloat y, GLfloat z) void APIENTRY D3DNormal3f(GLfloat x, GLfloat y, GLfloat z)

View file

@ -370,7 +370,9 @@ progfuncs_t deffuncs = {
PR_ResumeThread, PR_ResumeThread,
PR_AbortStack, PR_AbortStack,
0 0,
QC_RegisterFieldVar
}; };
#undef printf #undef printf

View file

@ -123,6 +123,8 @@ struct progfuncs_s {
void (*AbortStack) (progfuncs_t *prinst); void (*AbortStack) (progfuncs_t *prinst);
int lastcalledbuiltinnumber; int lastcalledbuiltinnumber;
int (*RegisterFieldVar) (progfuncs_t *prinst, unsigned int type, char *name, int requestedpos, int origionalofs);
}; };
typedef struct progexterns_s { typedef struct progexterns_s {
@ -204,6 +206,8 @@ typedef union eval_s
#define PR_globals(pf, num) (*pf->globals) (pf, num) #define PR_globals(pf, num) (*pf->globals) (pf, num)
#define PR_entvars(pf, ent) (*pf->entvars) (pf, ent) #define PR_entvars(pf, ent) (*pf->entvars) (pf, ent)
#define PR_RegisterFieldVar(pf,type,name,reqofs,qcofs) (*pf->RegisterFieldVar) (pf,type,name,reqofs,qcofs)
#define ED_Alloc(pf) (*pf->ED_Alloc) (pf) #define ED_Alloc(pf) (*pf->ED_Alloc) (pf)
#define ED_Free(pf, ed) (*pf->ED_Free) (pf, ed) #define ED_Free(pf, ed) (*pf->ED_Free) (pf, ed)

View file

@ -23,7 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#ifndef CLIENTONLY #ifndef CLIENTONLY
//okay, so these are a quick but easy hack //okay, so these are a quick but easy hack
int QC_RegisterFieldVar(struct progfuncs_s *progfuncs, unsigned int type, char *name, int requestedpos, int origionalofs);
void ED_Print (struct progfuncs_s *progfuncs, struct edict_s *ed); void ED_Print (struct progfuncs_s *progfuncs, struct edict_s *ed);
int PR_EnableEBFSBuiltin(char *name, int binum); int PR_EnableEBFSBuiltin(char *name, int binum);
void PR_CleanLogText_Init (void); void PR_CleanLogText_Init (void);
@ -8235,11 +8234,11 @@ void PR_RegisterSVBuiltins(void)
void PR_RegisterFields(void) //it's just easier to do it this way. void PR_RegisterFields(void) //it's just easier to do it this way.
{ {
#define fieldfloat(name) QC_RegisterFieldVar(svprogfuncs, ev_float, #name, (int)&((edict_t*)0)->v.name - (int)&((edict_t*)0)->v, -1) #define fieldfloat(name) PR_RegisterFieldVar(svprogfuncs, ev_float, #name, (int)&((edict_t*)0)->v.name - (int)&((edict_t*)0)->v, -1)
#define fieldvector(name) QC_RegisterFieldVar(svprogfuncs, ev_vector, #name, (int)&((edict_t*)0)->v.name - (int)&((edict_t*)0)->v, -1) #define fieldvector(name) PR_RegisterFieldVar(svprogfuncs, ev_vector, #name, (int)&((edict_t*)0)->v.name - (int)&((edict_t*)0)->v, -1)
#define fieldentity(name) QC_RegisterFieldVar(svprogfuncs, ev_entity, #name, (int)&((edict_t*)0)->v.name - (int)&((edict_t*)0)->v, -1) #define fieldentity(name) PR_RegisterFieldVar(svprogfuncs, ev_entity, #name, (int)&((edict_t*)0)->v.name - (int)&((edict_t*)0)->v, -1)
#define fieldstring(name) QC_RegisterFieldVar(svprogfuncs, ev_string, #name, (int)&((edict_t*)0)->v.name - (int)&((edict_t*)0)->v, -1) #define fieldstring(name) PR_RegisterFieldVar(svprogfuncs, ev_string, #name, (int)&((edict_t*)0)->v.name - (int)&((edict_t*)0)->v, -1)
#define fieldfunction(name) QC_RegisterFieldVar(svprogfuncs, ev_function, #name, (int)&((edict_t*)0)->v.name - (int)&((edict_t*)0)->v, -1) #define fieldfunction(name) PR_RegisterFieldVar(svprogfuncs, ev_function, #name, (int)&((edict_t*)0)->v.name - (int)&((edict_t*)0)->v, -1)
fieldfloat(modelindex); fieldfloat(modelindex);
fieldvector(absmin); fieldvector(absmin);
@ -8333,11 +8332,10 @@ void PR_RegisterFields(void) //it's just easier to do it this way.
fieldfloat(alpha); fieldfloat(alpha);
fieldfloat(fatness); fieldfloat(fatness);
fieldentity(view2); fieldentity(view2);
fieldfloat(sendflags);
fieldvector(movement); fieldvector(movement);
QC_RegisterFieldVar(svprogfuncs, ev_float, "buttonforward", (int)&((edict_t*)0)->v.movement[0] - (int)&((edict_t*)0)->v, -1); PR_RegisterFieldVar(svprogfuncs, ev_float, "buttonforward", (int)&((edict_t*)0)->v.movement[0] - (int)&((edict_t*)0)->v, -1);
QC_RegisterFieldVar(svprogfuncs, ev_float, "buttonright", (int)&((edict_t*)0)->v.movement[1] - (int)&((edict_t*)0)->v, -1); PR_RegisterFieldVar(svprogfuncs, ev_float, "buttonright", (int)&((edict_t*)0)->v.movement[1] - (int)&((edict_t*)0)->v, -1);
QC_RegisterFieldVar(svprogfuncs, ev_float, "buttonup", (int)&((edict_t*)0)->v.movement[2] - (int)&((edict_t*)0)->v, -1); PR_RegisterFieldVar(svprogfuncs, ev_float, "buttonup", (int)&((edict_t*)0)->v.movement[2] - (int)&((edict_t*)0)->v, -1);
fieldfloat(fteflags); fieldfloat(fteflags);
fieldfloat(vweapmodelindex); fieldfloat(vweapmodelindex);
@ -8346,11 +8344,11 @@ void PR_RegisterFields(void) //it's just easier to do it this way.
fieldentity(drawonlytoclient); fieldentity(drawonlytoclient);
//UDC_EXTEFFECT... yuckie //UDC_EXTEFFECT... yuckie
QC_RegisterFieldVar(svprogfuncs, ev_float, "fieldcolor", (int)&((edict_t*)0)->v.seefcolour - (int)&((edict_t*)0)->v, -1); PR_RegisterFieldVar(svprogfuncs, ev_float, "fieldcolor", (int)&((edict_t*)0)->v.seefcolour - (int)&((edict_t*)0)->v, -1);
QC_RegisterFieldVar(svprogfuncs, ev_float, "fieldsizex", (int)&((edict_t*)0)->v.seefsizex - (int)&((edict_t*)0)->v, -1); PR_RegisterFieldVar(svprogfuncs, ev_float, "fieldsizex", (int)&((edict_t*)0)->v.seefsizex - (int)&((edict_t*)0)->v, -1);
QC_RegisterFieldVar(svprogfuncs, ev_float, "fieldsizey", (int)&((edict_t*)0)->v.seefsizey - (int)&((edict_t*)0)->v, -1); PR_RegisterFieldVar(svprogfuncs, ev_float, "fieldsizey", (int)&((edict_t*)0)->v.seefsizey - (int)&((edict_t*)0)->v, -1);
QC_RegisterFieldVar(svprogfuncs, ev_float, "fieldsizez", (int)&((edict_t*)0)->v.seefsizez - (int)&((edict_t*)0)->v, -1); PR_RegisterFieldVar(svprogfuncs, ev_float, "fieldsizez", (int)&((edict_t*)0)->v.seefsizez - (int)&((edict_t*)0)->v, -1);
QC_RegisterFieldVar(svprogfuncs, ev_float, "fieldoffset", (int)&((edict_t*)0)->v.seefoffset - (int)&((edict_t*)0)->v, -1); PR_RegisterFieldVar(svprogfuncs, ev_float, "fieldoffset", (int)&((edict_t*)0)->v.seefoffset - (int)&((edict_t*)0)->v, -1);
//hexen 2 stuff //hexen 2 stuff
fieldfloat(playerclass); fieldfloat(playerclass);
@ -8372,7 +8370,7 @@ void PR_RegisterFields(void) //it's just easier to do it this way.
fieldfloat(dimension_hit); fieldfloat(dimension_hit);
if (pr_fixbrokenqccarrays.value) if (pr_fixbrokenqccarrays.value)
QC_RegisterFieldVar(svprogfuncs, 0, NULL, 0,0); PR_RegisterFieldVar(svprogfuncs, 0, NULL, 0,0);
} }

View file

@ -232,7 +232,6 @@ typedef struct entvars_s
float alpha; float alpha;
float fatness; float fatness;
int view2; int view2;
float sendflags;
float fteflags; float fteflags;
vec3_t movement; vec3_t movement;
float vweapmodelindex; float vweapmodelindex;

View file

@ -111,6 +111,9 @@ int numlight;
extern int sv_lightningmodel; extern int sv_lightningmodel;
#endif #endif
edict_t *csqcent[MAX_EDICTS];
int csqcnuments;
qboolean SV_AddNailUpdate (edict_t *ent) qboolean SV_AddNailUpdate (edict_t *ent)
{ {
if (ent->v.modelindex != sv_nailmodel if (ent->v.modelindex != sv_nailmodel
@ -140,6 +143,16 @@ qboolean SV_DemoNailUpdate (int i)
return true; return true;
} }
static qboolean SV_AddCSQCUpdate (edict_t *ent)
{
// if (!ent->sendcsqc)
return false;
// csqcent[csqcnuments++] = ent;
// return true;
}
#ifdef PEXT_LIGHTUPDATES #ifdef PEXT_LIGHTUPDATES
qboolean SV_AddLightUpdate (edict_t *ent) qboolean SV_AddLightUpdate (edict_t *ent)
{ {
@ -258,6 +271,11 @@ void SV_EmitNailUpdate (sizebuf_t *msg, qboolean recorder)
} }
} }
void SV_EmitCSQCUpdate(client_t *client, sizebuf_t *msg)
{
}
//============================================================================= //=============================================================================
@ -836,6 +854,7 @@ void SV_WritePlayerToClient(sizebuf_t *msg, clstate_t *ent)
#endif #endif
#ifdef PEXT_SEEF1
#define EFNQ_DARKLIGHT 16 #define EFNQ_DARKLIGHT 16
#define EFNQ_DARKFIELD 32 #define EFNQ_DARKFIELD 32
#define EFNQ_LIGHT 64 #define EFNQ_LIGHT 64
@ -956,9 +975,10 @@ void SV_AddEffect(client_t *to, edict_t *ent, int seefno)
break; break;
} }
} }
#endif
void SV_SendExtraEntEffects(client_t *to, edict_t *ent) void SV_SendExtraEntEffects(client_t *to, edict_t *ent)
{ {
#ifdef PEXT_SEEF1
int removeeffects = 0; int removeeffects = 0;
if (pr_udc_exteffect_enabled) if (pr_udc_exteffect_enabled)
{ {
@ -1018,6 +1038,7 @@ void SV_SendExtraEntEffects(client_t *to, edict_t *ent)
SV_RemoveEffect(to, ent, removeeffects); SV_RemoveEffect(to, ent, removeeffects);
} }
} }
#endif
} }
/* /*
============= =============
@ -1314,6 +1335,9 @@ void SV_WritePlayersToClient (client_t *client, edict_t *clent, qbyte *pvs, size
continue; //not in this dimension - sorry... continue; //not in this dimension - sorry...
} }
if (SV_AddCSQCUpdate(ent))
continue;
{ {
clstate_t clst; clstate_t clst;
clst.playernum = j; clst.playernum = j;
@ -1726,6 +1750,7 @@ qboolean Q2BSP_EdictInFatPVS(edict_t *ent)
return true; return true;
} }
#endif #endif
/* /*
============= =============
SV_WriteEntitiesToClient SV_WriteEntitiesToClient
@ -2048,34 +2073,7 @@ void SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg, qboolean ignore
// if (strstr(sv.model_precache[(int)ent->v.modelindex], "gib")) // if (strstr(sv.model_precache[(int)ent->v.modelindex], "gib"))
// continue; // continue;
//QC code doesn't want some clients to see some ents.
#define SF_OWNERSEEONLY 1
#define SF_OWNERDONTSEE 2
#define SF_OWNERTEAMONLY 4
#define SF_OWNERTEAMDONTSEE 8
if (ent->v.sendflags && !ignorepvs) //hmm
{
if ((int)ent->v.sendflags & SF_OWNERSEEONLY)
{
if (PROG_TO_EDICT(svprogfuncs, ent->v.owner) != clent)
continue;
}
if ((int)ent->v.sendflags & SF_OWNERDONTSEE)
{
if (PROG_TO_EDICT(svprogfuncs, ent->v.owner) == clent)
continue;
}
if ((int)ent->v.sendflags & SF_OWNERTEAMONLY)
{
if (ent->v.team != clent->v.team)
continue;
}
if ((int)ent->v.sendflags & SF_OWNERTEAMDONTSEE)
{
if (ent->v.team == clent->v.team)
continue;
}
}
if (ent->v.nodrawtoclient) //DP extension. if (ent->v.nodrawtoclient) //DP extension.
if (ent->v.nodrawtoclient == EDICT_TO_PROG(svprogfuncs, client->edict)) if (ent->v.nodrawtoclient == EDICT_TO_PROG(svprogfuncs, client->edict))
continue; continue;
@ -2097,6 +2095,9 @@ void SV_WriteEntitiesToClient (client_t *client, sizebuf_t *msg, qboolean ignore
if (!((int)client->edict->v.dimension_see & ((int)ent->v.dimension_seen | (int)ent->v.dimension_ghost))) if (!((int)client->edict->v.dimension_see & ((int)ent->v.dimension_seen | (int)ent->v.dimension_ghost)))
continue; //not in this dimension - sorry... continue; //not in this dimension - sorry...
if (SV_AddCSQCUpdate(ent)) //csqc took it.
continue;
#ifdef NQPROT #ifdef NQPROT
if (nqprot) if (nqprot)
{ {

View file

@ -3036,7 +3036,9 @@ void SV_InitLocal (void)
#ifdef PEXT_FLOATCOORDS #ifdef PEXT_FLOATCOORDS
svs.fteprotocolextensions |= PEXT_FLOATCOORDS; svs.fteprotocolextensions |= PEXT_FLOATCOORDS;
#endif #endif
#ifdef PEXT_SEEF1
svs.fteprotocolextensions |= PEXT_SEEF1; svs.fteprotocolextensions |= PEXT_SEEF1;
#endif
svs.fteprotocolextensions |= PEXT_SPLITSCREEN; svs.fteprotocolextensions |= PEXT_SPLITSCREEN;
svs.fteprotocolextensions |= PEXT_HEXEN2; svs.fteprotocolextensions |= PEXT_HEXEN2;
svs.fteprotocolextensions |= PEXT_SPAWNSTATIC2; svs.fteprotocolextensions |= PEXT_SPAWNSTATIC2;

View file

@ -1389,10 +1389,11 @@ void SV_UpdateToReliableMessages (void)
if (svprogfuncs) if (svprogfuncs)
{ {
extern cvar_t sv_gravity;
// maxspeed/entgravity changes // maxspeed/entgravity changes
ent = host_client->edict; ent = host_client->edict;
newval = ent->v.gravity; newval = ent->v.gravity*sv_gravity.value;
if (progstype == PROG_NQ) if (progstype == PROG_NQ)
{ {
if (!newval) if (!newval)
@ -1413,7 +1414,7 @@ void SV_UpdateToReliableMessages (void)
else */if (host_client->entgravity != newval) else */if (host_client->entgravity != newval)
{ {
ClientReliableWrite_Begin(host_client, svc_entgravity, 5); ClientReliableWrite_Begin(host_client, svc_entgravity, 5);
ClientReliableWrite_Float(host_client, newval); ClientReliableWrite_Float(host_client, newval/movevars.gravity); //lie to the client in a cunning way
host_client->entgravity = newval; host_client->entgravity = newval;
} }
newval = ent->v.maxspeed; newval = ent->v.maxspeed;

View file

@ -2974,6 +2974,7 @@ void SV_ExecuteUserCommand (char *s, qboolean fromQC)
#ifdef NQPROT #ifdef NQPROT
void SVNQ_Spawn_f (void) void SVNQ_Spawn_f (void)
{ {
extern cvar_t sv_gravity;
int i; int i;
client_t *client; client_t *client;
edict_t *ent; edict_t *ent;
@ -3008,7 +3009,7 @@ void SVNQ_Spawn_f (void)
if (host_client->istobeloaded) //minimal setup if (host_client->istobeloaded) //minimal setup
{ {
host_client->entgravity = ent->v.gravity; host_client->entgravity = ent->v.gravity*sv_gravity.value;
host_client->maxspeed = ent->v.maxspeed; host_client->maxspeed = ent->v.maxspeed;
} }
else else
@ -3021,6 +3022,7 @@ void SVNQ_Spawn_f (void)
ent->v.netname = PR_SetString(svprogfuncs, host_client->name); ent->v.netname = PR_SetString(svprogfuncs, host_client->name);
host_client->entgravity = ent->v.gravity = 1.0; host_client->entgravity = ent->v.gravity = 1.0;
host_client->entgravity*=sv_gravity.value;
host_client->maxspeed = ent->v.maxspeed = sv_maxspeed.value; host_client->maxspeed = ent->v.maxspeed = sv_maxspeed.value;
} }
@ -3687,6 +3689,7 @@ void SV_RunCmd (usercmd_t *ucmd, qboolean recurse)
int oldmsec; int oldmsec;
double tmp_time; double tmp_time;
qboolean jumpable; qboolean jumpable;
extern cvar_t sv_gravity;
#ifdef Q2SERVER #ifdef Q2SERVER
if (!svprogfuncs) if (!svprogfuncs)
@ -3929,7 +3932,7 @@ void SV_RunCmd (usercmd_t *ucmd, qboolean recurse)
else else
pmove.hullnum = SV_HullNumForPlayer(sv_player->v.hull, sv_player->v.mins, sv_player->v.maxs); pmove.hullnum = SV_HullNumForPlayer(sv_player->v.hull, sv_player->v.mins, sv_player->v.maxs);
movevars.entgravity = host_client->entgravity; movevars.entgravity = host_client->entgravity/movevars.gravity;
movevars.maxspeed = host_client->maxspeed; movevars.maxspeed = host_client->maxspeed;
movevars.bunnyspeedcap = pm_bunnyspeedcap.value; movevars.bunnyspeedcap = pm_bunnyspeedcap.value;
movevars.ktjump = pm_ktjump.value; movevars.ktjump = pm_ktjump.value;

View file

@ -13,24 +13,6 @@ void SV_BuildClientFrame (client_t *client)
} }
#else #else
#define Q2PS_M_TYPE (1<<0)
#define Q2PS_M_ORIGIN (1<<1)
#define Q2PS_M_VELOCITY (1<<2)
#define Q2PS_M_TIME (1<<3)
#define Q2PS_M_FLAGS (1<<4)
#define Q2PS_M_GRAVITY (1<<5)
#define Q2PS_M_DELTA_ANGLES (1<<6)
#define Q2PS_VIEWOFFSET (1<<7)
#define Q2PS_VIEWANGLES (1<<8)
#define Q2PS_KICKANGLES (1<<9)
#define Q2PS_BLEND (1<<10)
#define Q2PS_FOV (1<<11)
#define Q2PS_WEAPONINDEX (1<<12)
#define Q2PS_WEAPONFRAME (1<<13)
#define Q2PS_RDFLAGS (1<<14)
#define Q2RF_BEAM 128
q2entity_state_t *svs_client_entities;//[Q2UPDATE_BACKUP*MAX_PACKET_ENTITIES]; q2entity_state_t *svs_client_entities;//[Q2UPDATE_BACKUP*MAX_PACKET_ENTITIES];
int svs_num_client_entities; int svs_num_client_entities;
int svs_next_client_entities; int svs_next_client_entities;

View file

@ -734,39 +734,24 @@ vec_t VI2Length(int x, int y)
length = sqrt (length); length = sqrt (length);
return length; return length;
} }
void D_DrawSparkTrans32 (particle_t *pparticle) //draw a line in 3d space void D_DrawSparkTrans32 (particle_t *pparticle, vec3_t src, vec3_t dest) //draw a line in 3d space
{ {
/* /*
Finds 2d coords for the points, then draws a line between them with an appropriate alpha Finds 2d coords for the points, then draws a line between them with an appropriate alpha
*/ */
vec3_t delta;
unsigned char *pdest; unsigned char *pdest;
unsigned char *pal; unsigned char *pal;
short *pz; short *pz;
int count, u1, v1, z1, a1, a, ia; int count, u1, v1, z1, a1, a, ia;
int u2, v2, z2; int u2, v2, z2;
float speed;
int du, dv, dz, da; int du, dv, dz, da;
if (pparticle->alpha <= 0.0) if (pparticle->alpha <= 0.0)
return; return;
speed = Length(pparticle->vel); D_2dPos(src, &u1, &v1, &z1);
if ((speed) < 1) D_2dPos(dest, &u2, &v2, &z2);
{
D_2dPos(pparticle->org, &u1, &v1, &z1);
D_2dPos(pparticle->org, &u2, &v2, &z2);
}
else
{ //causes flickers with lower vels (due to bouncing in physics)
if (speed < 50)
speed *= 50/speed;
VectorMA(pparticle->org, 5/(speed), pparticle->vel, delta);
D_2dPos(delta, &u1, &v1, &z1);
VectorMA(pparticle->org, -5/(speed), pparticle->vel, delta);
D_2dPos(delta, &u2, &v2, &z2);
}
if ((v1 > d_vrectbottom_particle) || if ((v1 > d_vrectbottom_particle) ||
(u1 > d_vrectright_particle) || (u1 > d_vrectright_particle) ||
@ -837,35 +822,20 @@ pal = (qbyte *)(d_8to32table + (int)pparticle->color);
} while (count--); } while (count--);
} }
void D_DrawSparkTrans16 (particle_t *pparticle) //draw a line in 3d space, 8bpp void D_DrawSparkTrans16 (particle_t *pparticle, vec3_t src, vec3_t dest) //draw a line in 3d space, 8bpp
{ {
vec3_t delta;
unsigned short *pdest; unsigned short *pdest;
short *pz; short *pz;
int count, u1, v1, z1; int count, u1, v1, z1;
int u2, v2, z2; int u2, v2, z2;
float speed;
int du, dv, dz; int du, dv, dz;
if (pparticle->alpha <= 0.0) if (pparticle->alpha <= 0.0)
return; return;
speed = Length(pparticle->vel); D_2dPos(src, &u1, &v1, &z1);
if ((speed) < 1) D_2dPos(dest, &u2, &v2, &z2);
{
D_2dPos(pparticle->org, &u1, &v1, &z1);
D_2dPos(pparticle->org, &u2, &v2, &z2);
}
else
{ //causes flickers with lower vels (due to bouncing in physics)
if (speed < 50)
speed *= 50/speed;
VectorMA(pparticle->org, 2.5/(speed), pparticle->vel, delta);
D_2dPos(delta, &u1, &v1, &z1);
VectorMA(pparticle->org, -2.5/(speed), pparticle->vel, delta);
D_2dPos(delta, &u2, &v2, &z2);
}
if ((v1 > d_vrectbottom_particle) || if ((v1 > d_vrectbottom_particle) ||
(u1 > d_vrectright_particle) || (u1 > d_vrectright_particle) ||
@ -925,14 +895,12 @@ void D_DrawSparkTrans16 (particle_t *pparticle) //draw a line in 3d space, 8bpp
} while (count--); } while (count--);
} }
void D_DrawSparkTrans (particle_t *pparticle) //draw a line in 3d space, 8bpp void D_DrawSparkTrans (particle_t *pparticle, vec3_t src, vec3_t dest) //draw a line in 3d space, 8bpp
{ {
vec3_t delta;
qbyte *pdest; qbyte *pdest;
short *pz; short *pz;
int count, u1, v1, z1; int count, u1, v1, z1;
int u2, v2, z2; int u2, v2, z2;
float speed;
int du, dv, dz; int du, dv, dz;
/* /*
@ -941,12 +909,12 @@ void D_DrawSparkTrans (particle_t *pparticle) //draw a line in 3d space, 8bpp
*/ */
if (r_pixbytes == 4) if (r_pixbytes == 4)
{ {
D_DrawSparkTrans32(pparticle); D_DrawSparkTrans32(pparticle, src, dest);
return; return;
} }
if (r_pixbytes == 2) if (r_pixbytes == 2)
{ {
D_DrawSparkTrans16(pparticle); D_DrawSparkTrans16(pparticle, src, dest);
return; return;
} }
@ -955,21 +923,8 @@ void D_DrawSparkTrans (particle_t *pparticle) //draw a line in 3d space, 8bpp
if (t_state & TT_ZERO) if (t_state & TT_ZERO)
return; return;
speed = Length(pparticle->vel); D_2dPos(src, &u1, &v1, &z1);
if ((speed) < 1) D_2dPos(dest, &u2, &v2, &z2);
{
D_2dPos(pparticle->org, &u1, &v1, &z1);
D_2dPos(pparticle->org, &u2, &v2, &z2);
}
else
{ //causes flickers with lower vels (due to bouncing in physics)
if (speed < 50)
speed *= 50/speed;
VectorMA(pparticle->org, 2.5/(speed), pparticle->vel, delta);
D_2dPos(delta, &u1, &v1, &z1);
VectorMA(pparticle->org, -2.5/(speed), pparticle->vel, delta);
D_2dPos(delta, &u2, &v2, &z2);
}
if ((v1 > d_vrectbottom_particle) || if ((v1 > d_vrectbottom_particle) ||
(u1 > d_vrectright_particle) || (u1 > d_vrectright_particle) ||

View file

@ -79,7 +79,7 @@ void R_CalcTransTable(int table, int level)
else else
rvr = 0; rvr = 0;
COM_FOpenFile (va("data/ttable%i.dat", (int) level) , &f); //we can ignore the filesize return value COM_FOpenFile (va("tables/ttable%i.dat", (int) level) , &f); //we can ignore the filesize return value
if (f) if (f)
{ {
if (fread (t_lookup[table], 256, 256, f) == 256) if (fread (t_lookup[table], 256, 256, f) == 256)
@ -126,14 +126,14 @@ void R_CalcTransTable(int table, int level)
if (r_transtablewrite.value) if (r_transtablewrite.value)
{ {
COM_CreatePath(va("%s/data/", com_gamedir)); COM_CreatePath(va("%s/tables/", com_gamedir));
#if 1 #if 1
f = fopen (va("%s/data/ttable%i.dat", com_gamedir, (int) level), "wb"); f = fopen (va("%s/tables/ttable%i.dat", com_gamedir, (int) level), "wb");
if (f) if (f)
{ {
if (fwrite (t_lookup[table], 256, 256, f) != 256) if (fwrite (t_lookup[table], 256, 256, f) != 256)
{ {
Con_Printf("Couldn't write data to \"data/ttable%i.dat\"\n", (int) level); Con_Printf("Couldn't write data to \"tables/ttable%i.dat\"\n", (int) level);
fclose(f); fclose(f);
if (rvr) if (rvr)
R_ReverseTable(table); // make sure it gets reversed if needed R_ReverseTable(table); // make sure it gets reversed if needed
@ -142,9 +142,9 @@ void R_CalcTransTable(int table, int level)
fclose(f); fclose(f);
} }
else else
Con_Printf("Couldn't write data to \"data/ttable%i.dat\"\n", (int) level); Con_Printf("Couldn't write data to \"tables/ttable%i.dat\"\n", (int) level);
#else #else
COM_WriteFile(va("data/ttable%i.dat", (int)level, t_lookup[table], 256*256); COM_WriteFile(va("tables/ttable%i.dat", (int)level, t_lookup[table], 256*256);
#endif #endif
} }

View file

@ -27,6 +27,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#endif #endif
#include "d_local.h" //trans stuff #include "d_local.h" //trans stuff
#include "sw_draw.h"
extern unsigned int *d_8to32table; extern unsigned int *d_8to32table;
typedef struct { typedef struct {
@ -1010,9 +1012,8 @@ void SWDraw_Pic (int x, int y, mpic_t *pic)
Draw_SubPic Draw_SubPic
============= =============
*/ */
void SWDraw_TransSubPic(int x, int y, qpic_t *qpic, int srcx, int srcy, int width, int height) void SWDraw_TransSubPic(int x, int y, mpic_t *pic, int srcx, int srcy, int width, int height)
{ {
mpic_t *pic = (mpic_t *)qpic;
qbyte *dest, *source; qbyte *dest, *source;
int v, u; int v, u;
@ -1103,15 +1104,14 @@ void SWDraw_TransSubPic(int x, int y, qpic_t *qpic, int srcx, int srcy, int widt
Draw_SubPic Draw_SubPic
============= =============
*/ */
void SWDraw_SubPic(int x, int y, qpic_t *qpic, int srcx, int srcy, int width, int height) void SWDraw_SubPic(int x, int y, mpic_t *pic, int srcx, int srcy, int width, int height)
{ {
mpic_t *pic = (mpic_t *)qpic;
qbyte *dest, *source; qbyte *dest, *source;
int v, u; int v, u;
if (pic->flags & MPIC_ALPHA) if (pic->flags & MPIC_ALPHA)
{ {
SWDraw_TransSubPic(x, y, qpic, srcx, srcy, width, height); SWDraw_TransSubPic(x, y, pic, srcx, srcy, width, height);
return; return;
} }
@ -1328,42 +1328,39 @@ void SWDraw_TransPic (int x, int y, mpic_t *pic)
Draw_TransPicTranslate Draw_TransPicTranslate
============= =============
*/ */
void SWDraw_TransPicTranslate (int x, int y, qpic_t *qpic, qbyte *translation) void SWDraw_TransPicTranslate (int x, int y, int width, int height, qbyte *source, qbyte *translation)
{ {
mpic_t *pic = (mpic_t*)qpic; qbyte tbyte;
qbyte *source, tbyte;
int v, u; int v, u;
if (x < 0 || (unsigned)(x + pic->width) > vid.width || y < 0 || if (x < 0 || (unsigned)(x + width) > vid.width || y < 0 ||
(unsigned)(y + pic->height) > vid.height) (unsigned)(y + height) > vid.height)
{ {
Sys_Error ("Draw_TransPic: bad coordinates"); Sys_Error ("Draw_TransPic: bad coordinates");
} }
source = pic->data;
if (r_pixbytes == 1) if (r_pixbytes == 1)
{ {
qbyte *dest; qbyte *dest;
dest = vid.buffer + y * vid.rowbytes + x; dest = vid.buffer + y * vid.rowbytes + x;
if (pic->width & 7) if (width & 7)
{ // general { // general
for (v=0 ; v<pic->height ; v++) for (v=0 ; v<height ; v++)
{ {
for (u=0 ; u<pic->width ; u++) for (u=0 ; u<width ; u++)
if ( (tbyte=source[u]) != TRANSPARENT_COLOR) if ( (tbyte=source[u]) != TRANSPARENT_COLOR)
dest[u] = translation[tbyte]; dest[u] = translation[tbyte];
dest += vid.rowbytes; dest += vid.rowbytes;
source += pic->width; source += width;
} }
} }
else else
{ // unwound { // unwound
for (v=0 ; v<pic->height ; v++) for (v=0 ; v<height ; v++)
{ {
for (u=0 ; u<pic->width ; u+=8) for (u=0 ; u<width ; u+=8)
{ {
if ( (tbyte=source[u]) != TRANSPARENT_COLOR) if ( (tbyte=source[u]) != TRANSPARENT_COLOR)
dest[u] = translation[tbyte]; dest[u] = translation[tbyte];
@ -1383,7 +1380,7 @@ void SWDraw_TransPicTranslate (int x, int y, qpic_t *qpic, qbyte *translation)
dest[u+7] = translation[tbyte]; dest[u+7] = translation[tbyte];
} }
dest += vid.rowbytes; dest += vid.rowbytes;
source += pic->width; source += width;
} }
} }
} }
@ -1393,23 +1390,23 @@ void SWDraw_TransPicTranslate (int x, int y, qpic_t *qpic, qbyte *translation)
puidest = (unsigned int *)(vid.buffer + ((y * vid.rowbytes + x) << 2)); puidest = (unsigned int *)(vid.buffer + ((y * vid.rowbytes + x) << 2));
if (pic->width & 7) if (width & 7)
{ // general { // general
for (v=0 ; v<pic->height ; v++) for (v=0 ; v<height ; v++)
{ {
for (u=0 ; u<pic->width ; u++) for (u=0 ; u<width ; u++)
if ( (tbyte=source[u]) != TRANSPARENT_COLOR) if ( (tbyte=source[u]) != TRANSPARENT_COLOR)
puidest[u] = d_8to32table[translation[tbyte]]; puidest[u] = d_8to32table[translation[tbyte]];
puidest += vid.rowbytes; puidest += vid.rowbytes;
source += pic->width; source += width;
} }
} }
else else
{ // unwound { // unwound
for (v=0 ; v<pic->height ; v++) for (v=0 ; v<height ; v++)
{ {
for (u=0 ; u<pic->width ; u+=8) for (u=0 ; u<width ; u+=8)
{ {
if ( (tbyte=source[u]) != TRANSPARENT_COLOR) if ( (tbyte=source[u]) != TRANSPARENT_COLOR)
puidest[u] = d_8to32table[translation[tbyte]]; puidest[u] = d_8to32table[translation[tbyte]];
@ -1429,7 +1426,7 @@ void SWDraw_TransPicTranslate (int x, int y, qpic_t *qpic, qbyte *translation)
puidest[u+7] = d_8to32table[translation[tbyte]]; puidest[u+7] = d_8to32table[translation[tbyte]];
} }
puidest += vid.rowbytes; puidest += vid.rowbytes;
source += pic->width; source += width;
} }
} }
} }
@ -1694,9 +1691,8 @@ void SWDraw_ImageColours (float r, float g, float b, float a) //like glcolour4f
SWDraw_Image_Blend = r<1 || b<1 || g<1 || a<1; SWDraw_Image_Blend = r<1 || b<1 || g<1 || a<1;
} }
void SWDraw_Image (float xp, float yp, float wp, float hp, float s1, float t1, float s2, float t2, qpic_t *qpic) void SWDraw_Image (float xp, float yp, float wp, float hp, float s1, float t1, float s2, float t2, mpic_t *pic)
{ {
mpic_t *pic = (mpic_t*)qpic;
float xend, yend, xratio, yratio; float xend, yend, xratio, yratio;
if (!pic) if (!pic)

View file

@ -32,7 +32,7 @@ void SWDraw_DebugChar (qbyte num);
void SWDraw_SubPic(int x, int y, mpic_t *pic, int srcx, int srcy, int width, int height); void SWDraw_SubPic(int x, int y, mpic_t *pic, int srcx, int srcy, int width, int height);
void SWDraw_Pic (int x, int y, mpic_t *pic); void SWDraw_Pic (int x, int y, mpic_t *pic);
void SWDraw_TransPic (int x, int y, mpic_t *pic); void SWDraw_TransPic (int x, int y, mpic_t *pic);
void SWDraw_TransPicTranslate (int x, int y, mpic_t *pic, qbyte *translation); void SWDraw_TransPicTranslate (int x, int y, int w, int h, qbyte *pic, qbyte *translation);
void SWDraw_ConsoleBackground (int lines); void SWDraw_ConsoleBackground (int lines);
void SWDraw_EditorBackground (int lines); void SWDraw_EditorBackground (int lines);
void SWDraw_BeginDisc (void); void SWDraw_BeginDisc (void);

View file

@ -147,7 +147,7 @@ void SWSCR_UpdateScreen (void)
D_DisableBackBufferAccess (); // for adapters that can't stay mapped in D_DisableBackBufferAccess (); // for adapters that can't stay mapped in
// for linear writes all the time // for linear writes all the time
nohud = true; nohud = false;
#ifdef TEXTEDIT #ifdef TEXTEDIT
if (!editormodal) //don't render view. if (!editormodal) //don't render view.
#endif #endif