Skip to content

Commit

Permalink
Windows fixes
Browse files Browse the repository at this point in the history
Former-commit-id: b9c699a
  • Loading branch information
mwydmuch committed Mar 25, 2016
1 parent 1544c61 commit 8bdfa5a
Show file tree
Hide file tree
Showing 11 changed files with 124 additions and 65 deletions.
62 changes: 42 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ if( MSVC )

endif()

set( VIZDOOM_OUTPUT_DIR ${CMAKE_BINARY_DIR}/bin )

# Targets
add_subdirectory( vizdoom_src )
Expand All @@ -65,7 +66,7 @@ find_package(Threads REQUIRED)

set( VIZDOOM_INCLUDE_DIR vizdoom_api_src )

include_directories( ${VIZDOOM_IrmNCLUDE_DIR} ${Boost_INCLUDE_DIR} )
include_directories( ${VIZDOOM_INCLUDE_DIR} ${Boost_INCLUDE_DIR} )

set( VIZDOOM_LIBS
${Boost_LIBRARIES}
Expand All @@ -90,11 +91,18 @@ target_link_libraries (vizdoomshared ${VIZDOOM_LIBS})

set_target_properties( vizdoomstatic vizdoomshared
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin
ARCHIVE_OUTPUT_DIRECTORY ${VIZDOOM_OUTPUT_DIR}
ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${VIZDOOM_OUTPUT_DIR}
ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${VIZDOOM_OUTPUT_DIR}
LIBRARY_OUTPUT_DIRECTORY ${VIZDOOM_OUTPUT_DIR}
LIBRARY_OUTPUT_DIRECTORY_DEBUG ${VIZDOOM_OUTPUT_DIR}
LIBRARY_OUTPUT_DIRECTORY_RELEASE ${VIZDOOM_OUTPUT_DIR}
RUNTIME_OUTPUT_DIRECTORY ${VIZDOOM_OUTPUT_DIR}
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${VIZDOOM_OUTPUT_DIR}
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${VIZDOOM_OUTPUT_DIR}
OUTPUT_NAME vizdoom )

#Python binding
if(BUILD_PYTHON)

#set(Boost_USE_DEBUG_PYTHON OFF)
Expand All @@ -108,7 +116,7 @@ if(BUILD_PYTHON)

set( VIZDOOM_PYTHON_LIBS
${VIZDOOM_LIBS}
${Boost_PYTHON_LIBRARY}
${Boost_PYTHON_LIBRARY}
${PYTHON_LIBRARIES}
${NUMPY_LIBRARIES} )

Expand All @@ -130,15 +138,21 @@ if(BUILD_PYTHON)

set_target_properties( vizdoompython
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin/python
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin/python
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin/python
ARCHIVE_OUTPUT_DIRECTORY ${VIZDOOM_OUTPUT_DIR}/python
ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${VIZDOOM_OUTPUT_DIR}/python
ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${VIZDOOM_OUTPUT_DIR}/python
LIBRARY_OUTPUT_DIRECTORY ${VIZDOOM_OUTPUT_DIR}/python
LIBRARY_OUTPUT_DIRECTORY_DEBUG ${VIZDOOM_OUTPUT_DIR}/python
LIBRARY_OUTPUT_DIRECTORY_RELEASE ${VIZDOOM_OUTPUT_DIR}/python
RUNTIME_OUTPUT_DIRECTORY ${VIZDOOM_OUTPUT_DIR}/python
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${VIZDOOM_OUTPUT_DIR}/python
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${VIZDOOM_OUTPUT_DIR}/python
OUTPUT_NAME vizdoom )

if(UNIX)
ADD_CUSTOM_COMMAND(
TARGET vizdoompython
COMMAND ln -sf ${PROJECT_SOURCE_DIR}/bin/python/vizdoom.so ${PROJECT_SOURCE_DIR}/examples/python/vizdoom.so
COMMAND ln -sf ${VIZDOOM_OUTPUT_DIR}/python/vizdoom.so ${PROJECT_SOURCE_DIR}/examples/python/vizdoom.so
COMMAND ln -sf ${PROJECT_SOURCE_DIR}/examples/config/bots.cfg ${PROJECT_SOURCE_DIR}/examples/python/bots.cfg
COMMENT "Adding symlinks to vizdoom.so and bots.cfg in examples/python."
)
Expand All @@ -147,6 +161,7 @@ if(BUILD_PYTHON)

endif()

#Java binding
if(BUILD_JAVA)

if (NOT DEFINED ENV{JAVA_HOME})
Expand All @@ -160,8 +175,7 @@ if(BUILD_JAVA)
set( VIZDOOM_JAVA_INCLUDE_DIR ${VIZDOOM_INCLUDE_DIR} vizdoom_api_bindings/java )

set( VIZDOOM_JAVA_LIBS
${VIZDOOM_LIBS}
${Boost_LIBRARIES}
${VIZDOOM_LIBS}
${Java_LIBRARIES}
${JNI_LIBRARIES} )

Expand Down Expand Up @@ -206,23 +220,31 @@ if(BUILD_JAVA)
./vizdoom_api_bindings/java/errors/SharedMemoryException.java
./vizdoom_api_bindings/java/GameState.java
./vizdoom_api_bindings/java/DoomGame.java
OUTPUT_DIR ${PROJECT_SOURCE_DIR}/bin/java OUTPUT_NAME vizdoom)
OUTPUT_DIR ${VIZDOOM_OUTPUT_DIR}/java
OUTPUT_NAME vizdoom)

