diff --git a/src/acs/call-funcs.cpp b/src/acs/call-funcs.cpp index 780455f07..d3039dab9 100644 --- a/src/acs/call-funcs.cpp +++ b/src/acs/call-funcs.cpp @@ -555,28 +555,6 @@ bool CallFunc_EndPrint(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Wo (void)argV; (void)argC; - if (ACS_ActivatorIsLocal(thread) == true) - { - HU_SetCEchoDuration(5); - HU_DoCEcho(thread->printBuf.data()); - } - - thread->printBuf.drop(); - return false; -} - -/*-------------------------------------------------- - bool CallFunc_EndPrintTitlecard(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC) - - One of the ACS wrappers for Titlecard CEcho. This - version only prints if the activator is a - display player. ---------------------------------------------------*/ -bool CallFunc_EndPrintTitlecard(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC) -{ - (void)argV; - (void)argC; - if (ACS_ActivatorIsLocal(thread) == true) HU_DoTitlecardCEcho(thread->printBuf.data()); @@ -947,30 +925,11 @@ bool CallFunc_EndPrintBold(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM (void)argV; (void)argC; - HU_SetCEchoDuration(5); - HU_DoCEcho(thread->printBuf.data()); - - thread->printBuf.drop(); - return false; -} - -/*-------------------------------------------------- - bool CallFunc_EndPrintBoldTitlecard(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC) - - One of the ACS wrappers for Titlecard CEcho. This - version prints for all players. ---------------------------------------------------*/ -bool CallFunc_EndPrintBoldTitlecard(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC) -{ - (void)argV; - (void)argC; - HU_DoTitlecardCEcho(thread->printBuf.data()); thread->printBuf.drop(); return false; } - /*-------------------------------------------------- bool CallFunc_PlayerTeam(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC) diff --git a/src/acs/call-funcs.hpp b/src/acs/call-funcs.hpp index 9e634c0d9..4bbe3eaec 100644 --- a/src/acs/call-funcs.hpp +++ b/src/acs/call-funcs.hpp @@ -55,7 +55,6 @@ bool CallFunc_ChangeCeiling(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSV bool CallFunc_LineSide(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); bool CallFunc_ClearLineSpecial(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); bool CallFunc_EndPrint(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); -bool CallFunc_EndPrintTitlecard(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); bool CallFunc_PlayerCount(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); bool CallFunc_GameType(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); bool CallFunc_GameSpeed(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); @@ -66,7 +65,6 @@ bool CallFunc_SetLineTexture(ACSVM::Thread *thread, const ACSVM::Word *argV, ACS bool CallFunc_SetLineSpecial(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); bool CallFunc_ThingSound(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); bool CallFunc_EndPrintBold(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); -bool CallFunc_EndPrintBoldTitlecard(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); bool CallFunc_PlayerTeam(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); bool CallFunc_PlayerRings(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); bool CallFunc_PlayerScore(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC); diff --git a/src/acs/environment.cpp b/src/acs/environment.cpp index 28078967d..b3093e3ed 100644 --- a/src/acs/environment.cpp +++ b/src/acs/environment.cpp @@ -101,11 +101,6 @@ Environment::Environment() addCodeDataACS0(122, {"", 0, addCallFunc(CallFunc_PlayerScore)}); - // Lat: Titlecard CEcho. I'm not sure if I should be putting it here. - // @TODO: Confirm this is fine? - addCodeDataACS0( 123, {"", 0, addCallFunc(CallFunc_EndPrintTitlecard)}); - addCodeDataACS0( 124, {"", 0, addCallFunc(CallFunc_EndPrintBoldTitlecard)}); - // 136 to 137: Implemented by ACSVM // 157: Implemented by ACSVM diff --git a/src/hu_stuff.c b/src/hu_stuff.c index 8521049a8..a68f4857b 100644 --- a/src/hu_stuff.c +++ b/src/hu_stuff.c @@ -161,7 +161,7 @@ static tic_t cechotimer = 0; static tic_t cechoduration = 5*TICRATE; static INT32 cechoflags = 0; -static char tcechotext[48]; // the text is wide so only 48 chars should do. +static char tcechotext[1024]; // buffer for the titlecard text static tic_t tcechotimer = 0; // goes up by 1 each frame this is active static tic_t tcechoduration = 0; // Set automatically @@ -2016,8 +2016,59 @@ static void HU_DrawTitlecardCEcho(void) { if (tcechotimer) { - INT32 w = V_TitleCardStringWidth(tcechotext); - V_DrawTitleCardString(160 -w/2, 90, tcechotext, 0, false, tcechotimer, TICRATE*4); + INT32 i = 0; + INT32 y = (BASEVIDHEIGHT/2)-16; + INT32 pnumlines = 0; + INT32 timeroffset = 0; + + char *line; + char *echoptr; + char temp[1024]; + + for (i = 0; tcechotext[i] != '\0'; ++i) + if (tcechotext[i] == '\\') + pnumlines++; + + y -= (pnumlines-1)*16; + + // Prevent crashing because I'm sick of this + if (y < 0) + { + CONS_Alert(CONS_WARNING, "CEcho contained too many lines, not displaying\n"); + cechotimer = 0; + return; + } + + strcpy(temp, tcechotext); + echoptr = &temp[0]; + + while (*echoptr != '\0') + { + INT32 w; + INT32 timer = (INT32)(tcechotimer - timeroffset); + + if (timer <= 0) + return; // we don't care. + + line = strchr(echoptr, '\\'); + + if (line == NULL) + break; + + *line = '\0'; + + w = V_TitleCardStringWidth(echoptr); + V_DrawTitleCardString(BASEVIDWIDTH/2 -w/2, y, echoptr, 0, false, timer, TICRATE*4); + + y += 32; + + // offset the timer for the next line. + timeroffset += strlen(echoptr); + + // set the ptr to the \0 we made and advance it because we don't want an empty string. + echoptr = line; + echoptr++; + } } } @@ -2636,6 +2687,8 @@ void HU_DoTitlecardCEcho(const char *msg) I_OutputMsg("%s\n", msg); // print to log strncpy(tcechotext, msg, sizeof(tcechotext)); + strncat(tcechotext, "\\", sizeof(tcechotext) - strlen(tcechotext) - 1); + cechotext[sizeof(tcechotext) - 1] = '\0'; tcechotimer = 1; tcechoduration = TICRATE*6 + strlen(tcechotext); } \ No newline at end of file