forked from teamnwah/openmw-tes3coop
Merged athile and zinnschlag
This commit is contained in:
commit
359f2903d7
14 changed files with 92 additions and 31 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -7,7 +7,6 @@ CMakeFiles
|
||||||
CMakeCache.txt
|
CMakeCache.txt
|
||||||
Makefile
|
Makefile
|
||||||
cmake*.cmake
|
cmake*.cmake
|
||||||
openmw
|
|
||||||
Ogre.log
|
Ogre.log
|
||||||
ogre.cfg
|
ogre.cfg
|
||||||
build
|
build
|
||||||
|
|
|
@ -180,7 +180,8 @@ set(OPENMW_LIBS_HEADER)
|
||||||
|
|
||||||
# Platform specific
|
# Platform specific
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
set(PLATFORM_INCLUDE_DIR "platform")
|
set(PLATFORM_INCLUDE_DIR "platform")
|
||||||
|
add_definitions(-DBOOST_ALL_NO_LIB)
|
||||||
else (WIN32)
|
else (WIN32)
|
||||||
set(PLATFORM_INCLUDE_DIR "")
|
set(PLATFORM_INCLUDE_DIR "")
|
||||||
endif (WIN32)
|
endif (WIN32)
|
||||||
|
@ -188,10 +189,11 @@ endif (WIN32)
|
||||||
# Dependencies
|
# Dependencies
|
||||||
|
|
||||||
find_package(OGRE REQUIRED)
|
find_package(OGRE REQUIRED)
|
||||||
find_package(Boost REQUIRED COMPONENTS system filesystem program_options)
|
find_package(Boost REQUIRED COMPONENTS system filesystem program_options thread)
|
||||||
find_package(OIS REQUIRED)
|
find_package(OIS REQUIRED)
|
||||||
include_directories("."
|
include_directories("."
|
||||||
${OGRE_INCLUDE_DIR} ${OIS_INCLUDE_DIR} ${Boost_INCLUDE_DIR}
|
${OGRE_INCLUDE_DIR} ${OGRE_INCLUDE_DIR}/Ogre
|
||||||
|
${OIS_INCLUDE_DIR} ${Boost_INCLUDE_DIR}
|
||||||
${PLATFORM_INCLUDE_DIR}
|
${PLATFORM_INCLUDE_DIR}
|
||||||
${CMAKE_HOME_DIRECTORY}/extern/caelum/include)
|
${CMAKE_HOME_DIRECTORY}/extern/caelum/include)
|
||||||
link_directories(${Boost_LIBRARY_DIRS} ${OGRE_LIB_DIR})
|
link_directories(${Boost_LIBRARY_DIRS} ${OGRE_LIB_DIR})
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
project(clientconsole)
|
|
||||||
find_package(Boost REQUIRED COMPONENTS system)
|
|
||||||
link_directories(${Boost_LIBRARY_DIRS})
|
|
||||||
add_executable(clientconsole client.cpp)
|
add_executable(clientconsole client.cpp)
|
||||||
target_link_libraries(clientconsole ${Boost_LIBRARIES})
|
target_link_libraries(clientconsole ${Boost_LIBRARIES})
|
||||||
|
|
|
@ -66,15 +66,15 @@ void OMW::Engine::processCommands()
|
||||||
|
|
||||||
OMW::Engine::Engine()
|
OMW::Engine::Engine()
|
||||||
: mDebug (false), mVerboseScripts (false), mNewGame (false), mScriptManager (0),
|
: mDebug (false), mVerboseScripts (false), mNewGame (false), mScriptManager (0),
|
||||||
mScriptContext (0)
|
mScriptContext (0), mEnableCommandServer (false)
|
||||||
{
|
{
|
||||||
mspCommandServer.reset(
|
|
||||||
new OMW::CommandServer::Server(&mCommandQueue, kCommandServerPort));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
OMW::Engine::~Engine()
|
OMW::Engine::~Engine()
|
||||||
{
|
{
|
||||||
// mspCommandServer->stop();
|
if (mspCommandServer.get())
|
||||||
|
mspCommandServer->stop();
|
||||||
|
|
||||||
delete mEnvironment.mWorld;
|
delete mEnvironment.mWorld;
|
||||||
delete mEnvironment.mSoundManager;
|
delete mEnvironment.mSoundManager;
|
||||||
delete mEnvironment.mGlobalScripts;
|
delete mEnvironment.mGlobalScripts;
|
||||||
|
@ -142,6 +142,11 @@ void OMW::Engine::enableDebugMode()
|
||||||
{
|
{
|
||||||
mDebug = true;
|
mDebug = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void OMW::Engine::enableCommandServer()
|
||||||
|
{
|
||||||
|
mEnableCommandServer = true;
|
||||||
|
}
|
||||||
|
|
||||||
void OMW::Engine::enableVerboseScripts()
|
void OMW::Engine::enableVerboseScripts()
|
||||||
{
|
{
|
||||||
|
@ -203,8 +208,14 @@ void OMW::Engine::go()
|
||||||
MWInput::MWInputManager input(mOgre, mEnvironment.mWorld->getPlayerPos(), mDebug);
|
MWInput::MWInputManager input(mOgre, mEnvironment.mWorld->getPlayerPos(), mDebug);
|
||||||
|
|
||||||
// Launch the console server
|
// Launch the console server
|
||||||
std::cout << "Starting command server on port " << kCommandServerPort << std::endl;
|
if (mEnableCommandServer)
|
||||||
mspCommandServer->start();
|
{
|
||||||
|
std::cout << "Starting command server on port " << kCommandServerPort << std::endl;
|
||||||
|
mspCommandServer.reset(new OMW::CommandServer::Server(&mCommandQueue, kCommandServerPort));
|
||||||
|
mspCommandServer->start();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
std::cout << "Command server disabled" << std::endl;
|
||||||
|
|
||||||
std::cout << "\nStart! Press Q/ESC or close window to exit.\n";
|
std::cout << "\nStart! Press Q/ESC or close window to exit.\n";
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,7 @@ namespace OMW
|
||||||
bool mNewGame;
|
bool mNewGame;
|
||||||
|
|
||||||
TsDeque<OMW::Command> mCommandQueue;
|
TsDeque<OMW::Command> mCommandQueue;
|
||||||
|
bool mEnableCommandServer;
|
||||||
std::auto_ptr<OMW::CommandServer::Server> mspCommandServer;
|
std::auto_ptr<OMW::CommandServer::Server> mspCommandServer;
|
||||||
|
|
||||||
MWWorld::Environment mEnvironment;
|
MWWorld::Environment mEnvironment;
|
||||||
|
@ -98,6 +99,10 @@ namespace OMW
|
||||||
/// - non-exclusive input
|
/// - non-exclusive input
|
||||||
void enableDebugMode();
|
void enableDebugMode();
|
||||||
|
|
||||||
|
/// Enable the command server so external apps can send commands to the console.
|
||||||
|
/// Must be set before go().
|
||||||
|
void enableCommandServer();
|
||||||
|
|
||||||
/// Enable verbose script output
|
/// Enable verbose script output
|
||||||
void enableVerboseScripts();
|
void enableVerboseScripts();
|
||||||
|
|
||||||
|
|
|
@ -32,6 +32,7 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine)
|
||||||
( "debug", "debug mode" )
|
( "debug", "debug mode" )
|
||||||
( "script-verbose", "verbose script output" )
|
( "script-verbose", "verbose script output" )
|
||||||
( "new-game", "activate char gen/new game mechanics" )
|
( "new-game", "activate char gen/new game mechanics" )
|
||||||
|
( "disable-command-server", "turn off the command server" )
|
||||||
;
|
;
|
||||||
|
|
||||||
bpo::variables_map variables;
|
bpo::variables_map variables;
|
||||||
|
@ -62,6 +63,9 @@ bool parseOptions (int argc, char**argv, OMW::Engine& engine)
|
||||||
|
|
||||||
if (variables.count ("new-game"))
|
if (variables.count ("new-game"))
|
||||||
engine.setNewGame();
|
engine.setNewGame();
|
||||||
|
|
||||||
|
if (variables.count("disable-command-server") == 0)
|
||||||
|
engine.enableCommandServer();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -111,7 +111,7 @@ namespace MWScript
|
||||||
void InterpreterContext::setGlobalLong (const std::string& name, int value)
|
void InterpreterContext::setGlobalLong (const std::string& name, int value)
|
||||||
{
|
{
|
||||||
// a global long is internally a float.
|
// a global long is internally a float.
|
||||||
float value2 = value;
|
float value2 = float(value);
|
||||||
|
|
||||||
mEnvironment.mWorld->getGlobalVariable (name) =
|
mEnvironment.mWorld->getGlobalVariable (name) =
|
||||||
*reinterpret_cast<Interpreter::Type_Data *> (&value2);
|
*reinterpret_cast<Interpreter::Type_Data *> (&value2);
|
||||||
|
|
|
@ -16,10 +16,11 @@ namespace MWWorld
|
||||||
class World;
|
class World;
|
||||||
|
|
||||||
///< Collection of script-accessable sub-systems
|
///< Collection of script-accessable sub-systems
|
||||||
struct Environment
|
class Environment
|
||||||
{
|
{
|
||||||
Environment() : mWorld (0), mSoundManager (0), mGlobalScripts (0), mFrameDuration (0) {}
|
public:
|
||||||
|
Environment() : mWorld (0), mSoundManager (0), mGlobalScripts (0), mFrameDuration (0) {}
|
||||||
|
|
||||||
World *mWorld;
|
World *mWorld;
|
||||||
MWSound::SoundManager *mSoundManager;
|
MWSound::SoundManager *mSoundManager;
|
||||||
MWScript::GlobalScripts *mGlobalScripts;
|
MWScript::GlobalScripts *mGlobalScripts;
|
||||||
|
|
|
@ -166,8 +166,9 @@ namespace MWWorld
|
||||||
iter->second->show();
|
iter->second->show();
|
||||||
|
|
||||||
// Optionally enable the sky
|
// Optionally enable the sky
|
||||||
// if (mEnableSky)
|
///\todo FIXME
|
||||||
// mpSkyManager = MWRender::SkyManager::create(renderer.getWindow(), mScene.getCamera());
|
if (false)
|
||||||
|
mSkyManager = MWRender::SkyManager::create(renderer.getWindow(), mScene.getCamera());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,8 @@
|
||||||
|
|
||||||
#include "server.hpp"
|
#include "server.hpp"
|
||||||
|
#include "libs/platform/strings.h"
|
||||||
|
|
||||||
using boost::asio::ip::tcp;
|
using boost::asio::ip::tcp;
|
||||||
|
|
||||||
#include <libs/mangle/tools/str_exception.hpp>
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Namespace for containing implementation details that the
|
// Namespace for containing implementation details that the
|
||||||
// rest of OpenMW doesn't need to worry about
|
// rest of OpenMW doesn't need to worry about
|
||||||
|
@ -55,6 +53,7 @@ namespace OMW { namespace CommandServer { namespace Detail {
|
||||||
///
|
///
|
||||||
void Connection::stop()
|
void Connection::stop()
|
||||||
{
|
{
|
||||||
|
mSocket.shutdown(boost::asio::socket_base::shutdown_both);
|
||||||
mSocket.close();
|
mSocket.close();
|
||||||
mpThread->join();
|
mpThread->join();
|
||||||
}
|
}
|
||||||
|
@ -105,7 +104,7 @@ namespace OMW { namespace CommandServer { namespace Detail {
|
||||||
bDone = true;
|
bDone = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
throw str_exception("Unexpected header!");
|
throw std::runtime_error("Unexpected header!");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
bDone = true;
|
bDone = true;
|
||||||
|
@ -120,12 +119,12 @@ namespace OMW { namespace CommandServer {
|
||||||
using namespace Detail;
|
using namespace Detail;
|
||||||
|
|
||||||
Server::Server (Deque* pCommandQueue, const int port)
|
Server::Server (Deque* pCommandQueue, const int port)
|
||||||
: mAcceptor (mIOService, tcp::endpoint(tcp::v4(), port))
|
: mPort (port)
|
||||||
|
, mAcceptor (mIOService, tcp::endpoint(tcp::v4(), mPort))
|
||||||
, mbStopping (false)
|
, mbStopping (false)
|
||||||
, mpCommandQueue (pCommandQueue)
|
, mpCommandQueue (pCommandQueue)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Server::start()
|
void Server::start()
|
||||||
{
|
{
|
||||||
|
@ -133,8 +132,41 @@ namespace OMW { namespace CommandServer {
|
||||||
mpThread = new boost::thread(boost::bind(&Server::threadMain, this));
|
mpThread = new boost::thread(boost::bind(&Server::threadMain, this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Helper function - see Server::stop()
|
||||||
|
//
|
||||||
|
static void connectAndDisconnect (int port)
|
||||||
|
{
|
||||||
|
char portString[64];
|
||||||
|
snprintf(portString, 64, "%d", port);
|
||||||
|
|
||||||
|
boost::asio::io_service ioService;
|
||||||
|
tcp::resolver resolver(ioService);
|
||||||
|
tcp::resolver::query query("localhost", portString);
|
||||||
|
tcp::resolver::iterator endpoint_iterator = resolver.resolve(query);
|
||||||
|
tcp::resolver::iterator end;
|
||||||
|
|
||||||
|
tcp::socket socket(ioService);
|
||||||
|
boost::system::error_code error = boost::asio::error::host_not_found;
|
||||||
|
while (error && endpoint_iterator != end)
|
||||||
|
{
|
||||||
|
socket.close();
|
||||||
|
socket.connect(*endpoint_iterator++, error);
|
||||||
|
}
|
||||||
|
|
||||||
|
socket.close();
|
||||||
|
ioService.stop();
|
||||||
|
}
|
||||||
|
|
||||||
void Server::stop()
|
void Server::stop()
|
||||||
{
|
{
|
||||||
|
// Boost.Asio doesn't have a way to cancel the blocking accept() call
|
||||||
|
// in the listening thread. Therefore, set an internal flag to let
|
||||||
|
// the server know it's stopping and then unblock it via a do-nothing
|
||||||
|
// connect/disconnect.
|
||||||
|
mbStopping = true;
|
||||||
|
connectAndDisconnect(mPort);
|
||||||
|
|
||||||
// (1) Stop accepting new connections
|
// (1) Stop accepting new connections
|
||||||
// (2) Wait for the listener thread to finish
|
// (2) Wait for the listener thread to finish
|
||||||
mAcceptor.close();
|
mAcceptor.close();
|
||||||
|
@ -144,7 +176,6 @@ namespace OMW { namespace CommandServer {
|
||||||
// open connections
|
// open connections
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(mConnectionsMutex);
|
boost::mutex::scoped_lock lock(mConnectionsMutex);
|
||||||
mbStopping = true;
|
|
||||||
for (ConnectionSet::iterator it = mConnections.begin();
|
for (ConnectionSet::iterator it = mConnections.begin();
|
||||||
it != mConnections.end();
|
it != mConnections.end();
|
||||||
++it)
|
++it)
|
||||||
|
@ -186,7 +217,7 @@ namespace OMW { namespace CommandServer {
|
||||||
std::auto_ptr<Connection> spConnection(new Connection(mAcceptor.io_service(), this));
|
std::auto_ptr<Connection> spConnection(new Connection(mAcceptor.io_service(), this));
|
||||||
boost::system::error_code ec;
|
boost::system::error_code ec;
|
||||||
mAcceptor.accept(spConnection->socket(), ec);
|
mAcceptor.accept(spConnection->socket(), ec);
|
||||||
if (!ec)
|
if (!ec && !mbStopping)
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(mConnectionsMutex);
|
boost::mutex::scoped_lock lock(mConnectionsMutex);
|
||||||
mConnections.insert(spConnection.get());
|
mConnections.insert(spConnection.get());
|
||||||
|
|
|
@ -45,6 +45,7 @@ namespace OMW { namespace CommandServer
|
||||||
void threadMain();
|
void threadMain();
|
||||||
|
|
||||||
// Objects used to set up the listening server
|
// Objects used to set up the listening server
|
||||||
|
int mPort;
|
||||||
boost::asio::io_service mIOService;
|
boost::asio::io_service mIOService;
|
||||||
boost::asio::ip::tcp::acceptor mAcceptor;
|
boost::asio::ip::tcp::acceptor mAcceptor;
|
||||||
boost::thread* mpThread;
|
boost::thread* mpThread;
|
||||||
|
|
|
@ -9,8 +9,9 @@ namespace ESM {
|
||||||
* Script definitions
|
* Script definitions
|
||||||
*/
|
*/
|
||||||
|
|
||||||
struct Script
|
class Script
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
struct SCHDstruct
|
struct SCHDstruct
|
||||||
{
|
{
|
||||||
/* Script name.
|
/* Script name.
|
||||||
|
|
|
@ -98,7 +98,7 @@ namespace ESMS
|
||||||
CellRefList<Ingredient, D> ingreds;
|
CellRefList<Ingredient, D> ingreds;
|
||||||
CellRefList<CreatureLevList, D> creatureLists;
|
CellRefList<CreatureLevList, D> creatureLists;
|
||||||
CellRefList<ItemLevList, D> itemLists;
|
CellRefList<ItemLevList, D> itemLists;
|
||||||
CellRefList<Light, D> lights;
|
CellRefList<ESM::Light, D> lights;
|
||||||
CellRefList<Tool, D> lockpicks;
|
CellRefList<Tool, D> lockpicks;
|
||||||
CellRefList<Misc, D> miscItems;
|
CellRefList<Misc, D> miscItems;
|
||||||
CellRefList<NPC, D> npcs;
|
CellRefList<NPC, D> npcs;
|
||||||
|
|
9
extern/caelum/CMakeLists.txt
vendored
9
extern/caelum/CMakeLists.txt
vendored
|
@ -1,7 +1,14 @@
|
||||||
project(Caelum)
|
project(Caelum)
|
||||||
|
|
||||||
|
IF(MSVC)
|
||||||
|
add_definitions("-D_SCL_SECURE_NO_WARNINGS /wd4305 /wd4244" )
|
||||||
|
ENDIF(MSVC)
|
||||||
|
|
||||||
ADD_DEFINITIONS(-DCAELUM_LIB)
|
ADD_DEFINITIONS(-DCAELUM_LIB)
|
||||||
INCLUDE_DIRECTORIES( ${CMAKE_HOME_DIRECTORY}/extern/caelum/include )
|
INCLUDE_DIRECTORIES(
|
||||||
|
${CMAKE_HOME_DIRECTORY}/extern/caelum/include
|
||||||
|
${OGRE_INCLUDE_DIR}/Ogre
|
||||||
|
)
|
||||||
|
|
||||||
file(GLOB_RECURSE CAELUM_SRC src/*)
|
file(GLOB_RECURSE CAELUM_SRC src/*)
|
||||||
file(GLOB_RECURSE CAELUM_HDR include/*)
|
file(GLOB_RECURSE CAELUM_HDR include/*)
|
||||||
|
|
Loading…
Reference in a new issue