Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows Visual Studio 2022 update #247

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,9 @@ engine/*.tar.gz
# clangd artifacts
compile_commands.json
.cache/

# If built on windows via cmake, those folders will be generated by camke or have
# to be generated by the user. We don't want them to be in the repo
dependencies/**
bin/**
build/**
77 changes: 48 additions & 29 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ cmake_policy(SET CMP0063 NEW)

PROJECT(FTEQuake)

# On Windows put all the built libs/exes/etc. in one directory
IF (WIN32)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")
ENDIF()

INCLUDE_DIRECTORIES(
engine/common
engine/client
Expand Down Expand Up @@ -127,15 +134,41 @@ ELSE()
SET(SYS_LIBS ${SYS_LIBS})
ENDIF()

FIND_PACKAGE(ZLIB)
IF(ZLIB_FOUND)
# On windows we build zlib by including its source (which includes a CMakeLists.txt)
# into a folder dependencies.
IF (WIN32)

IF(NOT DEFINED ZLIB_SOURCE_DIR)
SET(ZLIB_SOURCE_DIR "dependencies/zlib")
ENDIF()

MESSAGE("Zlib source directory is set to: " ${ZLIB_SOURCE_DIR})

IF (NOT EXISTS ${ZLIB_SOURCE_DIR})
MESSAGE("Zlib source directory could not be found: " ${ZLIB_SOURCE_DIR})
ENDIF()

ADD_SUBDIRECTORY(${ZLIB_SOURCE_DIR})
SET(ZLIB_LIBRARIES zlib)
SET(ZLIB_STATIC zlibstatic)
SET(ZLIB_LIBRARY zlib)
SET(ZLIB_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/${ZLIB_SOURCE_DIR})

SET(FTE_LIB_DEFINES ${FTE_LIB_DEFINES};ZLIB_STATIC)
SET(FTE_LIBS ${FTE_LIBS} ${ZLIB_LIBRARIES})
SET(FTESV_LIBS ${FTESV_LIBS} ${ZLIB_LIBRARIES})
SET(FTEQCC_LIBS ${FTEQCC_LIBS} ${ZLIB_LIBRARIES})
ELSE()
MESSAGE(WARNING "libz library NOT available. compressed pk3 will not be available.")
SET(FTE_LIB_DEFINES ${FTE_LIB_DEFINES};NO_ZLIB)
FIND_PACKAGE(ZLIB)
IF(ZLIB_FOUND)
SET(FTE_LIB_DEFINES ${FTE_LIB_DEFINES};ZLIB_STATIC)
SET(FTE_LIBS ${FTE_LIBS} ${ZLIB_LIBRARIES})
SET(FTESV_LIBS ${FTESV_LIBS} ${ZLIB_LIBRARIES})
SET(FTEQCC_LIBS ${FTEQCC_LIBS} ${ZLIB_LIBRARIES})
ELSE()
MESSAGE(WARNING "libz library NOT available. compressed pk3 will not be available.")
SET(FTE_LIB_DEFINES ${FTE_LIB_DEFINES};NO_ZLIB)
ENDIF()
ENDIF()

FIND_PACKAGE(BZip2)
Expand Down Expand Up @@ -256,7 +289,10 @@ IF(CMAKE_BUILD_TYPE MATCHES "Debug")
ENDIF()
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_FILE_OFFSET_BITS=64")

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFTE_LIBRARY_PATH=${CMAKE_INSTALL_FULL_LIBDIR}/${FTE_INSTALL_LIBDIR} -DFTE_DATA_DIR=${CMAKE_INSTALL_FULL_DATAROOTDIR}")
# NOTE(pythno): On windows we have folder names with spaces, eg. "Program Files (x86)". Therefore the path variables have to be surrounded
# with doublequotes (") to make it visiable as one string to windows and not multiple.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DFTE_LIBRARY_PATH=\"${CMAKE_INSTALL_FULL_LIBDIR}/${FTE_INSTALL_LIBDIR}\" -DFTE_DATA_DIR=\"${CMAKE_INSTALL_FULL_DATAROOTDIR}\"")


FUNCTION(EMBED_PLUGIN_META PLUGNAME PLUGTITLE PLUGDESC)
SET_TARGET_PROPERTIES(plug_${PLUGNAME} PROPERTIES OUTPUT_NAME "${PLUGNAME}")
Expand Down Expand Up @@ -307,10 +343,8 @@ ELSEIF(WIN32 AND NOT FTE_USE_SDL)
engine/client/snd_wasapi.c
engine/client/snd_win.c
engine/client/snd_xaudio.c
engine/client/sys_win.c

engine/client/sys_win.c
engine/gl/gl_vidnt.c

engine/d3d/d3d_backend.c
engine/d3d/d3d_image.c
engine/d3d/d3d_shader.c
Expand Down Expand Up @@ -377,17 +411,14 @@ ELSEIF(UNIX AND NOT FTE_USE_SDL) #linux(ish)
engine/client/sys_linux.c
engine/common/sys_linux_threads.c
engine/common/net_ssl_gnutls.c

engine/client/snd_al.c
engine/client/snd_alsa.c
engine/client/snd_linux.c
engine/client/snd_pulse.c
engine/client/snd_sdl.c #we use SDL audio even without sys_sdl, because of pulseaudio fucking over alsa, alsa fucking over oss3, and oss4 not being used. Either way, openal should be the default anyway.

engine/client/cd_linux.c
engine/gl/gl_vidlinuxglx.c
engine/gl/gl_videgl.c

# engine/gl/gl_vidrpi.c
# engine/gl/gl_vidwayland.c
)
Expand Down Expand Up @@ -599,7 +630,6 @@ SET(FTE_COMMON_FILES
engine/common/sha2.c
engine/common/translate.c
engine/common/zone.c

#important headers
engine/common/bothdefs.h
engine/common/config_fteqw.h
Expand All @@ -608,7 +638,6 @@ SET(FTE_COMMON_FILES
engine/common/config_wastes.h
engine/common/config_freecs.h
engine/common/config_fteqw_noweb.h

#useless headers that I'll never search for
engine/client/api_menu.h
engine/client/cdaudio.h
Expand Down Expand Up @@ -681,31 +710,25 @@ SET(FTE_COMMON_FILES
#engine/sw/sw_spans.h
engine/vk/vkrenderer.h
engine/web/ftejslib.h


#sigh
engine/client/pr_skelobj.c
engine/client/m_download.c
engine/client/net_master.c

engine/client/net_master.c
#these are here because of hitmodel etc
engine/gl/gl_heightmap.c
engine/gl/gl_hlmdl.c
engine/gl/gl_model.c

engine/gl/gl_model.c
engine/server/sv_move.c
engine/server/sv_phys.c
engine/server/world.c

${FTE_QCVM_FILES}
engine/qclib/hash.c

engine/server/world.c
${FTE_QCVM_FILES}
engine/qclib/hash.c
engine/http/httpclient.c
)

SET(FTE_SERVER_FILES
engine/server/net_preparse.c
engine/server/pr_cmds.c
engine/server/pr_cmds.c
engine/server/pr_lua.c
engine/server/pr_q1qvm.c
engine/server/savegame.c
Expand Down Expand Up @@ -785,8 +808,6 @@ SET(FTE_CLIENT_FILES
engine/client/view.c
engine/client/wad.c
engine/client/zqtp.c


#These are generic renderer files and no longer gl-specific (for the most part)
engine/gl/gl_alias.c
engine/gl/gl_font.c
Expand All @@ -796,7 +817,6 @@ SET(FTE_CLIENT_FILES
engine/gl/gl_shadow.c
engine/gl/gl_warp.c
engine/gl/ltface.c

#these are renderer-specific
engine/client/vid_headless.c
${FTE_GL_FILES}
Expand Down Expand Up @@ -1216,7 +1236,6 @@ IF(0)
# engine/sw/sw_vidwin.c
engine/common/mathlib.c
# engine/client/in_win.c

engine/sw/sw.h
engine/sw/sw_spans.h
)
Expand Down
3 changes: 2 additions & 1 deletion engine/common/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -7216,7 +7216,8 @@ static qboolean Mods_AddManifest(void *usr, ftemanifest_t *man, enum modsourcety
//note that intrinsics are ignored entirely if someone took the time to make any other kind of fmf for that basedir.
for (p = 0; p < nummods; p++)
{
if (modlist[p].manifest && !strcmp(modlist[p].manifest->basedir?:"", man->basedir?:"") && !strcmp(modlist[p].manifest->mainconfig?:"", man->mainconfig?:"") && ((modlist[p].sourcetype!=MST_INTRINSIC&&sourcetype==MST_INTRINSIC) || !Q_strcasecmp(modlist[p].manifest->installation, man->installation)))
// NOTE(pythno): The original code without providing a statement after '?' won't compile with msvc
if (modlist[p].manifest && !strcmp(modlist[p].manifest->basedir ? modlist[p].manifest->basedir :"", man->basedir ? man->basedir :"") && !strcmp(modlist[p].manifest->mainconfig ? modlist[p].manifest->mainconfig :"", man->mainconfig ? man->mainconfig :"") && ((modlist[p].sourcetype!=MST_INTRINSIC&&sourcetype==MST_INTRINSIC) || !Q_strcasecmp(modlist[p].manifest->installation, man->installation)))
return false;
}
break;
Expand Down
4 changes: 4 additions & 0 deletions engine/common/fs_zip.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,17 @@
# endif
# include <zlib.h>

// NOTE(pythno): zlib64 is not available if we compile zlib from source. Both
// libs will be called just zlib.lib
/*
# ifdef _MSC_VER
# ifdef _WIN64
# pragma comment(lib, MSVCLIBSPATH "zlib64.lib")
# else
# pragma comment(lib, MSVCLIBSPATH "zlib.lib")
# endif
# endif
*/

# ifdef DYNAMIC_ZLIB
# define ZLIB_LOADED() (zlib_handle!=NULL)
Expand Down
7 changes: 7 additions & 0 deletions engine/server/sv_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,20 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

*/

#if defined(WIN32)
#include <stdint.h> // NOTE(pythno): Needed for windows 'intmax_t'
#endif

#include "quakedef.h"
#include "netinc.h"
#include "fs.h" //for updates
#ifdef SQL
#include "sv_sql.h"
#endif

#include <sys/types.h>

#ifndef CLIENTONLY
#define Q2EDICT_NUM(i) (q2edict_t*)((char *)ge->edicts+(i)*ge->edict_size)

Expand Down
Loading