don't swallow multimedia keys unless they're actually bound to something.

fix possible out-of-range issue with qc ent references.
shader parsing is now a little more strict.
lua code support updated to bring it more in line with hifi's efforts, still not enabled by default.

git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5233 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
Spoike 2018-04-06 17:21:15 +00:00
parent 67c68b2c43
commit e44d8a85d8
34 changed files with 1834 additions and 679 deletions

View file

@ -2764,7 +2764,7 @@ void CLQ1_AddVisibleBBoxes(void)
"}\n"); "}\n");
for (i = 1; i < w->num_edicts; i++) for (i = 1; i < w->num_edicts; i++)
{ {
e = WEDICT_NUM(w->progs, i); e = WEDICT_NUM_PB(w->progs, i);
if (ED_ISFREE(e)) if (ED_ISFREE(e))
continue; continue;

View file

@ -2405,31 +2405,34 @@ void INS_TranslateKeyEvent(WPARAM wParam, LPARAM lParam, qboolean down, int qdev
int INS_AppCommand(LPARAM lParam) int INS_AppCommand(LPARAM lParam)
{ {
const char *b;
int qkey = 0; int qkey = 0;
switch(HIWORD(lParam)&0xfff) switch(HIWORD(lParam)&0xfff)
{ {
case APPCOMMAND_BROWSER_BACKWARD: qkey = K_MM_BACK; break; case APPCOMMAND_BROWSER_BACKWARD: qkey = K_MM_BROWSER_BACK; break;
case APPCOMMAND_BROWSER_FAVORITES: qkey = K_MM_FAVORITES; break; case APPCOMMAND_BROWSER_FAVORITES: qkey = K_MM_BROWSER_FAVORITES; break;
case APPCOMMAND_BROWSER_FORWARD: qkey = K_MM_FORWARD; break; case APPCOMMAND_BROWSER_FORWARD: qkey = K_MM_BROWSER_FORWARD; break;
case APPCOMMAND_BROWSER_HOME: qkey = K_MM_HOME; break; case APPCOMMAND_BROWSER_HOME: qkey = K_MM_BROWSER_HOME; break;
case APPCOMMAND_BROWSER_REFRESH: qkey = K_MM_REFRESH; break; case APPCOMMAND_BROWSER_REFRESH: qkey = K_MM_BROWSER_REFRESH; break;
case APPCOMMAND_BROWSER_SEARCH: qkey = K_SEARCH; break; case APPCOMMAND_BROWSER_SEARCH: qkey = K_SEARCH; break;
case APPCOMMAND_BROWSER_STOP: qkey = K_MM_STOP; break; case APPCOMMAND_BROWSER_STOP: qkey = K_MM_BROWSER_STOP; break;
// case APPCOMMAND_VOLUME_MUTE: qkey = K_MM_MUTE; break; case APPCOMMAND_VOLUME_MUTE: qkey = K_MM_VOLUME_MUTE; break;
case APPCOMMAND_VOLUME_UP: qkey = K_VOLUP; break; case APPCOMMAND_VOLUME_UP: qkey = K_VOLUP; break;
case APPCOMMAND_VOLUME_DOWN: qkey = K_VOLDOWN; break; case APPCOMMAND_VOLUME_DOWN: qkey = K_VOLDOWN; break;
case APPCOMMAND_MEDIA_NEXTTRACK: qkey = K_MM_TRACK_NEXT; break;
// I want to use these, but that would fuck up external music players. case APPCOMMAND_MEDIA_PREVIOUSTRACK:qkey = K_MM_TRACK_PREV; break;
// case APPCOMMAND_MEDIA_NEXTTRACK: case APPCOMMAND_MEDIA_STOP: qkey = K_MM_TRACK_STOP; break;
// case APPCOMMAND_MEDIA_PREVIOUSTRACK: case APPCOMMAND_MEDIA_PLAY_PAUSE: qkey = K_MM_TRACK_PLAYPAUSE; break;
// case APPCOMMAND_MEDIA_STOP:
// case APPCOMMAND_MEDIA_PLAY_PAUSE:
default: default:
return false; return false;
} }
b = Key_GetBinding(qkey, 0, 0);
if (b && *b)
{ //only take the key if its actually bound to something, otherwise let the system handle it normally.
IN_KeyEvent(0, true, qkey, 0); IN_KeyEvent(0, true, qkey, 0);
IN_KeyEvent(0, false, qkey, 0); IN_KeyEvent(0, false, qkey, 0);
return true; return true;
}
return false; return false;
} }
#endif #endif

View file

@ -51,7 +51,6 @@ int key_bindmaps[2];
char *keybindings[K_MAX][KEY_MODIFIERSTATES]; char *keybindings[K_MAX][KEY_MODIFIERSTATES];
qbyte bindcmdlevel[K_MAX][KEY_MODIFIERSTATES]; qbyte bindcmdlevel[K_MAX][KEY_MODIFIERSTATES];
qboolean consolekeys[K_MAX]; // if true, can't be rebound while in console qboolean consolekeys[K_MAX]; // if true, can't be rebound while in console
qboolean menubound[K_MAX]; // if true, can't be rebound while in menu
int keyshift[K_MAX]; // key to map to if shift held down in console int keyshift[K_MAX]; // key to map to if shift held down in console
int key_repeats[K_MAX]; // if > 1, it is autorepeating int key_repeats[K_MAX]; // if > 1, it is autorepeating
qboolean keydown[K_MAX]; qboolean keydown[K_MAX];
@ -2304,10 +2303,6 @@ void Key_Init (void)
keyshift['`'] = '~'; keyshift['`'] = '~';
keyshift['\\'] = '|'; keyshift['\\'] = '|';
menubound[K_ESCAPE] = true;
for (i=0 ; i<12 ; i++)
menubound[K_F1+i] = true;
// //
// register our functions // register our functions
// //

View file

@ -202,12 +202,17 @@ K_GP_DPAD_LEFT = 253,
K_GP_DPAD_RIGHT = 254, K_GP_DPAD_RIGHT = 254,
K_GP_UNKNOWN = 255, K_GP_UNKNOWN = 255,
K_MM_BACK, K_MM_BROWSER_BACK,
K_MM_FAVORITES, K_MM_BROWSER_FAVORITES,
K_MM_FORWARD, K_MM_BROWSER_FORWARD,
K_MM_HOME, K_MM_BROWSER_HOME,
K_MM_REFRESH, K_MM_BROWSER_REFRESH,
K_MM_STOP, K_MM_BROWSER_STOP,
K_MM_VOLUME_MUTE,
K_MM_TRACK_NEXT,
K_MM_TRACK_PREV,
K_MM_TRACK_STOP,
K_MM_TRACK_PLAYPAUSE,
K_MAX K_MAX
}; };

View file

@ -39,11 +39,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern usercmd_t cl_pendingcmd[MAX_SPLITS]; extern usercmd_t cl_pendingcmd[MAX_SPLITS];
#ifndef TEXTEDITOR
//client only builds don't have a qc debugger
#define QCEditor NULL
#endif
static pubprogfuncs_t *csqcprogs; static pubprogfuncs_t *csqcprogs;
typedef struct csqctreadstate_s { typedef struct csqctreadstate_s {
@ -1373,7 +1368,7 @@ static void QCBUILTIN PF_R_AddEntityMask(pubprogfuncs_t *prinst, struct globalva
maxe = *prinst->parms->sv_num_edicts; maxe = *prinst->parms->sv_num_edicts;
for (e=1; e < maxe; e++) for (e=1; e < maxe; e++)
{ {
ent = (void*)EDICT_NUM(prinst, e); ent = (void*)EDICT_NUM_PB(prinst, e);
if (ED_ISFREE(ent)) if (ED_ISFREE(ent))
continue; continue;
if (ent->v->think) if (ent->v->think)
@ -1404,7 +1399,7 @@ static void QCBUILTIN PF_R_AddEntityMask(pubprogfuncs_t *prinst, struct globalva
maxe = *prinst->parms->sv_num_edicts; maxe = *prinst->parms->sv_num_edicts;
for (e=1; e < maxe; e++) for (e=1; e < maxe; e++)
{ {
ent = (void*)EDICT_NUM(prinst, e); ent = (void*)EDICT_NUM_PB(prinst, e);
if (ED_ISFREE(ent)) if (ED_ISFREE(ent))
continue; continue;
@ -3185,7 +3180,7 @@ void CSQC_ResetTrails(void)
for (i = 0; i < *prinst->parms->sv_num_edicts; i++) for (i = 0; i < *prinst->parms->sv_num_edicts; i++)
{ {
ent = (csqcedict_t*)EDICT_NUM(prinst, i); ent = (csqcedict_t*)EDICT_NUM_PB(prinst, i);
ent->trailstate = NULL; ent->trailstate = NULL;
} }
} }
@ -4577,8 +4572,8 @@ void CSQC_RunThreads(void)
{ //call it and forget it ever happened. The Sleep biltin will recreate if needed. { //call it and forget it ever happened. The Sleep biltin will recreate if needed.
*csqcg.self = EDICT_TO_PROG(csqcprogs, EDICT_NUM(csqcprogs, state->self)); *csqcg.self = EDICT_TO_PROG(csqcprogs, EDICT_NUM_UB(csqcprogs, state->self));
*csqcg.other = EDICT_TO_PROG(csqcprogs, EDICT_NUM(csqcprogs, state->other)); *csqcg.other = EDICT_TO_PROG(csqcprogs, EDICT_NUM_UB(csqcprogs, state->other));
csqcprogs->RunThread(csqcprogs, state->thread); csqcprogs->RunThread(csqcprogs, state->thread);
csqcprogs->parms->memfree(state->thread); csqcprogs->parms->memfree(state->thread);
@ -7331,7 +7326,7 @@ qboolean CSQC_Init (qboolean anycsqc, qboolean csdatenabled, unsigned int checks
csqcentsize = PR_InitEnts(csqcprogs, pr_csqc_maxedicts.value); csqcentsize = PR_InitEnts(csqcprogs, pr_csqc_maxedicts.value);
//world edict becomes readonly //world edict becomes readonly
worldent = (csqcedict_t *)EDICT_NUM(csqcprogs, 0); worldent = (csqcedict_t *)EDICT_NUM_PB(csqcprogs, 0);
worldent->ereftype = ER_ENTITY; worldent->ereftype = ER_ENTITY;
for (i = 0; i < csqcprogs->numprogs; i++) for (i = 0; i < csqcprogs->numprogs; i++)
@ -7450,7 +7445,7 @@ void CSQC_WorldLoaded(void)
csqc_world.worldmodel = cl.worldmodel; csqc_world.worldmodel = cl.worldmodel;
World_RBE_Start(&csqc_world); World_RBE_Start(&csqc_world);
worldent = (csqcedict_t *)EDICT_NUM(csqcprogs, 0); worldent = (csqcedict_t *)EDICT_NUM_PB(csqcprogs, 0);
worldent->v->solid = SOLID_BSP; worldent->v->solid = SOLID_BSP;
wmodelindex = CS_FindModel(cl.worldmodel?cl.worldmodel->name:"", &tmp); wmodelindex = CS_FindModel(cl.worldmodel?cl.worldmodel->name:"", &tmp);
tmp = csqc_worldchanged; tmp = csqc_worldchanged;
@ -7710,7 +7705,7 @@ qboolean CSQC_SetupToRenderPortal(int entkeynum)
if (csqcprogs && entkeynum < 0) if (csqcprogs && entkeynum < 0)
{ {
csqcedict_t *e = (void*)EDICT_NUM(csqcprogs, -entkeynum); csqcedict_t *e = (void*)EDICT_NUM_UB(csqcprogs, -entkeynum);
if (e->xv->camera_transform) if (e->xv->camera_transform)
{ {
int oself = *csqcg.self; int oself = *csqcg.self;
@ -8483,7 +8478,7 @@ void CSQC_GetEntityOrigin(unsigned int csqcent, float *out)
wedict_t *ent; wedict_t *ent;
if (!csqcprogs) if (!csqcprogs)
return; return;
ent = WEDICT_NUM(csqcprogs, csqcent); ent = WEDICT_NUM_UB(csqcprogs, csqcent);
VectorCopy(ent->v->origin, out); VectorCopy(ent->v->origin, out);
} }
@ -8631,7 +8626,7 @@ void CSQC_ParseEntities(void)
#ifndef CLIENTONLY #ifndef CLIENTONLY
if (sv.state) if (sv.state)
{ {
Con_Printf("Server classname: \"%s\"\n", PR_GetString(svprogfuncs, EDICT_NUM(svprogfuncs, entnum)->v->classname)); Con_Printf("Server classname: \"%s\"\n", PR_GetString(svprogfuncs, EDICT_NUM_UB(svprogfuncs, entnum)->v->classname));
} }
#endif #endif
} }

View file

@ -1512,7 +1512,7 @@ void QCBUILTIN PF_menu_findchain (pubprogfuncs_t *prinst, struct globalvars_s *p
for (i = 1; i < *prinst->parms->sv_num_edicts; i++) for (i = 1; i < *prinst->parms->sv_num_edicts; i++)
{ {
ent = (menuedict_t *)EDICT_NUM(prinst, i); ent = (menuedict_t *)EDICT_NUM_PB(prinst, i);
if (ent->ereftype == ER_FREE) if (ent->ereftype == ER_FREE)
continue; continue;
t = *(string_t *)&((float*)ent->fields)[f]; t = *(string_t *)&((float*)ent->fields)[f];
@ -1544,7 +1544,7 @@ void QCBUILTIN PF_menu_findchainfloat (pubprogfuncs_t *prinst, struct globalvars
for (i = 1; i < *prinst->parms->sv_num_edicts; i++) for (i = 1; i < *prinst->parms->sv_num_edicts; i++)
{ {
ent = (menuedict_t*)EDICT_NUM(prinst, i); ent = (menuedict_t*)EDICT_NUM_PB(prinst, i);
if (ent->ereftype == ER_FREE) if (ent->ereftype == ER_FREE)
continue; continue;
if (((float *)ent->fields)[f] != s) if (((float *)ent->fields)[f] != s)
@ -1573,7 +1573,7 @@ void QCBUILTIN PF_menu_findchainflags (pubprogfuncs_t *prinst, struct globalvars
for (i = 1; i < *prinst->parms->sv_num_edicts; i++) for (i = 1; i < *prinst->parms->sv_num_edicts; i++)
{ {
ent = (menuedict_t*)EDICT_NUM(prinst, i); ent = (menuedict_t*)EDICT_NUM_PB(prinst, i);
if (ent->ereftype == ER_FREE) if (ent->ereftype == ER_FREE)
continue; continue;
if ((int)((float *)ent->fields)[f] & s) if ((int)((float *)ent->fields)[f] & s)
@ -1596,7 +1596,7 @@ void QCBUILTIN PF_ftoe(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{ {
int entnum = G_FLOAT(OFS_PARM0); int entnum = G_FLOAT(OFS_PARM0);
RETURN_EDICT(prinst, EDICT_NUM(prinst, entnum)); RETURN_EDICT(prinst, EDICT_NUM_UB(prinst, entnum));
} }
void QCBUILTIN PF_IsNotNull(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) void QCBUILTIN PF_IsNotNull(pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
@ -2623,8 +2623,8 @@ qboolean MP_Init (void)
//'world' edict //'world' edict
// EDICT_NUM(menu_world.progs, 0)->readonly = true; // EDICT_NUM_PB(menu_world.progs, 0)->readonly = true;
EDICT_NUM(menu_world.progs, 0)->ereftype = ER_ENTITY; EDICT_NUM_PB(menu_world.progs, 0)->ereftype = ER_ENTITY;
mp_init_function = PR_FindFunction(menu_world.progs, "m_init", PR_ANY); mp_init_function = PR_FindFunction(menu_world.progs, "m_init", PR_ANY);
@ -2640,7 +2640,7 @@ qboolean MP_Init (void)
PR_ExecuteProgram(menu_world.progs, mp_init_function); PR_ExecuteProgram(menu_world.progs, mp_init_function);
inmenuprogs--; inmenuprogs--;
EDICT_NUM(menu_world.progs, 0)->readonly = true; EDICT_NUM_PB(menu_world.progs, 0)->readonly = true;
Con_DPrintf("Initialized menu.dat\n"); Con_DPrintf("Initialized menu.dat\n");
return true; return true;

View file

@ -2646,7 +2646,7 @@ static void SND_Spatialize(soundcardinfo_t *sc, channel_t *ch)
#ifdef CSQC_DAT #ifdef CSQC_DAT
if (ch->entnum < 0 && -ch->entnum < csqc_world.num_edicts) if (ch->entnum < 0 && -ch->entnum < csqc_world.num_edicts)
{ {
wedict_t *ed = WEDICT_NUM(csqc_world.progs, -ch->entnum); wedict_t *ed = WEDICT_NUM_PB(csqc_world.progs, -ch->entnum);
if (ed->ereftype == ER_ENTITY) if (ed->ereftype == ER_ENTITY)
{ {
VectorCopy(ed->v->origin, ch->origin); VectorCopy(ed->v->origin, ch->origin);

View file

@ -1934,7 +1934,7 @@ void R_DrawNameTags(void)
float bestscore = 0, score = 0; float bestscore = 0, score = 0;
for (i = 1; i < w->num_edicts; i++) for (i = 1; i < w->num_edicts; i++)
{ {
e = WEDICT_NUM(w->progs, i); e = WEDICT_NUM_PB(w->progs, i);
if (ED_ISFREE(e)) if (ED_ISFREE(e))
continue; continue;
VectorInterpolate(e->v->mins, 0.5, e->v->maxs, org); VectorInterpolate(e->v->mins, 0.5, e->v->maxs, org);
@ -1957,7 +1957,7 @@ void R_DrawNameTags(void)
} }
if (best) if (best)
{ {
e = WEDICT_NUM(w->progs, best); e = WEDICT_NUM_PB(w->progs, best);
VectorInterpolate(e->v->mins, 0.5, e->v->maxs, org); VectorInterpolate(e->v->mins, 0.5, e->v->maxs, org);
VectorAdd(org, e->v->origin, org); VectorAdd(org, e->v->origin, org);
if (Matrix4x4_CM_Project(org, screenspace, r_refdef.viewangles, r_refdef.vieworg, r_refdef.fov_x, r_refdef.fov_y)) if (Matrix4x4_CM_Project(org, screenspace, r_refdef.viewangles, r_refdef.vieworg, r_refdef.fov_x, r_refdef.fov_y))

View file

@ -1627,9 +1627,9 @@ static void World_ODE_Frame_JointFromEntity(world_t *world, wedict_t *ed)
//Con_Printf("made new joint %i\n", (int) (ed - prog->edicts)); //Con_Printf("made new joint %i\n", (int) (ed - prog->edicts));
dJointSetData(j, (void *) ed); dJointSetData(j, (void *) ed);
if(enemy) if(enemy)
b1 = (dBodyID)((WEDICT_NUM(world->progs, enemy))->ode.ode_body); b1 = (dBodyID)((WEDICT_NUM_UB(world->progs, enemy))->ode.ode_body);
if(aiment) if(aiment)
b2 = (dBodyID)((WEDICT_NUM(world->progs, aiment))->ode.ode_body); b2 = (dBodyID)((WEDICT_NUM_UB(world->progs, aiment))->ode.ode_body);
dJointAttach(j, b1, b2); dJointAttach(j, b1, b2);
switch(jointtype) switch(jointtype)
@ -2641,14 +2641,14 @@ static void QDECL World_ODE_Frame(world_t *world, double frametime, double gravi
// copy physics properties from entities to physics engine // copy physics properties from entities to physics engine
for (i = 0;i < world->num_edicts;i++) for (i = 0;i < world->num_edicts;i++)
{ {
ed = (wedict_t*)EDICT_NUM(world->progs, i); ed = (wedict_t*)EDICT_NUM_PB(world->progs, i);
if (!ED_ISFREE(ed)) if (!ED_ISFREE(ed))
World_ODE_Frame_BodyFromEntity(world, ed); World_ODE_Frame_BodyFromEntity(world, ed);
} }
// oh, and it must be called after all bodies were created // oh, and it must be called after all bodies were created
for (i = 0;i < world->num_edicts;i++) for (i = 0;i < world->num_edicts;i++)
{ {
ed = (wedict_t*)EDICT_NUM(world->progs, i); ed = (wedict_t*)EDICT_NUM_PB(world->progs, i);
if (!ED_ISFREE(ed)) if (!ED_ISFREE(ed))
World_ODE_Frame_JointFromEntity(world, ed); World_ODE_Frame_JointFromEntity(world, ed);
} }
@ -2691,7 +2691,7 @@ static void QDECL World_ODE_Frame(world_t *world, double frametime, double gravi
// copy physics properties from physics engine to entities // copy physics properties from physics engine to entities
for (i = 1;i < world->num_edicts;i++) for (i = 1;i < world->num_edicts;i++)
{ {
ed = (wedict_t*)EDICT_NUM(world->progs, i); ed = (wedict_t*)EDICT_NUM_PB(world->progs, i);
if (!ED_ISFREE(ed)) if (!ED_ISFREE(ed))
World_ODE_Frame_BodyToEntity(world, ed); World_ODE_Frame_BodyToEntity(world, ed);
} }

View file

@ -93,7 +93,7 @@ static qboolean PM_PortalTransform(world_t *w, int portalnum, vec3_t org, vec3_t
{ {
vec3_t rounded; vec3_t rounded;
qboolean okay = true; qboolean okay = true;
wedict_t *portal = WEDICT_NUM(w->progs, portalnum); wedict_t *portal = WEDICT_NUM_UB(w->progs, portalnum);
int oself = *w->g.self; int oself = *w->g.self;
void *pr_globals = PR_globals(w->progs, PR_CURRENT); void *pr_globals = PR_globals(w->progs, PR_CURRENT);
int i; int i;

View file

@ -1227,7 +1227,7 @@ void QCBUILTIN PF_findchainflags (pubprogfuncs_t *prinst, struct globalvars_s *p
for (i = 1; i < *prinst->parms->sv_num_edicts; i++) for (i = 1; i < *prinst->parms->sv_num_edicts; i++)
{ {
ent = WEDICT_NUM(prinst, i); ent = WEDICT_NUM_PB(prinst, i);
if (ED_ISFREE(ent)) if (ED_ISFREE(ent))
continue; continue;
if (!((int)((float *)ent->v)[ff] & s)) if (!((int)((float *)ent->v)[ff] & s))
@ -1258,7 +1258,7 @@ void QCBUILTIN PF_findchainfloat (pubprogfuncs_t *prinst, struct globalvars_s *p
for (i = 1; i < *prinst->parms->sv_num_edicts; i++) for (i = 1; i < *prinst->parms->sv_num_edicts; i++)
{ {
ent = WEDICT_NUM(prinst, i); ent = WEDICT_NUM_PB(prinst, i);
if (ED_ISFREE(ent)) if (ED_ISFREE(ent))
continue; continue;
if (((float *)ent->v)[ff] != s) if (((float *)ent->v)[ff] != s)
@ -1291,7 +1291,7 @@ void QCBUILTIN PF_findchain (pubprogfuncs_t *prinst, struct globalvars_s *pr_glo
for (i = 1; i < *prinst->parms->sv_num_edicts; i++) for (i = 1; i < *prinst->parms->sv_num_edicts; i++)
{ {
ent = WEDICT_NUM(prinst, i); ent = WEDICT_NUM_PB(prinst, i);
if (ED_ISFREE(ent)) if (ED_ISFREE(ent))
continue; continue;
t = *(string_t *)&((float*)ent->v)[ff]; t = *(string_t *)&((float*)ent->v)[ff];
@ -1321,7 +1321,7 @@ void QCBUILTIN PF_FindFlags (pubprogfuncs_t *prinst, struct globalvars_s *pr_glo
for (e++; e < *prinst->parms->sv_num_edicts; e++) for (e++; e < *prinst->parms->sv_num_edicts; e++)
{ {
ed = WEDICT_NUM(prinst, e); ed = WEDICT_NUM_PB(prinst, e);
if (ED_ISFREE(ed)) if (ED_ISFREE(ed))
continue; continue;
if ((int)((float *)ed->v)[f] & s) if ((int)((float *)ed->v)[f] & s)
@ -1353,7 +1353,7 @@ void QCBUILTIN PF_FindFloat (pubprogfuncs_t *prinst, struct globalvars_s *pr_glo
for (e++; e < *prinst->parms->sv_num_edicts; e++) for (e++; e < *prinst->parms->sv_num_edicts; e++)
{ {
ed = WEDICT_NUM(prinst, e); ed = WEDICT_NUM_PB(prinst, e);
if (ED_ISFREE(ed)) if (ED_ISFREE(ed))
continue; continue;
if (((int *)ed->v)[f] == s) if (((int *)ed->v)[f] == s)
@ -1386,7 +1386,7 @@ void QCBUILTIN PF_FindString (pubprogfuncs_t *prinst, struct globalvars_s *pr_gl
for (e++ ; e < *prinst->parms->sv_num_edicts ; e++) for (e++ ; e < *prinst->parms->sv_num_edicts ; e++)
{ {
ed = WEDICT_NUM(prinst, e); ed = WEDICT_NUM_PB(prinst, e);
if (ED_ISFREE(ed)) if (ED_ISFREE(ed))
continue; continue;
t = ((string_t *)ed->v)[f]; t = ((string_t *)ed->v)[f];
@ -2925,7 +2925,7 @@ void QCBUILTIN PF_edict_for_num(pubprogfuncs_t *prinst, struct globalvars_s *pr_
if (num >= w->num_edicts) if (num >= w->num_edicts)
RETURN_EDICT(prinst, w->edicts); RETURN_EDICT(prinst, w->edicts);
ent = (edict_t*)EDICT_NUM(prinst, num); ent = (edict_t*)EDICT_NUM_PB(prinst, num);
RETURN_EDICT(prinst, ent); RETURN_EDICT(prinst, ent);
} }
@ -2998,7 +2998,7 @@ void QCBUILTIN PF_findradius (pubprogfuncs_t *prinst, struct globalvars_s *pr_gl
rad = rad*rad; rad = rad*rad;
for (i=1 ; i<w->num_edicts ; i++) for (i=1 ; i<w->num_edicts ; i++)
{ {
ent = WEDICT_NUM(prinst, i); ent = WEDICT_NUM_PB(prinst, i);
if (ED_ISFREE(ent)) if (ED_ISFREE(ent))
continue; continue;
if (ent->v->solid == SOLID_NOT && (!((int)ent->v->flags & FL_FINDABLE_NONSOLID)) && !sv_gameplayfix_blowupfallenzombies.value) if (ent->v->solid == SOLID_NOT && (!((int)ent->v->flags & FL_FINDABLE_NONSOLID)) && !sv_gameplayfix_blowupfallenzombies.value)
@ -3031,7 +3031,7 @@ void QCBUILTIN PF_nextent (pubprogfuncs_t *prinst, struct globalvars_s *pr_globa
RETURN_EDICT(prinst, *prinst->parms->sv_edicts); RETURN_EDICT(prinst, *prinst->parms->sv_edicts);
return; return;
} }
ent = WEDICT_NUM(prinst, i); ent = WEDICT_NUM_PB(prinst, i);
if (!ED_ISFREE(ent)) if (!ED_ISFREE(ent))
{ {
RETURN_EDICT(prinst, ent); RETURN_EDICT(prinst, ent);

View file

@ -165,7 +165,8 @@ typedef struct areanode_s
typedef struct wedict_s wedict_t; typedef struct wedict_s wedict_t;
#define PROG_TO_WEDICT (wedict_t*)PROG_TO_EDICT #define PROG_TO_WEDICT (wedict_t*)PROG_TO_EDICT
#define WEDICT_NUM (wedict_t *)EDICT_NUM #define WEDICT_NUM_UB (wedict_t *)EDICT_NUM_UB //ent number isn't bounded
#define WEDICT_NUM_PB (wedict_t *)EDICT_NUM_PB //pre-bound
#define G_WEDICT (wedict_t *)G_EDICT #define G_WEDICT (wedict_t *)G_EDICT
typedef struct typedef struct

View file

@ -2592,11 +2592,6 @@ static shaderkey_t shaderkeys[] =
{"clutter", Shader_ClutterParms, "fte"}, {"clutter", Shader_ClutterParms, "fte"},
{"deferredlight", Shader_Deferredlight, "fte"}, //(sort = prelight) {"deferredlight", Shader_Deferredlight, "fte"}, //(sort = prelight)
// {"lpp_light", Shader_Deferredlight, "fte"}, //(sort = prelight) // {"lpp_light", Shader_Deferredlight, "fte"}, //(sort = prelight)
{"glslprogram", Shader_GLSLProgramName, "fte"},
{"program", Shader_ProgramName, "fte"}, //gl or d3d
{"hlslprogram", Shader_HLSL9ProgramName, "fte"}, //for d3d
{"hlsl11program", Shader_HLSL11ProgramName, "fte"}, //for d3d
{"param", Shader_ProgramParam, "fte"}, //legacy
{"affine", Shader_Affine, "fte"}, //some hardware is horribly slow, and can benefit from certain hints. {"affine", Shader_Affine, "fte"}, //some hardware is horribly slow, and can benefit from certain hints.
{"bemode", Shader_BEMode, "fte"}, {"bemode", Shader_BEMode, "fte"},
@ -2609,9 +2604,14 @@ static shaderkey_t shaderkeys[] =
{"lowermap", Shader_LowerMap, "fte"}, {"lowermap", Shader_LowerMap, "fte"},
{"reflectmask", Shader_ReflectMask, "fte"}, {"reflectmask", Shader_ReflectMask, "fte"},
/*simpler parsing for fte shaders*/ /*program stuff at the material level is an outdated practise.*/
{"progblendfunc", Shader_ProgBlendFunc, "fte"}, {"program", Shader_ProgramName, "fte"}, //usable with any renderer that has a usable shader language...
{"progmap", Shader_ProgMap, "fte"}, {"glslprogram", Shader_GLSLProgramName, "fte"}, //for renderers that accept embedded glsl
{"hlslprogram", Shader_HLSL9ProgramName, "fte"}, //for d3d with embedded hlsl
{"hlsl11program", Shader_HLSL11ProgramName, "fte"}, //for d3d with embedded hlsl
{"param", Shader_ProgramParam, "fte"}, //legacy
{"progblendfunc", Shader_ProgBlendFunc, "fte"}, //specifies the blend mode (actually just overrides the first subpasses' blendmode.
{"progmap", Shader_ProgMap, "fte"}, //avoids needing extra subpasses (actually just inserts an extra pass).
//dp compat //dp compat
{"reflectcube", Shader_ReflectCube, "dp"}, {"reflectcube", Shader_ReflectCube, "dp"},
@ -4364,6 +4364,8 @@ void Shader_Readpass (shader_t *shader, char **ptr)
{ {
if ( token[0] == '}' ) if ( token[0] == '}' )
break; break;
else if (token[0] == '{')
Con_Printf("unexpected indentation in %s\n", shader->name);
else if ( Shader_Parsetok (shader, pass, shaderpasskeys, token, ptr) ) else if ( Shader_Parsetok (shader, pass, shaderpasskeys, token, ptr) )
break; break;
} }
@ -4471,6 +4473,12 @@ static qboolean Shader_Parsetok (shader_t *shader, shaderpass_t *pass, shaderkey
char *prefix; char *prefix;
qboolean toolchainprefix = false; qboolean toolchainprefix = false;
if (*token == '_')
{ //forward compat: make sure there's a way to shut stuff up if you're using future extensions in an outdated engine.
token++;
toolchainprefix = true;
}
//handle known prefixes. //handle known prefixes.
if (!Q_strncasecmp(token, "fte", 3)) {prefix = token; token += 3; } if (!Q_strncasecmp(token, "fte", 3)) {prefix = token; token += 3; }
else if (!Q_strncasecmp(token, "dp", 2)) {prefix = token; token += 2; } else if (!Q_strncasecmp(token, "dp", 2)) {prefix = token; token += 2; }

View file

@ -2908,7 +2908,8 @@ static LONG WINAPI GLMainWndProc (
break; break;
case WM_APPCOMMAND: case WM_APPCOMMAND:
lRet = INS_AppCommand(lParam); if (!INS_AppCommand(lParam))
lRet = DefWindowProc(hWnd, uMsg, wParam, lParam); //otherwise it won't get handled by background apps, like media players.
break; break;
case WM_MOUSEACTIVATE: case WM_MOUSEACTIVATE:

View file

@ -430,7 +430,7 @@ reeval:
return pr_xstatement; return pr_xstatement;
break; break;
} }
ed = PROG_TO_EDICT(progfuncs, OPA->edict); ed = PROG_TO_EDICT_PB(progfuncs, OPA->edict);
#ifdef PARANOID #ifdef PARANOID
NUM_FOR_EDICT(ed); // make sure it's in range NUM_FOR_EDICT(ed); // make sure it's in range
#endif #endif
@ -491,7 +491,7 @@ reeval:
OPC->_int = 0; OPC->_int = 0;
break; break;
} }
ed = PROG_TO_EDICT(progfuncs, OPA->edict); ed = PROG_TO_EDICT_PB(progfuncs, OPA->edict);
#ifdef PARANOID #ifdef PARANOID
NUM_FOR_EDICT(ed); // make sure it's in range NUM_FOR_EDICT(ed); // make sure it's in range
#endif #endif
@ -528,7 +528,7 @@ reeval:
OPC->_vector[2] = 0; OPC->_vector[2] = 0;
break; break;
} }
ed = PROG_TO_EDICT(progfuncs, OPA->edict); ed = PROG_TO_EDICT_PB(progfuncs, OPA->edict);
#ifdef PARANOID #ifdef PARANOID
NUM_FOR_EDICT(ed); // make sure it's in range NUM_FOR_EDICT(ed); // make sure it's in range
#endif #endif
@ -967,7 +967,7 @@ reeval:
break; break;
case OP_THINKTIME: case OP_THINKTIME:
externs->thinktimeop(&progfuncs->funcs, (struct edict_s *)PROG_TO_EDICT(progfuncs, OPA->edict), OPB->_float); externs->thinktimeop(&progfuncs->funcs, (struct edict_s *)PROG_TO_EDICT_UB(progfuncs, OPA->edict), OPB->_float);
break; break;
case OP_MULSTORE_F: case OP_MULSTORE_F:

View file

@ -498,6 +498,7 @@ int PDECL PR_InitEnts(pubprogfuncs_t *ppf, int max_ents)
prinst.max_fields_size = prinst.fields_size; prinst.max_fields_size = prinst.fields_size;
prinst.edicttable = (struct edictrun_s**)(progfuncs->funcs.edicttable = PRHunkAlloc(progfuncs, prinst.maxedicts*sizeof(struct edicts_s *), "edicttable")); prinst.edicttable = (struct edictrun_s**)(progfuncs->funcs.edicttable = PRHunkAlloc(progfuncs, prinst.maxedicts*sizeof(struct edicts_s *), "edicttable"));
progfuncs->funcs.edicttable_length = prinst.maxedicts;
e = PRHunkAlloc(progfuncs, externs->edictsize, "edict0"); e = PRHunkAlloc(progfuncs, externs->edictsize, "edict0");
e->fieldsize = prinst.fields_size; e->fieldsize = prinst.fields_size;
e->entnum = 0; e->entnum = 0;
@ -571,6 +572,7 @@ static void PDECL PR_Configure (pubprogfuncs_t *ppf, size_t addressable_size, in
prinst.profilingalert = Sys_GetClockRate(); prinst.profilingalert = Sys_GetClockRate();
prinst.maxedicts = 1; prinst.maxedicts = 1;
prinst.edicttable = (edictrun_t**)(progfuncs->funcs.edicttable = &sv_edicts); prinst.edicttable = (edictrun_t**)(progfuncs->funcs.edicttable = &sv_edicts);
progfuncs->funcs.edicttable_length = 1;
sv_num_edicts = 1; //set up a safty buffer so things won't go horribly wrong too often sv_num_edicts = 1; //set up a safty buffer so things won't go horribly wrong too often
sv_edicts=(struct edict_s *)&tempedict; sv_edicts=(struct edict_s *)&tempedict;
tempedict.readonly = true; tempedict.readonly = true;
@ -874,7 +876,7 @@ struct edict_s *PDECL ProgsToEdict (pubprogfuncs_t *ppf, int progs)
} }
progs = 0; progs = 0;
} }
return (struct edict_s *)PROG_TO_EDICT(progfuncs.inst, progs); return (struct edict_s *)PROG_TO_EDICT_PB(progfuncs.inst, progs);
} }
int PDECL EdictToProgs (pubprogfuncs_t *ppf, struct edict_s *ed) int PDECL EdictToProgs (pubprogfuncs_t *ppf, struct edict_s *ed)
{ {

View file

@ -802,7 +802,7 @@ char *PR_UglyOldValueString (progfuncs_t *progfuncs, etype_t type, eval_t *val)
QC_snprintfz (line, sizeof(line), "%s", PR_StringToNative(&progfuncs->funcs, val->string)); QC_snprintfz (line, sizeof(line), "%s", PR_StringToNative(&progfuncs->funcs, val->string));
break; break;
case ev_entity: case ev_entity:
QC_snprintfz (line, sizeof(line), "%i", NUM_FOR_EDICT(progfuncs, (struct edict_s *)PROG_TO_EDICT(progfuncs, val->edict))); QC_snprintfz (line, sizeof(line), "%i", val->edict);
break; break;
case ev_function: case ev_function:
f = pr_progstate[(val->function & 0xff000000)>>24].functions + (val->function & ~0xff000000); f = pr_progstate[(val->function & 0xff000000)>>24].functions + (val->function & ~0xff000000);
@ -2143,7 +2143,7 @@ int PDECL PR_LoadEnts(pubprogfuncs_t *ppf, const char *file, void *ctx, void (PD
sv_num_edicts = 1; //set up a safty buffer so things won't go horribly wrong too often sv_num_edicts = 1; //set up a safty buffer so things won't go horribly wrong too often
sv_edicts=(struct edict_s *)&tempedict; sv_edicts=(struct edict_s *)&tempedict;
prinst.edicttable = (struct edictrun_s**)(progfuncs->funcs.edicttable = &sv_edicts); prinst.edicttable = (struct edictrun_s**)(progfuncs->funcs.edicttable = &sv_edicts);
progfuncs->funcs.edicttable_length = numents;
sv_num_edicts = numents; //should be fine sv_num_edicts = numents; //should be fine

View file

@ -329,7 +329,7 @@ static void PDECL PR_PrintRelevantLocals(progfuncs_t *progfuncs)
} }
else else
{ {
ed = PROG_TO_EDICT(progfuncs, entnum); ed = PROG_TO_EDICT_PB(progfuncs, entnum);
if ((unsigned int)((eval_t *)&pr_globals[st16[st].b])->_int*4u >= ed->fieldsize) if ((unsigned int)((eval_t *)&pr_globals[st16[st].b])->_int*4u >= ed->fieldsize)
continue; continue;
else else
@ -751,8 +751,10 @@ pbool LocateDebugTerm(progfuncs_t *progfuncs, char *key, eval_t **result, etype_
fofs = fdef->ofs; fofs = fdef->ofs;
type = fdef->type; type = fdef->type;
if ((unsigned int)val->_int >= prinst.maxedicts)
ed = PROG_TO_EDICT(progfuncs, val->_int); ed = NULL;
else
ed = PROG_TO_EDICT_PB(progfuncs, val->_int);
if (!ed) if (!ed)
return false; return false;
if (fofs < 0 || fofs >= (int)prinst.max_fields_size) if (fofs < 0 || fofs >= (int)prinst.max_fields_size)
@ -1492,7 +1494,7 @@ const char *PR_GetEdictClassname(progfuncs_t *progfuncs, unsigned int edict)
fdef_t *cnfd = ED_FindField(progfuncs, "classname"); fdef_t *cnfd = ED_FindField(progfuncs, "classname");
if (cnfd && edict < prinst.maxedicts) if (cnfd && edict < prinst.maxedicts)
{ {
string_t *v = (string_t *)((char *)edvars(PROG_TO_EDICT(progfuncs, edict)) + cnfd->ofs*4); string_t *v = (string_t *)((char *)edvars(PROG_TO_EDICT_PB(progfuncs, edict)) + cnfd->ofs*4);
return PR_StringToNative(&progfuncs->funcs, *v); return PR_StringToNative(&progfuncs->funcs, *v);
} }
return ""; return "";

View file

@ -147,9 +147,6 @@ typedef struct prinst_s
#define pr_xstatement prinst.pr_xstatement #define pr_xstatement prinst.pr_xstatement
//pr_edict.c //pr_edict.c
unsigned int maxedicts;
evalc_t spawnflagscache; evalc_t spawnflagscache;
unsigned int fields_size; // in bytes unsigned int fields_size; // in bytes
unsigned int max_fields_size; unsigned int max_fields_size;
@ -161,6 +158,7 @@ typedef struct prinst_s
size_t addressableused; size_t addressableused;
size_t addressablesize; size_t addressablesize;
unsigned int maxedicts;
struct edictrun_s **edicttable; struct edictrun_s **edicttable;
} prinst_t; } prinst_t;
@ -413,7 +411,8 @@ unsigned int PDECL QC_NUM_FOR_EDICT(pubprogfuncs_t *progfuncs, struct edict_s *e
//#define NEXT_EDICT(e) ((edictrun_t *)( (byte *)e + pr_edict_size)) //#define NEXT_EDICT(e) ((edictrun_t *)( (byte *)e + pr_edict_size))
#define EDICT_TO_PROG(pf, e) (((edictrun_t*)e)->entnum) #define EDICT_TO_PROG(pf, e) (((edictrun_t*)e)->entnum)
#define PROG_TO_EDICT(pf, e) ((struct edictrun_s *)prinst.edicttable[e]) #define PROG_TO_EDICT_PB(pf, e) ((struct edictrun_s *)prinst.edicttable[e]) //index already validated
#define PROG_TO_EDICT_UB(pf, e) ((struct edictrun_s *)prinst.edicttable[((unsigned int)(e)<prinst.maxedicts)?e:0]) //(safely) pokes world if the index is otherwise invalid
//============================================================================ //============================================================================

View file

@ -105,8 +105,8 @@ struct pubprogfuncs_s
struct edict_s *(PDECL *EntAlloc) (pubprogfuncs_t *prinst, pbool object, size_t extrasize); struct edict_s *(PDECL *EntAlloc) (pubprogfuncs_t *prinst, pbool object, size_t extrasize);
void (PDECL *EntFree) (pubprogfuncs_t *prinst, struct edict_s *ed); void (PDECL *EntFree) (pubprogfuncs_t *prinst, struct edict_s *ed);
struct edict_s *(PDECL *EDICT_NUM) (pubprogfuncs_t *prinst, unsigned int n); //get the nth edict struct edict_s *(PDECL *EdictNum) (pubprogfuncs_t *prinst, unsigned int n); //get the nth edict
unsigned int (PDECL *NUM_FOR_EDICT) (pubprogfuncs_t *prinst, struct edict_s *e); //so you can find out what that 'n' will be unsigned int (PDECL *NumForEdict) (pubprogfuncs_t *prinst, struct edict_s *e); //so you can find out what that 'n' will be
char *(PDECL *VarString) (pubprogfuncs_t *prinst, int first); //returns a string made up of multiple arguments char *(PDECL *VarString) (pubprogfuncs_t *prinst, int first); //returns a string made up of multiple arguments
@ -195,6 +195,7 @@ struct pubprogfuncs_s
void (PDECL *SetStringField) (pubprogfuncs_t *progfuncs, struct edict_s *ed, string_t *fld, const char *str, pbool str_is_static); //if ed is null, fld points to a global. if str_is_static, then s doesn't need its own memory allocated. void (PDECL *SetStringField) (pubprogfuncs_t *progfuncs, struct edict_s *ed, string_t *fld, const char *str, pbool str_is_static); //if ed is null, fld points to a global. if str_is_static, then s doesn't need its own memory allocated.
pbool (PDECL *DumpProfile) (pubprogfuncs_t *progfuncs, pbool resetprofiles); pbool (PDECL *DumpProfile) (pubprogfuncs_t *progfuncs, pbool resetprofiles);
unsigned int edicttable_length;
struct edict_s **edicttable; struct edict_s **edicttable;
}; };
@ -285,9 +286,10 @@ typedef union eval_s
#if 0//def _DEBUG #if 0//def _DEBUG
#define EDICT_NUM(pf, num) (*pf->EDICT_NUM) (pf, num) #define EDICT_NUM(pf, num) (*pf->EDICT_NUM) (pf, num)
#else #else
#define EDICT_NUM(pf, num) (pf->edicttable[num]) #define EDICT_NUM_PB(pf, num) (pf->edicttable[num])
#define EDICT_NUM_UB(pf, num) EDICT_NUM_PB(pf,(((unsigned int)(num))>=pf->edicttable_length)?0:num)
#endif #endif
#define NUM_FOR_EDICT(pf, e) (*pf->NUM_FOR_EDICT) (pf, (struct edict_s*)(e)) #define NUM_FOR_EDICT(pf, e) (*pf->NumForEdict) (pf, (struct edict_s*)(e))
#define SetGlobalEdict(pf, ed, ofs) (*pf->SetGlobalEdict) (pf, ed, ofs) #define SetGlobalEdict(pf, ed, ofs) (*pf->SetGlobalEdict) (pf, ed, ofs)
#define PR_VarString(pf,first) (*pf->VarString) (pf,first) #define PR_VarString(pf,first) (*pf->VarString) (pf,first)

View file

@ -1826,7 +1826,7 @@ void NPP_QWFlush(void)
{ {
short data; short data;
float org[3]; float org[3];
edict_t *ent = EDICT_NUM(svprogfuncs, LittleShort((*(short*)&buffer[1]))); edict_t *ent = EDICT_NUM_UB(svprogfuncs, LittleShort((*(short*)&buffer[1])));
ent->muzzletime = sv.world.physicstime+host_frametime; //flag the entity as needing an EF_MUZZLEFLASH ent->muzzletime = sv.world.physicstime+host_frametime; //flag the entity as needing an EF_MUZZLEFLASH
VectorCopy(ent->v->origin, org); VectorCopy(ent->v->origin, org);

View file

@ -483,7 +483,7 @@ static void PDECL PR_SSQC_Relocated(pubprogfuncs_t *pr, char *oldb, char *newb,
#ifdef VM_Q1 #ifdef VM_Q1
for (i = 0; i < sv.world.num_edicts; i++) for (i = 0; i < sv.world.num_edicts; i++)
{ {
ent = EDICT_NUM(pr, i); ent = EDICT_NUM_PB(pr, i);
if ((char*)ent->xv >= oldb && (char*)ent->xv < oldb+oldlen) if ((char*)ent->xv >= oldb && (char*)ent->xv < oldb+oldlen)
ent->xv = (extentvars_t*)((char*)ent->xv - oldb + newb); ent->xv = (extentvars_t*)((char*)ent->xv - oldb + newb);
} }
@ -1273,7 +1273,7 @@ static void PR_ApplyCompilation_f (void)
for (i=0 ; i<sv.allocated_client_slots ; i++) for (i=0 ; i<sv.allocated_client_slots ; i++)
{ {
ent = EDICT_NUM(svprogfuncs, i+1); ent = EDICT_NUM_PB(svprogfuncs, i+1);
svs.clients[i].edict = ent; svs.clients[i].edict = ent;
} }
@ -3096,7 +3096,7 @@ PF_particle
particle(origin, color, count) particle(origin, color, count)
================= =================
*/ */
static void QCBUILTIN PF_particle (pubprogfuncs_t *prinst, globalvars_t *pr_globals) //I said it was for compatability only. void QCBUILTIN PF_particle (pubprogfuncs_t *prinst, globalvars_t *pr_globals) //I said it was for compatability only.
{ {
float *org, *dir; float *org, *dir;
int color; int color;
@ -3686,7 +3686,7 @@ void PF_newcheckclient (pubprogfuncs_t *prinst, world_t *w)
if (i >= sv.allocated_client_slots+1) if (i >= sv.allocated_client_slots+1)
i = 1; i = 1;
ent = EDICT_NUM(prinst, i); ent = EDICT_NUM_UB(prinst, i);
if (i == w->lastcheck) if (i == w->lastcheck)
break; // didn't find anything else break; // didn't find anything else
@ -3747,7 +3747,7 @@ int PF_checkclient_Internal (pubprogfuncs_t *prinst)
} }
// return check if it might be visible // return check if it might be visible
ent = EDICT_NUM(prinst, w->lastcheck); ent = EDICT_NUM_PB(prinst, w->lastcheck);
if (ED_ISFREE(ent) || ent->v->health <= 0) if (ED_ISFREE(ent) || ent->v->health <= 0)
{ {
return 0; return 0;
@ -3776,7 +3776,7 @@ int PF_checkclient_Internal (pubprogfuncs_t *prinst)
static void QCBUILTIN PF_checkclient (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) static void QCBUILTIN PF_checkclient (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{ {
RETURN_EDICT(prinst, EDICT_NUM(prinst, PF_checkclient_Internal(prinst))); RETURN_EDICT(prinst, EDICT_NUM_PB(prinst, PF_checkclient_Internal(prinst)));
} }
//============================================================================ //============================================================================
@ -3961,7 +3961,7 @@ static void QCBUILTIN PF_spawnclient (pubprogfuncs_t *prinst, struct globalvars_
svs.clients[i].datagram.allowoverflow = true; svs.clients[i].datagram.allowoverflow = true;
svs.clients[i].datagram.maxsize = 0; svs.clients[i].datagram.maxsize = 0;
svs.clients[i].edict = EDICT_NUM(prinst, i+1); svs.clients[i].edict = EDICT_NUM_PB(prinst, i+1);
SV_SetUpClientEdict (&svs.clients[i], svs.clients[i].edict); SV_SetUpClientEdict (&svs.clients[i], svs.clients[i].edict);
@ -4700,7 +4700,7 @@ vector aim(entity, missilespeed)
*/ */
//cvar_t sv_aim = {"sv_aim", "0.93"}; //cvar_t sv_aim = {"sv_aim", "0.93"};
cvar_t sv_aim = CVAR("sv_aim", "2"); cvar_t sv_aim = CVAR("sv_aim", "2");
static void QCBUILTIN PF_aim (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals) void QCBUILTIN PF_aim (pubprogfuncs_t *prinst, struct globalvars_s *pr_globals)
{ {
edict_t *ent, *check, *bestent; edict_t *ent, *check, *bestent;
vec3_t start, dir, end, bestdir; vec3_t start, dir, end, bestdir;
@ -4754,7 +4754,7 @@ static void QCBUILTIN PF_aim (pubprogfuncs_t *prinst, struct globalvars_s *pr_gl
for (i=1 ; i<sv.world.num_edicts ; i++ ) for (i=1 ; i<sv.world.num_edicts ; i++ )
{ {
check = EDICT_NUM(prinst, i); check = EDICT_NUM_PB(prinst, i);
if (check->v->takedamage != DAMAGE_AIM) if (check->v->takedamage != DAMAGE_AIM)
continue; continue;
if (check == ent) if (check == ent)
@ -8449,8 +8449,8 @@ void PRSV_RunThreads(void)
{ //call it and forget it ever happened. The Sleep biltin will recreate if needed. { //call it and forget it ever happened. The Sleep biltin will recreate if needed.
pr_globals = PR_globals(svprogfuncs, PR_CURRENT); pr_globals = PR_globals(svprogfuncs, PR_CURRENT);
pr_global_struct->self = EDICT_TO_PROG(svprogfuncs, EDICT_NUM(svprogfuncs, state->self)); pr_global_struct->self = EDICT_TO_PROG(svprogfuncs, EDICT_NUM_UB(svprogfuncs, state->self));
pr_global_struct->other = EDICT_TO_PROG(svprogfuncs, EDICT_NUM(svprogfuncs, state->other)); pr_global_struct->other = EDICT_TO_PROG(svprogfuncs, EDICT_NUM_UB(svprogfuncs, state->other));
G_FLOAT(OFS_RETURN) = state->returnval; G_FLOAT(OFS_RETURN) = state->returnval;
svprogfuncs->RunThread(svprogfuncs, state->thread); svprogfuncs->RunThread(svprogfuncs, state->thread);
@ -9256,7 +9256,7 @@ static void QCBUILTIN PF_ShowPic(pubprogfuncs_t *prinst, struct globalvars_s *pr
prinst->callargc = 6; prinst->callargc = 6;
for (entnum = 0; entnum < sv.allocated_client_slots; entnum++) for (entnum = 0; entnum < sv.allocated_client_slots; entnum++)
{ {
G_INT(OFS_PARM5) = EDICT_TO_PROG(prinst, EDICT_NUM(prinst, entnum+1)); G_INT(OFS_PARM5) = EDICT_TO_PROG(prinst, EDICT_NUM_PB(prinst, entnum+1));
PF_ShowPic(prinst, pr_globals); PF_ShowPic(prinst, pr_globals);
} }
} }
@ -9285,7 +9285,7 @@ static void QCBUILTIN PF_HidePic(pubprogfuncs_t *prinst, struct globalvars_s *pr
prinst->callargc = 2; prinst->callargc = 2;
for (entnum = 0; entnum < sv.allocated_client_slots; entnum++) for (entnum = 0; entnum < sv.allocated_client_slots; entnum++)
{ {
G_INT(OFS_PARM1) = EDICT_TO_PROG(prinst, EDICT_NUM(prinst, entnum+1)); G_INT(OFS_PARM1) = EDICT_TO_PROG(prinst, EDICT_NUM_PB(prinst, entnum+1));
PF_HidePic(prinst, pr_globals); PF_HidePic(prinst, pr_globals);
} }
} }
@ -9323,7 +9323,7 @@ static void QCBUILTIN PF_MovePic(pubprogfuncs_t *prinst, struct globalvars_s *pr
prinst->callargc = 5; prinst->callargc = 5;
for (entnum = 0; entnum < sv.allocated_client_slots; entnum++) for (entnum = 0; entnum < sv.allocated_client_slots; entnum++)
{ {
G_INT(OFS_PARM4) = EDICT_TO_PROG(prinst, EDICT_NUM(prinst, entnum+1)); G_INT(OFS_PARM4) = EDICT_TO_PROG(prinst, EDICT_NUM_PB(prinst, entnum+1));
PF_MovePic(prinst, pr_globals); PF_MovePic(prinst, pr_globals);
} }
} }
@ -9354,7 +9354,7 @@ static void QCBUILTIN PF_ChangePic(pubprogfuncs_t *prinst, struct globalvars_s *
prinst->callargc = 3; prinst->callargc = 3;
for (entnum = 0; entnum < sv.allocated_client_slots; entnum++) for (entnum = 0; entnum < sv.allocated_client_slots; entnum++)
{ {
G_INT(OFS_PARM2) = EDICT_TO_PROG(prinst, EDICT_NUM(prinst, entnum+1)); G_INT(OFS_PARM2) = EDICT_TO_PROG(prinst, EDICT_NUM_PB(prinst, entnum+1));
PF_ChangePic(prinst, pr_globals); PF_ChangePic(prinst, pr_globals);
} }
} }
@ -9531,7 +9531,7 @@ static void QCBUILTIN PF_runclientphys(pubprogfuncs_t *prinst, struct globalvars
if (pmove.onground) if (pmove.onground)
{ {
ent->v->flags = (int)ent->v->flags | FL_ONGROUND; ent->v->flags = (int)ent->v->flags | FL_ONGROUND;
ent->v->groundentity = EDICT_TO_PROG(svprogfuncs, EDICT_NUM(svprogfuncs, pmove.physents[pmove.groundent].info)); ent->v->groundentity = EDICT_TO_PROG(svprogfuncs, EDICT_NUM_PB(svprogfuncs, pmove.physents[pmove.groundent].info));
} }
else else
ent->v->flags = (int)ent->v->flags & ~FL_ONGROUND; ent->v->flags = (int)ent->v->flags & ~FL_ONGROUND;
@ -9544,7 +9544,7 @@ static void QCBUILTIN PF_runclientphys(pubprogfuncs_t *prinst, struct globalvars
if (pmove.physents[pmove.touchindex[i]].notouch) if (pmove.physents[pmove.touchindex[i]].notouch)
continue; continue;
n = pmove.physents[pmove.touchindex[i]].info; n = pmove.physents[pmove.touchindex[i]].info;
touched = EDICT_NUM(svprogfuncs, n); touched = EDICT_NUM_PB(svprogfuncs, n);
if (!touched->v->touch || n >= playertouchmax || (playertouch[n/8]&(1<<(n%8)))) if (!touched->v->touch || n >= playertouchmax || (playertouch[n/8]&(1<<(n%8))))
continue; continue;

File diff suppressed because it is too large Load diff

View file

@ -472,7 +472,7 @@ static edict_t *QDECL Q1QVMPF_EntAlloc(pubprogfuncs_t *pf, pbool object, size_t
edict_t *e; edict_t *e;
for ( i=0 ; i<sv.world.num_edicts ; i++) for ( i=0 ; i<sv.world.num_edicts ; i++)
{ {
e = (edict_t*)EDICT_NUM(pf, i); e = (edict_t*)EDICT_NUM_PB(pf, i);
// the first couple seconds of server time can involve a lot of // the first couple seconds of server time can involve a lot of
// freeing and allocating, so relax the replacement policy // freeing and allocating, so relax the replacement policy
if (!e || (ED_ISFREE(e) && ( e->freetime < 2 || sv.time - e->freetime > 0.5 ) )) if (!e || (ED_ISFREE(e) && ( e->freetime < 2 || sv.time - e->freetime > 0.5 ) ))
@ -488,7 +488,7 @@ static edict_t *QDECL Q1QVMPF_EntAlloc(pubprogfuncs_t *pf, pbool object, size_t
{ {
for ( i=0 ; i<sv.world.num_edicts ; i++) for ( i=0 ; i<sv.world.num_edicts ; i++)
{ {
e = (edict_t*)EDICT_NUM(pf, i); e = (edict_t*)EDICT_NUM_PB(pf, i);
// the first couple seconds of server time can involve a lot of // the first couple seconds of server time can involve a lot of
// freeing and allocating, so relax the replacement policy // freeing and allocating, so relax the replacement policy
if (!e || ED_ISFREE(e)) if (!e || ED_ISFREE(e))
@ -868,7 +868,7 @@ static qintptr_t QVM_BPrint (void *offset, quintptr_t mask, const qintptr_t *arg
} }
static qintptr_t QVM_SPrint (void *offset, quintptr_t mask, const qintptr_t *arg) static qintptr_t QVM_SPrint (void *offset, quintptr_t mask, const qintptr_t *arg)
{ {
if ((unsigned)VM_LONG(arg[0]) > sv.allocated_client_slots) if ((unsigned)VM_LONG(arg[0])-1u >= sv.allocated_client_slots)
return 0; return 0;
SV_ClientPrintf(&svs.clients[VM_LONG(arg[0])-1], VM_LONG(arg[1]), "%s", (char*)VM_POINTER(arg[2])); SV_ClientPrintf(&svs.clients[VM_LONG(arg[0])-1], VM_LONG(arg[1]), "%s", (char*)VM_POINTER(arg[2]));
return 0; return 0;
@ -951,7 +951,7 @@ static qintptr_t QVM_FindRadius (void *offset, quintptr_t mask, const qintptr_t
rad *= rad; rad *= rad;
for(start++; start < sv.world.num_edicts; start++) for(start++; start < sv.world.num_edicts; start++)
{ {
ed = EDICT_NUM(svprogfuncs, start); ed = EDICT_NUM_PB(svprogfuncs, start);
if (ED_ISFREE(ed)) if (ED_ISFREE(ed))
continue; continue;
VectorSubtract(ed->v->origin, org, diff); VectorSubtract(ed->v->origin, org, diff);
@ -962,7 +962,7 @@ static qintptr_t QVM_FindRadius (void *offset, quintptr_t mask, const qintptr_t
} }
static qintptr_t QVM_WalkMove (void *offset, quintptr_t mask, const qintptr_t *arg) static qintptr_t QVM_WalkMove (void *offset, quintptr_t mask, const qintptr_t *arg)
{ {
wedict_t *ed = WEDICT_NUM(svprogfuncs, arg[0]); wedict_t *ed = WEDICT_NUM_UB(svprogfuncs, arg[0]);
float yaw = VM_FLOAT(arg[1]); float yaw = VM_FLOAT(arg[1]);
float dist = VM_FLOAT(arg[2]); float dist = VM_FLOAT(arg[2]);
vec3_t move; vec3_t move;
@ -985,7 +985,7 @@ static qintptr_t QVM_DropToFloor (void *offset, quintptr_t mask, const qintptr_t
trace_t trace; trace_t trace;
extern cvar_t pr_droptofloorunits; extern cvar_t pr_droptofloorunits;
ent = EDICT_NUM(svprogfuncs, arg[0]); ent = EDICT_NUM_UB(svprogfuncs, arg[0]);
VectorCopy (ent->v->origin, end); VectorCopy (ent->v->origin, end);
if (pr_droptofloorunits.value > 0) if (pr_droptofloorunits.value > 0)
@ -1010,7 +1010,7 @@ static qintptr_t QVM_DropToFloor (void *offset, quintptr_t mask, const qintptr_t
static qintptr_t QVM_CheckBottom (void *offset, quintptr_t mask, const qintptr_t *arg) static qintptr_t QVM_CheckBottom (void *offset, quintptr_t mask, const qintptr_t *arg)
{ {
vec3_t up = {0,0,1}; vec3_t up = {0,0,1};
return World_CheckBottom(&sv.world, (wedict_t*)EDICT_NUM(svprogfuncs, VM_LONG(arg[0])), up); return World_CheckBottom(&sv.world, (wedict_t*)EDICT_NUM_UB(svprogfuncs, VM_LONG(arg[0])), up);
} }
static qintptr_t QVM_PointContents (void *offset, quintptr_t mask, const qintptr_t *arg) static qintptr_t QVM_PointContents (void *offset, quintptr_t mask, const qintptr_t *arg)
{ {
@ -1033,7 +1033,7 @@ static qintptr_t QVM_NextEnt (void *offset, quintptr_t mask, const qintptr_t *ar
{ {
return 0; return 0;
} }
ent = EDICT_NUM(svprogfuncs, i); ent = EDICT_NUM_PB(svprogfuncs, i);
if (!ED_ISFREE(ent)) if (!ED_ISFREE(ent))
{ {
return i; return i;
@ -1530,7 +1530,7 @@ static qintptr_t QVM_Add_Bot (void *offset, quintptr_t mask, const qintptr_t *ar
cl->datagram.allowoverflow = true; cl->datagram.allowoverflow = true;
cl->datagram.maxsize = 0; cl->datagram.maxsize = 0;
cl->edict = EDICT_NUM(sv.world.progs, i+1); cl->edict = EDICT_NUM_PB(sv.world.progs, i+1);
Info_SetValueForKey(cl->userinfo, "name", name, sizeof(cl->userinfo)); Info_SetValueForKey(cl->userinfo, "name", name, sizeof(cl->userinfo));
Info_SetValueForKey(cl->userinfo, "topcolor", va("%i", top), sizeof(cl->userinfo)); Info_SetValueForKey(cl->userinfo, "topcolor", va("%i", top), sizeof(cl->userinfo));
@ -2167,8 +2167,8 @@ qboolean PR_LoadQ1QVM(void)
// q1qvmprogfuncs.AddString = Q1QVMPF_AddString; //using this breaks 64bit support, and is a 'bad plan' elsewhere too, // q1qvmprogfuncs.AddString = Q1QVMPF_AddString; //using this breaks 64bit support, and is a 'bad plan' elsewhere too,
q1qvmprogfuncs.EDICT_NUM = Q1QVMPF_EdictNum; q1qvmprogfuncs.EdictNum = Q1QVMPF_EdictNum;
q1qvmprogfuncs.NUM_FOR_EDICT = Q1QVMPF_NumForEdict; q1qvmprogfuncs.NumForEdict = Q1QVMPF_NumForEdict;
q1qvmprogfuncs.EdictToProgs = Q1QVMPF_EdictToProgs; q1qvmprogfuncs.EdictToProgs = Q1QVMPF_EdictToProgs;
q1qvmprogfuncs.ProgsToEdict = Q1QVMPF_ProgsToEdict; q1qvmprogfuncs.ProgsToEdict = Q1QVMPF_ProgsToEdict;
q1qvmprogfuncs.EntAlloc = Q1QVMPF_EntAlloc; q1qvmprogfuncs.EntAlloc = Q1QVMPF_EntAlloc;
@ -2262,6 +2262,7 @@ qboolean PR_LoadQ1QVM(void)
sv.world.num_edicts = 1; sv.world.num_edicts = 1;
sv.world.max_edicts = bound(64, gd.maxedicts, MAX_EDICTS); sv.world.max_edicts = bound(64, gd.maxedicts, MAX_EDICTS);
q1qvmprogfuncs.edicttable = Z_Malloc(sizeof(*q1qvmprogfuncs.edicttable) * sv.world.max_edicts); q1qvmprogfuncs.edicttable = Z_Malloc(sizeof(*q1qvmprogfuncs.edicttable) * sv.world.max_edicts);
q1qvmprogfuncs.edicttable_length = sv.world.max_edicts;
limit = VM_MemoryMask(q1qvm); limit = VM_MemoryMask(q1qvm);
if (gd.sizeofent < 0 || gd.sizeofent > 0xffffffff / gd.maxedicts) if (gd.sizeofent < 0 || gd.sizeofent > 0xffffffff / gd.maxedicts)

View file

@ -341,7 +341,7 @@ void SV_Loadgame_Legacy(char *filename, vfsfile_t *f, int version)
{ {
if (cl->state) if (cl->state)
sv.spawned_client_slots += 1; sv.spawned_client_slots += 1;
ent = EDICT_NUM(svprogfuncs, i+1); ent = EDICT_NUM_PB(svprogfuncs, i+1);
} }
else else
ent = NULL; ent = NULL;
@ -824,7 +824,7 @@ qboolean SV_LoadLevelCache(const char *savename, const char *level, const char *
for (i=0 ; i<svs.allocated_client_slots ; i++) for (i=0 ; i<svs.allocated_client_slots ; i++)
{ {
if (i < sv.allocated_client_slots) if (i < sv.allocated_client_slots)
ent = EDICT_NUM(svprogfuncs, i+1); ent = EDICT_NUM_PB(svprogfuncs, i+1);
else else
ent = NULL; ent = NULL;
svs.clients[i].edict = ent; svs.clients[i].edict = ent;
@ -881,7 +881,7 @@ qboolean SV_LoadLevelCache(const char *savename, const char *level, const char *
for (i=0 ; i<sv.world.num_edicts ; i++) for (i=0 ; i<sv.world.num_edicts ; i++)
{ {
ent = EDICT_NUM(svprogfuncs, i); ent = EDICT_NUM_PB(svprogfuncs, i);
if (ED_ISFREE(ent)) if (ED_ISFREE(ent))
continue; continue;
@ -1162,7 +1162,7 @@ void SV_SaveLevelCache(const char *savedir, qboolean dontharmgame)
{ {
for (clnum=0; clnum < sv.allocated_client_slots; clnum++) for (clnum=0; clnum < sv.allocated_client_slots; clnum++)
{ {
edict_t *ed = EDICT_NUM(svprogfuncs, clnum+1); edict_t *ed = EDICT_NUM_PB(svprogfuncs, clnum+1);
ed->ereftype = ER_ENTITY; ed->ereftype = ER_ENTITY;
} }
} }
@ -1210,6 +1210,20 @@ void SV_Savegame (const char *savename, qboolean mapchange)
return; return;
} }
switch(svs.gametype)
{
default:
case GT_Q1QVM:
#ifdef VM_LUA
case GT_LUA:
#endif
Con_Printf("gamecode doesn't support saving\n");
return;
case GT_PROGS:
case GT_QUAKE2:
break;
}
if (sv.allocated_client_slots == 1 && svs.gametype == GT_PROGS) if (sv.allocated_client_slots == 1 && svs.gametype == GT_PROGS)
{ {
if (svs.clients->state > cs_connected && svs.clients[0].edict->v->health <= 0) if (svs.clients->state > cs_connected && svs.clients[0].edict->v->health <= 0)
@ -1444,9 +1458,6 @@ void SV_AutoSave(void)
default: //probably broken. don't ever try. default: //probably broken. don't ever try.
return; return;
#ifdef VM_LUA
case GT_LUA:
#endif
case GT_Q1QVM: case GT_Q1QVM:
case GT_PROGS: case GT_PROGS:
//don't bother to autosave multiplayer games. //don't bother to autosave multiplayer games.

View file

@ -328,7 +328,7 @@ void SV_EmitCSQCUpdate(client_t *client, sizebuf_t *msg, qbyte svcnumber)
{ {
if (!(client->pendingcsqcbits[entnum] & SENDFLAGS_REMOVED)) if (!(client->pendingcsqcbits[entnum] & SENDFLAGS_REMOVED))
{ //while the entity has NOREMOVE, only remove it if the remove is a resend { //while the entity has NOREMOVE, only remove it if the remove is a resend
if ((int)EDICT_NUM(svprogfuncs, en)->xv->pvsflags & PVSF_NOREMOVE) if ((int)EDICT_NUM_PB(svprogfuncs, en)->xv->pvsflags & PVSF_NOREMOVE)
continue; continue;
} }
if (msg->cursize + 5 >= msg->maxsize) if (msg->cursize + 5 >= msg->maxsize)
@ -451,7 +451,7 @@ void SV_EmitCSQCUpdate(client_t *client, sizebuf_t *msg, qbyte svcnumber)
{ {
if (!(client->pendingcsqcbits[entnum] & SENDFLAGS_REMOVED)) if (!(client->pendingcsqcbits[entnum] & SENDFLAGS_REMOVED))
{ //while the entity has NOREMOVE, only remove it if the remove is a resend { //while the entity has NOREMOVE, only remove it if the remove is a resend
if ((int)EDICT_NUM(svprogfuncs, en)->xv->pvsflags & PVSF_NOREMOVE) if ((int)EDICT_NUM_PB(svprogfuncs, entnum)->xv->pvsflags & PVSF_NOREMOVE)
continue; continue;
} }
if (msg->cursize + 5 >= msg->maxsize) if (msg->cursize + 5 >= msg->maxsize)
@ -1387,7 +1387,7 @@ qboolean SVFTE_EmitPacketEntities(client_t *client, packet_entities_t *to, sizeb
o = &client->sentents.entities[j]; o = &client->sentents.entities[j];
if (o->number) if (o->number)
{ {
e = EDICT_NUM(svprogfuncs, o->number); e = EDICT_NUM_PB(svprogfuncs, o->number);
if (!((int)e->xv->pvsflags & PVSF_NOREMOVE)) if (!((int)e->xv->pvsflags & PVSF_NOREMOVE))
{ {
client->pendingdeltabits[j] = UF_REMOVE; client->pendingdeltabits[j] = UF_REMOVE;
@ -1446,7 +1446,7 @@ qboolean SVFTE_EmitPacketEntities(client_t *client, packet_entities_t *to, sizeb
o = &client->sentents.entities[j]; o = &client->sentents.entities[j];
if (o->number) if (o->number)
{ {
e = EDICT_NUM(svprogfuncs, o->number); e = EDICT_NUM_PB(svprogfuncs, o->number);
if (!((int)e->xv->pvsflags & PVSF_NOREMOVE)) if (!((int)e->xv->pvsflags & PVSF_NOREMOVE))
{ {
client->pendingdeltabits[j] = UF_REMOVE; client->pendingdeltabits[j] = UF_REMOVE;
@ -1527,14 +1527,14 @@ qboolean SVFTE_EmitPacketEntities(client_t *client, packet_entities_t *to, sizeb
{ {
/*if reset2, then this is the second packet sent to the client and should have a forced reset (but which isn't tracked)*/ /*if reset2, then this is the second packet sent to the client and should have a forced reset (but which isn't tracked)*/
resend[outno].bits = bits & ~UF_RESET2; resend[outno].bits = bits & ~UF_RESET2;
bits = UF_RESET | SVFTE_DeltaCalcBits(&EDICT_NUM(svprogfuncs, j)->baseline, NULL, &client->sentents.entities[j], client->sentents.bonedata); bits = UF_RESET | SVFTE_DeltaCalcBits(&EDICT_NUM_PB(svprogfuncs, j)->baseline, NULL, &client->sentents.entities[j], client->sentents.bonedata);
// Con_Printf("RESET2 %i @ %i\n", j, sequence); // Con_Printf("RESET2 %i @ %i\n", j, sequence);
} }
else if (bits & UF_RESET) else if (bits & UF_RESET)
{ {
/*flag the entity for the next packet, so we always get two resets when it appears, to reduce the effects of packetloss on seeing rockets etc*/ /*flag the entity for the next packet, so we always get two resets when it appears, to reduce the effects of packetloss on seeing rockets etc*/
client->pendingdeltabits[j] = UF_RESET2; client->pendingdeltabits[j] = UF_RESET2;
bits = UF_RESET | SVFTE_DeltaCalcBits(&EDICT_NUM(svprogfuncs, j)->baseline, NULL, &client->sentents.entities[j], client->sentents.bonedata); bits = UF_RESET | SVFTE_DeltaCalcBits(&EDICT_NUM_PB(svprogfuncs, j)->baseline, NULL, &client->sentents.entities[j], client->sentents.bonedata);
resend[outno].bits = UF_RESET; resend[outno].bits = UF_RESET;
// Con_Printf("RESET %i @ %i\n", j, sequence); // Con_Printf("RESET %i @ %i\n", j, sequence);
} }
@ -1623,7 +1623,7 @@ void SVQW_EmitPacketEntities (client_t *client, packet_entities_t *to, sizebuf_t
if (newnum < oldnum) if (newnum < oldnum)
{ // this is a new entity, send it from the baseline { // this is a new entity, send it from the baseline
if (svprogfuncs) if (svprogfuncs)
ent = EDICT_NUM(svprogfuncs, newnum); ent = EDICT_NUM_UB(svprogfuncs, newnum);
else else
ent = NULL; ent = NULL;
//Con_Printf ("baseline %i\n", newnum); //Con_Printf ("baseline %i\n", newnum);
@ -2593,7 +2593,7 @@ void SV_WritePlayersToClient (client_t *client, client_frame_t *frame, edict_t *
ent = cl->edict; ent = cl->edict;
if (cl->viewent && ent == clent) if (cl->viewent && ent == clent)
{ {
vent = EDICT_NUM(svprogfuncs, cl->viewent); vent = EDICT_NUM_UB(svprogfuncs, cl->viewent);
if (!vent) if (!vent)
vent = ent; vent = ent;
} }
@ -2704,7 +2704,7 @@ void SV_WritePlayersToClient (client_t *client, client_frame_t *frame, edict_t *
{ {
if (client->spec_track > 0) if (client->spec_track > 0)
{ {
edict_t *s = EDICT_NUM(svprogfuncs, client->spec_track); edict_t *s = EDICT_NUM_UB(svprogfuncs, client->spec_track);
clst.spectator = 2; clst.spectator = 2;
clst.mins = s->v->mins; clst.mins = s->v->mins;
@ -2766,7 +2766,7 @@ void SV_WritePlayersToClient (client_t *client, client_frame_t *frame, edict_t *
#ifdef NQPROT #ifdef NQPROT
void SVNQ_EmitEntityState(sizebuf_t *msg, entity_state_t *ent) void SVNQ_EmitEntityState(sizebuf_t *msg, entity_state_t *ent)
{ {
edict_t *ed = EDICT_NUM(svprogfuncs, ent->number); edict_t *ed = EDICT_NUM_PB(svprogfuncs, ent->number);
entity_state_t *baseline = &ed->baseline; entity_state_t *baseline = &ed->baseline;
int i, eff; int i, eff;
@ -3536,7 +3536,7 @@ void SV_Snapshot_BuildQ1(client_t *client, packet_entities_t *pack, pvscamera_t
for ( ; e<limit ; e++) for ( ; e<limit ; e++)
{ {
ent = EDICT_NUM(svprogfuncs, e); ent = EDICT_NUM_PB(svprogfuncs, e);
if (ED_ISFREE(ent)) if (ED_ISFREE(ent))
continue; continue;
@ -3599,7 +3599,7 @@ void SV_Snapshot_BuildQ1(client_t *client, packet_entities_t *pack, pvscamera_t
tracecullent = ent; tracecullent = ent;
while(tracecullent->xv->tag_entity&&c-->0) while(tracecullent->xv->tag_entity&&c-->0)
{ {
tracecullent = EDICT_NUM(svprogfuncs, tracecullent->xv->tag_entity); tracecullent = EDICT_NUM_UB(svprogfuncs, tracecullent->xv->tag_entity);
} }
if (tracecullent == clent) if (tracecullent == clent)
tracecullent = NULL; tracecullent = NULL;
@ -3800,13 +3800,13 @@ void SV_Snapshot_SetupPVS(client_t *client, pvscamera_t *camera)
for (; client; client = client->controlled) for (; client; client = client->controlled)
{ {
if (client->viewent) //svc_viewentity hack if (client->viewent) //svc_viewentity hack
SV_AddCameraEntity(camera, EDICT_NUM(svprogfuncs, client->viewent), client->edict->v->view_ofs); SV_AddCameraEntity(camera, EDICT_NUM_UB(svprogfuncs, client->viewent), client->edict->v->view_ofs);
else else
SV_AddCameraEntity(camera, client->edict, client->edict->v->view_ofs); SV_AddCameraEntity(camera, client->edict, client->edict->v->view_ofs);
//spectators should always see their targetted player //spectators should always see their targetted player
if (client->spec_track) if (client->spec_track)
SV_AddCameraEntity(camera, EDICT_NUM(svprogfuncs, client->spec_track), client->edict->v->view_ofs); SV_AddCameraEntity(camera, EDICT_NUM_UB(svprogfuncs, client->spec_track), client->edict->v->view_ofs);
//view2 support should always see the extra entity //view2 support should always see the extra entity
if (client->edict->xv->view2) if (client->edict->xv->view2)
@ -4031,7 +4031,7 @@ void SV_ProcessSendFlags(client_t *c)
return; return;
for (e=1 ; e<sv.world.num_edicts && e < c->max_net_ents; e++) for (e=1 ; e<sv.world.num_edicts && e < c->max_net_ents; e++)
{ {
ent = EDICT_NUM(svprogfuncs, e); ent = EDICT_NUM_PB(svprogfuncs, e);
if (ED_ISFREE(ent)) if (ED_ISFREE(ent))
continue; continue;
if (ent->xv->SendFlags) if (ent->xv->SendFlags)
@ -4052,7 +4052,7 @@ void SV_CleanupEnts(void)
for (e=1 ; e<=needcleanup ; e++) for (e=1 ; e<=needcleanup ; e++)
{ {
ent = EDICT_NUM(svprogfuncs, e); ent = EDICT_NUM_PB(svprogfuncs, e);
ent->xv->SendFlags = 0; ent->xv->SendFlags = 0;
#ifndef NOLEGACY #ifndef NOLEGACY

View file

@ -232,7 +232,7 @@ void SVQ1_CreateBaseline (void)
for (entnum = 0; entnum < sv.world.num_edicts ; entnum++) for (entnum = 0; entnum < sv.world.num_edicts ; entnum++)
{ {
svent = EDICT_NUM(svprogfuncs, entnum); svent = EDICT_NUM_PB(svprogfuncs, entnum);
memcpy(&svent->baseline, &nullentitystate, sizeof(entity_state_t)); memcpy(&svent->baseline, &nullentitystate, sizeof(entity_state_t));
svent->baseline.number = entnum; svent->baseline.number = entnum;
@ -304,6 +304,7 @@ void SV_SpawnParmsToClient(client_t *client)
void SV_SaveSpawnparmsClient(client_t *client, float *transferparms) void SV_SaveSpawnparmsClient(client_t *client, float *transferparms)
{ {
int j; int j;
eval_t *eval;
SV_SpawnParmsToQC(client); SV_SpawnParmsToQC(client);
#ifdef VM_Q1 #ifdef VM_Q1
@ -344,7 +345,8 @@ void SV_SaveSpawnparmsClient(client_t *client, float *transferparms)
} }
// call the progs to get default spawn parms for the new client // call the progs to get default spawn parms for the new client
if (PR_FindGlobal(svprogfuncs, "ClientReEnter", 0, NULL)) eval = PR_FindGlobal(svprogfuncs, "ClientReEnter", 0, NULL);
if (eval && eval->function)
{//oooh, evil. {//oooh, evil.
char buffer[65536*4]; char buffer[65536*4];
size_t bufsize = 0; size_t bufsize = 0;
@ -1280,7 +1282,7 @@ void SV_SpawnServer (const char *server, const char *startspot, qboolean noents,
#endif #endif
case GT_Q1QVM: case GT_Q1QVM:
case GT_PROGS: case GT_PROGS:
ent = EDICT_NUM(svprogfuncs, 0); ent = EDICT_NUM_PB(svprogfuncs, 0);
ent->ereftype = ER_ENTITY; ent->ereftype = ER_ENTITY;
#ifndef SERVERONLY #ifndef SERVERONLY
@ -1386,7 +1388,7 @@ void SV_SpawnServer (const char *server, const char *startspot, qboolean noents,
{ {
//world entity is hackily spawned //world entity is hackily spawned
extern cvar_t coop, pr_imitatemvdsv; extern cvar_t coop, pr_imitatemvdsv;
ent = EDICT_NUM(svprogfuncs, 0); ent = EDICT_NUM_PB(svprogfuncs, 0);
ent->ereftype = ER_ENTITY; ent->ereftype = ER_ENTITY;
#ifdef VM_Q1 #ifdef VM_Q1
if (svs.gametype != GT_Q1QVM) //we cannot do this with qvm if (svs.gametype != GT_Q1QVM) //we cannot do this with qvm
@ -1518,7 +1520,7 @@ void SV_SpawnServer (const char *server, const char *startspot, qboolean noents,
if (svprogfuncs) if (svprogfuncs)
{ {
eval_t *val; eval_t *val;
ent = EDICT_NUM(svprogfuncs, 0); ent = EDICT_NUM_PB(svprogfuncs, 0);
ent->v->angles[0] = ent->v->angles[1] = ent->v->angles[2] = 0; ent->v->angles[0] = ent->v->angles[1] = ent->v->angles[2] = 0;
if ((val = svprogfuncs->GetEdictFieldValue(svprogfuncs, ent, "message", ev_string, NULL))) if ((val = svprogfuncs->GetEdictFieldValue(svprogfuncs, ent, "message", ev_string, NULL)))
snprintf(sv.mapname, sizeof(sv.mapname), "%s", PR_GetString(svprogfuncs, val->string)); snprintf(sv.mapname, sizeof(sv.mapname), "%s", PR_GetString(svprogfuncs, val->string));
@ -1614,7 +1616,8 @@ void SV_SpawnServer (const char *server, const char *startspot, qboolean noents,
{ {
eval_t *eval; eval_t *eval;
eval = PR_FindGlobal(svprogfuncs, "startspot", 0, NULL); eval = PR_FindGlobal(svprogfuncs, "startspot", 0, NULL);
if (eval) eval->string = PR_NewString(svprogfuncs, startspot); if (eval && svs.gametype != GT_Q1QVM) //we cannot do this with qvm
svprogfuncs->SetStringField(svprogfuncs, NULL, &eval->string, startspot, false);
} }
if (Cmd_AliasExist("f_svnewmap", RESTRICT_LOCAL)) if (Cmd_AliasExist("f_svnewmap", RESTRICT_LOCAL))
@ -1633,7 +1636,7 @@ void SV_SpawnServer (const char *server, const char *startspot, qboolean noents,
//fixme: go off bsp extents instead? //fixme: go off bsp extents instead?
for(i = 1; i < sv.world.num_edicts; i++) for(i = 1; i < sv.world.num_edicts; i++)
{ {
ent = EDICT_NUM(svprogfuncs, i); ent = EDICT_NUM_PB(svprogfuncs, i);
for (j = 0; j < 3; j++) for (j = 0; j < 3; j++)
{ {
ne = fabs(ent->v->origin[j]); ne = fabs(ent->v->origin[j]);

View file

@ -2242,7 +2242,7 @@ client_t *SV_AddSplit(client_t *controller, char *info, int id)
break; break;
#endif #endif
default: default:
cl->edict = EDICT_NUM(svprogfuncs, i+1); cl->edict = EDICT_NUM_PB(svprogfuncs, i+1);
break; break;
} }
@ -3006,7 +3006,7 @@ client_t *SVC_DirectConnect(void)
} }
if (svprogfuncs) if (svprogfuncs)
ent = EDICT_NUM(svprogfuncs, edictnum); ent = EDICT_NUM_UB(svprogfuncs, edictnum);
else else
ent = NULL; ent = NULL;
#ifdef Q2SERVER #ifdef Q2SERVER

View file

@ -701,7 +701,7 @@ static qboolean WPhys_PushAngles (world_t *w, wedict_t *pusher, vec3_t move, vec
if (pusher->v->movetype != MOVETYPE_H2PUSHPULL) if (pusher->v->movetype != MOVETYPE_H2PUSHPULL)
for (e = 1; e < w->num_edicts; e++) for (e = 1; e < w->num_edicts; e++)
{ {
check = WEDICT_NUM(w->progs, e); check = WEDICT_NUM_PB(w->progs, e);
if (ED_ISFREE(check)) if (ED_ISFREE(check))
continue; continue;
@ -902,7 +902,7 @@ qboolean WPhys_Push (world_t *w, wedict_t *pusher, vec3_t move, vec3_t amove)
num_moved = 0; num_moved = 0;
for (e=1 ; e<w->num_edicts ; e++) for (e=1 ; e<w->num_edicts ; e++)
{ {
check = WEDICT_NUM(w->progs, e); check = WEDICT_NUM_PB(w->progs, e);
if (ED_ISFREE(check)) if (ED_ISFREE(check))
continue; continue;
if (check->v->movetype == MOVETYPE_PUSH if (check->v->movetype == MOVETYPE_PUSH
@ -2368,7 +2368,7 @@ void World_Physics_Frame(world_t *w)
/*physics mode 1 = thinks only*/ /*physics mode 1 = thinks only*/
for (i=0 ; i<w->num_edicts ; i++) for (i=0 ; i<w->num_edicts ; i++)
{ {
ent = (wedict_t*)EDICT_NUM(w->progs, i); ent = (wedict_t*)EDICT_NUM_PB(w->progs, i);
if (ED_ISFREE(ent)) if (ED_ISFREE(ent))
continue; continue;
@ -2386,7 +2386,7 @@ void World_Physics_Frame(world_t *w)
// //
for (i=0 ; i<w->num_edicts ; i++) for (i=0 ; i<w->num_edicts ; i++)
{ {
ent = (wedict_t*)EDICT_NUM(w->progs, i); ent = (wedict_t*)EDICT_NUM_PB(w->progs, i);
if (ED_ISFREE(ent)) if (ED_ISFREE(ent))
continue; continue;

View file

@ -1710,7 +1710,7 @@ void SV_WriteEntityDataToMessage (client_t *client, sizebuf_t *msg, int pnum)
// a fixangle might get lost in a dropped packet. Oh well. // a fixangle might get lost in a dropped packet. Oh well.
if (client->spectator && ISNQCLIENT(client) && client->spec_track > 0) if (client->spectator && ISNQCLIENT(client) && client->spec_track > 0)
{ {
edict_t *ed = EDICT_NUM(svprogfuncs, client->spec_track); edict_t *ed = EDICT_NUM_UB(svprogfuncs, client->spec_track);
MSG_WriteByte(msg, svc_setangle); MSG_WriteByte(msg, svc_setangle);
MSG_WriteAngle(msg, ed->v->v_angle[0]); MSG_WriteAngle(msg, ed->v->v_angle[0]);
MSG_WriteAngle(msg, ed->v->v_angle[1]); MSG_WriteAngle(msg, ed->v->v_angle[1]);
@ -1841,7 +1841,7 @@ void SV_WriteClientdataToMessage (client_t *client, sizebuf_t *msg)
#ifdef NQPROT #ifdef NQPROT
ent = client->edict; ent = client->edict;
if (client->spectator && client->spec_track) if (client->spectator && client->spec_track)
ent = EDICT_NUM(svprogfuncs, client->spec_track); ent = EDICT_NUM_UB(svprogfuncs, client->spec_track);
if (progstype != PROG_QW) if (progstype != PROG_QW)
{ {
if (ISQWCLIENT(client) && !(client->fteprotocolextensions2 & PEXT2_PREDINFO)) if (ISQWCLIENT(client) && !(client->fteprotocolextensions2 & PEXT2_PREDINFO))
@ -2250,7 +2250,7 @@ void SV_CalcClientStats(client_t *client, int statsi[MAX_CL_STATS], float statsf
// if we are a spectator and we are tracking a player, we get his stats // if we are a spectator and we are tracking a player, we get his stats
// so our status bar reflects his // so our status bar reflects his
if (client->spectator && client->spec_track > 0) if (client->spectator && client->spec_track > 0)
ent = EDICT_NUM(svprogfuncs, client->spec_track); ent = EDICT_NUM_UB(svprogfuncs, client->spec_track);
#ifdef HLSERVER #ifdef HLSERVER
if (svs.gametype == GT_HALFLIFE) if (svs.gametype == GT_HALFLIFE)

View file

@ -1536,7 +1536,7 @@ void SV_SendClientPrespawnInfo(client_t *client)
break; break;
} }
ent = EDICT_NUM(svprogfuncs, client->prespawn_idx); ent = EDICT_NUM_PB(svprogfuncs, client->prespawn_idx);
if (!ent) if (!ent)
state = &nullentitystate; state = &nullentitystate;
@ -1918,7 +1918,7 @@ void SV_SpawnSpectator (void)
for (i=svs.allocated_client_slots+1 ; i<sv.world.num_edicts ; i++) for (i=svs.allocated_client_slots+1 ; i<sv.world.num_edicts ; i++)
{ {
e = EDICT_NUM(svprogfuncs, i); e = EDICT_NUM_PB(svprogfuncs, i);
if (!strcmp(PR_GetString(svprogfuncs, e->v->classname), "info_player_start")) if (!strcmp(PR_GetString(svprogfuncs, e->v->classname), "info_player_start"))
{ {
VectorCopy (e->v->origin, sv_player->v->origin); VectorCopy (e->v->origin, sv_player->v->origin);
@ -2000,7 +2000,7 @@ void SV_Begin_Core(client_t *split)
{ {
//keep the spectator tracking the player from the previous map //keep the spectator tracking the player from the previous map
if (split->spec_track > 0) if (split->spec_track > 0)
split->edict->v->goalentity = EDICT_TO_PROG(svprogfuncs, EDICT_NUM(svprogfuncs, split->spec_track)); split->edict->v->goalentity = EDICT_TO_PROG(svprogfuncs, EDICT_NUM_UB(svprogfuncs, split->spec_track));
else else
split->edict->v->goalentity = 0; split->edict->v->goalentity = 0;
@ -4144,8 +4144,8 @@ void SV_PTrack_f (void)
{ {
// turn off tracking // turn off tracking
host_client->spec_track = 0; host_client->spec_track = 0;
ent = EDICT_NUM(svprogfuncs, host_client - svs.clients + 1); ent = EDICT_NUM_PB(svprogfuncs, host_client - svs.clients + 1);
tent = EDICT_NUM(svprogfuncs, 0); tent = EDICT_NUM_PB(svprogfuncs, 0);
ent->v->goalentity = EDICT_TO_PROG(svprogfuncs, tent); ent->v->goalentity = EDICT_TO_PROG(svprogfuncs, tent);
if (ISNQCLIENT(host_client)) if (ISNQCLIENT(host_client))
@ -4169,8 +4169,8 @@ void SV_PTrack_f (void)
{ {
SV_ClientTPrintf (host_client, PRINT_HIGH, "invalid player to track\n"); SV_ClientTPrintf (host_client, PRINT_HIGH, "invalid player to track\n");
host_client->spec_track = 0; host_client->spec_track = 0;
ent = EDICT_NUM(svprogfuncs, host_client - svs.clients + 1); ent = EDICT_NUM_PB(svprogfuncs, host_client - svs.clients + 1);
tent = EDICT_NUM(svprogfuncs, 0); tent = EDICT_NUM_PB(svprogfuncs, 0);
ent->v->goalentity = EDICT_TO_PROG(svprogfuncs, tent); ent->v->goalentity = EDICT_TO_PROG(svprogfuncs, tent);
if (ISNQCLIENT(host_client)) if (ISNQCLIENT(host_client))
@ -4182,8 +4182,8 @@ void SV_PTrack_f (void)
} }
host_client->spec_track = i + 1; // now tracking host_client->spec_track = i + 1; // now tracking
ent = EDICT_NUM(svprogfuncs, host_client - svs.clients + 1); ent = EDICT_NUM_PB(svprogfuncs, host_client - svs.clients + 1);
tent = EDICT_NUM(svprogfuncs, i + 1); tent = EDICT_NUM_PB(svprogfuncs, i + 1);
ent->v->goalentity = EDICT_TO_PROG(svprogfuncs, tent); ent->v->goalentity = EDICT_TO_PROG(svprogfuncs, tent);
if (ISNQCLIENT(host_client)) if (ISNQCLIENT(host_client))
@ -7223,7 +7223,7 @@ if (sv_player->v->health > 0 && before && !after )
if (pmove.onground) if (pmove.onground)
{ {
sv_player->v->flags = (int)sv_player->v->flags | FL_ONGROUND; sv_player->v->flags = (int)sv_player->v->flags | FL_ONGROUND;
sv_player->v->groundentity = EDICT_TO_PROG(svprogfuncs, EDICT_NUM(svprogfuncs, pmove.physents[pmove.groundent].info)); sv_player->v->groundentity = EDICT_TO_PROG(svprogfuncs, EDICT_NUM_PB(svprogfuncs, pmove.physents[pmove.groundent].info));
} }
else else
sv_player->v->flags = (int)sv_player->v->flags & ~FL_ONGROUND; sv_player->v->flags = (int)sv_player->v->flags & ~FL_ONGROUND;
@ -7305,7 +7305,7 @@ if (sv_player->v->health > 0 && before && !after )
float vel; float vel;
vec3_t dir; vec3_t dir;
vec3_t svel; vec3_t svel;
ent = EDICT_NUM(svprogfuncs, n); ent = EDICT_NUM_PB(svprogfuncs, n);
VectorSubtract(ent->v->origin, sv_player->v->origin, dir); VectorSubtract(ent->v->origin, sv_player->v->origin, dir);
VectorNormalize(dir); VectorNormalize(dir);
VectorCopy(sv_player->v->velocity, svel); VectorCopy(sv_player->v->velocity, svel);
@ -7319,7 +7319,7 @@ if (sv_player->v->health > 0 && before && !after )
if (pmove.physents[pmove.touchindex[i]].notouch) if (pmove.physents[pmove.touchindex[i]].notouch)
continue; continue;
n = pmove.physents[pmove.touchindex[i]].info; n = pmove.physents[pmove.touchindex[i]].info;
ent = EDICT_NUM(svprogfuncs, n); ent = EDICT_NUM_PB(svprogfuncs, n);
if (n >= playertouchmax || playertouch[n>>3]&(1<<(n&7))) if (n >= playertouchmax || playertouch[n>>3]&(1<<(n&7)))
continue; continue;
@ -7437,7 +7437,7 @@ void SV_ReadPrydonCursor(void)
} }
// as requested by FrikaC, cursor_trace_ent is reset to world if the // as requested by FrikaC, cursor_trace_ent is reset to world if the
// entity is free at time of receipt // entity is free at time of receipt
if (!svprogfuncs || ED_ISFREE(EDICT_NUM(svprogfuncs, entnum))) if (!svprogfuncs || ED_ISFREE(EDICT_NUM_UB(svprogfuncs, entnum)))
entnum = 0; entnum = 0;
if (msg_badread) Con_Printf("SV_ReadPrydonCursor: badread at %s:%i\n", __FILE__, __LINE__); if (msg_badread) Con_Printf("SV_ReadPrydonCursor: badread at %s:%i\n", __FILE__, __LINE__);
@ -7512,7 +7512,7 @@ void SV_ReadQCRequest(void)
e = MSGSV_ReadEntity(host_client); e = MSGSV_ReadEntity(host_client);
if (e < 0 || e >= sv.world.num_edicts) if (e < 0 || e >= sv.world.num_edicts)
e = 0; e = 0;
G_INT(OFS_PARM0+i*3) = EDICT_TO_PROG(svprogfuncs, EDICT_NUM(svprogfuncs, e)); G_INT(OFS_PARM0+i*3) = EDICT_TO_PROG(svprogfuncs, EDICT_NUM_PB(svprogfuncs, e));
break; break;
} }
i++; i++;
@ -8164,7 +8164,7 @@ void SVNQ_ReadClientMove (usercmd_t *move, qboolean forceangle16)
if (host_client->spec_track) if (host_client->spec_track)
{ //disable tracking { //disable tracking
host_client->spec_track = 0; host_client->spec_track = 0;
host_client->edict->v->goalentity = EDICT_TO_PROG(svprogfuncs, EDICT_NUM(svprogfuncs, 0)); host_client->edict->v->goalentity = EDICT_TO_PROG(svprogfuncs, EDICT_NUM_PB(svprogfuncs, 0));
ClientReliableWrite_Begin(host_client, svc_setview, 4); ClientReliableWrite_Begin(host_client, svc_setview, 4);
ClientReliableWrite_Entity(host_client, host_client - svs.clients + 1); ClientReliableWrite_Entity(host_client, host_client - svs.clients + 1);
} }
@ -8194,7 +8194,7 @@ void SVNQ_ReadClientMove (usercmd_t *move, qboolean forceangle16)
} }
host_client->spec_track = i; host_client->spec_track = i;
host_client->edict->v->goalentity = EDICT_TO_PROG(svprogfuncs, EDICT_NUM(svprogfuncs, i)); host_client->edict->v->goalentity = EDICT_TO_PROG(svprogfuncs, EDICT_NUM_PB(svprogfuncs, i));
ClientReliableWrite_Begin(host_client, svc_setview, 4); ClientReliableWrite_Begin(host_client, svc_setview, 4);
ClientReliableWrite_Entity(host_client, i?i:(host_client - svs.clients + 1)); ClientReliableWrite_Entity(host_client, i?i:(host_client - svs.clients + 1));

View file

@ -308,7 +308,7 @@ void World_ClearWorld_Nodes (world_t *w, qboolean relink)
{ {
for (i=0 ; i<w->num_edicts ; i++) for (i=0 ; i<w->num_edicts ; i++)
{ {
ent = WEDICT_NUM(w->progs, i); ent = WEDICT_NUM_PB(w->progs, i);
if (!ent) if (!ent)
continue; continue;
ent->area.prev = ent->area.next = NULL; ent->area.prev = ent->area.next = NULL;
@ -369,7 +369,7 @@ static void World_ClearWorld_AreaGrid (world_t *w, qboolean relink)
{ {
for (i=0 ; i<w->num_edicts ; i++) for (i=0 ; i<w->num_edicts ; i++)
{ {
ent = WEDICT_NUM(w->progs, i); ent = WEDICT_NUM_PB(w->progs, i);
if (!ent) if (!ent)
continue; continue;
for (j = 0; j < countof(ent->gridareas); j++) for (j = 0; j < countof(ent->gridareas); j++)
@ -1802,7 +1802,7 @@ static void World_ClipToEverything (world_t *w, moveclip_t *clip)
wedict_t *touch; wedict_t *touch;
for (e=1 ; e<w->num_edicts ; e++) for (e=1 ; e<w->num_edicts ; e++)
{ {
touch = (wedict_t*)EDICT_NUM(w->progs, e); touch = (wedict_t*)EDICT_NUM_PB(w->progs, e);
if (ED_ISFREE(touch)) if (ED_ISFREE(touch))
continue; continue;
@ -2414,7 +2414,7 @@ trace_t World_Move (world_t *w, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t e
if (type & MOVE_OTHERONLY) if (type & MOVE_OTHERONLY)
{ {
wedict_t *other = WEDICT_NUM(w->progs, *w->g.other); wedict_t *other = WEDICT_NUM_UB(w->progs, *w->g.other);
return World_ClipMoveToEntity (w, other, other->v->origin, start, mins, maxs, end, hullnum, type & MOVE_HITMODEL, clip.capsule, clip.hitcontentsmask); return World_ClipMoveToEntity (w, other, other->v->origin, start, mins, maxs, end, hullnum, type & MOVE_HITMODEL, clip.capsule, clip.hitcontentsmask);
} }
@ -2502,7 +2502,7 @@ trace_t World_Move (world_t *w, vec3_t start, vec3_t mins, vec3_t maxs, vec3_t e
if (clip.trace.allsolid) if (clip.trace.allsolid)
break; break;
touch = (wedict_t*)EDICT_NUM(w->progs, i+1); touch = (wedict_t*)EDICT_NUM_PB(w->progs, i+1);
if (touch->v->solid == SOLID_NOT) if (touch->v->solid == SOLID_NOT)
continue; continue;
if (touch == clip.passedict) if (touch == clip.passedict)
@ -2647,7 +2647,7 @@ void World_RBE_Shutdown(world_t *world)
{ {
for (u = 0; u < world->num_edicts; u++) for (u = 0; u < world->num_edicts; u++)
{ {
ed = WEDICT_NUM(world->progs, u); ed = WEDICT_NUM_PB(world->progs, u);
world->rbe->RemoveJointFromEntity(world, ed); world->rbe->RemoveJointFromEntity(world, ed);
world->rbe->RemoveFromEntity(world, ed); world->rbe->RemoveFromEntity(world, ed);
} }

View file

@ -287,7 +287,7 @@ static qboolean QDECL S_LoadAVSound (sfx_t *s, qbyte *data, size_t datalen, int
const int iBufSize = 4 * 1024; const int iBufSize = 4 * 1024;
if (!ffmpeg_audiodecoder) if (!ffmpeg_audiodecoder)
ffmpeg_audiodecoder = pCvar_GetNVFDG("ffmpeg_audiodecoder_wip", "0", 0, "Enables the use of ffmpeg's decoder for pure audio files.", "ffmpeg"); return false;
if (!ffmpeg_audiodecoder->value /* && *ffmpeg_audiodecoder.string */) if (!ffmpeg_audiodecoder->value /* && *ffmpeg_audiodecoder.string */)
return false; return false;
@ -358,6 +358,8 @@ static qboolean AVAudio_Init(void)
{ {
if (!pPlug_ExportNative("S_LoadSound", S_LoadAVSound)) if (!pPlug_ExportNative("S_LoadSound", S_LoadAVSound))
{ {
ffmpeg_audiodecoder = pCvar_GetNVFDG("ffmpeg_audiodecoder_wip", "0", 0, "Enables the use of ffmpeg's decoder for pure audio files.", "ffmpeg");
Con_Printf("avplug: Engine doesn't support audio decoder plugins\n"); Con_Printf("avplug: Engine doesn't support audio decoder plugins\n");
return false; return false;
} }

View file

@ -1572,14 +1572,14 @@ static void QDECL World_Bullet_Frame(world_t *world, double frametime, double gr
// copy physics properties from entities to physics engine // copy physics properties from entities to physics engine
for (i = 0;i < world->num_edicts;i++) for (i = 0;i < world->num_edicts;i++)
{ {
ed = (wedict_t*)EDICT_NUM(world->progs, i); ed = (wedict_t*)EDICT_NUM_PB(world->progs, i);
if (!ED_ISFREE(ed)) if (!ED_ISFREE(ed))
World_Bullet_Frame_BodyFromEntity(world, ed); World_Bullet_Frame_BodyFromEntity(world, ed);
} }
// oh, and it must be called after all bodies were created // oh, and it must be called after all bodies were created
for (i = 0;i < world->num_edicts;i++) for (i = 0;i < world->num_edicts;i++)
{ {
ed = (wedict_t*)EDICT_NUM(world->progs, i); ed = (wedict_t*)EDICT_NUM_PB(world->progs, i);
if (!ED_ISFREE(ed)) if (!ED_ISFREE(ed))
World_Bullet_Frame_JointFromEntity(world, ed); World_Bullet_Frame_JointFromEntity(world, ed);
} }
@ -1620,7 +1620,7 @@ static void QDECL World_Bullet_Frame(world_t *world, double frametime, double gr
// copy physics properties from physics engine to entities // copy physics properties from physics engine to entities
for (i = 1;i < world->num_edicts;i++) for (i = 1;i < world->num_edicts;i++)
{ {
ed = (wedict_t*)EDICT_NUM(world->progs, i); ed = (wedict_t*)EDICT_NUM_PB(world->progs, i);
if (!ED_ISFREE(ed)) if (!ED_ISFREE(ed))
World_Bullet_Frame_BodyToEntity(world, ed); World_Bullet_Frame_BodyToEntity(world, ed);
} }