Skip to content

Commit 104edcc

Browse files
committed
Merge remote-tracking branch 'OpenXRay/dev' into yohji/feat/remove-SSS
2 parents c69a3ef + e2c51d5 commit 104edcc

File tree

5 files changed

+37
-13
lines changed

5 files changed

+37
-13
lines changed

src/Layers/xrRender_R2/r2_R_calculate.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,11 @@ void CRender::Calculate()
8282
// Configure
8383
o.distortion = o.distortion_enabled;
8484
o.mt_calculate = ps_r2_mt_calculate > 0;
85+
#ifdef USE_DX11
8586
o.mt_render = ps_r2_mt_render > 0;
87+
#else
88+
o.mt_render = 0; // OpenGL does not support parallel draw calls
89+
#endif
8690

8791
if (m_bFirstFrameAfterReset)
8892
return;

src/xrCore/Threading/TaskManager.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,10 +197,11 @@ TaskManager::~TaskManager()
197197
void TaskManager::RegisterThisThreadAsWorker()
198198
{
199199
ZoneScoped;
200+
std::lock_guard guard{ workersLock };
201+
200202
R_ASSERT2(workers.size() < std::thread::hardware_concurrency(),
201203
"You must change OTHER_THREADS_COUNT if you want to register more custom threads.");
202204

203-
std::lock_guard guard{ workersLock };
204205
s_tl_worker.id = workers.size();
205206
workers.emplace_back(&s_tl_worker);
206207
}

src/xrCore/XML/XMLDocument.cpp

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -217,11 +217,33 @@ XML_NODE XMLDocument::NavigateToNode(CONST_XML_NODE start_node, pcstr path, cons
217217
buf_str[0] = 0;
218218
xr_strcpy(buf_str, path);
219219

220-
const char seps[] = ":";
221220
size_t tmp = 0;
222221

223-
//разбить путь на отдельные подпути
224-
char* token = strtok(buf_str, seps);
222+
char* cursor = buf_str;
223+
224+
// Thread-safe tokenization over ':'
225+
auto next_token = [](char*& cur) -> char*
226+
{
227+
if (!cur || *cur == '\0')
228+
return nullptr;
229+
230+
char* start = cur;
231+
char* sep = strchr(cur, ':');
232+
if (sep)
233+
{
234+
*sep = '\0';
235+
cur = sep + 1;
236+
}
237+
else
238+
{
239+
cur = nullptr;
240+
}
241+
242+
return start;
243+
};
244+
245+
// разбить путь на отдельные подпути
246+
char* token = next_token(cursor);
225247

226248
if (token != nullptr)
227249
{
@@ -234,7 +256,7 @@ XML_NODE XMLDocument::NavigateToNode(CONST_XML_NODE start_node, pcstr path, cons
234256
while (token)
235257
{
236258
// Get next token:
237-
token = strtok(nullptr, seps);
259+
token = next_token(cursor);
238260

239261
if (token != nullptr)
240262
if (node)

src/xrEngine/StringTable/StringTable.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,17 +59,14 @@ void CStringTable::Init()
5959
xr_sprintf(files_mask, "text" DELIMITER "%s" DELIMITER "*.xml", pData->m_sLanguage.c_str());
6060
FS.file_list(fset, "$game_config$", FS_ListFiles, files_mask);
6161

62-
auto fit = fset.begin();
63-
auto fit_e = fset.end();
64-
65-
for (; fit != fit_e; ++fit)
62+
xr_parallel_for_each(fset, [this](const FS_File& it)
6663
{
6764
string_path fn, ext;
68-
_splitpath(fit->name.c_str(), nullptr, nullptr, fn, ext);
65+
_splitpath(it.name.c_str(), nullptr, nullptr, fn, ext);
6966
xr_strcat(fn, ext);
7067

7168
Load(fn);
72-
}
69+
});
7370

7471
if (!translate("st_currency", pData->m_sCurrency) &&
7572
!translate("ui_st_money_descr", pData->m_sCurrency) && // OGSR
@@ -238,7 +235,7 @@ void CStringTable::Load(LPCSTR xml_file_full)
238235
[[maybe_unused]] bool duplicate{};
239236
const STRING_VALUE str_val = ParseLine(string_text); // NOLINT
240237
{
241-
//std::lock_guard guard{ pDataMutex };
238+
std::lock_guard guard{ pDataMutex };
242239
#ifndef MASTER_GOLD
243240
duplicate = pData->m_StringTable.find(string_name) != pData->m_StringTable.end();
244241
#endif

0 commit comments

Comments
 (0)