Skip to content

Commit

Permalink
Lei24 (#343)
Browse files Browse the repository at this point in the history
- captureLimit should not end non-capturing games anymore
- additional surfaceflags for different surface types such as snow, wood, sand, gravel, foilage, ice, and glass
- improve hexcolors in the ui, allow for on-demand refresh of ui colors, add more hexcolors
- increase some limits of elements in the ui
- suppress excess ui warnings into developer
- sergei/kyonshi do not exist in OA3; default to sarge for missionpack currently (avoids crashes)
- don't attempt to load from characters/
- changing one model also changes teammodel
- add preliminary support for entity glow functionality and alternate shells for them (requires renderer engine changes to support). the primary idea behind alternate shell is performance and to avoid overdraw by force altering the model's vertex colors instead (overriding lighting and any other rgbGen op)
- add preliminary support for drawing player names above teammate heads (requires client engine changes to support)
- cg_hitSound camel-cased and defaults to 1 (again)
- reducing clown cruft by dropping the reference from the teamnames and just going for red/blue for now
- removed cg_leiChibi (again)
- bloodExplosion starts the shader (ancient bug/oversight)
- reverted superfluous cruft
  • Loading branch information
leilei- authored May 14, 2024
1 parent 2419368 commit d371ff1
Show file tree
Hide file tree
Showing 62 changed files with 1,254 additions and 1,267 deletions.
7 changes: 5 additions & 2 deletions code/cgame/cg_consolecmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,7 @@ static void CG_DenyOrder_f(void) {
}

static void CG_TaskOffense_f(void) {
if (CG_UsesTeamFlags(cgs.gametype)) {
if (cgs.gametype == GT_CTF || cgs.gametype == GT_CTF_ELIMINATION || cgs.gametype == GT_1FCTF) {
trap_SendConsoleCommand(va("cmd vsay_team %s\n", VOICECHAT_ONGETFLAG));
} else {
trap_SendConsoleCommand(va("cmd vsay_team %s\n", VOICECHAT_ONOFFENSE));
Expand Down Expand Up @@ -508,7 +508,10 @@ CG_StartOrbit_f
*/

static void CG_StartOrbit_f(void) {
if (!cg_developer.integer) {
char var[MAX_TOKEN_CHARS];

trap_Cvar_VariableStringBuffer("developer", var, sizeof ( var));
if (!atoi(var)) {
return;
}
if (cg_cameraOrbit.value != 0) {
Expand Down
140 changes: 120 additions & 20 deletions code/cgame/cg_draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,14 @@ void CG_Text_PaintChar(float x, float y, float width, float height, float scale,
trap_R_DrawStretchPic(x, y, w, h, s, t, s2, t2, hShader);
}


void CG_Text_PaintCharNoAdjust(float x, float y, float width, float height, float scale, float s, float t, float s2, float t2, qhandle_t hShader) {
float w, h;
w = width * scale;
h = height * scale;
trap_R_DrawStretchPic(x, y, w, h, s, t, s2, t2, hShader);
}

void CG_Text_Paint(float x, float y, float scale, vec4_t color, const char *text, float adjust, int limit, int style) {
int len, count;
vec4_t newColor;
Expand Down Expand Up @@ -191,6 +199,75 @@ void CG_Text_Paint(float x, float y, float scale, vec4_t color, const char *text
}



void CG_Text_Paint_3D(float x, float y, float scale, vec4_t color, const char *text, float adjust, int limit, int style) {
int len, count;
vec4_t newColor;
glyphInfo_t *glyph;
float useScale;
fontInfo_t *font = &cgDC.Assets.textFont;
if (scale <= cg_smallFont.value) {
font = &cgDC.Assets.smallFont;
} else if (scale > cg_bigFont.value) {
font = &cgDC.Assets.bigFont;
}
useScale = scale * font->glyphScale;
if (text) {
const char *s = text;
trap_R_SetColor(color);
memcpy(&newColor[0], &color[0], sizeof (vec4_t));
len = strlen(text);
if (limit > 0 && len > limit) {
len = limit;
}
count = 0;
while (s && *s && count < len) {
glyph = &font->glyphs[*s & 255];
if (Q_IsColorString(s)) {
memcpy(newColor, g_color_table[ColorIndex(*(s + 1))], sizeof ( newColor));
newColor[3] = color[3];
trap_R_SetColor(newColor);
s += 2;
continue;
} else {
float yadj = useScale * glyph->top;
if (style == ITEM_TEXTSTYLE_SHADOWED || style == ITEM_TEXTSTYLE_SHADOWEDMORE) {
int ofs = style == ITEM_TEXTSTYLE_SHADOWED ? 1 : 2;
colorBlack[3] = newColor[3];
trap_R_SetColor(colorBlack);
CG_Text_PaintCharNoAdjust(x + ofs, y - yadj + ofs,
glyph->imageWidth,
glyph->imageHeight,
useScale,
glyph->s,
glyph->t,
glyph->s2,
glyph->t2,
glyph->glyph);
colorBlack[3] = 1.0;
trap_R_SetColor(newColor);
}
CG_Text_PaintCharNoAdjust(x, y - yadj,
glyph->imageWidth,
glyph->imageHeight,
useScale,
glyph->s,
glyph->t,
glyph->s2,
glyph->t2,
glyph->glyph);
// CG_DrawPic(x, y - yadj, scale * cgDC.Assets.textFont.glyphs[text[i]].imageWidth, scale * cgDC.Assets.textFont.glyphs[text[i]].imageHeight, cgDC.Assets.textFont.glyphs[text[i]].glyph);
x += (glyph->xSkip * useScale) + adjust;
s++;
count++;
}
}
trap_R_SetColor(NULL);
}
}



#endif

/*
Expand Down Expand Up @@ -1184,9 +1261,6 @@ static float CG_DrawCountdownTimer(float y) {
//msec = cg.time - cgs.levelStartTime;
if (cg.time > rst) //We are started
{
if (cgs.gametype == GT_DOUBLE_D) {
return y;
}
msec = cgs.roundtime * 1000 - (cg.time - rst);
if (msec <= 30 * 1000 - 1) //<= 30 seconds
memcpy(color, g_color_table[ColorIndex(COLOR_YELLOW)], sizeof (color));
Expand Down Expand Up @@ -1449,7 +1523,7 @@ static float CG_DrawFollowMessage(float y) {
char *s;
int w;

if (!(cg.snap->ps.pm_flags & PMF_FOLLOW) || ((cgs.elimflags & EF_NO_FREESPEC) && CG_IsARoundBasedGametype(cgs.gametype) && CG_IsATeamGametype(cgs.gametype))) {
if (!(cg.snap->ps.pm_flags & PMF_FOLLOW) || ((cgs.elimflags & EF_NO_FREESPEC) && (cgs.gametype == GT_ELIMINATION || cgs.gametype == GT_CTF_ELIMINATION))) {
return y;
}

Expand Down Expand Up @@ -1588,7 +1662,7 @@ static void CG_DrawUpperRight(stereoFrame_t stereoFrame) {

y = 0;

if (CG_IsATeamGametype(cgs.gametype) && cg_drawTeamOverlay.integer == 1) {
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1 && cg_drawTeamOverlay.integer == 1) {
y = CG_DrawTeamOverlay(y, qtrue, qtrue);
}
/*if ( cgs.gametype == GT_DOUBLE_D ) {
Expand All @@ -1613,7 +1687,7 @@ static void CG_DrawUpperRight(stereoFrame_t stereoFrame) {
if (cg_drawFPS.integer && (stereoFrame == STEREO_CENTER || stereoFrame == STEREO_RIGHT)) {
y = CG_DrawFPS(y);
}
if (CG_IsARoundBasedGametype(cgs.gametype) || cgs.gametype == GT_DOUBLE_D) {
if (cgs.gametype == GT_ELIMINATION || cgs.gametype == GT_CTF_ELIMINATION || cgs.gametype == GT_LMS) {
y = CG_DrawCountdownTimer(y);
/*if (cgs.clientinfo[ cg.clientNum ].isDead)
y = CG_DrawEliminationDeathMessage( y);*/
Expand Down Expand Up @@ -1671,7 +1745,7 @@ static float CG_DrawScores(float y) {
y1 = y;

// draw from the right side to left
if (CG_IsATeamGametype(cgs.gametype)) {
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1) {
x = 640;
color[0] = 0.0f;
color[1] = 0.0f;
Expand All @@ -1686,7 +1760,7 @@ static float CG_DrawScores(float y) {
}
CG_DrawBigString(x + 4, y, s, 1.0F);

if (CG_UsesTeamFlags(cgs.gametype) && !CG_UsesTheWhiteFlag(cgs.gametype)) {
if (cgs.gametype == GT_CTF || cgs.gametype == GT_CTF_ELIMINATION) {
// Display flag status
item = BG_FindItemForPowerup(PW_BLUEFLAG);

Expand Down Expand Up @@ -1720,7 +1794,7 @@ static float CG_DrawScores(float y) {
}
CG_DrawBigString(x + 4, y, s, 1.0F);

if (CG_UsesTeamFlags(cgs.gametype) && !CG_UsesTheWhiteFlag(cgs.gametype)) {
if (cgs.gametype == GT_CTF || cgs.gametype == GT_CTF_ELIMINATION) {
// Display flag status
item = BG_FindItemForPowerup(PW_REDFLAG);

Expand Down Expand Up @@ -1756,7 +1830,9 @@ static float CG_DrawScores(float y) {
CG_DrawSmallString(x, y - 28, s, 1.0F);
}

if (CG_IsATeamGametype(cgs.gametype) && cgs.gametype != GT_TEAM) {


if (cgs.gametype >= GT_CTF && cgs.ffa_gt == 0) {
v = cgs.capturelimit;
} else {
v = cgs.fraglimit;
Expand Down Expand Up @@ -1959,7 +2035,7 @@ static void CG_DrawLowerRight(void) {

y = 472 - ICON_SIZE;

if (CG_IsATeamGametype(cgs.gametype) && cg_drawTeamOverlay.integer == 2) {
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1 && cg_drawTeamOverlay.integer == 2) {
y = CG_DrawTeamOverlay(y, qtrue, qfalse);
}

Expand Down Expand Up @@ -2014,7 +2090,7 @@ static void CG_DrawLowerLeft(void) {

y = 480 - ICON_SIZE;

if (CG_IsATeamGametype(cgs.gametype) && cg_drawTeamOverlay.integer == 3) {
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1 && cg_drawTeamOverlay.integer == 3) {
y = CG_DrawTeamOverlay(y, qfalse, qfalse);
}

Expand Down Expand Up @@ -2987,7 +3063,7 @@ static void CG_DrawSpectator(void) {
CG_DrawBigString(320 - 9 * 8, 440, "SPECTATOR", 1.0F);
if (cgs.gametype == GT_TOURNAMENT) {
CG_DrawBigString(320 - 15 * 8, 460, "waiting to play", 1.0F);
} else if (CG_IsATeamGametype(cgs.gametype)) {
} else if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1) {
CG_DrawBigString(320 - 39 * 8, 460, "press ESC and use the JOIN menu to play", 1.0F);
}
}
Expand Down Expand Up @@ -3102,7 +3178,7 @@ static qboolean CG_DrawScoreboard(void) {


if (menuScoreboard == NULL) {
if (CG_IsATeamGametype(cgs.gametype)) {
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1) {
menuScoreboard = Menus_FindByName("teamscore_menu");
} else {
menuScoreboard = Menus_FindByName("score_menu");
Expand All @@ -3126,7 +3202,7 @@ static qboolean CG_DrawScoreboard(void) {
#else
char *s;
int w;
if (cg.respawnTime && cg.snap->ps.persistant[PERS_TEAM] != TEAM_SPECTATOR && (!CG_IsARoundBasedGametype(cgs.gametype))) {
if (cg.respawnTime && cg.snap->ps.persistant[PERS_TEAM] != TEAM_SPECTATOR && (cgs.gametype < GT_ELIMINATION || cgs.gametype > GT_LMS)) {
if (cg.respawnTime > cg.time) {
s = va("Respawn in: %2.2f", ((double) cg.respawnTime - (double) cg.time) / 1000.0);
w = CG_DrawStrlen(s) * SMALLCHAR_WIDTH;
Expand Down Expand Up @@ -3474,6 +3550,8 @@ void CG_DrawTimedMenus(void) {
CG_Draw2D
=================
*/
void CG_PlayerSpritesOverWorld(centity_t *cent);

static void CG_Draw2D(stereoFrame_t stereoFrame) {
#ifdef MISSIONPACK
if (cgs.orderPending && cg.time > cgs.orderTime) {
Expand Down Expand Up @@ -3534,18 +3612,38 @@ static void CG_Draw2D(stereoFrame_t stereoFrame) {

CG_DrawReward();
}
}

if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1) {
#ifndef MISSIONPACK
if (CG_IsATeamGametype(cgs.gametype)) {
CG_DrawTeamInfo();
}
CG_DrawTeamInfo();
#endif
}
}

CG_DrawVote();
CG_DrawTeamVote();

CG_DrawLagometer();

// leilei - draw the player's names
#ifdef MISSIONPACK
{
int f;
centity_t *cent;
vec3_t angles;
vec3_t origin;



for (f=0;f<MAX_CLIENTS;f++){
cent = &cg.headent[f];
if (cent);
CG_PlayerSpritesOverWorld(cent);
}

}
#endif

#ifdef MISSIONPACK
if (!cg_paused.integer) {
CG_DrawUpperRight(stereoFrame);
Expand All @@ -3571,11 +3669,13 @@ static void CG_Draw2D(stereoFrame_t stereoFrame) {
CG_DrawCenterDDString();
CG_DrawCenter1FctfString();
CG_DrawCenterString();
}

cg.accBoardShowing = CG_DrawAccboard();
}


}

/*
=====================
CG_DrawActive
Expand Down
1 change: 1 addition & 0 deletions code/cgame/cg_effects.c
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ void CG_Bleed( vec3_t origin, int entityNum ) {
ex->refEntity.rotation = rand() % 360;
ex->refEntity.radius = 24;

ex->refEntity.shaderTime = ex->startTime / 1000.0f; // leilei- fix the blood animation
ex->refEntity.customShader = cgs.media.bloodExplosionShader;

// don't show player's own blood in view
Expand Down
5 changes: 4 additions & 1 deletion code/cgame/cg_ents.c
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,10 @@ static void CG_TeamBase( centity_t *cent ) {
int t, h;
float c;

if ( CG_UsesTeamFlags(cgs.gametype) ) {
if ( cgs.gametype == GT_CTF || cgs.gametype == GT_1FCTF ) {
//#else
// if ( cgs.gametype == GT_CTF) {
//#endif
// show the flag base
memset(&model, 0, sizeof(model));
model.reType = RT_MODEL;
Expand Down
53 changes: 50 additions & 3 deletions code/cgame/cg_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,7 @@ static void CG_Obituary(entityState_t *ent) {
if (attacker == cg.snap->ps.clientNum) {
char *s;

if (!CG_IsATeamGametype(cgs.gametype) && !CG_UsesTeamFlags(cgs.gametype) &&
!CG_UsesTheWhiteFlag(cgs.gametype) && !CG_IsARoundBasedGametype(cgs.gametype) &&
cgs.gametype != GT_DOUBLE_D && cgs.gametype != GT_DOMINATION) {
if ( cgs.gametype < GT_TEAM ) {
s = va("You fragged %s\n%s place with %i", targetName,
CG_PlaceString(cg.snap->ps.persistant[PERS_RANK] + 1),
cg.snap->ps.persistant[PERS_SCORE]);
Expand Down Expand Up @@ -732,6 +730,55 @@ void CG_EntityEvent(centity_t *cent, vec3_t position) {
cgs.media.footsteps[ FOOTSTEP_METAL ][rand()&3]);
}
break;
case EV_FOOTSTEP_SNOW:
DEBUGNAME("EV_FOOTSTEP_SNOW");
if (cg_footsteps.integer) {
trap_S_StartSound(NULL, es->number, CHAN_BODY,
cgs.media.footsteps[ FOOTSTEP_SNOW ][rand()&3]);
}
break;
case EV_FOOTSTEP_WOOD:
DEBUGNAME("EV_FOOTSTEP_WOOD");
if (cg_footsteps.integer) {
trap_S_StartSound(NULL, es->number, CHAN_BODY,
cgs.media.footsteps[ FOOTSTEP_WOOD ][rand()&3]);
}
break;
case EV_FOOTSTEP_SAND:
DEBUGNAME("EV_FOOTSTEP_SAND");
if (cg_footsteps.integer) {
trap_S_StartSound(NULL, es->number, CHAN_BODY,
cgs.media.footsteps[ FOOTSTEP_SAND ][rand()&3]);
}
break;
case EV_FOOTSTEP_GRAVEL:
DEBUGNAME("EV_FOOTSTEP_GRAVEL");
if (cg_footsteps.integer) {
trap_S_StartSound(NULL, es->number, CHAN_BODY,
cgs.media.footsteps[ FOOTSTEP_GRAVEL ][rand()&3]);
}
break;
case EV_FOOTSTEP_FOILAGE:
DEBUGNAME("EV_FOOTSTEP_FOILAGE");
if (cg_footsteps.integer) {
trap_S_StartSound(NULL, es->number, CHAN_BODY,
cgs.media.footsteps[ FOOTSTEP_FOILAGE ][rand()&3]);
}
break;
case EV_FOOTSTEP_ICE:
DEBUGNAME("EV_FOOTSTEP_ICE");
if (cg_footsteps.integer) {
trap_S_StartSound(NULL, es->number, CHAN_BODY,
cgs.media.footsteps[ FOOTSTEP_ICE ][rand()&3]);
}
break;
case EV_FOOTSTEP_GLASS:
DEBUGNAME("EV_FOOTSTEP_GLASS");
if (cg_footsteps.integer) {
trap_S_StartSound(NULL, es->number, CHAN_BODY,
cgs.media.footsteps[ FOOTSTEP_GLASS ][rand()&3]);
}
break;
case EV_FOOTSPLASH:
DEBUGNAME("EV_FOOTSPLASH");
if (cg_footsteps.integer) {
Expand Down
Loading

0 comments on commit d371ff1

Please sign in to comment.