diff --git a/engine/client/cl_parse.c b/engine/client/cl_parse.c index f66618293..84b65158b 100644 --- a/engine/client/cl_parse.c +++ b/engine/client/cl_parse.c @@ -3084,6 +3084,9 @@ char *CL_ParseChat(char *text, player_info_t **player) Validation_CheckIfResponse(text); + if (!Plug_ChatMessage(text + offset, *player ? (int)(*player - cl.players) : -1, flags)) + return NULL; + if (flags == 2 && !TP_FilterMessage(text + offset)) return NULL; @@ -3096,6 +3099,11 @@ char *CL_ParseChat(char *text, player_info_t **player) else if (check_flood == NO_IGNORE_ADD) Ignore_Flood_Add(s); } + else + { + if (!Plug_ServerMessage(text + offset, PRINT_CHAT)) + return NULL; + } suppress_talksound = false; @@ -3163,35 +3171,35 @@ int CL_PlayerColor(player_info_t *plr, int *name_ormask) { //translate q1 skin colours to console colours case 10: case 1: - *name_ormask = CON_STANDARDMASK; + *name_ormask = CON_HIGHCHARSMASK; case 4: //red c = 1; break; case 11: - *name_ormask = CON_STANDARDMASK; + *name_ormask = CON_HIGHCHARSMASK; case 3: // green c = 2; break; case 5: - *name_ormask = CON_STANDARDMASK; + *name_ormask = CON_HIGHCHARSMASK; case 12: c = 3; break; case 6: case 7: - *name_ormask = CON_STANDARDMASK; + *name_ormask = CON_HIGHCHARSMASK; case 8: case 9: c = 5; break; case 2: // light blue - *name_ormask = CON_STANDARDMASK; + *name_ormask = CON_HIGHCHARSMASK; case 13: //blue case 14: //blue c = 6; break; default: - *name_ormask = CON_STANDARDMASK; + *name_ormask = CON_HIGHCHARSMASK; case 0: // white c = 7; break; @@ -3218,7 +3226,7 @@ int CL_PlayerColor(player_info_t *plr, int *name_ormask) } if ((c / 7) & 1) - *name_ormask = CON_STANDARDMASK; + *name_ormask = CON_HIGHCHARSMASK; c = 1 + (c % 7); } @@ -3236,7 +3244,7 @@ int CL_PlayerColor(player_info_t *plr, int *name_ormask) c = plr->userid; // Quake2 can start from 0 if ((c / 7) & 1) - *name_ormask = CON_STANDARDMASK; + *name_ormask = CON_HIGHCHARSMASK; c = 1 + (c % 7); } @@ -3244,7 +3252,7 @@ int CL_PlayerColor(player_info_t *plr, int *name_ormask) return c; } -// CL_ParseChat: takes chat strings and performs name coloring and cl_parsewhitetext parsing +// CL_PrintChat: takes chat strings and performs name coloring and cl_parsewhitetext parsing // NOTE: text in rawmsg/msg is assumed destroyable and should not be used afterwards void CL_PrintChat(player_info_t *plr, char *rawmsg, char *msg, int plrflags) { @@ -3272,7 +3280,7 @@ void CL_PrintChat(player_info_t *plr, char *rawmsg, char *msg, int plrflags) if (cl_standardchat.value) { - name_ormask = CON_STANDARDMASK; + name_ormask = CON_HIGHCHARSMASK; c = 7; } else @@ -3284,7 +3292,7 @@ void CL_PrintChat(player_info_t *plr, char *rawmsg, char *msg, int plrflags) c = 0; // blacken () on observers else { - name_ormask = CON_STANDARDMASK; + name_ormask = CON_HIGHCHARSMASK; c = 7; } } @@ -3293,7 +3301,7 @@ void CL_PrintChat(player_info_t *plr, char *rawmsg, char *msg, int plrflags) else { // defaults for fake clients - name_ormask = CON_STANDARDMASK; + name_ormask = CON_HIGHCHARSMASK; c = 7; } } @@ -3304,7 +3312,7 @@ void CL_PrintChat(player_info_t *plr, char *rawmsg, char *msg, int plrflags) { if (memessage) { - con_ormask = CON_STANDARDMASK; + con_ormask = CON_HIGHCHARSMASK; if (!cl_standardchat.value && (plrflags & TPM_SPECTATOR)) Con_Printf ("^0*^7 "); else @@ -3316,7 +3324,7 @@ void CL_PrintChat(player_info_t *plr, char *rawmsg, char *msg, int plrflags) // color is reset every printf so we're safe here con_ormask = name_ormask; Con_Printf("^%c(", c); - con_ormask = CON_STANDARDMASK; + con_ormask = CON_HIGHCHARSMASK; Con_Printf("%s", name); con_ormask = name_ormask; Con_Printf("^%c)", c); @@ -3330,7 +3338,7 @@ void CL_PrintChat(player_info_t *plr, char *rawmsg, char *msg, int plrflags) if (!memessage) { // only print seperator with an actual player name - con_ormask = CON_STANDARDMASK; + con_ormask = CON_HIGHCHARSMASK; if (!cl_standardchat.value && (plrflags & TPM_SPECTATOR)) Con_Printf ("^0:^7 "); else @@ -3341,7 +3349,7 @@ void CL_PrintChat(player_info_t *plr, char *rawmsg, char *msg, int plrflags) } // print message - con_ormask = CON_STANDARDMASK; + con_ormask = CON_HIGHCHARSMASK; if (cl_parsewhitetext.value && (cl_parsewhitetext.value == 1 || (plrflags & TPM_TEAM))) { char *t, *u; @@ -3356,7 +3364,7 @@ void CL_PrintChat(player_info_t *plr, char *rawmsg, char *msg, int plrflags) Con_Printf("%s", msg); con_ormask = 0; Con_Printf("%s", t+1); - con_ormask = CON_STANDARDMASK; + con_ormask = CON_HIGHCHARSMASK; msg = u+1; } else @@ -3522,7 +3530,6 @@ void CL_ParsePrecache(void) CL_ParseServerMessage ===================== */ -char *Translate(char *message); int received_framecount; void CL_ParseServerMessage (void) { @@ -3612,8 +3619,6 @@ void CL_ParseServerMessage (void) i = MSG_ReadByte (); s = MSG_ReadString (); - // Plug_Message(0, i, s); - if (i == PRINT_CHAT) { char *msg; @@ -3630,13 +3635,19 @@ void CL_ParseServerMessage (void) } else { - CL_ParsePrint(s, i); - CL_PrintStandardMessage(s); + if (Plug_ServerMessage(s, i)) + { + CL_ParsePrint(s, i); + CL_PrintStandardMessage(s); + } } break; case svc_centerprint: - SCR_CenterPrint (destsplit, Translate(MSG_ReadString ())); + s = MSG_ReadString (); + + if (Plug_CenterPrintMessage(s, destsplit)) + SCR_CenterPrint (destsplit, s); break; case svc_stufftext: @@ -4072,8 +4083,6 @@ void CLQ2_ParseServerMessage (void) i = MSG_ReadByte (); s = MSG_ReadString (); - // Plug_Message(0, i, s); - if (i == PRINT_CHAT) { char *msg; @@ -4087,8 +4096,11 @@ void CLQ2_ParseServerMessage (void) } else { - CL_ParsePrint(s, i); - CL_PrintStandardMessage(s); + if (Plug_ServerMessage(s, i)) + { + CL_ParsePrint(s, i); + CL_PrintStandardMessage(s); + } } con_ormask = 0; break; @@ -4113,7 +4125,10 @@ void CLQ2_ParseServerMessage (void) CLQ2_ParseBaseline(); break; case svcq2_centerprint: //15 // [string] to put in center of the screen - SCR_CenterPrint (0, Translate(MSG_ReadString ())); + s = MSG_ReadString(); + + if (Plug_CenterPrintMessage(s, 0)) + SCR_CenterPrint (0, s); break; case svcq2_download: //16 // [short] size [size bytes] CL_ParseDownload(); @@ -4304,9 +4319,6 @@ void CLNQ_ParseServerMessage (void) char *msg; player_info_t *plr = NULL; - // Plug_Message(0, PRINT_CHAT, s); - - if (msg = CL_ParseChat(s+1, &plr)) { CL_ParsePrint(s+1, PRINT_CHAT); @@ -4315,10 +4327,11 @@ void CLNQ_ParseServerMessage (void) } else { - // Plug_Message(0, PRINT_HIGH, s); - - CL_ParsePrint(s, PRINT_HIGH); - CL_PrintStandardMessage(s); + if (Plug_ServerMessage(s, PRINT_HIGH)) + { + CL_ParsePrint(s, PRINT_HIGH); + CL_PrintStandardMessage(s); + } } con_ormask = 0; break; @@ -4328,7 +4341,10 @@ void CLNQ_ParseServerMessage (void) break; case svc_centerprint: - SCR_CenterPrint (0, Translate(MSG_ReadString ())); + s = MSG_ReadString (); + + if (Plug_CenterPrintMessage(s, 0)) + SCR_CenterPrint (0, s); break; case svc_stufftext: diff --git a/engine/client/cl_screen.c b/engine/client/cl_screen.c index bcc82c281..2a4011f8c 100644 --- a/engine/client/cl_screen.c +++ b/engine/client/cl_screen.c @@ -167,17 +167,17 @@ CENTER PRINTING =============================================================================== */ -unsigned short scr_centerstring[MAX_SPLITS][1024]; +conchar_t scr_centerstring[MAX_SPLITS][1024]; float scr_centertime_start[MAX_SPLITS]; // for slow victory printing float scr_centertime_off[MAX_SPLITS]; int scr_center_lines[MAX_SPLITS]; int scr_erase_lines[MAX_SPLITS]; int scr_erase_center[MAX_SPLITS]; -void CopyAndMarkup(unsigned short *dest, qbyte *src, int maxlength) +void CopyAndMarkup(conchar_t *dest, qbyte *src, int maxlength) { - int ext = COLOR_WHITE<<8; - int extstack[20]; + conchar_t ext = CON_WHITEMASK; + conchar_t extstack[20]; int extstackdepth = 0; if (maxlength < 0) @@ -189,33 +189,21 @@ void CopyAndMarkup(unsigned short *dest, qbyte *src, int maxlength) if (*src == '^') { src++; - if (*src >= '0' && *src <= '7') + if (*src >= '0' && *src <= '9') { - ext = (*src++-'0')*256 | (ext&~CON_COLOURMASK); + ext = q3codemasks[*src - '0'] | (ext&~CON_Q3MASK); continue; } - else if (*src == '8') //'half transparent' + else if (*src == 'b') // toggle blink bit { src++; - ext = (COLOR_WHITE)*256 | (ext&~CON_COLOURMASK); + ext ^= CON_BLINKTEXT; continue; } - else if (*src == '9') //'half brightness' + else if (*src == 'a') // toggle alternate charset { src++; - ext = (COLOR_WHITE)*256 | (ext&~CON_COLOURMASK); - continue; - } - else if (*src == 'b') - { - src++; - ext = (ext & ~CON_BLINKTEXT) + (CON_BLINKTEXT - (ext & CON_BLINKTEXT)); - continue; - } - else if (*src == 'a') - { - src++; - ext = (ext & ~CON_2NDCHARSETTEXT) + (CON_2NDCHARSETTEXT - (ext & CON_2NDCHARSETTEXT)); + ext ^= CON_2NDCHARSETTEXT; continue; } else if (*src == 's') @@ -314,7 +302,7 @@ void SCR_EraseCenterString (void) } } -void SCR_CenterPrintBreaks(unsigned short *start, int *lines, int *maxlength) +void SCR_CenterPrintBreaks(conchar_t *start, int *lines, int *maxlength) { int l; *lines = 0; @@ -350,7 +338,7 @@ void SCR_CenterPrintBreaks(unsigned short *start, int *lines, int *maxlength) void SCR_DrawCenterString (int pnum) { - unsigned short *start; + conchar_t *start; int l; int j; int x, y; diff --git a/engine/client/console.c b/engine/client/console.c index f513f7bcb..5445c8150 100644 --- a/engine/client/console.c +++ b/engine/client/console.c @@ -21,24 +21,44 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "quakedef.h" -//this is the same order as q3, except that white and black are swapped... -consolecolours_t consolecolours[] = { -#define CON_WHITEMASK 7*256 //must be constant. things assume this - {0, 0, 0, 0x0000}, - {1, 0, 0, 0x001F}, - {0, 1, 0, 0x03E0}, - {1, 1, 0, 0x03FF}, - {0.1, 0.1, 1, 0x7C00}, //brighten dark blue a little - {1, 0, 1, 0x7C1F}, - {0, 1, 1, 0x7FE0}, - {1, 1, 1, 0x7FFF} +// This is the standard RGBI palette used in CGA text mode +consolecolours_t consolecolours[MAXCONCOLOURS] = { + { 0, 0, 0, 0, 0, 0 }, // black + { 0, 0, 170, 0, 0, 0.67}, // blue + { 0, 170, 0, 0, 0.67, 0 }, // green + { 0, 170, 170, 0, 0.67, 0.67}, // cyan + {170, 0, 0, 0.67, 0, 0 }, // red + {170, 0, 170, 0.67, 0, 0.67}, // magenta + {170, 85, 0, 0.67, 0.33, 0 }, // brown + {170, 170, 170, 0.67, 0.67, 0.67}, // light gray + { 85, 85, 85, 0.33, 0.33, 0.33}, // dark gray + { 85, 85, 255, 0.33, 0.33, 1 }, // light blue + { 85, 255, 85, 0.33, 1, 0.33}, // light green + { 85, 255, 255, 0.33, 1, 1 }, // light cyan + {255, 85, 85, 1, 0.33, 0.33}, // light red + {255, 85, 255, 1, 0.33, 1 }, // light magenta + {255, 255, 85, 1, 1, 0.33}, // yellow + {255, 255, 255, 1, 1, 1 } // white }; -int con_ormask; +// This is for remapping the Q3 color codes to character masks, including ^9 +conchar_t q3codemasks[MAXQ3COLOURS] = { + 0x00000000, // 0, black + 0x0c000000, // 1, red + 0x0a000000, // 2, green + 0x0e000000, // 3, yellow + 0x09000000, // 4, blue + 0x0b000000, // 5, cyan + 0x0d000000, // 6, magenta + 0x0f000000, // 7, white + 0x0f100000, // 8, half-alpha white (BX_COLOREDTEXT) + 0x07000000 // 9, "half-intensity" (BX_COLOREDTEXT) +}; + +conchar_t con_ormask; console_t con_main; console_t *con_current; // point to either con_main - #ifdef QTERM #include typedef struct qterm_s { @@ -436,7 +456,7 @@ Con_Resize void Con_ResizeCon (console_t *con) { int i, j, width, oldwidth, oldtotallines, numlines, numchars; - unsigned short tbuf[CON_TEXTSIZE]; + conchar_t tbuf[CON_TEXTSIZE]; if (scr_chatmode == 2) width = (vid.width >> 4) - 2; @@ -472,7 +492,7 @@ void Con_ResizeCon (console_t *con) numchars = con->linewidth; Q_memcpy (tbuf, con->text, sizeof(con->text)); - for (i = 0; i < sizeof(con->text)/sizeof(unsigned short); i++) + for (i = 0; i < sizeof(con->text)/sizeof(conchar_t); i++) con->text[i] = ' '; // Q_memset (con->text, ' ', sizeof(con->text)); @@ -598,7 +618,7 @@ void Con_PrintCon (console_t *con, char *txt) if (txt[0] == 1 || txt[0] == 2) { - mask = CON_STANDARDMASK|CON_WHITEMASK; // go to colored text + mask = CON_HIGHCHARSMASK|CON_WHITEMASK; // go to colored text txt++; } else @@ -609,21 +629,21 @@ void Con_PrintCon (console_t *con, char *txt) { if (c == '^') { - if (txt[1]>='0' && txt[1]<'8') + if (txt[1]>='0' && txt[1]<='9') { - mask = (txt[1]-'0')*256 + (mask&~CON_COLOURMASK); //change colour only. + mask = q3codemasks[txt[1]-'0'] + (mask&~CON_Q3MASK); //change colour only. txt+=2; continue; } if (txt[1] == 'b') { - mask = (mask & ~CON_BLINKTEXT) + (CON_BLINKTEXT - (mask & CON_BLINKTEXT)); + mask ^= CON_BLINKTEXT; txt+=2; continue; } if (txt[1] == 'a') { - mask = (mask & ~CON_2NDCHARSETTEXT) + (CON_2NDCHARSETTEXT - (mask & CON_2NDCHARSETTEXT)); + mask ^= CON_2NDCHARSETTEXT; txt+=2; continue; } @@ -873,9 +893,9 @@ void Con_DrawInput (void) int p; unsigned char *text, *fname; extern int con_commandmatch; - unsigned short maskedtext[MAXCMDLINE]; + conchar_t maskedtext[MAXCMDLINE]; - unsigned short mask=CON_WHITEMASK; + conchar_t mask=CON_WHITEMASK; int maskstack[4]; int maskstackdepth = 0; @@ -898,12 +918,12 @@ void Con_DrawInput (void) { if (text[i] == '^') //is this an escape code? { - if (text[i+1]>='0' && text[i+1]<'8') - mask = (text[i+1]-'0')*256 + (mask&~CON_COLOURMASK); //change colour only. + if (text[i+1]>='0' && text[i+1]<='9') + mask = q3codemasks[text[i+1]-'0'] | (mask&~CON_Q3MASK); //change colour only. else if (text[i+1] == 'b') - mask = (mask & ~CON_BLINKTEXT) + (CON_BLINKTEXT - (mask & CON_BLINKTEXT)); + mask ^= CON_BLINKTEXT; else if (text[i+1] == 'a') //alternate - mask = (mask & ~CON_2NDCHARSETTEXT) + (CON_2NDCHARSETTEXT - (mask & CON_2NDCHARSETTEXT)); + mask ^= CON_2NDCHARSETTEXT; else if (text[i+1] == 's') //store on stack (it's great for names) { if (maskstackdepth < sizeof(maskstack)/sizeof(maskstack[0])) @@ -938,7 +958,7 @@ void Con_DrawInput (void) if (text[1] == '/' || Cmd_IsCommand(text+1)) { //color the first token yellow, it's a valid command for (p = 1; (maskedtext[p]&255)>' '; p++) - maskedtext[p] = (maskedtext[p]&255) | (COLOR_YELLOW<<8); + maskedtext[p] = (maskedtext[p]&255) | (COLOR_YELLOW<' '; p++) - maskedtext[p+x] = (unsigned char)fname[p] | (COLOR_GREEN<<8); + maskedtext[p+x] = (unsigned char)fname[p] | (COLOR_GREEN<='0' && s[x+1]<'8') - mask = (s[x+1]-'0')*256 + (mask&~CON_COLOURMASK); //change colour only. + if (s[x+1]>='0' && s[x+1]<='9') + mask = q3codemasks[s[x+1]-'0'] | (mask&~CON_Q3MASK); //change colour only. else if (s[x+1] == 'b') - mask = (mask & ~CON_BLINKTEXT) + (CON_BLINKTEXT - (mask & CON_BLINKTEXT)); + mask ^= CON_BLINKTEXT; else if (s[x+1] == 'a') //alternate - mask = (mask & ~CON_2NDCHARSETTEXT) + (CON_2NDCHARSETTEXT - (mask & CON_2NDCHARSETTEXT)); + mask ^= CON_2NDCHARSETTEXT; else if (s[x+1] == 's') //store on stack (it's great for names) { if (maskstackdepth < sizeof(maskstack)/sizeof(maskstack[0])) @@ -1125,12 +1145,12 @@ void Con_DrawNotify (void) { if (s[x] == '^') { - if (s[x+1]>='0' && s[x+1]<'8') - mask = (s[x+1]-'0')*256 + (mask&~CON_COLOURMASK); //change colour only. + if (s[x+1]>='0' && s[x+1]<='9') + mask = q3codemasks[s[x+1]-'0'] | (mask&~CON_Q3MASK); //change colour only. else if (s[x+1] == 'b') - mask = (mask & ~CON_BLINKTEXT) + (CON_BLINKTEXT - (mask & CON_BLINKTEXT)); + mask ^= CON_BLINKTEXT; else if (s[x+1] == 'a') //alternate - mask = (mask & ~CON_2NDCHARSETTEXT) + (CON_2NDCHARSETTEXT - (mask & CON_2NDCHARSETTEXT)); + mask ^= CON_2NDCHARSETTEXT; else if (s[x+1] == 's') //store on stack (it's great for names) { if (maskstackdepth < sizeof(maskstack)/sizeof(maskstack[0])) @@ -1152,7 +1172,7 @@ void Con_DrawNotify (void) Draw_ColouredCharacter ( (x+skip)<<3, v, s[x]|mask); x++; } - Draw_ColouredCharacter ( (x+skip)<<3, v, (10+((int)(realtime*con_cursorspeed)&1))|M_COLOR_WHITE); + Draw_ColouredCharacter ( (x+skip)<<3, v, (10+((int)(realtime*con_cursorspeed)&1))|CON_WHITEMASK); v += 8; } @@ -1165,7 +1185,7 @@ void Con_DrawNotify (void) void Con_PrintToSys(void) { int line, row, x, spc, content; - short *text; + conchar_t *text; console_t *curcon = &con_main; content = 0; @@ -1203,7 +1223,7 @@ void Con_DrawConsole (int lines, qboolean noback) int i, j, x, y; float n; int rows; - unsigned short *text; + conchar_t *text; char *txt; int row; unsigned char dlbar[1024]; @@ -1333,9 +1353,9 @@ void Con_DrawConsole (int lines, qboolean noback) // draw it y = curcon->vislines-22 + 8; for (i = 0; i < strlen(dlbar); i++) - Draw_ColouredCharacter ( (i+1)<<3, y, (unsigned char)dlbar[i] | M_COLOR_WHITE); + Draw_ColouredCharacter ( (i+1)<<3, y, (unsigned char)dlbar[i] | CON_WHITEMASK); - Draw_ColouredCharacter ((n+1+x)*8, y, (unsigned char)'\x83' | M_COLOR_WHITE); + Draw_ColouredCharacter ((n+1+x)*8, y, (unsigned char)'\x83' | CON_WHITEMASK); } // draw the input prompt, user text, and cursor if desired diff --git a/engine/client/m_download.c b/engine/client/m_download.c index 2851843dc..edd37923d 100644 --- a/engine/client/m_download.c +++ b/engine/client/m_download.c @@ -480,7 +480,6 @@ void Menu_DownloadStuff_f (void) key_dest = key_menu; m_state = m_complex; - m_entersound = true; menu = M_CreateMenu(sizeof(dlmenu_t)); info = menu->data; diff --git a/engine/client/m_items.c b/engine/client/m_items.c index f03f9d2d7..f8558276b 100644 --- a/engine/client/m_items.c +++ b/engine/client/m_items.c @@ -1316,6 +1316,8 @@ void M_Menu_Main_f (void) } */ + S_LocalSound ("misc/menu2.wav"); + mgt = M_GameType(); if (mgt == MGT_QUAKE2) //quake2 main menu. { @@ -1323,7 +1325,6 @@ void M_Menu_Main_f (void) { m_state = m_complex; key_dest = key_menu; - m_entersound = true; mainm = M_CreateMenu(0); mainm->key = MC_Main_Key; @@ -1354,7 +1355,6 @@ void M_Menu_Main_f (void) { m_state = m_complex; key_dest = key_menu; - m_entersound = true; mainm = M_CreateMenu(0); mainm->key = MC_Main_Key; @@ -1389,7 +1389,6 @@ void M_Menu_Main_f (void) { m_state = m_complex; key_dest = key_menu; - m_entersound = true; mainm = M_CreateMenu(0); p = Draw_SafeCachePic("gfx/ttl_main.lmp"); diff --git a/engine/client/m_master.c b/engine/client/m_master.c index f6a26b86c..898e1eb9e 100644 --- a/engine/client/m_master.c +++ b/engine/client/m_master.c @@ -80,7 +80,7 @@ static void NM_Print (int cx, int cy, qbyte *str) { while (*str) { - Draw_ColouredCharacter (cx, cy, (*str)|128|M_COLOR_WHITE); + Draw_ColouredCharacter (cx, cy, (*str)|CON_HIGHCHARSMASK|CON_WHITEMASK); str++; cx += 8; } @@ -90,7 +90,7 @@ static void NM_PrintWhite (int cx, int cy, qbyte *str) { while (*str) { - Draw_ColouredCharacter (cx, cy, (*str)+M_COLOR_WHITE); + Draw_ColouredCharacter (cx, cy, (*str)|CON_WHITEMASK); str++; cx += 8; } @@ -100,16 +100,12 @@ static void NM_PrintColoured (int cx, int cy, int colour, qbyte *str) { while (*str) { - NM_DrawColouredCharacter (cx, cy, (*str) + (colour<<8)); + NM_DrawColouredCharacter (cx, cy, (*str) | (colour<0) { - NM_DrawColouredCharacter (right, y, (*(unsigned char *)text) + (colour<<8)); + NM_DrawColouredCharacter (right, y, (*(unsigned char *)text) | (colour<teamedit->text); Cvar_Set(&skin, info->skinedit->text); Cbuf_AddText(va("color %i %i\n", info->lowercolour, info->topcolour), RESTRICT_LOCAL); -m_entersound=true; -M_RemoveMenu(menu); + S_LocalSound ("misc/menu2.wav"); + M_RemoveMenu(menu); return true; } qboolean SetupMenuColour (union menuoption_s *option,struct menu_s *menu, int key) @@ -107,7 +106,7 @@ qboolean SetupMenuColour (union menuoption_s *option,struct menu_s *menu, int ke info->topcolour ++; if (info->topcolour>=14) info->topcolour=0; - m_entersound=true; + S_LocalSound ("misc/menu2.wav"); return true; } if (key == K_LEFTARROW) @@ -115,7 +114,7 @@ qboolean SetupMenuColour (union menuoption_s *option,struct menu_s *menu, int ke info->topcolour --; if (info->topcolour<=0) info->topcolour=13; - m_entersound=true; + S_LocalSound ("misc/menu2.wav"); return true; } @@ -127,7 +126,7 @@ qboolean SetupMenuColour (union menuoption_s *option,struct menu_s *menu, int ke info->lowercolour ++; if (info->lowercolour>=14) info->lowercolour=0; - m_entersound=true; + S_LocalSound ("misc/menu2.wav"); return true; } if (key == K_LEFTARROW) @@ -135,7 +134,7 @@ qboolean SetupMenuColour (union menuoption_s *option,struct menu_s *menu, int ke info->lowercolour --; if (info->lowercolour<=0) info->lowercolour=13; - m_entersound=true; + S_LocalSound ("misc/menu2.wav"); return true; } } @@ -179,7 +178,6 @@ void M_Menu_Setup_f (void) key_dest = key_menu; m_state = m_complex; - m_entersound = true; menu = M_CreateMenu(sizeof(setupmenu_t)); info = menu->data; @@ -217,7 +215,6 @@ void M_Menu_ServerList_f (void) { key_dest = key_menu; m_state = m_slist; - m_entersound = true; MasterInfo_Begin(); } @@ -304,7 +301,6 @@ qboolean MultiBeginGame (union menuoption_s *option,struct menu_s *menu, int key Cbuf_AddText("echo You can use the setrenderer command to return to a graphical interface at any time\n", RESTRICT_LOCAL); } -m_entersound=true; M_RemoveAllMenus(); return true; @@ -372,7 +368,6 @@ void M_Menu_GameOptions_f (void) key_dest = key_menu; m_state = m_complex; - m_entersound = true; menu = M_CreateMenu(sizeof(newmultimenu_t)); info = menu->data; diff --git a/engine/client/m_options.c b/engine/client/m_options.c index ea5e0dad0..26dcc5e74 100644 --- a/engine/client/m_options.c +++ b/engine/client/m_options.c @@ -46,7 +46,6 @@ void M_Menu_Options_f (void) key_dest = key_menu; m_state = m_complex; - m_entersound = true; menu = M_CreateMenu(0); @@ -204,7 +203,6 @@ void M_Menu_Audio_Speakers_f (void) key_dest = key_menu; m_state = m_complex; - m_entersound = true; menu = M_CreateMenu(sizeof(audiomenuinfo_t)); info = menu->data; @@ -262,7 +260,6 @@ void M_Menu_Audio_f (void) key_dest = key_menu; m_state = m_complex; - m_entersound = true; menu = M_CreateMenu(0); @@ -317,7 +314,6 @@ void M_Menu_Particles_f (void) key_dest = key_menu; m_state = m_complex; - m_entersound = true; menu = M_CreateMenu(0); @@ -434,7 +430,6 @@ void M_Menu_FPS_f (void) key_dest = key_menu; m_state = m_complex; - m_entersound = true; menu = M_CreateMenu(0); diff --git a/engine/client/m_script.c b/engine/client/m_script.c index ee0e87ee6..140dcf5b7 100644 --- a/engine/client/m_script.c +++ b/engine/client/m_script.c @@ -44,8 +44,6 @@ void M_MenuS_Script_f (void) //create a menu. // if (key_dest != key_console) key_dest = key_menu; m_state = m_complex; - if (menu_script != currentmenu) - m_entersound = true; selectitem = 0; items=0; diff --git a/engine/client/m_single.c b/engine/client/m_single.c index 110d8dc5f..b3d797c6f 100644 --- a/engine/client/m_single.c +++ b/engine/client/m_single.c @@ -98,7 +98,6 @@ void M_Menu_Save_f (void) key_dest = key_menu; m_state = m_complex; - m_entersound = true; menu = M_CreateMenu(sizeof(loadsavemenuinfo_t)); menu->data = menu+1; @@ -123,7 +122,6 @@ void M_Menu_Load_f (void) key_dest = key_menu; m_state = m_complex; - m_entersound = true; menu = M_CreateMenu(sizeof(loadsavemenuinfo_t)); menu->data = menu+1; @@ -158,7 +156,6 @@ void M_Menu_SinglePlayer_f (void) key_dest = key_menu; m_state = m_complex; - m_entersound = true; mgt = M_GameType(); if (mgt == MGT_QUAKE2) @@ -408,7 +405,6 @@ void M_Menu_Demos_f (void) key_dest = key_menu; m_state = m_complex; - m_entersound = true; menu = M_CreateMenu(sizeof(demomenu_t)); menu->remove = M_Demo_Remove; @@ -445,7 +441,6 @@ void M_Menu_ParticleSets_f (void) key_dest = key_menu; m_state = m_complex; - m_entersound = true; menu = M_CreateMenu(sizeof(demomenu_t)); menu->remove = M_Demo_Remove; @@ -474,7 +469,6 @@ void M_Menu_MediaFiles_f (void) key_dest = key_menu; m_state = m_complex; - m_entersound = true; menu = M_CreateMenu(sizeof(demomenu_t)); menu->remove = M_Demo_Remove; diff --git a/engine/client/menu.c b/engine/client/menu.c index d11f18292..9dc8703e4 100644 --- a/engine/client/menu.c +++ b/engine/client/menu.c @@ -27,8 +27,6 @@ m_state_t m_state; extern menu_t *menu_script; -qboolean m_entersound; // play after drawing a frame, so caching - // won't disrupt the sound qboolean m_recursiveDraw; int m_return_state; @@ -69,7 +67,7 @@ void M_Print (int cx, int cy, qbyte *str) { while (*str) { - M_DrawCharacter (cx, cy, (*str)+128); + M_DrawCharacter (cx, cy, (*str)|CON_HIGHCHARSMASK); str++; cx += 8; } @@ -79,7 +77,7 @@ void M_PrintColoured (int cx, int cy, int colour, qbyte *str) { while (*str) { - M_DrawColouredCharacter (cx, cy, (*str) + (colour<<8)); + M_DrawColouredCharacter (cx, cy, (*str) + (colour<= num_help_pages) help_page = 0; break; case K_DOWNARROW: case K_LEFTARROW: - m_entersound = true; + S_LocalSound ("misc/menu2.wav"); if (--help_page < 0) help_page = num_help_pages-1; break; @@ -781,7 +776,6 @@ void M_Menu_Quit_f (void) key_dest = key_menu; m_state = m_complex; - m_entersound = true; M_RemoveMenu(&quitmenu); memset(&quitmenu, 0, sizeof(quitmenu)); @@ -1005,12 +999,6 @@ void M_Draw (int uimenu) #endif } - if (m_entersound) - { - S_LocalSound ("misc/menu2.wav"); - m_entersound = false; - } - VID_UnlockBuffer (); S_ExtraUpdate (); VID_LockBuffer (); diff --git a/engine/client/menu.h b/engine/client/menu.h index e08498d3f..a32c943b4 100644 --- a/engine/client/menu.h +++ b/engine/client/menu.h @@ -278,8 +278,6 @@ void M_Complex_Draw(void); void M_Script_Init(void); void M_Serverlist_Init(void); -extern qboolean m_entersound; - void M_Menu_Main_f (void); void M_Menu_SinglePlayer_f (void); void M_Menu_Load_f (void); diff --git a/engine/client/renderer.c b/engine/client/renderer.c index 3f12a5911..37fd55706 100644 --- a/engine/client/renderer.c +++ b/engine/client/renderer.c @@ -1138,7 +1138,6 @@ void M_Menu_Video_f (void) key_dest = key_menu; m_state = m_complex; - m_entersound = true; menu = M_CreateMenu(sizeof(videomenuinfo_t)); info = menu->data; diff --git a/engine/client/sbar.c b/engine/client/sbar.c index d426a24c7..3a05dfde3 100644 --- a/engine/client/sbar.c +++ b/engine/client/sbar.c @@ -110,7 +110,7 @@ void Sbar_ChatModeOverlay(void); void Draw_FunString(int x, int y, unsigned char *str) { - int ext = COLOR_WHITE<<8; + int ext = CON_WHITEMASK; int extstack[4]; int extstackdepth = 0; @@ -120,21 +120,21 @@ void Draw_FunString(int x, int y, unsigned char *str) if (*str == '^') { str++; - if (*str >= '0' && *str <= '7') + if (*str >= '0' && *str <= '9') { - ext = (*str++-'0')*256 + (ext&~CON_COLOURMASK); //change colour only. + ext = q3codemasks[*str++-'0'] | (ext&~CON_Q3MASK); //change colour only. continue; } else if (*str == 'a') { str++; - ext = (ext & ~CON_2NDCHARSETTEXT) + (CON_2NDCHARSETTEXT - (ext & CON_2NDCHARSETTEXT)); + ext ^= CON_2NDCHARSETTEXT; continue; } else if (*str == 'b') { str++; - ext = (ext & ~CON_BLINKTEXT) + (CON_BLINKTEXT - (ext & CON_BLINKTEXT)); + ext ^= CON_BLINKTEXT; continue; } else if (*str == 's') //store on stack (it's great for names) @@ -159,26 +159,26 @@ void Draw_FunString(int x, int y, unsigned char *str) } else if (*str == '^') { - Draw_ColouredCharacter(x, y, '^' + ext); + Draw_ColouredCharacter(x, y, '^' | ext); str++; } else { - Draw_ColouredCharacter(x, y, '^' + ext); + Draw_ColouredCharacter(x, y, '^' | ext); x += 8; - Draw_ColouredCharacter (x, y, (*str++) + ext); + Draw_ColouredCharacter (x, y, (*str++) | ext); } x += 8; continue; } - Draw_ColouredCharacter (x, y, (*str++) + ext); + Draw_ColouredCharacter (x, y, (*str++) | ext); x += 8; } } void Draw_FunStringLen(int x, int y, unsigned char *str, int len) { - int ext = COLOR_WHITE<<8; + int ext = CON_WHITEMASK; int extstack[4]; int extstackdepth = 0; @@ -191,21 +191,21 @@ void Draw_FunStringLen(int x, int y, unsigned char *str, int len) if (*str == '^') { str++; - if (*str >= '0' && *str <= '7') + if (*str >= '0' && *str <= '9') { - ext = (*str++-'0')*256 + (ext&~CON_COLOURMASK); //change colour only. + ext = q3codemasks[*str++-'0'] | (ext&~CON_Q3MASK); //change colour only. continue; } else if (*str == 'a') { str++; - ext = (ext & ~CON_2NDCHARSETTEXT) + (CON_2NDCHARSETTEXT - (ext & CON_2NDCHARSETTEXT)); + ext ^= CON_2NDCHARSETTEXT; continue; } else if (*str == 'b') { str++; - ext = (ext & ~CON_BLINKTEXT) + (CON_BLINKTEXT - (ext & CON_BLINKTEXT)); + ext ^= CON_BLINKTEXT; continue; } else if (*str == 's') //store on stack (it's great for names) @@ -229,19 +229,19 @@ void Draw_FunStringLen(int x, int y, unsigned char *str, int len) } else if (*str == '^') { - Draw_ColouredCharacter(x, y, '^' + ext); + Draw_ColouredCharacter(x, y, '^' | ext); str++; } else { - Draw_ColouredCharacter(x, y, '^' + ext); + Draw_ColouredCharacter(x, y, '^' | ext); x += 8; - Draw_ColouredCharacter (x, y, (*str++) + ext); + Draw_ColouredCharacter (x, y, (*str++) | ext); } x += 8; continue; } - Draw_ColouredCharacter (x, y, (*str++) + ext); + Draw_ColouredCharacter (x, y, (*str++) | ext); x += 8; } } @@ -2056,7 +2056,7 @@ void Sbar_DeathmatchOverlay (int start) y += skip; } - Draw_Character(0,0,COLOR_WHITE<<8); + Draw_Character(0,0,CON_WHITEMASK); if (y >= vid.height-10) // we ran over the screen size, squish largegame = true; @@ -2157,7 +2157,7 @@ void Sbar_ChatModeOverlay(void) y += skip; } - Draw_Character(0,0,COLOR_WHITE<<8); + Draw_Character(0,0,CON_WHITEMASK); if (y >= vid.height-10) // we ran over the screen size, squish largegame = true; @@ -2240,7 +2240,7 @@ void Sbar_MiniDeathmatchOverlay (void) f = s->frags; sprintf (num, "%3i",f); - Draw_ColouredCharacter ( x+8 , y, (COLOR_WHITE<<8)|num[0]); + Draw_ColouredCharacter ( x+8 , y, CON_WHITEMASK|num[0]); Draw_Character ( x+16, y, num[1]); Draw_Character ( x+24, y, num[2]); @@ -2270,7 +2270,7 @@ void Sbar_MiniDeathmatchOverlay (void) // draw seperator x += 208; for (y = sbar_rect.height - sb_lines; y < sbar_rect.height - 6; y += 2) - Draw_ColouredCharacter(x, y, (COLOR_WHITE<<8)|14); + Draw_ColouredCharacter(x, y, CON_WHITEMASK|14); x += 16; diff --git a/engine/client/textedit.c b/engine/client/textedit.c index 5dd22e419..32cbb49f5 100644 --- a/engine/client/textedit.c +++ b/engine/client/textedit.c @@ -760,7 +760,7 @@ void Draw_CursorLine(int ox, int y, fileblock_t *b) if (*d == '\t') { if (a == cx) - Draw_ColouredCharacter (x+ox, y, 11|M_COLOR_WHITE); + Draw_ColouredCharacter (x+ox, y, 11|CON_WHITEMASK); x+=ts; x-=x%ts; d++; @@ -770,9 +770,9 @@ void Draw_CursorLine(int ox, int y, fileblock_t *b) if (x+ox< vid.width) { if (a == cx) - Draw_ColouredCharacter (x+ox, y, 11|M_COLOR_WHITE); + Draw_ColouredCharacter (x+ox, y, 11|CON_WHITEMASK); else - Draw_ColouredCharacter (x+ox, y, (int)*d | (colour<<8)); + Draw_ColouredCharacter (x+ox, y, (int)*d | (colour<= '0' && c < '8') || c == 'a' || c == 'b' || c == 's' || c == 'r') + if ((c >= '0' && c <= '9') || c == 'a' || c == 'b' || c == 's' || c == 'r') { i--; s++; diff --git a/engine/common/plugin.c b/engine/common/plugin.c index 81b0454d3..b16486baa 100644 --- a/engine/common/plugin.c +++ b/engine/common/plugin.c @@ -125,7 +125,9 @@ typedef struct plugin_s { //protocol-in-a-plugin int connectionlessclientpacket; #endif - int messagefunction; + int svmsgfunction; + int chatmsgfunction; + int centerprintfunction; struct plugin_s *next; } plugin_t; @@ -371,8 +373,12 @@ int VARGS Plug_ExportToEngine(void *offset, unsigned int mask, const long *arg) currentplug->sbarlevel[2] = arg[1]; else if (!strcmp(name, "ConnectionlessClientPacket")) currentplug->connectionlessclientpacket = arg[1]; - else if (!strcmp(name, "MessageEvent")) - currentplug->messagefunction = arg[1]; + else if (!strcmp(name, "ServerMessageEvent")) + currentplug->svmsgfunction = arg[1]; + else if (!strcmp(name, "ChatMessageEvent")) + currentplug->chatmsgfunction = arg[1]; + else if (!strcmp(name, "CenterPrintMessage")) + currentplug->centerprintfunction = arg[1]; #endif else return 0; @@ -1549,17 +1555,49 @@ void Plug_SBar(void) } #endif -int Plug_Message(int clientnum, int messagelevel, char *buffer) +qboolean Plug_ServerMessage(char *buffer, int messagelevel) { + qboolean ret = true; + for (currentplug = plugs; currentplug; currentplug = currentplug->next) { - if (currentplug->messagefunction) + if (currentplug->svmsgfunction) { - VM_Call(currentplug->vm, currentplug->messagefunction, clientnum, messagelevel, buffer); + ret &= VM_Call(currentplug->vm, currentplug->svmsgfunction, buffer, messagelevel); } } - return 1; // don't silence message + return ret; // true to display message, false to supress +} + +qboolean Plug_ChatMessage(char *buffer, int talkernum, int tpflags) +{ + qboolean ret = true; + + for (currentplug = plugs; currentplug; currentplug = currentplug->next) + { + if (currentplug->chatmsgfunction) + { + ret &= VM_Call(currentplug->vm, currentplug->chatmsgfunction, buffer, talkernum, tpflags); + } + } + + return ret; // true to display message, false to supress +} + +qboolean Plug_CenterPrintMessage(char *buffer, int clientnum) +{ + qboolean ret = true; + + for (currentplug = plugs; currentplug; currentplug = currentplug->next) + { + if (currentplug->centerprintfunction) + { + ret &= VM_Call(currentplug->vm, currentplug->centerprintfunction, buffer, clientnum); + } + } + + return ret; // true to display message, false to supress } void Plug_Close(plugin_t *plug) diff --git a/engine/gl/gl_draw.c b/engine/gl/gl_draw.c index 49e1fb4b4..a56f3ef32 100644 --- a/engine/gl/gl_draw.c +++ b/engine/gl/gl_draw.c @@ -1279,9 +1279,10 @@ void GLDraw_Character (int x, int y, unsigned int num) #endif*/ } +void GLDraw_FillRGB (int x, int y, int w, int h, float r, float g, float b); void GLDraw_ColouredCharacter (int x, int y, unsigned int num) { - int col; + unsigned int col; if (num & CON_BLINKTEXT) { @@ -1290,11 +1291,16 @@ void GLDraw_ColouredCharacter (int x, int y, unsigned int num) return; } + // draw background + if (num & CON_NONCLEARBG) { - col = (num&CON_COLOURMASK)/256; - qglColor3f(consolecolours[col].r, consolecolours[col].g, consolecolours[col].b); + col = (num & CON_BGMASK) >> CON_BGSHIFT; + GLDraw_FillRGB(x, y, 8, 8, consolecolours[col].fr, consolecolours[col].fg, consolecolours[col].fb); } + // render character with foreground color + col = (num & CON_FGMASK) >> CON_FGSHIFT; + qglColor3f(consolecolours[col].fr, consolecolours[col].fg, consolecolours[col].fb); Draw_Character(x, y, num); } /* @@ -1948,30 +1954,10 @@ void GLDraw_TileClear (int x, int y, int w, int h) } } - -/* -============= -Draw_Fill - -Fills a box of pixels with a single color -============= -*/ -void GLDraw_Fill (int x, int y, int w, int h, int c) +void GLDraw_FillRGB (int x, int y, int w, int h, float r, float g, float b) { - extern qboolean gammaworks; qglDisable (GL_TEXTURE_2D); - if (gammaworks) - { - qglColor3f (host_basepal[c*3]/255.0, - host_basepal[c*3+1]/255.0, - host_basepal[c*3+2]/255.0); - } - else - { - qglColor3f (gammatable[host_basepal[c*3]]/255.0, - gammatable[host_basepal[c*3+1]]/255.0, - gammatable[host_basepal[c*3+2]]/255.0); - } + qglColor3f (r, g, b); qglBegin (GL_QUADS); @@ -1984,6 +1970,32 @@ void GLDraw_Fill (int x, int y, int w, int h, int c) qglColor3f (1,1,1); qglEnable (GL_TEXTURE_2D); } + +/* +============= +Draw_Fill + +Fills a box of pixels with a single color +============= +*/ +void GLDraw_Fill (int x, int y, int w, int h, int c) +{ + extern qboolean gammaworks; + if (gammaworks) + { + GLDraw_FillRGB (x, y, w, h, + host_basepal[c*3]/255.0, + host_basepal[c*3+1]/255.0, + host_basepal[c*3+2]/255.0); + } + else + { + GLDraw_FillRGB (x, y, w, h, + gammatable[host_basepal[c*3]]/255.0, + gammatable[host_basepal[c*3+1]]/255.0, + gammatable[host_basepal[c*3+2]]/255.0); + } +} //============================================================================= /* diff --git a/engine/gl/gl_draw.h b/engine/gl/gl_draw.h index 3a85f0966..762e40b0d 100644 --- a/engine/gl/gl_draw.h +++ b/engine/gl/gl_draw.h @@ -38,6 +38,7 @@ void GLDraw_EditorBackground (int lines); void GLDraw_BeginDisc (void); void GLDraw_EndDisc (void); void GLDraw_TileClear (int x, int y, int w, int h); +void GLDraw_FillRGB (int x, int y, int w, int h, float r, float g, float b); void GLDraw_Fill (int x, int y, int w, int h, int c); void GLDraw_FadeScreen (void); void GLDraw_String (int x, int y, const qbyte *str); diff --git a/engine/server/pr_cmds.c b/engine/server/pr_cmds.c index 3a6ae6c2f..5a3c464d5 100644 --- a/engine/server/pr_cmds.c +++ b/engine/server/pr_cmds.c @@ -30,7 +30,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. //okay, so these are a quick but easy hack void ED_Print (struct progfuncs_s *progfuncs, struct edict_s *ed); int PR_EnableEBFSBuiltin(char *name, int binum); -void PR_CleanLogText_Init (void); cvar_t nomonsters = {"nomonsters", "0"}; cvar_t gamecfg = {"gamecfg", "0"}; @@ -535,8 +534,6 @@ void PR_LoadGlabalStruct(void) pr_items2 = !!PR_FindGlobal(svprogfuncs, "items2", 0); - PR_CleanLogText_Init(); - SV_ClearQCStats(); if (progstype == PROG_H2) @@ -5362,7 +5359,7 @@ void PF_redstring(progfuncs_t *prinst, struct globalvars_s *pr_globals) static char buf[1024]; for (s = buf; *string; s++, string++) - *s=*string|128; + *s=*string|CON_HIGHCHARSMASK; *s = '\0'; RETURN_TSTRING(buf); @@ -6836,66 +6833,46 @@ void PF_strstr (progfuncs_t *prinst, struct globalvars_s *pr_globals) RETURN_TSTRING(p); } -/* -==================== -SV_CleanName_Init - -sets chararcter table to translate quake texts to more friendly texts -==================== -*/ - -char chartbl2[256]; - -void PR_CleanLogText_Init (void) +char readable2[256] = { - int i; - - for (i = 0; i < 256; i++) - chartbl2[i] = (i&127) < 32 ? ' ' : i&127; - - chartbl2[13] = 13; - chartbl2[10] = 10; - // special cases - - // numbers - for (i = 18; i < 28; i++) - chartbl2[i] = chartbl2[i + 128] = i + 30; - - // brackets - chartbl2[29] = chartbl2[29 + 128] = chartbl2[128] = '('; - chartbl2[31] = chartbl2[31 + 128] = chartbl2[130] = ')'; - chartbl2[16] = chartbl2[16 + 128]= '['; - chartbl2[17] = chartbl2[17 + 128] = ']'; - - // hash - for (i = 1; i < 10; i++) // 5 redefined as '.' - chartbl2[i] = chartbl2[i + 128] = '#'; - - chartbl2[11] = chartbl2[11 + 128] = '#'; - - // dot - chartbl2[5] = chartbl2[14] = chartbl2[15] = chartbl2[28] = chartbl2[46] = '.'; - chartbl2[5 + 128] = chartbl2[14 + 128] = chartbl2[15 + 128] = chartbl2[28 + 128] = chartbl2[46 + 128] = '.'; - - // left arrow - chartbl2[127] = '>'; - - // right arrow - chartbl2[141] = '<'; - - // '=' - chartbl2[30] = chartbl2[129] = chartbl2[30 + 128] = '='; - - // whitespaces - chartbl2[12] = chartbl2[12 + 128] = chartbl2[138] = ' '; - - chartbl2[33] = chartbl2[33 + 128]= '!'; -} + '.', '_', '_', '_', '_', '.', '_', '_', + '_', '_', '\n', '_', '\n', '>', '.', '.', + '[', ']', '0', '1', '2', '3', '4', '5', + '6', '7', '8', '9', '.', '_', '_', '_', + ' ', '!', '\"', '#', '$', '%', '&', '\'', + '(', ')', '*', '+', ',', '-', '.', '/', + '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', ':', ';', '<', '=', '>', '?', + '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', + 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', + 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', + 'X', 'Y', 'Z', '[', '\\', ']', '^', '_', + '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', + 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', + 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', + 'x', 'y', 'z', '{', '|', '}', '~', '_', + '_', '_', '_', '_', '_', '.', '_', '_', + '_', '_', '_', '_', '_', '>', '.', '.', + '[', ']', '0', '1', '2', '3', '4', '5', + '6', '7', '8', '9', '.', '_', '_', '_', + ' ', '!', '\"', '#', '$', '%', '&', '\'', + '(', ')', '*', '+', ',', '-', '.', '/', + '0', '1', '2', '3', '4', '5', '6', '7', + '8', '9', ':', ';', '<', '=', '>', '?', + '@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', + 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', + 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', + 'X', 'Y', 'Z', '[', '\\', ']', '^', '_', + '`', 'a', 'b', 'c', 'd', 'e', 'f', 'g', + 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', + 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', + 'x', 'y', 'z', '{', '|', '}', '~', '_' +}; void PR_CleanText(unsigned char *text) { for ( ; *text; text++) - *text = chartbl2[*text]; + *text = readable2[*text]; } /* diff --git a/engine/server/sv_mvd.c b/engine/server/sv_mvd.c index dd960e50e..5eea9162a 100644 --- a/engine/server/sv_mvd.c +++ b/engine/server/sv_mvd.c @@ -899,8 +899,8 @@ void SV_MVDWritePackets (int num) demo.dbuf->maxsize = MAXSIZE + demo.dbuf->bufsize; } -static char chartbl[256]; -void CleanName_Init (); +extern char readable[256]; +#define chartbl readable void MVD_Init (void) { @@ -918,15 +918,8 @@ void MVD_Init (void) Cvar_Register (&sv_demoSuffix, MVDVARGROUP); Cvar_Register (&sv_demotxt, MVDVARGROUP); Cvar_Register (&sv_demoExtraNames, MVDVARGROUP); - - - CleanName_Init(); } - - - - static char *SV_PrintTeams(void) { char *teams[MAX_CLIENTS]; @@ -1523,85 +1516,6 @@ static qboolean SV_MVD_Record (mvddest_t *dest) return true; } -/* -==================== -SV_CleanName_Init - -sets chararcter table for quake text->filename translation -==================== -*/ - -void CleanName_Init () -{ - int i; - - for (i = 0; i < 256; i++) - chartbl[i] = (((i&127) < 'a' || (i&127) > 'z') && ((i&127) < '0' || (i&127) > '9')) ? '_' : (i&127); - - // special cases - - // numbers - for (i = 18; i < 29; i++) - chartbl[i] = chartbl[i + 128] = i + 30; - - // allow lowercase only - for (i = 'A'; i <= 'Z'; i++) - chartbl[i] = chartbl[i+128] = i + 'a' - 'A'; - - // brackets - chartbl[29] = chartbl[29+128] = chartbl[128] = '('; - chartbl[31] = chartbl[31+128] = chartbl[130] = ')'; - chartbl[16] = chartbl[16 + 128]= '['; - chartbl[17] = chartbl[17 + 128] = ']'; - - // dot - chartbl[5] = chartbl[14] = chartbl[15] = chartbl[28] = chartbl[46] = '.'; - chartbl[5 + 128] = chartbl[14 + 128] = chartbl[15 + 128] = chartbl[28 + 128] = chartbl[46 + 128] = '.'; - - // ! - chartbl[33] = chartbl[33 + 128] = '!'; - - // # - chartbl[35] = chartbl[35 + 128] = '#'; - - // % - chartbl[37] = chartbl[37 + 128] = '%'; - - // & - chartbl[38] = chartbl[38 + 128] = '&'; - - // ' - chartbl[39] = chartbl[39 + 128] = '\''; - - // ( - chartbl[40] = chartbl[40 + 128] = '('; - - // ) - chartbl[41] = chartbl[41 + 128] = ')'; - - // + - chartbl[43] = chartbl[43 + 128] = '+'; - - // - - chartbl[45] = chartbl[45 + 128] = '-'; - - // @ - chartbl[64] = chartbl[64 + 128] = '@'; - - // ^ -// chartbl[94] = chartbl[94 + 128] = '^'; - - - chartbl[91] = chartbl[91 + 128] = '['; - chartbl[93] = chartbl[93 + 128] = ']'; - - chartbl[16] = chartbl[16 + 128] = '['; - chartbl[17] = chartbl[17 + 128] = ']'; - - chartbl[123] = chartbl[123 + 128] = '{'; - chartbl[125] = chartbl[125 + 128] = '}'; -} - /* ==================== SV_CleanName diff --git a/engine/server/sv_sys_unix.c b/engine/server/sv_sys_unix.c index 45179f2e6..02b33db41 100644 --- a/engine/server/sv_sys_unix.c +++ b/engine/server/sv_sys_unix.c @@ -41,8 +41,19 @@ cvar_t sys_linebuffer = {"sys_linebuffer", "1"}; qboolean stdin_ready; - - +// This is for remapping the Q3 color codes to character masks, including ^9 +conchar_t q3codemasks[MAXQ3COLOURS] = { + 0x00000000, // 0, black + 0x0c000000, // 1, red + 0x0a000000, // 2, green + 0x0e000000, // 3, yellow + 0x09000000, // 4, blue + 0x0b000000, // 5, cyan + 0x0d000000, // 6, magenta + 0x0f000000, // 7, white + 0x0f100000, // 8, half-alpha white (BX_COLOREDTEXT) + 0x07000000 // 9, "half-intensity" (BX_COLOREDTEXT) +}; struct termios orig, changes; @@ -186,39 +197,64 @@ void Sys_Error (const char *error, ...) exit (1); } - - - - - - - - - - - - - +int ansiremap[8] = {0, 4, 2, 6, 1, 5, 3, 7}; void ApplyColour(unsigned int chr) { - static int oldchar = 7*256; - chr = chr&~255; + static int oldchar = CON_WHITEMASK; + int bg, fg; + chr &= CON_FLAGSMASK; if (oldchar == chr) return; oldchar = chr; - switch(chr&CON_COLOURMASK) + + printf("\e[0;"); // reset + + if (chr & CON_BLINKTEXT) + printf("5;"); // set blink + + bg = chr & CON_BGMASK >> CON_BGSHIFT; + fg = chr & CON_FGMASK >> CON_FGSHIFT; + + // don't handle intensive bit for background + // as terminals differ too much in displaying \e[1;7;3?m + bg &= 0x7; + + if (chr & CON_NONCLEARBG) { -//to get around wierd defaults (like a white background) we have these special hacks for colours 0 and 7 - case 0*256: - printf("\e[0;7%sm", (chr&CON_BLINKTEXT)?";5":""); - break; - case 7*256: - printf("\e[0%sm", (chr&CON_BLINKTEXT)?";5":""); - break; - default: - printf("\e[0;%i%sm", 30+((chr&CON_COLOURMASK)>>8), (chr&CON_BLINKTEXT)?";5":""); - break; + if (fg & 0x8) // intensive bit set for foreground + { + printf("1;"); // set bold/intensity ansi flag + fg &= 0x7; // strip intensive bit + } + + // set foreground and background colors + printf("3%i;4%im", ansiremap[fg], ansiremap[bg]); + } + else + { + switch(fg) + { + //to get around wierd defaults (like a white background) we have these special hacks for colours 0 and 7 + case COLOR_BLACK: + printf("7m"); // set inverse + break; + case COLOR_GREY: + printf("1;30m"); // treat as dark grey + break; + case COLOR_WHITE: + print("m"); // set nothing else + break; + default: + if (fg & 0x8) // intensive bit set for foreground + { + printf("1;"); // set bold/intensity ansi flag + fg &= 0x7; // strip intensive bit + } + + printf("3%im", fg); // set foreground + break; + } } } @@ -227,7 +263,7 @@ void Sys_PrintColouredChar(unsigned int chr) { ApplyColour(chr); - putch(chr&255); + putch(chr & CON_CHARMASK); } /* @@ -292,7 +328,7 @@ void Sys_Printf (char *fmt, ...) if (sys_colorconsole.value) { - int ext = COLOR_WHITE<<8; + int ext = CON_WHITEMASK; int extstack[4]; int extstackdepth = 0; unsigned char *str = (unsigned char*)msg; @@ -303,21 +339,21 @@ void Sys_Printf (char *fmt, ...) if (*str == '^') { str++; - if (*str >= '0' && *str <= '7') + if (*str >= '0' && *str <= '9') { - ext = (*str++-'0')*256 + (ext&~CON_COLOURMASK); //change colour only. + ext = q3codemasks[*str++-'0'] | (ext&~CON_Q3MASK); //change colour only. continue; } else if (*str == 'a') { str++; - ext = (ext & ~CON_2NDCHARSETTEXT) + (CON_2NDCHARSETTEXT - (ext & CON_2NDCHARSETTEXT)); + ext ^= CON_2NDCHARSETTEXT; continue; } else if (*str == 'b') { str++; - ext = (ext & ~CON_BLINKTEXT) + (CON_BLINKTEXT - (ext & CON_BLINKTEXT)); + ext ^= CON_BLINKTEXT; continue; } else if (*str == 's') //store on stack (it's great for names) @@ -342,20 +378,20 @@ void Sys_Printf (char *fmt, ...) } else if (*str == '^') { - Sys_PrintColouredChar('^' + ext); + Sys_PrintColouredChar('^' | ext); str++; } else { - Sys_PrintColouredChar('^' + ext); - Sys_PrintColouredChar ((*str++) + ext); + Sys_PrintColouredChar('^' | ext); + Sys_PrintColouredChar ((*str++) | ext); } continue; } - Sys_PrintColouredChar ((*str++) + ext); + Sys_PrintColouredChar ((*str++) | ext); } - ApplyColour(7*256); + ApplyColour(CON_WHITEMASK); } else { diff --git a/engine/server/sv_sys_win.c b/engine/server/sv_sys_win.c index 93060917f..b250d1d4b 100644 --- a/engine/server/sv_sys_win.c +++ b/engine/server/sv_sys_win.c @@ -31,7 +31,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #endif #define SERVICENAME DISTRIBUTION"SV" - +// This is for remapping the Q3 color codes to character masks, including ^9 +conchar_t q3codemasks[MAXQ3COLOURS] = { + 0x00000000, // 0, black + 0x0c000000, // 1, red + 0x0a000000, // 2, green + 0x0e000000, // 3, yellow + 0x09000000, // 4, blue + 0x0b000000, // 5, cyan + 0x0d000000, // 6, magenta + 0x0f000000, // 7, white + 0x0f100000, // 8, half-alpha white (BX_COLOREDTEXT) + 0x07000000 // 9, "half-intensity" (BX_COLOREDTEXT) +}; static HANDLE hconsoleout; static HINSTANCE game_library; @@ -421,75 +433,54 @@ char *Sys_ConsoleInput (void) void ApplyColour(unsigned int chr) { - static int oldchar = 7*256; - chr = chr&~255; + static int oldchar = CON_WHITEMASK; + chr &= CON_FLAGSMASK; if (oldchar == chr) return; oldchar = chr; -#if 1 if (hconsoleout) { - int val; - val = FOREGROUND_INTENSITY; - switch(chr&CON_COLOURMASK) + unsigned short val = 0; + + // bits 28-31 of the console chars match up to the attributes for + // the CHAR_INFO struct exactly + if (chr & CON_NONCLEARBG) + val = (chr & (CON_FGMASK|CON_BGMASK) >> CON_FGSHIFT); + else { - case 0*256: - val = FOREGROUND_INTENSITY|FOREGROUND_INTENSITY; //don't allow secret messages (just hard to read) - break; - case 1*256: - val = FOREGROUND_RED|FOREGROUND_INTENSITY; - break; - case 2*256: - val = FOREGROUND_GREEN|FOREGROUND_INTENSITY; - break; - case 3*256: - val = FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_INTENSITY; - break; - case 4*256: - val = FOREGROUND_BLUE|FOREGROUND_INTENSITY; - break; - case 5*256: - val = FOREGROUND_RED|FOREGROUND_BLUE|FOREGROUND_INTENSITY; - break; - case 6*256: - val = FOREGROUND_GREEN|FOREGROUND_BLUE|FOREGROUND_INTENSITY; - break; - case 7*256: - val = FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE; - break; + int fg = (chr & CON_FGMASK) >> CON_FGSHIFT; + + switch (fg) + { + case COLOR_BLACK: // reverse ^0 like the Linux version + val = BACKGROUND_RED|BACKGROUND_GREEN|BACKGROUND_BLUE; + break; + case COLOR_WHITE: // reset to defaults? + val = FOREGROUND_RED|FOREGROUND_GREEN|FOREGROUND_BLUE; // use grey + break; + case COLOR_GREY: + val = FOREGROUND_INTENSITY; // color light grey as dark grey + break; + default: + val = fg; // send RGBI value as is + break; + } } + if ((chr & CON_HALFALPHA) && (val & ~FOREGROUND_INTENSITY)) + val &= ~FOREGROUND_INTENSITY; // strip intensity to fake alpha + SetConsoleTextAttribute(hconsoleout, val); } -#else - //does ansi work? - //no? - //windows sucks. - switch(chr&CON_COLOURMASK) - { - case 0*256: - printf("%c[%s;3%u;4%um", (char)27, - (chr & CON_BLINKTEXT)? "01" : "00", - (unsigned int)(0), - (unsigned int)(0)); - break; - default: - printf("%c[%s;3%u;4%um", (char)27, - (chr & CON_BLINKTEXT)? "01" : "00", - (unsigned int)(7), - (unsigned int)(0)); - break; - } -#endif } void Sys_PrintColouredChar(unsigned int chr) { ApplyColour(chr); - printf("%c", chr&255); + printf("%c", chr & CON_CHARMASK); } /* @@ -551,7 +542,7 @@ void Sys_Printf (char *fmt, ...) if (sys_colorconsole.value && hconsoleout) { - int ext = COLOR_WHITE<<8; + int ext = CON_WHITEMASK; int extstack[4]; int extstackdepth = 0; unsigned char *str = (unsigned char*)msg; @@ -562,21 +553,21 @@ void Sys_Printf (char *fmt, ...) if (*str == '^') { str++; - if (*str >= '0' && *str <= '7') + if (*str >= '0' && *str <= '9') { - ext = (*str++-'0')*256 + (ext&~CON_COLOURMASK); //change colour only. + ext = q3codemasks[*str++-'0'] | (ext&~CON_Q3MASK); //change colour only. continue; } else if (*str == 'a') { str++; - ext = (ext & ~CON_2NDCHARSETTEXT) + (CON_2NDCHARSETTEXT - (ext & CON_2NDCHARSETTEXT)); + ext ^= CON_2NDCHARSETTEXT; continue; } else if (*str == 'b') { str++; - ext = (ext & ~CON_BLINKTEXT) + (CON_BLINKTEXT - (ext & CON_BLINKTEXT)); + ext ^= CON_BLINKTEXT; continue; } else if (*str == 's') //store on stack (it's great for names) @@ -601,20 +592,20 @@ void Sys_Printf (char *fmt, ...) } else if (*str == '^') { - Sys_PrintColouredChar('^' + ext); + Sys_PrintColouredChar('^' | ext); str++; } else { - Sys_PrintColouredChar('^' + ext); - Sys_PrintColouredChar ((*str++) + ext); + Sys_PrintColouredChar('^' | ext); + Sys_PrintColouredChar ((*str++) | ext); } continue; } - Sys_PrintColouredChar ((*str++) + ext); + Sys_PrintColouredChar ((*str++) | ext); } - ApplyColour(7*256); + ApplyColour(CON_WHITEMASK); } else printf("%s", msg); diff --git a/engine/sw/d_local.h b/engine/sw/d_local.h index b5d60d529..2ca139fc6 100644 --- a/engine/sw/d_local.h +++ b/engine/sw/d_local.h @@ -153,8 +153,8 @@ int palremapsize; palremap_t *D_GetPaletteRemap(int red, int green, int blue, qboolean desaturate, qboolean fullbrights, int topcolor, int bottomcolor); qbyte *D_GetMenuTintPal(void); -extern palremap_t *D_IdentityRemap(void); -extern void D_DereferenceRemap(palremap_t *palremap); +palremap_t *D_IdentityRemap(void); +void D_DereferenceRemap(palremap_t *palremap); void D_InitTrans(void); // void Set_TransLevelI(int level); diff --git a/engine/sw/d_trans.c b/engine/sw/d_trans.c index 7791f20d7..a1981cec3 100644 --- a/engine/sw/d_trans.c +++ b/engine/sw/d_trans.c @@ -256,7 +256,7 @@ void MakePaletteRemaps(void) for (i = 2; i < palremapsize; i++) { palremaps[i].key = 0; - palremaps[i].references = 0; + palremaps[i].references = -2147483648; } } @@ -360,7 +360,7 @@ void BuildModulatedPalette(qbyte *indexes, int red, int green, int blue, qboolea palremap_t *D_GetPaletteRemap(int red, int green, int blue, qboolean desaturate, qboolean fullbrights, int topcolor, int bottomcolor) { - int i, key, deref = -1; + int i, key, deref = -1, dereflast = 1; topcolor = topcolor & 0xf; bottomcolor = bottomcolor & 0xf; @@ -374,11 +374,17 @@ palremap_t *D_GetPaletteRemap(int red, int green, int blue, qboolean desaturate, palremaps[i].b == blue && palremaps[i].key == key) { - palremaps[i].references++; + if (palremaps[i].references < 1) + palremaps[i].references = 1; + else + palremaps[i].references++; return palremaps + i; } - else if (palremaps[i].references <= 0) + else if (palremaps[i].references < dereflast) + { deref = i; + dereflast = palremaps[i].references; + } } if (deref < 2) // no remaps found and all maps are referenced @@ -420,8 +426,20 @@ palremap_t *RebuildMenuTint(void) void D_DereferenceRemap(palremap_t *palremap) { + static int dereftime; + if (palremap && palremap >= palremaps+2) - palremap->references--; + { + if (palremap->references < 2) + { + if (dereftime >= 0) + dereftime = -2147483648; // lowest negative 32-bit number + palremap->references = dereftime; + dereftime++; + } + else + palremap->references--; + } } qbyte *D_GetMenuTintPal(void) @@ -441,7 +459,6 @@ qbyte *D_GetMenuTintPal(void) return NULL; } - palremap_t *D_IdentityRemap(void) // TODO: explicitly inline this { return palremaps; diff --git a/engine/sw/sw_draw.c b/engine/sw/sw_draw.c index 771697b27..a81b2ee1f 100644 --- a/engine/sw/sw_draw.c +++ b/engine/sw/sw_draw.c @@ -666,22 +666,19 @@ void SWDraw_Character (int x, int y, unsigned int num) } /* -#define FindPalette(r,g,b) pal555to8[((r&0xF8)>>3)|((g&0xF8)<<2)|((b&0xF8)<<7)] -#define colourmask(p,r,g,b) FindPalette(host_basepal[p*3]*r, host_basepal[p*3+1]*g, host_basepal[p*3+2]*b) -#define draw(p) colourmask(p, (int)consolecolours[colour].r, (int)consolecolours[colour].g, (int)consolecolours[colour].b) -*/ - #define drawpal(r,g,b) pal555to8[(r|(g<<5)|(b<<10)) & consolecolours[colour].rgbmask] #define draw(p) drawpal(host_basepal[p*3]>>3,host_basepal[p*3+1]>>3,host_basepal[p*3+2]>>3) +*/ +#define draw(x) pr->pal[x] void SWDraw_ColouredCharacter (int x, int y, unsigned int num) { qbyte *source; int drawline; int row, col; extern cvar_t cl_noblink; - -int colour; + unsigned int colour, bgcolour; + qboolean drawbg = false; if (y <= -8) return; // totally off screen @@ -689,7 +686,11 @@ int colour; if (y > vid.height - 8 || x < 0 || x > vid.width - 8) return; - colour = (num&CON_COLOURMASK)/256; + colour = (num & CON_FGMASK) >> CON_FGSHIFT; + bgcolour = (num & CON_BGMASK) >> CON_BGSHIFT; + + if (num & CON_NONCLEARBG) + drawbg = true; if (num & CON_BLINKTEXT) { @@ -698,7 +699,7 @@ int colour; return; } - if (colour == COLOR_WHITE) + if (colour == COLOR_WHITE && !drawbg) { Draw_Character(x, y, num); return; @@ -720,30 +721,61 @@ int colour; if (r_pixbytes == 1) { + palremap_t *pr; qbyte *dest; dest = vid.conbuffer + y*vid.conrowbytes + x; - while (drawline--) + pr = D_GetPaletteRemap(consolecolours[colour].ir, + consolecolours[colour].ig, + consolecolours[colour].ib, + false, true, TOP_DEFAULT, BOTTOM_DEFAULT); + + if (drawbg) { - if (source[0]) - dest[0] = draw(source[0]); - if (source[1]) - dest[1] = draw(source[1]); - if (source[2]) - dest[2] = draw(source[2]); - if (source[3]) - dest[3] = draw(source[3]); - if (source[4]) - dest[4] = draw(source[4]); - if (source[5]) - dest[5] = draw(source[5]); - if (source[6]) - dest[6] = draw(source[6]); - if (source[7]) - dest[7] = draw(source[7]); - source += 128; - dest += vid.conrowbytes; + int bgidx = GetPalette(consolecolours[bgcolour].ir, + consolecolours[bgcolour].ig, + consolecolours[bgcolour].ib); + + while (drawline--) + { + dest[0] = source[0] ? draw(source[0]) : bgidx; + dest[1] = source[1] ? draw(source[1]) : bgidx; + dest[2] = source[2] ? draw(source[2]) : bgidx; + dest[3] = source[3] ? draw(source[3]) : bgidx; + dest[4] = source[4] ? draw(source[4]) : bgidx; + dest[5] = source[5] ? draw(source[5]) : bgidx; + dest[6] = source[6] ? draw(source[6]) : bgidx; + dest[7] = source[7] ? draw(source[7]) : bgidx; + source += 128; + dest += vid.conrowbytes; + } } + else + { + while (drawline--) + { + if (source[0]) + dest[0] = draw(source[0]); + if (source[1]) + dest[1] = draw(source[1]); + if (source[2]) + dest[2] = draw(source[2]); + if (source[3]) + dest[3] = draw(source[3]); + if (source[4]) + dest[4] = draw(source[4]); + if (source[5]) + dest[5] = draw(source[5]); + if (source[6]) + dest[6] = draw(source[6]); + if (source[7]) + dest[7] = draw(source[7]); + source += 128; + dest += vid.conrowbytes; + } + } + + D_DereferenceRemap(pr); } else if (r_pixbytes == 2) { @@ -754,39 +786,45 @@ int colour; dest16 = (unsigned short *)vid.conbuffer + y*vid.conrowbytes + x; - rm = consolecolours[colour].r*32; - gm = consolecolours[colour].g*32; - bm = consolecolours[colour].b*32; - - while (drawline--) + rm = consolecolours[colour].ir>>3; + gm = consolecolours[colour].ig>>3; + bm = consolecolours[colour].ib>>3; + + if (drawbg) { - for (i = 0; i < 8; i++) + int bgidx16 = (consolecolours[bgcolour].ir>>3) | + (consolecolours[bgcolour].ig>>3)<<5 | + (consolecolours[bgcolour].ib>>3)<<10; + + while (drawline--) { - if (source[i]) - dest16[i] = ((pal[source[i]*4+0]*bm/256)<<10)+ - ((pal[source[i]*4+1]*gm/256)<<5)+ - pal[source[i]*4+2]*rm/256; + for (i = 0; i < 8; i++) + { + if (source[i]) + dest16[i] = (((16+pal[source[i]*4+0]*bm)>>8)<<10)+ + (((16+pal[source[i]*4+1]*gm)>>8)<<5)+ + ((16+pal[source[i]*4+2]*rm)>>8); + else + dest16[i] = bgidx16; + } + source += 128; + dest16 += vid.conrowbytes; + } + } + else + { + while (drawline--) + { + for (i = 0; i < 8; i++) + { + if (source[i]) + dest16[i] = (((16+pal[source[i]*4+0]*bm)>>8)<<10)+ + (((16+pal[source[i]*4+1]*gm)>>8)<<5)+ + ((16+pal[source[i]*4+2]*rm)>>8); + } + source += 128; + dest16 += vid.conrowbytes; } - /* - if (source[0]) - dest16[0] = pal[draw(source[0])]; - if (source[1]) - dest16[1] = pal[draw(source[1])]; - if (source[2]) - dest16[2] = pal[draw(source[2])]; - if (source[3]) - dest16[3] = pal[draw(source[3])]; - if (source[4]) - dest16[4] = pal[draw(source[4])]; - if (source[5]) - dest16[5] = pal[draw(source[5])]; - if (source[6]) - dest16[6] = pal[draw(source[6])]; - if (source[7]) - dest16[7] = pal[draw(source[7])]; - */ - source += 128; - dest16 += vid.conrowbytes; } } else if (r_pixbytes == 4) @@ -796,19 +834,45 @@ int colour; unsigned char *pal = (unsigned char *)d_8to32table; dest = vid.conbuffer + (y*vid.conrowbytes + x)*r_pixbytes; - while (drawline--) + if (drawbg) { - for (i = 0; i < 8; i++) + while (drawline--) { - if (source[i]) + for (i = 0; i < 8; i++) { - dest[0+i*4] = pal[source[i]*4+0]*consolecolours[colour].b; - dest[1+i*4] = pal[source[i]*4+1]*consolecolours[colour].g; - dest[2+i*4] = pal[source[i]*4+2]*consolecolours[colour].r; - } + if (source[i]) + { + dest[0+i*4] = (128+pal[source[i]*4+0]*consolecolours[colour].ib)>>8; + dest[1+i*4] = (128+pal[source[i]*4+1]*consolecolours[colour].ig)>>8; + dest[2+i*4] = (128+pal[source[i]*4+2]*consolecolours[colour].ir)>>8; + } + else + { + dest[0+i*4] = consolecolours[bgcolour].ib; + dest[1+i*4] = consolecolours[bgcolour].ig; + dest[2+i*4] = consolecolours[bgcolour].ir; + } + } + source += 128; + dest += vid.conrowbytes*r_pixbytes; + } + } + else + { + while (drawline--) + { + for (i = 0; i < 8; i++) + { + if (source[i]) + { + dest[0+i*4] = (128+pal[source[i]*4+0]*consolecolours[colour].ib)>>8; + dest[1+i*4] = (128+pal[source[i]*4+1]*consolecolours[colour].ig)>>8; + dest[2+i*4] = (128+pal[source[i]*4+2]*consolecolours[colour].ir)>>8; + } + } + source += 128; + dest += vid.conrowbytes*r_pixbytes; } - source += 128; - dest += vid.conrowbytes*r_pixbytes; } } }