Skip to content

Commit

Permalink
Rename CHAR_WIDTH to CONCHAR_WIDTH.
Browse files Browse the repository at this point in the history
Prevents conflict with limits.h when compiling in C23 mode. Also rename
CHAR_HEIGHT.

(cherry picked from commit d07f8c9)
  • Loading branch information
skullernet authored and res2k committed Jan 2, 2025
1 parent 7820c5f commit 2846687
Show file tree
Hide file tree
Showing 14 changed files with 152 additions and 152 deletions.
4 changes: 2 additions & 2 deletions inc/client/client.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "common/net/net.h"
#include "common/utils.h"

#define CHAR_WIDTH 8
#define CHAR_HEIGHT 8
#define CONCHAR_WIDTH 8
#define CONCHAR_HEIGHT 8

// only begin attenuating sound volumes when outside the FULLVOLUME range
#define SOUND_FULLVOLUME 80
Expand Down
10 changes: 5 additions & 5 deletions src/client/cgame.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ static void CG_SCR_SetAltTypeface(bool enabled)
static float CG_SCR_FontLineHeight(int scale)
{
if (!scr.kfont.pic)
return CHAR_HEIGHT * scale;
return CONCHAR_HEIGHT * scale;

return scr.kfont.line_height;
}
Expand All @@ -244,7 +244,7 @@ static cg_vec2_t CG_SCR_MeasureFontString(const char *str, int scale)
int x, y = CG_SCR_FontLineHeight(scale);

