├── debian ├── compat ├── source │ ├── format │ ├── lintian-overrides │ └── options ├── netmaumau-server-common.docs ├── netmaumau-server-common.dirs ├── netmaumau-server.dirs ├── netmaumau-client.install ├── netmaumau-server.install ├── netmaumau-server.manpages ├── libnetmaumauclient5.install ├── libnetmaumaucommon6.install ├── netmaumau-dev.docs ├── libnetmaumauclient5.shlibs ├── libnetmaumaucommon6.shlibs ├── netmaumau-client.lintian-overrides ├── netmaumau.lintian-overrides ├── netmaumau-dev.lintian-overrides ├── netmaumau-server-common.bash-completion ├── netmaumau-server-common.lintian-overrides ├── netmaumau-dev.links ├── watch ├── netmaumau-server.lintian-overrides ├── libnetmaumauclient5.lintian-overrides ├── netmaumau-dev.install ├── libnetmaumaucommon6.lintian-overrides ├── netmaumau-server-common.install ├── netmaumau-dev.doc-base ├── copyright ├── netmaumau-server.prerm ├── netmaumau-server-common.prerm ├── netmaumau-server.postinst └── netmaumau-server-common.postinst ├── src ├── ai │ ├── maxsuitaction.aai │ ├── aceroundaction.aai │ ├── bestjackaction.aai │ ├── jacksuitaction.aai │ ├── playjackaction.aai │ ├── powerjackaction.aai │ ├── aceroundcondition.cai │ ├── bestsuitcondition.cai │ ├── havejackcondition.cai │ ├── jackonlycondition.cai │ ├── jackplusoneaction.aai │ ├── powerjackcondition.cai │ ├── randomjackaction.aai │ ├── servesevenaction.aai │ ├── skipplayeraction.aai │ ├── checksevencondition.cai │ ├── jackplusonecondition.cai │ ├── randomjackcondition.cai │ ├── skipplayercondition.cai │ ├── suspendaction.aai │ ├── powerplayaction.aai │ ├── nextaction.cpp │ ├── suspendaction.cpp │ ├── powerjackaction.cpp │ ├── randomjackcondition.cpp │ ├── decisionbase.cpp │ ├── playjackaction.cpp │ ├── powerjackcondition.cpp │ ├── bestsuitcondition.cpp │ ├── decisionbase.h │ ├── binarycondition.h │ ├── staticcondition.h │ ├── nextaction.h │ ├── powersuitcondition.h │ ├── checksevencondition.cpp │ ├── aceroundcondition.cpp │ ├── jackplusoneaction.cpp │ ├── powersuitaction.h │ ├── skipplayercondition.cpp │ ├── iaction.h │ ├── jackplusonecondition.cpp │ ├── icondition.h │ ├── powersuitcondition.cpp │ ├── abstractcondition.h │ ├── havejackcondition.cpp │ ├── havelessthancondition.h │ ├── abstractcondition.cpp │ ├── bestjackaction.cpp │ ├── servesevenaction.cpp │ └── aceroundaction.cpp ├── images │ ├── JC.PNG │ ├── JD.PNG │ ├── JH.PNG │ ├── JS.PNG │ ├── KC.PNG │ ├── KD.PNG │ ├── KH.PNG │ ├── KS.PNG │ ├── QC.PNG │ ├── QD.PNG │ ├── QH.PNG │ ├── QS.PNG │ └── Makefile.am ├── test │ ├── testimg.png │ ├── stresstest.sh.in │ └── Makefile.am ├── server │ ├── netmaumau.rc.in │ ├── ttynamecheckdir.h │ ├── gamecontext.cpp │ └── gamecontext.h ├── lua │ ├── Makefile.am │ ├── luafatalexception.cpp │ ├── luaexception.cpp │ ├── luaexception.h │ └── luafatalexception.h ├── sqlite │ └── Makefile.am ├── include │ ├── Makefile.am │ ├── inullable.h │ ├── defaultplayerimage.h │ ├── iplayerpiclistener.h │ ├── shutdownexception.h │ ├── timeoutexception.h │ ├── playerlistexception.h │ ├── gamerunningexception.h │ ├── capabilitiesexception.h │ ├── lostconnectionexception.h │ ├── protocolerrorexception.h │ ├── nonetmaumauserverexception.h │ ├── connectionrejectedexception.h │ ├── scoresexception.h │ └── remoteplayerexception.h ├── Makefile.am ├── client │ ├── scoresexception.cpp │ ├── timeoutexception.cpp │ ├── shutdownexception.cpp │ ├── playerlistexception.cpp │ ├── gamerunningexception.cpp │ ├── capabilitiesexception.cpp │ ├── protocolerrorexception.cpp │ ├── lostconnectionexception.cpp │ ├── nonetmaumauserverexception.cpp │ ├── connectionrejectedexception.cpp │ ├── interceptederrorexception.cpp │ ├── Makefile.am │ ├── remoteplayerexception.cpp │ ├── interceptederrorexception.h │ └── clientconnectionimpl.h ├── common │ ├── pngcheck.cpp │ ├── zlibexception.cpp │ ├── defaultplayerimage.cpp │ ├── errorstring.h │ ├── pathtools.h │ ├── pngcheck.h │ ├── icardfactory.h │ ├── condition.cpp │ ├── tcpopt_cork.h │ ├── tcpopt_nodelay.h │ ├── tcpopt_nodelay.cpp │ ├── iobserver.h │ ├── zlibexception.h │ ├── tcpopt_base.h │ ├── socketexception.cpp │ ├── mutexlocker.cpp │ ├── ci_string.h │ ├── zstreambuf.h │ ├── tcpopt_cork.cpp │ ├── condition.h │ ├── select.h │ ├── ci_string.cpp │ ├── pathtools.cpp │ └── errorstring.cpp └── engine │ ├── nullcardcountobserver.cpp │ ├── hardplayer.cpp │ ├── serverplayerexception.cpp │ ├── icardcountobserver.h │ ├── Makefile.am │ ├── italonchange.h │ ├── nullaceroundlistener.cpp │ ├── hardplayer.h │ ├── iaceroundlistener.h │ ├── nullcardcountobserver.h │ ├── serverplayerexception.h │ ├── nullaceroundlistener.h │ ├── nullconnection.cpp │ ├── nullconnection.h │ ├── easyplayer.h │ ├── stdcardfactory.cpp │ └── stdcardfactory.h ├── netmaumau.ico ├── DIE OFFIZIELLEN MAUMAU SPIELREGELN.pdf ├── m4 ├── m4_nmm_clientversion.m4 ├── m4_ax_check_clang.m4 ├── m4_ax_check_base64.m4 └── m4_ax_cxx_gcc_abi_demangle.m4 ├── THANKS ├── netmaumau.xinetd.in ├── netmaumau.pc.in ├── doc └── Makefile.am ├── start-server.sh.in ├── nmm-server.bc.in └── netmaumau.h2m.in /debian/compat: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (native) 2 | -------------------------------------------------------------------------------- /debian/netmaumau-server-common.docs: -------------------------------------------------------------------------------- 1 | THANKS 2 | -------------------------------------------------------------------------------- /src/ai/maxsuitaction.aai: -------------------------------------------------------------------------------- 1 | NAME(MaxSuitAction) 2 | -------------------------------------------------------------------------------- /debian/netmaumau-server-common.dirs: -------------------------------------------------------------------------------- 1 | /etc/xinetd.d 2 | -------------------------------------------------------------------------------- /debian/netmaumau-server.dirs: -------------------------------------------------------------------------------- 1 | /var/games/netmaumau 2 | -------------------------------------------------------------------------------- /src/ai/aceroundaction.aai: -------------------------------------------------------------------------------- 1 | NAME(AceRoundAction) 2 | -------------------------------------------------------------------------------- /src/ai/bestjackaction.aai: -------------------------------------------------------------------------------- 1 | NAME(BestJackAction) 2 | -------------------------------------------------------------------------------- /src/ai/jacksuitaction.aai: -------------------------------------------------------------------------------- 1 | NAME(JackSuitAction) 2 | -------------------------------------------------------------------------------- /src/ai/playjackaction.aai: -------------------------------------------------------------------------------- 1 | NAME(PlayJackAction) 2 | -------------------------------------------------------------------------------- /src/ai/powerjackaction.aai: -------------------------------------------------------------------------------- 1 | NAME(PowerJackAction) 2 | -------------------------------------------------------------------------------- /debian/netmaumau-client.install: -------------------------------------------------------------------------------- 1 | /usr/games/nmm-client 2 | -------------------------------------------------------------------------------- /debian/netmaumau-server.install: -------------------------------------------------------------------------------- 1 | /usr/games/nmm-server 2 | -------------------------------------------------------------------------------- /src/ai/aceroundcondition.cai: -------------------------------------------------------------------------------- 1 | NAME(AceRoundCondition) 2 | -------------------------------------------------------------------------------- /src/ai/bestsuitcondition.cai: -------------------------------------------------------------------------------- 1 | NAME(BestSuitCondition) 2 | -------------------------------------------------------------------------------- /src/ai/havejackcondition.cai: -------------------------------------------------------------------------------- 1 | NAME(HaveJackCondition) 2 | -------------------------------------------------------------------------------- /src/ai/jackonlycondition.cai: -------------------------------------------------------------------------------- 1 | NAME(JackOnlyCondition) 2 | -------------------------------------------------------------------------------- /src/ai/jackplusoneaction.aai: -------------------------------------------------------------------------------- 1 | NAME(JackPlusOneAction) 2 | -------------------------------------------------------------------------------- /src/ai/powerjackcondition.cai: -------------------------------------------------------------------------------- 1 | NAME(PowerJackCondition) 2 | -------------------------------------------------------------------------------- /src/ai/randomjackaction.aai: -------------------------------------------------------------------------------- 1 | NAME(RandomJackAction) 2 | -------------------------------------------------------------------------------- /src/ai/servesevenaction.aai: -------------------------------------------------------------------------------- 1 | NAME(ServeSevenAction) 2 | -------------------------------------------------------------------------------- /src/ai/skipplayeraction.aai: -------------------------------------------------------------------------------- 1 | NAME(SkipPlayerAction) 2 | -------------------------------------------------------------------------------- /src/ai/checksevencondition.cai: -------------------------------------------------------------------------------- 1 | NAME(CheckSevenCondition) 2 | -------------------------------------------------------------------------------- /src/ai/jackplusonecondition.cai: -------------------------------------------------------------------------------- 1 | NAME(JackPlusOneCondition) 2 | -------------------------------------------------------------------------------- /src/ai/randomjackcondition.cai: -------------------------------------------------------------------------------- 1 | NAME(RandomJackCondition) 2 | -------------------------------------------------------------------------------- /src/ai/skipplayercondition.cai: -------------------------------------------------------------------------------- 1 | NAME(SkipPlayerCondition) 2 | -------------------------------------------------------------------------------- /debian/netmaumau-server.manpages: -------------------------------------------------------------------------------- 1 | debian/tmp/usr/share/man/man1/* 2 | -------------------------------------------------------------------------------- /src/ai/suspendaction.aai: -------------------------------------------------------------------------------- 1 | NAME(SuspendAction) 2 | CONSTPERFORM() 3 | -------------------------------------------------------------------------------- /debian/libnetmaumauclient5.install: -------------------------------------------------------------------------------- 1 | /usr/lib/libnetmaumauclient.so.* 2 | -------------------------------------------------------------------------------- /debian/libnetmaumaucommon6.install: -------------------------------------------------------------------------------- 1 | /usr/lib/libnetmaumaucommon.so.* 2 | -------------------------------------------------------------------------------- /debian/netmaumau-dev.docs: -------------------------------------------------------------------------------- 1 | debian/tmp/usr/share/doc/netmaumau/client-api-doc 2 | -------------------------------------------------------------------------------- /netmaumau.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/velnias75/NetMauMau/HEAD/netmaumau.ico -------------------------------------------------------------------------------- /debian/libnetmaumauclient5.shlibs: -------------------------------------------------------------------------------- 1 | libnetmaumauclient 5 libnetmaumauclient5 (>= 0.23.7~) 2 | -------------------------------------------------------------------------------- /debian/libnetmaumaucommon6.shlibs: -------------------------------------------------------------------------------- 1 | libnetmaumaucommon 6 libnetmaumaucommon6 (>= 0.23.7~) 2 | -------------------------------------------------------------------------------- /debian/netmaumau-client.lintian-overrides: -------------------------------------------------------------------------------- 1 | netmaumau-client binary: binary-without-manpage 2 | -------------------------------------------------------------------------------- /debian/netmaumau.lintian-overrides: -------------------------------------------------------------------------------- 1 | netmaumau source: debian-watch-file-in-native-package 2 | -------------------------------------------------------------------------------- /debian/source/lintian-overrides: -------------------------------------------------------------------------------- 1 | netmaumau source: debian-watch-file-in-native-package 2 | -------------------------------------------------------------------------------- /src/images/JC.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/velnias75/NetMauMau/HEAD/src/images/JC.PNG -------------------------------------------------------------------------------- /src/images/JD.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/velnias75/NetMauMau/HEAD/src/images/JD.PNG -------------------------------------------------------------------------------- /src/images/JH.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/velnias75/NetMauMau/HEAD/src/images/JH.PNG -------------------------------------------------------------------------------- /src/images/JS.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/velnias75/NetMauMau/HEAD/src/images/JS.PNG -------------------------------------------------------------------------------- /src/images/KC.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/velnias75/NetMauMau/HEAD/src/images/KC.PNG -------------------------------------------------------------------------------- /src/images/KD.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/velnias75/NetMauMau/HEAD/src/images/KD.PNG -------------------------------------------------------------------------------- /src/images/KH.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/velnias75/NetMauMau/HEAD/src/images/KH.PNG -------------------------------------------------------------------------------- /src/images/KS.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/velnias75/NetMauMau/HEAD/src/images/KS.PNG -------------------------------------------------------------------------------- /src/images/QC.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/velnias75/NetMauMau/HEAD/src/images/QC.PNG -------------------------------------------------------------------------------- /src/images/QD.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/velnias75/NetMauMau/HEAD/src/images/QD.PNG -------------------------------------------------------------------------------- /src/images/QH.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/velnias75/NetMauMau/HEAD/src/images/QH.PNG -------------------------------------------------------------------------------- /src/images/QS.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/velnias75/NetMauMau/HEAD/src/images/QS.PNG -------------------------------------------------------------------------------- /src/test/testimg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/velnias75/NetMauMau/HEAD/src/test/testimg.png -------------------------------------------------------------------------------- /debian/netmaumau-dev.lintian-overrides: -------------------------------------------------------------------------------- 1 | netmaumau-dev: extended-description-is-probably-too-short 2 | -------------------------------------------------------------------------------- /debian/netmaumau-server-common.bash-completion: -------------------------------------------------------------------------------- 1 | /usr/share/bash-completion/completions/nmm-server 2 | -------------------------------------------------------------------------------- /src/ai/powerplayaction.aai: -------------------------------------------------------------------------------- 1 | NAME(PowerPlayAction) 2 | PARAM(bool set = false) 3 | PRIVVAR(bool m_set) 4 | -------------------------------------------------------------------------------- /src/server/netmaumau.rc.in: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/velnias75/NetMauMau/HEAD/src/server/netmaumau.rc.in -------------------------------------------------------------------------------- /debian/netmaumau-server-common.lintian-overrides: -------------------------------------------------------------------------------- 1 | netmaumau-server-common: description-contains-duplicated-word 2 | -------------------------------------------------------------------------------- /debian/netmaumau-dev.links: -------------------------------------------------------------------------------- 1 | /usr/share/javascript/jquery/jquery.js /usr/share/doc/netmaumau-dev/client-api-doc/jquery.js 2 | -------------------------------------------------------------------------------- /DIE OFFIZIELLEN MAUMAU SPIELREGELN.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/velnias75/NetMauMau/HEAD/DIE OFFIZIELLEN MAUMAU SPIELREGELN.pdf -------------------------------------------------------------------------------- /debian/watch: -------------------------------------------------------------------------------- 1 | version=3 2 | https://github.com/velnias75/NetMauMau/releases \ 3 | (?:.*/)?archive/V([\d\.]+)\.tar\.(?:gz|bz2|xz) 4 | -------------------------------------------------------------------------------- /debian/netmaumau-server.lintian-overrides: -------------------------------------------------------------------------------- 1 | netmaumau-server: killall-is-dangerous 2 | netmaumau-server: description-contains-duplicated-word 3 | -------------------------------------------------------------------------------- /m4/m4_nmm_clientversion.m4: -------------------------------------------------------------------------------- 1 | AC_DEFUN([NMM_CLIENTVERSION], [ 2 | CLIENTVERSION=`echo $((($1<<16)|$2))` 3 | AC_SUBST([CLIENTVERSION]) 4 | ]) 5 | 6 | -------------------------------------------------------------------------------- /debian/libnetmaumauclient5.lintian-overrides: -------------------------------------------------------------------------------- 1 | libnetmaumauclient5: extended-description-is-probably-too-short 2 | libnetmaumauclient5: no-symbols-control-file 3 | -------------------------------------------------------------------------------- /debian/netmaumau-dev.install: -------------------------------------------------------------------------------- 1 | /usr/include/netmaumau 2 | /usr/lib/libnetmaumauclient.so 3 | /usr/lib/libnetmaumaucommon.so 4 | /usr/lib/pkgconfig/netmaumau.pc 5 | -------------------------------------------------------------------------------- /THANKS: -------------------------------------------------------------------------------- 1 | Thanks are going to: 2 | 3 | Catherine Maria Touhami 4 | Christoph Korn 5 | Julian Ospald 6 | -------------------------------------------------------------------------------- /debian/libnetmaumaucommon6.lintian-overrides: -------------------------------------------------------------------------------- 1 | libnetmaumaucommon6: extended-description-is-probably-too-short 2 | libnetmaumaucommon6: no-symbols-control-file 3 | 4 | -------------------------------------------------------------------------------- /debian/netmaumau-server-common.install: -------------------------------------------------------------------------------- 1 | /etc/xinetd.d/netmaumau 2 | /usr/share/bash-completion/completions/nmm-server 3 | /usr/share/netmaumau/*.PNG 4 | /usr/share/netmaumau/*.ico 5 | /usr/share/netmaumau/*.lua 6 | -------------------------------------------------------------------------------- /netmaumau.xinetd.in: -------------------------------------------------------------------------------- 1 | service netmaumau 2 | { 3 | disable = no 4 | per_source = 1 5 | port = 8899 6 | socket_type = stream 7 | protocol = tcp 8 | user = root 9 | server = @bindir@/nmm-server 10 | server_args = --inetd --group=tty @ADDWEBSERVER@ 11 | type = UNLISTED 12 | wait = yes 13 | instances = 1 14 | } 15 | -------------------------------------------------------------------------------- /debian/source/options: -------------------------------------------------------------------------------- 1 | compression = "xz" 2 | compression-level = 9 3 | tar-ignore = .svn 4 | tar-ignore = .git 5 | tar-ignore = .gitignore 6 | tar-ignore = V*.xml 7 | tar-ignore = "DIE\ OFFIZIELLEN\ MAUMAU\ SPIELREGELN.pdf" 8 | tar-ignore = *.patch 9 | tar-ignore = config.log 10 | tar-ignore = nmm-ai.flw 11 | tar-ignore = debug 12 | -------------------------------------------------------------------------------- /m4/m4_ax_check_clang.m4: -------------------------------------------------------------------------------- 1 | AC_DEFUN([AX_CHECK_CLANG], [ 2 | AC_LANG_PUSH([C++]) 3 | AC_MSG_CHECKING([if compiling with clang]) 4 | AC_COMPILE_IFELSE( 5 | [ AC_LANG_PROGRAM([], [[ 6 | #ifndef __clang__ 7 | not clang 8 | #endif 9 | ]])], [CLANG=yes], [CLANG=no]) 10 | AC_LANG_POP([C++]) 11 | AC_MSG_RESULT([$CLANG])]) 12 | -------------------------------------------------------------------------------- /src/images/Makefile.am: -------------------------------------------------------------------------------- 1 | dist_pkgdata_DATA = JC.PNG JD.PNG JH.PNG JS.PNG KC.PNG KD.PNG KH.PNG KS.PNG QC.PNG QD.PNG QH.PNG \ 2 | QS.PNG 3 | 4 | EXTRA_DIST = create_ai_icon.sh 5 | 6 | install-data-hook: 7 | $(LN_S) QS.PNG "$(DESTDIR)$(pkgdatadir)"/ai_img1.png 8 | $(LN_S) KC.PNG "$(DESTDIR)$(pkgdatadir)"/ai_img2.png 9 | $(LN_S) QC.PNG "$(DESTDIR)$(pkgdatadir)"/ai_img3.png 10 | -------------------------------------------------------------------------------- /debian/netmaumau-dev.doc-base: -------------------------------------------------------------------------------- 1 | Document: netmaumau-dev 2 | Title: Documentation for developers of clients for NetMauMau 3 | Author: Heiko Schäfer 4 | Section: Games/Card 5 | Abstract: This documentation covers the development of clients for NetMauMau 6 | 7 | Format: HTML 8 | Index: /usr/share/doc/netmaumau-dev/client-api-doc/index.html 9 | Files: /usr/share/doc/netmaumau-dev/client-api-doc/* 10 | -------------------------------------------------------------------------------- /netmaumau.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | package_name=@PACKAGE_NAME@ 4 | version=@PACKAGE_VERSION@ 5 | 6 | libdir=@libdir@ 7 | lib_name=netmaumauclient 8 | 9 | includedir=@pkgincludedir@ 10 | 11 | Name: libnetmaumauclient 12 | Description: client library to communicate with the NetMauMau server 13 | URL: https://github.com/velnias75/NetMauMau/ 14 | Version: ${version} 15 | Libs: -L${libdir} -lnetmaumaucommon -lnetmaumauclient 16 | Cflags: -I${includedir} -DCLIENTVERSION=@CLIENTVERSION@ 17 | -------------------------------------------------------------------------------- /m4/m4_ax_check_base64.m4: -------------------------------------------------------------------------------- 1 | AC_DEFUN([AX_CHECK_BASE64], 2 | [ AC_CHECK_PROGS([BASE64], [base64]) 3 | if test -z "$ac_cv_prog_BASE64"; then 4 | AC_MSG_ERROR([base64 not found, please install]) 5 | fi 6 | AC_MSG_CHECKING([if base64 supports -w0]) 7 | B64_RES=`echo x 2>/dev/null | base64 -w0 2>/dev/null` 8 | if test "$B64_RES" == "eAo="; then 9 | AC_MSG_RESULT([yes]) 10 | AC_SUBST([B64_TR], [cat]) 11 | BASE64="$BASE64 -w0"; 12 | else 13 | AC_MSG_RESULT([no]) 14 | B64_TR="tr -d '\n' | tr -d '\r'"; 15 | AC_SUBST([B64_TR]) 16 | fi 17 | ]) 18 | -------------------------------------------------------------------------------- /src/lua/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libluaruleset.la 2 | 3 | noinst_HEADERS = luaexception.h luafatalexception.h luaruleset.h luastate.h 4 | 5 | pkgdata_DATA = stdrules.lua 6 | 7 | EXTRA_DIST = $(pkgdata_DATA) 8 | 9 | if GSL 10 | GSL=-DHAVE_GSL 11 | else 12 | GSL= 13 | endif 14 | 15 | libluaruleset_la_CPPFLAGS = $(GSL) 16 | libluaruleset_la_CXXFLAGS = -I$(top_srcdir)/src/include -I$(top_srcdir)/src/common \ 17 | -I$(top_srcdir)/src/engine $(LIBLUA_CFLAGS) 18 | libluaruleset_la_SOURCES = luaexception.cpp luafatalexception.cpp luaruleset.cpp luastate.cpp 19 | libluaruleset_la_LIBADD = $(LIBLUA_LIBS) 20 | -------------------------------------------------------------------------------- /src/sqlite/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libsqlite.la 2 | 3 | noinst_HEADERS = sqlite.h sqliteimpl.h 4 | 5 | libsqlite_la_CPPFLAGS = -I$(top_srcdir)/src/include -I$(top_srcdir)/src/common \ 6 | -I$(top_srcdir)/src/engine -DDBDIR=\"$(localstatedir)/$(PACKAGE)\" \ 7 | -DBUILDDIR=\"$(abs_top_builddir)\" 8 | libsqlite_la_CXXFLAGS = $(LIBSQLITE_CFLAGS) $(NO_EXCEPTIONS) 9 | libsqlite_la_SOURCES = sqlite.cpp sqliteimpl.cpp 10 | libsqlite_la_LIBADD = $(LIBSQLITE_LIBS) 11 | 12 | install-data-local: 13 | $(INSTALL) -d -m 755 $(DESTDIR)/$(localstatedir)/$(PACKAGE) 14 | 15 | uninstall-local: 16 | rm -rf $(DESTDIR)/$(localstatedir)/$(PACKAGE) 17 | -------------------------------------------------------------------------------- /doc/Makefile.am: -------------------------------------------------------------------------------- 1 | EXTRA_DIST = DoxygenLayout.xml 2 | 3 | if GENDOX 4 | 5 | noinst_DATA = client-dox.stamp 6 | 7 | DISTCLEANFILES = doxygen* 8 | 9 | clean-local: 10 | -rm -rf html 11 | -rm -rf client.dox.warnings client-dox.stamp 12 | 13 | client-dox.stamp: client.dox 14 | $(DOXYGEN) $< 15 | touch client-dox.stamp 16 | 17 | install-data-local: 18 | $(INSTALL) -d -m 755 $(DESTDIR)/$(docdir)/client-api-doc 19 | $(INSTALL) -m 644 -D html/* $(DESTDIR)/$(docdir)/client-api-doc 20 | -rm -rf $(DESTDIR)/$(docdir)/client-api-doc/*.map 21 | -rm -rf $(DESTDIR)/$(docdir)/client-api-doc/*.md5 22 | 23 | uninstall-local: 24 | -rm -rf $(DESTDIR)/$(docdir)/client-api-doc 25 | 26 | endif 27 | -------------------------------------------------------------------------------- /src/include/Makefile.am: -------------------------------------------------------------------------------- 1 | NETMAUMAU_HDRS = abstractclient.h abstractconnection.h abstractsocket.h capabilitiesexception.h \ 2 | cardtools.h clientconnection.h connectionrejectedexception.h defaultplayerimage.h \ 3 | gamerunningexception.h ibase64.h icard.h iconnection.h inullable.h iplayerpiclistener.h \ 4 | linkercontrol.h lostconnectionexception.h nonetmaumauserverexception.h \ 5 | playerlistexception.h protocolerrorexception.h remoteplayerexception.h scoresexception.h \ 6 | shutdownexception.h socketexception.h timeoutexception.h tmp.h versionmismatchexception.h 7 | 8 | if ENABLE_CLIENT 9 | pkginclude_HEADERS = $(NETMAUMAU_HDRS) 10 | else 11 | noinst_HEADERS = $(NETMAUMAU_HDRS) 12 | endif 13 | 14 | if BRANDING 15 | 16 | noinst_DATA = ai-icon-deleted 17 | 18 | clean-local: 19 | -rm -f ai-icon-deleted 20 | 21 | ai-icon-deleted: $(AI_IMAGE) 22 | -@rm -f $(top_srcdir)/src/common/ai-icon.h 2> /dev/null 23 | -@rm -f $(top_builddir)/src/common/ai-icon.h 2> /dev/null 24 | -touch ai-icon-deleted 25 | endif 26 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = include images common sqlite lua ai engine server client test 2 | 3 | if ENABLE_DEHEADER 4 | deheader: 5 | @echo "Running deheader with DEHEADER_FLAGS=\"$(DEHEADER_FLAGS)\" …" ; 6 | @cd $(abs_top_srcdir)/src && \ 7 | deheader $(DEHEADER_FLAGS) -m "$(MAKE) CXXFLAGS='$(LIBLUA_CFLAGS) $(CXXFLAGS) $(CPPFLAGS) \ 8 | -DHAVE_GSL=1 -I$(abs_top_builddir)/src/ai -I$(abs_top_srcdir)/src/ai \ 9 | -I$(abs_top_srcdir)/src/client -I$(abs_top_srcdir)/src/common \ 10 | -I$(abs_top_srcdir)/src/engine -I$(abs_top_srcdir)/src/images \ 11 | -I$(abs_top_srcdir)/src/include -I$(abs_top_srcdir)/src/lua \ 12 | -I$(abs_top_srcdir)/src/server -I$(abs_top_srcdir)/src/sqlite \ 13 | -I$(abs_top_srcdir)/src/test -I$(abs_top_builddir) -DNMM_EXE_NAME=\\\".\\\" \ 14 | -DNMM_EXE_EXT=\\\".\\\" -DNMM_EXE_PATH=\\\".\\\" -DSYSCONFDIR=\\\".\\\" \ 15 | -DLUADIR=\\\".\\\" -DCLIENTVERSION=15 -DBUILDDIR=\\\".\\\" -DPKGDATADIR=\\\".\\\" \ 16 | -I$(abs_top_builddir)/src/common -DHAVE_CONFIG_H=1 \ 17 | -I$(abs_top_builddir)/src/test -Werror -Wfatal-errors'" 18 | endif 19 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Files: * 3 | Copyright: 2014 Heiko Schäfer 4 | License: GPL-3+ 5 | This program is free software; you can redistribute it 6 | and/or modify it under the terms of the GNU General Public 7 | License as published by the Free Software Foundation; either 8 | version 2 of the License, or (at your option) any later 9 | version. 10 | . 11 | This program is distributed in the hope that it will be 12 | useful, but WITHOUT ANY WARRANTY; without even the implied 13 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 14 | PURPOSE. See the GNU General Public License for more 15 | details. 16 | . 17 | You should have received a copy of the GNU General Public 18 | License along with this package; if not, write to the Free 19 | Software Foundation, Inc., 51 Franklin St, Fifth Floor, 20 | Boston, MA 02110-1301 USA 21 | . 22 | On Debian systems, the full text of the GNU General Public 23 | License version 2 can be found in the file 24 | `/usr/share/common-licenses/GPL-3'. 25 | -------------------------------------------------------------------------------- /debian/netmaumau-server.prerm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # prerm script for netmaumau-server 3 | # 4 | # see: dh_installdeb(1) 5 | 6 | set -e 7 | 8 | # summary of how this script can be called: 9 | # * `remove' 10 | # * `upgrade' 11 | # * `failed-upgrade' 12 | # * `remove' `in-favour' 13 | # * `deconfigure' `in-favour' 14 | # `removing' 15 | # 16 | # for details, see http://www.debian.org/doc/debian-policy/ or 17 | # the debian-policy package 18 | 19 | 20 | case "$1" in 21 | remove) 22 | rm -rf /var/games/netmaumau/NetMauMau.db 23 | ;; 24 | 25 | upgrade|failed-upgrade) 26 | ;; 27 | 28 | *) 29 | echo "prerm called with unknown argument \`$1'" >&2 30 | exit 1 31 | ;; 32 | esac 33 | 34 | # dh_installdeb will replace this with shell code automatically 35 | # generated by other debhelper scripts. 36 | 37 | #DEBHELPER# 38 | 39 | exit 0 40 | -------------------------------------------------------------------------------- /debian/netmaumau-server-common.prerm: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # prerm script for netmaumau-server-common 3 | # 4 | # see: dh_installdeb(1) 5 | 6 | set -e 7 | 8 | # summary of how this script can be called: 9 | # * `remove' 10 | # * `upgrade' 11 | # * `failed-upgrade' 12 | # * `remove' `in-favour' 13 | # * `deconfigure' `in-favour' 14 | # `removing' 15 | # 16 | # for details, see http://www.debian.org/doc/debian-policy/ or 17 | # the debian-policy package 18 | 19 | 20 | case "$1" in 21 | remove) 22 | rm -rf /usr/share/netmaumau/ai_img*.png 23 | ;; 24 | 25 | upgrade|failed-upgrade) 26 | ;; 27 | 28 | *) 29 | echo "prerm called with unknown argument \`$1'" >&2 30 | exit 1 31 | ;; 32 | esac 33 | 34 | # dh_installdeb will replace this with shell code automatically 35 | # generated by other debhelper scripts. 36 | 37 | #DEBHELPER# 38 | 39 | exit 0 40 | -------------------------------------------------------------------------------- /start-server.sh.in: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | ############################################################################### 3 | # 4 | # Copyright 2015 by Heiko Schäfer 5 | # 6 | # This file is part of NetMauMau. 7 | # 8 | # NetMauMau is free software: you can redistribute it and/or modify 9 | # it under the terms of the GNU Lesser General Public License as 10 | # published by the Free Software Foundation, either version 3 of 11 | # the License, or (at your option) any later version. 12 | # 13 | # NetMauMau is distributed in the hope that it will be useful, 14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 | # GNU Lesser General Public License for more details. 17 | # 18 | # You should have received a copy of the GNU Lesser General Public License 19 | # along with NetMauMau. If not, see . 20 | # 21 | ############################################################################### 22 | 23 | export NETMAUMAU_RULES=@SRCDIR@/src/lua/stdrules.lua 24 | 25 | @BUILDDIR@/src/server/nmm-server "--user=$USER" "$@" 26 | 27 | -------------------------------------------------------------------------------- /src/client/scoresexception.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "scoresexception.h" 21 | 22 | using namespace NetMauMau::Client::Exception; 23 | 24 | ScoresException::ScoresException(const std::string &msg, SOCKET sfd) throw() : 25 | SocketException(msg, sfd) {} 26 | 27 | ScoresException::~ScoresException() throw() {} 28 | 29 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 30 | -------------------------------------------------------------------------------- /src/client/timeoutexception.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "timeoutexception.h" 21 | 22 | using namespace NetMauMau::Client::Exception; 23 | 24 | TimeoutException::TimeoutException(const std::string &msg, SOCKET sfd) throw() : 25 | SocketException(msg, sfd) {} 26 | 27 | TimeoutException::~TimeoutException() throw() {} 28 | 29 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 30 | -------------------------------------------------------------------------------- /src/client/shutdownexception.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "shutdownexception.h" 21 | 22 | using namespace NetMauMau::Client::Exception; 23 | 24 | ShutdownException::ShutdownException(const std::string &msg, SOCKET sfd) throw() : 25 | SocketException(msg, sfd) {} 26 | 27 | ShutdownException::~ShutdownException() throw() {} 28 | 29 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 30 | -------------------------------------------------------------------------------- /src/common/pngcheck.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "pngcheck.h" 21 | 22 | #include "mimemagic.h" // for MimeMagic 23 | 24 | bool NetMauMau::Common::checkPNG(const unsigned char *pngData, std::size_t pngDataLen) throw() { 25 | return MimeMagic::getInstance()->checkMime(pngData, pngDataLen, "image/png"); 26 | } 27 | 28 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 29 | -------------------------------------------------------------------------------- /src/client/playerlistexception.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "playerlistexception.h" 21 | 22 | using namespace NetMauMau::Client::Exception; 23 | 24 | PlayerlistException::PlayerlistException(const std::string &msg, SOCKET sfd) throw() : 25 | SocketException(msg, sfd) {} 26 | 27 | PlayerlistException::~PlayerlistException() throw() {} 28 | 29 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 30 | -------------------------------------------------------------------------------- /src/client/gamerunningexception.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "gamerunningexception.h" 21 | 22 | using namespace NetMauMau::Client::Exception; 23 | 24 | GameRunningException::GameRunningException(const std::string &msg, SOCKET sfd) throw() : 25 | SocketException(msg, sfd) {} 26 | 27 | GameRunningException::~GameRunningException() throw() {} 28 | 29 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 30 | -------------------------------------------------------------------------------- /src/client/capabilitiesexception.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "capabilitiesexception.h" 21 | 22 | using namespace NetMauMau::Client::Exception; 23 | 24 | CapabilitiesException::CapabilitiesException(const std::string &msg, SOCKET sfd) throw() : 25 | SocketException(msg, sfd) {} 26 | 27 | CapabilitiesException::~CapabilitiesException() throw() {} 28 | 29 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 30 | -------------------------------------------------------------------------------- /src/client/protocolerrorexception.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "protocolerrorexception.h" 21 | 22 | using namespace NetMauMau::Client::Exception; 23 | 24 | ProtocolErrorException::ProtocolErrorException(const std::string &msg, SOCKET sfd) throw() : 25 | SocketException(msg, sfd) {} 26 | 27 | ProtocolErrorException::~ProtocolErrorException() throw() {} 28 | 29 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 30 | -------------------------------------------------------------------------------- /src/client/lostconnectionexception.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "lostconnectionexception.h" 21 | 22 | using namespace NetMauMau::Client::Exception; 23 | 24 | LostConnectionException::LostConnectionException(const std::string &msg, SOCKET sfd) throw() : 25 | SocketException(msg, sfd) {} 26 | 27 | LostConnectionException::~LostConnectionException() throw() {} 28 | 29 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 30 | -------------------------------------------------------------------------------- /src/client/nonetmaumauserverexception.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "nonetmaumauserverexception.h" 21 | 22 | using namespace NetMauMau::Client::Exception; 23 | 24 | NoNetMauMauServerException::NoNetMauMauServerException(const std::string &msg, SOCKET sfd) throw() 25 | : SocketException(msg, sfd) {} 26 | 27 | NoNetMauMauServerException::~NoNetMauMauServerException() throw() {} 28 | 29 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 30 | -------------------------------------------------------------------------------- /src/common/zlibexception.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "zlibexception.h" 21 | 22 | using namespace NetMauMau::Common::Exception; 23 | 24 | ZLibException::ZLibException(const std::string &msg) : std::exception(), m_msg(msg) {}; 25 | 26 | ZLibException::~ZLibException() throw() {} 27 | 28 | const char *ZLibException::what() const throw() { 29 | return m_msg.c_str(); 30 | } 31 | 32 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 33 | -------------------------------------------------------------------------------- /src/client/connectionrejectedexception.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "connectionrejectedexception.h" 21 | 22 | using namespace NetMauMau::Client::Exception; 23 | 24 | ConnectionRejectedException::ConnectionRejectedException(const std::string &msg, 25 | SOCKET sfd) throw() : SocketException(msg, sfd) {} 26 | 27 | ConnectionRejectedException::~ConnectionRejectedException() throw() {} 28 | 29 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 30 | -------------------------------------------------------------------------------- /src/client/interceptederrorexception.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "interceptederrorexception.h" 21 | 22 | using namespace NetMauMau::Client; 23 | 24 | Exception::InterceptedErrorException::InterceptedErrorException(const std::string &msg, 25 | SOCKET sfd) throw() : SocketException(msg, sfd) {} 26 | 27 | Exception::InterceptedErrorException::~InterceptedErrorException() throw() {} 28 | 29 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 30 | -------------------------------------------------------------------------------- /src/common/defaultplayerimage.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "defaultplayerimage.h" 21 | 22 | #include "ai-icon.h" 23 | 24 | #pragma GCC visibility push(default) 25 | namespace NetMauMau { 26 | 27 | namespace Common { 28 | 29 | const std::string DefaultPlayerImage(reinterpret_cast(ai_icon_data), 30 | sizeof(ai_icon_data)); 31 | 32 | } 33 | 34 | } 35 | #pragma GCC visibility pop 36 | 37 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 38 | -------------------------------------------------------------------------------- /src/ai/nextaction.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "nextaction.h" 21 | 22 | using namespace NetMauMau::AI; 23 | 24 | NextAction::NextAction(const IConditionPtr &cond) throw() : AbstractAction(), m_condition(cond) {} 25 | 26 | NextAction::~NextAction() throw() {} 27 | 28 | const IConditionPtr &NextAction::perform(IAIState &, 29 | const NetMauMau::Player::IPlayer::CARDS &) const throw() { 30 | return m_condition; 31 | } 32 | 33 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 34 | -------------------------------------------------------------------------------- /src/ai/suspendaction.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "suspendaction.h" 21 | 22 | using namespace NetMauMau::AI; 23 | 24 | SuspendAction::SuspendAction() throw() : AbstractAction() {} 25 | 26 | SuspendAction::~SuspendAction() throw() {} 27 | 28 | const IConditionPtr &SuspendAction::perform(IAIState &, 29 | const NetMauMau::Player::IPlayer::CARDS &) const throw() { 30 | return AbstractAction::getNullCondition(); 31 | } 32 | 33 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 34 | -------------------------------------------------------------------------------- /src/client/Makefile.am: -------------------------------------------------------------------------------- 1 | if ENABLE_CLIENT 2 | 3 | lib_LTLIBRARIES = libnetmaumauclient.la 4 | noinst_LTLIBRARIES = libnetmaumauclient_private.la 5 | 6 | noinst_HEADERS = abstractclientv05impl.h clientcardfactory.h clientconnectionimpl.h \ 7 | interceptederrorexception.h 8 | 9 | libnetmaumauclient_private_la_CXXFLAGS = -I$(top_srcdir)/src/include -I$(top_srcdir)/src/common \ 10 | $(NO_EXCEPTIONS) 11 | libnetmaumauclient_private_la_SOURCES = clientcardfactory.cpp 12 | 13 | libnetmaumauclient_la_CXXFLAGS = -I$(top_srcdir)/src/include -I$(top_srcdir)/src/common 14 | libnetmaumauclient_la_SOURCES = abstractclient.cpp abstractclientv05impl.cpp \ 15 | capabilitiesexception.cpp clientconnection.cpp clientconnectionimpl.cpp \ 16 | connectionrejectedexception.cpp gamerunningexception.cpp interceptederrorexception.cpp \ 17 | lostconnectionexception.cpp nonetmaumauserverexception.cpp playerlistexception.cpp \ 18 | protocolerrorexception.cpp remoteplayerexception.cpp scoresexception.cpp \ 19 | shutdownexception.cpp timeoutexception.cpp versionmismatchexception.cpp 20 | libnetmaumauclient_la_LDFLAGS = -nodefaultlibs -nostartfiles -no-undefined \ 21 | -version-info 5:$(SERVER_VERSION_MINOR):$(SERVER_VERSION_MAJOR) 22 | libnetmaumauclient_la_LIBADD = libnetmaumauclient_private.la ../common/libnetmaumaucommon.la 23 | 24 | endif 25 | -------------------------------------------------------------------------------- /src/server/ttynamecheckdir.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_SERVER_TTYNAMECHECKDIR_H 21 | #define NETMAUMAU_SERVER_TTYNAMECHECKDIR_H 22 | 23 | #ifndef _WIN32 24 | 25 | #include 26 | 27 | namespace NetMauMau { 28 | 29 | namespace Server { 30 | 31 | char *ttynameCheckDir(dev_t ttyNr, const char *devDir); 32 | 33 | } 34 | 35 | } 36 | 37 | #endif 38 | 39 | #endif /* NETMAUMAU_SERVER_TTYNAMECHECKDIR_H */ 40 | 41 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 42 | -------------------------------------------------------------------------------- /src/lua/luafatalexception.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "luafatalexception.h" 21 | 22 | using namespace NetMauMau::Lua::Exception; 23 | 24 | LuaFatalException::LuaFatalException(const std::string &msg, const char *fname) throw() 25 | : LuaException(msg, fname) {} 26 | 27 | LuaFatalException::LuaFatalException(const LuaFatalException &o) throw() : LuaException(o) {} 28 | 29 | LuaFatalException::~LuaFatalException() throw() {} 30 | 31 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 32 | -------------------------------------------------------------------------------- /src/common/errorstring.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_COMMON_ERRORSTRING_H 21 | #define NETMAUMAU_COMMON_ERRORSTRING_H 22 | 23 | #include "linkercontrol.h" 24 | 25 | namespace NetMauMau { 26 | 27 | namespace Common { 28 | 29 | _EXPORT const char *errorString() throw(); 30 | _EXPORT const char *errorString(int errnum, bool gai = false) throw(); 31 | 32 | } 33 | 34 | } 35 | 36 | #endif /* NETMAUMAU_COMMON_ERRORSTRING_H */ 37 | 38 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 39 | -------------------------------------------------------------------------------- /src/common/pathtools.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_COMMON_PATHTOOLS_H 21 | #define NETMAUMAU_COMMON_PATHTOOLS_H 22 | 23 | #include 24 | 25 | namespace NetMauMau { 26 | 27 | namespace Common { 28 | 29 | typedef enum { BINDIR, PKGDATA, USER } MPATH; 30 | 31 | std::string getModulePath(MPATH mpath, const char *fname = 0L, const char *fext = 0L) throw(); 32 | 33 | } 34 | 35 | } 36 | 37 | #endif /* NETMAUMAU_COMMON_PATHTOOLS_H */ 38 | 39 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 40 | -------------------------------------------------------------------------------- /src/common/pngcheck.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_PNGCHECK_H 21 | #define NETMAUMAU_PNGCHECK_H 22 | 23 | #include // for size_t 24 | 25 | #include "linkercontrol.h" // for _EXPORT 26 | 27 | namespace NetMauMau { 28 | 29 | namespace Common { 30 | 31 | _EXPORT bool checkPNG(const unsigned char *pngData, std::size_t pngDataLen) throw(); 32 | 33 | } 34 | 35 | } 36 | 37 | #endif /* NETMAUMAU_PNGCHECK_H */ 38 | 39 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 40 | -------------------------------------------------------------------------------- /src/lua/luaexception.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "luaexception.h" 21 | 22 | using namespace NetMauMau::Lua::Exception; 23 | 24 | LuaException::LuaException(const std::string &msg, const char *fname) throw() 25 | : SocketException(std::string("[Lua") + (fname ? " " : "") + (fname ? fname : "") + "] " + 26 | msg) {} 27 | 28 | LuaException::LuaException(const LuaException &o) throw() : SocketException(o) {} 29 | 30 | LuaException::~LuaException() throw() {} 31 | 32 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 33 | -------------------------------------------------------------------------------- /nmm-server.bc.in: -------------------------------------------------------------------------------- 1 | _nmm-server() { 2 | 3 | local cur prev opts 4 | 5 | COMPREPLY=( ) 6 | 7 | cur=$(_get_cword) 8 | prev="${COMP_WORDS[COMP_CWORD-1]}" 9 | 10 | # COMPREPLY considers '=' as a word. For $prev we prefer the word before the actual "=" 11 | if [[ "$prev" == "=" ]] 12 | then 13 | prev="${COMP_WORDS[COMP_CWORD - 2]}" 14 | elif [[ "$cur" == "=" ]] 15 | then 16 | cur="" 17 | fi 18 | 19 | opts=`@bindir@/nmm-server --usage | _parse_usage -` 20 | 21 | case "${prev}" in 22 | --bind) 23 | _ip_addresses 24 | _known_hosts_real "$cur" 25 | COMPREPLY+=" " 26 | return 0 27 | ;; 28 | --iface) 29 | _available_interfaces 30 | COMPREPLY+=" " 31 | return 0 32 | ;; 33 | --group) 34 | _allowed_groups 35 | COMPREPLY+=" " 36 | return 0 37 | ;; 38 | --user) 39 | _allowed_users 40 | COMPREPLY+=" " 41 | return 0 42 | ;; 43 | --ace-round) 44 | COMPREPLY=( $(compgen -W "ACE QUEEN KING" -- ${cur}) ) 45 | COMPREPLY+=" " 46 | return 0 47 | ;; 48 | esac 49 | 50 | COMPREPLY=( $(compgen -W "${opts}" -- ${cur}) ) 51 | } 52 | 53 | complete -o nospace -F _nmm-server nmm-server 54 | -------------------------------------------------------------------------------- /src/include/inullable.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_INULLABLE_H 21 | #define NETMAUMAU_INULLABLE_H 22 | 23 | #include "linkercontrol.h" 24 | 25 | namespace NetMauMau { 26 | 27 | namespace Common { 28 | 29 | class INullable { 30 | DISALLOW_COPY_AND_ASSIGN(INullable) 31 | public: 32 | virtual ~INullable() {} 33 | 34 | virtual bool isNull() const throw() = 0; 35 | 36 | protected: 37 | INullable() {} 38 | }; 39 | 40 | } 41 | 42 | } 43 | 44 | #endif /* NETMAUMAU_INULLABLE_H */ 45 | 46 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 47 | -------------------------------------------------------------------------------- /src/ai/powerjackaction.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "powerjackaction.h" 21 | 22 | using namespace NetMauMau::AI; 23 | 24 | PowerJackAction::PowerJackAction() throw() : AbstractAction() {} 25 | 26 | PowerJackAction::~PowerJackAction() throw() {} 27 | 28 | const IConditionPtr &PowerJackAction::perform(IAIState &state, 29 | const NetMauMau::Player::IPlayer::CARDS &cards) const throw() { 30 | 31 | if(cards.size() == 1u) state.setCard(cards.front()); 32 | 33 | return getNullCondition(); 34 | } 35 | 36 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 37 | -------------------------------------------------------------------------------- /src/common/icardfactory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_ICARDFACTORY_H 21 | #define NETMAUMAU_ICARDFACTORY_H 22 | 23 | #include "icard.h" 24 | 25 | namespace NetMauMau { 26 | 27 | class ICardFactory { 28 | public: 29 | virtual ~ICardFactory() {} 30 | 31 | virtual _NOUNUSED Common::ICard *create(Common::ICard::SUIT suit, 32 | Common::ICard::RANK rank) const = 0; 33 | 34 | protected: 35 | explicit ICardFactory() {} 36 | }; 37 | 38 | } 39 | 40 | #endif /* NETMAUMAU_ICARDFACTORY_H */ 41 | 42 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 43 | -------------------------------------------------------------------------------- /src/engine/nullcardcountobserver.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "nullcardcountobserver.h" 21 | 22 | using namespace NetMauMau; 23 | 24 | NullCardCountObserver::NullCardCountObserver() : ICardCountObserver(), 25 | Common::SmartSingleton() {} 26 | 27 | NullCardCountObserver::~NullCardCountObserver() throw() {} 28 | 29 | bool NullCardCountObserver::isNull() const throw() { 30 | return true; 31 | } 32 | 33 | void NullCardCountObserver::cardCountChanged(const Player::IPlayer *) const throw() {} 34 | 35 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 36 | -------------------------------------------------------------------------------- /src/common/condition.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "condition.h" 21 | 22 | using namespace NetMauMau::Common; 23 | 24 | Condition::Condition() : m_cond() { 25 | 26 | const int r = pthread_cond_init(&m_cond, NULL); 27 | 28 | if(r) throw MutexException(errorString(r)); 29 | } 30 | 31 | Condition::Condition(const Condition &o) throw() : m_cond(o.m_cond) {} 32 | 33 | Condition::~Condition() throw() { 34 | pthread_cond_destroy(&m_cond); 35 | } 36 | 37 | int Condition::signal() throw() { 38 | return pthread_cond_signal(&m_cond); 39 | } 40 | 41 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 42 | -------------------------------------------------------------------------------- /src/include/defaultplayerimage.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | /** 21 | * @file 22 | */ 23 | 24 | #ifndef NETMAUMAU_COMMON_DEFAULTPLAYERIMAGE_H 25 | #define NETMAUMAU_COMMON_DEFAULTPLAYERIMAGE_H 26 | 27 | #include 28 | 29 | namespace NetMauMau { 30 | 31 | namespace Common { 32 | 33 | /** 34 | * @ingroup util 35 | * @brief @c std::string containing the default player image in PNG format 36 | * 37 | * @since 0.11 38 | */ 39 | extern const std::string DefaultPlayerImage; 40 | 41 | } 42 | 43 | } 44 | 45 | #endif /* NETMAUMAU_COMMON_DEFAULTPLAYERIMAGE_H */ 46 | 47 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 48 | -------------------------------------------------------------------------------- /src/test/stresstest.sh.in: -------------------------------------------------------------------------------- 1 | #!@SHELL@ 2 | # 3 | # Copyright 2015 by Heiko Schäfer 4 | # 5 | # This file is part of NetMauMau. 6 | # 7 | # NetMauMau is free software: you can redistribute it and/or modify 8 | # it under the terms of the GNU Lesser General Public License as 9 | # published by the Free Software Foundation, either version 3 of 10 | # the License, or (at your option) any later version. 11 | # 12 | # NetMauMau is distributed in the hope that it will be useful, 13 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 | # GNU Lesser General Public License for more details. 16 | # 17 | # You should have received a copy of the GNU Lesser General Public License 18 | # along with NetMauMau. If not, see . 19 | # 20 | 21 | let seed=0 22 | 23 | if [ -n "$1" ]; then 24 | let seed=$1 25 | fi 26 | 27 | if [ -n "$2" ]; then 28 | let mseed=$2 29 | else 30 | let mseed=-1 31 | fi 32 | 33 | export GSL_RNG_TYPE=ranlxs2 34 | export GSL_RNG_SEED=$seed 35 | export NETMAUMAU_RULES=@RULES@ 36 | export NMM_NO_TRACE=1 37 | export NMM_NO_SQLITE=1 38 | 39 | terminate() { 40 | echo 41 | echo "Seed: "$seed ; 42 | exit 0 43 | } 44 | 45 | trap terminate SIGINT SIGTERM 46 | 47 | while(@check_PROGRAMS@ && test $mseed -eq -1 -o $seed -lt $mseed ); do 48 | let seed=seed+1 ; 49 | export GSL_RNG_SEED=$seed ; 50 | done 51 | 52 | echo 53 | echo "Seed: "$seed ; 54 | -------------------------------------------------------------------------------- /src/engine/hardplayer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "hardplayer.h" 21 | 22 | #include "jackonlycondition.h" // for JackOnlyCondition 23 | #include "powerjackcondition.h" // for PowerJackCondition 24 | 25 | using namespace NetMauMau::Player; 26 | 27 | HardPlayer::HardPlayer(const std::string &name, const NetMauMau::IPlayedOutCards *poc) 28 | : AIPlayerBase < NetMauMau::AI::JackOnlyCondition, 29 | NetMauMau::AI::PowerJackCondition > (name, poc) {} 30 | 31 | HardPlayer::~HardPlayer() throw() {} 32 | 33 | IPlayer::TYPE HardPlayer::getType() const throw() { 34 | return HARD; 35 | } 36 | 37 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 38 | -------------------------------------------------------------------------------- /src/client/remoteplayerexception.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "remoteplayerexception.h" 21 | 22 | using namespace NetMauMau::Client::Exception; 23 | 24 | RemotePlayerException::RemotePlayerException(const std::string &p, const std::string &msg) throw() 25 | : SocketException(msg), m_player(p) {} 26 | 27 | RemotePlayerException::RemotePlayerException(const RemotePlayerException &o) throw() 28 | : SocketException(o), m_player(o.m_player) {} 29 | 30 | RemotePlayerException::~RemotePlayerException() throw() {} 31 | 32 | std::string RemotePlayerException::player() const throw() { 33 | return m_player; 34 | } 35 | 36 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 37 | -------------------------------------------------------------------------------- /src/engine/serverplayerexception.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "serverplayerexception.h" 21 | 22 | using namespace NetMauMau::Server::Exception; 23 | 24 | ServerPlayerException::ServerPlayerException(const std::string &p, const std::string &msg, 25 | SOCKET sfd) throw() : SocketException(msg, sfd), m_player(p) {} 26 | 27 | ServerPlayerException::ServerPlayerException(const ServerPlayerException &o) throw() 28 | : SocketException(o), m_player(o.m_player) {} 29 | 30 | ServerPlayerException::~ServerPlayerException() throw() {} 31 | 32 | std::string ServerPlayerException::player() const throw() { 33 | return m_player; 34 | } 35 | 36 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 37 | -------------------------------------------------------------------------------- /src/common/tcpopt_cork.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_COMMON_TCPOPT_CORK_H 21 | #define NETMAUMAU_COMMON_TCPOPT_CORK_H 22 | 23 | #include "tcpopt_base.h" 24 | 25 | #define TCPOPT_CORK(fd) const volatile NetMauMau::Common::TCPOptCork __tcp__opt__cork__(fd); \ 26 | _UNUSED(__tcp__opt__cork__) 27 | 28 | namespace NetMauMau { 29 | 30 | namespace Common { 31 | 32 | class _EXPORT TCPOptCork : public TCPOptBase { 33 | DISALLOW_COPY_AND_ASSIGN(TCPOptCork) 34 | public: 35 | explicit TCPOptCork(SOCKET fd) throw(); 36 | virtual ~TCPOptCork() throw(); 37 | }; 38 | 39 | } 40 | 41 | } 42 | 43 | #endif /* NETMAUMAU_COMMON_TCPOPT_CORK_H */ 44 | 45 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 46 | -------------------------------------------------------------------------------- /src/engine/icardcountobserver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_ICARDCOUNTOBSERVER_H 21 | #define NETMAUMAU_ICARDCOUNTOBSERVER_H 22 | 23 | #include "inullable.h" 24 | 25 | namespace NetMauMau { 26 | 27 | namespace Player { 28 | class IPlayer; 29 | } 30 | 31 | class ICardCountObserver : public Common::INullable { 32 | DISALLOW_COPY_AND_ASSIGN(ICardCountObserver) 33 | public: 34 | virtual ~ICardCountObserver() {} 35 | 36 | virtual void cardCountChanged(const Player::IPlayer *player) const throw() = 0; 37 | 38 | protected: 39 | explicit ICardCountObserver() : INullable() {} 40 | }; 41 | 42 | } 43 | 44 | #endif /* NETMAUMAU_ICARDCOUNTOBSERVER_H */ 45 | 46 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 47 | -------------------------------------------------------------------------------- /netmaumau.h2m.in: -------------------------------------------------------------------------------- 1 | [DESCRIPTION] 2 | @PACKAGE_NAME@ is a server for the popular card game Mau Mau. 3 | 4 | [FILES] 5 | The Lua rules script \fBstdrules.lua\fR will get searched and - if existing - loaded in order from 6 | .IP 1. 7 | @pkgdatadir@ 8 | .IP 2. 9 | @sysconfdir@/@PACKAGE@ 10 | .IP 3. 11 | ~/.@PACKAGE_NAME@ 12 | 13 | [SEE ALSO] 14 | Visit the 15 | .mso www.tmac 16 | .URL "https://sourceforge.net/projects/netmaumau/" "homepage" " for more information." 17 | 18 | [AUTHOR] 19 | Written by Heiko Schaefer 20 | 21 | [REPORTING BUGS] 22 | Report bugs to @PACKAGE_BUGREPORT@ or into the 23 | .mso www.tmac 24 | .URL "https://github.com/velnias75/NetMauMau/issues" "issue tracker" "." 25 | 26 | [THANKS] 27 | Very special thanks are going to \fBCatherine Maria Touhami\fR. 28 | 29 | [COPYRIGHT] 30 | Copyright (c) @BUILD_YEAR@, Heiko Schaefer 31 | .PP 32 | @PACKAGE_NAME@ is free software: you can redistribute it and/or modify it under the terms of the 33 | GNU Lesser General Public License as published by the Free Software Foundation, either version 3 34 | of the License, or (at your option) any later version. 35 | .PP 36 | @PACKAGE_NAME@ is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; 37 | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 38 | See the GNU Lesser General Public License for more details. 39 | .PP 40 | You should have received a copy of the GNU Lesser General Public License along with @PACKAGE_NAME@. 41 | If not, see . 42 | -------------------------------------------------------------------------------- /src/common/tcpopt_nodelay.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_COMMON_TCPOPT_NODELAY_H 21 | #define NETMAUMAU_COMMON_TCPOPT_NODELAY_H 22 | 23 | #include "tcpopt_base.h" 24 | 25 | #define TCPOPT_NODELAY(fd) const volatile NetMauMau::Common::TCPOptNodelay __tcp__opt__nodelay__(fd); \ 26 | _UNUSED(__tcp__opt__nodelay__) 27 | 28 | namespace NetMauMau { 29 | 30 | namespace Common { 31 | 32 | class _EXPORT TCPOptNodelay : public TCPOptBase { 33 | DISALLOW_COPY_AND_ASSIGN(TCPOptNodelay) 34 | public: 35 | explicit TCPOptNodelay(SOCKET fd) throw(); 36 | virtual ~TCPOptNodelay() throw(); 37 | }; 38 | 39 | } 40 | 41 | } 42 | 43 | #endif /* NETMAUMAU_COMMON_TCPOPT_NODELAY_H */ 44 | 45 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 46 | -------------------------------------------------------------------------------- /src/engine/Makefile.am: -------------------------------------------------------------------------------- 1 | noinst_LTLIBRARIES = libengine.la libengine_private.la 2 | 3 | noinst_HEADERS = abstractplayer.h aiplayerbase.h defaulteventhandler.h easyplayer.h \ 4 | enginecontext.h engine.h hardplayer.h iaceroundlistener.h icardcountobserver.h \ 5 | ieventhandler.h iplayedoutcards.h iruleset.h italonchange.h nextturn.h \ 6 | nullaceroundlistener.h nullcardcountobserver.h nullconnection.h nullruleset.h \ 7 | random_gen.h serverplayerexception.h stdcardfactory.h talon.h 8 | 9 | if GSL 10 | GSL=-DHAVE_GSL 11 | else 12 | GSL= 13 | endif 14 | 15 | libengine_private_la_CPPFLAGS = $(GSL) -DLUADIR=\"$(pkgdatadir)\" -DSYSCONFDIR=\"$(sysconfdir)\" 16 | libengine_private_la_CXXFLAGS = -I$(top_srcdir)/src/include -I$(top_srcdir)/src/common \ 17 | -I$(top_builddir)/src/ai -I$(top_srcdir)/src/ai -I$(top_srcdir)/src/lua \ 18 | -I$(top_srcdir)/src/sqlite $(GSL_CFLAGS) 19 | libengine_private_la_SOURCES = abstractplayer.cpp easyplayer.cpp engine.cpp enginecontext.cpp \ 20 | hardplayer.cpp nextturn.cpp nullconnection.cpp nullruleset.cpp serverplayerexception.cpp 21 | libengine_private_la_LIBADD = ../ai/libai.la $(GSL_LIBS) 22 | 23 | libengine_la_CPPFLAGS = $(GSL) 24 | libengine_la_CXXFLAGS = -I$(top_srcdir)/src/include -I$(top_srcdir)/src/sqlite \ 25 | -I$(top_srcdir)/src/common $(GSL_CFLAGS) $(NO_EXCEPTIONS) 26 | libengine_la_SOURCES = defaulteventhandler.cpp nullaceroundlistener.cpp nullcardcountobserver.cpp \ 27 | stdcardfactory.cpp talon.cpp 28 | libengine_la_LIBADD = ../sqlite/libsqlite.la libengine_private.la ../lua/libluaruleset.la \ 29 | ../common/libnetmaumaucommon.la 30 | -------------------------------------------------------------------------------- /debian/netmaumau-server.postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # postinst script for netmaumau-server 3 | # 4 | # see: dh_installdeb(1) 5 | 6 | set -e 7 | 8 | # summary of how this script can be called: 9 | # * `configure' 10 | # * `abort-upgrade' 11 | # * `abort-remove' `in-favour' 12 | # 13 | # * `abort-remove' 14 | # * `abort-deconfigure' `in-favour' 15 | # `removing' 16 | # 17 | # for details, see http://www.debian.org/doc/debian-policy/ or 18 | # the debian-policy package 19 | 20 | case "$1" in 21 | configure) 22 | chown nobody:nogroup /var/games/netmaumau 23 | 24 | if [ -n "`pgrep -f "nmm-server"`" ]; then 25 | if [ -n "`pgrep -f "inetd"`" ]; then 26 | echo "Detected a NetMauMau server started from (x)inetd." 27 | echo "Stopping nmm-server to spawn the newly installed instance at next request …" 28 | killall nmm-server 2> /dev/null 29 | fi 30 | fi 31 | ;; 32 | 33 | abort-upgrade|abort-remove|abort-deconfigure) 34 | ;; 35 | 36 | *) 37 | echo "postinst called with unknown argument \`$1'" >&2 38 | exit 1 39 | ;; 40 | esac 41 | 42 | # dh_installdeb will replace this with shell code automatically 43 | # generated by other debhelper scripts. 44 | 45 | #DEBHELPER# 46 | 47 | exit 0 48 | -------------------------------------------------------------------------------- /src/ai/randomjackcondition.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "randomjackcondition.h" 21 | 22 | #include "randomjackaction.h" // for RandomJackAction 23 | 24 | using namespace NetMauMau::AI; 25 | 26 | RandomJackCondition::RandomJackCondition() throw() : AbstractCondition() {} 27 | 28 | RandomJackCondition::~RandomJackCondition() throw() {} 29 | 30 | IActionPtr RandomJackCondition::perform(const IAIState &state, 31 | const NetMauMau::Player::IPlayer::CARDS &) const throw() { 32 | return !state.isNoJack() && (!state.getCard() || 33 | state.getPowerSuit() != NetMauMau::Common::ICard::SUIT_ILLEGAL) ? 34 | IActionPtr(new RandomJackAction()) : getNullAction(); 35 | } 36 | 37 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 38 | -------------------------------------------------------------------------------- /src/common/tcpopt_nodelay.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #if defined(HAVE_CONFIG_H) || defined(IN_IDE_PARSER) 21 | #include "config.h" 22 | #endif 23 | 24 | #ifdef HAVE_NETINET_IN_H 25 | #include 26 | #include 27 | #elif defined(_WIN32) 28 | #include 29 | #endif 30 | 31 | #include "tcpopt_nodelay.h" 32 | 33 | using namespace NetMauMau::Common; 34 | 35 | #if defined(HAVE_NETINET_IN_H) || defined(_WIN32) 36 | TCPOptNodelay::TCPOptNodelay(SOCKET fd) throw() : TCPOptBase(fd, TCP_NODELAY, "TCP_NODELAY") {} 37 | #else 38 | TCPOptNodelay::TCPOptNodelay(SOCKET) throw() : TCPOptBase(INVALID_SOCKET, 0, "TCP_NODELAY") {} 39 | #endif 40 | 41 | TCPOptNodelay::~TCPOptNodelay() throw() {} 42 | 43 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 44 | -------------------------------------------------------------------------------- /src/engine/italonchange.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_ITALONCHANGE_H 21 | #define NETMAUMAU_ITALONCHANGE_H 22 | 23 | #include "linkercontrol.h" 24 | 25 | namespace NetMauMau { 26 | 27 | namespace Common { 28 | class ICard; 29 | } 30 | 31 | class ITalonChange { 32 | DISALLOW_COPY_AND_ASSIGN(ITalonChange) 33 | public: 34 | virtual ~ITalonChange() {} 35 | 36 | virtual void uncoveredCard(const NetMauMau::Common::ICard *top) const = 0; 37 | virtual void talonEmpty(bool empty) const throw() = 0; 38 | virtual void shuffled() const = 0; 39 | virtual void underflow() = 0; 40 | 41 | protected: 42 | explicit ITalonChange() {} 43 | }; 44 | 45 | } 46 | 47 | #endif /* NETMAUMAU_ITALONCHANGE_H */ 48 | 49 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 50 | -------------------------------------------------------------------------------- /src/engine/nullaceroundlistener.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "nullaceroundlistener.h" 21 | 22 | using namespace NetMauMau; 23 | 24 | NullAceRoundListener::NullAceRoundListener() : IAceRoundListener(), 25 | Common::SmartSingleton() {} 26 | 27 | NullAceRoundListener::~NullAceRoundListener() throw() {} 28 | 29 | bool NullAceRoundListener::isNull() const throw() { 30 | return true; 31 | } 32 | 33 | Common::ICard::RANK NullAceRoundListener::getAceRoundRank() const { 34 | return Common::ICard::RANK_ILLEGAL; 35 | } 36 | 37 | void NullAceRoundListener::aceRoundStarted(const Player::IPlayer *) const {} 38 | 39 | void NullAceRoundListener::aceRoundEnded(const Player::IPlayer *) const {} 40 | 41 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 42 | -------------------------------------------------------------------------------- /src/lua/luaexception.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_LUA_EXCEPTION_LUAEXCEPTION_H 21 | #define NETMAUMAU_LUA_EXCEPTION_LUAEXCEPTION_H 22 | 23 | #include "socketexception.h" // for SocketException 24 | 25 | namespace NetMauMau { 26 | 27 | namespace Lua { 28 | 29 | namespace Exception { 30 | 31 | class LuaException : public Common::Exception::SocketException { 32 | LuaException &operator=(const LuaException &); 33 | public: 34 | LuaException(const LuaException &o) throw(); 35 | explicit LuaException(const std::string &msg, const char *fname = 0L) throw(); 36 | virtual ~LuaException() throw(); 37 | }; 38 | 39 | } 40 | 41 | } 42 | 43 | } 44 | 45 | #endif /* NETMAUMAU_LUA_EXCEPTION_LUAEXCEPTION_H */ 46 | 47 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 48 | -------------------------------------------------------------------------------- /src/ai/decisionbase.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "decisionbase.h" 21 | 22 | using namespace NetMauMau::AI; 23 | 24 | DecisionBase::DecisionBase() throw() {} 25 | 26 | DecisionBase::~DecisionBase() throw() {} 27 | 28 | NetMauMau::Player::IPlayer::CARDS 29 | DecisionBase::removeJack(const NetMauMau::Player::IPlayer::CARDS &cards) throw() { 30 | 31 | NetMauMau::Player::IPlayer::CARDS myCards(cards); 32 | 33 | myCards.erase(std::remove_if(myCards.begin(), myCards.end(), 34 | std::bind2nd(NetMauMau::Common::equalTo 35 | < NetMauMau::Player::IPlayer::CARDS::value_type, 36 | NetMauMau::Common::ICard::RANK > (), 37 | NetMauMau::Common::ICard::JACK)), myCards.end()); 38 | return myCards; 39 | } 40 | 41 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 42 | -------------------------------------------------------------------------------- /src/ai/playjackaction.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "playjackaction.h" 21 | 22 | #include "iruleset.h" // for IRuleSet 23 | 24 | using namespace NetMauMau::AI; 25 | 26 | PlayJackAction::PlayJackAction() throw() : AbstractAction() {} 27 | 28 | PlayJackAction::~PlayJackAction() throw() {} 29 | 30 | const IConditionPtr &PlayJackAction::perform(IAIState &state, 31 | const NetMauMau::Player::IPlayer::CARDS &) const throw() { 32 | 33 | const NetMauMau::Common::ICardPtr firstCard(*state.getPlayerCards().begin()); 34 | 35 | state.setCard(state.getRuleSet()->checkCard(state.getUncoveredCard(), firstCard) ? 36 | firstCard : NetMauMau::Common::ICardPtr()); 37 | 38 | return AbstractAction::getNullCondition(); 39 | } 40 | 41 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 42 | -------------------------------------------------------------------------------- /src/server/gamecontext.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "gamecontext.h" 21 | 22 | using namespace NetMauMau::Server; 23 | 24 | GameContext::GameContext(NetMauMau::Event::IEventHandler &evtHdlr, long aiDelay, bool dirChange, 25 | NetMauMau::Common::CARDCONFIG &cc, bool aiPlayer, const AINAMES &aiNames, 26 | char aceRound) throw() : m_aiPlayer(aiPlayer), m_aiNames(aiNames), 27 | m_engineCtx(evtHdlr, dirChange, aiDelay, !aiPlayer || !getAINames().empty(), aceRound, cc), 28 | m_cardConfig(cc) {} 29 | 30 | GameContext::GameContext(const GameContext &o) throw() : m_aiPlayer(o.m_aiPlayer), 31 | m_aiNames(o.m_aiNames), m_engineCtx(o.m_engineCtx), m_cardConfig(o.m_cardConfig) {} 32 | 33 | GameContext::~GameContext() throw() {} 34 | 35 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 36 | -------------------------------------------------------------------------------- /debian/netmaumau-server-common.postinst: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # postinst script for netmaumau-server-common 3 | # 4 | # see: dh_installdeb(1) 5 | 6 | set -e 7 | 8 | # summary of how this script can be called: 9 | # * `configure' 10 | # * `abort-upgrade' 11 | # * `abort-remove' `in-favour' 12 | # 13 | # * `abort-remove' 14 | # * `abort-deconfigure' `in-favour' 15 | # `removing' 16 | # 17 | # for details, see http://www.debian.org/doc/debian-policy/ or 18 | # the debian-policy package 19 | 20 | 21 | case "$1" in 22 | configure) 23 | if [ ! -e /usr/share/netmaumau/ai_img1.png ]; then \ 24 | ln -s /usr/share/netmaumau/QS.PNG /usr/share/netmaumau/ai_img1.png; \ 25 | fi 26 | if [ ! -e /usr/share/netmaumau/ai_img2.png ]; then \ 27 | ln -s /usr/share/netmaumau/KC.PNG /usr/share/netmaumau/ai_img2.png; \ 28 | fi 29 | if [ ! -e /usr/share/netmaumau/ai_img3.png ]; then \ 30 | ln -s /usr/share/netmaumau/QC.PNG /usr/share/netmaumau/ai_img3.png; \ 31 | fi 32 | ;; 33 | 34 | abort-upgrade|abort-remove|abort-deconfigure) 35 | ;; 36 | 37 | *) 38 | echo "postinst called with unknown argument \`$1'" >&2 39 | exit 1 40 | ;; 41 | esac 42 | 43 | # dh_installdeb will replace this with shell code automatically 44 | # generated by other debhelper scripts. 45 | 46 | #DEBHELPER# 47 | 48 | exit 0 49 | -------------------------------------------------------------------------------- /src/common/iobserver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_COMMON_IOBSERVER_H 21 | #define NETMAUMAU_COMMON_IOBSERVER_H 22 | 23 | #include "linkercontrol.h" 24 | #include "tmp.h" 25 | 26 | namespace NetMauMau { 27 | 28 | namespace Common { 29 | 30 | template 31 | class IObserver { 32 | DISALLOW_COPY_AND_ASSIGN(IObserver) 33 | public: 34 | typedef SourceType source_type; 35 | typedef typename SourceType::what_type what_type; 36 | 37 | virtual ~IObserver() {} 38 | 39 | virtual void setSource(const source_type *s) = 0; 40 | virtual void update(typename Commons::RParam::Type what) = 0; 41 | 42 | protected: 43 | IObserver() {} 44 | }; 45 | 46 | } 47 | 48 | } 49 | 50 | #endif /* NETMAUMAU_COMMON_IOBSERVER_H */ 51 | 52 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 53 | -------------------------------------------------------------------------------- /src/common/zlibexception.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_COMMON_ZLIBEXCEPTION_H 21 | #define NETMAUMAU_COMMON_ZLIBEXCEPTION_H 22 | 23 | #include 24 | #include 25 | 26 | #include "linkercontrol.h" 27 | 28 | namespace NetMauMau { 29 | 30 | namespace Common { 31 | 32 | namespace Exception { 33 | 34 | class _EXPORT ZLibException : public std::exception { 35 | ZLibException &operator=(const ZLibException &); 36 | public: 37 | explicit ZLibException(const std::string &msg); 38 | virtual ~ZLibException() throw(); 39 | 40 | virtual const char *what() const throw() _PURE; 41 | 42 | private: 43 | std::string m_msg; 44 | }; 45 | 46 | } 47 | 48 | } 49 | 50 | } 51 | 52 | #endif // NETMAUMAU_COMMON_ZLIBEXCEPTION_H 53 | 54 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 55 | -------------------------------------------------------------------------------- /src/engine/hardplayer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_PLAYER_HARDPLAYER_H 21 | #define NETMAUMAU_PLAYER_HARDPLAYER_H 22 | 23 | #include "aiplayerbase.h" // for AIPlayerBase 24 | 25 | namespace NetMauMau { 26 | 27 | namespace AI { 28 | class JackOnlyCondition; 29 | class PowerJackCondition; 30 | } 31 | 32 | namespace Player { 33 | 34 | class HardPlayer : public AIPlayerBase { 35 | DISALLOW_COPY_AND_ASSIGN(HardPlayer) 36 | public: 37 | explicit HardPlayer(const std::string &name, const IPlayedOutCards *poc); 38 | virtual ~HardPlayer() throw(); 39 | 40 | virtual TYPE getType() const throw() _CONST; 41 | }; 42 | 43 | } 44 | 45 | } 46 | 47 | #endif /* NETMAUMAU_PLAYER_HARDPLAYER_H */ 48 | 49 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 50 | -------------------------------------------------------------------------------- /src/lua/luafatalexception.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_LUA_EXCEPTION_LUAFATALEXCEPTION_H 21 | #define NETMAUMAU_LUA_EXCEPTION_LUAFATALEXCEPTION_H 22 | 23 | #include "luaexception.h" // for LuaException 24 | 25 | namespace NetMauMau { 26 | 27 | namespace Lua { 28 | 29 | namespace Exception { 30 | 31 | class LuaFatalException : public LuaException { 32 | LuaFatalException &operator=(const LuaFatalException &); 33 | public: 34 | LuaFatalException(const LuaFatalException &o) throw(); 35 | explicit LuaFatalException(const std::string &msg, const char *fname = 0L) throw(); 36 | virtual ~LuaFatalException() throw(); 37 | }; 38 | 39 | } 40 | 41 | } 42 | 43 | } 44 | 45 | #endif /* NETMAUMAU_LUA_EXCEPTION_LUAFATALEXCEPTION_H */ 46 | 47 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 48 | -------------------------------------------------------------------------------- /src/ai/powerjackcondition.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "powerjackcondition.h" 21 | 22 | #include "powerjackaction.h" 23 | #include "bestjackaction.h" 24 | 25 | namespace { 26 | const NetMauMau::AI::IActionPtr POWERJACKACTION(new NetMauMau::AI::PowerJackAction()); 27 | const NetMauMau::AI::IActionPtr BESTJACKACTION(new NetMauMau::AI::BestJackAction()); 28 | } 29 | 30 | using namespace NetMauMau::AI; 31 | 32 | PowerJackCondition::PowerJackCondition() throw() : AbstractCondition() {} 33 | 34 | PowerJackCondition::~PowerJackCondition() throw() {} 35 | 36 | IActionPtr 37 | PowerJackCondition::perform(const IAIState &, 38 | const NetMauMau::Player::IPlayer::CARDS &cards) const throw() { 39 | return cards.size() == 1u ? POWERJACKACTION : BESTJACKACTION; 40 | } 41 | 42 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 43 | -------------------------------------------------------------------------------- /src/ai/bestsuitcondition.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "bestsuitcondition.h" 21 | 22 | #include "powersuitaction.h" // for PowerSuitAction 23 | 24 | using namespace NetMauMau::AI; 25 | 26 | BestSuitCondition::BestSuitCondition() throw() : AbstractCondition() {} 27 | 28 | BestSuitCondition::~BestSuitCondition() throw() {} 29 | 30 | IActionPtr 31 | BestSuitCondition::perform(const IAIState &state, 32 | const NetMauMau::Player::IPlayer::CARDS &cards) const throw() { 33 | 34 | if(!state.getCard() && !state.isNoJack() && state.hasPlayerFewCards() && 35 | DecisionBase::count(cards, NetMauMau::Common::ICard::JACK)) { 36 | return IActionPtr(new PowerSuitAction()); 37 | } else { 38 | return IActionPtr(new PowerSuitAction(NetMauMau::Common::ICard::SUIT_ILLEGAL)); 39 | } 40 | } 41 | 42 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 43 | -------------------------------------------------------------------------------- /src/engine/iaceroundlistener.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_ENGINE_IACEROUNDLISTENER_H 21 | #define NETMAUMAU_ENGINE_IACEROUNDLISTENER_H 22 | 23 | #include "inullable.h" 24 | #include "icard.h" 25 | 26 | namespace NetMauMau { 27 | 28 | namespace Player { 29 | class IPlayer; 30 | } 31 | 32 | class IAceRoundListener : public Common::INullable { 33 | DISALLOW_COPY_AND_ASSIGN(IAceRoundListener) 34 | public: 35 | virtual ~IAceRoundListener() {} 36 | 37 | virtual Common::ICard::RANK getAceRoundRank() const = 0; 38 | virtual void aceRoundStarted(const Player::IPlayer *player) const = 0; 39 | virtual void aceRoundEnded(const Player::IPlayer *player) const = 0; 40 | 41 | protected: 42 | explicit IAceRoundListener() : INullable() {} 43 | }; 44 | 45 | } 46 | 47 | #endif /* NETMAUMAU_ENGINE_IACEROUNDLISTENER_H */ 48 | 49 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 50 | -------------------------------------------------------------------------------- /src/engine/nullcardcountobserver.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_NULLCARDCOUNTOBSERVER_H 21 | #define NETMAUMAU_NULLCARDCOUNTOBSERVER_H 22 | 23 | #include "icardcountobserver.h" 24 | #include "smartsingleton.h" 25 | 26 | namespace NetMauMau { 27 | 28 | class NullCardCountObserver : public ICardCountObserver, 29 | public Common::SmartSingleton { 30 | DISALLOW_COPY_AND_ASSIGN(NullCardCountObserver) 31 | friend class Common::SmartSingleton; 32 | public: 33 | virtual ~NullCardCountObserver() throw(); 34 | 35 | virtual bool isNull() const throw() _CONST; 36 | 37 | virtual void cardCountChanged(const Player::IPlayer *player) const throw() _CONST; 38 | 39 | private: 40 | NullCardCountObserver(); 41 | }; 42 | 43 | } 44 | 45 | #endif /* NETMAUMAU_NULLCARDCOUNTOBSERVER_H */ 46 | 47 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 48 | -------------------------------------------------------------------------------- /src/client/interceptederrorexception.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_INTERCEPTEDERROREXCEPTION_H 21 | #define NETMAUMAU_INTERCEPTEDERROREXCEPTION_H 22 | 23 | #include "socketexception.h" 24 | 25 | namespace NetMauMau { 26 | 27 | namespace Client { 28 | 29 | namespace Exception { 30 | 31 | class _EXPORT InterceptedErrorException : public Common::Exception::SocketException { 32 | InterceptedErrorException &operator=(const InterceptedErrorException &); 33 | public: 34 | InterceptedErrorException(const InterceptedErrorException &o) throw(); 35 | explicit InterceptedErrorException(const std::string &msg, 36 | SOCKET sockfd = INVALID_SOCKET) throw(); 37 | virtual ~InterceptedErrorException() throw(); 38 | }; 39 | 40 | } 41 | 42 | } 43 | 44 | } 45 | 46 | #endif /* NETMAUMAU_INTERCEPTEDERROREXCEPTION_H */ 47 | 48 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 49 | -------------------------------------------------------------------------------- /src/common/tcpopt_base.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_COMMON_TCPOPT_BASE_H 21 | #define NETMAUMAU_COMMON_TCPOPT_BASE_H 22 | 23 | #ifdef _WIN32 24 | #include 25 | #define VTYPE DWORD 26 | #else 27 | #define VTYPE int 28 | #endif 29 | 30 | #include "socketexception.h" 31 | 32 | namespace NetMauMau { 33 | 34 | namespace Common { 35 | 36 | class TCPOptBase { 37 | DISALLOW_COPY_AND_ASSIGN(TCPOptBase) 38 | public: 39 | virtual ~TCPOptBase() throw(); 40 | 41 | protected: 42 | TCPOptBase(SOCKET fd, int optname, const char *optStr) throw(); 43 | 44 | private: 45 | // cppcheck-suppress functionStatic 46 | int setOpt(const VTYPE val) const throw(); 47 | 48 | private: 49 | char *m_optStr; 50 | SOCKET m_fd; 51 | int m_optname; 52 | VTYPE m_val; 53 | bool m_ok; 54 | }; 55 | 56 | } 57 | 58 | } 59 | 60 | #endif /* NETMAUMAU_COMMON_TCPOPT_BASE_H */ 61 | 62 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 63 | -------------------------------------------------------------------------------- /src/common/socketexception.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "socketexception.h" 21 | 22 | #include "protocol.h" 23 | 24 | using namespace NetMauMau::Common::Exception; 25 | 26 | SocketException::SocketException(const std::string &msg, SOCKET sfd, int err) throw() : 27 | std::exception(), m_msg(msg), m_sockfd(sfd), m_errno(err) {} 28 | 29 | SocketException::SocketException(const SocketException &o) throw() : m_msg(o.m_msg), 30 | m_sockfd(o.m_sockfd), m_errno(o.m_errno) {} 31 | 32 | SocketException::~SocketException() throw() {} 33 | 34 | const char *SocketException::what() const throw() { 35 | return !m_msg.empty() ? m_msg.c_str() : 36 | NetMauMau::Common::Protocol::V15::ERR_TO_EXC_UNKNOWN.c_str(); 37 | } 38 | 39 | SOCKET SocketException::sockfd() const throw() { 40 | return m_sockfd; 41 | } 42 | 43 | int SocketException::error() const throw() { 44 | return m_errno; 45 | } 46 | 47 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 48 | -------------------------------------------------------------------------------- /src/include/iplayerpiclistener.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_IPLAYERPICHANDLER_H 21 | #define NETMAUMAU_IPLAYERPICHANDLER_H 22 | 23 | #include 24 | 25 | #include "linkercontrol.h" 26 | 27 | namespace NetMauMau { 28 | 29 | namespace Client { 30 | 31 | class IPlayerPicListener { 32 | DISALLOW_COPY_AND_ASSIGN(IPlayerPicListener) 33 | public: 34 | virtual ~IPlayerPicListener() {} 35 | 36 | virtual void beginReceivePlayerPicture(const std::string &player) const throw() = 0; 37 | virtual void endReceivePlayerPicture(const std::string &player) const throw() = 0; 38 | 39 | virtual void uploadSucceded(const std::string &player) const throw() = 0; 40 | virtual void uploadFailed(const std::string &player) const throw() = 0; 41 | 42 | protected: 43 | explicit IPlayerPicListener() {} 44 | }; 45 | 46 | } 47 | 48 | } 49 | 50 | #endif /* NETMAUMAU_IPLAYERPICHANDLER_H */ 51 | 52 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 53 | -------------------------------------------------------------------------------- /src/common/mutexlocker.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "mutexlocker.h" 21 | 22 | namespace NetMauMau { 23 | 24 | namespace Common { 25 | 26 | MutexException::MutexException(const std::string &msg) throw() : m_msg(msg) {} 27 | 28 | MutexException::~MutexException() throw() {} 29 | 30 | const char *MutexException::what() const throw() { 31 | return m_msg.c_str(); 32 | } 33 | 34 | template class MutexBase < pthread_mutex_t, pthread_mutexattr_t, pthread_mutex_init, 35 | pthread_mutex_destroy >; 36 | template class MutexBase < pthread_rwlock_t, pthread_rwlockattr_t, pthread_rwlock_init, 37 | pthread_rwlock_destroy >; 38 | 39 | template class MutexLockerBase; 40 | template class MutexLockerBase; 41 | template class MutexLockerBase; 42 | 43 | } 44 | 45 | } 46 | 47 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 48 | -------------------------------------------------------------------------------- /src/include/shutdownexception.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | /** 21 | * @file 22 | * @author Heiko Schäfer 23 | */ 24 | 25 | #ifndef NETMAUMAU_SHUTDOWNEXCEPTION_H 26 | #define NETMAUMAU_SHUTDOWNEXCEPTION_H 27 | 28 | #include "socketexception.h" 29 | 30 | namespace NetMauMau { 31 | 32 | namespace Client { 33 | 34 | namespace Exception { 35 | 36 | /** 37 | * @ingroup exceptions 38 | * @brief The server is shutting down 39 | * @since 0.4 40 | */ 41 | class _EXPORT ShutdownException : public Common::Exception::SocketException { 42 | ShutdownException &operator=(const ShutdownException &); 43 | public: 44 | ShutdownException(const ShutdownException &o) throw(); 45 | explicit ShutdownException(const std::string &msg, SOCKET sockfd = INVALID_SOCKET) throw(); 46 | virtual ~ShutdownException() throw(); 47 | }; 48 | 49 | } 50 | 51 | } 52 | 53 | } 54 | 55 | #endif /* NETMAUMAU_SHUTDOWNEXCEPTION_H */ 56 | 57 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 58 | -------------------------------------------------------------------------------- /src/engine/serverplayerexception.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_SERVERPLAYEREXCEPTION_H 21 | #define NETMAUMAU_SERVERPLAYEREXCEPTION_H 22 | 23 | #include "socketexception.h" // for INVALID_SOCKET, SOCKET, etc 24 | 25 | namespace NetMauMau { 26 | 27 | namespace Server { 28 | 29 | namespace Exception { 30 | 31 | class ServerPlayerException : public Common::Exception::SocketException { 32 | ServerPlayerException &operator=(const ServerPlayerException &); 33 | public: 34 | ServerPlayerException(const ServerPlayerException &o) throw(); 35 | ServerPlayerException(const std::string &player, const std::string &msg, 36 | SOCKET sockfd = INVALID_SOCKET) throw(); 37 | virtual ~ServerPlayerException() throw(); 38 | 39 | std::string player() const throw(); 40 | 41 | private: 42 | std::string m_player; 43 | }; 44 | 45 | } 46 | 47 | } 48 | 49 | } 50 | 51 | #endif /* NETMAUMAU_SERVERPLAYEREXCEPTION_H */ 52 | 53 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 54 | -------------------------------------------------------------------------------- /m4/m4_ax_cxx_gcc_abi_demangle.m4: -------------------------------------------------------------------------------- 1 | # =========================================================================== 2 | # http://www.gnu.org/software/autoconf-archive/ax_cxx_gcc_abi_demangle.html 3 | # =========================================================================== 4 | # 5 | # SYNOPSIS 6 | # 7 | # AX_CXX_GCC_ABI_DEMANGLE 8 | # 9 | # DESCRIPTION 10 | # 11 | # If the compiler supports GCC C++ ABI name demangling (has header 12 | # cxxabi.h and abi::__cxa_demangle() function), define 13 | # HAVE_GCC_ABI_DEMANGLE 14 | # 15 | # Adapted from AX_CXX_RTTI by Luc Maisonobe 16 | # 17 | # LICENSE 18 | # 19 | # Copyright (c) 2008 Neil Ferguson 20 | # 21 | # Copying and distribution of this file, with or without modification, are 22 | # permitted in any medium without royalty provided the copyright notice 23 | # and this notice are preserved. This file is offered as-is, without any 24 | # warranty. 25 | 26 | #serial 8 27 | 28 | AC_DEFUN([AX_CXX_GCC_ABI_DEMANGLE], 29 | [AC_CACHE_CHECK(whether the compiler supports GCC C++ ABI name demangling, 30 | ax_cv_cxx_gcc_abi_demangle, 31 | [AC_LANG_SAVE 32 | AC_LANG_CPLUSPLUS 33 | AC_TRY_COMPILE([#include 34 | #include 35 | #include 36 | #include 37 | 38 | template 39 | class A {}; 40 | ],[A instance; 41 | int status = 0; 42 | char* c_name = 0; 43 | 44 | c_name = abi::__cxa_demangle(typeid(instance).name(), 0, 0, &status); 45 | 46 | std::string name(c_name); 47 | free(c_name); 48 | 49 | return name == "A"; 50 | ], 51 | ax_cv_cxx_gcc_abi_demangle=yes, ax_cv_cxx_gcc_abi_demangle=no) 52 | AC_LANG_RESTORE 53 | ]) 54 | if test "$ax_cv_cxx_gcc_abi_demangle" = yes; then 55 | AC_DEFINE(HAVE_GCC_ABI_DEMANGLE,1, 56 | [define if the compiler supports GCC C++ ABI name demangling]) 57 | fi 58 | ]) 59 | -------------------------------------------------------------------------------- /src/include/timeoutexception.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | /** 21 | * @file 22 | * @author Heiko Schäfer 23 | */ 24 | 25 | #ifndef NETMAUMAU_TIMEOUTEXCEPTION_H 26 | #define NETMAUMAU_TIMEOUTEXCEPTION_H 27 | 28 | #include "socketexception.h" 29 | 30 | namespace NetMauMau { 31 | 32 | namespace Client { 33 | 34 | /** 35 | * @brief Exceptions thrown by clients 36 | */ 37 | namespace Exception { 38 | 39 | /** 40 | * @ingroup exceptions 41 | * @brief A connection timed out 42 | */ 43 | class _EXPORT TimeoutException : public Common::Exception::SocketException { 44 | TimeoutException &operator=(const TimeoutException &); 45 | public: 46 | TimeoutException(const TimeoutException &o) throw(); 47 | explicit TimeoutException(const std::string &msg, SOCKET sockfd = INVALID_SOCKET) throw(); 48 | virtual ~TimeoutException() throw(); 49 | }; 50 | 51 | } 52 | 53 | } 54 | 55 | } 56 | 57 | #endif /* NETMAUMAU_TIMEOUTEXCEPTION_H */ 58 | 59 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 60 | -------------------------------------------------------------------------------- /src/common/ci_string.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_COMMON_CI_STRING_H 21 | #define NETMAUMAU_COMMON_CI_STRING_H 22 | 23 | #include 24 | 25 | #include "linkercontrol.h" 26 | 27 | namespace NetMauMau { 28 | 29 | namespace Common { 30 | 31 | #pragma GCC diagnostic ignored "-Weffc++" 32 | #pragma GCC diagnostic push 33 | struct _EXPORT ci_char_traits : public std::char_traits { 34 | static bool eq(char_type c1, char_type c2) _PURE; 35 | static bool lt(char_type c1, char_type c2) _PURE; 36 | static int compare(const char_type *s1, const char_type *s2, size_t n) _PURE; 37 | static const char_type *find(const char_type *s, size_t n, char_type a) _PURE; 38 | }; 39 | #pragma GCC diagnostic pop 40 | 41 | typedef std::basic_string ci_string; 42 | 43 | } 44 | 45 | } 46 | 47 | extern template class std::basic_string; 48 | 49 | #endif /* NETMAUMAU_COMMON_CI_STRING_H */ 50 | 51 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 52 | -------------------------------------------------------------------------------- /src/include/playerlistexception.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | /** 21 | * @file 22 | * @author Heiko Schäfer 23 | */ 24 | 25 | #ifndef NETMAUMAU_PLAYERLISTEXCEPTION_H 26 | #define NETMAUMAU_PLAYERLISTEXCEPTION_H 27 | 28 | #include "socketexception.h" 29 | 30 | namespace NetMauMau { 31 | 32 | namespace Client { 33 | 34 | namespace Exception { 35 | 36 | /** 37 | * @ingroup exceptions 38 | * @brief Failure while retrieving player list 39 | * @since 0.4 40 | */ 41 | class _EXPORT PlayerlistException : public Common::Exception::SocketException { 42 | PlayerlistException &operator=(const PlayerlistException &); 43 | public: 44 | PlayerlistException(const PlayerlistException &o) throw(); 45 | explicit PlayerlistException(const std::string &msg, SOCKET sockfd = INVALID_SOCKET) throw(); 46 | virtual ~PlayerlistException() throw(); 47 | }; 48 | 49 | } 50 | 51 | } 52 | 53 | } 54 | 55 | #endif /* NETMAUMAU_PLAYERLISTEXCEPTION_H */ 56 | 57 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 58 | -------------------------------------------------------------------------------- /src/engine/nullaceroundlistener.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_NULLACEROUNDLISTENER_H 21 | #define NETMAUMAU_NULLACEROUNDLISTENER_H 22 | 23 | #include "iaceroundlistener.h" 24 | #include "smartsingleton.h" 25 | 26 | namespace NetMauMau { 27 | 28 | class NullAceRoundListener : public IAceRoundListener, 29 | public Common::SmartSingleton { 30 | DISALLOW_COPY_AND_ASSIGN(NullAceRoundListener) 31 | friend class Common::SmartSingleton; 32 | public: 33 | virtual ~NullAceRoundListener() throw(); 34 | 35 | virtual bool isNull() const throw() _CONST; 36 | 37 | virtual Common::ICard::RANK getAceRoundRank() const _CONST; 38 | 39 | virtual void aceRoundStarted(const Player::IPlayer *player) const _CONST; 40 | virtual void aceRoundEnded(const Player::IPlayer *player) const _CONST; 41 | 42 | private: 43 | NullAceRoundListener(); 44 | }; 45 | 46 | } 47 | 48 | #endif /* NETMAUMAU_NULLACEROUNDLISTENER_H */ 49 | 50 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 51 | -------------------------------------------------------------------------------- /src/ai/decisionbase.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_ENGINE_AI_DECISIONBASE_H 21 | #define NETMAUMAU_ENGINE_AI_DECISIONBASE_H 22 | 23 | #include "iaistate.h" // for IAIState, etc 24 | #include "cardtools.h" 25 | 26 | namespace NetMauMau { 27 | 28 | namespace AI { 29 | 30 | class DecisionBase { 31 | DISALLOW_COPY_AND_ASSIGN(DecisionBase) 32 | public: 33 | virtual ~DecisionBase() throw() _CONST; 34 | 35 | static Player::IPlayer::CARDS removeJack(const Player::IPlayer::CARDS &cards) throw(); 36 | 37 | template 38 | static typename CardType::difference_type count(CardType cards, Tp arg) throw() { 39 | return std::count_if(cards.begin(), cards.end(), std::bind2nd(NetMauMau::Common::equalTo 40 | (), arg)); 41 | } 42 | 43 | protected: 44 | explicit DecisionBase() throw(); 45 | }; 46 | 47 | } 48 | 49 | } 50 | 51 | #endif /* NETMAUMAU_ENGINE_AI_DECISIONBASE_H */ 52 | 53 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 54 | -------------------------------------------------------------------------------- /src/include/gamerunningexception.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | /** 21 | * @file 22 | * @author Heiko Schäfer 23 | */ 24 | 25 | #ifndef NETMAUMAU_GAMERUNNINGEXCEPTION_H 26 | #define NETMAUMAU_GAMERUNNINGEXCEPTION_H 27 | 28 | #include "socketexception.h" 29 | 30 | namespace NetMauMau { 31 | 32 | namespace Client { 33 | 34 | namespace Exception { 35 | 36 | /** 37 | * @ingroup exceptions 38 | * @brief There is already a game running on the server 39 | * @since 0.15 40 | */ 41 | class _EXPORT GameRunningException : public Common::Exception::SocketException { 42 | GameRunningException &operator=(const GameRunningException &); 43 | public: 44 | GameRunningException(const GameRunningException &o) throw(); 45 | explicit GameRunningException(const std::string &msg, SOCKET sockfd = INVALID_SOCKET) throw(); 46 | virtual ~GameRunningException() throw(); 47 | }; 48 | 49 | } 50 | 51 | } 52 | 53 | } 54 | 55 | #endif /* NETMAUMAU_GAMERUNNINGEXCEPTION_H */ 56 | 57 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 58 | -------------------------------------------------------------------------------- /src/ai/binarycondition.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_ENGINE_AI_BINARYCONDITION_H 21 | #define NETMAUMAU_ENGINE_AI_BINARYCONDITION_H 22 | 23 | #include "abstractcondition.h" 24 | 25 | namespace NetMauMau { 26 | 27 | namespace AI { 28 | 29 | class BinaryCondition : public AbstractCondition { 30 | DISALLOW_COPY_AND_ASSIGN(BinaryCondition) 31 | public: 32 | virtual ~BinaryCondition() throw() {} 33 | 34 | protected: 35 | BinaryCondition(const IActionPtr &actTrue, const IActionPtr &actFalse) throw() 36 | : AbstractCondition(), m_trueAction(actTrue), m_falseAction(actFalse) {} 37 | 38 | inline IActionPtr getTrueAction() const throw() { 39 | return m_trueAction; 40 | } 41 | 42 | inline IActionPtr getFalseAction() const throw() { 43 | return m_falseAction; 44 | } 45 | 46 | private: 47 | const IActionPtr m_trueAction; 48 | const IActionPtr m_falseAction; 49 | }; 50 | 51 | } 52 | 53 | } 54 | 55 | #endif /* NETMAUMAU_ENGINE_AI_BINARYCONDITION_H */ 56 | 57 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 58 | -------------------------------------------------------------------------------- /src/ai/staticcondition.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_ENGINE_AI_STATICCONDITION_H 21 | #define NETMAUMAU_ENGINE_AI_STATICCONDITION_H 22 | 23 | #include "abstractcondition.h" 24 | 25 | namespace NetMauMau { 26 | 27 | namespace AI { 28 | 29 | template 30 | class StaticCondition : public AbstractCondition { 31 | DISALLOW_COPY_AND_ASSIGN(StaticCondition) 32 | public: 33 | StaticCondition() throw() : AbstractCondition() {} 34 | 35 | virtual ~StaticCondition() throw() {} 36 | 37 | virtual IActionPtr perform(const IAIState &, const Player::IPlayer::CARDS &) const throw() { 38 | return IActionPtr(new Action()); 39 | } 40 | 41 | #if defined(TRACE_AI) && !defined(NDEBUG) 42 | protected: 43 | inline virtual std::string traceLog() const throw() { 44 | return std::string("StaticCondition (-> ").append(Action().traceLog()).append(1, ')'); 45 | } 46 | #endif 47 | }; 48 | 49 | } 50 | 51 | } 52 | 53 | #endif /* NETMAUMAU_ENGINE_AI_STATICCONDITION_H */ 54 | 55 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 56 | -------------------------------------------------------------------------------- /src/engine/nullconnection.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "nullconnection.h" 21 | 22 | using namespace NetMauMau; 23 | 24 | NullConnection::NullConnection() : Common::IConnection() {} 25 | 26 | NullConnection::~NullConnection() {} 27 | 28 | NullConnection &NullConnection::getInstance() { 29 | static NullConnection instance; 30 | return instance; 31 | } 32 | 33 | bool NullConnection::isNull() const throw() { 34 | return true; 35 | } 36 | 37 | void NullConnection::addAIPlayers(const PLAYERNAMES &) {} 38 | 39 | Common::IConnection::NAMESOCKFD NullConnection::getPlayerInfo(SOCKET) const { 40 | return Common::IConnection::NAMESOCKFD(); 41 | } 42 | 43 | std::string NullConnection::getPlayerName(SOCKET) const { 44 | return std::string(); 45 | } 46 | 47 | bool NullConnection::hasHumanPlayers() const { 48 | return false; 49 | } 50 | 51 | void NullConnection::removePlayer(SOCKET) {} 52 | 53 | void NullConnection::wait(long) throw(Common::Exception::SocketException) {} 54 | 55 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 56 | -------------------------------------------------------------------------------- /src/include/capabilitiesexception.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | /** 21 | * @file 22 | * @author Heiko Schäfer 23 | */ 24 | 25 | #ifndef NETMAUMAU_CAPABILITIESEXCEPTION_H 26 | #define NETMAUMAU_CAPABILITIESEXCEPTION_H 27 | 28 | #include "socketexception.h" 29 | 30 | namespace NetMauMau { 31 | 32 | namespace Client { 33 | 34 | namespace Exception { 35 | 36 | /** 37 | * @ingroup exceptions 38 | * @brief Failure while retrieving capabilities 39 | * @since 0.4 40 | */ 41 | class _EXPORT CapabilitiesException : public Common::Exception::SocketException { 42 | CapabilitiesException &operator=(const CapabilitiesException &); 43 | public: 44 | CapabilitiesException(const CapabilitiesException &o) throw(); 45 | explicit CapabilitiesException(const std::string &msg, SOCKET sockfd = INVALID_SOCKET) throw(); 46 | virtual ~CapabilitiesException() throw(); 47 | }; 48 | 49 | } 50 | 51 | } 52 | 53 | } 54 | 55 | #endif /* NETMAUMAU_CAPABILITIESEXCEPTION_H */ 56 | 57 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 58 | -------------------------------------------------------------------------------- /src/ai/nextaction.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_ENGINE_AI_NEXTACTION_H 21 | #define NETMAUMAU_ENGINE_AI_NEXTACTION_H 22 | 23 | #include "abstractaction.h" // for AbstractAction 24 | 25 | namespace NetMauMau { 26 | 27 | namespace AI { 28 | 29 | class NextAction : public AbstractAction { 30 | DISALLOW_COPY_AND_ASSIGN(NextAction) 31 | public: 32 | explicit NextAction(const IConditionPtr &cond) throw(); 33 | virtual ~NextAction() throw() _CONST; 34 | 35 | virtual const IConditionPtr &perform(IAIState &state, 36 | const Player::IPlayer::CARDS &cards) const throw() _PURE; 37 | #if defined(TRACE_AI) && !defined(NDEBUG) 38 | protected: 39 | inline virtual std::string traceLog() const throw() { 40 | return std::string("NextAction (-> ").append(m_condition->traceLog()).append(1, ')'); 41 | } 42 | #endif 43 | 44 | private: 45 | const IConditionPtr &m_condition; 46 | }; 47 | 48 | } 49 | 50 | } 51 | 52 | #endif /* NETMAUMAU_ENGINE_AI_NEXTACTION_H */ 53 | 54 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 55 | -------------------------------------------------------------------------------- /src/client/clientconnectionimpl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_CLIENTCONNECTIONIMPL_H 21 | #define NETMAUMAU_CLIENTCONNECTIONIMPL_H 22 | 23 | #include 24 | 25 | #include "clientconnection.h" // for Connection, etc 26 | 27 | namespace NetMauMau { 28 | 29 | namespace Client { 30 | 31 | class ConnectionImpl { 32 | DISALLOW_COPY_AND_ASSIGN(ConnectionImpl) 33 | public: 34 | explicit ConnectionImpl(Connection *piface, const std::string &pName, const timeval *timeout, 35 | uint32_t clientVersion); 36 | ~ConnectionImpl(); 37 | 38 | bool hello(uint16_t *maj = 0L, uint16_t *min = 0L) throw(Common::Exception::SocketException); 39 | 40 | public: 41 | typedef std::deque BUFFER; 42 | Connection *const _piface; 43 | 44 | std::string m_pName; 45 | const timeval *m_timeout; 46 | uint32_t m_clientVersion; 47 | BUFFER m_buf; 48 | }; 49 | 50 | } 51 | 52 | } 53 | 54 | #endif /* NETMAUMAU_CLIENTCONNECTIONIMPL_H */ 55 | 56 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 57 | -------------------------------------------------------------------------------- /src/common/zstreambuf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_COMMON_ZSTREAMBUF_H 21 | #define NETMAUMAU_COMMON_ZSTREAMBUF_H 22 | 23 | #include 24 | #include 25 | 26 | #include 27 | 28 | #include "zlibexception.h" 29 | 30 | namespace NetMauMau { 31 | 32 | namespace Common { 33 | 34 | class _EXPORT Zstreambuf : public std::streambuf { 35 | DISALLOW_COPY_AND_ASSIGN(Zstreambuf) 36 | public: 37 | Zstreambuf(const std::ostream &os, int compressionLevel = Z_DEFAULT_COMPRESSION, 38 | bool flush = false) throw(Exception::ZLibException); 39 | virtual ~Zstreambuf(); 40 | 41 | protected: 42 | virtual int sync(); 43 | virtual int_type overflow(int_type); 44 | 45 | private: 46 | int_type deflateBuffer(int flush); 47 | 48 | private: 49 | z_stream m_zstream; 50 | std::streambuf *m_sbuf; 51 | char_type *m_buf; 52 | uLong m_deflateBound; 53 | bool m_flush; 54 | }; 55 | 56 | } 57 | 58 | } 59 | 60 | #endif /* NETMAUMAU_COMMON_ZSTREAMBUF_H */ 61 | 62 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 63 | -------------------------------------------------------------------------------- /src/ai/powersuitcondition.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_ENGINE_AI_POWERSUITCONDITION_H 21 | #define NETMAUMAU_ENGINE_AI_POWERSUITCONDITION_H 22 | 23 | #include "binarycondition.h" // for BinaryCondition 24 | 25 | namespace NetMauMau { 26 | 27 | namespace AI { 28 | 29 | class PowerSuitCondition : public BinaryCondition { 30 | DISALLOW_COPY_AND_ASSIGN(PowerSuitCondition) 31 | public: 32 | explicit PowerSuitCondition() throw(); 33 | explicit PowerSuitCondition(const IActionPtr &actTrue, const IActionPtr &actFalse) throw(); 34 | virtual ~PowerSuitCondition() throw(); 35 | 36 | virtual IActionPtr perform(const IAIState &state, 37 | const Player::IPlayer::CARDS &cards) const throw(); 38 | 39 | #if defined(TRACE_AI) && !defined(NDEBUG) 40 | protected: 41 | inline virtual std::string traceLog() const throw() { 42 | return "PowerSuitCondition"; 43 | } 44 | #endif 45 | }; 46 | 47 | } 48 | 49 | } 50 | 51 | #endif /* NETMAUMAU_ENGINE_AI_POWERSUITCONDITION_H */ 52 | 53 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 54 | -------------------------------------------------------------------------------- /src/include/lostconnectionexception.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | /** 21 | * @file 22 | * @author Heiko Schäfer 23 | */ 24 | 25 | #ifndef NETMAUMAU_LOSTCONNECTIONEXCEPTION_H 26 | #define NETMAUMAU_LOSTCONNECTIONEXCEPTION_H 27 | 28 | #include "socketexception.h" 29 | 30 | namespace NetMauMau { 31 | 32 | namespace Client { 33 | 34 | namespace Exception { 35 | 36 | /** 37 | * @ingroup exceptions 38 | * @brief The server lost a connection to a player 39 | * @since 0.21.1 40 | */ 41 | class _EXPORT LostConnectionException : public Common::Exception::SocketException { 42 | LostConnectionException &operator=(const LostConnectionException &); 43 | public: 44 | LostConnectionException(const LostConnectionException &o) throw(); 45 | explicit LostConnectionException(const std::string &msg, SOCKET sockfd = INVALID_SOCKET) throw(); 46 | virtual ~LostConnectionException() throw(); 47 | }; 48 | 49 | } 50 | 51 | } 52 | 53 | } 54 | 55 | #endif /* NETMAUMAU_LOSTCONNECTIONEXCEPTION_H */ 56 | 57 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 58 | -------------------------------------------------------------------------------- /src/include/protocolerrorexception.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | /** 21 | * @file 22 | * @author Heiko Schäfer 23 | */ 24 | 25 | #ifndef NETMAUMAU_PROTOCOLERROREXCEPTION_H 26 | #define NETMAUMAU_PROTOCOLERROREXCEPTION_H 27 | 28 | #include "socketexception.h" 29 | 30 | namespace NetMauMau { 31 | 32 | namespace Client { 33 | 34 | namespace Exception { 35 | 36 | /** 37 | * @ingroup exceptions 38 | * @brief An error in the protocol transmission occurred 39 | * @since 0.4 40 | */ 41 | class _EXPORT ProtocolErrorException : public Common::Exception::SocketException { 42 | ProtocolErrorException &operator=(const ProtocolErrorException &); 43 | public: 44 | ProtocolErrorException(const ProtocolErrorException &o) throw(); 45 | explicit ProtocolErrorException(const std::string &msg, SOCKET sockfd = INVALID_SOCKET) throw(); 46 | virtual ~ProtocolErrorException() throw(); 47 | }; 48 | 49 | } 50 | 51 | } 52 | 53 | } 54 | 55 | #endif /* NETMAUMAU_PROTOCOLERROREXCEPTION_H */ 56 | 57 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 58 | -------------------------------------------------------------------------------- /src/ai/checksevencondition.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "checksevencondition.h" 21 | 22 | #include "servesevenaction.h" // for ServeSevenAction 23 | #include "skipplayercondition.h" // for SkipPlayerCondition 24 | 25 | namespace { 26 | const NetMauMau::AI::IActionPtr SERVESEVENACTION(new NetMauMau::AI::ServeSevenAction()); 27 | const NetMauMau::AI::IConditionPtr SKIPPLAYERACTION(new NetMauMau::AI::SkipPlayerCondition()); 28 | } 29 | 30 | using namespace NetMauMau::AI; 31 | 32 | CheckSevenCondition::CheckSevenCondition() throw() : AbstractCondition() {} 33 | 34 | CheckSevenCondition::~CheckSevenCondition() throw() {} 35 | 36 | IActionPtr CheckSevenCondition::perform(const IAIState &state, 37 | const NetMauMau::Player::IPlayer::CARDS &) const throw() { 38 | return state.getPlayedOutCards().size() > (4 * state.getTalonFactor()) && 39 | state.getUncoveredCard() == NetMauMau::Common::ICard::SEVEN ? 40 | SERVESEVENACTION : createNextAction(SKIPPLAYERACTION); 41 | } 42 | 43 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 44 | -------------------------------------------------------------------------------- /src/common/tcpopt_cork.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #if defined(HAVE_CONFIG_H) || defined(IN_IDE_PARSER) 21 | #include "config.h" 22 | #endif 23 | 24 | #ifdef HAVE_NETINET_IN_H 25 | #include 26 | #include 27 | #endif 28 | 29 | #include "tcpopt_cork.h" 30 | 31 | #if defined(TCP_NOPUSH) 32 | #define ONAME TCP_NOPUSH 33 | #define ONSTR "TCP_NOPUSH" 34 | #elif defined(TCP_CORK) 35 | #define ONAME TCP_CORK 36 | #define ONSTR "TCP_CORK" 37 | #else 38 | #undef ONAME 39 | #undef ONSTR 40 | #endif 41 | 42 | #if !(defined(ONAME) && defined(ONSTR)) && defined(HAVE_NETINET_IN_H) 43 | #warning "Neither TCP_NOPUSH nor TCP_CORK is available on this platform" 44 | #endif 45 | 46 | using namespace NetMauMau::Common; 47 | 48 | #if defined(ONAME) && defined(ONSTR) 49 | TCPOptCork::TCPOptCork(SOCKET fd) throw() : TCPOptBase(fd, ONAME, ONSTR) {} 50 | #else 51 | TCPOptCork::TCPOptCork(SOCKET) throw() : TCPOptBase(INVALID_SOCKET, 0, "") {} 52 | #endif 53 | 54 | TCPOptCork::~TCPOptCork() throw() {} 55 | 56 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 57 | -------------------------------------------------------------------------------- /src/engine/nullconnection.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_NULLCONNECTION_H 21 | #define NETMAUMAU_NULLCONNECTION_H 22 | 23 | #include "iconnection.h" // for IConnection, etc 24 | 25 | namespace NetMauMau { 26 | 27 | class NullConnection : public Common::IConnection { 28 | DISALLOW_COPY_AND_ASSIGN(NullConnection) 29 | public: 30 | virtual ~NullConnection() _CONST; 31 | 32 | static NullConnection &getInstance(); 33 | 34 | virtual bool isNull() const throw() _CONST; 35 | 36 | virtual NAMESOCKFD getPlayerInfo(SOCKET sockfd) const; 37 | virtual std::string getPlayerName(SOCKET sockfd) const; 38 | virtual void removePlayer(SOCKET sockfd) _CONST; 39 | virtual void addAIPlayers(const PLAYERNAMES &aiPlayers) _CONST; 40 | 41 | virtual bool hasHumanPlayers() const _CONST; 42 | 43 | virtual void wait(long ms) throw(Common::Exception::SocketException) _CONST; 44 | 45 | private: 46 | explicit NullConnection(); 47 | }; 48 | 49 | } 50 | 51 | #endif /* NETMAUMAU_ENGINE_NULLCONNECTION_H */ 52 | 53 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 54 | -------------------------------------------------------------------------------- /src/ai/aceroundcondition.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "aceroundcondition.h" 21 | 22 | #include "aceroundaction.h" // for AceRoundAction 23 | #include "iruleset.h" // for IRuleSet 24 | #include "randomjackcondition.h" // for RandomJackCondition 25 | 26 | namespace { 27 | const NetMauMau::AI::IActionPtr ACEROUNDACTION(new NetMauMau::AI::AceRoundAction()); 28 | const NetMauMau::AI::IConditionPtr RANDOMJACKCOND(new NetMauMau::AI::RandomJackCondition()); 29 | } 30 | 31 | using namespace NetMauMau::AI; 32 | 33 | AceRoundCondition::AceRoundCondition() throw() : AbstractCondition() {} 34 | 35 | AceRoundCondition::~AceRoundCondition() throw() {} 36 | 37 | IActionPtr AceRoundCondition::perform(const IAIState &state, 38 | const NetMauMau::Player::IPlayer::CARDS &) const throw() { 39 | return state.tryAceRound() || (!state.getRuleSet()->isAceRound() && 40 | state.getRuleSet()->isAceRoundPossible()) ? 41 | ACEROUNDACTION : createNextAction(RANDOMJACKCOND); 42 | } 43 | 44 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 45 | -------------------------------------------------------------------------------- /src/ai/jackplusoneaction.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "jackplusoneaction.h" 21 | #include "checksevencondition.h" 22 | 23 | namespace { 24 | const NetMauMau::AI::IConditionPtr CHECKSEVENCOND(new NetMauMau::AI::CheckSevenCondition()); 25 | } 26 | 27 | using namespace NetMauMau::AI; 28 | 29 | JackPlusOneAction::JackPlusOneAction() throw() : AbstractAction() {} 30 | 31 | JackPlusOneAction::~JackPlusOneAction() throw() {} 32 | 33 | const IConditionPtr &JackPlusOneAction::perform(IAIState &state, 34 | const NetMauMau::Player::IPlayer::CARDS &cards) const throw() { 35 | 36 | NetMauMau::Player::IPlayer::CARDS myCards(cards); 37 | 38 | push(myCards.begin(), myCards.end(), NetMauMau::Common::ICard::JACK); 39 | 40 | if(!(myCards.front() == state.getAvoidSuit() || myCards.front() == state.getAvoidRank())) { 41 | 42 | state.setCard(NetMauMau::Common::find(NetMauMau::Common::ICard::JACK, myCards.begin(), 43 | myCards.end())); 44 | return getNullCondition(); 45 | } 46 | 47 | return CHECKSEVENCOND; 48 | } 49 | 50 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 51 | -------------------------------------------------------------------------------- /src/ai/powersuitaction.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_ENGINE_AI_POWERSUITACTION_H 21 | #define NETMAUMAU_ENGINE_AI_POWERSUITACTION_H 22 | 23 | #include "abstractaction.h" // for AbstractAction 24 | 25 | namespace NetMauMau { 26 | 27 | namespace AI { 28 | 29 | class PowerSuitAction : public AbstractAction { 30 | DISALLOW_COPY_AND_ASSIGN(PowerSuitAction) 31 | public: 32 | PowerSuitAction() throw(); 33 | explicit PowerSuitAction(Common::ICard::SUIT suit) throw(); 34 | virtual ~PowerSuitAction() throw() _CONST; 35 | 36 | virtual const IConditionPtr &perform(IAIState &state, 37 | const Player::IPlayer::CARDS &cards) const throw(); 38 | #if defined(TRACE_AI) && !defined(NDEBUG) 39 | protected: 40 | inline virtual std::string traceLog() const throw() { 41 | return "PowerSuitAction"; 42 | } 43 | #endif 44 | 45 | private: 46 | const bool m_determineSuit; 47 | const Common::ICard::SUIT m_suit; 48 | }; 49 | 50 | } 51 | 52 | } 53 | 54 | #endif /* NETMAUMAU_ENGINE_AI_POWERSUITACTION_H */ 55 | 56 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 57 | -------------------------------------------------------------------------------- /src/ai/skipplayercondition.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "skipplayercondition.h" 21 | 22 | #include "bestsuitcondition.h" // for BestSuitCondition 23 | #include "skipplayeraction.h" // for SkipPlayerAction 24 | 25 | namespace { 26 | const NetMauMau::AI::IConditionPtr BESTSUITCOND(new NetMauMau::AI::BestSuitCondition()); 27 | } 28 | 29 | using namespace NetMauMau::AI; 30 | 31 | SkipPlayerCondition::SkipPlayerCondition() throw() : AbstractCondition() {} 32 | 33 | SkipPlayerCondition::~SkipPlayerCondition() throw() {} 34 | 35 | IActionPtr SkipPlayerCondition::perform(const IAIState &state, 36 | const NetMauMau::Player::IPlayer::CARDS &) const throw() { 37 | return state.getPlayerCount() > 2 && (state.getRightCount() < state.getCardCount() || 38 | state.getRightCount() < state.getLeftCount()) && 39 | DecisionBase::count(state.getPlayedOutCards(), NetMauMau::Common::ICard::SEVEN) ? 40 | IActionPtr(new SkipPlayerAction()) : AbstractCondition::createNextAction(BESTSUITCOND); 41 | } 42 | 43 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 44 | -------------------------------------------------------------------------------- /src/test/Makefile.am: -------------------------------------------------------------------------------- 1 | check_PROGRAMS = test_netmaumau 2 | noinst_SCRIPTS = stresstest.sh 3 | 4 | if ENABLE_CLI_CLIENT 5 | bin_PROGRAMS = nmm-client 6 | endif 7 | 8 | if GSL 9 | GSL=-DHAVE_GSL 10 | else 11 | GSL= 12 | endif 13 | 14 | EXTRA_DIST = testimg.png stresstest.sh.in 15 | 16 | DISTCLEANFILES = stresstest.sh testimg.h 17 | 18 | BUILT_SOURCES = testimg.h 19 | 20 | export GSL_RNG_TYPE := ranlxs2 21 | export GSL_RNG_SEED := 280375 22 | export NETMAUMAU_RULES := $(abs_top_srcdir)/src/lua/stdrules.lua 23 | export NMM_NO_TRACE := 1 24 | export NMM_NO_SQLITE := 1 25 | 26 | TESTS = $(check_PROGRAMS) 27 | 28 | noinst_HEADERS = testeventhandler.h testclient.h 29 | 30 | test_netmaumau_CPPFLAGS = $(GSL) 31 | test_netmaumau_CXXFLAGS = -I$(top_srcdir)/src/common -I$(top_srcdir)/src/include \ 32 | -I$(top_srcdir)/src/engine -I$(top_srcdir)/src/ai -I$(top_srcdir)/src/lua \ 33 | -I$(top_srcdir)/src/sqlite 34 | test_netmaumau_SOURCES = test_netmaumau.cpp testeventhandler.cpp 35 | test_netmaumau_LDADD = ../common/libnetmaumaucommon.la ../engine/libengine.la 36 | test_netmaumau_LDFLAGS = -no-install 37 | 38 | if ENABLE_CLI_CLIENT 39 | nmm_client_CPPFLAGS = -DCLIENTVERSION=$(CLIENTVERSION) $(GSL) 40 | nmm_client_CXXFLAGS = -I$(top_srcdir)/src/include -I$(top_srcdir)/src/engine \ 41 | -I$(top_srcdir)/src/common $(GSL_CFLAGS) $(POPT_CFLAGS) 42 | nmm_client_SOURCES = test_client.cpp testclient.cpp 43 | nmm_client_LDADD = ../common/libnetmaumaucommon.la ../client/libnetmaumauclient.la \ 44 | $(POPT_LIBS) $(GSL_LIBS) 45 | endif 46 | 47 | .DELETE_ON_ERROR: 48 | testimg.h: testimg.png 49 | $(AM_V_GEN)$(SHELL) $(top_srcdir)/src/images/create_ai_icon.sh 'test_client_img' $< > $@ 50 | 51 | stresstest.sh: $(top_srcdir)/src/test/stresstest.sh.in 52 | $(AM_V_GEN)$(SED) \ 53 | -e 's|@RULES[@]|$(NETMAUMAU_RULES)|g' \ 54 | -e 's|@SHELL[@]|$(SHELL)|g' \ 55 | -e 's|@check_PROGRAMS[@]|$(abs_builddir)/$(check_PROGRAMS)|g' < $< > $@ 56 | @chmod u+x $@ 57 | -------------------------------------------------------------------------------- /src/ai/iaction.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_ENGINE_AI_IACTION_H 21 | #define NETMAUMAU_ENGINE_AI_IACTION_H 22 | 23 | #if defined(HAVE_CONFIG_H) || defined(IN_IDE_PARSER) 24 | #include "config.h" 25 | #endif 26 | 27 | #if defined(TRACE_AI) && !defined(NDEBUG) 28 | #include 29 | #endif 30 | 31 | #include "linkercontrol.h" 32 | 33 | namespace NetMauMau { 34 | 35 | namespace Common { 36 | template class SmartPtr; 37 | } 38 | 39 | namespace AI { 40 | 41 | class ICondition; 42 | class IAIState; 43 | 44 | class IAction { 45 | DISALLOW_COPY_AND_ASSIGN(IAction) 46 | public: 47 | virtual ~IAction() throw() {} 48 | 49 | virtual const Common::SmartPtr &operator()(IAIState &state) const throw() = 0; 50 | 51 | #if defined(TRACE_AI) && !defined(NDEBUG) 52 | virtual std::string traceLog() const throw() = 0; 53 | #endif 54 | 55 | protected: 56 | IAction() throw() {} 57 | }; 58 | 59 | typedef Common::SmartPtr IActionPtr; 60 | 61 | } 62 | 63 | } 64 | 65 | #endif /* NETMAUMAU_ENGINE_AI_IACTION_H */ 66 | 67 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 68 | -------------------------------------------------------------------------------- /src/common/condition.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_COMMON_CONDITION_H 21 | #define NETMAUMAU_COMMON_CONDITION_H 22 | 23 | #include 24 | 25 | #include "mutex.h" 26 | 27 | namespace NetMauMau { 28 | 29 | namespace Common { 30 | 31 | class _EXPORT Condition { 32 | Condition &operator=(const Condition &); 33 | 34 | template 35 | void wait_internal(typename Commons::RParam::Type m, 36 | typename Commons::RParam

