Skip to content

Commit 166d251

Browse files
authored
Merge pull request #39 from zao/port-fixes
Misc. macOS portability fixes
2 parents 744debc + 7433bab commit 166d251

File tree

6 files changed

+23
-8
lines changed

6 files changed

+23
-8
lines changed

engine/render/r_font.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ r_font_c::r_font_c(r_renderer_c* renderer, const char* fontName)
5252
numFontHeight = 0;
5353
fontHeightMap = NULL;
5454

55-
std::string fileNameBase = fmt::format(CFG_DATAPATH "fonts/{}", fontName);
55+
std::string fileNameBase = fmt::format(CFG_DATAPATH "Fonts/{}", fontName);
5656

5757
// Open info file
5858
std::string tgfName = fileNameBase + ".tgf";

engine/render/r_main.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "r_local.h"
1010

1111
#include <array>
12+
#include <filesystem>
1213
#include <fmt/chrono.h>
1314
#include <map>
1415
#include <numeric>
@@ -1295,7 +1296,9 @@ void r_renderer_c::EndFrame()
12951296
for (int l = 0; l < numLayer; l++) {
12961297
auto& layer = layerSort[l];
12971298
if (layerBreak && layerBreak->first == layer->layer && layerBreak->second == layer->subLayer) {
1299+
#ifdef _WIN32
12981300
DebugBreak();
1301+
#endif
12991302
}
13001303
layer->Render();
13011304
}
@@ -1711,7 +1714,7 @@ void r_renderer_c::DoScreenshot(image_c* i, const char* ext)
17111714
// curTimeSt.tm_hour, curTimeSt.tm_min, curTimeSt.tm_sec, ext);
17121715

17131716
// Make folder if it doesn't exist
1714-
_mkdir(CFG_DATAPATH "Screenshots");
1717+
std::filesystem::create_directory(CFG_DATAPATH "Screenshots");
17151718

17161719
// Save image
17171720
if (i->Save(ssname.c_str())) {

engine/render/r_main.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include <array>
1414
#include <imgui.h>
15+
#include <vector>
1516

1617
// =======
1718
// Classes

libs/LZip/lzip.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
#include <stdio.h>
22
#include <stdlib.h>
33
#include <string.h>
4-
#include <io.h>
54

65
#include "zlib.h"
76

7+
#ifdef _WIN32
8+
#define LZIP_EXPORT __declspec(dllexport)
9+
#else
10+
#define LZIP_EXPORT
11+
#endif
12+
813
extern "C" {
914
#include "lua.h"
1015
#include "lauxlib.h"
@@ -326,7 +331,7 @@ void fs_file_c::Seek(int pos, int mode)
326331
// Seek forward
327332
byte* sk = new byte[diff];
328333
Read(sk, diff);
329-
delete sk;
334+
delete[] sk;
330335
} else if (diff < 0) {
331336
// Restart reading
332337
pU = 0;
@@ -337,7 +342,7 @@ void fs_file_c::Seek(int pos, int mode)
337342
// Seek forward
338343
byte* sk = new byte[seekto];
339344
Read(sk, seekto);
340-
delete sk;
345+
delete[] sk;
341346
}
342347
}
343348
} else {
@@ -668,7 +673,7 @@ static int l_zipFile_Length(lua_State* L)
668673
return 1;
669674
}
670675

671-
extern "C" __declspec(dllexport) int luaopen_lzip(lua_State* L)
676+
extern "C" LZIP_EXPORT int luaopen_lzip(lua_State* L)
672677
{
673678
lua_settop(L, 0);
674679
lua_newtable(L); // Library table
@@ -727,4 +732,4 @@ extern "C" __declspec(dllexport) int luaopen_lzip(lua_State* L)
727732
lua_pop(L, 2);
728733

729734
return 1;
730-
}
735+
}

ui_main.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,11 @@ void ui_main_c::ScriptInit()
286286
lua_pushcfunction(L, traceback);
287287
lua_pushvalue(L, -1);
288288
lua_setfield(L, LUA_REGISTRYINDEX, "traceback");
289+
290+
#if _WIN32
289291
lua_pushboolean(L, 1);
290292
lua_setfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
293+
#endif
291294

292295
// Add libraries and APIs
293296
lua_gc(L, LUA_GCSTOP, 0);
@@ -562,4 +565,4 @@ int ui_main_c::KeyForName(const char* keyName)
562565
}
563566
}
564567
return 0;
565-
}
568+
}

ui_subscript.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,10 @@ bool ui_subscript_c::Start()
314314
lua_rawseti(L, LUA_REGISTRYINDEX, 0);
315315
lua_pushcfunction(L, traceback);
316316

317+
#ifdef _WIN32
317318
lua_pushboolean(L, 1);
318319
lua_setfield(L, LUA_REGISTRYINDEX, "LUA_NOENV");
320+
#endif
319321

320322
// Add libraries and APIs
321323
lua_gc(L, LUA_GCSTOP, 0);
@@ -446,6 +448,7 @@ void ui_subscript_c::SubScriptFrame()
446448
ui->PCall(extraArgs + 2, 0);
447449
}
448450
FreeString(errorStr);
451+
errorStr = nullptr;
449452
} else {
450453
int extraArgs = ui->PushCallback("OnSubFinished");
451454
if (extraArgs >= 0) {

0 commit comments

Comments
 (0)