if (!scr.kfont.pic)
x = strlen(str) * CHAR_WIDTH * scale;
x = strlen(str) * CONCHAR_WIDTH * scale;
else {
x = 0;

Expand Down Expand Up @@ -277,8 +277,8 @@ static void CG_SCR_DrawFontString(const char *str, int x, int y, int scale, cons
// FIXME: can contain line breaks
if (!scr.kfont.pic) {
while (*str) {
R_DrawStretchChar(draw_x, y, CHAR_WIDTH * scale, CHAR_HEIGHT * scale, draw_flags, *str++, draw_color, scr.font_pic);
draw_x += CHAR_WIDTH * scale;
R_DrawStretchChar(draw_x, y, CONCHAR_WIDTH * scale, CONCHAR_HEIGHT * scale, draw_flags, *str++, draw_color, scr.font_pic);
draw_x += CONCHAR_WIDTH * scale;
}
} else {
while (*str) {
Expand Down Expand Up @@ -328,7 +328,7 @@ static int32_t CG_SCR_DrawBind(int32_t isplit, const char *binding, const char *
else
Q_snprintf(str, sizeof(str), "[%s] %s", key, CG_Localize(purpose, NULL, 0));
CG_SCR_DrawFontString(str, x, y, scale, &rgba_white, false, CENTER);
return CHAR_HEIGHT;
return CONCHAR_HEIGHT;
}

static bool CG_CL_InAutoDemoLoop(void)
Expand Down
34 changes: 17 additions & 17 deletions src/client/cgame_classic.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ with this program; if not, write to the Free Software Foundation, Inc.,
/* Some definitions copied from client.h
* This file is deliberately not included to make sure only functions from
* the cgame_import struct are used */
#define CHAR_WIDTH 8
#define CHAR_HEIGHT 8
#define CONCHAR_WIDTH 8
#define CONCHAR_HEIGHT 8

#define UI_LEFT BIT(0)
#define UI_RIGHT BIT(1)
Expand Down Expand Up @@ -100,7 +100,7 @@ static void CG_DrawString(int x, int y, int flags, size_t maxlen, const char *s,
while (maxlen-- && *s) {
byte c = *s++;
cgix.DrawCharEx(x, y, flags, c, color);
x += CHAR_WIDTH;
x += CONCHAR_WIDTH;
}
}

Expand All @@ -118,9 +118,9 @@ static void CG_DrawStringEx(int x, int y, int flags, size_t maxlen, const char *
}

if ((flags & UI_CENTER) == UI_CENTER) {
x -= len * CHAR_WIDTH / 2;
x -= len * CONCHAR_WIDTH / 2;
} else if (flags & UI_RIGHT) {
x -= len * CHAR_WIDTH;
x -= len * CONCHAR_WIDTH;
}

CG_DrawString(x, y, flags, maxlen, s, color);
Expand Down Expand Up @@ -149,7 +149,7 @@ static void CG_DrawStringMulti(int x, int y, int flags, size_t maxlen, const cha
}
CG_DrawStringEx(x, y, flags, len, s, color);

y += CHAR_HEIGHT;
y += CONCHAR_HEIGHT;
s = p + 1;
}
}
Expand Down Expand Up @@ -340,13 +340,13 @@ static void layout_client(vrect_t hud_vrect, const char **s, const player_state_
time = atoi(token);

HUD_DrawAltString(x + 32, y, cgi.CL_GetClientName(value));
HUD_DrawString(x + 32, y + CHAR_HEIGHT, "Score: ");
HUD_DrawString(x + 32, y + CONCHAR_HEIGHT, "Score: ");
Q_snprintf(buffer, sizeof(buffer), "%i", score);
HUD_DrawAltString(x + 32 + 7 * CHAR_WIDTH, y + CHAR_HEIGHT, buffer);
HUD_DrawAltString(x + 32 + 7 * CONCHAR_WIDTH, y + CONCHAR_HEIGHT, buffer);
Q_snprintf(buffer, sizeof(buffer), "Ping: %i", ping);
HUD_DrawString(x + 32, y + 2 * CHAR_HEIGHT, buffer);
HUD_DrawString(x + 32, y + 2 * CONCHAR_HEIGHT, buffer);
Q_snprintf(buffer, sizeof(buffer), "Time: %i", time);
HUD_DrawString(x + 32, y + 3 * CHAR_HEIGHT, buffer);
HUD_DrawString(x + 32, y + 3 * CONCHAR_HEIGHT, buffer);

DrawPic(x, y, cgi.CL_GetClientPic(value));
}
Expand Down Expand Up @@ -523,7 +523,7 @@ static void SCR_DrawHealthBar(vrect_t hud_vrect, int x, int y, int value)
int bar_width = hud_vrect.width / 3;
float percent = (value - 1) / 254.0f;
int w = bar_width * percent + 0.5f;
int h = CHAR_HEIGHT / 2;
int h = CONCHAR_HEIGHT / 2;

x -= bar_width / 2;
cgi.SCR_DrawColorPic(x, y, w, h, "_white", &rgba_fg);
Expand Down Expand Up @@ -721,8 +721,8 @@ static void SCR_ExecuteLayoutString(vrect_t hud_vrect, const char *s, int32_t pl
}

HUD_DrawCenterString(x + 320 / 2, y, cgi.get_configstring(index));
SCR_DrawHealthBar(hud_vrect, x + 320 / 2, y + CHAR_HEIGHT + 4, value & 0xff);
SCR_DrawHealthBar(hud_vrect, x + 320 / 2, y + CHAR_HEIGHT + 12, (value >> 8) & 0xff);
SCR_DrawHealthBar(hud_vrect, x + 320 / 2, y + CONCHAR_HEIGHT + 4, value & 0xff);
SCR_DrawHealthBar(hud_vrect, x + 320 / 2, y + CONCHAR_HEIGHT + 12, (value >> 8) & 0xff);
continue;
}
}
Expand Down Expand Up @@ -802,10 +802,10 @@ static void SCR_DrawInventory(vrect_t hud_vrect, const cg_server_data_t *data, c
x += 24;

HUD_DrawString(x, y, "hotkey ### item");
y += CHAR_HEIGHT;
y += CONCHAR_HEIGHT;

HUD_DrawString(x, y, "------ --- ----");
y += CHAR_HEIGHT;
y += CONCHAR_HEIGHT;

for (i = top; i < num && i < top + DISPLAY_ITEMS; i++) {
item = index[i];
Expand All @@ -822,11 +822,11 @@ static void SCR_DrawInventory(vrect_t hud_vrect, const cg_server_data_t *data, c
} else { // draw a blinky cursor by the selected item
HUD_DrawString(x, y, string);
if ((cgi.CL_ClientRealTime() >> 8) & 1) {
cgi.SCR_DrawChar(x - CHAR_WIDTH, y, 1, 15, false);
cgi.SCR_DrawChar(x - CONCHAR_WIDTH, y, 1, 15, false);
}
}

y += CHAR_HEIGHT;
y += CONCHAR_HEIGHT;
}
}