set_target_properties( vizdoomjava
PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin/java
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin/java
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin/java
ARCHIVE_OUTPUT_DIRECTORY ${VIZDOOM_OUTPUT_DIR}/java
ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${VIZDOOM_OUTPUT_DIR}/java
ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${VIZDOOM_OUTPUT_DIR}/java
LIBRARY_OUTPUT_DIRECTORY ${VIZDOOM_OUTPUT_DIR}/java
LIBRARY_OUTPUT_DIRECTORY_DEBUG ${VIZDOOM_OUTPUT_DIR}/java
LIBRARY_OUTPUT_DIRECTORY_RELEASE ${VIZDOOM_OUTPUT_DIR}/java
RUNTIME_OUTPUT_DIRECTORY ${VIZDOOM_OUTPUT_DIR}/java
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${VIZDOOM_OUTPUT_DIR}/java
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${VIZDOOM_OUTPUT_DIR}/java
OUTPUT_NAME vizdoom )

endif()


#message("-- Downloading Freedoom WADs")
#message("-- Original Doom WADs can not be provided due to licences")

if( WIN32 )
file( DOWNLOAD https://github.com/freedoom/freedoom/releases/download/v0.10.1/freedoom-0.10.1.zip ./scenarios/freedoom-0.10.1.zip SHOW_PROGRESS )
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/scenarios/freedoom.zip")
message("-- Downloading Freedoom WADs")
message("-- Original Doom WADs can not be provided due to licences")

file( DOWNLOAD https://github.com/freedoom/freedoom/releases/download/v0.10.1/freedoom-0.10.1.zip ${PROJECT_SOURCE_DIR}/scenarios/freedoom.zip SHOW_PROGRESS )
endif()
endif()

if(UNIX)
Expand Down
49 changes: 25 additions & 24 deletions vizdoom_api_bindings/java/DoomGame.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

public class DoomGame{
static {
System.loadLibrary("vizdoom");
System.loadLibrary("vizdoom");
}

public long internalPtr = 0;
Expand All @@ -29,11 +29,11 @@ public DoomGame(){
public native boolean isRunning();

public native void setAction(int[] actions);
public native void advanceAction();
public native void advanceAction(int tics);
public native void advanceAction(int tics, boolean stateUpdate, boolean renderOnly);
public native double makeAction(int[] actions);
public native double makeAction(int[] actions, int tics);
public native void advanceAction();
public native void advanceAction(int tics);
public native void advanceAction(int tics, boolean stateUpdate, boolean renderOnly);
public native double makeAction(int[] actions);
public native double makeAction(int[] actions, int tics);


public native GameState getState();
Expand All @@ -44,7 +44,7 @@ public DoomGame(){
public native boolean isEpisodeFinished();

public native boolean isPlayerDead();
public native void respawnPlayer();
public native void respawnPlayer();

public native void addAvailableButton(Button button);
public native void addAvailableButton(Button button, int maxValue);
Expand All @@ -56,16 +56,17 @@ public DoomGame(){
public native void addAvailableGameVariable(GameVariable var);

public native void clearAvailableGameVariables();
public native int getAvailableGameVariablesSize();
public native int getAvailableGameVariablesSize();

public native void addGameArgs(String arg);
public native void clearGameArgs();
public native void clearGameArgs();

public native void sendGameCommand(String cmd);
public native void sendGameCommand(String cmd);

public native int[] getGameScreen();

private native int getMod();
private native int getMod();

public Mode getMode(){
Mode ret=Mode.values()[getMod()];
return ret;
Expand All @@ -78,13 +79,13 @@ public Mode getMode(){

public native int getGameVariable(GameVariable var);

public native double getLivingReward();
public native void setLivingReward(double livingReward);
public native double getDeathPenalty();
public native void setDeathPenalty(double deathPenalty);
public native double getLivingReward();
public native void setLivingReward(double livingReward);
public native double getDeathPenalty();
public native void setDeathPenalty(double deathPenalty);

public native double getLastReward();
public native double getSummaryReward();
public native double getLastReward();
public native double getSummaryReward();

public native void setViZDoomPath(String path);
public native void setDoomGamePath(String path);
Expand All @@ -93,18 +94,18 @@ public Mode getMode(){
public native void setDoomSkill(int skill);
public native void setDoomConfigPath(String path);

public native int getSeed();
public native void setSeed(int seed);
public native int getSeed();
public native void setSeed(int seed);

public native int getEpisodeStartTime();
public native void setEpisodeStartTime(int tics);
public native int getEpisodeStartTime();
public native void setEpisodeStartTime(int tics);

public native int getEpisodeTimeout();
public native void setEpisodeTimeout(int tics);
public native int getEpisodeTimeout();
public native void setEpisodeTimeout(int tics);

public native int getEpisodeTime();

public native void setScreenResolution(ScreenResolution resolution);
public native void setScreenResolution(ScreenResolution resolution);
public native void setScreenFormat(ScreenFormat format);
public native void setRenderHud(boolean hud);
public native void setRenderWeapon(boolean weapon);
Expand Down
4 changes: 2 additions & 2 deletions vizdoom_api_bindings/java/ViZDoomGameJava.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ JNIEXPORT jobject JNICALL Java_DoomGame_getState
}
env->ReleaseIntArrayElements(jbuffer, oarr, NULL);

uint8_t *pointer;
boost::uint8_t *pointer;
pointer=statec.imageBuffer;
jintArray jbuffer2 = env->NewIntArray(rozmiar);
oarr = env->GetIntArrayElements(jbuffer2, NULL);
Expand Down Expand Up @@ -876,7 +876,7 @@ JNIEXPORT jintArray JNICALL Java_DoomGame_getGameScreen
int rozmiar=game->getScreenSize();
std::vector<int> ourvector;

uint8_t *pointer;
boost::uint8_t *pointer;
pointer=game->getGameScreen();
jintArray jbuffer = env->NewIntArray(rozmiar);
jint *oarr;
Expand Down
4 changes: 2 additions & 2 deletions vizdoom_api_src/ViZDoomDefines.h
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
#ifndef __VIZDOOM_DEFINES_H__
#define __VIZDOOM_DEFINES_H__

#include <cstdlib>
#include <boost/cstdint.hpp>
#include <vector>

namespace vizdoom{

#define VIZDOOM_API_VERSION_STR "1.0.0"
#define VIZDOOM_API_VERSION_INT 100

typedef unsigned char uint8_t;
typedef boost::uint8_t uint8_t;

struct GameState {
unsigned int number;
Expand Down
2 changes: 1 addition & 1 deletion vizdoom_src/src/d_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1025,7 +1025,7 @@ void D_DoomLoop ()
vizdoom_time = I_GetTime (true);
I_WaitForTic(vizdoom_time);
//I_WaitForTic(gametic + 1);
D_ProcessEvents ();
//D_ProcessEvents ();
}

G_BuildTiccmd (&netcmds[consoleplayer][maketic%BACKUPTICS]);
Expand Down
2 changes: 2 additions & 0 deletions vizdoom_src/src/vizdoom_game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ void ViZDoom_GameVarsInit(){
}

void ViZDoom_GameVarsTic(){

vizdoomGameVars->GAME_TIC = gametic;
vizdoomGameVars->GAME_STATE = gamestate;
vizdoomGameVars->GAME_ACTION = gameaction;
Expand Down Expand Up @@ -176,6 +177,7 @@ void ViZDoom_GameVarsTic(){
vizdoomGameVars->PLAYER_AMMO[i] = ViZDoom_CheckSlotAmmo(i);
vizdoomGameVars->PLAYER_WEAPON[i] = ViZDoom_CheckSlotWeapons(i);
}

}

void ViZDoom_GameVarsClose(){
Expand Down
Loading

0 comments on commit 8bdfa5a

Please sign in to comment.