Skip to content

Commit d371ff1

Browse files
authored
Lei24 (#343)
- 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
1 parent 2419368 commit d371ff1

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1254
-1267
lines changed

code/cgame/cg_consolecmds.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ static void CG_DenyOrder_f(void) {
393393
}
394394

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

510510
static void CG_StartOrbit_f(void) {
511-
if (!cg_developer.integer) {
511+
char var[MAX_TOKEN_CHARS];
512+
513+
trap_Cvar_VariableStringBuffer("developer", var, sizeof ( var));
514+
if (!atoi(var)) {
512515
return;
513516
}
514517
if (cg_cameraOrbit.value != 0) {

code/cgame/cg_draw.c

Lines changed: 120 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,14 @@ void CG_Text_PaintChar(float x, float y, float width, float height, float scale,
124124
trap_R_DrawStretchPic(x, y, w, h, s, t, s2, t2, hShader);
125125
}
126126

127+
128+
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) {
129+
float w, h;
130+
w = width * scale;
131+
h = height * scale;
132+
trap_R_DrawStretchPic(x, y, w, h, s, t, s2, t2, hShader);
133+
}
134+
127135
void CG_Text_Paint(float x, float y, float scale, vec4_t color, const char *text, float adjust, int limit, int style) {
128136
int len, count;
129137
vec4_t newColor;
@@ -191,6 +199,75 @@ void CG_Text_Paint(float x, float y, float scale, vec4_t color, const char *text
191199
}
192200

193201

202+
203+
void CG_Text_Paint_3D(float x, float y, float scale, vec4_t color, const char *text, float adjust, int limit, int style) {
204+
int len, count;
205+
vec4_t newColor;
206+
glyphInfo_t *glyph;
207+
float useScale;
208+
fontInfo_t *font = &cgDC.Assets.textFont;
209+
if (scale <= cg_smallFont.value) {
210+
font = &cgDC.Assets.smallFont;
211+
} else if (scale > cg_bigFont.value) {
212+
font = &cgDC.Assets.bigFont;
213+
}
214+
useScale = scale * font->glyphScale;
215+
if (text) {
216+
const char *s = text;
217+
trap_R_SetColor(color);
218+
memcpy(&newColor[0], &color[0], sizeof (vec4_t));
219+
len = strlen(text);
220+
if (limit > 0 && len > limit) {
221+
len = limit;
222+
}
223+
count = 0;
224+
while (s && *s && count < len) {
225+
glyph = &font->glyphs[*s & 255];
226+
if (Q_IsColorString(s)) {
227+
memcpy(newColor, g_color_table[ColorIndex(*(s + 1))], sizeof ( newColor));
228+
newColor[3] = color[3];
229+
trap_R_SetColor(newColor);
230+
s += 2;
231+
continue;
232+
} else {
233+
float yadj = useScale * glyph->top;
234+
if (style == ITEM_TEXTSTYLE_SHADOWED || style == ITEM_TEXTSTYLE_SHADOWEDMORE) {
235+
int ofs = style == ITEM_TEXTSTYLE_SHADOWED ? 1 : 2;
236+
colorBlack[3] = newColor[3];
237+
trap_R_SetColor(colorBlack);
238+
CG_Text_PaintCharNoAdjust(x + ofs, y - yadj + ofs,
239+
glyph->imageWidth,
240+
glyph->imageHeight,
241+
useScale,
242+
glyph->s,
243+
glyph->t,
244+
glyph->s2,
245+
glyph->t2,
246+
glyph->glyph);
247+
colorBlack[3] = 1.0;
248+
trap_R_SetColor(newColor);
249+
}
250+
CG_Text_PaintCharNoAdjust(x, y - yadj,
251+
glyph->imageWidth,
252+
glyph->imageHeight,
253+
useScale,
254+
glyph->s,
255+
glyph->t,
256+
glyph->s2,
257+
glyph->t2,
258+
glyph->glyph);
259+
// 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);
260+
x += (glyph->xSkip * useScale) + adjust;
261+
s++;
262+
count++;
263+
}
264+
}
265+
trap_R_SetColor(NULL);
266+
}
267+
}
268+
269+
270+
194271
#endif
195272

196273
/*
@@ -1184,9 +1261,6 @@ static float CG_DrawCountdownTimer(float y) {
11841261
//msec = cg.time - cgs.levelStartTime;
11851262
if (cg.time > rst) //We are started
11861263
{
1187-
if (cgs.gametype == GT_DOUBLE_D) {
1188-
return y;
1189-
}
11901264
msec = cgs.roundtime * 1000 - (cg.time - rst);
11911265
if (msec <= 30 * 1000 - 1) //<= 30 seconds
11921266
memcpy(color, g_color_table[ColorIndex(COLOR_YELLOW)], sizeof (color));
@@ -1449,7 +1523,7 @@ static float CG_DrawFollowMessage(float y) {
14491523
char *s;
14501524
int w;
14511525

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

@@ -1588,7 +1662,7 @@ static void CG_DrawUpperRight(stereoFrame_t stereoFrame) {
15881662

15891663
y = 0;
15901664

1591-
if (CG_IsATeamGametype(cgs.gametype) && cg_drawTeamOverlay.integer == 1) {
1665+
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1 && cg_drawTeamOverlay.integer == 1) {
15921666
y = CG_DrawTeamOverlay(y, qtrue, qtrue);
15931667
}
15941668
/*if ( cgs.gametype == GT_DOUBLE_D ) {
@@ -1613,7 +1687,7 @@ static void CG_DrawUpperRight(stereoFrame_t stereoFrame) {
16131687
if (cg_drawFPS.integer && (stereoFrame == STEREO_CENTER || stereoFrame == STEREO_RIGHT)) {
16141688
y = CG_DrawFPS(y);
16151689
}
1616-
if (CG_IsARoundBasedGametype(cgs.gametype) || cgs.gametype == GT_DOUBLE_D) {
1690+
if (cgs.gametype == GT_ELIMINATION || cgs.gametype == GT_CTF_ELIMINATION || cgs.gametype == GT_LMS) {
16171691
y = CG_DrawCountdownTimer(y);
16181692
/*if (cgs.clientinfo[ cg.clientNum ].isDead)
16191693
y = CG_DrawEliminationDeathMessage( y);*/
@@ -1671,7 +1745,7 @@ static float CG_DrawScores(float y) {
16711745
y1 = y;
16721746

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

1689-
if (CG_UsesTeamFlags(cgs.gametype) && !CG_UsesTheWhiteFlag(cgs.gametype)) {
1763+
if (cgs.gametype == GT_CTF || cgs.gametype == GT_CTF_ELIMINATION) {
16901764
// Display flag status
16911765
item = BG_FindItemForPowerup(PW_BLUEFLAG);
16921766

@@ -1720,7 +1794,7 @@ static float CG_DrawScores(float y) {
17201794
}
17211795
CG_DrawBigString(x + 4, y, s, 1.0F);
17221796

1723-
if (CG_UsesTeamFlags(cgs.gametype) && !CG_UsesTheWhiteFlag(cgs.gametype)) {
1797+
if (cgs.gametype == GT_CTF || cgs.gametype == GT_CTF_ELIMINATION) {
17241798
// Display flag status
17251799
item = BG_FindItemForPowerup(PW_REDFLAG);
17261800

@@ -1756,7 +1830,9 @@ static float CG_DrawScores(float y) {
17561830
CG_DrawSmallString(x, y - 28, s, 1.0F);
17571831
}
17581832

1759-
if (CG_IsATeamGametype(cgs.gametype) && cgs.gametype != GT_TEAM) {
1833+
1834+
1835+
if (cgs.gametype >= GT_CTF && cgs.ffa_gt == 0) {
17601836
v = cgs.capturelimit;
17611837
} else {
17621838
v = cgs.fraglimit;
@@ -1959,7 +2035,7 @@ static void CG_DrawLowerRight(void) {
19592035

19602036
y = 472 - ICON_SIZE;
19612037

1962-
if (CG_IsATeamGametype(cgs.gametype) && cg_drawTeamOverlay.integer == 2) {
2038+
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1 && cg_drawTeamOverlay.integer == 2) {
19632039
y = CG_DrawTeamOverlay(y, qtrue, qfalse);
19642040
}
19652041

@@ -2014,7 +2090,7 @@ static void CG_DrawLowerLeft(void) {
20142090

20152091
y = 480 - ICON_SIZE;
20162092

2017-
if (CG_IsATeamGametype(cgs.gametype) && cg_drawTeamOverlay.integer == 3) {
2093+
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1 && cg_drawTeamOverlay.integer == 3) {
20182094
y = CG_DrawTeamOverlay(y, qfalse, qfalse);
20192095
}
20202096

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

31033179

31043180
if (menuScoreboard == NULL) {
3105-
if (CG_IsATeamGametype(cgs.gametype)) {
3181+
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1) {
31063182
menuScoreboard = Menus_FindByName("teamscore_menu");
31073183
} else {
31083184
menuScoreboard = Menus_FindByName("score_menu");
@@ -3126,7 +3202,7 @@ static qboolean CG_DrawScoreboard(void) {
31263202
#else
31273203
char *s;
31283204
int w;
3129-
if (cg.respawnTime && cg.snap->ps.persistant[PERS_TEAM] != TEAM_SPECTATOR && (!CG_IsARoundBasedGametype(cgs.gametype))) {
3205+
if (cg.respawnTime && cg.snap->ps.persistant[PERS_TEAM] != TEAM_SPECTATOR && (cgs.gametype < GT_ELIMINATION || cgs.gametype > GT_LMS)) {
31303206
if (cg.respawnTime > cg.time) {
31313207
s = va("Respawn in: %2.2f", ((double) cg.respawnTime - (double) cg.time) / 1000.0);
31323208
w = CG_DrawStrlen(s) * SMALLCHAR_WIDTH;
@@ -3474,6 +3550,8 @@ void CG_DrawTimedMenus(void) {
34743550
CG_Draw2D
34753551
=================
34763552
*/
3553+
void CG_PlayerSpritesOverWorld(centity_t *cent);
3554+
34773555
static void CG_Draw2D(stereoFrame_t stereoFrame) {
34783556
#ifdef MISSIONPACK
34793557
if (cgs.orderPending && cg.time > cgs.orderTime) {
@@ -3534,18 +3612,38 @@ static void CG_Draw2D(stereoFrame_t stereoFrame) {
35343612

35353613
CG_DrawReward();
35363614
}
3537-
}
3615+
3616+
if (cgs.gametype >= GT_TEAM && cgs.ffa_gt != 1) {
35383617
#ifndef MISSIONPACK
3539-
if (CG_IsATeamGametype(cgs.gametype)) {
3540-
CG_DrawTeamInfo();
3541-
}
3618+
CG_DrawTeamInfo();
35423619
#endif
3620+
}
3621+
}
35433622

35443623
CG_DrawVote();
35453624
CG_DrawTeamVote();
35463625

35473626
CG_DrawLagometer();
35483627

3628+
// leilei - draw the player's names
3629+
#ifdef MISSIONPACK
3630+
{
3631+
int f;
3632+
centity_t *cent;
3633+
vec3_t angles;
3634+
vec3_t origin;
3635+
3636+
3637+
3638+
for (f=0;f<MAX_CLIENTS;f++){
3639+
cent = &cg.headent[f];
3640+
if (cent);
3641+
CG_PlayerSpritesOverWorld(cent);
3642+
}
3643+
3644+
}
3645+
#endif
3646+
35493647
#ifdef MISSIONPACK
35503648
if (!cg_paused.integer) {
35513649
CG_DrawUpperRight(stereoFrame);
@@ -3571,11 +3669,13 @@ static void CG_Draw2D(stereoFrame_t stereoFrame) {
35713669
CG_DrawCenterDDString();
35723670
CG_DrawCenter1FctfString();
35733671
CG_DrawCenterString();
3574-
}
35753672

35763673
cg.accBoardShowing = CG_DrawAccboard();
35773674
}
35783675

3676+
3677+
}
3678+
35793679
/*
35803680
=====================
35813681
CG_DrawActive

code/cgame/cg_effects.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,7 @@ void CG_Bleed( vec3_t origin, int entityNum ) {
573573
ex->refEntity.rotation = rand() % 360;
574574
ex->refEntity.radius = 24;
575575

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

578579
// don't show player's own blood in view

code/cgame/cg_ents.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -864,7 +864,10 @@ static void CG_TeamBase( centity_t *cent ) {
864864
int t, h;
865865
float c;
866866

867-
if ( CG_UsesTeamFlags(cgs.gametype) ) {
867+
if ( cgs.gametype == GT_CTF || cgs.gametype == GT_1FCTF ) {
868+
//#else
869+
// if ( cgs.gametype == GT_CTF) {
870+
//#endif
868871
// show the flag base
869872
memset(&model, 0, sizeof(model));
870873
model.reType = RT_MODEL;

code/cgame/cg_event.c

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,7 @@ static void CG_Obituary(entityState_t *ent) {
254254
if (attacker == cg.snap->ps.clientNum) {
255255
char *s;
256256

257-
if (!CG_IsATeamGametype(cgs.gametype) && !CG_UsesTeamFlags(cgs.gametype) &&
258-
!CG_UsesTheWhiteFlag(cgs.gametype) && !CG_IsARoundBasedGametype(cgs.gametype) &&
259-
cgs.gametype != GT_DOUBLE_D && cgs.gametype != GT_DOMINATION) {
257+
if ( cgs.gametype < GT_TEAM ) {
260258
s = va("You fragged %s\n%s place with %i", targetName,
261259
CG_PlaceString(cg.snap->ps.persistant[PERS_RANK] + 1),
262260
cg.snap->ps.persistant[PERS_SCORE]);
@@ -732,6 +730,55 @@ void CG_EntityEvent(centity_t *cent, vec3_t position) {
732730
cgs.media.footsteps[ FOOTSTEP_METAL ][rand()&3]);
733731
}
734732
break;
733+
case EV_FOOTSTEP_SNOW:
734+
DEBUGNAME("EV_FOOTSTEP_SNOW");
735+
if (cg_footsteps.integer) {
736+
trap_S_StartSound(NULL, es->number, CHAN_BODY,
737+
cgs.media.footsteps[ FOOTSTEP_SNOW ][rand()&3]);
738+
}
739+
break;
740+
case EV_FOOTSTEP_WOOD:
741+
DEBUGNAME("EV_FOOTSTEP_WOOD");
742+
if (cg_footsteps.integer) {
743+
trap_S_StartSound(NULL, es->number, CHAN_BODY,
744+
cgs.media.footsteps[ FOOTSTEP_WOOD ][rand()&3]);
745+
}
746+
break;
747+
case EV_FOOTSTEP_SAND:
748+
DEBUGNAME("EV_FOOTSTEP_SAND");
749+
if (cg_footsteps.integer) {
750+
trap_S_StartSound(NULL, es->number, CHAN_BODY,
751+
cgs.media.footsteps[ FOOTSTEP_SAND ][rand()&3]);
752+
}
753+
break;
754+
case EV_FOOTSTEP_GRAVEL:
755+
DEBUGNAME("EV_FOOTSTEP_GRAVEL");
756+
if (cg_footsteps.integer) {
757+
trap_S_StartSound(NULL, es->number, CHAN_BODY,
758+
cgs.media.footsteps[ FOOTSTEP_GRAVEL ][rand()&3]);
759+
}
760+
break;
761+
case EV_FOOTSTEP_FOILAGE:
762+
DEBUGNAME("EV_FOOTSTEP_FOILAGE");
763+
if (cg_footsteps.integer) {
764+
trap_S_StartSound(NULL, es->number, CHAN_BODY,
765+
cgs.media.footsteps[ FOOTSTEP_FOILAGE ][rand()&3]);
766+
}
767+
break;
768+
case EV_FOOTSTEP_ICE:
769+
DEBUGNAME("EV_FOOTSTEP_ICE");
770+
if (cg_footsteps.integer) {
771+
trap_S_StartSound(NULL, es->number, CHAN_BODY,
772+
cgs.media.footsteps[ FOOTSTEP_ICE ][rand()&3]);
773+
}
774+
break;
775+
case EV_FOOTSTEP_GLASS:
776+
DEBUGNAME("EV_FOOTSTEP_GLASS");
777+
if (cg_footsteps.integer) {
778+
trap_S_StartSound(NULL, es->number, CHAN_BODY,
779+
cgs.media.footsteps[ FOOTSTEP_GLASS ][rand()&3]);
780+
}
781+
break;
735782
case EV_FOOTSPLASH:
736783
DEBUGNAME("EV_FOOTSPLASH");
737784
if (cg_footsteps.integer) {

0 commit comments

Comments
 (0)