Windows: Stop setting working directory/current directory to directory of .exe path

I found a way to set the default working directory when running from visual studio debugger to the output directory, so this code is unnecessary now
This commit is contained in:
UnknownShadow200 2022-05-31 23:16:18 +10:00
parent 271b5faa4a
commit 5b27d4fc37
4 changed files with 13 additions and 20 deletions

View file

@ -89,6 +89,9 @@
<OutDir>$(SolutionDir)x64\Release\</OutDir>
<IntDir>x64\Release\obj\</IntDir>
</PropertyGroup>
<PropertyGroup>
<LocalDebuggerWorkingDirectory>$(OutDir)</LocalDebuggerWorkingDirectory>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>

View file

@ -16,6 +16,7 @@
#include "Chat.h"
#include "Inventory.h"
#include "TexturePack.h"
#include "Utils.h"
/*########################################################################################################################*
@ -55,6 +56,7 @@ IMapImporter Map_FindImporter(const cc_string* path) {
}
cc_result Map_LoadFrom(const cc_string* path) {
cc_string relPath, fileName, fileExt;
IMapImporter importer;
struct Stream stream;
cc_result res;
@ -71,11 +73,16 @@ cc_result Map_LoadFrom(const cc_string* path) {
}
/* No point logging error for closing readonly file */
stream.Close(&stream);
(void)stream.Close(&stream);
if (res) Logger_SysWarn2(res, "decoding", path);
World_SetNewMap(World.Blocks, World.Width, World.Height, World.Length);
LocalPlayer_MoveToSpawn();
relPath = *path;
Utils_UNSAFE_GetFilename(&relPath);
String_UNSAFE_Separate(&relPath, '.', &fileName, &fileExt);
String_Copy(&World.Name, &fileName);
return res;
}

View file

@ -1744,17 +1744,13 @@ void HotkeyListScreen_Show(void) {
static void LoadLevelScreen_EntryClick(void* screen, void* widget) {
cc_string path; char pathBuffer[FILENAME_SIZE];
struct ListScreen* s = (struct ListScreen*)screen;
cc_string relPath, fileName, fileExt;
cc_result res;
relPath = ListScreen_UNSAFE_GetCur(s, widget);
cc_string relPath = ListScreen_UNSAFE_GetCur(s, widget);
String_InitArray(path, pathBuffer);
String_Format1(&path, "maps/%s", &relPath);
res = Map_LoadFrom(&path);
String_UNSAFE_Separate(&relPath, '.', &fileName, &fileExt);
String_Copy(&World.Name, &fileName);
/* FileNotFound error may be because user deleted maps from disc */
if (res != ReturnCode_FileNotFound) return;
Chat_AddRaw("&eReloading level list as it may be out of date");

View file

@ -926,18 +926,5 @@ int Platform_GetCommandLineArgs(int argc, STRING_REF char** argv, cc_string* arg
return i;
}
cc_result Platform_SetDefaultCurrentDirectory(int argc, char **argv) {
WCHAR path[NATIVE_STR_LEN + 1];
int i, len;
cc_result res = Process_RawGetExePath(path, &len);
if (res) return res;
/* Get rid of filename at end of directory */
for (i = len - 1; i >= 0; i--, len--) {
if (path[i] == '/' || path[i] == '\\') break;
}
path[len] = '\0';
return SetCurrentDirectoryW(path) ? 0 : GetLastError();
}
cc_result Platform_SetDefaultCurrentDirectory(int argc, char** argv) { return 0; }
#endif