Skip to content

Commit abc249f

Browse files
committed
Merge branch 'development' into source-refactor
2 parents 8ab75ff + 01ccb96 commit abc249f

File tree

8 files changed

+24
-51
lines changed

8 files changed

+24
-51
lines changed

Source/Managers/LuaMan.cpp

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ namespace RTE {
6868
.def("RangeRand", &LuaStateWrapper::RangeRand)
6969
.def("PosRand", &LuaStateWrapper::PosRand)
7070
.def("NormalRand", &LuaStateWrapper::NormalRand)
71-
.def("GetDirectoryList", &LuaStateWrapper::DirectoryList, luabind::return_stl_iterator)
72-
.def("GetFileList", &LuaStateWrapper::FileList, luabind::return_stl_iterator)
71+
.def("GetDirectoryList", &LuaStateWrapper::DirectoryList, luabind::adopt(luabind::return_value) + luabind::return_stl_iterator)
72+
.def("GetFileList", &LuaStateWrapper::FileList, luabind::adopt(luabind::return_value) + luabind::return_stl_iterator)
7373
.def("FileExists", &LuaStateWrapper::FileExists)
7474
.def("FileOpen", &LuaStateWrapper::FileOpen)
7575
.def("FileClose", &LuaStateWrapper::FileClose)
@@ -273,8 +273,8 @@ namespace RTE {
273273
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
274274

275275
// Passthrough LuaMan Functions
276-
const std::vector<std::string>& LuaStateWrapper::DirectoryList(const std::string& relativeDirectory) { return g_LuaMan.DirectoryList(relativeDirectory); }
277-
const std::vector<std::string>& LuaStateWrapper::FileList(const std::string& relativeDirectory) { return g_LuaMan.FileList(relativeDirectory); }
276+
const std::vector<std::string>* LuaStateWrapper::DirectoryList(const std::string& relativeDirectory) { return g_LuaMan.DirectoryList(relativeDirectory); }
277+
const std::vector<std::string>* LuaStateWrapper::FileList(const std::string& relativeDirectory) { return g_LuaMan.FileList(relativeDirectory); }
278278
bool LuaStateWrapper::FileExists(const std::string &fileName) { return g_LuaMan.FileExists(fileName); }
279279
int LuaStateWrapper::FileOpen(const std::string& fileName, const std::string& accessMode) { return g_LuaMan.FileOpen(fileName, accessMode); }
280280
void LuaStateWrapper::FileClose(int fileIndex) { return g_LuaMan.FileClose(fileIndex); }
@@ -923,24 +923,22 @@ namespace RTE {
923923

924924
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
925925

926-
const std::vector<std::string> & LuaMan::DirectoryList(const std::string &filePath) {
927-
thread_local std::vector<std::string> directoryPaths;
928-
directoryPaths.clear();
926+
const std::vector<std::string> * LuaMan::DirectoryList(const std::string &filePath) {
927+
auto *directoryPaths = new std::vector<std::string>();
929928

930929
for (const std::filesystem::directory_entry &directoryEntry : std::filesystem::directory_iterator(System::GetWorkingDirectory() + filePath)) {
931-
if (directoryEntry.is_directory()) { directoryPaths.emplace_back(directoryEntry.path().filename().generic_string()); }
930+
if (directoryEntry.is_directory()) { directoryPaths->emplace_back(directoryEntry.path().filename().generic_string()); }
932931
}
933932
return directoryPaths;
934933
}
935934

936935
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
937936

938-
const std::vector<std::string> & LuaMan::FileList(const std::string &filePath) {
939-
thread_local std::vector<std::string> filePaths;
940-
filePaths.clear();
937+
const std::vector<std::string> * LuaMan::FileList(const std::string &filePath) {
938+
auto *filePaths = new std::vector<std::string>();
941939

942940
for (const std::filesystem::directory_entry &directoryEntry : std::filesystem::directory_iterator(System::GetWorkingDirectory() + filePath)) {
943-
if (directoryEntry.is_regular_file()) { filePaths.emplace_back(directoryEntry.path().filename().generic_string()); }
941+
if (directoryEntry.is_regular_file()) { filePaths->emplace_back(directoryEntry.path().filename().generic_string()); }
944942
}
945943
return filePaths;
946944
}
@@ -1044,9 +1042,6 @@ namespace RTE {
10441042
if (fgets(buf, sizeof(buf), m_OpenedFiles[fileIndex]) != nullptr) {
10451043
return buf;
10461044
}
1047-
#ifndef RELEASE_BUILD
1048-
g_ConsoleMan.PrintString("ERROR: " + std::string(FileEOF(fileIndex) ? "Tried to read past EOF." : "Failed to read from file."));
1049-
#endif
10501045
} else {
10511046
g_ConsoleMan.PrintString("ERROR: Tried to read an invalid or closed file.");
10521047
}

Source/Managers/LuaMan.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -284,8 +284,8 @@ namespace RTE {
284284
double PosRand();
285285

286286
#pragma region Passthrough LuaMan Functions
287-
const std::vector<std::string>& DirectoryList(const std::string& relativeDirectory);
288-
const std::vector<std::string>& FileList(const std::string& relativeDirectory);
287+
const std::vector<std::string>* DirectoryList(const std::string& relativeDirectory);
288+
const std::vector<std::string>* FileList(const std::string& relativeDirectory);
289289
bool FileExists(const std::string &fileName);
290290
int FileOpen(const std::string& fileName, const std::string& accessMode);
291291
void FileClose(int fileIndex);
@@ -433,15 +433,15 @@ namespace RTE {
433433
/// </summary>
434434
/// <param name="relativeDirectory">Directory path relative to the working directory.</param>
435435
/// <returns>A vector of the directories in relativeDirectory.</returns>
436-
const std::vector<std::string> & DirectoryList(const std::string &relativeDirectory);
436+
const std::vector<std::string> * DirectoryList(const std::string &relativeDirectory);
437437

438438
/// <summary>
439439
/// Returns a vector of all the files in relativeDirectory, which is relative to the working directory.
440440
/// Note that a call to this method overwrites any previously returned vector from DirectoryList() or FileList().
441441
/// </summary>
442442
/// <param name="relativeDirectory">Directory path relative to the working directory.</param>
443443
/// <returns>A vector of the files in relativeDirectory.</returns>
444-
const std::vector<std::string> & FileList(const std::string &relativeDirectory);
444+
const std::vector<std::string> * FileList(const std::string &relativeDirectory);
445445

446446
/// <summary>
447447
/// Returns whether or not the specified file exists. You can only check for files inside .rte folders in the working directory.

external/sources/luabind-0.7.1/meson.build

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,12 @@ elif cxx.get_argument_syntax() == 'msvc'
2020
cpp_options = ['cpp_std=vc++20']
2121
endif
2222

23-
if not get_option('use_prebuilt_libraries') or host_machine.system() in ['darwin', 'linux']
24-
luabind = static_library('luabind071', luabind_src, dependencies: luabind_dependencies, include_directories:luabind_include, cpp_args:cpp_args+ luabind_args, override_options: ['warning_level=0']+ cpp_options)
25-
else
26-
luabind = []
27-
if get_option('debug')
28-
deps = cxx.find_library('luabind-debug' , dirs: meson.current_source_dir()/'_Bin')
29-
else
30-
deps = cxx.find_library('luabind-release', dirs: meson.current_source_dir()/'_Bin')
31-
endif
23+
if (not get_option('debug')) or get_option('debug_type') == 'release'
24+
luabind_args += ['-DLUABIND_NO_ERROR_CHECKING=1']
3225
endif
3326

27+
luabind = static_library('luabind071', luabind_src, dependencies: luabind_dependencies, include_directories:luabind_include, cpp_args:cpp_args+ luabind_args, override_options: ['warning_level=0']+ cpp_options)
28+
3429
luabind_dep = declare_dependency(link_with: luabind, dependencies: deps, include_directories: luabind_include, compile_args: luabind_args)
3530

3631
meson.override_dependency('luabind', luabind_dep)
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
option('use_prebuilt_libraries', type: 'boolean', value: true, yield: true, description: 'On windows use the prebuilt libraries')
1+
option('use_prebuilt_libraries', type: 'boolean', value: true, yield: true, description: 'On windows use the prebuilt libraries')
2+
option('debug_type', type: 'combo', choices: ['full','minimal','release'], value:'minimal', yield: true, description: 'Enable certain Debug features, that might slow down the game')

meson.build

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ elif compiler.get_argument_syntax()== 'msvc'
7373
message('cl detected')
7474
elfname = 'Cortex Command'
7575
extra_args += ['-D_HAS_ITERATOR_DEBUGGING=0', '-D_HAS_AUTO_PTR_ETC=1', '-bigobj']
76+
add_global_arguments('-D_ITERATOR_DEBUG_LEVEL=0', language:'cpp')
7677
add_project_link_arguments(['winmm.lib', 'ws2_32.lib', 'dinput8.lib', 'ddraw.lib', 'dxguid.lib', 'dsound.lib', 'dbghelp.lib'], language:'cpp')
7778
if host_machine.cpu_family() == 'x86'
7879
elfname += ' x86'
@@ -226,9 +227,9 @@ base_exclude_files = [
226227
]
227228

228229
if get_option('install_data')
229-
install_subdir(get_option('cccpdatadir'),
230-
exclude_directories:['.git', '.github', 'Metagames.rte', 'Scenes.rte'],
230+
install_subdir('Data',
231+
exclude_directories:['.git', '.github'],
231232
exclude_files:base_exclude_files,
232-
install_dir:get_option('data_install_dir'),
233+
install_dir:get_option('data_install_dir')/'Data',
233234
strip_directory:true)
234235
endif

meson_darwin.ini

Lines changed: 0 additions & 14 deletions
This file was deleted.

meson_options.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
option('debug_type', type: 'combo', choices: ['full','minimal','release'], value:'minimal', description: 'Enable certain Debug features, that might slow down the game')
2-
option('cccpdatadir', type:'string', value:'.', description: 'Path to the Cortex Command Data Repository')
32
option('data_install_dir', type:'string', value:'share/CortexCommand', description: 'Where to install the data files relative to prefix directory')
43
option('install_fmod', type:'boolean', value: true, description: 'Wether to install the fmod library.')
54
option('fmod_dir', type:'string', value:'lib/CortexCommand/', description: 'Where to install the fmod library relative to prefix directory.')

meson_win.txt

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)