Skip to content

Commit b4058fc

Browse files
committed
Fix warnings, explicitly set MSVC version to 17
1 parent bd4952b commit b4058fc

File tree

7 files changed

+33
-51
lines changed

7 files changed

+33
-51
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ jobs:
2929
uses: ilammy/msvc-dev-cmd@v1
3030
with:
3131
arch: x64
32+
ver: 17
3233

3334
- name: Build and install debug
3435
run: |

include/NavKit/NavKit.h

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

src/CMakeLists.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ add_executable (NavKit
3333
module/SceneExtract.cpp
3434
module/Settings.cpp
3535
util/FileUtil.cpp
36-
util/ErrorHandler.cpp
36+
util/ErrorHandler.cpp
3737
)
3838
target_include_directories(NavKit PUBLIC "${PROJECT_BINARY_DIR}")
3939
target_include_directories(NavKit PRIVATE ${SIMPLEINI_INCLUDE_DIRS})
@@ -73,7 +73,6 @@ add_custom_command(
7373
COMMENT "Copying ${NAV_WEAKNESS_DLL} to ${CMAKE_BINARY_DIR}"
7474
)
7575

76-
7776
file(COPY "${NavKit_SOURCE_DIR}/lib/Debug/ResourceLib_HM3.dll" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
7877
file(COPY "${NavKit_SOURCE_DIR}/bin/Glacier2Obj.exe" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
7978
file(COPY "${NavKit_SOURCE_DIR}/src/resource/Glacier2Obj.py" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}")
@@ -113,6 +112,4 @@ target_link_libraries(NavKit
113112
)
114113
set_target_properties(NavKit PROPERTIES WIN32_EXECUTABLE TRUE)
115114

116-
if (CMAKE_VERSION VERSION_GREATER 3.12)
117-
set_property(TARGET NavKit PROPERTY CXX_STANDARD 20)
118-
endif()
115+
set_property(TARGET NavKit PROPERTY CXX_STANDARD 20)

src/NavKit.cpp

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2020
* SOFTWARE.
2121
*/
22-
#include "../include/NavKit/NavKit.h"
2322
#include <SDL.h>
2423
#include <cpptrace/from_current.hpp>
2524
#include "../include/NavKit/module/Airg.h"
@@ -36,10 +35,6 @@
3635
#undef main
3736

3837
int SDL_main(const int argc, char **argv) {
39-
return NavKit::runProgram();
40-
}
41-
42-
int NavKit::runProgram() {
4338
CPPTRACE_TRY
4439
{
4540
std::thread logThread(Logger::logRunner);
@@ -86,17 +81,14 @@ int NavKit::runProgram() {
8681

8782
NFD_Quit();
8883
renderer.closeWindow();
84+
return 0;
8985
}
9086
CPPTRACE_CATCH(const std::exception& e) {
9187
ErrorHandler::openErrorDialog("An unexpected error occurred: " + std::string(e.what()) + "\n\nStack Trace:\n" +
9288
cpptrace::from_current_exception().to_string());
93-
94-
return 1;
9589
} catch (...) {
96-
ErrorHandler::openErrorDialog("An unexpected error occurred:\n\nStack Trace:\n" +
90+
ErrorHandler::openErrorDialog("An unexpected error occurred:\n\nStack Trace: \n" +
9791
cpptrace::from_current_exception().to_string());
98-
return 1;
9992
}
100-
10193
return 0;
10294
}

src/model/ReasoningGrid.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#include "../../include/NavKit/model/ReasoningGrid.h"
2-
#include "../../include/NavKit/module/Logger.h"
2+
#include <algorithm>
3+
#include <from_current.hpp>
4+
#include <set>
35
#include "../../include/NavKit/module/Airg.h"
6+
#include "../../include/NavKit/module/Logger.h"
47
#include "../../include/NavKit/module/Navp.h"
58
#include "../../include/NavKit/module/Renderer.h"
69
#include "../../include/NavKit/util/ErrorHandler.h"
7-
#include <algorithm>
8-
#include <from_current.hpp>
9-
#include <set>
1010

1111
const void Vec4::writeJson(std::ostream &f) {
1212
f << "{";

src/module/InputHandler.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1+
#include "../../include/NavKit/module/InputHandler.h"
12
#include "../../include/NavKit/module/Airg.h"
23
#include "../../include/NavKit/module/Gui.h"
3-
#include "../../include/NavKit/module/InputHandler.h"
44
#include "../../include/NavKit/module/Navp.h"
55
#include "../../include/NavKit/module/Renderer.h"
66
#include "../../include/RecastDemo/imgui.h"
77

88
#include <algorithm>
9-
#include <SDL_opengl.h>
109
#include <SDL.h>
10+
#include <SDL_opengl.h>
1111

1212
const int InputHandler::QUIT = 1;
1313

@@ -32,6 +32,7 @@ int InputHandler::handleInput() {
3232
Renderer& renderer = Renderer::getInstance();
3333
Airg& airg = Airg::getInstance();
3434
Navp& navp = Navp::getInstance();
35+
bool done = false;
3536
while (SDL_PollEvent(&event)) {
3637
switch (event.type) {
3738
case SDL_WINDOWEVENT:
@@ -109,8 +110,8 @@ int InputHandler::handleInput() {
109110
break;
110111

111112
case SDL_QUIT:
112-
return QUIT;
113-
113+
done = true;
114+
break;
114115
default:
115116
break;
116117
}
@@ -128,6 +129,9 @@ int InputHandler::handleInput() {
128129
if (SDL_GetModState() & KMOD_CTRL) {
129130
keybSpeed /= 4.0f;
130131
}
132+
if (done) {
133+
return QUIT;
134+
}
131135
return 0;
132136
}
133137

src/util/ErrorHandler.cpp

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "../../include/NavKit/util/ErrorHandler.h"
2-
#include "../../include/NavKit/module/Renderer.h"
32
#include "../../include/NavKit/Resource.h"
3+
#include "../../include/NavKit/module/Renderer.h"
44

55
std::string *ErrorHandler::errorMessage = nullptr;
66

@@ -18,27 +18,26 @@ INT_PTR CALLBACK ErrorHandler::ErrorDialogHandler(HWND hwndDlg, UINT uMsg, WPARA
1818
EndDialog(hwndDlg, IDOK);
1919
return TRUE;
2020
}
21-
if (LOWORD(wParam) == IDC_COPY_BUTTON) {
22-
OpenClipboard(hwndDlg);
23-
EmptyClipboard();
24-
if (errorMessage) {
25-
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, errorMessage->length() + 1);
26-
char *data = (char *) GlobalLock(hMem);
27-
strcpy_s(data, errorMessage->length() + 1, errorMessage->c_str());
28-
GlobalUnlock(hMem);
29-
SetClipboardData(CF_TEXT, hMem);
30-
CloseClipboard();
31-
GlobalFree(hMem);
21+
if (LOWORD(wParam) == IDC_COPY_BUTTON) {
22+
OpenClipboard(hwndDlg);
23+
EmptyClipboard();
24+
if (errorMessage) {
25+
HGLOBAL hMem = GlobalAlloc(GMEM_MOVEABLE, errorMessage->length() + 1);
26+
char *data = (char *) GlobalLock(hMem);
27+
strcpy_s(data, errorMessage->length() + 1, errorMessage->c_str());
28+
GlobalUnlock(hMem);
29+
SetClipboardData(CF_TEXT, hMem);
30+
CloseClipboard();
31+
GlobalFree(hMem);
32+
}
33+
return TRUE;
3234
}
33-
return TRUE;
34-
}
35-
break;
35+
return FALSE;
3636
default: return FALSE;
3737
}
38-
return FALSE;
3938
}
4039

41-
void ErrorHandler::openErrorDialog(const std::string& message) {
40+
void ErrorHandler::openErrorDialog(const std::string &message) {
4241
errorMessage = new std::string(message);
4342
DialogBoxParamA(GetModuleHandle(nullptr), MAKEINTRESOURCE(IDD_ERROR_DIALOG), Renderer::hwnd, ErrorDialogHandler, 0);
4443
}

0 commit comments

Comments
 (0)