Skip to content

Commit

Permalink
stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
renefritze committed Aug 22, 2012
1 parent 3a320bf commit 7ae10ca
Show file tree
Hide file tree
Showing 21 changed files with 196 additions and 86 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
build-*
build
*~
.cproject
.project
Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ ENDIF(WIN32)
# Build target defintions
#----------------------------------------------------------------------------------------------------

# Here we define the executable libSpringLobby ( or on Windows libSpringLobby.exe )
# Here we define the executable lsl-server ( or on Windows libSpringLobby.exe )

#ignore warnings about macosx app bundle output dir
cmake_policy(SET CMP0006 OLD)
Expand Down Expand Up @@ -110,13 +110,13 @@ INCLUDE(cmake/compat_flags.cmake)
# ${libSpringLobby_SOURCE_DIR}/tools/regen_config_header.sh ${libSpringLobby_SOURCE_DIR}/cmake/config.h ${libSpringLobby_BINARY_DIR}/libSpringLobby_config.h
# )
# add_dependencies( distcheck dist )
# add_dependencies( libSpringLobby version )
# add_dependencies( lsl-server version )

IF (WIN32)
install_if_standalone(FILES AUTHORS COPYING NEWS README THANKS DESTINATION .)
install_if_standalone(DIRECTORY ${CMAKE_INSTALL_PREFIX}/locale DESTINATION .)
ELSE (WIN32)
install_if_standalone(FILES AUTHORS COPYING NEWS README THANKS DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/libSpringLobby )
install_if_standalone(FILES AUTHORS COPYING NEWS README THANKS DESTINATION ${CMAKE_INSTALL_PREFIX}/share/doc/lsl-server )
ENDIF (WIN32)

