Skip to content

Commit

Permalink
Merge branch 'develop' into auto_clothing
Browse files Browse the repository at this point in the history
  • Loading branch information
RosaryMala committed Aug 7, 2019
2 parents e1661d8 + e86e207 commit 47b43e6
Show file tree
Hide file tree
Showing 33 changed files with 1,585 additions and 1,004 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ build/install_manifest.txt
build/_CPack_Packages
build/dfhack-*.zip
build/dfhack-*.bz2
build/*ninja*
build/compile_commands.json
build/dfhack_setarch.txt
build/ImportExecutables.cmake

# Python binding binaries
*.pyc
Expand All @@ -58,5 +62,8 @@ tags
/build/win32/DF_PATH.txt
/.vs

# CLion
.idea

# custom plugins
/plugins/CMakeLists.custom.txt
14 changes: 11 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ OPTION(REMOVE_SYMBOLS_FROM_DF_STUBS "Remove debug symbols from DF stubs. (Reduce
cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR)
project(dfhack)

if("${CMAKE_GENERATOR}" STREQUAL Ninja)
if("${CMAKE_VERSION}" VERSION_LESS 3.9)
message(WARNING "You are using an old version of CMake (${CMAKE_VERSION}) with Ninja. This may result in ninja errors - see docs/Compile.rst for more details. Upgrading your CMake version is recommended.")
endif()
endif()

macro(CHECK_GCC COMPILER_PATH)
execute_process(COMMAND ${COMPILER_PATH} -dumpversion OUTPUT_VARIABLE GCC_VERSION_OUT)
string(STRIP "${GCC_VERSION_OUT}" GCC_VERSION_OUT)
Expand Down Expand Up @@ -290,6 +296,7 @@ if(WIN32)
endif()
endif()

option(EXTERNAL_LIBSTDCXX "macOS only: Avoid installing the DFHack-provided libstdc++." OFF)
if(APPLE)
# libstdc++ (GCC 4.8.5 for OS X 10.6)
# fixes crash-on-unwind bug in DF's libstdc++
Expand Down Expand Up @@ -340,9 +347,10 @@ if(APPLE)
endif()
endif()

install(PROGRAMS ${LIBSTDCXX_DOWNLOAD_DIR}/libstdc++.6.dylib
DESTINATION ./hack/)

if(NOT EXTERNAL_LIBSTDCXX)
install(PROGRAMS ${LIBSTDCXX_DOWNLOAD_DIR}/libstdc++.6.dylib
DESTINATION ./hack/)
endif()
endif()

#### expose depends ####
Expand Down
6 changes: 6 additions & 0 deletions depends/lua/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,12 @@ LIST(APPEND SRC_LIBLUA ${HDR_LIBLUA})
ADD_LIBRARY ( lua SHARED ${SRC_LIBLUA} )
TARGET_LINK_LIBRARIES ( lua ${LIBS})

if (MSVC)
target_compile_options(lua PRIVATE /FI dfhack_llimits.h)
else ()
target_compile_options(lua PRIVATE -include dfhack_llimits.h)
endif ()

install(TARGETS lua
LIBRARY DESTINATION ${DFHACK_LIBRARY_DESTINATION}
RUNTIME DESTINATION ${DFHACK_LIBRARY_DESTINATION})
Expand Down
61 changes: 61 additions & 0 deletions depends/lua/include/dfhack_llimits.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/**
Copyright © 2018 Pauli <[email protected]>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
damages arising from the use of this software.
Permission is granted to anyone to use this software for any
purpose, including commercial applications, and to alter it and
redistribute it freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must
not claim that you wrote the original software. If you use this
software in a product, an acknowledgment in the product
documentation would be appreciated but is not required.
2. Altered source versions must be plainly marked as such, and
must not be misrepresented as being the original software.
3. This notice may not be removed or altered from any source
distribution.
*/

#pragma once

#ifdef _MSC_VER
#include <windows.h>
#else
#include <pthread.h>
#endif

#include <stdlib.h>

/*! \file dfhack_llimits.h
* dfhack specific lua porting header that overrides lua defaults for thread
* safety.
*/

#ifdef _MSC_VER
typedef CRITICAL_SECTION mutex_t;
#else
typedef pthread_mutex_t mutex_t;
#endif

struct lua_extra_state {
mutex_t* mutex;
};

#define luai_mutex(L) ((lua_extra_state*)lua_getextraspace(L))->mutex

#ifdef _MSC_VER
#define luai_userstateopen(L) luai_mutex(L) = (mutex_t*)malloc(sizeof(mutex_t)); InitializeCriticalSection(luai_mutex(L))
#define luai_userstateclose(L) lua_unlock(L); DeleteCriticalSection(luai_mutex(L)); free(luai_mutex(L))
#define lua_lock(L) EnterCriticalSection(luai_mutex(L))
#define lua_unlock(L) LeaveCriticalSection(luai_mutex(L))
#else
#define luai_userstateopen(L) luai_mutex(L) = (mutex_t*)malloc(sizeof(mutex_t)); *luai_mutex(L) = PTHREAD_MUTEX_INITIALIZER
#define luai_userstateclose(L) lua_unlock(L); pthread_mutex_destroy(luai_mutex(L)); free(luai_mutex(L))
#define lua_lock(L) pthread_mutex_lock(luai_mutex(L))
#define lua_unlock(L) pthread_mutex_unlock(luai_mutex(L))
#endif
2 changes: 2 additions & 0 deletions docs/Authors.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ Kris Parker kaypy
Kromtec Kromtec
Kurik Amudnil
Lethosor lethosor
LordGolias LordGolias
Mason11987 Mason11987
Matt Regul mattregul
Matthew Cline
Expand All @@ -87,6 +88,7 @@ Milo Christiansen milochristiansen
MithrilTuxedo MithrilTuxedo
mizipzor mizipzor
moversti moversti
napagokc napagokc
Neil Little nmlittle
Nick Rart nickrart comestible
Nikolay Amiantov abbradar
Expand Down
20 changes: 20 additions & 0 deletions docs/Compile.rst
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ and more, please see `contributing-code`.
Build settings
==============

