OpenClonk
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros
Standard.cpp File Reference
#include "C4Include.h"
Include dependency graph for Standard.cpp:

Go to the source code of this file.

Functions

int32_t Distance (int32_t iX1, int32_t iY1, int32_t iX2, int32_t iY2)
 
int Angle (int iX1, int iY1, int iX2, int iY2)
 
int Pow (int base, int exponent)
 
bool IsIdentifier (char cChar)
 
int32_t StrToI32 (const char *str, int base, const char **scan_end)
 
void SCopy (const char *szSource, char *sTarget, size_t iMaxL)
 
void SCopy (const char *szSource, char *sTarget)
 
void SCopyUntil (const char *szSource, char *sTarget, char cUntil, int iMaxL, int iIndex)
 
void SCopyUntil (const char *szSource, char *sTarget, const char *sUntil, size_t iMaxL)
 
bool SEqualUntil (const char *szStr1, const char *szStr2, char cWild)
 
bool SEqual2 (const char *szStr1, const char *szStr2)
 
bool SEqualNoCase (const char *szStr1, const char *szStr2, int iLen)
 
bool SEqual2NoCase (const char *szStr1, const char *szStr2, int iLen)
 
int SCharPos (char cTarget, const char *szInStr, int iIndex)
 
int SCharLastPos (char cTarget, const char *szInStr)
 
void SAppend (const char *szSource, char *szTarget, int iMaxL)
 
void SAppendChar (char cChar, char *szStr)
 
bool SCopySegment (const char *szString, int iSegment, char *sTarget, char cSeparator, int iMaxL, bool fSkipWhitespace)
 
bool SCopySegmentEx (const char *szString, int iSegment, char *sTarget, char cSep1, char cSep2, int iMaxL, bool fSkipWhitespace)
 
unsigned int SCharCount (char cTarget, const char *szInStr, const char *cpUntil)
 
unsigned int SCharCountEx (const char *szString, const char *szCharList)
 
void SReplaceChar (char *str, char fc, char tc)
 
void SCapitalize (char *str)
 
const char * SSearch (const char *szString, const char *szIndex)
 
const char * SSearchNoCase (const char *szString, const char *szIndex)
 
void SWordWrap (char *szText, char cSpace, char cSepa, int iMaxLine)
 
const char * SAdvanceSpace (const char *szSPos)
 
const char * SRewindSpace (const char *szSPos, const char *pBegin)
 
const char * SAdvancePast (const char *szSPos, char cPast)
 
void SCopyIdentifier (const char *szSource, char *sTarget, int iMaxL)
 
int SClearFrontBack (char *szString, char cClear)
 
void SNewSegment (char *szStr, const char *szSepa)
 
int SGetLine (const char *szText, const char *cpPosition)
 
int SLineGetCharacters (const char *szText, const char *cpPosition)
 
void SInsert (char *szString, const char *szInsert, int iPosition, int iMaxLen)
 
void SDelete (char *szString, int iLen, int iPosition)
 
bool SCopyEnclosed (const char *szSource, char cOpen, char cClose, char *sTarget, int iSize)
 
bool SGetModule (const char *szList, int iIndex, char *sTarget, int iSize)
 
bool SIsModule (const char *szList, const char *szString, int *ipIndex, bool fCaseSensitive)
 
bool SAddModule (char *szList, const char *szModule, bool fCaseSensitive)
 
bool SAddModules (char *szList, const char *szModules, bool fCaseSensitive)
 
bool SRemoveModule (char *szList, const char *szModule, bool fCaseSensitive)
 
bool SRemoveModules (char *szList, const char *szModules, bool fCaseSensitive)
 
int SModuleCount (const char *szList)
 
bool SWildcardMatchEx (const char *szString, const char *szWildcard)
 
bool IsValidUtf8 (const char *text, int length)
 
uint32_t GetNextUTF8Character (const char **pszString)
 
int GetCharacterCount (const char *s)
 
std::string vstrprintf (const char *format, va_list args)
 
std::string strprintf (const char *format,...)
 

Function Documentation

int Angle ( int  iX1,
int  iY1,
int  iX2,
int  iY2 
)

Definition at line 35 of file Standard.cpp.

References Abs().

Referenced by C4Object::Draw(), C4ValueProviderCosV::Execute(), C4ValueProviderSinV::Execute(), C4Command::FlightControl(), InitCoreFunctionMap(), C4Command::JumpControl(), and C4Command::MoveTo().

36 {
37  int iAngle = (int) ( 180.0 * atan2( float(Abs(iY1-iY2)), float(Abs(iX1-iX2)) ) / M_PI );
38  if (iX2>iX1 )
39  { if (iY2<iY1) iAngle = 90-iAngle; else iAngle = 90+iAngle; }
40  else
41  { if (iY2<iY1) iAngle = 270+iAngle; else iAngle = 270-iAngle; }
42  return iAngle;
43 }
T Abs(T val)
Definition: Standard.h:44

Here is the call graph for this function:

Here is the caller graph for this function:

int32_t Distance ( int32_t  iX1,
int32_t  iY1,
int32_t  iX2,
int32_t  iY2 
)

Definition at line 24 of file Standard.cpp.

Referenced by C4MapScriptAlgoLines::C4MapScriptAlgoLines(), C4PathFinderRay::Execute(), C4ValueProviderAbsX::Execute(), C4ValueProviderDist::Execute(), C4Command::FlightControl(), C4Command::Get(), C4ViewportList::GetAudibility(), InitCoreFunctionMap(), C4Command::JumpControl(), C4Command::MoveTo(), SumPathLength::operator()(), C4Command::Put(), C4Object::SetAudibilityAt(), and TrajectoryDistance().

25 {
26  int64_t dx = int64_t(iX1)-iX2, dy = int64_t(iY1)-iY2;
27  int64_t d2 = dx*dx+dy*dy;
28  if (d2 < 0) return -1;
29  int32_t dist = int32_t(sqrt(double(d2)));
30  if (int64_t(dist)*dist < d2) ++dist;
31  if (int64_t(dist)*dist > d2) --dist;
32  return dist;
33 }

Here is the caller graph for this function:

int GetCharacterCount ( const char *  s)

Definition at line 762 of file Standard.cpp.

References s.

763 {
764  int l = 0;
765  while (*s)
766  {
767  unsigned char c = *s;
768  if (c < 128 || c > 247)
769  {
770  ++l;
771  s += 1;
772  }
773  else if (c > 191 && c < 224)
774  {
775  ++l;
776  s += 2;
777  }
778  else if (c >= 224 && c <= 239)
779  {
780  ++l;
781  s += 3;
782  }
783  else if (c >= 240 && c <= 247)
784  {
785  ++l;
786  s += 4;
787  }
788  else assert(false);
789  }
790  return l;
791 }
#define s
uint32_t GetNextUTF8Character ( const char **  pszString)

Definition at line 726 of file Standard.cpp.

Referenced by GetNextCharacter().

