From 1bc6e891491179440df5050e1251ea6268ed2d5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20F=C3=B6rster?= Date: Wed, 8 Aug 2012 09:29:25 +0200 Subject: [PATCH] [games-server/ghost++] initial import, still not finished (and only compile tested) uses cmake as we have a dep on it anyway. --- games-server/ghost++/Manifest | 1 + games-server/ghost++/files/CMakeLists.txt | 68 +++ .../files/cmake/modules/FindMySQL.cmake | 120 +++++ .../files/cmake/modules/FindSqlite.cmake | 50 ++ .../files/cmake/modules/FindStormLib.cmake | 23 + .../files/cmake/modules/Findbncsutil.cmake | 23 + .../ghost++/files/ghost++-GetLastError.patch | 13 + .../ghost++/files/ghost++-configpath.patch | 43 ++ games-server/ghost++/files/ghost++-ggb.patch | 152 ++++++ .../files/ghost++-sqlite-include-guard.patch | 16 + .../files/ghost++-stormlib-include.patch | 26 + games-server/ghost++/files/ghost++.cfg | 501 ++++++++++++++++++ .../ghost++/ghost++-17.1_p20120618.ebuild | 58 ++ 13 files changed, 1094 insertions(+) create mode 100644 games-server/ghost++/Manifest create mode 100644 games-server/ghost++/files/CMakeLists.txt create mode 100644 games-server/ghost++/files/cmake/modules/FindMySQL.cmake create mode 100644 games-server/ghost++/files/cmake/modules/FindSqlite.cmake create mode 100644 games-server/ghost++/files/cmake/modules/FindStormLib.cmake create mode 100644 games-server/ghost++/files/cmake/modules/Findbncsutil.cmake create mode 100644 games-server/ghost++/files/ghost++-GetLastError.patch create mode 100644 games-server/ghost++/files/ghost++-configpath.patch create mode 100644 games-server/ghost++/files/ghost++-ggb.patch create mode 100644 games-server/ghost++/files/ghost++-sqlite-include-guard.patch create mode 100644 games-server/ghost++/files/ghost++-stormlib-include.patch create mode 100644 games-server/ghost++/files/ghost++.cfg create mode 100644 games-server/ghost++/ghost++-17.1_p20120618.ebuild diff --git a/games-server/ghost++/Manifest b/games-server/ghost++/Manifest new file mode 100644 index 0000000..00750ef --- /dev/null +++ b/games-server/ghost++/Manifest @@ -0,0 +1 @@ +DIST ghost++-17.1_p20120618.tar.xz 790644 SHA256 7ca988a20ab070c2c8b8fbf7c4e3b8843640addc82390397555f2b3db88d2884 SHA512 ae658693f66c5a35f991a0970db83ccd8152daffddebb7ce5d2b5cc9b6abc46d2e96c0159d2a8fb8b18c27470652db34c4d1e020c6b4cbe9490f606f5565ea44 WHIRLPOOL bb7a3003b0264d21adaf78f1fdeb9d96488fd667193caec4fb1529aa5a3d130fe98e422b872823e7389966e6ffafbe1d424fa5ec00218675c5b157f981720937 diff --git a/games-server/ghost++/files/CMakeLists.txt b/games-server/ghost++/files/CMakeLists.txt new file mode 100644 index 0000000..87668cc --- /dev/null +++ b/games-server/ghost++/files/CMakeLists.txt @@ -0,0 +1,68 @@ +project(ghost++) +cmake_minimum_required(VERSION 2.6) + +set(SRC_FILES + ghost/bncsutilinterface.cpp + ghost/bnet.cpp + ghost/bnetprotocol.cpp + ghost/bnlsclient.cpp + ghost/bnlsprotocol.cpp + ghost/commandpacket.cpp + ghost/config.cpp + ghost/crc32.cpp + ghost/csvparser.cpp + ghost/game.cpp + ghost/gameplayer.cpp + ghost/gameprotocol.cpp + ghost/gameslot.cpp + ghost/game_admin.cpp + ghost/game_base.cpp + ghost/ghost.cpp + ghost/ghostdb.cpp + ghost/ghostdbmysql.cpp + ghost/ghostdbsqlite.cpp + ghost/gpsprotocol.cpp + ghost/language.cpp + ghost/map.cpp + ghost/packed.cpp + ghost/replay.cpp + ghost/savegame.cpp + ghost/sha1.cpp + ghost/socket.cpp + ghost/stats.cpp + ghost/statsdota.cpp + ghost/statsw3mmd.cpp + ghost/util.cpp +) + +set(DOTA_ELO_SRC_FILES + update_dota_elo/elo.cpp + update_dota_elo/update_dota_elo.cpp +) + +set(W3MMD_ELO_SRC_FILES + update_w3mmd_elo/elo.cpp + update_w3mmd_elo/update_w3mmd_elo.cpp +) + +# Check modules first in local dir +set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules) + +find_package(bncsutil REQUIRED) +set(Boost_USE_MULTITHREADED ON) +find_package(Boost COMPONENTS date_time filesystem system thread REQUIRED) +find_package(StormLib REQUIRED) +find_package(Sqlite REQUIRED) +set(LINK_LIBS ${bncsutil_LIBRARY} ${Boost_LIBRARIES} ${StormLib_LIBRARY} ${SQLITE_LIBRARIES}) + +if(WITH_MYSQL) + find_package(MySQL REQUIRED) + add_definitions(-DGHOST_MYSQL) + LIST(APPEND LINK_LIBS ${MYSQL_CLIENT_LIBS}) +endif() + +add_executable(ghost++ ${SRC_FILES}) +target_link_libraries(ghost++ ${LINK_LIBS}) + +install(TARGETS ghost++ RUNTIME DESTINATION bin) +install(FILES ghost++.cfg default.cfg language.cfg DESTINATION ${CONFIGPATH}) diff --git a/games-server/ghost++/files/cmake/modules/FindMySQL.cmake b/games-server/ghost++/files/cmake/modules/FindMySQL.cmake new file mode 100644 index 0000000..d9681e7 --- /dev/null +++ b/games-server/ghost++/files/cmake/modules/FindMySQL.cmake @@ -0,0 +1,120 @@ +#-------------------------------------------------------- +# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved +# +# The MySQL Connector/ODBC is licensed under the terms of the GPLv2 +# , like most +# MySQL Connectors. There are special exceptions to the terms and +# conditions of the GPLv2 as it is applied to this software, see the +# FLOSS License Exception +# . +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published +# by the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY +# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +########################################################################## + + +#-------------- FIND MYSQL_INCLUDE_DIR ------------------ +FIND_PATH(MYSQL_INCLUDE_DIR mysql.h + $ENV{MYSQL_INCLUDE_DIR} + $ENV{MYSQL_DIR}/include + /usr/include/mysql + /usr/local/include/mysql + /opt/mysql/mysql/include + /opt/mysql/mysql/include/mysql + /usr/local/mysql/include + /usr/local/mysql/include/mysql + $ENV{ProgramFiles}/MySQL/*/include + $ENV{SystemDrive}/MySQL/*/include) + +#----------------- FIND MYSQL_LIB_DIR ------------------- +IF (WIN32) + # Set lib path suffixes + # dist = for mysql binary distributions + # build = for custom built tree + IF (CMAKE_BUILD_TYPE STREQUAL Debug) + SET(libsuffixDist debug) + SET(libsuffixBuild Debug) + ELSE (CMAKE_BUILD_TYPE STREQUAL Debug) + SET(libsuffixDist opt) + SET(libsuffixBuild Release) + ADD_DEFINITIONS(-DDBUG_OFF) + ENDIF (CMAKE_BUILD_TYPE STREQUAL Debug) + + FIND_LIBRARY(MYSQL_LIB NAMES mysqlclient + PATHS + $ENV{MYSQL_DIR}/lib/${libsuffixDist} + $ENV{MYSQL_DIR}/lib + $ENV{MYSQL_DIR}/libmysql + $ENV{MYSQL_DIR}/lib + $ENV{MYSQL_DIR}/libmysql/${libsuffixBuild} + $ENV{MYSQL_DIR}/client/${libsuffixBuild} + $ENV{MYSQL_DIR}/libmysql/${libsuffixBuild} + $ENV{ProgramFiles}/MySQL/*/lib/${libsuffixDist} + $ENV{ProgramFiles}/MySQL/*/lib + $ENV{SystemDrive}/MySQL/*/lib/${libsuffixDist}) +ELSE (WIN32) + FIND_LIBRARY(MYSQL_LIB NAMES mysqlclient_r + PATHS + $ENV{MYSQL_DIR}/libmysql_r/.libs + $ENV{MYSQL_DIR}/lib + $ENV{MYSQL_DIR}/lib/mysql + /usr/lib/mysql + /usr/local/lib/mysql + /usr/local/mysql/lib + /usr/local/mysql/lib/mysql + /opt/mysql/mysql/lib + /opt/mysql/mysql/lib/mysql) +ENDIF (WIN32) + +IF(MYSQL_LIB) + GET_FILENAME_COMPONENT(MYSQL_LIB_DIR ${MYSQL_LIB} PATH) +ENDIF(MYSQL_LIB) + +IF (MYSQL_INCLUDE_DIR AND MYSQL_LIB_DIR) + SET(MYSQL_FOUND TRUE) + + INCLUDE_DIRECTORIES(${MYSQL_INCLUDE_DIR}) + LINK_DIRECTORIES(${MYSQL_LIB_DIR}) + + FIND_LIBRARY(MYSQL_ZLIB zlib PATHS ${MYSQL_LIB_DIR}) + FIND_LIBRARY(MYSQL_YASSL yassl PATHS ${MYSQL_LIB_DIR}) + FIND_LIBRARY(MYSQL_TAOCRYPT taocrypt PATHS ${MYSQL_LIB_DIR}) + IF (WIN32) + SET(MYSQL_CLIENT_LIBS mysqlclient) + ELSE (WIN32) + SET(MYSQL_CLIENT_LIBS mysqlclient_r) + ENDIF (WIN32) + IF (MYSQL_ZLIB) + SET(MYSQL_CLIENT_LIBS ${MYSQL_CLIENT_LIBS} zlib) + ENDIF (MYSQL_ZLIB) + IF (MYSQL_YASSL) + SET(MYSQL_CLIENT_LIBS ${MYSQL_CLIENT_LIBS} yassl) + ENDIF (MYSQL_YASSL) + IF (MYSQL_TAOCRYPT) + SET(MYSQL_CLIENT_LIBS ${MYSQL_CLIENT_LIBS} taocrypt) + ENDIF (MYSQL_TAOCRYPT) + # Added needed mysqlclient dependencies on Windows + IF (WIN32) + SET(MYSQL_CLIENT_LIBS ${MYSQL_CLIENT_LIBS} ws2_32) + ELSE (WIN32) + FIND_PACKAGE(Threads) + SET(MYSQL_CLIENT_LIBS ${MYSQL_CLIENT_LIBS} ${CMAKE_THREAD_LIBS_INIT}) + ENDIF (WIN32) + + MESSAGE(STATUS "MySQL Include dir: ${MYSQL_INCLUDE_DIR} library dir: ${MYSQL_LIB_DIR}") + MESSAGE(STATUS "MySQL client libraries: ${MYSQL_CLIENT_LIBS}") +ELSE (MYSQL_INCLUDE_DIR AND MYSQL_LIB_DIR) + MESSAGE(FATAL_ERROR "Cannot find MySQL. Include dir: ${MYSQL_INCLUDE_DIR} library dir: ${MYSQL_LIB_DIR}") +ENDIF (MYSQL_INCLUDE_DIR AND MYSQL_LIB_DIR) + diff --git a/games-server/ghost++/files/cmake/modules/FindSqlite.cmake b/games-server/ghost++/files/cmake/modules/FindSqlite.cmake new file mode 100644 index 0000000..c4f2e90 --- /dev/null +++ b/games-server/ghost++/files/cmake/modules/FindSqlite.cmake @@ -0,0 +1,50 @@ +# - Try to find Sqlite +# Once done this will define +# +# SQLITE_FOUND - system has Sqlite +# SQLITE_INCLUDE_DIR - the Sqlite include directory +# SQLITE_LIBRARIES - Link these to use Sqlite +# SQLITE_DEFINITIONS - Compiler switches required for using Sqlite +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# + + +# Copyright (c) 2008, Gilles Caulier, +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. + +if ( SQLITE_INCLUDE_DIR AND SQLITE_LIBRARIES ) + # in cache already + SET(Sqlite_FIND_QUIETLY TRUE) +endif ( SQLITE_INCLUDE_DIR AND SQLITE_LIBRARIES ) + +# use pkg-config to get the directories and then use these values +# in the FIND_PATH() and FIND_LIBRARY() calls +if( NOT WIN32 ) + find_package(PkgConfig) + + pkg_check_modules(PC_SQLITE QUIET sqlite3) + + set(SQLITE_DEFINITIONS ${PC_SQLITE_CFLAGS_OTHER}) +endif( NOT WIN32 ) + +find_path(SQLITE_INCLUDE_DIR NAMES sqlite3.h + PATHS + ${PC_SQLITE_INCLUDEDIR} + ${PC_SQLITE_INCLUDE_DIRS} +) + +find_library(SQLITE_LIBRARIES NAMES sqlite3 + PATHS + ${PC_SQLITE_LIBDIR} + ${PC_SQLITE_LIBRARY_DIRS} +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Sqlite DEFAULT_MSG SQLITE_INCLUDE_DIR SQLITE_LIBRARIES ) + +# show the SQLITE_INCLUDE_DIR and SQLITE_LIBRARIES variables only in the advanced view +mark_as_advanced(SQLITE_INCLUDE_DIR SQLITE_LIBRARIES ) + diff --git a/games-server/ghost++/files/cmake/modules/FindStormLib.cmake b/games-server/ghost++/files/cmake/modules/FindStormLib.cmake new file mode 100644 index 0000000..fb30414 --- /dev/null +++ b/games-server/ghost++/files/cmake/modules/FindStormLib.cmake @@ -0,0 +1,23 @@ +# - Find StormLib +# Find StormLib headers and libraries. +# +# StormLib_INCLUDE_DIR - where to find StormLib.h, etc. +# StormLib_LIBRARY - List of libraries when using StormLib. +# StormLib_FOUND - True if StormLib found. + +# Look for the header file. +FIND_PATH( StormLib_INCLUDE_DIR NAMES StormLib.h + PATHS /usr/include /usr/local/include) +MARK_AS_ADVANCED(StormLib_INCLUDE_DIR) + +# Look for the library. +FIND_LIBRARY( StormLib_LIBRARY NAMES storm + PATHS /usr/lib /usr/lib64 ) +MARK_AS_ADVANCED(StormLib_LIBRARY) + +# Copy the results to the output variables. +IF(StormLib_INCLUDE_DIR AND StormLib_LIBRARY) + SET(StormLib_FOUND 1) +ELSE(StormLib_INCLUDE_DIR AND StormLib_LIBRARY) + SET(StormLib_FOUND 0) +ENDIF(StormLib_INCLUDE_DIR AND StormLib_LIBRARY) \ No newline at end of file diff --git a/games-server/ghost++/files/cmake/modules/Findbncsutil.cmake b/games-server/ghost++/files/cmake/modules/Findbncsutil.cmake new file mode 100644 index 0000000..dffc69d --- /dev/null +++ b/games-server/ghost++/files/cmake/modules/Findbncsutil.cmake @@ -0,0 +1,23 @@ +# - Find bncsutil +# Find bncsutil headers and libraries. +# +# bncsutil_INCLUDE_DIR - where to find bncsutil.h, etc. +# bncsutil_LIBRARY - List of libraries when using bncsutil. +# bncsutil_FOUND - True if bncsutil found. + +# Look for the header file. +FIND_PATH( bncsutil_INCLUDE_DIR NAMES bncsutil.h + PATHS /usr/include/bncsutil /usr/local/include/bncsutil) +MARK_AS_ADVANCED(bncsutil_INCLUDE_DIR) + +# Look for the library. +FIND_LIBRARY( bncsutil_LIBRARY NAMES bncsutil + PATHS /usr/lib /usr/lib64 ) +MARK_AS_ADVANCED(bncsutil_LIBRARY) + +# Copy the results to the output variables. +IF(bncsutil_INCLUDE_DIR AND bncsutil_LIBRARY) + SET(bncsutil_FOUND 1) +ELSE(bncsutil_INCLUDE_DIR AND bncsutil_LIBRARY) + SET(bncsutil_FOUND 0) +ENDIF(bncsutil_INCLUDE_DIR AND bncsutil_LIBRARY) \ No newline at end of file diff --git a/games-server/ghost++/files/ghost++-GetLastError.patch b/games-server/ghost++/files/ghost++-GetLastError.patch new file mode 100644 index 0000000..a9fd57e --- /dev/null +++ b/games-server/ghost++/files/ghost++-GetLastError.patch @@ -0,0 +1,13 @@ +Index: ghost/socket.h +=================================================================== +--- ghost/socket.h (revision 580) ++++ ghost/socket.h (working copy) +@@ -79,8 +79,6 @@ + #define SOCKET_ERROR -1 + + #define closesocket close +- +- extern int GetLastError( ); + #endif + + #ifndef INADDR_NONE diff --git a/games-server/ghost++/files/ghost++-configpath.patch b/games-server/ghost++/files/ghost++-configpath.patch new file mode 100644 index 0000000..cf4d8d6 --- /dev/null +++ b/games-server/ghost++/files/ghost++-configpath.patch @@ -0,0 +1,43 @@ +Index: ghost/ghost.cpp +=================================================================== +--- ghost/ghost.cpp (revision 573) ++++ ghost/ghost.cpp (working copy) +@@ -233,15 +233,23 @@ + { + srand( time( NULL ) ); + ++// we need a full path for the config file since we could install system-wide so the executable is not in the same place as the config --Dessa ++#ifdef CONFIGPATH ++ gCFGFile = CONFIGPATH "ghost.cfg"; ++#else + gCFGFile = "ghost.cfg"; +- ++#endif + if( argc > 1 && argv[1] ) + gCFGFile = argv[1]; + + // read config file + + CConfig CFG; ++#ifdef CONFIGPATH ++ CFG.Read( CONFIGPATH "default.cfg" ); ++#else + CFG.Read( "default.cfg" ); ++#endif + CFG.Read( gCFGFile ); + gLogFile = CFG.GetString( "bot_log", string( ) ); + gLogMethod = CFG.GetInt( "bot_logmethod", 1 ); +@@ -1459,8 +1467,12 @@ + void CGHost :: LoadIPToCountryData( ) + { + ifstream in; ++// bah, why isn't that configurable? hardcode for now --Dessa ++#ifdef CONFIGPATH ++ in.open( CONFIGPATH "/ip-to-country.csv" ); ++#else + in.open( "ip-to-country.csv" ); +- ++#endif + if( in.fail( ) ) + CONSOLE_Print( "[GHOST] warning - unable to read file [ip-to-country.csv], iptocountry data not loaded" ); + else diff --git a/games-server/ghost++/files/ghost++-ggb.patch b/games-server/ghost++/files/ghost++-ggb.patch new file mode 100644 index 0000000..2d154f5 --- /dev/null +++ b/games-server/ghost++/files/ghost++-ggb.patch @@ -0,0 +1,152 @@ +Index: ghost/game_base.cpp +=================================================================== +--- ghost/game_base.cpp (revision 580) ++++ ghost/game_base.cpp (working copy) +@@ -388,12 +388,13 @@ + + // we also broadcast the game to the local network every 5 seconds so we hijack this timer for our nefarious purposes + // however we only want to broadcast if the countdown hasn't started +- // see the !sendlan code later in this file for some more information about how this works +- // todotodo: should we send a game cancel message somewhere? we'll need to implement a host counter for it to work +- +- if( !m_CountDownStarted ) +- { +- // construct a fixed host counter which will be used to identify players from this "realm" (i.e. LAN) ++ // see the !sendlan code later in this file for some more information about how this works ++ // todotodo: should we send a game cancel message somewhere? we'll need to implement a host counter for it to work ++ ++ ++ if( !m_CountDownStarted ) ++ { ++ // construct a fixed host counter which will be used to identify players from this "realm" (i.e. LAN) + // the fixed host counter's 4 most significant bits will contain a 4 bit ID (0-15) + // the rest of the fixed host counter will contain the 28 least significant bits of the actual host counter + // since we're destroying 4 bits of information here the actual host counter should not be greater than 2^28 which is a reasonable assumption +Index: ghost/ghost.cpp +=================================================================== +--- ghost/ghost.cpp (revision 580) ++++ ghost/ghost.cpp (working copy) +@@ -677,12 +677,20 @@ + if( m_AdminGamePort == m_HostPort ) + CONSOLE_Print( "[GHOST] warning - admingame_port and bot_hostport are set to the same value, you won't be able to host any games" ); + } +- else +- m_AdminGame = NULL; +- +- if( m_BNETs.empty( ) && !m_AdminGame ) +- CONSOLE_Print( "[GHOST] warning - no battle.net connections found and no admin game created" ); +- ++ else ++ m_AdminGame = NULL; ++ ++ // create the listening socket for broadcasters; ++ ++ int Port = CFG->GetInt("bot_broadcasters_port", 6969 ); ++ m_GameBroadcastersListener = new CTCPServer( ); ++ m_GameBroadcastersListener->Listen( string( ),Port ); ++ CONSOLE_Print( "[GHOST] Listening for game broadcasters on port [" + UTIL_ToString( Port ) +"]" ); ++ ++ ++ if( m_BNETs.empty( ) && !m_AdminGame ) ++ CONSOLE_Print( "[GHOST] warning - no battle.net connections found and no admin game created" ); ++ + #ifdef GHOST_MYSQL + CONSOLE_Print( "[GHOST] GHost++ Version " + m_Version + " (with MySQL support)" ); + #else +@@ -881,9 +889,23 @@ + { + (*i)->SetFD( &fd, &send_fd, &nfds ); + ++NumFDs; +- } +- +- // before we call select we need to determine how long to block for ++ } ++ // 6. the Game Broadcasters ++ for(vector::iterator i = m_GameBroadcasters.begin( ); i!= m_GameBroadcasters.end( ); i++ ) ++ { ++ if ( (*i)->GetConnected( ) && !(*i)->HasError( ) ) ++ { ++ (*i)->SetFD( &fd, &send_fd, &nfds ); ++ NumFDs++; ++ } ++ } ++ ++ // 7. the listener for game broadcasters ++ m_GameBroadcastersListener->SetFD( &fd, &send_fd,&nfds ); ++ NumFDs++; ++ ++ ++ // before we call select we need to determine how long to block for + // previously we just blocked for a maximum of the passed usecBlock microseconds + // however, in an effort to make game updates happen closer to the desired latency setting we now use a dynamic block interval + // note: we still use the passed usecBlock as a hard maximum +@@ -1170,12 +1192,37 @@ + } + } + +- m_LastAutoHostTime = GetTime( ); +- } +- +- return m_Exiting || AdminExit || BNETExit; +-} +- ++ m_LastAutoHostTime = GetTime( ); ++ } ++ ++ CTCPSocket *NewSocket = m_GameBroadcastersListener->Accept( &fd ); ++ if ( NewSocket ) ++ { ++ m_GameBroadcasters.push_back( NewSocket ); ++ CONSOLE_Print("[GHOST] Game Broadcaster [" + NewSocket->GetIPString( ) +"] connected" ); ++ //BYTEARRAY info; ++ // UTIL_AppendByteArray( info, m_AdminGamePort,false ); ++ //UTIL_AppendByteArray( info, m_HostPort, false ); ++ //NewSocket->PutBytes( info ); ++ } ++ for(vector::iterator i = m_GameBroadcasters.begin( ); i!= m_GameBroadcasters.end( ); ) ++ { ++ if ( (*i)->HasError( ) || !(*i)->GetConnected( ) ) ++ { ++ CONSOLE_Print("[GHOST] Game Broadcaster [" + (*i)->GetIPString( ) +"] disconnected"); ++ delete *i; ++ i = m_GameBroadcasters.erase( i ); ++ continue; ++ } ++ //(*i)->DoRecv( &fd ); ++ (*i)->DoSend( &send_fd ); ++ i++; ++ } ++ ++ ++ return m_Exiting || AdminExit || BNETExit; ++} ++ + void CGHost :: EventBNETConnecting( CBNET *bnet ) + { + if( m_AdminGame ) +Index: ghost/ghost.h +=================================================================== +--- ghost/ghost.h (revision 580) ++++ ghost/ghost.h (working copy) +@@ -130,13 +130,15 @@ + string m_AdminGameMap; // config value: the admin game map config to use + unsigned char m_LANWar3Version; // config value: LAN warcraft 3 version + uint32_t m_ReplayWar3Version; // config value: replay warcraft 3 version (for saving replays) +- uint32_t m_ReplayBuildNumber; // config value: replay build number (for saving replays) +- bool m_TCPNoDelay; // config value: use Nagle's algorithm or not +- uint32_t m_MatchMakingMethod; // config value: the matchmaking method ++ uint32_t m_ReplayBuildNumber; // config value: replay build number (for saving replays) ++ bool m_TCPNoDelay; // config value: use Nagle's algorithm or not ++ uint32_t m_MatchMakingMethod; // config value: the matchmaking method ++ CTCPServer *m_GameBroadcastersListener; // listening socket for game broadcasters ++ vector m_GameBroadcasters;// vector of sockets that broadcast the games ++ ++ CGHost( CConfig *CFG ); ++ ~CGHost( ); + +- CGHost( CConfig *CFG ); +- ~CGHost( ); +- + // processing functions + + bool Update( long usecBlock ); diff --git a/games-server/ghost++/files/ghost++-sqlite-include-guard.patch b/games-server/ghost++/files/ghost++-sqlite-include-guard.patch new file mode 100644 index 0000000..1a37ad5 --- /dev/null +++ b/games-server/ghost++/files/ghost++-sqlite-include-guard.patch @@ -0,0 +1,16 @@ +Index: ghost/ghostdbsqlite.cpp +=================================================================== +--- ghost/ghostdbsqlite.cpp (revision 580) ++++ ghost/ghostdbsqlite.cpp (working copy) +@@ -23,8 +23,9 @@ + #include "config.h" + #include "ghostdb.h" + #include "ghostdbsqlite.h" +-#include "sqlite3.h" + ++#include ++ + // + // CQSLITE3 (wrapper class) + // + diff --git a/games-server/ghost++/files/ghost++-stormlib-include.patch b/games-server/ghost++/files/ghost++-stormlib-include.patch new file mode 100644 index 0000000..d07b9b7 --- /dev/null +++ b/games-server/ghost++/files/ghost++-stormlib-include.patch @@ -0,0 +1,26 @@ +Index: ghost/ghost.cpp +=================================================================== +--- ghost/ghost.cpp (revision 572) ++++ ghost/ghost.cpp (working copy) +@@ -48,7 +48,7 @@ + #endif + + #define __STORMLIB_SELF__ +-#include ++#include + + /* + +Index: ghost/map.cpp +=================================================================== +--- ghost/map.cpp (revision 572) ++++ ghost/map.cpp (working copy) +@@ -26,7 +26,7 @@ + #include "map.h" + + #define __STORMLIB_SELF__ +-#include ++#include + + #define ROTL(x,n) ((x)<<(n))|((x)>>(32-(n))) // this won't work with signed types + #define ROTR(x,n) ((x)>>(n))|((x)<<(32-(n))) // this won't work with signed types diff --git a/games-server/ghost++/files/ghost++.cfg b/games-server/ghost++/files/ghost++.cfg new file mode 100644 index 0000000..3b99483 --- /dev/null +++ b/games-server/ghost++/files/ghost++.cfg @@ -0,0 +1,501 @@ +##################### +# BOT CONFIGURATION # +##################### + +### the log file + +bot_log = /var/log/ghost++.log + +### the log method +### set this to 1 to leave the log unlocked while GHost++ is running (may be slower, particularly on Windows) +### set this to 2 to lock the log while GHost++ is running (may be faster, particularly on Windows) +### note: if the log is locked you will not be able to edit/move/delete it while GHost++ is running + +bot_logmethod = 1 + +### the language file + +bot_language = /etc/ghost++/language.cfg + +### the path to your local Warcraft III directory +### this path must contain war3.exe, storm.dll, and game.dll +### if this path contains War3Patch.mpq the bot will attempt to extract "Scripts\common.j" and "Scripts\blizzard.j" on startup and write them to bot_mapcfgpath (which is defined later in this file) +### common.j and blizzard.j are only required for automatically calculating map_crc, you do not need them if your map config files already contain map_crc + +bot_war3path = /var/lib/ghost++ + +### whether to act as Warcraft III: The Frozen Throne or not +### set this to 0 to act as Warcraft III: Reign of Chaos (you WILL NOT need to enter a TFT cd key to login to battle.net) +### set this to 1 to act as Warcraft III: The Frozen Throne (you WILL need to enter a TFT cd key to login to battle.net) + +bot_tft = 1 + +### the address GHost++ will bind to when hosting games (leave it blank to bind to all available addresses) +### if you don't know what this is just leave it blank + +bot_bindaddress = + +### the port GHost++ will host games on (this must be different from your admingame_port) + +bot_hostport = 6112 + +### whether to allow GProxy++ reliable reconnects or not +### you should ensure that bot_synclimit is set to a reasonable value if you choose to allow GProxy++ reliable reconnects +### a reasonable value is 5000 divided by bot_latency, e.g. if bot_latency is 100 use a value of 50 for bot_synclimit + +bot_reconnect = 0 + +### the port GHost++ will listen for GProxy++ reliable reconnects on + +bot_reconnectport = 6114 + +### the maximum number of minutes to wait for a GProxy++ client to reconnect to the game +### if you set this to 0 or 1 GHost++ will wait for up to 1 minute +### if you set this to 10 or more GHost++ will only wait for up to 10 minutes +### due to the way GProxy++ works, increasing this value increases bandwidth requirements and CPU requirements on the players' computers +### players can always vote to drop a player who is lagging after waiting 45 seconds regardless of this value + +bot_reconnectwaittime = 3 + +### maximum number of games to host at once + +bot_maxgames = 5 + +### command trigger for ingame only (battle.net command triggers are defined later) + +bot_commandtrigger = ! + +### the path to the directory where you keep your map config files +### this directory can also contain common.j and blizzard.j (extracted from War3Patch.mpq) +### common.j and blizzard.j are only required for automatically calculating map_crc, you do not need them if your map config files already contain map_crc + +bot_mapcfgpath = /etc/ghost++/mapcfgs + +### the path to the directory where you keep your savegame files + +bot_savegamepath = /var/lib/ghost++/savegames + +### the path to the directory where you keep your map files +### GHost++ doesn't require map files but if it has access to them it can send them to players and automatically calculate most map config values +### GHost++ will search [bot_mappath + map_localpath] for the map file (map_localpath is set in each map's config file) + +bot_mappath = /var/lib/ghost++/maps + +### whether to save replays or not + +bot_savereplays = 0 + +### the path to the directory where you want GHost++ to save replays + +bot_replaypath = /var/lib/ghost++/replays + +### the Warcraft 3 version to save replays as + +replay_war3version = 26 + +### the Warcraft 3 build number to save replays as (this is specific to each Warcraft 3 version) +### patch 1.23: war3version 23, buildnumber 6058 +### patch 1.24: war3version 24, buildnumber 6059 +### patch 1.24b: war3version 24, buildnumber 6059 + +replay_buildnumber = 6059 + +### the bot's virtual host name as it appears in the game lobby +### colour codes are defined by the sequence "|cFF" followed by a six character hexadecimal colour in RRGGBB format (e.g. 0000FF for pure blue) +### the virtual host name cannot be longer than 15 characters including the colour code, if you try to go over this limit GHost++ will use the default virtual host name + +bot_virtualhostname = |cFF4080C0GHost + +### whether to hide each player's IP address from other players or not + +bot_hideipaddresses = 0 + +### whether to check for multiple IP address usage or not + +bot_checkmultipleipusage = 1 + +### whether to do automatic spoof checks or not +### you can always manually spoof check by whispering the bot (and in fact this is required before running admin commands) +### set to 0 to disable automatic spoof checks +### set to 1 to enable automatic spoof checks on all players +### set to 2 to enable automatic spoof checks on potential admins only + +bot_spoofchecks = 2 + +### whether to require spoof checks or not +### this controls whether the bot will require players to spoof check before starting the game +### it does NOT control whether the bot will require players to spoof check before running admin commands - spoof checks are ALWAYS required for admin status +### if you require spoof checks, players will be kicked from the lobby if they haven't spoof checked within 20 seconds of joining (autohosted games only) + +bot_requirespoofchecks = 0 + +### whether to consider admins and root admins as reserved players or not +### reserved players are allowed to join full games because another player will be kicked to allow them to join + +bot_reserveadmins = 1 + +### whether to display game refresh messages by default +### this can always be changed for a particular game with the !refresh command + +bot_refreshmessages = 0 + +### whether to automatically lock games when the owner joins + +bot_autolock = 0 + +### whether to automatically save games when a player disconnects +### this can always be changed for a particular game with the !autosave command + +bot_autosave = 0 + +### whether to allow map downloads or not +### set to 0 to disable map downloads +### set to 1 to enable map downloads +### set to 2 to enable conditional map downloads (an admin must start each map download with the !download or !dl command) + +bot_allowdownloads = 1 + +### whether to ping players during map downloads or not +### GHost++ will always stop pinging any players who are downloading the map +### this config value determines whether GHost++ should stop pinging *all* players when at least one player is downloading the map + +bot_pingduringdownloads = 0 + +### the maximum number of players allowed to download the map at the same time + +bot_maxdownloaders = 3 + +### the maximum combined download speed of all players downloading the map (in KB/sec) + +bot_maxdownloadspeed = 100 + +### use LC style pings (divide actual pings by two) + +bot_lcpings = 1 + +### auto kick players with ping higher than this + +bot_autokickping = 400 + +### the ban method +### if bot_banmethod = 1, GHost++ will automatically reject players using a banned name +### if bot_banmethod = 2, GHost++ will automatically reject players using a banned IP address +### if bot_banmethod = 3, GHost++ will automatically reject players using a banned name or IP address +### if bot_banmethod is anything else GHost++ will print a message when a banned player joins but will not automatically reject them + +bot_banmethod = 1 + +### the IP blacklist file + +bot_ipblacklistfile = /etc/ghost++/ipblacklist.txt + +### automatically close the game lobby if a reserved player (or admin) doesn't join it for this many minutes +### games which are set to automatically start when enough players join are exempt from this limit (e.g. autohosted games) + +bot_lobbytimelimit = 10 + +### the game latency +### this can always be changed for a particular game with the !latency command (which enforces a minimum of 20 and a maximum of 500) + +bot_latency = 100 + +### the maximum number of packets a player is allowed to get out of sync by before starting the lag screen +### before version 8.0 GHost++ did not have a lag screen which is the same as setting this to a very high number +### this can always be changed for a particular game with the !synclimit command (which enforces a minimum of 10 and a maximum of 10000) + +bot_synclimit = 50 + +### whether votekicks are allowed or not + +bot_votekickallowed = 1 + +### the percentage of players required to vote yes for a votekick to pass +### the player starting the votekick is assumed to have voted yes and the player the votekick is started against is assumed to have voted no +### the formula for calculating the number of votes needed is votes_needed = ceil( ( num_players - 1 ) * bot_votekickpercentage / 100 ) +### this means it will round UP the number of votes required +### if you set it to 100 it will require 2/3, 3/4, 4/5, 5/6, 6/7, 7/8, 8/9, 9/10, 10/11, and 11/12 votes to pass +### if you set it to 90 it will require 2/3, 3/4, 4/5, 5/6, 6/7, 7/8, 8/9, 9/10, 9/11, and 10/12 votes to pass +### if you set it to 80 it will require 2/3, 3/4, 4/5, 4/6, 5/7, 6/8, 7/9, 8/10, 8/11, and 9/12 votes to pass +### if you set it to 70 it will require 2/3, 3/4, 3/5, 4/6, 5/7, 5/8, 6/9, 7/10, 7/11, and 8/12 votes to pass +### if you set it to 60 it will require 2/3, 2/4, 3/5, 3/6, 4/7, 5/8, 5/9, 6/10, 6/11, and 7/12 votes to pass + +bot_votekickpercentage = 100 + +### the default map config (the ".cfg" will be added automatically if you leave it out) + +bot_defaultmap = wormwar + +### the MOTD file +### the first 8 lines of this file will be displayed when a player joins the game +### if this file doesn't exist a default MOTD will be used + +bot_motdfile = /etc/ghost++/motd.txt + +### the gameloaded file +### the first 8 lines of this file will be displayed when the game finished loading (after the player loading times are displayed) + +bot_gameloadedfile = /etc/ghost++/gameloaded.txt + +### the gameover file +### the first 8 lines of this file will be displayed when the game is over +### this only works when using a stats class - note: at the time of this writing the only stats class is for DotA maps + +bot_gameoverfile = /etc/ghost++/gameover.txt + +### whether to send "local admin messages" or not +### these messages are battle.net chat messages, whispers, and emotes which the bot receives and passes on to the "local admin" +### the local admin is the game owner if they are playing from a LAN or the same computer as the bot +### this is useful when you are using the admin game to play with one set of CD keys and you want messages sent to the bot to be relayed to you +### you can enable or disable this for a particular game with the !messages command + +bot_localadminmessages = 1 + +### the "TCP no delay" flag +### this controls whether or not your operating system should use the "no delay" algorithm on game sockets +### the algorithm is designed to reduce latency by sending data in small packets as soon as possible rather than waiting to send a single larger packet +### enabling this algorithm requires additional bandwidth because it is a less efficient way of sending data +### however, it may reduce game latencies in some cases + +tcp_nodelay = 0 + +### the matchmaking method +### this controls how the bot matches players when they join the game when using !autohostmm +### set it to 0 to disable matchmaking (first come first served, even if their scores are very different) +### set it to 1 to use the "furthest score" method (the player with the furthest score from the average is kicked to make room for another player) +### set it to 2 to use the "lowest score" method (the player with the lowest score is kicked to make room for another player) + +bot_matchmakingmethod = 1 + +### the mapgametype overwrite (advance) +### This controls the mapgametype overwrite. Use with caution as this can result in an ipban from battle.net services or make users unavailable to join your bot with an invalid number +### Example numbers can be found at (http://www.codelain.com/forum/index.php?topic=11373.msg135301#msg135301) +### set it to 0 to disable mapgametype overwrite + +bot_mapgametype = 0 + +############################ +# ADMIN GAME CONFIGURATION # +############################ + +### whether to create the admin game or not (see readme.txt for more information) + +admingame_create = 0 + +### the port GHost++ will host the admin game on (this must be different from your bot_hostport) + +admingame_port = 6113 + +### the admin game password + +admingame_password = + +### the default map config to use in the admin game +### if this value is blank the bot will use a hardcoded map instead +### it's recommended that you use the hardcoded map instead of specifying a different one +### this value exists because the hardcoded map is specific to Warcraft 3 versions and you may wish to use a previous or newer version +### the ".cfg" will be added automatically if you leave it out + +admingame_map = + +##################### +# LAN CONFIGURATION # +##################### + +### the Warcraft 3 version to use when broadcasting LAN games + +lan_war3version = 26 + +### the UDP broadcast target +### if this value is blank the bot will try to broadcast LAN games on the default interface which is chosen by your operating system +### sometimes your operating system will choose the wrong interface when more than one exists +### therefore you can use this value to force the bot to use a specific interface +### for example you may set it to "192.168.1.255" to broadcast LAN games to the 192.168.1.x subnet + +udp_broadcasttarget = + +### the UDP "don't route" flag + +udp_dontroute = 0 + +### the Ghost++ Game Broadcasters incoming port leave unset for default, only works with ggb useflag enabled + +# bot_broadcasters_port = 6969 + +########################## +# AUTOHOST CONFIGURATION # +########################## + +### this section of the config file is for enabling autohost when the bot starts up without having to issue a command +### you can activate the autohost feature without changing anything here by using the !autohost command + +autohost_maxgames = 0 +autohost_startplayers = 0 +autohost_gamename = +autohost_owner = + +########################## +# DATABASE CONFIGURATION # +########################## + +### database type +### use "sqlite3" for a local SQLite database +### use "mysql" for any MySQL database + +db_type = sqlite3 + +### sqlite3 database configuration +### this is only used if your database type is SQLite + +db_sqlite3_file = /var/lib/ghost++/ghost.dbs + +### mysql database configuration +### this is only used if your database type is MySQL + +db_mysql_server = localhost +db_mysql_database = ghost +db_mysql_user = YOUR_USERNAME +db_mysql_password = YOUR_PASSWORD +db_mysql_port = 0 + +### the bot ID is included each time the bot adds data to the MySQL database +### it is used to identify where each row of data came from when you configure multiple bots to connect to the same MySQL database +### GHost++ does not use the bot ID number itself, it's just to help you keep track of the data in your database + +db_mysql_botid = 1 + +############################ +# BATTLE.NET CONFIGURATION # +############################ + +### which battle.net server to connect to +### 1.) useast.battle.net +### 2.) uswest.battle.net +### 3.) asia.battle.net +### 4.) europe.battle.net +### note that each banned player is tied to the realm it was created on and the realm is case sensitive +### so if you change your realm from useast.battle.net to USEAST.BATTLE.NET it'll still connect but anyone previously banned will not be counted as banned until you change it back + +bnet_server = useast.battle.net + +### the server alias +### this name will be used to identify the battle.net server in the GHost++ console +### if you leave it blank it will use a short name such as "USEast" for official battle.net servers or it will use the actual server address + +bnet_serveralias = USEast + +### your Warcraft III: Reign of Chaos CD key +### you cannot use the same CD key here that you yourself use to login to battle.net if you plan to login at the same time as your bot + +bnet_cdkeyroc = FFFFFFFFFFFFFFFFFFFFFFFFFF + +### your Warcraft III: The Frozen Throne CD key +### you cannot use the same CD key here that you yourself use to login to battle.net if you plan to login at the same time as your bot + +bnet_cdkeytft = FFFFFFFFFFFFFFFFFFFFFFFFFF + +### the locale specifies the area of the world you are from +### battle.net uses this to group players together, showing them games hosted by players and bots mostly from their own area +### it's important to set this to the correct value to increase the effectiveness of the game refresher +### if you are using Windows you can set this to "system" to use the locale of your system +### otherwise you can use the list at the following URL to get the correct value for your area: +### http://msdn.microsoft.com/en-us/library/0h88fahh%28VS.85%29.aspx +### put the "decimal value" here, e.g. 1033 is the default for "English - United States" +### note: you cannot use a value of "system" on Linux, doing so will use a default value of 1033 instead + +bnet_locale = 1033 + +### your battle.net username +### you cannot use the same username here that you yourself use to login to battle.net if you plan to login at the same time as your bot + +bnet_username = + +### your battle.net password + +bnet_password = + +### the first channel to join upon entering battle.net + +bnet_firstchannel = The Void + +### the root admins on this battle.net server only +### seperate each name with a space, e.g. bnet_rootadmin = Varlock Kilranin Instinct121 + +bnet_rootadmin = + +### command trigger for this battle.net server only + +bnet_commandtrigger = ! + +### whether to automatically add your friends list to each game's reserved list + +bnet_holdfriends = 1 + +### whether to automatically add your clan members list to each game's reserved list + +bnet_holdclan = 1 + +### whether to allow anonymous users (non admins) to use public commands such as !stats and !statsdota on this battle.net connection +### if you are having trouble with spammers causing your bot to flood the server you should disable this + +bnet_publiccommands = 1 + +### BNLS server information for Warden handling (see readme.txt for more information) +### you will need to use a valid BNLS server here if you are connecting to an official battle.net realm or you will be disconnected every two minutes +### NB: not true anymore. + +bnet_bnlsserver = localhost +bnet_bnlsport = 9367 +bnet_bnlswardencookie = 1 + +### you will need to edit this section of the config file if you're connecting to a PVPGN server +### your PVPGN server operator will tell you what to put here + +bnet_custom_war3version = 24 +bnet_custom_exeversion = +bnet_custom_exeversionhash = +bnet_custom_passwordhashtype = +bnet_custom_pvpgnrealmname = PvPGN Realm + +### +### example configuration for connecting to a second official battle.net server +### + +# bnet2_server = uswest.battle.net +# bnet2_serveralias = USWest +# bnet2_cdkeyroc = FFFFFFFFFFFFFFFFFFFFFFFFFF +# bnet2_cdkeytft = FFFFFFFFFFFFFFFFFFFFFFFFFF +# bnet2_locale = system +# bnet2_username = +# bnet2_password = +# bnet2_firstchannel = The Void +# bnet2_rootadmin = +# bnet2_commandtrigger = ! +# bnet2_holdfriends = 1 +# bnet2_holdclan = 1 +# bnet2_publiccommands = 1 +# bnet2_bnlsserver = localhost +# bnet2_bnlsport = 9367 +# bnet2_bnlswardencookie = 2 + +### +### example configuration for connecting to a third PVPGN battle.net server +### + +# bnet3_server = server.eurobattle.net +# bnet3_serveralias = EuroBattle +# bnet3_cdkeyroc = FFFFFFFFFFFFFFFFFFFFFFFFFF +# bnet3_cdkeytft = FFFFFFFFFFFFFFFFFFFFFFFFFF +# bnet3_locale = system +# bnet3_username = +# bnet3_password = +# bnet3_firstchannel = The Void +# bnet3_rootadmin = +# bnet3_commandtrigger = ! +# bnet3_holdfriends = 1 +# bnet3_holdclan = 1 +# bnet3_publiccommands = 1 +# bnet3_custom_war3version = 24 +# bnet3_custom_exeversion = 184 0 22 1 +# bnet3_custom_exeversionhash = 219 152 153 144 +# bnet3_custom_passwordhashtype = pvpgn +# bnet3_custom_pvpgnrealmname = PvPGN Realm \ No newline at end of file diff --git a/games-server/ghost++/ghost++-17.1_p20120618.ebuild b/games-server/ghost++/ghost++-17.1_p20120618.ebuild new file mode 100644 index 0000000..2f8e5f4 --- /dev/null +++ b/games-server/ghost++/ghost++-17.1_p20120618.ebuild @@ -0,0 +1,58 @@ +# Copyright 1999-2012 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 +# $Header: $Id$ + +EAPI="4" + +inherit cmake-utils + +DESCRIPTION="Warcraft 3 Game Host" +HOMEPAGE="http://www.codelain.com" +SRC_URI="http://people.znc.in/~dessa/ghost/${P}.tar.xz" + +RESTRICT="mirror" + +LICENSE="as-is" +SLOT="0" +KEYWORDS="~amd64 ~x86" +IUSE="ggb mysql" + +DEPEND="dev-libs/boost + dev-games/bncsutil + dev-games/StormLib + dev-db/sqlite + mysql? ( virtual/mysql )" +RDEPEND="${DEPEND}" + +#pkg_setup() { +# enewgroup ghost +# enewuser ghost -1 -1 /var/lib/ghost ghost +#} + +src_prepare() { + cd "${S}" + epatch "${FILESDIR}/${PN}-stormlib-include.patch" + epatch "${FILESDIR}/${PN}-GetLastError.patch" + epatch "${FILESDIR}/${PN}-sqlite-include-guard.patch" + epatch "${FILESDIR}/${PN}-configpath.patch" + use ggb && epatch "${FILESDIR}/${PN}-ggb.patch" + cp "${FILESDIR}/CMakeLists.txt" "${S}" + cp -r "${FILESDIR}/cmake" "${S}" + cp "${FILESDIR}/ghost++.cfg" "${S}" +} + +src_configure() { + local mycmakeargs=" + -DCONFIGPATH="${EROOT}etc/ghost++/" + $(cmake-utils_use_with mysql MYSQL)" + + cmake-utils_src_configure +} + +src_install() { + cmake-utils_src_install + +# keepdir /var/lib/ghost++ /var/run/ghost++ /var/log/ghost++ +# fowners -R ghost /var/lib/ghost++ /var/run/ghost++ /var/log/ghost++ /etc/ghost++ +# fperms 750 /var/lib/ghost++ /var/run/ghost++ /var/log/ghost++ +}