diff --git a/doc/Building.md b/doc/Building.md index 3a2fe1d79..2186d3a6b 100644 --- a/doc/Building.md +++ b/doc/Building.md @@ -113,17 +113,19 @@ Additionally, [ZDoom dependencies](http://zdoom.org/wiki/Compile_ZDoom_on_Mac_OS Run CMake and use generated project. Users with brew-installed Python may need to manually set: -``-DPYTHON_INCLUDE_DIR=/usr/local/Cellar/python/2.x.x/Frameworks/Python.framework/Versions/2.7/include/python2.7`` and -``-DPYTHON_LIBRARY=/usr/local/Cellar/python/2.x.x/Frameworks/Python.framework/Versions/2.7/lib/libpython2.7.dylib`` +``-DPYTHON_INCLUDE_DIR=/usr/local/Cellar/python/x.x.x/Frameworks/Python.framework/Versions/x.x/include/pythonx.x`` and +``-DPYTHON_LIBRARY=/usr/local/Cellar/python/x.x.x/Frameworks/Python.framework/Versions/x.x/lib/libpythonx.x.dylib`` ####Configuration #### Torch7 lua bindings -If you want to build against luajit installed locally by torch (as in http://torch.ch/docs/getting-started.html#_), please do: +If you want to build against luajit installed locally by torch (as in http://torch.ch/docs/getting-started.html#_): ``` -cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_PYTHON=OFF -DBUILD_LUA=ON -DLUA_EXECUTABLE=/Users/yourname/torch/bin/luajit -DLUA_LIBRARIES=/Users/yourname/torch/install/lib/libluajit.dylib -DLUA_INCLUDE_DIR=/Users/yourname/torch/install/include/ +cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_PYTHON=OFF -DBUILD_LUA=ON -DLUA_EXECUTABLE=torch_root_dir/bin/luajit -DLUA_LIBRARIES=torch_root_dir/install/lib/libluajit.so/dylib -DLUA_INCLUDE_DIR=torch_root_dir/install/include/ ``` -Then manually copied folder: `/Users/yourname/Desktop/ViZDoom/bin/lua/vizdoom` to: `/Users/yourname/torch/install/lib/` and `/Users/yourname/torch/install/share/lua/5.1`, provided Torch7 was installed in `~/torch` as by default. + +Manual instalation: +Copy folder: `vizdoom_root_dir/bin/lua/vizdoom` to: `torch_root_dir/install/lib/` and `torch_root_dir/install/share/lua/5.1`. ## Compilation output @@ -132,9 +134,9 @@ Compilation output will be placed in ``vizdoom_root_dir/bin`` and it should cont * ``bin/vizdoom / vizdoom.exe`` - ViZDoom executable * ``bin/vizdoom.pk3`` - resources file used by ViZDoom (needed by ViZDoom executable) * ``bin/libvizdoom.a / vizdoom.lib`` - C++ ViZDoom static library -* ``bin/libvizdoom.so / vizdoom.dll`` - C++ ViZDoom dynamically linked library -* ``bin/python2/vizdoom.so / vizdoom.pyd`` - ViZDoom Python module -* ``bin/python3/vizdoom.so / vizdoom.pyd`` - ViZDoom Python3 module -* ``bin/java/libvizdoom.so / vizdoom.dll`` - ViZDoom library for Java +* ``bin/libvizdoom.so / libvizdoom.dylib / vizdoom.dll`` - C++ ViZDoom dynamically linked library +* ``bin/python2/vizdoom.so / vizdoom.dylib / vizdoom.pyd`` - ViZDoom Python module +* ``bin/python3/vizdoom.so / vizdoom.dylib / vizdoom.pyd`` - ViZDoom Python3 module +* ``bin/java/libvizdoom.so / libvizdoom.dylib / vizdoom.dll`` - ViZDoom library for Java * ``bin/java/vizdoom.jar`` - Contains ViZDoom Java classes -* ``bin/lua/vizdoom.so / vizdoom.dll`` - ViZDoom Lua module +* ``bin/lua/vizdoom`` - ViZDoom Lua module diff --git a/doc/Changelog.md b/doc/Changelog.md index 46066f132..7f2ed093c 100644 --- a/doc/Changelog.md +++ b/doc/Changelog.md @@ -20,7 +20,7 @@ - The option to use minimal hud instead of default full hud - `setRenderMinimalHud` added. - The option to enable/disable effects that use sprites - `setRenderEffectsSprites` added. -- The option to enable/disable ingame messages independently of the console output - `setRenderMessages` added. +- The option to enable/disable in game messages independently of the console output - `setRenderMessages` added. - The option to enable/disable corpses - `setRenderCorpses` added. @@ -37,6 +37,7 @@ recording `filePath` argument added to `newEpisode`, `replayEpisode` added. - New `ticrate` optional argument in `doomTicsToMs`, `msToDoomTics`. - `doomTicsToSec` and `secToDoomTics` added. + #### Paths - **Paths in config files are now relative to config file.** @@ -45,13 +46,12 @@ recording `filePath` argument added to `newEpisode`, `replayEpisode` added. #### Others -- ZDoom engine updated to 2.8.1 +- ZDoom engine updated to 2.8.1. - **Basic support for multiplayer in PLAYER and SPECTATOR Modes.** - Improved exceptions messages. - Bugs associated with paths handling fixed. - Many minor bugs fixed. -- Python bindings output changed to bin/python2 and bin/python3. -- Possibility to change scenario wad during runtime (limited functionality) +- Possibility to change scenario wad during runtime (only first map from WAD file). #### C++ specific @@ -80,7 +80,7 @@ recording `filePath` argument added to `newEpisode`, `replayEpisode` added. - Consts added to Python. - Aliases for `doom_fixed_to_double` - `doom_fixed_to_float` added. -- Support for pip installation for Linux and Windows. +- Support for pip installation for Linux, MacOS. diff --git a/src/lib/ViZDoomController.h b/src/lib/ViZDoomController.h index 41d7cd3e6..01a08399e 100644 --- a/src/lib/ViZDoomController.h +++ b/src/lib/ViZDoomController.h @@ -69,11 +69,11 @@ namespace vizdoom { /* OSes */ #ifdef __linux__ -#define OS_LINUX + #define OS_LINUX #elif _WIN32 -#define OS_WIN + #define OS_WIN #elif __APPLE__ -#define OS_OSX + #define OS_OSX #endif class DoomController { @@ -89,43 +89,28 @@ namespace vizdoom { /*------------------------------------------------------------------------------------------------------------*/ bool init(); - void close(); - void restart(); - bool isTicPossible(); - void tic(bool update = true); - void tics(unsigned int tics, bool update = true); - void restartMap(std::string demoPath = ""); - void respawnPlayer(); - bool isDoomRunning(); - void sendCommand(std::string command); void setTicrate(unsigned int ticrate); - unsigned int getTicrate(); unsigned int getDoomSeed(); - void setDoomSeed(unsigned int seed); - void clearDoomSeed(); unsigned int getInstanceSeed(); - void setInstanceSeed(unsigned int seed); std::string getMap(); - void setMap(std::string map, std::string demoPath = ""); - void playDemo(std::string demoPath, int player = 0); @@ -133,47 +118,33 @@ namespace vizdoom { /*------------------------------------------------------------------------------------------------------------*/ std::string getExePath(); - void setExePath(std::string exePath); std::string getIwadPath(); - void setIwadPath(std::string iwadPath); std::string getFilePath(); - void setFilePath(std::string filePath); int getSkill(); - void setSkill(int skill); std::string getConfigPath(); - void setConfigPath(std::string configPath); unsigned int getMapStartTime(); - void setMapStartTime(unsigned int tics); - unsigned int getMapTimeout(); - void setMapTimeout(unsigned int tics); - bool isMapLastTic(); - bool isMapFirstTic(); - bool isMapEnded(); - unsigned int getMapLastTic(); void setNoConsole(bool console); - void setNoSound(bool noSound); void addCustomArg(std::string arg); - void clearCustomArgs(); @@ -181,77 +152,50 @@ namespace vizdoom { /*------------------------------------------------------------------------------------------------------------*/ void setWindowHidden(bool windowHidden); - void setNoXServer(bool noXServer); - void setRenderHud(bool hud); - void setRenderMinimalHud(bool minHud); - void setRenderWeapon(bool weapon); - void setRenderCrosshair(bool crosshair); - void setRenderDecals(bool decals); - void setRenderParticles(bool particles); - void setRenderEffectsSprites(bool sprites); - void setRenderMessages(bool messages); void setRenderCorpses(bool corpses); void setRenderScreenFlashes(bool flashes); void setScreenResolution(unsigned int width, unsigned int height); - unsigned int getScreenWidth(); - void setScreenWidth(unsigned int width); - unsigned int getScreenHeight(); - void setScreenHeight(unsigned int height); - ScreenFormat getScreenFormat(); void setScreenFormat(ScreenFormat format); - unsigned int getScreenChannels(); - unsigned int getScreenDepth(); - size_t getScreenPitch(); - size_t getScreenSize(); /* Depth buffer */ bool isDepthBufferEnabled(); - void setDepthBufferEnabled(bool depthBuffer); /* Labels */ bool isLabelsEnabled(); - void setLabelsEnabled(bool labels); /* Automap */ bool isAutomapEnabled(); - void setAutomapEnabled(bool map); - void setAutomapMode(AutomapMode mode); - void setAutomapRotate(bool rotate); - void setAutomapRenderTextures(bool textures); /* Buffers in SM */ uint8_t *const getScreenBuffer(); - uint8_t *const getDepthBuffer(); - uint8_t *const getLabelsBuffer(); - uint8_t *const getAutomapBuffer(); /* Buttons getters and setters */ @@ -263,32 +207,21 @@ namespace vizdoom { /* Buttons state */ int getButtonState(Button button); - void setButtonState(Button button, int state); - void toggleButtonState(Button button); /* Buttons availableity */ bool isButtonAvailable(Button button); - void setButtonAvailable(Button button, bool set); - void resetButtons(); - void disableAllButtons(); int getButtonMaxValue(Button button); - void setButtonMaxValue(Button button, unsigned int value); - void availableAllButtons(); - bool isAllowDoomInput(); - void setAllowDoomInput(bool set); - bool isRunDoomAsync(); - void setRunDoomAsync(bool set); @@ -296,19 +229,14 @@ namespace vizdoom { /*------------------------------------------------------------------------------------------------------------*/ double getGameVariable(GameVariable var); - unsigned int getGameTic(); - bool isMultiplayerGame(); - bool isNetGame(); - unsigned int getMapTic(); - int getMapReward(); - bool isPlayerDead(); + private: /* Flow */ @@ -318,15 +246,10 @@ namespace vizdoom { bool doomWorking; bool receiveMQMsg(); - void waitForDoomStart(); - void waitForDoomWork(); - void waitForDoomMapStartTime(); - void createDoomArgs(); - void launchDoom(); /* Seed */ @@ -354,8 +277,8 @@ namespace vizdoom { void handleSignals(); - static void - signalHandler(ba::signal_set &signal, DoomController *controller, const bs::error_code &error, int sigNumber); + static void signalHandler(ba::signal_set &signal, DoomController *controller, + const bs::error_code &error, int sigNumber); void intSignal(int sigNumber); diff --git a/src/lib/ViZDoomMessageQueue.h b/src/lib/ViZDoomMessageQueue.h index d3002d7ed..44bc5b2f7 100644 --- a/src/lib/ViZDoomMessageQueue.h +++ b/src/lib/ViZDoomMessageQueue.h @@ -33,9 +33,9 @@ namespace vizdoom { namespace bip = boost::interprocess; /* Message queues' settings */ -#define MQ_MAX_MSG_NUM 64 -#define MQ_MAX_MSG_SIZE sizeof(Message) -#define MQ_MAX_CMD_LEN 128 + #define MQ_MAX_MSG_NUM 64 + #define MQ_MAX_MSG_SIZE sizeof(Message) + #define MQ_MAX_CMD_LEN 128 /* Message struct */ struct Message { @@ -47,15 +47,12 @@ namespace vizdoom { public: MessageQueue(std::string name); - ~MessageQueue(); void init(); - void close(); void send(uint8_t code, const char *command = nullptr); - Message receive(); //void receive(Message *msg); diff --git a/src/lib/ViZDoomPathHelpers.cpp b/src/lib/ViZDoomPathHelpers.cpp index 772ae692e..68f4a6276 100644 --- a/src/lib/ViZDoomPathHelpers.cpp +++ b/src/lib/ViZDoomPathHelpers.cpp @@ -76,7 +76,7 @@ namespace vizdoom { // We can end up with ..s in our result because of symbolic links if (boost::filesystem::is_symlink(normalizedPath)) normalizedPath /= *i; - // Otherwise it should be safe to resolve the parent + // Otherwise it should be safe to resolve the parent else if (normalizedPath.filename() == ".." || normalizedPath.filename() == "") normalizedPath /= *i; else normalizedPath = normalizedPath.parent_path(); } else if (*i != ".") normalizedPath /= *i; @@ -152,8 +152,8 @@ namespace vizdoom { std::string thisObjectPath = "."; #endif - thisObjectPath = boost::filesystem::absolute(thisObjectPath).parent_path().generic_string(); - return thisObjectPath; + thisObjectPath = boost::filesystem::absolute(thisObjectPath).parent_path().generic_string(); + return thisObjectPath; } std::string THIS_SHARED_OBJECT_PATH = initializeThisSharedObjectPath(); diff --git a/src/lib/ViZDoomPathHelpers.h b/src/lib/ViZDoomPathHelpers.h index 0b851ee59..5d66f86ba 100644 --- a/src/lib/ViZDoomPathHelpers.h +++ b/src/lib/ViZDoomPathHelpers.h @@ -27,11 +27,11 @@ /* OSes */ #ifdef __linux__ -#define OS_LINUX + #define OS_LINUX #elif _WIN32 -#define OS_WIN + #define OS_WIN #elif __APPLE__ -#define OS_OSX + #define OS_OSX #endif namespace vizdoom { diff --git a/src/lib/ViZDoomSharedMemory.h b/src/lib/ViZDoomSharedMemory.h index 2f2948faf..5c7d49a61 100644 --- a/src/lib/ViZDoomSharedMemory.h +++ b/src/lib/ViZDoomSharedMemory.h @@ -168,25 +168,17 @@ namespace vizdoom { public: SharedMemory(std::string name); - ~SharedMemory(); void init(); - void update(); - void close(); SMGameState *getGameState(); - SMInputState *getInputState(); - uint8_t *getScreenBuffer(); - uint8_t *getDepthBuffer(); - uint8_t *getLabelsBuffer(); - uint8_t *getAutomapBuffer(); private: