medfall

A super great game engine
Log | Files | Refs

commit 49a8da8d2141e54f95abee2776b2b046e5712d19
parent f61c4a22fd31932362891f43573906da27213dfc
Author: Michael Savage <mikejsavage@gmail.com>
Date:   Sat, 11 Nov 2017 11:57:32 +0200

Windows fixes

Diffstat:
clipmap.cc | 2++
intrinsics.h | 3---
make.lua | 2+-
platform_alignment.h | 2+-
scripts/gen_makefile.lua | 2+-
unix_backtrace.h | 3+++
win32_backtrace.h | 13+++++++++++++
7 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/clipmap.cc b/clipmap.cc @@ -113,6 +113,8 @@ struct RGBA { }; GAME_INIT( game_init ) { + net_init(); + // load quadtree { clipmap.heightmap = alloc_array2d< u16 >( &mem->persistent_arena, 4096, 4096 ); diff --git a/intrinsics.h b/intrinsics.h @@ -4,7 +4,6 @@ #include <stdlib.h> #include <stdint.h> #include <string.h> -#include <errno.h> #include "platform.h" #include "platform_backtrace.h" @@ -59,8 +58,6 @@ typedef uintptr_t uptr; inline void assert_impl( const bool predicate, const char * message ) { if( !predicate ) { puts( message ); - int err = errno; - printf( "errno(%d): %s\n", err, strerror( err ) ); print_backtrace_and_abort(); } } diff --git a/make.lua b/make.lua @@ -19,7 +19,7 @@ if OS == "macos" then end bin( "medfall", { "main", "clipmap", "heightmap", "decompress_bc", "skybox", "platform_network", game_objs }, { "lz4", game_libs } ) -msvc_bin_ldflags( "medfall", "opengl32.lib gdi32.lib" ) +msvc_bin_ldflags( "medfall", "opengl32.lib gdi32.lib Ws2_32.lib" ) gcc_bin_ldflags( "medfall", game_ldflags ) bin( "launch", { "launcher/main", "http", "sha2", "platform_network", game_objs }, { "imgui", "monocypher", "whereami", game_libs } ) diff --git a/platform_alignment.h b/platform_alignment.h @@ -4,7 +4,7 @@ #if COMPILER_MSVC #define ALIGNOF( x ) __alignof( x ) -#define ALIGNTO( x ) TODO +#define ALIGNTO( n ) __declspec( align( n ) ) #elif COMPILER_GCCORCLANG #define ALIGNOF( x ) __alignof__( x ) #define ALIGNTO( n ) __attribute__(( aligned( n ) )) diff --git a/scripts/gen_makefile.lua b/scripts/gen_makefile.lua @@ -16,7 +16,7 @@ local configs = { cxxflags = "/I . /c /Oi /Gm- /GR- /EHa- /EHsc /nologo /DNOMINMAX /DWIN32_LEAN_AND_MEAN", ldflags = "user32.lib shell32.lib advapi32.lib dbghelp.lib /nologo", - warnings = "/W4 /wd4100 /wd4201 /wd4189 /wd4351 /wd4505 /wd4127 /wd4530 /wd4702 /D_CRT_SECURE_NO_WARNINGS", + warnings = "/W4 /wd4100 /wd4189 /wd4201 /wd4324 /wd4351 /wd4127 /wd4505 /wd4530 /wd4702 /D_CRT_SECURE_NO_WARNINGS", }, [ "windows-64" ] = { }, diff --git a/unix_backtrace.h b/unix_backtrace.h @@ -6,6 +6,9 @@ #include <execinfo.h> inline void print_backtrace_and_abort() { + int error = errno; + printf( "errno = %d: %s\n", error, strerror( error ) ); + void * stack[ 128 ]; const int stack_size = backtrace( stack, 128 ); backtrace_symbols_fd( stack, stack_size, STDERR_FILENO ); diff --git a/win32_backtrace.h b/win32_backtrace.h @@ -1,6 +1,7 @@ #pragma once #include <windows.h> +#include <errno.h> #pragma warning( push ) #pragma warning( disable : 4091 ) @@ -8,6 +9,18 @@ #pragma warning( pop ) inline void print_backtrace_and_abort() { + { + int error = errno; + printf( "errno = %d: %s\n", error, strerror( error ) ); + } + { + DWORD error = GetLastError(); + char buf[ 1024 ]; + FormatMessageA( FORMAT_MESSAGE_FROM_SYSTEM, NULL, error, + MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), buf, sizeof( buf ), NULL ); + printf( "GetLastError = %d: %s", error, buf ); + } + const int max_symbol_len = 1024; HANDLE process = GetCurrentProcess();