add_subdirectory( src )
Expand Down
10 changes: 5 additions & 5 deletions src/lsl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ SET( templatesources
LIST( APPEND libSpringLobbyHeader ${templatesources} )
set_source_files_properties( ${libSpringLobbyHeader} PROPERTIES HEADER_FILE_ONLY 1 )

ADD_LIBRARY(libSpringLobby STATIC ${libSpringLobbyHeader} ${libSpringLobbySrc} ${libSpringLobby_RC_FILE} )
TARGET_LINK_LIBRARIES(libSpringLobby libSpringLobbyUtils boost_system-mt boost_filesystem-mt boost_thread-mt )
ADD_LIBRARY(lsl-server STATIC ${libSpringLobbyHeader} ${libSpringLobbySrc} ${libSpringLobby_RC_FILE} )
TARGET_LINK_LIBRARIES(lsl-server lsl-utils boost_system-mt boost_filesystem-mt boost_thread-mt )

IF(MINGW)
TARGET_LINK_LIBRARIES( libSpringLobby iphlpapi )
TARGET_LINK_LIBRARIES( lsl-server iphlpapi )
ENDIF(MINGW)

IF (WIN32)
install_if_standalone(TARGETS libSpringLobby DESTINATION . )
install_if_standalone(TARGETS lsl-server DESTINATION . )
ELSE (WIN32)
install_if_standalone(TARGETS libSpringLobby
install_if_standalone(TARGETS lsl-server
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib )
ENDIF (WIN32)
2 changes: 1 addition & 1 deletion src/lsl/battle/ibattle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include <lslutils/debug.h>
#include <lslutils/misc.h>
#include <lslutils/conversion.h>
#include <lslutils/lslconfig.h>
#include <lslutils/config.h>
#include <lslutils/autopointers.h>
#include <lslunitsync/unitsync.h>
#include <lslunitsync/optionswrapper.h>
Expand Down
4 changes: 2 additions & 2 deletions src/lsl/spring/spring.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ namespace BA = boost::algorithm;

Spring& spring()
{
static LineInfo<Spring> m( AT );
static GlobalObjectHolder<Spring,LineInfo<Spring> > m_spring( m );
static LSL::Util::LineInfo<Spring> m( AT );
static LSL::Util::GlobalObjectHolder<Spring, LSL::Util::LineInfo<Spring> > m_spring( m );
return m_spring;
}

Expand Down
6 changes: 3 additions & 3 deletions src/lslunitsync/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ set_source_files_properties( ${libUnitsyncHeader} PROPERTIES HEADER_FILE_ONLY 1
#cimage deps
FIND_PACKAGE( PNG REQUIRED)
ADD_DEFINITIONS( -Dcimg_use_png )
ADD_LIBRARY(libUnitsync++ STATIC ${libUnitsyncHeader} ${libUnitsyncSrc} )
ADD_LIBRARY(lsl-unitsync STATIC ${libUnitsyncHeader} ${libUnitsyncSrc} )
if( WIN32 )
TARGET_LINK_LIBRARIES(libUnitsync++ dl )
TARGET_LINK_LIBRARIES(lsl-unitsync dl )
endif()
TARGET_LINK_LIBRARIES(libUnitsync++ ${Boost_LIBRARIES} ${PNG_LIBRARY})
TARGET_LINK_LIBRARIES(lsl-unitsync ${Boost_LIBRARIES} ${PNG_LIBRARY})
5 changes: 3 additions & 2 deletions src/lslunitsync/c_api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include <lslutils/logging.h>
#include <lslutils/misc.h>
#include <lslutils/globalsmanager.h>
#include <lslutils/debug.h>
#include <lslutils/conversion.h>

Expand Down Expand Up @@ -1229,8 +1230,8 @@ float UnitsyncLib::GetKeyValue( const std::string& key, float defval )

UnitsyncLib& susynclib()
{
static LineInfo<UnitsyncLib> m( AT );
static GlobalObjectHolder<UnitsyncLib, LineInfo<UnitsyncLib> > ss( m );
static LSL::Util::LineInfo<UnitsyncLib> m( AT );
static LSL::Util::GlobalObjectHolder<UnitsyncLib, LSL::Util::LineInfo<UnitsyncLib> > ss( m );
return ss;
}

Expand Down
22 changes: 22 additions & 0 deletions src/lslunitsync/image.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@
#include <lslutils/misc.h>
#include <lslutils/logging.h>

#ifdef HAVE_WX
#include <wx/bitmap.h>
#include <wx/image.h>
#endif

#ifdef WIN32
#include <boost/filesystem.hpp>
Expand All @@ -27,6 +31,7 @@ FILE* fmemopen(void* data, size_t size, const char* mode)
namespace cimg_library {

template < class T>
//! extends cimg to loading images from in-memory buffer
void load_mem( LSL::Util::uninitialized_array<char>& data, size_t size,
const std::string& fn, CImg<T>& img) {
const char* filename = fn.c_str();
Expand Down Expand Up @@ -253,4 +258,21 @@ int UnitsyncImage::GetWidth() const
return m_data_ptr->width();
}

#ifdef HAVE_WX
wxBitmap UnitsyncImage::wxbitmap() const
{
wxBitmap bmp;
auto handler = bmp.FindHandler(wxBITMAP_TYPE_PNG);
if(handler)
handler->Create(&bmp, static_cast<const void*>(m_data_ptr->data()), wxBITMAP_TYPE_PNG, m_data_ptr->width(), m_data_ptr->height());
else
LslError("png handler missing");
return bmp;
}
wxImage UnitsyncImage::wximage () const
{
return wxImage(this->wxbitmap().ConvertToImage());
}
#endif

} // namespace LSL
9 changes: 9 additions & 0 deletions src/lslunitsync/image.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ template <class T>
struct CImg;
}

#ifdef HAVE_WX
class wxBitmap;
class wxImage;
#endif

namespace LSL {

namespace Util {
Expand Down Expand Up @@ -49,6 +54,10 @@ class UnitsyncImage
static UnitsyncImage FromVfsFileData( Util::uninitialized_array<char>& data, size_t size, const std::string& fn, bool useWhiteAsTransparent = true );
///@}

#ifdef HAVE_WX
wxBitmap wxbitmap() const;
wxImage wximage() const;
#endif
int GetWidth() const;
int GetHeight() const;
void Rescale( const int new_width, const int new_height);
Expand Down
24 changes: 12 additions & 12 deletions src/lslunitsync/unitsync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "c_api.h"
#include "image.h"

#include <lslutils/lslconfig.h>
#include <lslutils/config.h>
#include <lslutils/debug.h>
#include <lslutils/conversion.h>
#include <lslutils/misc.h>
Expand Down Expand Up @@ -94,7 +94,7 @@ bool Unitsync::FastLoadUnitSyncLibInit()
LOCK_UNITSYNC;
m_cache_thread = new WorkerThread();
if ( IsLoaded() ) {
m_cache_path = sett().GetCachePath();
m_cache_path = Util::config().GetCachePath().string();
PopulateArchiveList();
}
return true;
Expand All @@ -107,7 +107,7 @@ bool Unitsync::LoadUnitSyncLib( const std::string& unitsyncloc )
bool ret = _LoadUnitSyncLib( unitsyncloc );
if (ret)
{
m_cache_path = sett().GetCachePath();
m_cache_path = LSL::Util::config().GetCachePath().string();
PopulateArchiveList();
// GetGlobalEventSender(GlobalEvents::OnUnitsyncReloaded).SendEvent( 0 );
}
Expand Down Expand Up @@ -195,7 +195,7 @@ void Unitsync::PopulateArchiveList()
bool Unitsync::_LoadUnitSyncLib( const std::string& unitsyncloc )
{
try {
m_susynclib->Load( unitsyncloc, sett().GetForcedSpringConfigFilePath() );
m_susynclib->Load( unitsyncloc, LSL::Util::config().GetForcedSpringConfigFilePath().string() );
} catch (...) {
return false;
}
Expand Down Expand Up @@ -577,6 +577,7 @@ StringVector Unitsync::GetAIList( const std::string& modname ) const
}
catch ( ... ) {}
}
std::sort(std::begin(ret), std::end(ret));
return ret;
}

Expand Down Expand Up @@ -812,7 +813,7 @@ StringVector Unitsync::FindFilesVFS( const std::string& pattern ) const

bool Unitsync::ReloadUnitSyncLib()
{
return LoadUnitSyncLib( sett().GetCurrentUsedUnitSync() );
return LoadUnitSyncLib( LSL::Util::config().GetCurrentUsedUnitSync().string() );
}


Expand Down Expand Up @@ -1090,15 +1091,14 @@ void Unitsync::PrefetchMap( const std::string& mapname )
}
}

