| 1366 | //============================================================================ |
| 1367 | |
| 1368 | UnicodeString GameTextManager::fetch( const Char *label, Bool *exists ) |
| 1369 | { |
| 1370 | DEBUG_ASSERTCRASH ( m_initialized, ("String Manager has not been m_initialized") ); |
| 1371 | |
| 1372 | if( m_stringInfo == nullptr ) |
| 1373 | { |
| 1374 | if( exists ) |
| 1375 | *exists = FALSE; |
| 1376 | return m_failed; |
| 1377 | } |
| 1378 | |
| 1379 | StringLookUp *lookUp; |
| 1380 | StringLookUp key; |
| 1381 | AsciiString lb; |
| 1382 | lb = label; |
| 1383 | key.info = nullptr; |
| 1384 | key.label = &lb; |
| 1385 | |
| 1386 | lookUp = (StringLookUp *) bsearch( &key, (void*) m_stringLUT, m_textCount, sizeof(StringLookUp), compareLUT ); |
| 1387 | |
| 1388 | if ( lookUp == nullptr && m_mapStringLUT && m_mapTextCount ) |
| 1389 | { |
| 1390 | lookUp = (StringLookUp *) bsearch( &key, (void*) m_mapStringLUT, m_mapTextCount, sizeof(StringLookUp), compareLUT ); |
| 1391 | } |
| 1392 | |
| 1393 | // GeneralsX @bugfix BenderAI 22/05/2026 Fallback to lower-priority CSF when override tables are incomplete. |
| 1394 | if ( lookUp == nullptr && m_fallbackStringLUT && m_fallbackTextCount ) |
| 1395 | { |
| 1396 | lookUp = (StringLookUp *) bsearch( &key, (void*) m_fallbackStringLUT, m_fallbackTextCount, sizeof(StringLookUp), compareLUT ); |
| 1397 | } |
| 1398 | |
| 1399 | if( lookUp == nullptr ) |
| 1400 | { |
| 1401 | |
| 1402 | // string not found |
| 1403 | if( exists ) |
| 1404 | *exists = FALSE; |
| 1405 | |
| 1406 | // See if we already have the missing string |
| 1407 | UnicodeString missingString; |
| 1408 | missingString.format(L"MISSING: '%hs'", label); |
| 1409 | |
| 1410 | NoString *noString = m_noStringList; |
| 1411 | |
| 1412 | while ( noString ) |
| 1413 | { |
| 1414 | if (noString->text == missingString) |
| 1415 | return missingString; |
| 1416 | |
| 1417 | noString = noString->next; |
| 1418 | } |
| 1419 | |
| 1420 | //DEBUG_LOG(("*** MISSING:'%s' ***", label)); |
| 1421 | // Remember file could have been altered at this point. |
| 1422 | noString = NEW NoString; |
| 1423 | noString->text = missingString; |
| 1424 | noString->next = m_noStringList; |
| 1425 | m_noStringList = noString; |
no test coverage detected