This section describes build configuration options that apply to all platforms.
If you don't have a working build environment set up yet, follow the instructions
in the platform-specific sections below first, then come back here.

Generator
---------

Expand All @@ -86,6 +90,12 @@ much slower than Ninja builds.
generator cannot be changed after ``cmake`` has been run without creating a
new build folder. Do not forget to specify this option.

CMake versions 3.6 and older, and possibly as recent as 3.9, are known to
produce project files with dependency cycles that fail to build
(see :issue:`1369`). Obtaining a recent version of CMake is recommended, either from
`cmake.org <https://cmake.org/download/>`_ or through a package manager. See
the sections below for more platform-specific directions for installing CMake.

Build type
----------

Expand Down Expand Up @@ -142,6 +152,12 @@ Before you can build anything, you'll also need ``cmake``. It is advisable to
also get ``ccmake`` on distributions that split the cmake package into multiple
parts.

You will need pthread; most systems should have this already. Note that older
CMake versions may have trouble detecting pthread, so if you run into
pthread-related errors and pthread is installed, you may need to upgrade CMake,
either by downloading it from `cmake.org <https://cmake.org/download/>`_ or
through your package manager, if possible.

You also need zlib, libsdl (1.2, not sdl2, like DF), perl, and the XML::LibXML
and XML::LibXSLT perl packages (for the code generation parts). You should be
able to find them in your distro repositories.
Expand All @@ -158,6 +174,10 @@ Here are some package install commands for various platforms:

apt-get install gcc cmake ninja-build git zlib1g-dev libsdl1.2-dev libxml-libxml-perl libxml-libxslt-perl

* On Fedora::

yum install gcc-c++ cmake ninja-build git zlib-devel SDL-devel perl-core perl-XML-LibXML perl-XML-LibXSLT ruby

* Debian and derived distros should have similar requirements to Ubuntu.


Expand Down
9 changes: 9 additions & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,15 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
================================================================================
# Future

## Misc Improvements
- `RemoteFortressReader`:
- added basic framework for controlling and reading the menus in DF, currently only supports the building menu.
- added support for reading item raws.
- added a check for wheather or not the game is currently saving or loading, for utilities to check if it's safe to read from DF.
- guestimate unit facing direction, and position within tiles.
- get unit age.
- get unit wounds.

## Internals
- Fixed some OpenGL build issues with `stonesense`

Expand Down
13 changes: 8 additions & 5 deletions library/Core.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1427,6 +1427,7 @@ bool Core::loadScriptFile(color_ostream &out, string fname, bool silent)

static void run_dfhack_init(color_ostream &out, Core *core)
{
CoreSuspender lock;
if (!df::global::world || !df::global::ui || !df::global::gview)
{
out.printerr("Key globals are missing, skipping loading dfhack.init.\n");
Expand Down Expand Up @@ -1528,6 +1529,7 @@ Core::Core() :
HotkeyMutex{},
HotkeyCond{},
alias_mutex{},
started{false},
misc_data_mutex{},
CoreSuspendMutex{},
CoreWakeup{},
Expand All @@ -1537,7 +1539,7 @@ Core::Core() :
// init the console. This must be always the first step!
plug_mgr = 0;
errorstate = false;
started = false;
vinfo = 0;
memset(&(s_mods), 0, sizeof(s_mods));

// set up hotkey capture
Expand All @@ -1547,7 +1549,6 @@ Core::Core() :
last_pause_state = false;
top_viewscreen = NULL;
screen_window = NULL;
server = NULL;

color_ostream::log_errors_to_stderr = true;

Expand Down Expand Up @@ -1765,6 +1766,8 @@ bool Core::Init()
// create plugin manager
plug_mgr = new PluginManager(this);
plug_mgr->init();
cerr << "Starting the TCP listener.\n";
auto listen = ServerMain::listen(RemoteClient::GetDefaultPort());
IODATA *temp = new IODATA;
temp->core = this;
temp->plug_mgr = plug_mgr;
Expand All @@ -1789,9 +1792,7 @@ bool Core::Init()
started = true;
modstate = 0;

cerr << "Starting the TCP listener.\n";
server = new ServerMain();
if (!server->listen(RemoteClient::GetDefaultPort()))
if (!listen.get())
cerr << "TCP listen failed.\n";

if (df::global::ui_sidebar_menus)
Expand Down Expand Up @@ -2294,6 +2295,8 @@ int Core::Shutdown ( void )
HotkeyCond.notify_one();
}

ServerMain::block();

d->hotkeythread.join();
d->iothread.join();

Expand Down
Loading

0 comments on commit 47b43e6

Please sign in to comment.