Expand Down
48 changes: 24 additions & 24 deletions src/client/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ void Con_CheckResize(void)
con.vidWidth = Q_rint(r_config.width * con.scale);
con.vidHeight = Q_rint(r_config.height * con.scale);

con.linewidth = Q_clip(con.vidWidth / CHAR_WIDTH - 2, 0, CON_LINEWIDTH);
con.linewidth = Q_clip(con.vidWidth / CONCHAR_WIDTH - 2, 0, CON_LINEWIDTH);
con.prompt.inputLine.visibleChars = con.linewidth;
con.prompt.widthInChars = con.linewidth;
con.chatPrompt.inputLine.visibleChars = con.linewidth;
Expand Down Expand Up @@ -693,7 +693,7 @@ static int Con_DrawLine(int v, int row, float alpha, bool notify)
const consoleLine_t *line = &con.text[row & CON_TOTALLINES_MASK];
const char *s = line->text;
int flags = 0;
int x = CHAR_WIDTH;
int x = CONCHAR_WIDTH;
int w = con.linewidth;
color_t color;

Expand Down Expand Up @@ -724,7 +724,7 @@ static int Con_DrawLine(int v, int row, float alpha, bool notify)
return R_DrawString(x, v, flags, w, s, color, con.charsetImage);
}

#define CON_PRESTEP (CHAR_HEIGHT * 3 + CHAR_HEIGHT / 4)
#define CON_PRESTEP (CONCHAR_HEIGHT * 3 + CONCHAR_HEIGHT / 4)