727 {
728  // assume the current character is UTF8 already (i.e., highest bit set)
729  const uint32_t REPLACEMENT_CHARACTER = 0xFFFDu;
730  const char *szString = *pszString;
731  unsigned char c = *szString++;
732  uint32_t dwResult = REPLACEMENT_CHARACTER;
733  assert(c>127);
734  if (c>191 && c<224)
735  {
736  unsigned char c2 = *szString++;
737  if ((c2 & 192) != 128) { *pszString = szString; return REPLACEMENT_CHARACTER; }
738  dwResult = (int(c&31)<<6) | (c2&63); // two char code
739  }
740  else if (c >= 224 && c <= 239)
741  {
742  unsigned char c2 = *szString++;
743  if ((c2 & 192) != 128) { *pszString = szString; return REPLACEMENT_CHARACTER; }
744  unsigned char c3 = *szString++;
745  if ((c3 & 192) != 128) { *pszString = szString; return REPLACEMENT_CHARACTER; }
746  dwResult = (int(c&15)<<12) | (int(c2&63)<<6) | int(c3&63); // three char code
747  }
748  else if (c >= 240 && c <= 247)
749  {
750  unsigned char c2 = *szString++;
751  if ((c2 & 192) != 128) { *pszString = szString; return REPLACEMENT_CHARACTER; }
752  unsigned char c3 = *szString++;
753  if ((c3 & 192) != 128) { *pszString = szString; return REPLACEMENT_CHARACTER; }
754  unsigned char c4 = *szString++;
755  if ((c4 & 192) != 128) { *pszString = szString; return REPLACEMENT_CHARACTER; }
756  dwResult = (int(c&7)<<18) | (int(c2&63)<<12) | (int(c3&63)<<6) | int(c4&63); // four char code
757  }
758  *pszString = szString;
759  return dwResult;
760 }

Here is the caller graph for this function:

bool IsIdentifier ( char  cChar)

Definition at line 67 of file Standard.cpp.

References Inside().

Referenced by C4MaterialMap::LoadEnumeration(), C4LangStringTable::ReplaceStrings(), and SCopyIdentifier().

68 {
69  if (Inside(cChar,'A','Z')) return true;
70  if (Inside(cChar,'a','z')) return true;
71  if (Inside(cChar,'0','9')) return true;
72  if (cChar=='_') return true;
73  if (cChar=='~') return true;
74  if (cChar=='+') return true;
75  if (cChar=='-') return true;
76  return false;
77 }
bool Inside(T ival, U lbound, V rbound)
Definition: Standard.h:45

Here is the call graph for this function:

Here is the caller graph for this function:

bool IsValidUtf8 ( const char *  text,
int  length 
)

Definition at line 673 of file Standard.cpp.

Referenced by CStdFont::DrawText(), StdStrBuf::EnsureUnicode(), and CStdFont::GetTextExtent().

674 {
675  // Intentionally using a C-style cast to always get a uint8_t* from char*;
676  // reinterpret_cast would fail here on platforms that have unsigned char,
677  // while static_cast would fail on platforms with a signed char type
678  const uint8_t *input = (const uint8_t*)(text);
679 
680  for (const uint8_t *cursor = input; length < 0 ? *cursor != 0 : cursor - input < length; ++cursor)
681  {
682  int continuation_bytes = utf8_continuation_byte_table[*cursor];
683  if (continuation_bytes < 0)
684  return false;
685  else if (continuation_bytes == 0)
686  {
687  // Standard 7-bit ASCII value (i.e., 1 byte codepoint)
688  continue;
689  }
690  else if (length >= 0 && cursor - input + continuation_bytes >= length)
691  {
692  // Too few remaining bytes
693  return false;
694  }
695 
696  // Compute character value, so we can detect overlong sequences
697  assert((*cursor & 0xC0) == 0xC0);
698  uint32_t value = *cursor;
699  // strip length bits off the start byte
700  value &= (0xFF >> (continuation_bytes + 1));
701  for (int byte = 0; byte < continuation_bytes; ++byte)
702  {
703  // check that this is actually a continuation byte
704  if ((cursor[byte + 1] & 0xC0) != 0x80)
705  return false;
706  // merge continuation byte into value
707  value <<= 6;
708  value |= cursor[byte + 1] & 0x3F;
709  }
710  // make sure this is not overlong
711  if (value < utf8_min_char_value[continuation_bytes])
712  return false;
713  // and also not beyond 0x10FFFF
714  if (value > 0x10FFFF)
715  return false;
716  // and also not a wrongly encoded UTF-16 surrogate half
717  if (value >= 0xD800 && value <= 0xDFFF)
718  return false;
719  cursor += continuation_bytes;
720  }
721  // Looks fine
722  return true;
723 }

Here is the caller graph for this function:

int Pow ( int  base,
int  exponent 
)

Definition at line 46 of file Standard.cpp.

Referenced by C4AulCompiler::ConstexprEvaluator::visit().

47 {
48  if (exponent < 0) return 0;
49 
50  int result = 1;
51 
52  if (exponent & 1) result = base;
53  exponent >>= 1;
54 
55  while (exponent)
56  {
57  base *= base;
58  if (exponent & 1) result *= base;
59  exponent >>= 1;
60  }
61 
62  return result;
63 }

Here is the caller graph for this function:

bool SAddModule ( char *  szList,
const char *  szModule,
bool  fCaseSensitive 
)

Definition at line 534 of file Standard.cpp.

References SAppend(), SIsModule(), and SNewSegment().

Referenced by C4Config::AddModule(), C4Console::FileOpenWPlrs(), C4Application::ParseCommandLine(), SAddModules(), and C4StartupMainDlg::UpdateParticipants().

535 {
536  // Safety / no empties
537  if (!szList || !szModule || !szModule[0]) return false;
538  // Already a module?
539  if (SIsModule(szList,szModule,nullptr,fCaseSensitive)) return false;
540  // New segment, add string
541  SNewSegment(szList);
542  SAppend(szModule,szList);
543  // Success
544  return true;
545 }
void SAppend(const char *szSource, char *szTarget, int iMaxL)
Definition: Standard.cpp:234
bool SIsModule(const char *szList, const char *szString, int *ipIndex, bool fCaseSensitive)
Definition: Standard.cpp:518
void SNewSegment(char *szStr, const char *szSepa)
Definition: Standard.cpp:445

Here is the call graph for this function:

Here is the caller graph for this function:

bool SAddModules ( char *  szList,
const char *  szModules,
bool  fCaseSensitive 
)

Definition at line 547 of file Standard.cpp.

References SAddModule(), and SGetModule().

Referenced by C4StartupScenSelDlg::KeyCheat2().

548 {
549  // Safety / no empties
550  if (!szList || !szModules || !szModules[0]) return false;
551  // Add modules
552  char szModule[1024+1]; // limited
553  for (int cnt=0; SGetModule(szModules,cnt,szModule,1024); cnt++)
554  SAddModule(szList,szModule,fCaseSensitive);
555  // Success
556  return true;
557 }
bool SGetModule(const char *szList, int iIndex, char *sTarget, int iSize)
Definition: Standard.cpp:510
bool SAddModule(char *szList, const char *szModule, bool fCaseSensitive)
Definition: Standard.cpp:534

Here is the call graph for this function:

Here is the caller graph for this function:

const char* SAdvancePast ( const char *  szSPos,
char  cPast 
)

Definition at line 409 of file Standard.cpp.

Referenced by C4GameMessage::Append().