::Type p) { 37 | 38 | while(!p()) { 39 | 40 | const int r = pthread_cond_wait(&m_cond, m); 41 | 42 | if(r) throw MutexException(errorString(r)); 43 | } 44 | } 45 | 46 | public: 47 | Condition(); 48 | Condition(const Condition &o) throw(); 49 | ~Condition() throw(); 50 | 51 | template 52 | inline void wait(const M &m, const P &p) { 53 | wait_internal(m, p); 54 | } 55 | 56 | int signal() throw(); 57 | 58 | private: 59 | pthread_cond_t m_cond; 60 | }; 61 | 62 | } 63 | 64 | } 65 | 66 | #endif /* NETMAUMAU_COMMON_CONDITION_H */ 67 | 68 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 69 | -------------------------------------------------------------------------------- /src/include/nonetmaumauserverexception.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | /** 21 | * @file 22 | * @author Heiko Schäfer 23 | */ 24 | 25 | #ifndef NETMAUMAU_NONETMAUMAUSERVEREXCEPTION_H 26 | #define NETMAUMAU_NONETMAUMAUSERVEREXCEPTION_H 27 | 28 | #include "socketexception.h" 29 | 30 | namespace NetMauMau { 31 | 32 | namespace Client { 33 | 34 | namespace Exception { 35 | 36 | /** 37 | * @ingroup exceptions 38 | * @brief The remote host is not a %NetMauMau server 39 | * @since 0.4 40 | */ 41 | class _EXPORT NoNetMauMauServerException : public Common::Exception::SocketException { 42 | NoNetMauMauServerException &operator=(const NoNetMauMauServerException &); 43 | public: 44 | NoNetMauMauServerException(const NoNetMauMauServerException &o) throw(); 45 | explicit NoNetMauMauServerException(const std::string &msg, 46 | SOCKET sockfd = INVALID_SOCKET) throw(); 47 | virtual ~NoNetMauMauServerException() throw(); 48 | }; 49 | 50 | } 51 | 52 | } 53 | 54 | } 55 | 56 | #endif /* NETMAUMAU_NONETMAUMAUSERVEREXCEPTION_H */ 57 | 58 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 59 | -------------------------------------------------------------------------------- /src/ai/jackplusonecondition.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "jackplusonecondition.h" 21 | 22 | #include "checksevencondition.h" 23 | #include "jackplusoneaction.h" 24 | 25 | namespace { 26 | const NetMauMau::AI::IActionPtr JACKPLUSONEACTION(new NetMauMau::AI::JackPlusOneAction()); 27 | const NetMauMau::AI::IConditionPtr CHECKSEVENCOND(new NetMauMau::AI::CheckSevenCondition()); 28 | } 29 | 30 | using namespace NetMauMau::AI; 31 | 32 | JackPlusOneCondition::JackPlusOneCondition() throw() : AbstractCondition() {} 33 | 34 | JackPlusOneCondition::~JackPlusOneCondition() throw() {} 35 | 36 | IActionPtr JackPlusOneCondition::perform(const IAIState &/*state*/, 37 | const NetMauMau::Player::IPlayer::CARDS &cards) const throw() { 38 | 39 | return (/*state.getPlayerCount() > 2 &&*/ cards.size() == 2u && 40 | !NetMauMau::Common::find(NetMauMau::Common::ICard::SEVEN, cards.begin(), cards.end()) 41 | && NetMauMau::Common::find(NetMauMau::Common::ICard::JACK, cards.begin(), cards.end())) 42 | ? JACKPLUSONEACTION : createNextAction(CHECKSEVENCOND); 43 | } 44 | 45 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 46 | -------------------------------------------------------------------------------- /src/include/connectionrejectedexception.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | /** 21 | * @file 22 | * @author Heiko Schäfer 23 | */ 24 | 25 | #ifndef NETMAUMAU_CONNECTIONREJECTEDEXCEPTION_H 26 | #define NETMAUMAU_CONNECTIONREJECTEDEXCEPTION_H 27 | 28 | #include "socketexception.h" 29 | 30 | namespace NetMauMau { 31 | 32 | namespace Client { 33 | 34 | namespace Exception { 35 | 36 | /** 37 | * @ingroup exceptions 38 | * @brief The connection to the server got rejected 39 | * @since 0.4 40 | */ 41 | class _EXPORT ConnectionRejectedException : public Common::Exception::SocketException { 42 | ConnectionRejectedException &operator=(const ConnectionRejectedException &); 43 | public: 44 | ConnectionRejectedException(const ConnectionRejectedException &o) throw(); 45 | explicit ConnectionRejectedException(const std::string &msg, 46 | SOCKET sockfd = INVALID_SOCKET) throw(); 47 | virtual ~ConnectionRejectedException() throw(); 48 | }; 49 | 50 | } 51 | 52 | } 53 | 54 | } 55 | 56 | #endif /* NETMAUMAU_CONNECTIONREJECTEDEXCEPTION_H */ 57 | 58 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 59 | -------------------------------------------------------------------------------- /src/ai/icondition.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_ENGINE_AI_ICONDITION_H 21 | #define NETMAUMAU_ENGINE_AI_ICONDITION_H 22 | 23 | #if defined(HAVE_CONFIG_H) || defined(IN_IDE_PARSER) 24 | #include "config.h" 25 | #endif 26 | 27 | #if defined(TRACE_AI) && !defined(NDEBUG) 28 | #include 29 | #endif 30 | 31 | #include "linkercontrol.h" 32 | 33 | namespace NetMauMau { 34 | 35 | namespace Common { 36 | template class SmartPtr; 37 | } 38 | 39 | namespace AI { 40 | 41 | class IAction; 42 | class IAIState; 43 | 44 | class ICondition { 45 | DISALLOW_COPY_AND_ASSIGN(ICondition) 46 | public: 47 | virtual ~ICondition() throw() {} 48 | 49 | virtual Common::SmartPtr operator()(const IAIState &state) const throw() = 0; 50 | 51 | #if defined(TRACE_AI) && !defined(NDEBUG) 52 | virtual std::string traceLog() const throw() = 0; 53 | #endif 54 | 55 | protected: 56 | ICondition() throw() {} 57 | }; 58 | 59 | typedef Common::SmartPtr IConditionPtr; 60 | 61 | } 62 | 63 | } 64 | 65 | #endif /* NETMAUMAU_ENGINE_AI_ICONDITION_H */ 66 | 67 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 68 | -------------------------------------------------------------------------------- /src/ai/powersuitcondition.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "powersuitcondition.h" 21 | 22 | #include "aceroundcondition.h" // for AceRoundCondition 23 | #include "powerplayaction.h" // for PowerPlayAction 24 | 25 | namespace { 26 | const NetMauMau::AI::IConditionPtr ACEROUNDCOND(new NetMauMau::AI::AceRoundCondition()); 27 | } 28 | 29 | using namespace NetMauMau::AI; 30 | 31 | PowerSuitCondition::PowerSuitCondition() throw() : BinaryCondition(NetMauMau::AI::IActionPtr 32 | (new NetMauMau::AI::PowerPlayAction()), createNextAction(ACEROUNDCOND)) {} 33 | 34 | PowerSuitCondition::PowerSuitCondition(const IActionPtr &actTrue, 35 | const IActionPtr &actFalse) throw() 36 | : BinaryCondition(actTrue, actFalse) {} 37 | 38 | PowerSuitCondition::~PowerSuitCondition() throw() {} 39 | 40 | IActionPtr PowerSuitCondition::perform(const IAIState &state, 41 | const NetMauMau::Player::IPlayer::CARDS &) const throw() { 42 | return state.getPowerSuit() == NetMauMau::Common::ICard::SUIT_ILLEGAL ? getTrueAction() : 43 | getFalseAction(); 44 | } 45 | 46 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 47 | -------------------------------------------------------------------------------- /src/include/scoresexception.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | /** 21 | * @file 22 | * @author Heiko Schäfer 23 | */ 24 | 25 | #ifndef NETMAUMAU_SCORESEXCEPTION_H 26 | #define NETMAUMAU_SCORESEXCEPTION_H 27 | 28 | #include "socketexception.h" 29 | 30 | namespace NetMauMau { 31 | 32 | namespace Client { 33 | 34 | namespace Exception { 35 | 36 | /** 37 | * @ingroup exceptions 38 | * @brief Failure while retrieving scores 39 | * @since 0.9 40 | * @deprecated This exception is no more thrown nowhere 41 | */ 42 | class _EXPORT _DEPRECATED ScoresException : public Common::Exception::SocketException { 43 | #pragma GCC diagnostic ignored "-Wdeprecated-declarations" 44 | #pragma GCC diagnostic push 45 | ScoresException &operator=(const ScoresException &); 46 | #pragma GCC diagnostic pop 47 | public: 48 | ScoresException(const ScoresException &o) throw(); 49 | explicit ScoresException(const std::string &msg, SOCKET sockfd = INVALID_SOCKET) throw(); 50 | virtual ~ScoresException() throw(); 51 | }; 52 | 53 | } 54 | 55 | } 56 | 57 | } 58 | 59 | #endif /* NETMAUMAU_SCORESEXCEPTION_H */ 60 | 61 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 62 | -------------------------------------------------------------------------------- /src/ai/abstractcondition.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_ENGINE_AI_ABSTRACTCONDITION_H 21 | #define NETMAUMAU_ENGINE_AI_ABSTRACTCONDITION_H 22 | 23 | #include "decisionbase.h" // for DecisionBase 24 | #include "icondition.h" // for ICondition, IConditionPtr 25 | 26 | #include "iaction.h" // for IActionPtr 27 | 28 | namespace NetMauMau { 29 | 30 | namespace AI { 31 | 32 | class AbstractCondition : public ICondition, protected DecisionBase { 33 | DISALLOW_COPY_AND_ASSIGN(AbstractCondition) 34 | public: 35 | virtual ~AbstractCondition() throw() _CONST; 36 | 37 | virtual IActionPtr operator()(const IAIState &state) const throw(); 38 | 39 | protected: 40 | AbstractCondition() throw(); 41 | 42 | virtual IActionPtr perform(const IAIState &state, 43 | const Player::IPlayer::CARDS &cards) const throw() = 0; 44 | 45 | IActionPtr createNextAction(const IConditionPtr &cond) const throw(); 46 | static const IActionPtr &getNullAction() throw() _CONST; 47 | }; 48 | 49 | } 50 | 51 | } 52 | 53 | #endif /* NETMAUMAU_ENGINE_AI_ABSTRACTCONDITION_H */ 54 | 55 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 56 | -------------------------------------------------------------------------------- /src/engine/easyplayer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_PLAYER_EASYPLAYER_H 21 | #define NETMAUMAU_PLAYER_EASYPLAYER_H 22 | 23 | #include "aiplayerbase.h" 24 | 25 | namespace NetMauMau { 26 | 27 | namespace AI { 28 | class JackOnlyCondition; 29 | class PowerJackCondition; 30 | } 31 | 32 | namespace Player { 33 | 34 | class EasyPlayer : public AIPlayerBase { 35 | DISALLOW_COPY_AND_ASSIGN(EasyPlayer) 36 | public: 37 | explicit EasyPlayer(const std::string &name, const IPlayedOutCards *poc); 38 | virtual ~EasyPlayer() throw(); 39 | 40 | virtual TYPE getType() const throw() _CONST; 41 | 42 | virtual Common::ICardPtr requestCard(const Common::ICardPtr &uncoveredCard, 43 | const Common::ICard::SUIT *jackSuit, 44 | std::size_t takeCount, bool noSuspend) const; 45 | 46 | virtual Common::ICard::SUIT getJackChoice(const Common::ICardPtr &uncoveredCard, 47 | const Common::ICardPtr &playedCard) const; 48 | virtual bool getAceRoundChoice() const _CONST; 49 | }; 50 | 51 | } 52 | 53 | } 54 | 55 | #endif /* NETMAUMAU_PLAYER_EASYPLAYER_H */ 56 | 57 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 58 | -------------------------------------------------------------------------------- /src/ai/havejackcondition.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "havejackcondition.h" 21 | 22 | #include "bestjackaction.h" // for BestJackAction 23 | #include "havelessthancondition.h" // for HaveLessThanCondition 24 | #include "jacksuitaction.h" // for JackSuitAction 25 | 26 | namespace { 27 | const NetMauMau::AI::IConditionPtr 28 | HAVELESSTHANEIGHTCOND(new NetMauMau::AI::HaveLessThanCondition<8>( 29 | NetMauMau::AI::IActionPtr(new NetMauMau::AI::BestJackAction()), 30 | NetMauMau::AI::IActionPtr())); 31 | } 32 | 33 | using namespace NetMauMau::AI; 34 | 35 | HaveJackCondition::HaveJackCondition() throw() : AbstractCondition() {} 36 | 37 | HaveJackCondition::~HaveJackCondition() throw() {} 38 | 39 | IActionPtr 40 | HaveJackCondition::perform(const IAIState &state, 41 | const NetMauMau::Player::IPlayer::CARDS &cards) const throw() { 42 | 43 | return (state.getPlayerCards().size() == 2 && 44 | NetMauMau::Common::find(NetMauMau::Common::ICard::JACK, cards.begin(), cards.end())) 45 | ? IActionPtr(new JackSuitAction()) : createNextAction(HAVELESSTHANEIGHTCOND); 46 | } 47 | 48 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 49 | -------------------------------------------------------------------------------- /src/ai/havelessthancondition.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_ENGINE_AI_HAVELESSTHANCONDITION_H 21 | #define NETMAUMAU_ENGINE_AI_HAVELESSTHANCONDITION_H 22 | 23 | #include 24 | 25 | #include "binarycondition.h" 26 | 27 | namespace NetMauMau { 28 | 29 | namespace AI { 30 | 31 | template 32 | class HaveLessThanCondition : public BinaryCondition { 33 | DISALLOW_COPY_AND_ASSIGN(HaveLessThanCondition) 34 | public: 35 | HaveLessThanCondition(const IActionPtr &actTrue, const IActionPtr &actFalse) throw() 36 | : BinaryCondition(actTrue, actFalse) {} 37 | 38 | virtual ~HaveLessThanCondition() throw() {} 39 | 40 | virtual IActionPtr perform(const IAIState &state, 41 | const Player::IPlayer::CARDS &) const throw() { 42 | return state.getPlayerCards().size() < Bound ? getTrueAction() : getFalseAction(); 43 | } 44 | 45 | #if defined(TRACE_AI) && !defined(NDEBUG) 46 | protected: 47 | inline virtual std::string traceLog() const throw() { 48 | return "HaveLessThanCondition"; 49 | } 50 | #endif 51 | }; 52 | 53 | } 54 | 55 | } 56 | 57 | #endif /* NETMAUMAU_ENGINE_AI_HAVELESSTHANCONDITION_H */ 58 | 59 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 60 | -------------------------------------------------------------------------------- /src/include/remoteplayerexception.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | /** 21 | * @file 22 | * @author Heiko Schäfer 23 | */ 24 | 25 | #ifndef NETMAUMAU_CLIENT_EXCEPTION_REMOTEPLAYEREXCEPTION_H 26 | #define NETMAUMAU_CLIENT_EXCEPTION_REMOTEPLAYEREXCEPTION_H 27 | 28 | #include "socketexception.h" // for INVALID_SOCKET, SOCKET, etc 29 | 30 | namespace NetMauMau { 31 | 32 | namespace Client { 33 | 34 | namespace Exception { 35 | 36 | /** 37 | * @ingroup exceptions 38 | * @brief Error in communication wit a remote player 39 | * @since 0.23.6 40 | */ 41 | class _EXPORT RemotePlayerException : public Common::Exception::SocketException { 42 | RemotePlayerException &operator=(const RemotePlayerException &); 43 | public: 44 | RemotePlayerException(const RemotePlayerException &o) throw(); 45 | RemotePlayerException(const std::string &player, const std::string &msg) throw(); 46 | virtual ~RemotePlayerException() throw(); 47 | 48 | std::string player() const throw(); 49 | 50 | private: 51 | std::string m_player; 52 | }; 53 | 54 | } 55 | 56 | } 57 | 58 | } 59 | 60 | #endif /* NETMAUMAU_CLIENT_EXCEPTION_REMOTEPLAYEREXCEPTION_H */ 61 | 62 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 63 | -------------------------------------------------------------------------------- /src/common/select.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_COMMON_SELECT_H 21 | #define NETMAUMAU_COMMON_SELECT_H 22 | 23 | #if defined(HAVE_CONFIG_H) || defined(IN_IDE_PARSER) 24 | #include "config.h" 25 | #endif 26 | 27 | #ifndef _WIN32 28 | #include 29 | #endif 30 | 31 | #include "smartsingleton.h" 32 | 33 | #include "socketexception.h" 34 | 35 | namespace NetMauMau { 36 | 37 | namespace Common { 38 | 39 | class _EXPORT Select : public SmartSingleton; 42 | public: 43 | virtual ~Select() throw(); 44 | 45 | // cppcheck-suppress functionStatic 46 | int perform(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, 47 | struct timeval *timeout, bool blockall = false) const throw(); 48 | 49 | private: 50 | Select() throw(Exception::SocketException); 51 | 52 | private: 53 | #ifdef HAVE_PSELECT 54 | mutable sigset_t m_sigSet; 55 | #else 56 | int m_sigSet; 57 | #endif 58 | }; 59 | 60 | } 61 | 62 | } 63 | 64 | extern template class NetMauMau::Common::SmartSingleton; 65 | 66 | #endif /* NETMAUMAU_COMMON_SELECT_H */ 67 | 68 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 69 | -------------------------------------------------------------------------------- /src/ai/abstractcondition.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "abstractcondition.h" 21 | 22 | #include "nextaction.h" 23 | 24 | #if defined(TRACE_AI) && !defined(NDEBUG) 25 | #include "logger.h" 26 | #endif 27 | 28 | namespace { 29 | const NetMauMau::AI::IActionPtr NULLACTION; 30 | } 31 | 32 | using namespace NetMauMau::AI; 33 | 34 | AbstractCondition::AbstractCondition() throw() : ICondition(), DecisionBase() {} 35 | 36 | AbstractCondition::~AbstractCondition() throw() {} 37 | 38 | IActionPtr AbstractCondition::createNextAction(const IConditionPtr &cond) const throw() { 39 | return IActionPtr(new NextAction(cond)); 40 | } 41 | 42 | const IActionPtr &AbstractCondition::getNullAction() throw() { 43 | return NULLACTION; 44 | } 45 | 46 | IActionPtr AbstractCondition::operator()(const IAIState &state) const throw() { 47 | 48 | #if defined(TRACE_AI) && !defined(NDEBUG) 49 | 50 | if(!std::getenv("NMM_NO_TRACE")) logDebug(" * " << traceLog()); 51 | 52 | #endif 53 | 54 | #ifndef NDEBUG 55 | state.getCardCount(); 56 | #endif 57 | 58 | return perform(state, state.isNoJack() ? DecisionBase::removeJack(state.getPlayerCards()) : 59 | state.getPlayerCards()); 60 | } 61 | 62 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 63 | -------------------------------------------------------------------------------- /src/ai/bestjackaction.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "bestjackaction.h" 21 | 22 | #include "checkjacksuitaction.h" // for CheckJackSuitAction 23 | #include "checksevencondition.h" // for CheckSevenCondition 24 | #include "decisionchain.h" // for DecisionChain 25 | #include "staticcondition.h" // for StaticCondition 26 | 27 | namespace { 28 | const NetMauMau::AI::IConditionPtr 29 | CHECKJACKSUITACTION(new NetMauMau::AI::StaticCondition()); 30 | } 31 | 32 | using namespace NetMauMau::AI; 33 | 34 | BestJackAction::BestJackAction() throw() : AbstractAction() {} 35 | 36 | BestJackAction::~BestJackAction() throw() {} 37 | 38 | const IConditionPtr &BestJackAction::perform(IAIState &state, 39 | const NetMauMau::Player::IPlayer::CARDS &) const throw() { 40 | 41 | state.setCard(); 42 | const NetMauMau::Common::ICardPtr bc(DecisionChain(state). 43 | getCard(NetMauMau::Player::IPlayer::CARDS(), true)); 44 | state.setCard((bc && bc != NetMauMau::Common::ICard::SUIT_ILLEGAL) ? 45 | bc : NetMauMau::Common::ICardPtr()); 46 | 47 | return CHECKJACKSUITACTION; 48 | } 49 | 50 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 51 | -------------------------------------------------------------------------------- /src/ai/servesevenaction.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "servesevenaction.h" 21 | 22 | #include "skipplayercondition.h" // for SkipPlayerCondition 23 | 24 | namespace { 25 | const NetMauMau::AI::IConditionPtr SKIPPLAYERCOND(new NetMauMau::AI::SkipPlayerCondition()); 26 | } 27 | 28 | using namespace NetMauMau::AI; 29 | 30 | ServeSevenAction::ServeSevenAction() throw() : AbstractAction() {} 31 | 32 | ServeSevenAction::~ServeSevenAction() throw() {} 33 | 34 | const IConditionPtr &ServeSevenAction::perform(IAIState &state, 35 | const NetMauMau::Player::IPlayer::CARDS &cards) const throw() { 36 | 37 | const NetMauMau::Player::IPlayer::CARDS::value_type f = 38 | AbstractAction::findRankTryAvoidSuit(NetMauMau::Common::ICard::SEVEN, cards, 39 | state.getAvoidSuit()); 40 | 41 | if(f) { 42 | state.setCard(f); 43 | return AbstractAction::getNullCondition(); 44 | } else if(!state.hasTakenCards()) { 45 | state.setCard(NetMauMau::Common::ICardPtr(const_cast 46 | (NetMauMau::Common::getIllegalCard()))); 47 | state.setCardsTaken(true); 48 | return AbstractAction::getNullCondition(); 49 | } 50 | 51 | return SKIPPLAYERCOND; 52 | } 53 | 54 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 55 | -------------------------------------------------------------------------------- /src/engine/stdcardfactory.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "stdcardfactory.h" 21 | #include "cardtools.h" 22 | 23 | using namespace NetMauMau; 24 | 25 | StdCardFactory::StdCardFactory() throw() : ICardFactory() {} 26 | 27 | StdCardFactory::~StdCardFactory() throw() {} 28 | 29 | Common::ICard *StdCardFactory::create(Common::ICard::SUIT s, Common::ICard::RANK r) const throw() { 30 | return new(std::nothrow) StdCard(s, r); 31 | } 32 | 33 | StdCardFactory::StdCard::StdCard(ICard::SUIT s, ICard::RANK r) throw() : ICard(), m_suit(s), 34 | m_rank(r), m_desc(Common::createCardDesc(m_suit, m_rank, false)), 35 | m_descAnsi(Common::createCardDesc(m_suit, m_rank, true)) {} 36 | 37 | StdCardFactory::StdCard::~StdCard() throw() {} 38 | 39 | Common::ICard::SUIT StdCardFactory::StdCard::getSuit() const throw() { 40 | return m_suit; 41 | } 42 | 43 | Common::ICard::RANK StdCardFactory::StdCard::getRank() const throw() { 44 | return m_rank; 45 | } 46 | 47 | std::size_t StdCardFactory::StdCard::getPoints() const throw() { 48 | return Common::getCardPoints(m_rank); 49 | } 50 | 51 | const std::string &StdCardFactory::StdCard::description(bool ansi) const throw() { 52 | return !ansi ? m_desc : m_descAnsi; 53 | } 54 | 55 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 56 | -------------------------------------------------------------------------------- /src/common/ci_string.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #if defined(HAVE_CONFIG_H) || defined(IN_IDE_PARSER) 21 | #include "config.h" 22 | #endif 23 | 24 | #ifdef HAVE_STRINGS_H 25 | #include 26 | #endif 27 | 28 | #include "ci_string.h" 29 | 30 | using namespace NetMauMau::Common; 31 | 32 | bool ci_char_traits::eq(char_type c1, char_type c2) { 33 | return std::toupper(c1) == std::toupper(c2); 34 | } 35 | 36 | bool ci_char_traits::lt(char_type c1, char_type c2) { 37 | return std::toupper(c1) < std::toupper(c2); 38 | } 39 | 40 | int ci_char_traits::compare(const char_type *s1, const char_type *s2, size_t n) { 41 | 42 | #ifdef HAVE_STRNCASECMP 43 | return strncasecmp(s1, s2, n); 44 | #else 45 | 46 | while(n-- != 0) { 47 | 48 | if(std::toupper(*s1) < std::toupper(*s2)) return -1; 49 | 50 | if(std::toupper(*s1) > std::toupper(*s2)) return 1; 51 | 52 | ++s1; 53 | ++s2; 54 | } 55 | 56 | return 0; 57 | 58 | #endif 59 | } 60 | 61 | const ci_char_traits::char_type *ci_char_traits::find(const char_type *s, size_t n, char_type a) { 62 | 63 | const int ua(std::toupper(a)); 64 | 65 | while(n-- != 0) { 66 | 67 | if(std::toupper(*s) == ua) return s; 68 | 69 | ++s; 70 | } 71 | 72 | return 0L; 73 | } 74 | 75 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 76 | -------------------------------------------------------------------------------- /src/engine/stdcardfactory.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_STDCARDFACTORY_H 21 | #define NETMAUMAU_STDCARDFACTORY_H 22 | 23 | #include // for size_t 24 | 25 | #include "icardfactory.h" // for ICardFactory 26 | 27 | namespace NetMauMau { 28 | 29 | class StdCardFactory : public ICardFactory { 30 | public: 31 | explicit StdCardFactory() throw(); 32 | virtual ~StdCardFactory() throw() _CONST; 33 | 34 | virtual _NOUNUSED Common::ICard *create(Common::ICard::SUIT s, 35 | Common::ICard::RANK r) const throw(); 36 | 37 | private: 38 | class StdCard : public Common::ICard { 39 | DISALLOW_COPY_AND_ASSIGN(StdCard) 40 | public: 41 | explicit StdCard(ICard::SUIT f, ICard::RANK r) throw(); 42 | virtual ~StdCard() throw(); 43 | 44 | virtual SUIT getSuit() const throw() _PURE; 45 | virtual RANK getRank() const throw() _PURE; 46 | virtual std::size_t getPoints() const throw() _PURE; 47 | 48 | virtual const std::string &description(bool ansi) const throw() _CONST; 49 | 50 | private: 51 | const ICard::SUIT m_suit; 52 | const ICard::RANK m_rank; 53 | const std::string m_desc; 54 | const std::string m_descAnsi; 55 | }; 56 | }; 57 | 58 | } 59 | 60 | #endif /* NETMAUMAU_STDCARDFACTORY_H */ 61 | 62 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 63 | -------------------------------------------------------------------------------- /src/common/pathtools.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifdef _WIN32 21 | #include "windows.h" 22 | #include 23 | #endif 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | #include "linkercontrol.h" 30 | #include "pathtools.h" 31 | 32 | namespace NetMauMau _EXPORT { 33 | 34 | namespace Common _EXPORT { 35 | 36 | std::string getModulePath(MPATH mpath, const char *name, const char *ext) throw() { 37 | 38 | #ifdef _WIN32 39 | 40 | TCHAR retPath[MAX_PATH]; 41 | 42 | std::memset(retPath, 0, MAX_PATH); 43 | 44 | if(mpath != USER) { 45 | GetModuleFileName(NULL, retPath, MAX_PATH); 46 | } else { 47 | std::strncpy(retPath, std::getenv("APPDATA"), MAX_PATH); 48 | } 49 | 50 | if(name && ext) { 51 | 52 | char drive[_MAX_DRIVE]; 53 | char dir[_MAX_DIR]; 54 | char fname[_MAX_FNAME]; 55 | char fext[_MAX_EXT]; 56 | 57 | _splitpath(retPath, drive, dir, fname, fext); 58 | _makepath(retPath, drive, dir, name, ext); 59 | } 60 | 61 | #else 62 | char retPath[PATH_MAX]; 63 | std::snprintf(retPath, PATH_MAX, "%s/%s%s%s", mpath == BINDIR ? NMM_EXE_PATH : (mpath == USER ? 64 | std::getenv("HOME") : PKGDATADIR), (name ? name : NMM_EXE_NAME), 65 | (ext && *ext != '.' ? "." : ""), (ext ? ext : (*NMM_EXE_EXT ? NMM_EXE_EXT : ""))); 66 | 67 | #endif 68 | 69 | return std::string(retPath); 70 | } 71 | 72 | } 73 | 74 | } 75 | 76 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 77 | -------------------------------------------------------------------------------- /src/common/errorstring.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2014-2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #if defined(HAVE_CONFIG_H) || defined(IN_IDE_PARSER) 21 | #include "config.h" // for MAXPICBYTES, etc 22 | #endif 23 | 24 | #include "errorstring.h" 25 | 26 | #include // for errno 27 | #include // for strerror 28 | 29 | #ifdef HAVE_NETDB_H 30 | #include // for NI_MAXHOST, NI_MAXSERV, etc 31 | #endif 32 | 33 | #ifdef _WIN32 34 | #include 35 | #include 36 | #endif 37 | 38 | #ifdef _WIN32 39 | namespace { 40 | TCHAR buffer[1024]; 41 | } 42 | #endif 43 | 44 | const char *NetMauMau::Common::errorString() throw() { 45 | #ifndef _WIN32 46 | return errorString(errno); 47 | #else 48 | return errorString(WSAGetLastError()); 49 | #endif 50 | } 51 | 52 | const char *NetMauMau::Common::errorString(int errnum, bool gai) throw() { 53 | #ifndef _WIN32 54 | #ifdef HAVE_NETDB_H 55 | return !gai ? std::strerror(errnum) : gai_strerror(errnum); 56 | #else 57 | return std::strerror(errnum); 58 | #endif 59 | #else 60 | 61 | if(!FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, 62 | errnum, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), buffer, sizeof(buffer), 63 | NULL)) { 64 | return std::strerror(errnum); 65 | } 66 | 67 | return buffer; 68 | 69 | #endif 70 | } 71 | 72 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 73 | -------------------------------------------------------------------------------- /src/server/gamecontext.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #ifndef NETMAUMAU_SERVER_GAMECONTEXT_H 21 | #define NETMAUMAU_SERVER_GAMECONTEXT_H 22 | 23 | #include 24 | 25 | #include "enginecontext.h" 26 | 27 | namespace NetMauMau { 28 | 29 | namespace Event { 30 | class IEventHandler; 31 | } 32 | 33 | namespace Server { 34 | 35 | class GameContext { 36 | GameContext &operator=(const GameContext &); 37 | public: 38 | typedef std::vector AINAMES; 39 | 40 | explicit GameContext(const GameContext &) throw(); 41 | explicit GameContext(Event::IEventHandler &evtHdlr, long aiDelay, bool dirChange, 42 | Common::CARDCONFIG &cc, bool aiPlayer = false, 43 | const AINAMES &aiNames = AINAMES(), char aceRound = 0) throw(); 44 | ~GameContext() throw(); 45 | 46 | inline bool hasAIPlayer() const throw() { 47 | return m_aiPlayer; 48 | } 49 | 50 | inline const AINAMES &getAINames() const throw() { 51 | return m_aiNames; 52 | } 53 | 54 | inline EngineContext &getEngineContext() throw() { 55 | return m_engineCtx; 56 | } 57 | 58 | inline Common::CARDCONFIG &getCardConfig() const throw() { 59 | return m_cardConfig; 60 | } 61 | 62 | private: 63 | const bool m_aiPlayer; 64 | const AINAMES m_aiNames; 65 | EngineContext m_engineCtx; 66 | Common::CARDCONFIG &m_cardConfig; 67 | }; 68 | 69 | } 70 | 71 | } 72 | 73 | #endif /* NETMAUMAU_SERVER_GAMECONTEXT_H */ 74 | 75 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 76 | -------------------------------------------------------------------------------- /src/ai/aceroundaction.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 by Heiko Schäfer 3 | * 4 | * This file is part of NetMauMau. 5 | * 6 | * NetMauMau is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * NetMauMau is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Lesser General Public License 17 | * along with NetMauMau. If not, see . 18 | */ 19 | 20 | #include "aceroundaction.h" 21 | 22 | #include "iruleset.h" // for IRuleSet 23 | #include "randomjackcondition.h" // for RandomJackCondition 24 | 25 | namespace { 26 | const NetMauMau::AI::IConditionPtr RANDOMJACKCOND(new NetMauMau::AI::RandomJackCondition()); 27 | } 28 | 29 | using namespace NetMauMau::AI; 30 | 31 | AceRoundAction::AceRoundAction() throw() : AbstractAction() {} 32 | 33 | AceRoundAction::~AceRoundAction() throw() {} 34 | 35 | const IConditionPtr &AceRoundAction::perform(IAIState &state, 36 | const NetMauMau::Player::IPlayer::CARDS &cards) const throw() { 37 | 38 | if(state.getRuleSet()->isAceRound()) { 39 | state.setCard(AbstractAction::findRankTryAvoidSuit(NetMauMau::Common::ICard::ACE, cards, 40 | state.getAvoidSuit())); 41 | return AbstractAction::getNullCondition(); 42 | } 43 | 44 | NetMauMau::Player::IPlayer::CARDS myCards(cards); 45 | 46 | state.setTryAceRound(DecisionBase::count(myCards, state.getRuleSet()->getAceRoundRank()) > 47 | (state.tryAceRound() ? 0 : 1)); 48 | 49 | if(state.tryAceRound()) { 50 | 51 | AbstractAction::stable_pull(myCards.begin(), myCards.end(), 52 | state.getRuleSet()->getAceRoundRank()); 53 | state.setCard(*myCards.begin()); 54 | 55 | return AbstractAction::getNullCondition(); 56 | } 57 | 58 | return RANDOMJACKCOND; 59 | } 60 | 61 | // kate: indent-mode cstyle; indent-width 4; replace-tabs off; tab-width 4; 62 | --------------------------------------------------------------------------------