Skip to content

Commit

Permalink
Merge pull request #87 from Arcnor/msvc-warnings
Browse files Browse the repository at this point in the history
enable stricter MSVC warnings, fix some of them
  • Loading branch information
JeodC authored Apr 19, 2024
2 parents 4289427 + 6e772ca commit 1fb980d
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 7 deletions.
4 changes: 2 additions & 2 deletions 2dlib/font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ void grFont::translate_mono_char(grSurface *sf, int x, int y, int index, gr_font

int grFont::draw_char(grSurface *sf, int x, int y, int ch, tCharProperties *chprop) {
gr_font_record *ft;
int next_x, width, index;
int next_x = 0, width, index;

ASSERT(m_FontHandle > -1);
if ((ch < min_ascii()) || (ch > max_ascii()))
Expand Down Expand Up @@ -615,7 +615,7 @@ int grFont::draw_char(grSurface *sf, int x, int y, int ch, tCharProperties *chpr

int grFont::draw_char(grSurface *sf, int x, int y, int ch, int sx, int sy, int sw, int sh, tCharProperties *chprop) {
gr_font_record *ft;
int next_x, width, index;
int next_x = 0, width, index;

ASSERT(m_FontHandle > -1);
if ((ch < min_ascii()) || (ch > max_ascii()))
Expand Down
15 changes: 14 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ ENDIF()
IF (WIN32)
SET(D3_GAMEDIR "c:/games/Descent3/")
set (CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} "lib/win" "lib/win/directx")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Gm /EHsc /RTC1 /W3 /nologo /c /ZI /TP /errorReport:prompt")
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /EHsc /RTC1 /W3 /nologo /c /Zi /TP /errorReport:prompt")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /GL /FD /EHsc /W3 /nologo /c /Zi /TP /errorReport:prompt")

SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO /SUBSYSTEM:WINDOWS /NODEFAULTLIB:LIBC")
Expand All @@ -65,6 +65,19 @@ IF (WIN32)
FIND_LIBRARY(DINPUT_LIBRARY NAMES dinput "${CMAKE_SOURCE_DIR}/lib/win" "${CMAKE_SOURCE_DIR}/lib/win/directx")
FIND_LIBRARY(DXGUID_LIBRARY NAMES dxguid "${CMAKE_SOURCE_DIR}/lib/win" "${CMAKE_SOURCE_DIR}/lib/win/directx")
FIND_LIBRARY(DDRAW_LIBRARY NAMES ddraw "${CMAKE_SOURCE_DIR}/lib/win" "${CMAKE_SOURCE_DIR}/lib/win/directx")

if (MSVC AND CMAKE_CXX_SIMULATE_ID STREQUAL "")
add_compile_options("/we4150") # deletion of pointer to incomplete type 'type'; no destructor called
# add_compile_options("/we4305") # truncation from 'X' to 'Y'
add_compile_options("/we4474") # too many arguments passed for format string
add_compile_options("/we4700") # uninitialized local variable 'X' used
add_compile_options("/we4804") # unsafe use of type 'bool' in operation
add_compile_options("/we4806") # unsafe operation: no value of type 'bool' promoted to type 'int' can equal the given constant
add_compile_options("/we4473") # not enough arguments passed for format string
add_compile_options("/we4477") # format string requires argument of type X but variadic argument Y has type Z
add_compile_options("/we4715") # 'function' : not all control paths return a value
add_compile_options("/we4834") # discarding return value of function with [[nodiscard]] attribute
endif()
ENDIF ()

MESSAGE("Install will copy files to ${D3_GAMEDIR}")
Expand Down
6 changes: 4 additions & 2 deletions Descent3/multi_external.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
#include "networking.h"
#include "descent.h" //for MSN_NAMELEN
#include "byteswap.h"
#include <cassert>

#define NETGAME_NAME_LEN 32
#define NETGAME_SCRIPT_LEN 32
Expand Down Expand Up @@ -286,9 +287,10 @@ inline void MultiAddFloat(float element, ubyte *data, int *count) {
}

inline void MultiAddString(char *str, ubyte *data, int *count) {
ubyte len = strlen(str) + 1;
size_t len = strlen(str) + 1;
assert(len <= 0xFF);

MultiAddByte(len, data, count);
MultiAddByte((ubyte)len, data, count);
memcpy(&data[*count], str, len);
*count += len;
}
Expand Down
2 changes: 1 addition & 1 deletion dd_sndlib/dsound3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@ void sb_buffered_loop_step(win_llsSystem *lls, sound_buffer_info *sb, int force_

pos_state old_pos_state;
float old_pan;
float old_volume;
float old_volume = 0.0f;

ASSERT(lls->m_mixer_type != SOUND_MIXER_SOFTWARE_16 && lls->m_mixer_type != SOUND_MIXER_NONE);

Expand Down
2 changes: 1 addition & 1 deletion music/omflex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ bool OutrageMusicSeq::LoadTheme(const char *file) {

case OMFCMD_COMPARE: {
tMusicVal val;
sscanf(operand, "r%d", &val);
sscanf(operand, "r%hd", &val);
ADD_NEW_INS_NUM(OMFCMD_COMPARE, val);
break;
}
Expand Down

0 comments on commit 1fb980d

Please sign in to comment.