410 {
411  if (!szSPos) return nullptr;
412  while (*szSPos)
413  {
414  if (*szSPos==cPast) { szSPos++; break; }
415  szSPos++;
416  }
417  return szSPos;
418 }

Here is the caller graph for this function:

const char* SAdvanceSpace ( const char *  szSPos)

Definition at line 391 of file Standard.cpp.

References IsWhiteSpace().

Referenced by C4MaterialMap::LoadEnumeration(), SCopySegment(), and SCopySegmentEx().

392 {
393  if (!szSPos) return nullptr;
394  while (IsWhiteSpace(*szSPos)) szSPos++;
395  return szSPos;
396 }
bool IsWhiteSpace(char cChar)
Definition: Standard.h:76

Here is the call graph for this function:

Here is the caller graph for this function:

void SAppend ( const char *  szSource,
char *  szTarget,
int  iMaxL 
)

Definition at line 234 of file Standard.cpp.

References SCopy(), and SLen().

Referenced by C4Config::AtExePath(), C4Config::AtNetworkPath(), C4Config::AtScreenshotPath(), C4Config::AtSystemDataPath(), C4Config::AtTempPath(), C4Config::AtTempUpdatePath(), C4Config::AtUserDataPath(), C4Group_CopyItem(), C4Group_MoveItem(), C4Group_PackDirectoryTo(), CopyDirectory(), DefaultExtension(), C4ConfigGeneral::DeterminePaths(), C4UpdatePackage::DoGrpUpdate(), EnforceExtension(), EraseDirectory(), C4Group::ExtractEntry(), C4Console::FileOpenWPlrs(), C4Network2ResList::FindTempResFileName(), ForEachFile(), C4ConfigGeneral::GetLanguageSequence(), C4ComponentHost::GetLanguageString(), C4Language::GetPackGroups(), C4Network2::Join(), C4SoundEffect::Load(), C4DefGraphics::Load(), C4UpdatePackage::MkUp(), RealPath(), C4Group::Rename(), C4ScenarioListLoader::Entry::RenameTo(), SAddModule(), C4ObjectInfo::Save(), C4Group::Save(), C4MaterialMap::SaveEnumeration(), C4Surface::SavePNG(), SetClientPrefix(), SNewSegment(), C4Playback::StreamToRecord(), and C4ObjectList::Write().

235 {
236  if (iMaxL == -1)
237  SCopy(szSource, szTarget + SLen(szTarget));
238  else
239  SCopy(szSource, szTarget + SLen(szTarget), iMaxL - SLen(szTarget));
240 }
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:129
size_t SLen(const char *sptr)
Definition: Standard.h:78

Here is the call graph for this function:

Here is the caller graph for this function:

void SAppendChar ( char  cChar,
char *  szStr 
)

Definition at line 242 of file Standard.cpp.

Referenced by AppendBackslash(), C4UpdatePackage::DoGrpUpdate(), C4ConfigGeneral::GetLanguageSequence(), C4Language::GetPackGroups(), and SetClientPrefix().

243 {
244  if (!szStr) return;
245  char *cPos;
246  for (cPos=szStr; *cPos; cPos++) {}
247  *cPos=cChar; *(cPos+1)=0;
248 }

Here is the caller graph for this function:

void SCapitalize ( char *  str)

Definition at line 331 of file Standard.cpp.

References CharCapital().

Referenced by C4ChatInputDialog::OnChatInput().

332 {
333  while (str && *str)
334  {
335  *str=CharCapital(*str);
336  str++;
337  }
338 }
char CharCapital(char cChar)
Definition: Standard.h:74

Here is the call graph for this function:

Here is the caller graph for this function:

unsigned int SCharCount ( char  cTarget,
const char *  szInStr,
const char *  cpUntil 
)

Definition at line 297 of file Standard.cpp.

References iResult.

Referenced by C4Group_IsExcluded(), C4ObjectInfoCore::Default(), C4Group::Delete(), C4Group::Extract(), C4SoundSystem::GetEffect(), C4MessageBoard::GetMessagePlayer(), GetParentPath(), IsSmallInputQuery(), IsWildcardString(), main(), C4Group::Merge(), C4Group::OpenAsChild(), C4Game::QuickSave(), SCharCountEx(), and SortRank().

298 {
299  unsigned int iResult=0;
300  // Scan string
301  while (*szInStr)
302  {
303  // End position reached (end character is not included)
304  if (szInStr==cpUntil) return iResult;
305  // Character found
306  if (*szInStr==cTarget) iResult++;
307  // Advance
308  szInStr++;
309  }
310  // Done
311  return iResult;
312 }
int iResult
Definition: C4GroupMain.cpp:39

Here is the caller graph for this function:

unsigned int SCharCountEx ( const char *  szString,
const char *  szCharList 
)

Definition at line 314 of file Standard.cpp.

References iResult, and SCharCount().

Referenced by C4LeagueSignupDialog::UserClose().

315 {
316  unsigned int iResult = 0;
317  while ( *szCharList )
318  {
319  iResult += SCharCount( *szCharList, szString );
320  szCharList++;
321  }
322  return iResult;
323 }
unsigned int SCharCount(char cTarget, const char *szInStr, const char *cpUntil)
Definition: Standard.cpp:297
int iResult
Definition: C4GroupMain.cpp:39

Here is the call graph for this function:

Here is the caller graph for this function:

int SCharLastPos ( char  cTarget,
const char *  szInStr 
)

Definition at line 224 of file Standard.cpp.

Referenced by EraseDirectory(), C4DefGraphics::Load(), C4Surface::Load(), C4PlayerControlAssignment::ResolveRefs(), and TruncatePath().

225 {
226  const char *cpos;
227  int ccpos,lcpos;
228  if (!szInStr) return -1;
229  for (cpos=szInStr,ccpos=0,lcpos=-1; *cpos; cpos++,ccpos++)
230  if (*cpos==cTarget) lcpos=ccpos;
231  return lcpos;
232 }

Here is the caller graph for this function:

int SCharPos ( char  cTarget,
const char *  szInStr,
int  iIndex 
)

Definition at line 210 of file Standard.cpp.

Referenced by CStdFont::BreakMessage(), C4MenuItem::DoTextProgress(), CStdFont::DrawText(), FnParTexCol(), ForEachFile(), C4ComponentHost::GetLanguageString(), CStdFont::GetTextExtent(), C4AchievementGraphics::Init(), C4RankSystem::Load(), C4DefGraphics::Load(), C4GameResList::LoadFoldersWithLocalDefs(), C4Game::LoadScenarioComponents(), MakeFilenameFromTitle(), MakeOriginalFilename(), C4MainMenu::MenuCommand(), C4MessageInput::ProcessCommand(), C4Markup::Read(), SCopyEnclosed(), SCopySegment(), SCopySegmentEx(), and SRemoveModule().

211 {
212  const char *cpos;
213  int ccpos;
214  if (!szInStr) return -1;
215  for (cpos=szInStr,ccpos=0; *cpos; cpos++,ccpos++)
216  if (*cpos==cTarget)
217  {
218  if (iIndex==0) return ccpos;
219  else iIndex--;
220  }
221  return -1;
222 }

Here is the caller graph for this function:

int SClearFrontBack ( char *  szString,
char  cClear 
)

Definition at line 432 of file Standard.cpp.

References SLen().

