Skip to content

Commit

Permalink
Formatting fixes in some files
Browse files Browse the repository at this point in the history
Former-commit-id: 7949ed9
  • Loading branch information
mwydmuch committed Dec 23, 2016
1 parent 39d5881 commit 7f62ad7
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 118 deletions.
22 changes: 12 additions & 10 deletions doc/Building.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
10 changes: 5 additions & 5 deletions doc/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.


Expand All @@ -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.**
Expand All @@ -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
Expand Down Expand Up @@ -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.



Expand Down
89 changes: 6 additions & 83 deletions src/lib/ViZDoomController.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -89,169 +89,113 @@ 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);


/* General game settings */
/*------------------------------------------------------------------------------------------------------------*/

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();


/* Rendering getters and setters */
/*------------------------------------------------------------------------------------------------------------*/

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 */
Expand All @@ -263,52 +207,36 @@ 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);


/* GameState getters */
/*------------------------------------------------------------------------------------------------------------*/

double getGameVariable(GameVariable var);

unsigned int getGameTic();

bool isMultiplayerGame();

bool isNetGame();

unsigned int getMapTic();

int getMapReward();

bool isPlayerDead();


private:

/* Flow */
Expand All @@ -318,15 +246,10 @@ namespace vizdoom {
bool doomWorking;

bool receiveMQMsg();

void waitForDoomStart();

void waitForDoomWork();

void waitForDoomMapStartTime();

void createDoomArgs();

void launchDoom();

/* Seed */
Expand Down Expand Up @@ -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);

Expand Down
9 changes: 3 additions & 6 deletions src/lib/ViZDoomMessageQueue.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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);
Expand Down
6 changes: 3 additions & 3 deletions src/lib/ViZDoomPathHelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down
Loading

0 comments on commit 7f62ad7

Please sign in to comment.