void Unitsync::RegisterEvtHandler( StringSignalSlotType handler )
boost::signals2::connection Unitsync::RegisterEvtHandler( const StringSignalSlotType& handler )
{
m_async_ops_complete_sig.connect( handler );
return m_async_ops_complete_sig.connect( handler );
}

void Unitsync::UnregisterEvtHandler( StringSignalSlotType handler )
void Unitsync::UnregisterEvtHandler(boost::signals2::connection &conn )
{
// m_async_ops_complete_sig.disconnect( handler );
assert( false );
conn.disconnect();
}

void Unitsync::PostEvent( const std::string evt )
Expand Down Expand Up @@ -1208,8 +1208,8 @@ void Unitsync::AddReloadEvent( )
}

Unitsync& usync() {
static LineInfo<Unitsync> m( AT );
static GlobalObjectHolder<Unitsync, LineInfo<Unitsync> > m_sync( m );
static LSL::Util::LineInfo<Unitsync> m( AT );
static LSL::Util::GlobalObjectHolder<Unitsync, LSL::Util::LineInfo<Unitsync> > m_sync( m );
return m_sync;
}

Expand Down
28 changes: 18 additions & 10 deletions src/lslunitsync/unitsync.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
#include <boost/signals2/signal.hpp>
#include <map>

#ifdef HAVE_WX
#include <wx/event.h>
#endif
namespace LSL {

class UnitsyncImage;
Expand All @@ -19,6 +22,10 @@ struct CachedMapInfo;
struct SpringMapInfo;
class UnitsyncLib;

#ifdef HAVE_WX
extern const wxEventType UnitSyncAsyncOperationCompletedEvt;
#endif

class Unitsync : public boost::noncopyable
{
private:
Expand Down Expand Up @@ -120,8 +127,8 @@ class Unitsync : public boost::noncopyable
/// schedule a map for prefetching
void PrefetchMap( const std::string& mapname );

void RegisterEvtHandler( StringSignalSlotType handler );
void UnregisterEvtHandler(StringSignalSlotType handler );
boost::signals2::connection RegisterEvtHandler(const StringSignalSlotType &handler );
void UnregisterEvtHandler(boost::signals2::connection& conn );
void PostEvent(const std::string evt ); // helper for WorkItems

void GetMinimapAsync( const std::string& mapname );
Expand Down Expand Up @@ -216,16 +223,17 @@ struct GameOptions
};

/// Helper class for managing async operations safely
class UnitSyncAsyncOps
class UnitSyncAsyncOps : public boost::noncopyable
{
public:
UnitSyncAsyncOps( Unitsync::StringSignalSlotType evtHandler )
: m_evtHandler( evtHandler )
{
usync().RegisterEvtHandler( evtHandler );
}
UnitSyncAsyncOps( const Unitsync::StringSignalSlotType& evtHandler )
// : m_evtHandler_connection()
{
usync().RegisterEvtHandler(evtHandler);
}

~UnitSyncAsyncOps() {
usync().UnregisterEvtHandler( m_evtHandler );
// usync().UnregisterEvtHandler(m_evtHandler_connection);
}

void GetMinimap( const std::string& mapname ) { usync().GetMinimapAsync( mapname ); }
Expand All @@ -237,7 +245,7 @@ class UnitSyncAsyncOps
void GetMapEx( const std::string& mapname ) { usync().GetMapExAsync( mapname ); }

private:
Unitsync::StringSignalSlotType m_evtHandler;
// boost::signals2::connection m_evtHandler_connection;
};

} // namespace LSL
Expand Down
6 changes: 3 additions & 3 deletions src/lslutils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

SET(libSpringLobbyUtilsSrc
"${CMAKE_CURRENT_SOURCE_DIR}/misc.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/lslconfig.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/config.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/crc.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/thread.cpp"
"${CMAKE_CURRENT_SOURCE_DIR}/net.cpp"
Expand All @@ -19,5 +19,5 @@ LIST( APPEND libSpringLobbyUtilsHeader ${templatesources} )
set_source_files_properties( ${libSpringLobbyUtilsHeader} PROPERTIES HEADER_FILE_ONLY 1 )
INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
ADD_LIBRARY(libSpringLobbyUtils STATIC ${libSpringLobbyHeader} ${libSpringLobbyUtilsSrc} )
TARGET_LINK_LIBRARIES(libSpringLobbyUtils boost_thread-mt)
ADD_LIBRARY(lsl-utils STATIC ${libSpringLobbyHeader} ${libSpringLobbyUtilsSrc} )
TARGET_LINK_LIBRARIES(lsl-utils boost_thread-mt)
Loading

0 comments on commit 7ae10ca

Please sign in to comment.