MCPcopy Create free account
hub / github.com/BohemiaInteractive/CWR / NormalizeSavePath

Function NormalizeSavePath

engine/Poseidon/Dev/Debug/DebugCheats.cpp:38–55  ·  view source on GitHub ↗

Save-path normalization — tri's isolated test config can produce a GetSaveDirectory() result like "C:\...\.tmpXYZ\Users\josef\Saved\C:\...\.tmpXYZ\mission-smoke\...\" where an absolute drive-letter path appears embedded mid-string. Windows CreateFile silently resolves the second drive prefix and SaveBin succeeds, but ParamArchiveLoad::LoadBin treats it as the literal path and fails to open the fil

Source from the content-addressed store, hash-verified

36//
37// No-op on a normal path (no embedded ':' past offset 2).
38static RString NormalizeSavePath(RString name)
39{
40 const char* s = (const char*)name;
41 if (!s)
42 return name;
43 int lastDriveAt = -1;
44 int len = (int)strlen(s);
45 // Start at index 2 — we expect the FIRST "X:" near the start, and
46 // we want to detect any EMBEDDED later occurrence.
47 for (int i = 2; i + 1 < len; i++)
48 {
49 if (s[i + 1] == ':' && ((s[i] >= 'A' && s[i] <= 'Z') || (s[i] >= 'a' && s[i] <= 'z')))
50 lastDriveAt = i;
51 }
52 if (lastDriveAt <= 0)
53 return name;
54 return RString(s + lastDriveAt);
55}
56extern int IDS_SAVE_GAME;
57extern int IDS_LOAD_GAME;
58namespace Poseidon

Callers 1

InvokeFunction · 0.85

Calls 1

RStringClass · 0.50

Tested by

no test coverage detected