Referenced by C4ObjectInfoCore::Default(), C4Application::ParseCommandLine(), and SGetModule().

433 {
434  int cleared=0;
435  char *cpos;
436  if (!szString) return 0;
437  for (cpos=szString; *cpos && (*cpos==cClear); cpos++,cleared++) {}
438  // strcpy is undefined when used on overlapping strings...
439  if (cpos!=szString) memmove(szString, cpos, SLen(cpos) + 1);
440  for (cpos=szString+SLen(szString)-1; (cpos>szString) && (*cpos==cClear); cpos--,cleared++)
441  *cpos=0x00;
442  return cleared;
443 }
size_t SLen(const char *sptr)
Definition: Standard.h:78

Here is the call graph for this function:

Here is the caller graph for this function:

void SCopy ( const char *  szSource,
char *  sTarget,
size_t  iMaxL 
)

Definition at line 129 of file Standard.cpp.

Referenced by C4Group::AccessEntry(), C4Group::AccessNextEntry(), C4MainMenu::ActivateNewPlayer(), C4MainMenu::ActivateSavegame(), C4NameList::Add(), C4MessageInput::AddCommand(), CStdFile::Append(), C4Config::AtExePath(), C4Config::AtNetworkPath(), C4Config::AtScreenshotPath(), C4Config::AtSystemDataPath(), C4Config::AtTempPath(), C4Config::AtTempUpdatePath(), C4Config::AtUserDataPath(), CStdFont::BreakMessage(), C4AdditionalDefGraphics::C4AdditionalDefGraphics(), C4DefGraphicsPtrBackupEntry::C4DefGraphicsPtrBackupEntry(), C4Group_CopyItem(), C4Group_MoveItem(), C4Group_PackDirectory(), C4Group_PackDirectoryTo(), C4Group_SetTempPath(), C4Group_UnpackDirectory(), C4MCOverlay::C4MCOverlay(), C4MenuItem::C4MenuItem(), C4PortraitSelDlg::C4PortraitSelDlg(), C4StartupPlrPropertiesDlg::C4StartupPlrPropertiesDlg(), C4Team::C4Team(), C4Network2Res::CalculateSHA(), CopyDirectory(), CStdFile::Create(), C4Network2ResList::CreateNetworkFolder(), C4ConfigGeneral::CreateSaveFolder(), C4TeamList::CreateTeam(), C4ObjectInfoCore::Default(), C4ToolsDlg::Default(), C4PlayerInfoCore::Default(), C4ConfigGeneral::DefaultLanguage(), C4Player::DefaultRuntimeData(), C4Network2Res::Derive(), C4ConfigGeneral::DeterminePaths(), DirectoryExists(), C4StartupNetDlg::DoOK(), C4MainMenu::DoRefillInternal(), C4Game::DrawCrewOverheadText(), CStdFont::DrawText(), EnforceExtension(), C4Menu::Enter(), EraseDirectory(), C4UpdatePackage::Execute(), C4Config::ExpandEnvironmentVariables(), C4Group::ExtractEntry(), C4Command::Fail(), C4PlayerList::FileInUse(), C4Group::FindEntry(), C4SoundSystem::FindInstance(), C4Group::FindNextEntry(), C4GroupSet::FindSuitableFile(), C4Network2ResList::FindTempResFileName(), C4Network2Res::FinishDerive(), C4GraphicsSystem::FlashMessage(), FnStringFormat(), ForEachFile(), C4GUI::Edit::GetCurrentWord(), C4SoundSystem::GetEffect(), GetFilenameOnly(), C4Language::GetPackGroups(), GetParentPath(), C4Network2Res::GetStandalone(), CStdFont::GetTextExtent(), C4LoaderScreen::Init(), C4MusicFile::Init(), C4RankSystem::Init(), CStdFont::Init(), C4Game::Init(), C4Player::Init(), C4Network2::Join(), C4SoundEffect::Load(), C4ObjectInfo::Load(), C4FacetSurface::Load(), C4DefGraphics::Load(), C4StartupPlrSelDlg::PlayerListItem::Load(), C4Surface::Load(), C4Player::Load(), C4Surface::LoadAny(), C4MusicSystem::LoadDir(), C4GameResList::LoadFoldersWithLocalDefs(), C4Game::LoadScenarioComponents(), C4Game::LoadScenarioSection(), main(), MakeFilenameFromTitle(), MakeOriginalFilename(), C4Config::MakeTempUpdateFolder(), C4UpdatePackage::MakeUpdate(), C4ObjectInfoList::MakeValidName(), C4MainMenu::MenuCommand(), C4Player::Message(), C4UpdatePackage::MkUp(), C4StartupPlrPropertiesDlg::OnClosed(), C4ChatControl::OnConnectBtn(), C4StartupMainDlg::OnNetJoin(), C4GameOptionButtons::OnPasswordSet(), C4StartupMainDlg::OnPlayerSelContextAddPlr(), CStdFile::Open(), C4Group::Open(), C4Group::OpenAsChild(), C4Game::OpenScenario(), StdStringAdapt::operator=(), C4Network2Res::OptimizeStandalone(), C4Application::ParseCommandLine(), C4MCParser::ParseFile(), C4MCParser::ParseMemFile(), C4MusicSystem::Play(), C4MessageInput::ProcessInput(), C4PlayerInfoCore::Promote(), C4Game::QuickSave(), RealPath(), C4GroupSet::RegisterParentFolders(), C4Group::Rename(), C4ScenarioListLoader::Entry::RenameTo(), C4LangStringTable::ReplaceStrings(), SAppend(), C4ObjectInfo::Save(), C4Group::Save(), C4Player::Save(), C4Landscape::P::SaveInternal(), C4Surface::SavePNG(), C4Console::SaveScenario(), SCopyEnclosed(), C4LoaderScreen::SeekLoaderScreens(), C4NameList::Set(), C4GroupEntry::Set(), C4GraphicsOverlay::Set(), C4GameControlClient::Set(), C4ToolsDlg::SetBackMaterial(), C4ToolsDlg::SetBackTexture(), C4Network2Res::SetByFile(), C4Network2Res::SetByGroup(), SetClientPrefix(), C4Network2Res::SetDerived(), C4MCOverlay::SetField(), C4Application::SetGameFont(), C4ToolsDlg::SetIFT(), C4Network2Res::SetLoad(), C4ToolsDlg::SetMaterial(), C4SDefinitions::SetModules(), C4Game::SetScenarioFilename(), C4GUI::ComboBox::SetText(), C4ToolsDlg::SetTexture(), C4Record::Start(), C4StartupScenSelDlg::StartScenario(), C4MessageInput::StoreBackBuffer(), C4Playback::StreamToRecord(), StdCompilerINIRead::String(), and C4InVal::ValidateString().

130 {
131  if (szSource == sTarget) return;
132  if (!sTarget) return; *sTarget=0; if (!szSource) return;
133  while (*szSource && (iMaxL>0))
134  { *sTarget=*szSource; iMaxL--; szSource++; sTarget++; }
135  *sTarget=0;
136 }
void SCopy ( const char *  szSource,
char *  sTarget 
)

Definition at line 138 of file Standard.cpp.

