Skip to content

Commit

Permalink
Fixed building on Windows 8.1 and 10
Browse files Browse the repository at this point in the history
Former-commit-id: abcd09d
  • Loading branch information
mwydmuch committed Oct 19, 2017
1 parent a0ff517 commit b8a7002
Show file tree
Hide file tree
Showing 9 changed files with 101 additions and 43 deletions.
3 changes: 2 additions & 1 deletion src/vizdoom/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,8 @@ add_executable( vizdoom WIN32 MACOSX_BUNDLE
viz_main.cpp
viz_message_queue.cpp
viz_screen.cpp
viz_shared_memory.cpp)
viz_shared_memory.cpp
viz_system.cpp)

set_source_files_properties( xlat/parse_xlat.cpp PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/xlat_parser.c" )
set_source_files_properties( sc_man.cpp PROPERTIES OBJECT_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/sc_man_scanner.h" )
Expand Down
2 changes: 1 addition & 1 deletion src/vizdoom/src/d_net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@

//VIZDOOM_CODE
#include "viz_main.h"
#include "viz_defines.h"
#include "viz_system.h"

EXTERN_CVAR (Bool, viz_controlled)
EXTERN_CVAR (Bool, viz_async)
Expand Down
1 change: 1 addition & 0 deletions src/vizdoom/src/posix/cocoa/i_system.mm
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
#include "v_text.h"
#include "x86.h"

//VIZDOOM_CODE
#include "viz_main.h"


Expand Down
1 change: 1 addition & 0 deletions src/vizdoom/src/posix/sdl/i_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
#include "m_fixed.h"
#include "g_level.h"

//VIZDOOM_CODE
#include "viz_main.h"

#ifdef __APPLE__
Expand Down
40 changes: 3 additions & 37 deletions src/vizdoom/src/viz_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,36 +20,19 @@
THE SOFTWARE.
*/

#include <boost/interprocess/ipc/message_queue.hpp>
#ifndef VIZ_OS_WIN
#include <boost/thread.hpp>
#endif

#ifdef VIZ_OS_WIN
#include <Windows.h>
#else
#include <unistd.h>
#endif

#include "viz_main.h"
#include "viz_defines.h"
#include "viz_system.h"
#include "viz_input.h"
#include "viz_game.h"
#include "viz_screen.h"
#include "viz_shared_memory.h"
#include "viz_message_queue.h"

#include "d_main.h"
#include "d_net.h"
#include "g_game.h"
#include "sbar.h"
#include "c_dispatch.h"
#include "i_system.h"

namespace b = boost;
#ifndef VIZ_OS_WIN
namespace bt = boost::this_thread;
#endif

/* CVARs and CCMDs */
/*--------------------------------------------------------------------------------------------------------------------*/
Expand Down Expand Up @@ -126,6 +109,7 @@ CCMD(viz_set_seed){
VIZ_DebugMsg(2, VIZ_FUNC, "viz_seed changed to: %d.", rngseed);
}


/* Flow */
/*--------------------------------------------------------------------------------------------------------------------*/

Expand Down Expand Up @@ -272,6 +256,7 @@ bool VIZ_IsPaused(){
//&& !paused && !pauseext && menuactive == MENU_Off && ConsoleState != c_down && ConsoleState != c_falling
}


/* CVARs settings */
/*--------------------------------------------------------------------------------------------------------------------*/

Expand Down Expand Up @@ -495,22 +480,3 @@ void VIZ_DebugMsg(int level, const char *func, const char *msg, ...){

VIZ_PrintFuncMsg(func, debug_msg);
}

void VIZ_InterruptionPoint(){
#ifndef VIZ_OS_WIN
try{
bt::interruption_point();
}
catch(b::thread_interrupted &ex){
exit(0);
}
#endif
}

void VIZ_Sleep(unsigned int ms){
#ifdef VIZ_OS_WIN
Sleep(ms);
#else
usleep(ms);
#endif
}
4 changes: 0 additions & 4 deletions src/vizdoom/src/viz_main.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,4 @@ void VIZ_Error(const char *func, const char *error, ...);

void VIZ_DebugMsg(int level, const char *func, const char *msg, ...);

void VIZ_InterruptionPoint();

void VIZ_Sleep(unsigned int ms);

#endif
62 changes: 62 additions & 0 deletions src/vizdoom/src/viz_system.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
Copyright (C) 2016 by Wojciech Jaśkowski, Michał Kempka, Grzegorz Runc, Jakub Toczek, Marek Wydmuch
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

#include "viz_system.h"
#include "viz_defines.h"

#ifdef VIZ_OS_WIN
#define USE_WINDOWS_DWORD
#include <Windows.h>
#else
#include <unistd.h>
#endif

#include <boost/chrono.hpp>
#include <boost/thread.hpp>

namespace b = boost;
namespace bt = boost::this_thread;
namespace bc = boost::chrono;


/* Sleep and interruptions handling */
/*--------------------------------------------------------------------------------------------------------------------*/

void VIZ_InterruptionPoint(){
#ifndef VIZ_OS_WIN
try{
bt::interruption_point();
}
catch(b::thread_interrupted &ex){
exit(0);
}
#endif
}

void VIZ_Sleep(unsigned int ms){
//bt::sleep_for(bc::milliseconds(ms));
#ifdef VIZ_OS_WIN
Sleep(ms);
#else
usleep(ms);
#endif
}
30 changes: 30 additions & 0 deletions src/vizdoom/src/viz_system.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
Copyright (C) 2016 by Wojciech Jaśkowski, Michał Kempka, Grzegorz Runc, Jakub Toczek, Marek Wydmuch
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

#ifndef __VIZ_SYSTEM_H__
#define __VIZ_SYSTEM_H__

void VIZ_InterruptionPoint();

void VIZ_Sleep(unsigned int ms);

#endif
1 change: 1 addition & 0 deletions src/vizdoom/src/win32/i_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
#include "textures/bitmap.h"
#include "textures/textures.h"

//VIZDOOM_CODE
#include "viz_main.h"

// MACROS ------------------------------------------------------------------
Expand Down

0 comments on commit b8a7002

Please sign in to comment.