/*
================
Expand Down Expand Up @@ -775,7 +775,7 @@ static void Con_DrawNotify(void)

Con_DrawLine(v, i, alpha, true);

v += CHAR_HEIGHT;
v += CONCHAR_HEIGHT;
}

if (cls.key_dest & KEY_MESSAGE) {
Expand All @@ -787,10 +787,10 @@ static void Con_DrawNotify(void)
skip = 5;
}

R_DrawString(CHAR_WIDTH, v, 0, MAX_STRING_CHARS, text,
R_DrawString(CONCHAR_WIDTH, v, 0, MAX_STRING_CHARS, text,
COLOR_WHITE, con.charsetImage);
con.chatPrompt.inputLine.visibleChars = con.linewidth - skip + 1;
IF_Draw(&con.chatPrompt.inputLine, skip * CHAR_WIDTH, v,
IF_Draw(&con.chatPrompt.inputLine, skip * CONCHAR_WIDTH, v,
UI_DRAWCURSOR, con.charsetImage);
}
}
Expand Down Expand Up @@ -836,15 +836,15 @@ static void Con_DrawSolidConsole(void)

// draw the text
y = vislines - CON_PRESTEP;
rows = y / CHAR_HEIGHT + 1; // rows of text to draw
rows = y / CONCHAR_HEIGHT + 1; // rows of text to draw

// draw arrows to show the buffer is backscrolled
if (con.display != con.current) {
for (i = 1; i < con.linewidth / 2; i += 4) {
R_DrawChar(i * CHAR_WIDTH, y, 0, '^', COLOR_SETA_U8(COLOR_RED, color.a), con.charsetImage);
R_DrawChar(i * CONCHAR_WIDTH, y, 0, '^', COLOR_SETA_U8(COLOR_RED, color.a), con.charsetImage);
}

y -= CHAR_HEIGHT;
y -= CONCHAR_HEIGHT;
rows--;
}

Expand All @@ -862,7 +862,7 @@ static void Con_DrawSolidConsole(void)
widths[i] = x;
}

y -= CHAR_HEIGHT;
y -= CONCHAR_HEIGHT;
row--;
}

Expand Down Expand Up @@ -909,8 +909,8 @@ static void Con_DrawSolidConsole(void)
Q_strlcat(buffer, suf, sizeof(buffer));

// draw it
y = vislines - CON_PRESTEP + CHAR_HEIGHT * 2;
R_DrawString(CHAR_WIDTH, y, 0, con.linewidth, buffer, COLOR_WHITE, con.charsetImage);
y = vislines - CON_PRESTEP + CONCHAR_HEIGHT * 2;
R_DrawString(CONCHAR_WIDTH, y, 0, con.linewidth, buffer, COLOR_WHITE, con.charsetImage);
} else if (cls.state == ca_loading) {
// draw loading state
switch (con.loadstate) {
Expand Down Expand Up @@ -938,48 +938,48 @@ static void Con_DrawSolidConsole(void)
Q_snprintf(buffer, sizeof(buffer), "Loading %s...", text);

// draw it
y = vislines - CON_PRESTEP + CHAR_HEIGHT * 2;
R_DrawString(CHAR_WIDTH, y, 0, con.linewidth, buffer, COLOR_WHITE, con.charsetImage);
y = vislines - CON_PRESTEP + CONCHAR_HEIGHT * 2;
R_DrawString(CONCHAR_WIDTH, y, 0, con.linewidth, buffer, COLOR_WHITE, con.charsetImage);
}
}

// draw the input prompt, user text, and cursor if desired
x = 0;
if (cls.key_dest & KEY_CONSOLE) {
y = vislines - CON_PRESTEP + CHAR_HEIGHT;
y = vislines - CON_PRESTEP + CONCHAR_HEIGHT;

// draw command prompt
i = con.mode == CON_REMOTE ? '#' : 17;
R_DrawChar(CHAR_WIDTH, y, 0, i, COLOR_YELLOW, con.charsetImage);
R_DrawChar(CONCHAR_WIDTH, y, 0, i, COLOR_YELLOW, con.charsetImage);

// draw input line
x = IF_Draw(&con.prompt.inputLine, 2 * CHAR_WIDTH, y,
x = IF_Draw(&con.prompt.inputLine, 2 * CONCHAR_WIDTH, y,
UI_DRAWCURSOR, con.charsetImage);
}

#define APP_VERSION APPLICATION " " VERSION
#define VER_WIDTH ((int)(sizeof(APP_VERSION) + 1) * CHAR_WIDTH)
#define VER_WIDTH ((int)(sizeof(APP_VERSION) + 1) * CONCHAR_WIDTH)

y = vislines - CON_PRESTEP + CHAR_HEIGHT;
y = vislines - CON_PRESTEP + CONCHAR_HEIGHT;
row = 0;
// shift version upwards to prevent overdraw
if (x > con.vidWidth - VER_WIDTH) {
y -= CHAR_HEIGHT;
y -= CONCHAR_HEIGHT;
row++;
}

// draw clock
if (con_clock->integer) {
x = Com_Time_m(buffer, sizeof(buffer)) * CHAR_WIDTH;
if (widths[row] + x + CHAR_WIDTH <= con.vidWidth) {
R_DrawString(con.vidWidth - CHAR_WIDTH - x, y - CHAR_HEIGHT,
x = Com_Time_m(buffer, sizeof(buffer)) * CONCHAR_WIDTH;
if (widths[row] + x + CONCHAR_WIDTH <= con.vidWidth) {
R_DrawString(con.vidWidth - CONCHAR_WIDTH - x, y - CONCHAR_HEIGHT,
UI_RIGHT, MAX_STRING_CHARS, buffer, COLOR_CYAN, con.charsetImage);
}
}

// draw version
if (!row || widths[0] + VER_WIDTH <= con.vidWidth) {
SCR_DrawStringEx(con.vidWidth - CHAR_WIDTH, y, UI_RIGHT,
SCR_DrawStringEx(con.vidWidth - CONCHAR_WIDTH, y, UI_RIGHT,
MAX_STRING_CHARS, APP_VERSION, COLOR_CYAN, con.charsetImage);
}
}
Expand Down
Loading

0 comments on commit 2846687

Please sign in to comment.