139 {
140  if (szSource == sTarget) return;
141  if (!sTarget) return; *sTarget=0; if (!szSource) return;
142  strcpy(sTarget,szSource);
143 }
bool SCopyEnclosed ( const char *  szSource,
char  cOpen,
char  cClose,
char *  sTarget,
int  iSize 
)

Definition at line 500 of file Standard.cpp.

References SCharPos(), and SCopy().

Referenced by C4Markup::Read().

501 {
502  int iPos,iLen;
503  if (!szSource || !sTarget) return false;
504  if ((iPos = SCharPos(cOpen,szSource)) < 0) return false;
505  if ((iLen = SCharPos(cClose,szSource+iPos+1)) < 0) return false;
506  SCopy(szSource+iPos+1,sTarget,std::min(iLen,iSize));
507  return true;
508 }
void SCopy(const char *szSource, char *sTarget, size_t iMaxL)
Definition: Standard.cpp:129
int SCharPos(char cTarget, const char *szInStr, int iIndex)
Definition: Standard.cpp:210
int iSize
Definition: TstC4NetIO.cpp:35

Here is the call graph for this function:

Here is the caller graph for this function:

void SCopyIdentifier ( const char *  szSource,
char *  sTarget,
int  iMaxL 
)

Definition at line 420 of file Standard.cpp.

References IsIdentifier().

Referenced by C4MaterialMap::LoadEnumeration().

421 {
422  if (!szSource || !sTarget) return;
423  while (IsIdentifier(*szSource))
424  {
425  if (iMaxL==1) { *sTarget++ = *szSource++; break; }
426  iMaxL--;
427  *sTarget++ = *szSource++;
428  }
429  *sTarget=0;
430 }
bool IsIdentifier(char cChar)
Definition: Standard.cpp:67

Here is the call graph for this function:

Here is the caller graph for this function:

bool SCopySegment ( const char *  szString,
int  iSegment,
char *  sTarget,
char  cSeparator,
int  iMaxL,
bool  fSkipWhitespace 
)

Definition at line 250 of file Standard.cpp.

References SAdvanceSpace(), SCharPos(), and SCopyUntil().

Referenced by C4Group_IsExcluded(), C4ObjectInfoCore::Default(), C4Group::Delete(), C4UpdatePackage::DoGrpUpdate(), C4Group::Extract(), C4ConfigGeneral::GetLanguageSequence(), C4ComponentHost::GetLanguageString(), C4Extra::Init(), C4RankSystem::Init(), C4FontLoader::InitFont(), C4ComponentHost::Load(), C4GameResList::Load(), C4SoundSystem::LoadEffects(), C4Language::LoadLanguage(), C4MainMenu::MenuCommand(), C4Group::Merge(), C4StartupMainDlg::OnPlayerSelContextRemove(), C4StartupMainDlg::OnPlayerSelContextRemovePlr(), RegisterShellExtensions(), SGetModule(), SortRank(), UnregisterShellExtensions(), and C4StartupMainDlg::UpdateParticipants().

252 {
253  // Advance to indexed segment
254  while (iSegment>0)
255  {
256  if (SCharPos(cSeparator,szString) == -1)
257  { sTarget[0]=0; return false; }
258  szString += SCharPos(cSeparator,szString)+1;
259  iSegment--;
260  }
261  // Advance whitespace
262  if (fSkipWhitespace)
263  szString = SAdvanceSpace(szString);
264  // Copy segment contents
265  SCopyUntil(szString,sTarget,cSeparator,iMaxL);
266  return true;
267 }
const char * SAdvanceSpace(const char *szSPos)
Definition: Standard.cpp:391
int SCharPos(char cTarget, const char *szInStr, int iIndex)
Definition: Standard.cpp:210
void SCopyUntil(const char *szSource, char *sTarget, char cUntil, int iMaxL, int iIndex)
Definition: Standard.cpp:145

Here is the call graph for this function:

Here is the caller graph for this function:

bool SCopySegmentEx ( const char *  szString,
int  iSegment,
char *  sTarget,
char  cSep1,
char  cSep2,
int  iMaxL,
bool  fSkipWhitespace 
)

Definition at line 269 of file Standard.cpp.

References SAdvanceSpace(), SCharPos(), and SCopyUntil().

Referenced by C4Draw::TextOut().

271 {
272  // Advance to indexed segment
273  while (iSegment>0)
274  {
275  // use the separator that's closer
276  int iPos1 = SCharPos(cSep1,szString), iPos2 = SCharPos(cSep2,szString);
277  if (iPos1 == -1)
278  if (iPos2 == -1)
279  { sTarget[0]=0; return false; }
280  else
281  iPos1=iPos2;
282  else if (iPos2 != -1 && iPos2 < iPos1)
283  iPos1 = iPos2;
284  szString += iPos1+1;
285  iSegment--;
286  }
287  // Advance whitespace
288  if (fSkipWhitespace)
289  szString = SAdvanceSpace(szString);
290  // Copy segment contents; use separator that's closer
291  int iPos1 = SCharPos(cSep1,szString), iPos2 = SCharPos(cSep2,szString);
292  if (iPos2 != -1 && (iPos2 < iPos1 || iPos1 == -1)) cSep1 = cSep2;
293  SCopyUntil(szString,sTarget,cSep1,iMaxL);
294  return true;
295 }
const char * SAdvanceSpace(const char *szSPos)
Definition: Standard.cpp:391
int SCharPos(char cTarget, const char *szInStr, int iIndex)
Definition: Standard.cpp:210
void SCopyUntil(const char *szSource, char *sTarget, char cUntil, int iMaxL, int iIndex)
Definition: Standard.cpp:145

Here is the call graph for this function:

Here is the caller graph for this function:

void SCopyUntil ( const char *  szSource,
char *  sTarget,
char  cUntil,
int  iMaxL,
int  iIndex 
)

Definition at line 145 of file Standard.cpp.

Referenced by C4FontLoader::InitFont(), C4MusicSystem::LoadMoreMusic(), C4Group::OpenAsChild(), C4MessageInput::ProcessCommand(), C4MessageInput::ProcessInput(), C4Game::QuickSave(), C4LangStringTable::ReplaceStrings(), C4GameSave::SaveDesc(), SCopySegment(), and SCopySegmentEx().

146 {
147  if (szSource == sTarget) return;
148  if (!sTarget) return; *sTarget=0; if (!szSource) return;
149  while ( *szSource && ((*szSource!=cUntil) || (iIndex>0)) && (iMaxL!=0) )
150  { *sTarget=*szSource; if (*szSource==cUntil) iIndex--; szSource++; sTarget++; iMaxL--; }
151  *sTarget=0;
152 }

Here is the caller graph for this function:

void SCopyUntil ( const char *  szSource,
char *  sTarget,
const char *  sUntil,
size_t  iMaxL 
)

Definition at line 154 of file Standard.cpp.

155 {
156  size_t n = std::min(strcspn(szSource, sUntil), iMaxL - 1);
157  strncpy(sTarget, szSource, n);
158  sTarget[n] = 0;
159 }
void SDelete ( char *  szString,
int  iLen,
int  iPosition 
)

Definition at line 492 of file Standard.cpp.

References MemCopy(), and SLen().

Referenced by SRemoveModule().

