int __cdecl _mbsnicoll( const unsigned char *s1, const unsigned char *s2, size_t n ) { #if !defined (_WIN32) return _mbsnicmp(s1, s2, n); #else /* !defined (_WIN32) */ int ret; size_t bcnt1, bcnt2; if (n == 0) return 0; bcnt1 = _mbsnbcnt(s1, n); bcnt2 = _mbsnbcnt(s2, n); if (0 == (ret = __crtCompareStringA(__mblcid, NORM_IGNORECASE, s1, bcnt1, s2, bcnt2, __mbcodepage))) return _NLSCMPERROR; return ret - 2; #endif /* !defined (_WIN32) */ }
unsigned char * __cdecl _mbsninc( const unsigned char *string, size_t ccnt ) { if (string == NULL) return(NULL); return((char *)string + (unsigned int)_mbsnbcnt(string, ccnt)); }
LTBOOL CCredit::Init(char* sBuf) { // Sanity checks... if (!sBuf) return(LTFALSE); // Set simple members... m_nState = CS_START; s_bPause = LTFALSE; m_Pos.x = 320; m_Pos.y = 240; m_ePosition = CP_CENTER; m_bBig = LTFALSE; m_hAlign = CUI_HALIGN_CENTER; // Parse the text buffer and add each line as a separate string... char sString[256]; int i = 0; while (*sBuf) { if ((*sBuf == '\n') || (*sBuf == '\r') || (*sBuf == '\0')) { sString[i] = '\0'; AddString(sString); i = 0; while (((*sBuf == '\n') || (*sBuf == '\r'))) { sBuf = (char*)_mbsinc((const unsigned char*)sBuf); }; } else { int nCount = _mbsnbcnt((const unsigned char*)sBuf,1); memcpy(&sString[i], sBuf, nCount); i += nCount; sBuf = (char*)_mbsinc((const unsigned char*)sBuf); } } sString[i] = '\0'; if (strlen(sString) > 0) AddString(sString); // All done... FormatStrings(); return(LTTRUE); }
DBOOL CCredit::Init(CClientDE* pClientDE, char* sBuf) { // Sanity checks... if (!pClientDE) return(DFALSE); if (!sBuf) return(DFALSE); // Set simple members... m_pClientDE = pClientDE; m_nState = CS_START; s_bPause = DFALSE; // Parse the text buffer and add each line as a seperate string... char sString[256]; int i = 0; while (*sBuf) { if ((*sBuf == '\n') || (*sBuf == '\r') || (*sBuf == '\0')) { sString[i] = '\0'; AddString(sString); i = 0; while (((*sBuf == '\n') || (*sBuf == '\r'))) { sBuf = (char*)_mbsinc((const unsigned char*)sBuf); }; } else { int nCount = _mbsnbcnt((const unsigned char*)sBuf,1); memcpy(&sString[i], sBuf, nCount); i += nCount; sBuf = (char*)_mbsinc((const unsigned char*)sBuf); } } sString[i] = '\0'; if (_mbstrlen(sString) > 0) AddString(sString); // All done... return(DTRUE); }
static CHAR_TYPE *pcopy( CHAR_TYPE **pdst, CHAR_TYPE *dst, const CHAR_TYPE *b_src, const CHAR_TYPE *e_src ) { /*========================================================================*/ unsigned len; if( pdst == NULL ) return( dst ); *pdst = dst; len = e_src - b_src; if( len >= _MAX_PATH2 ) { len = _MAX_PATH2 - 1; } #if defined( __WIDECHAR__ ) || defined( __UNIX__ ) memcpy( dst, b_src, len * CHARSIZE ); dst[ len ] = NULLCHAR; return( dst + len + 1 ); #else len = _mbsnccnt( (unsigned char *)b_src, len ); /* # chars in len bytes */ _mbsncpy( (unsigned char *)dst, (unsigned char *)b_src, len ); /* copy the chars */ dst[ _mbsnbcnt( (unsigned char *)dst, len ) ] = NULLCHAR; return( dst + _mbsnbcnt( (unsigned char *)dst, len ) + 1 ); #endif }
static void copypart( CHAR_TYPE *buf, const CHAR_TYPE *p, int len, int maxlen ) { if( buf != NULL ) { if( len > maxlen ) len = maxlen; #if defined( __WIDECHAR__ ) || defined( __UNIX__ ) || defined( __RDOS__ ) || defined( __RDOSDEV__ ) memcpy( buf, p, len * CHARSIZE ); /*strncpy( buf, p, len ); */ buf[len ] = NULLCHAR; #else len = _mbsnccnt( (unsigned char *)p, len ); /* # chars in len bytes */ _mbsncpy( (unsigned char *)buf, (unsigned char *)p, len ); /* copy the chars */ buf[_mbsnbcnt( (unsigned char *)buf, len )] = NULLCHAR; #endif } }
static void copypart( CHAR_TYPE *buf, const CHAR_TYPE *p, int len, int maxlen ) { if( buf != NULL ) { if( len > maxlen ) len = maxlen; #ifdef __WIDECHAR__ memcpy( buf, p, len * CHARSIZE ); /* 07-jul-91 DJG */ /*strncpy( buf, p, len ); */ buf[ len ] = NULLCHAR; #else #ifdef __UNIX__ memcpy( buf, p, len * CHARSIZE ); buf[ len ] = NULLCHAR; #else len = _mbsnccnt( p, len ); /* # chars in len bytes */ _mbsncpy( buf, p, len ); /* copy the chars */ buf[ _mbsnbcnt( buf, len ) ] = NULLCHAR; #endif #endif } }
/* * _DisplayLineInWindowWithColor - as it sounds! */ void _DisplayLineInWindowWithColor( LPWDATA w, int line, LPSTR text, int c1, int c2, int extra, int startcol ) { #ifdef _MBCS LPBYTE tmp; #else LPSTR tmp; #endif char buff[256]; int start,end,a,spend,cnt1,cnt2; WORD i; HWND hwnd; hwnd = w->hwnd; /*** Find dimensions of line ***/ #ifdef _MBCS tmp = FAR_mbsninc( (LPBYTE)text, startcol ); a = FAR_mbslen( tmp ); if( line < 1 || line >= w->height ) return; start = 0; spend = end = w->width - extra; if( end > a ) end = a; cnt1 = FAR_mbsnbcnt( tmp, end - start ); cnt2 = spend - end; FAR_mbsnbcpy( (LPBYTE)buff, tmp, cnt1 - start ); FARmemset( buff + cnt1, ' ', cnt2 ); tmp = FAR_mbsninc( (LPBYTE)buff, cnt1 + cnt2 ); *tmp = '\0'; #else tmp = text; tmp += startcol; a = FARstrlen( tmp ); if( line < 1 || line >= w->height ) return; start = 0; spend = end = w->width - extra; if( end > a ) end = a; cnt1 = end - start; cnt2 = spend - end; FARmemcpy( buff, tmp, cnt1 ); FARmemset( buff + cnt1, ' ', cnt2 ); buff[cnt1 + cnt2] = 0; #endif line--; #if defined( __OS2__ ) { RECTL rcl; HPS ps; POINTL ptl; POINTL points[TXTBOX_COUNT]; ptl.x = 0; ptl.y = (w->y2 - w->y1) - (line+1)*w->ychar + w->base_offset; ps = WinGetPS( hwnd ); _SelectFont( ps ); GpiQueryTextBox( ps, startcol, w->tmpbuff->data, TXTBOX_COUNT, points ); rcl.xLeft = points[TXTBOX_BOTTOMRIGHT].x; #ifdef _MBCS GpiQueryTextBox( ps, __mbslen( (unsigned char *)buff ), buff, TXTBOX_COUNT, points ); #else GpiQueryTextBox( ps, strlen( buff ), buff, TXTBOX_COUNT, points ); #endif rcl.xRight = points[TXTBOX_BOTTOMRIGHT].x; rcl.yTop = (w->y2 - w->y1) - line*w->ychar; rcl.yBottom = rcl.yTop - w->ychar; WinFillRect( ps, &rcl, c1 ); GpiSetColor( ps, c2 ); #ifdef _MBCS GpiCharStringAt( ps, &ptl, _mbsnbcnt(buff,w->width), buff ); #else GpiCharStringAt( ps, &ptl, w->width, buff ); #endif WinReleasePS( ps ); } #else { HDC dc; // SIZE size; // RECT rect; dc = GetDC( hwnd ); _SetMyDC( dc, _ColorMap[c2], _ColorMap[c1] ); // #ifdef __NT__ // GetTextExtentPoint32( dc, buff, strlen(buff), &size ); // #else // GetTextExtentPoint( dc, buff, strlen(buff), &size ); // #endif // #ifdef _MBCS TextOut( dc, 0, line * w->ychar, (LPSTR)buff, FAR_mbsnbcnt( (LPBYTE)buff, w->width ) ); #else TextOut( dc, 0, line * w->ychar, buff, w->width ); #endif /*** Clear to end of line to remove any residue ***/ // GetClientRect( w->hwnd, &rect ); // rect.top = line * w->ychar; // rect.bottom = (line+1) * w->ychar ; // rect.left = size.cx; // FillRect( dc, &rect, w->brush ); ReleaseDC( hwnd, dc ); } #endif /*** Update the w->image array ***/ #ifdef _MBCS { mb_char mbc; unsigned char *curMbc; int count; i = line * w->width + startcol; for( count = 0, curMbc = (unsigned char *)buff; count < w->width - startcol; count++ ) { mbc = _mbsnextc( curMbc ); /* get the character */ curMbc = _mbsinc( curMbc ); /* point to next char */ w->image[i + count] = mbc; /* store it in w->image */ } } #else i = line * w->width + startcol; FARmemcpy( &w->image[i], buff, w->width - startcol ); #endif } /* _DisplayLineInWindowWithColor */
void CCredits::AddCredits() { // Sanity checks... if (!m_pClientDE) return; // Set the static info... if (!CCredit::SetStaticInfo(m_pClientDE, GetMode(), IsClearingScreen())) { return; } // Get the credits text buffer... char* sName = NULL; #ifdef _ADDON if (IsIntro()) sName = "INTRO_AO"; else sName = "CREDITS_AO"; #else if (IsIntro()) sName = "INTRO"; else sName = "CREDITS"; #endif void* hModule = NULL; m_pClientDE->GetEngineHook("cres_hinstance", &hModule); char* sBuf = CreditsWin_GetTextBuffer(sName, hModule); if (!sBuf) return; char sCredit[1024]; int i = 0; while (*sBuf) { if (*sBuf == '#' && *((char*)_mbsinc((const unsigned char*)sBuf)) == '#') { sCredit[i] = '\0'; if (_mbsnbcmp((const unsigned char*)sCredit, (const unsigned char*)">END", 4) == 0) // end? { return; } AddCredit(sCredit); i = 0; sBuf = (char*)_mbsinc((const unsigned char*)sBuf); sBuf = (char*)_mbsinc((const unsigned char*)sBuf); while (*sBuf != '\0' && ((*sBuf == '\n') || (*sBuf == '\r'))) sBuf++; } else { int nCount = _mbsnbcnt((const unsigned char*)sBuf,1); memcpy(&sCredit[i], sBuf, nCount); i += nCount; sBuf = (char*)_mbsinc((const unsigned char*)sBuf); } } }