diff --git a/source/cl_parse.c b/source/cl_parse.c index 8dc8d13..0dec621 100644 --- a/source/cl_parse.c +++ b/source/cl_parse.c @@ -614,6 +614,11 @@ void CL_ParseUpdate (int bits) ent->light_lev = MSG_ReadByte(); // NZP END + if (bits & U_SCALE) + ent->scale = MSG_ReadByte(); + else + ent->scale = ENTSCALE_DEFAULT; + //johnfitz -- PROTOCOL_FITZQUAKE and PROTOCOL_NEHAHRA if (cl.protocol == PROTOCOL_FITZQUAKE || cl.protocol == PROTOCOL_RMQ) { @@ -621,8 +626,6 @@ void CL_ParseUpdate (int bits) ent->alpha = MSG_ReadByte(); else ent->alpha = ent->baseline.alpha; - if (bits & U_SCALE) - MSG_ReadByte(); // PROTOCOL_RMQ: currently ignored if (bits & U_FRAME2) ent->frame = (ent->frame & 0x00FF) | (MSG_ReadByte() << 8); if (bits & U_MODEL2) diff --git a/source/gl_rmain.c b/source/gl_rmain.c index 4b6d46d..0fa6700 100644 --- a/source/gl_rmain.c +++ b/source/gl_rmain.c @@ -353,12 +353,17 @@ qboolean R_CullModelForEntity (entity_t *e) R_RotateForEntity -- johnfitz -- modified to take origin and angles instead of pointer to entity =============== */ -void R_RotateForEntity (vec3_t origin, vec3_t angles) +void R_RotateForEntity (vec3_t origin, vec3_t angles, unsigned char scale) { glTranslatef (origin[0], origin[1], origin[2]); glRotatef (angles[1], 0, 0, 1); glRotatef (-angles[0], 0, 1, 0); glRotatef (angles[2], 1, 0, 0); + + if (scale != ENTSCALE_DEFAULT) { + float scalefactor = ENTSCALE_DECODE(scale); + glScalef(scalefactor, scalefactor, scalefactor); + } } /* diff --git a/source/glquake.h b/source/glquake.h index 3a9abfc..66356da 100644 --- a/source/glquake.h +++ b/source/glquake.h @@ -353,7 +353,7 @@ void R_CullSurfaces (void); qboolean R_CullBox (vec3_t emins, vec3_t emaxs); void R_StoreEfrags (efrag_t **ppefrag); qboolean R_CullModelForEntity (entity_t *e); -void R_RotateForEntity (vec3_t origin, vec3_t angles); +void R_RotateForEntity (vec3_t origin, vec3_t angle, unsigned char scale); void R_MarkLights (dlight_t *light, int num, mnode_t *node); void R_InitParticles (void); diff --git a/source/progdefs.q1 b/source/progdefs.q1 index df4ab9f..12ae290 100644 --- a/source/progdefs.q1 +++ b/source/progdefs.q1 @@ -164,6 +164,7 @@ typedef struct float currentmag2; float maxspeed; float facingenemy; + float scale; vec3_t colormod; vec3_t glowmod; float light_lev; diff --git a/source/protocol.h b/source/protocol.h index 47a6d62..fb6333b 100644 --- a/source/protocol.h +++ b/source/protocol.h @@ -142,6 +142,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define ENTALPHA_TOSAVE(a) (((a)==ENTALPHA_DEFAULT)?0.0f:(((a)==ENTALPHA_ZERO)?-1.0f:((float)(a)-1)/(254))) //server convert to float for savegame //johnfitz +#define ENTSCALE_DEFAULT 16 // Equivalent to float 1.0f due to byte packing. +#define ENTSCALE_ENCODE(a) ((a) ? ((a) * ENTSCALE_DEFAULT) : ENTSCALE_DEFAULT) // Convert to byte +#define ENTSCALE_DECODE(a) ((float)(a) / ENTSCALE_DEFAULT) // Convert to float for rendering + + // defaults for clientinfo messages #define DEFAULT_VIEWHEIGHT 32 diff --git a/source/r_alias.c b/source/r_alias.c index 1d68904..d95a7a7 100644 --- a/source/r_alias.c +++ b/source/r_alias.c @@ -883,7 +883,7 @@ void R_DrawTransparentAliasModel (entity_t *e) // transform it // glPushMatrix (); - R_RotateForEntity (lerpdata.origin, lerpdata.angles); + R_RotateForEntity (lerpdata.origin, lerpdata.angles, e->scale); glTranslatef (paliashdr->scale_origin[0], paliashdr->scale_origin[1], paliashdr->scale_origin[2]); glScalef (paliashdr->scale[0], paliashdr->scale[1], paliashdr->scale[2]); @@ -985,7 +985,7 @@ void R_DrawZombieLimb (entity_t *e,int which) glPushMatrix (); - R_RotateForEntity (lerpdata.origin, lerpdata.angles); + R_RotateForEntity (lerpdata.origin, lerpdata.angles, e->scale); paliashdr = (aliashdr_t *)Mod_Extradata (e->model); rs_aliaspolys += paliashdr->numtris; @@ -1080,7 +1080,7 @@ void R_DrawAliasModel (entity_t *e) // transform it // glPushMatrix (); - R_RotateForEntity (lerpdata.origin, lerpdata.angles); + R_RotateForEntity (lerpdata.origin, lerpdata.angles, ENTSCALE_DEFAULT); /* //sB needs fixing in Quakespasm but fuck GL bro //specChar = clmodel->name[strlen(clmodel->name) - 5]; if(doZHack && specChar == '#') @@ -1113,11 +1113,14 @@ void R_DrawAliasModel (entity_t *e) // Special handling of view model to keep FOV from altering look. Pretty good. Not perfect but rather close. if ((e == &cl.viewent || e == &cl.viewent2) && scr_fov_viewmodel.value) { float scale = 1.0f / tan (DEG2RAD (scr_fov.value / 2.0f)) * scr_fov_viewmodel.value / 90.0f; + if (e->scale != ENTSCALE_DEFAULT && e->scale != 0) scale *= ENTSCALE_DECODE(e->scale); glTranslatef (paliashdr->scale_origin[0] * scale, paliashdr->scale_origin[1], paliashdr->scale_origin[2]); glScalef (paliashdr->scale[0] * scale, paliashdr->scale[1], paliashdr->scale[2]); } else { - glTranslatef (paliashdr->scale_origin[0], paliashdr->scale_origin[1], paliashdr->scale_origin[2]); - glScalef (paliashdr->scale[0], paliashdr->scale[1], paliashdr->scale[2]); + float scale = 1.0f; + if (e->scale != ENTSCALE_DEFAULT && e->scale != 0) scale *= ENTSCALE_DECODE(e->scale); + glTranslatef (paliashdr->scale_origin[0] * scale, paliashdr->scale_origin[1] * scale, paliashdr->scale_origin[2] * scale); + glScalef (paliashdr->scale[0] * scale, paliashdr->scale[1] * scale, paliashdr->scale[2] * scale); } // @@ -1454,7 +1457,7 @@ void R_DrawAliasModel_ShowTris (entity_t *e) R_SetupEntityTransform (e, &lerpdata); glPushMatrix (); - R_RotateForEntity (lerpdata.origin,lerpdata.angles); + R_RotateForEntity (lerpdata.origin,lerpdata.angles, e->scale); glTranslatef (paliashdr->scale_origin[0], paliashdr->scale_origin[1], paliashdr->scale_origin[2]); glScalef (paliashdr->scale[0], paliashdr->scale[1], paliashdr->scale[2]); diff --git a/source/r_brush.c b/source/r_brush.c index d2a9b83..de60488 100644 --- a/source/r_brush.c +++ b/source/r_brush.c @@ -608,7 +608,7 @@ void R_DrawBrushModel (entity_t *e) e->origin[1] -= DIST_EPSILON; e->origin[2] -= DIST_EPSILON; } - R_RotateForEntity (e->origin, e->angles); + R_RotateForEntity (e->origin, e->angles, e->scale); if (gl_zfix.value) { e->origin[0] += DIST_EPSILON; @@ -673,7 +673,7 @@ void R_DrawBrushModel_ShowTris (entity_t *e) glPushMatrix (); e->angles[0] = -e->angles[0]; // stupid quake bug - R_RotateForEntity (e->origin, e->angles); + R_RotateForEntity (e->origin, e->angles, e->scale); e->angles[0] = -e->angles[0]; // stupid quake bug // diff --git a/source/r_sprite.c b/source/r_sprite.c index 8c9c6c2..8821ef7 100644 --- a/source/r_sprite.c +++ b/source/r_sprite.c @@ -86,6 +86,8 @@ void R_DrawSpriteModel (entity_t *e) mspriteframe_t *frame; float *s_up, *s_right; float angle, sr, cr; + float scale = ENTSCALE_DECODE(e->scale); + if (scale == 0) scale = 1.0f; //TODO: frustum cull it? @@ -156,23 +158,23 @@ void R_DrawSpriteModel (entity_t *e) glBegin (GL_TRIANGLE_FAN); //was GL_QUADS, but changed to support r_showtris glTexCoord2f (0, frame->tmax); - VectorMA (e->origin, frame->down, s_up, point); - VectorMA (point, frame->left, s_right, point); + VectorMA (e->origin, frame->down * scale, s_up, point); + VectorMA (point, frame->left * scale, s_right, point); glVertex3fv (point); glTexCoord2f (0, 0); - VectorMA (e->origin, frame->up, s_up, point); - VectorMA (point, frame->left, s_right, point); + VectorMA (e->origin, frame->up * scale, s_up, point); + VectorMA (point, frame->left * scale, s_right, point); glVertex3fv (point); glTexCoord2f (frame->smax, 0); - VectorMA (e->origin, frame->up, s_up, point); - VectorMA (point, frame->right, s_right, point); + VectorMA (e->origin, frame->up * scale, s_up, point); + VectorMA (point, frame->right * scale, s_right, point); glVertex3fv (point); glTexCoord2f (frame->smax, frame->tmax); - VectorMA (e->origin, frame->down, s_up, point); - VectorMA (point, frame->right, s_right, point); + VectorMA (e->origin, frame->down * scale, s_up, point); + VectorMA (point, frame->right * scale, s_right, point); glVertex3fv (point); glEnd (); diff --git a/source/render.h b/source/render.h index 591e57f..286bb87 100644 --- a/source/render.h +++ b/source/render.h @@ -73,6 +73,8 @@ typedef struct entity_s int dlightbits; float light_lev; + unsigned char scale; + // FIXME: could turn these into a union int trivial_accept; struct mnode_s *topnode; // for bmodels, first world node diff --git a/source/sv_main.c b/source/sv_main.c index 3b4d502..e4b2775 100644 --- a/source/sv_main.c +++ b/source/sv_main.c @@ -654,6 +654,9 @@ void SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg) if (ent->baseline.light_lev != ent->v.light_lev) bits |= U_LIGHTLEVEL; + if (ent->v.scale != ENTSCALE_DEFAULT && ent->v.scale != 0) + bits |= U_SCALE; + //johnfitz -- alpha if (pr_alpha_supported) { @@ -736,6 +739,9 @@ void SV_WriteEntitiesToClient (edict_t *clent, sizebuf_t *msg) MSG_WriteByte(msg, ent->v.light_lev); // NZP END + if (bits & U_SCALE) + MSG_WriteByte(msg, ENTSCALE_ENCODE(ent->v.scale)); + //johnfitz -- PROTOCOL_FITZQUAKE if (bits & U_ALPHA) MSG_WriteByte(msg, ent->alpha);