493 {
494  // Safety
495  if (!szString) return;
496  // Move down string remainder
497  MemCopy( szString+iPosition+iLen, szString+iPosition, SLen(szString+iPosition+iLen)+1 );
498 }
size_t SLen(const char *sptr)
Definition: Standard.h:78
void MemCopy(const void *lpMem1, void *lpMem2, size_t dwSize)
Definition: Standard.h:68

Here is the call graph for this function:

Here is the caller graph for this function:

bool SEqual2 ( const char *  szStr1,
const char *  szStr2 
)

Definition at line 175 of file Standard.cpp.

Referenced by C4GameMessage::Append(), StdCompilerINIRead::Boolean(), ConsoleDlgProc(), C4UpdatePackage::Execute(), FullScreenWinProc(), C4MessageBoard::GetMessagePlayer(), GetRelativePathS(), GetTextSpecFacet(), C4Game::Init(), C4StartupScenSelDlg::KeyCheat2(), C4TextureMap::LoadFlags(), C4MainMenu::MenuCommand(), C4MainMenu::OnSelectionChanged(), C4MessageInput::ProcessCommand(), C4PlayerControlAssignment::ResolveRefs(), C4Console::SaveScenario(), and C4Network2RefServer::UnpackPacket().

176 {
177  if (!szStr1 || !szStr2) return false;
178  while (*szStr1 && *szStr2)
179  if (*szStr1++ != *szStr2++) return false;
180  if (*szStr2) return false; // Str1 is shorter
181  return true;
182 }

Here is the caller graph for this function:

bool SEqual2NoCase ( const char *  szStr1,
const char *  szStr2,
int  iLen 
)

Definition at line 197 of file Standard.cpp.

References CharCapital().

Referenced by C4ScenarioParameters::AddFilename2ID(), C4Application::DoInit(), C4DefList::GetByPath(), GetC4Filename(), GetRelativePathS(), C4Application::ParseCommandLine(), C4MessageInput::ProcessInput(), C4ChatControl::ProcessInput(), and C4Startup::SetStartScreen().

198 {
199  if (!szStr1 || !szStr2) return false;
200  if (iLen==0) return true;
201  while (*szStr1 && *szStr2)
202  {
203  if ( CharCapital(*szStr1++) != CharCapital(*szStr2++)) return false;
204  if (iLen>0) { iLen--; if (iLen==0) return true; }
205  }
206  if (*szStr2) return false; // Str1 is shorter
207  return true;
208 }
char CharCapital(char cChar)
Definition: Standard.h:74

Here is the call graph for this function:

Here is the caller graph for this function:

bool SEqualNoCase ( const char *  szStr1,
const char *  szStr2,
int  iLen 
)

Definition at line 184 of file Standard.cpp.

References CharCapital().

Referenced by C4Record::AddFile(), C4TextureMap::CheckTexture(), C4Game::CreateSectionFromTempFile(), C4MaterialMap::CrossMapMaterials(), C4Game::DropFile(), C4PlayerList::FileInUse(), C4ScenarioListLoader::Folder::FindEntryByName(), C4Language::FindInfo(), C4PlayerInfoList::FindSavegameResumePlayerInfo(), C4DefGraphics::Get(), C4MaterialMap::Get(), C4PlayerInfoList::GetActivePlayerInfoByName(), C4PlayerList::GetAtClient(), C4Network2IRCClient::getChannel(), C4Network2Stats::GetGraphByName(), C4ScenarioSection::GetGroupfile(), C4ObjectInfoList::GetIdle(), C4TextureMap::GetIndex(), GetMusicFileTypeByExtension(), C4Language::GetPackGroups(), C4TextureMap::GetTexture(), C4TextureMap::GetTextureIndex(), C4StartupNetListEntry::IsSameRefQueryAddress(), C4LeagueResponseHead::isStatusRegister(), C4LeagueResponseHead::isSuccess(), ItemIdentical(), C4Network2::Join(), C4DefList::Load(), C4ObjectInfo::Load(), C4DefGraphics::Load(), C4MusicSystem::Load(), C4GameResList::LoadFoldersWithLocalDefs(), C4DefGraphics::LoadMesh(), C4Game::LoadScenarioSection(), C4DefGraphics::LoadSkeleton(), C4ObjectInfoList::NameExists(), C4Playback::Open(), C4Application::ParseCommandLine(), C4MessageInput::ProcessCommand(), C4MessageInput::ProcessInput(), C4ChatControl::ProcessInput(), C4Surface::Read(), C4GroupSet::RegisterParentFolders(), C4ScriptHost::ReloadScript(), C4Group::Rename(), C4ObjectInfo::Save(), C4ScenarioSection::ScenarioLoad(), SetClientPrefix(), C4Game::SetScenarioFilename(), C4Startup::SetStartScreen(), C4StartupOptionsDlg::SetSubscreen(), SIsModule(), C4KeyCodeEx::String2KeyCode(), C4KeyCodeEx::String2KeyShift(), C4StartupMainDlg::UpdateParticipants(), and C4InVal::ValidateString().

185 {
186  if (!szStr1 || !szStr2) return false;
187  if (iLen==0) return true;
188  while (*szStr1 && *szStr2)
189  {
190  if ( CharCapital(*szStr1++) != CharCapital(*szStr2++)) return false;
191  if (iLen>0) { iLen--; if (iLen==0) return true; }
192  }
193  if (*szStr1 || *szStr2) return false;
194  return true;
195 }
char CharCapital(char cChar)
Definition: Standard.h:74

Here is the call graph for this function:

Here is the caller graph for this function:

bool SEqualUntil ( const char *  szStr1,
const char *  szStr2,
char  cWild 
)

Definition at line 161 of file Standard.cpp.

162 {
163  if (!szStr1 || !szStr2) return false;
164  while (*szStr1 || *szStr2)
165  {
166  if ((*szStr1==cWild) || (*szStr2==cWild)) return true;
167  if (*szStr1!=*szStr2) return false;
168  szStr1++; szStr2++;
169  }
170  return true;
171 }
int SGetLine ( const char *  szText,
const char *  cpPosition 
)

Definition at line 450 of file Standard.cpp.

Referenced by C4AulParseError::C4AulParseError(), C4MCParserErr::C4MCParserErr(), C4AulScriptFunc::GetLineOfCode(), C4ScriptHost::Parse(), and C4AulScriptContext::ReturnDump().

451 {
452  if (!szText || !cpPosition) return 0;
453  int iLines = 1;
454  while (*szText && (szText<cpPosition))
455  {
456  if (*szText == 0x0A) iLines++;
457  szText++;
458  }
459  return iLines;
460 }

Here is the caller graph for this function:

bool SGetModule ( const char *  szList,
int  iIndex,
char *  sTarget,
int  iSize 
)

Definition at line 510 of file Standard.cpp.

References SClearFrontBack(), and SCopySegment().

Referenced by C4ClientPlayerInfos::C4ClientPlayerInfos(), C4Group_ApplyUpdate(), SAddModules(), C4SDefinitions::SetModules(), C4MusicSystem::SetPlayList(), SIsModule(), SRemoveModules(), and C4GameSave::WriteDescDefinitions().

