From 3e1538c95a8b4832f5aabc01a3c0816525e1651f Mon Sep 17 00:00:00 2001 From: avolkov Date: Thu, 4 May 2006 02:40:00 +0000 Subject: [PATCH] Playing failure sounds when entering text consistently; bug #884 git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@2348 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/sc2code/getchar.c | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/sc2/src/sc2code/getchar.c b/sc2/src/sc2code/getchar.c index acdd94a62..18f65e2d3 100644 --- a/sc2/src/sc2code/getchar.c +++ b/sc2/src/sc2code/getchar.c @@ -207,14 +207,20 @@ DoTextEntry (PTEXTENTRY_STATE pTES) pTES->JoystickMode = FALSE; chsize = getStringFromChar (chbuf, sizeof (chbuf), ch); - if (isWidePrintChar (ch) && chsize > 0 - && (pStr + len - pTES->BaseStr + chsize < pTES->MaxSize)) - { // insert character - memmove (pStr + chsize, pStr, len + 1); - memcpy (pStr, chbuf, chsize); - pStr += chsize; - ++pTES->CursorPos; - changed = TRUE; + if (isWidePrintChar (ch) && chsize > 0) + { + if (pStr + len - pTES->BaseStr + chsize < pTES->MaxSize) + { // insert character, when fits + memmove (pStr + chsize, pStr, len + 1); + memcpy (pStr, chbuf, chsize); + pStr += chsize; + ++pTES->CursorPos; + changed = TRUE; + } + else + { // does not fit + PlayMenuSound (MENU_SOUND_FAILURE); + } } ch = GetNextCharacter (); } @@ -378,6 +384,10 @@ DoTextEntry (PTEXTENTRY_STATE pTES) len += newch.len; changed = TRUE; } + else + { // does not fit + PlayMenuSound (MENU_SOUND_FAILURE); + } } } }