511 {
512  if (!szList || !sTarget) return false;
513  if (!SCopySegment(szList,iIndex,sTarget,';',iSize)) return false;
514  SClearFrontBack(sTarget);
515  return true;
516 }
bool SCopySegment(const char *szString, int iSegment, char *sTarget, char cSeparator, int iMaxL, bool fSkipWhitespace)
Definition: Standard.cpp:250
int SClearFrontBack(char *szString, char cClear)
Definition: Standard.cpp:432
int iSize
Definition: TstC4NetIO.cpp:35

Here is the call graph for this function:

Here is the caller graph for this function:

void SInsert ( char *  szString,
const char *  szInsert,
int  iPosition,
int  iMaxLen 
)

Definition at line 480 of file Standard.cpp.

References MemCopy(), and SLen().

Referenced by C4Group::GetFullName().

481 {
482  // Safety
483  if (!szString || !szInsert || !szInsert[0]) return;
484  size_t insertlen = strlen(szInsert);
485  if (iMaxLen >= 0 && strlen(szString) + insertlen > (size_t) iMaxLen) return;
486  // Move up string remainder
487  memmove (szString + iPosition + insertlen, szString + iPosition, SLen(szString+ iPosition) + 1);
488  // Copy insertion
489  MemCopy( szInsert, szString+iPosition, SLen(szInsert) );
490 }
size_t SLen(const char *sptr)
Definition: Standard.h:78
void MemCopy(const void *lpMem1, void *lpMem2, size_t dwSize)
Definition: Standard.h:68

Here is the call graph for this function:

Here is the caller graph for this function:

bool SIsModule ( const char *  szList,
const char *  szString,
int *  ipIndex,
bool  fCaseSensitive 
)

Definition at line 518 of file Standard.cpp.

References SEqual(), SEqualNoCase(), and SGetModule().

Referenced by C4Group_TestIgnore(), C4MapFolderData::CreateGUIElements(), C4FileSelDlg::GetSelection(), C4DefinitionSelDlg::IsItemGrayed(), C4Config::IsModule(), C4Game::JoinPlayer(), C4ScenarioListLoader::Scenario::LoadCustomPre(), C4StartupMainDlg::OnPlayerSelContextAdd(), C4Game::OpenScenario(), SAddModule(), C4FileSelDlg::SetSelection(), and SRemoveModule().

519 {
520  char szModule[1024+1];
521  // Compare all modules
522  for (int iMod=0; SGetModule(szList,iMod,szModule,1024); iMod++)
523  if (fCaseSensitive ? SEqual(szString,szModule) : SEqualNoCase(szString,szModule))
524  {
525  // Provide index if desired
526  if (ipIndex) *ipIndex = iMod;
527  // Found
528  return true;
529  }
530  // Not found
531  return false;
532 }
bool SGetModule(const char *szList, int iIndex, char *sTarget, int iSize)
Definition: Standard.cpp:510
bool SEqualNoCase(const char *szStr1, const char *szStr2, int iLen)
Definition: Standard.cpp:184
bool SEqual(const char *szStr1, const char *szStr2)
Definition: Standard.h:97

Here is the call graph for this function:

Here is the caller graph for this function:

int SLineGetCharacters ( const char *  szText,
const char *  cpPosition 
)

Definition at line 462 of file Standard.cpp.

Referenced by C4AulParseError::C4AulParseError().

463 {
464  if (!szText || !cpPosition) return 0;
465  int iChars = 1;
466  while (*szText && (szText<cpPosition))
467  {
468  if (*szText == 0x0A)
469  iChars = 1;
470  else if (*szText == '\t')
471  // assume a tab stop every 8 characters
472  iChars = ((iChars - 1 + 8) & ~7) + 1;
473  else
474  iChars++;
475  szText++;
476  }
477  return iChars;
478 }

Here is the caller graph for this function:

int SModuleCount ( const char *  szList)

Definition at line 588 of file Standard.cpp.

Referenced by C4ClientPlayerInfos::C4ClientPlayerInfos(), C4ScenarioListLoader::Scenario::CanOpen(), and C4SDefinitions::SetModules().

589 {
590  if (!szList) return 0;
591  int iCount = 0;
592  bool fNewModule = true;
593  while (*szList)
594  {
595  switch (*szList)
596  {
597  case ' ': break;
598  case ';': fNewModule=true; break;
599  default: if (fNewModule) iCount++; fNewModule=false; break;
600  }
601  szList++;
602  }
603  return iCount;
604 }

Here is the caller graph for this function:

void SNewSegment ( char *  szStr,
const char *  szSepa 
)

Definition at line 445 of file Standard.cpp.

References SAppend().

Referenced by SAddModule().

446 {
447  if (szStr[0]) SAppend(szSepa,szStr);
448 }
void SAppend(const char *szSource, char *szTarget, int iMaxL)
Definition: Standard.cpp:234

Here is the call graph for this function:

Here is the caller graph for this function:

bool SRemoveModule ( char *  szList,
const char *  szModule,
bool  fCaseSensitive 
)

Definition at line 559 of file Standard.cpp.

References SCharPos(), SDelete(), SIsModule(), and SLen().

Referenced by C4StartupMainDlg::OnPlayerSelContextRemovePlr(), C4Config::RemoveModule(), and SRemoveModules().

560 {
561  int iMod,iPos,iLen;
562  // Not a module
563  if (!SIsModule(szList,szModule,&iMod,fCaseSensitive)) return false;
564  // Get module start
565  iPos = 0;
566  if (iMod > 0) iPos = SCharPos(';',szList,iMod-1)+1;
567  // Get module length
568  iLen = SCharPos(';',szList+iPos);
569  if (iLen<0) iLen=SLen(szList); else iLen+=1;
570  // Delete module
571  SDelete(szList,iLen,iPos);
572  // Success
573  return true;
574 }
bool SIsModule(const char *szList, const char *szString, int *ipIndex, bool fCaseSensitive)
Definition: Standard.cpp:518
size_t SLen(const char *sptr)
Definition: Standard.h:78
void SDelete(char *szString, int iLen, int iPosition)
Definition: Standard.cpp:492
int SCharPos(char cTarget, const char *szInStr, int iIndex)
Definition: Standard.cpp:210

Here is the call graph for this function:

Here is the caller graph for this function:

bool SRemoveModules ( char *  szList,
const char *  szModules,
bool  fCaseSensitive 
)

Definition at line 576 of file Standard.cpp.

References SGetModule(), and SRemoveModule().

Referenced by C4StartupScenSelDlg::KeyCheat2().

577 {
578  // Safety / no empties
579  if (!szList || !szModules || !szModules[0]) return false;
580  // Remove modules
581  char szModule[1024+1]; // limited
582  for (int cnt=0; SGetModule(szModules,cnt,szModule,1024); cnt++)
583  SRemoveModule(szList,szModule,fCaseSensitive);
584  // Success
585  return true;
586 }
bool SGetModule(const char *szList, int iIndex, char *sTarget, int iSize)
Definition: Standard.cpp:510
bool SRemoveModule(char *szList, const char *szModule, bool fCaseSensitive)
Definition: Standard.cpp:559

Here is the call graph for this function:

Here is the caller graph for this function:

void SReplaceChar ( char *  str,
char  fc,
char  tc 
)

Definition at line 325 of file Standard.cpp.

Referenced by C4MenuItem::C4MenuItem(), C4StartupPlrSelDlg::CheckPlayerName(), C4NetFilenameAdapt::CompileFunc(), C4ObjectInfoCore::Default(), C4ComponentHost::Load(), C4TextureMap::LoadTextures(), C4Group::Open(), C4Application::ParseCommandLine(), and C4LangStringTable::ReplaceStrings().

326 {
327  while (str && *str)
328  { if (*str==fc) *str=tc; str++; }
329 }

Here is the caller graph for this function:

const char* SRewindSpace ( const char *  szSPos,
const char *  pBegin 
)

Definition at line 398 of file Standard.cpp.

References IsWhiteSpace().

399 {
400  if (!szSPos || !pBegin) return nullptr;
401  while (IsWhiteSpace(*szSPos))
402  {
403  szSPos--;
404  if (szSPos<pBegin) return nullptr;
405  }
406  return szSPos;
407 }
bool IsWhiteSpace(char cChar)
Definition: Standard.h:76

Here is the call graph for this function:

const char* SSearch ( const char *  szString,
const char *  szIndex 
)

Definition at line 340 of file Standard.cpp.

References SLen().

Referenced by C4ClientPlayerInfos::C4ClientPlayerInfos(), C4DownloadDlg::DownloadFile(), C4Config::ExpandEnvironmentVariables(), C4TextureMap::GetIndexMatTex(), C4ComponentHost::GetLanguageString(), C4ComponentHost::Load(), C4MusicSystem::LoadDir(), C4MaterialMap::LoadEnumeration(), C4TextureMap::LoadFlags(), C4Player::LoadRuntimeData(), LogFatal(), C4MessageInput::ProcessCommand(), StdStrBuf::Replace(), C4LangStringTable::ReplaceStrings(), C4Landscape::SetTextureIndex(), C4Markup::StripMarkup(), and C4Network2HTTPClient::UnpackPacket().

341 {
342  const char *cscr;
343  size_t indexlen,match=0;
344  if (!szString || !szIndex) return nullptr;
345  indexlen=SLen(szIndex);
346  for (cscr=szString; cscr && *cscr; cscr++)
347  {
348  if (*cscr==szIndex[match]) match++;
349  else match=0;
350  if (match>=indexlen) return cscr+1;
351  }
352  return nullptr;
353 }
size_t SLen(const char *sptr)
Definition: Standard.h:78

Here is the call graph for this function:

Here is the caller graph for this function:

const char* SSearchNoCase ( const char *  szString,
const char *  szIndex 
)

Definition at line 355 of file Standard.cpp.

References CharCapital(), and SLen().

Referenced by C4StartupNetListEntry::KeywordMatch().

356 {
357  const char *cscr;
358  size_t indexlen,match=0;
359  if (!szString || !szIndex) return nullptr;
360  indexlen=SLen(szIndex);
361  for (cscr=szString; cscr && *cscr; cscr++)
362  {
363  if (CharCapital(*cscr)==CharCapital(szIndex[match])) match++;
364  else match=0;
365  if (match>=indexlen) return cscr+1;
366  }
367  return nullptr;
368 }
size_t SLen(const char *sptr)
Definition: Standard.h:78
char CharCapital(char cChar)
Definition: Standard.h:74

Here is the call graph for this function:

Here is the caller graph for this function:

std::string strprintf ( const char *  format,
  ... 
)

Definition at line 809 of file Standard.cpp.

References s, and vstrprintf().

Referenced by C4GUI::MessageDialog::MessageDialog().

810 {
811  va_list args;
812  va_start(args, format);
813  std::string s = vstrprintf(format, args);
814  va_end(args);
815  return s;
816 }
std::string vstrprintf(const char *format, va_list args)
Definition: Standard.cpp:793
#define s

Here is the call graph for this function:

Here is the caller graph for this function:

int32_t StrToI32 ( const char *  str,
int  base,
const char **  scan_end 
)

Definition at line 97 of file Standard.cpp.

References s.

98 {
99  const char *s = str;
100  int sign = 1;
101  int32_t result = 0;
102  if (*s == '-')
103  {
104  sign = -1;
105  s++;
106  }
107  else if (*s == '+')
108  {
109  s++;
110  }
111  if (!*s)
112  {
113  // Abort if there are no digits to parse
114  if (scan_end) *scan_end = str;
115  return 0;
116  }
117  while (IsNumber(*s,base))
118  {
119  int value = ToNumber(*s++);
120  assert (value < base && value >= 0);
121  result *= base;
122  result += value;
123  }
124  if (scan_end != 0L) *scan_end = s;
125  result *= sign;
126  return result;
127 }
#define s
bool SWildcardMatchEx ( const char *  szString,
const char *  szWildcard 
)

Definition at line 606 of file Standard.cpp.

Referenced by C4Effect::Get(), C4Effect::GetCount(), C4Network2IRCClient::Join(), and StdMeshMaterialSubLoader::Load().

607 {
608  // safety
609  if (!szString || !szWildcard) return false;
610  // match char-wise
611  const char *pWild = szWildcard, *pPos = szString;
612  const char *pLWild = nullptr, *pLPos = nullptr; // backtracking
613  while (*pWild || pLWild)
614  // string wildcard?
615  if (*pWild == '*')
616  { pLWild = ++pWild; pLPos = pPos; }
617  // nothing left to match?
618  else if (!*pPos)
619  break;
620  // equal or one-character-wildcard? proceed
621  else if (*pWild == '?' || *pWild == *pPos)
622  { pWild++; pPos++; }
623  // backtrack possible?
624  else if (pLPos)
625  { pWild = pLWild; pPos = ++pLPos; }
626  // match failed
627  else
628  return false;
629  // match complete if both strings are fully matched
630  return !*pWild && !*pPos;
631 }

Here is the caller graph for this function:

void SWordWrap ( char *  szText,
char  cSpace,
char  cSepa,
int  iMaxLine 
)

Definition at line 370 of file Standard.cpp.

Referenced by C4Game::DrawCrewOverheadText().

371 {
372  if (!szText) return;
373  // Scan string
374  char *cPos,*cpLastSpace=nullptr;
375  int iLineRun=0;
376  for (cPos=szText; *cPos; cPos++)
377  {
378  // Store last space
379  if (*cPos==cSpace) cpLastSpace=cPos;
380  // Separator encountered: reset line run
381  if (*cPos==cSepa) iLineRun=0;
382  // Need a break, insert at last space
383  if (iLineRun>=iMaxLine)
384  if (cpLastSpace)
385  { *cpLastSpace=cSepa; iLineRun=cPos - cpLastSpace; }
386  // Line run
387  iLineRun++;
388  }
389 }

Here is the caller graph for this function:

std::string vstrprintf ( const char *  format,
va_list  args 
)

Definition at line 793 of file Standard.cpp.

References s.

Referenced by strprintf().

794 {
795  va_list argcopy;
796  va_copy(argcopy, args);
797  int size = vsnprintf(nullptr, 0, format, argcopy);
798  if (size < 0)
799  throw std::invalid_argument("invalid argument to strprintf");
800  va_end(argcopy);
801  std::string s;
802  s.resize(size + 1);
803  size = vsnprintf(&s[0], s.size(), format, args);
804  assert(size >= 0);
805  s.resize(size);
806  return s;
807 }
#define s

Here is the caller graph for this function: