summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralejandro-colomar <colomar.6.4.3@gmail.com>2019-06-23 03:48:17 +0200
committeralejandro-colomar <colomar.6.4.3@gmail.com>2019-06-23 03:48:17 +0200
commit3aede2897e53bd0f9a5d6da1da98873fc5e6b42b (patch)
treeaeef406f153550360789b3c21af4bc990a96c90e
parenta5561234338f3bfbe0cda4459b84c8840352650d (diff)
New version: tui/clui only, linux onlyv5-a15-a1
-rwxr-xr-x[-rw-r--r--].gitignore0
-rwxr-xr-x[-rw-r--r--].gitmodules0
-rwxr-xr-x[-rw-r--r--]COPYING.txt0
-rwxr-xr-x[-rw-r--r--]Makefile231
-rwxr-xr-x[-rw-r--r--]README.txt0
-rwxr-xr-x[-rw-r--r--]bin/Makefile66
-rwxr-xr-x[-rw-r--r--]inc/mine-sweeper/about/about.h (renamed from modules/about/inc/about.h)35
-rwxr-xr-x[-rw-r--r--]inc/mine-sweeper/ctrl/start.h (renamed from modules/ctrl/inc/start.h)0
-rwxr-xr-xinc/mine-sweeper/game/core.h109
-rwxr-xr-xinc/mine-sweeper/game/iface.h175
-rwxr-xr-x[-rw-r--r--]inc/mine-sweeper/menu/clui.h (renamed from modules/menu/inc/menu_clui.h)0
-rwxr-xr-x[-rw-r--r--]inc/mine-sweeper/menu/iface.h (renamed from modules/menu/inc/menu_iface.h)20
-rwxr-xr-x[-rw-r--r--]inc/mine-sweeper/menu/parser.h (renamed from modules/menu/inc/parser.h)0
-rwxr-xr-x[-rw-r--r--]inc/mine-sweeper/menu/tui.h (renamed from modules/menu/inc/menu_tui.h)0
-rwxr-xr-x[-rw-r--r--]inc/mine-sweeper/player/clui.h (renamed from modules/player/inc/player_clui.h)57
-rwxr-xr-x[-rw-r--r--]inc/mine-sweeper/player/iface.h (renamed from modules/player/inc/player_iface.h)113
-rwxr-xr-x[-rw-r--r--]inc/mine-sweeper/player/tui.h (renamed from modules/player/inc/player_tui.h)23
-rwxr-xr-x[-rw-r--r--]inc/mine-sweeper/save/save.h (renamed from modules/save/inc/save.h)26
-rwxr-xr-x[-rw-r--r--]inc/mine-sweeper/save/score.h (renamed from modules/menu/inc/menu_gui.h)38
-rwxr-xr-x[-rw-r--r--]inc/mine-sweeper/xyzzy/xyzzy.h (renamed from modules/xyzzy/inc/xyzzy.h)10
m---------libalx0
-rw-r--r--modules/Makefile67
-rw-r--r--modules/about/Makefile24
-rw-r--r--modules/about/src/about.c123
-rw-r--r--modules/about/tmp/Makefile45
-rw-r--r--modules/ctrl/Makefile24
-rw-r--r--modules/ctrl/tmp/Makefile53
-rw-r--r--modules/game/Makefile24
-rw-r--r--modules/game/inc/game_iface.h153
-rw-r--r--modules/game/tmp/Makefile73
-rw-r--r--modules/menu/Makefile24
-rw-r--r--modules/menu/src/menu_gui.c991
-rw-r--r--modules/menu/tmp/Makefile165
-rw-r--r--modules/player/Makefile24
-rw-r--r--modules/player/inc/player_gui.h79
-rw-r--r--modules/player/src/player_gui.c946
-rw-r--r--modules/player/tmp/Makefile102
-rw-r--r--modules/save/Makefile24
-rw-r--r--modules/save/inc/score.h70
-rw-r--r--modules/save/src/save.c255
-rw-r--r--modules/save/src/score.c311
-rw-r--r--modules/save/tmp/Makefile67
-rw-r--r--modules/tmp/Makefile46
-rw-r--r--modules/xyzzy/Makefile24
-rw-r--r--modules/xyzzy/tmp/Makefile45
-rwxr-xr-x[-rw-r--r--]share/mine-sweeper/COPYRIGHT.txt (renamed from share/COPYRIGHT.txt)0
-rwxr-xr-x[-rw-r--r--]share/mine-sweeper/DISCLAIMER.txt (renamed from share/DISCLAIMER.txt)0
-rwxr-xr-x[-rw-r--r--]share/mine-sweeper/HELP.txt (renamed from share/HELP.txt)0
-rwxr-xr-x[-rw-r--r--]share/mine-sweeper/LICENSE.txt (renamed from share/LICENSE.txt)0
-rwxr-xr-x[-rw-r--r--]share/mine-sweeper/README.txt (renamed from share/README.txt)0
-rwxr-xr-x[-rw-r--r--]share/mine-sweeper/USAGE.txt (renamed from share/USAGE.txt)0
-rwxr-xr-x[-rw-r--r--]share/mine-sweeper/saved/saved_000.mine (renamed from share/saved/saved_000.mine)0
-rwxr-xr-x[-rw-r--r--]src/about/about.c (renamed from modules/game/inc/game.h)114
-rwxr-xr-x[-rw-r--r--]src/ctrl/start.c (renamed from modules/ctrl/src/start.c)74
-rwxr-xr-x[-rw-r--r--]src/game/core.c (renamed from modules/game/src/game.c)213
-rwxr-xr-x[-rw-r--r--]src/game/iface.c (renamed from modules/game/src/game_iface.c)63
-rwxr-xr-x[-rw-r--r--]src/main.c45
-rwxr-xr-x[-rw-r--r--]src/menu/clui.c (renamed from modules/menu/src/menu_clui.c)39
-rwxr-xr-x[-rw-r--r--]src/menu/iface.c (renamed from modules/menu/src/menu_iface.c)84
-rwxr-xr-x[-rw-r--r--]src/menu/parser.c (renamed from modules/menu/src/parser.c)31
-rwxr-xr-x[-rw-r--r--]src/menu/tui.c (renamed from modules/menu/src/menu_tui.c)138
-rwxr-xr-x[-rw-r--r--]src/player/clui.c (renamed from modules/player/src/player_clui.c)19
-rwxr-xr-x[-rw-r--r--]src/player/iface.c (renamed from modules/player/src/player_iface.c)54
-rwxr-xr-x[-rw-r--r--]src/player/tui.c (renamed from modules/player/src/player_tui.c)86
-rwxr-xr-xsrc/save/save.c238
-rwxr-xr-xsrc/save/score.c128
-rwxr-xr-x[-rw-r--r--]src/xyzzy/xyzzy.c (renamed from modules/xyzzy/src/xyzzy.c)6
-rwxr-xr-x[-rw-r--r--]tmp/Makefile120
-rwxr-xr-xtmp/about/Makefile53
-rwxr-xr-xtmp/ctrl/Makefile55
-rwxr-xr-xtmp/game/Makefile72
-rwxr-xr-xtmp/menu/Makefile116
-rwxr-xr-xtmp/player/Makefile86
-rwxr-xr-xtmp/save/Makefile74
-rwxr-xr-xtmp/xyzzy/Makefile52
-rwxr-xr-x[-rw-r--r--]var/mine-sweeper/hiscores/beginner.mine (renamed from var/hiscores/hiscores_beginner.mine)0
-rwxr-xr-x[-rw-r--r--]var/mine-sweeper/hiscores/expert.mine (renamed from var/hiscores/hiscores_expert.mine)0
-rwxr-xr-x[-rw-r--r--]var/mine-sweeper/hiscores/intermediate.mine (renamed from var/hiscores/hiscores_intermediate.mine)0
78 files changed, 1980 insertions, 4642 deletions
diff --git a/.gitignore b/.gitignore
index 5ac8469..5ac8469 100644..100755
--- a/.gitignore
+++ b/.gitignore
diff --git a/.gitmodules b/.gitmodules
index 8b3a783..8b3a783 100644..100755
--- a/.gitmodules
+++ b/.gitmodules
diff --git a/COPYING.txt b/COPYING.txt
index 81c77e6..81c77e6 100644..100755
--- a/COPYING.txt
+++ b/COPYING.txt
diff --git a/Makefile b/Makefile
index 0c5d366..1ce22b8 100644..100755
--- a/Makefile
+++ b/Makefile
@@ -1,10 +1,10 @@
-#!/usr/bin/make -f
+#! /usr/bin/make -f
-VERSION = 4
-PATCHLEVEL =
-SUBLEVEL =
-EXTRAVERSION = ~b2
-NAME = graphic
+VERSION = 5
+PATCHLEVEL = ~a1
+SUBLEVEL =
+EXTRAVERSION =
+NAME =
export VERSION
export PATCHLEVEL
@@ -71,125 +71,106 @@ PROGRAMVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(
export PROGRAMVERSION
################################################################################
-OS = linux
-TST = false
-DBG = false
+# directories
+
+MAIN_DIR = $(CURDIR)
+
+LIBALX_DIR = $(CURDIR)/libalx/
+LIBALX_INC_DIR = $(LIBALX_DIR)/inc/
+LIBALX_LIB_DIR = $(LIBALX_DIR)/lib/libalx/
-export OS
-export TST
-export DBG
+BIN_DIR = $(CURDIR)/bin/
+INC_DIR = $(CURDIR)/inc/
+SRC_DIR = $(CURDIR)/src/
+TMP_DIR = $(CURDIR)/tmp/
+
+export MAIN_DIR
+export LIBALX_DIR
+export LIBALX_INC_DIR
+export LIBALX_LIB_DIR
+export BIN_DIR
+export INC_DIR
+export SRC_DIR
+export TMP_DIR
+
+# FIXME: Set local or not local when building a package
+INSTALL_BIN_DIR = /usr/local/bin/
+#INSTALL_BIN_DIR = /usr/bin/
+INSTALL_SHARE_DIR = /usr/local/share/
+#INSTALL_SHARE_DIR = /usr/share/
+INSTALL_VAR_DIR = /var/local/
+#INSTALL_VAR_DIR = /var/lib/
################################################################################
# Make variables (CC, etc...)
- CC = gcc
- AS = as
- AR = ar
- LD = ld
+CC = gcc
+AS = as
+AR = ar
+LD = ld
+SZ = size --format=SysV
export CC
export AS
export AR
export LD
+export SZ
################################################################################
# cflags
-CFLAGS_STD = -std=c11
+CFLAGS_STD = -std=c17
CFLAGS_STD += -Wpedantic
CFLAGS_OPT = -O3
CFLAGS_OPT += -march=native
+CFLAGS_OPT += -flto
CFLAGS_W = -Wall
+CFLAGS_W += -Wextra
+CFLAGS_W += -Wstrict-prototypes
CFLAGS_W += -Werror
-#CFLAGS_W += -Wstrict-prototypes
CFLAGS_W += -Wno-error=format-truncation
#CFLAGS_W += -Wno-error=unused-function
#CFLAGS_W += -Wno-error=unused-parameter
CFLAGS_PKG = `pkg-config --cflags ncurses`
-CFLAGS_PKG += `pkg-config --cflags gtk+-2.0`
+CFLAGS_PKG += -I $(LIBALX_INC_DIR)
CFLAGS_D = -D PROG_VERSION=\"$(PROGRAMVERSION)\"
CFLAGS_D += -D INSTALL_SHARE_DIR=\"$(INSTALL_SHARE_DIR)\"
-CFLAGS_D += -D SHARE_DIR=\"$(SHARE_DIR)\"
CFLAGS_D += -D INSTALL_VAR_DIR=\"$(INSTALL_VAR_DIR)\"
-CFLAGS_D += -D VAR_DIR=\"$(VAR_DIR)\"
-ifeq ($(OS), linux)
- CFLAGS_D += -D OS_LINUX
-else ifeq ($(OS), win)
- CFLAGS_D += -D OS_WIN
-endif
+CFLAGS_I = -I $(INC_DIR)
CFLAGS = $(CFLAGS_STD)
CFLAGS += $(CFLAGS_OPT)
CFLAGS += $(CFLAGS_W)
CFLAGS += $(CFLAGS_PKG)
CFLAGS += $(CFLAGS_D)
+CFLAGS += $(CFLAGS_I)
export CFLAGS
################################################################################
# libs
-LIBS_STATIC = -static
-
LIBS_STD = -l m
+LIBS_OPT = -O3
+LIBS_OPT += -march=native
+LIBS_OPT += -flto
+LIBS_OPT += -fuse-linker-plugin
+
LIBS_PKG = `pkg-config --libs ncurses`
-LIBS_PKG += `pkg-config --libs gtk+-2.0`
-ifeq ($(OS), linux)
- LIBS = $(LIBS_STD) $(LIBS_PKG)
-else ifeq ($(OS), win)
- LIBS = $(LIBS_STD) $(LIBS_STATIC) $(LIBS_PKG)
-endif
+LIBS = $(LIBS_STD)
+LIBS += $(LIBS_OPT)
+LIBS += $(LIBS_PKG)
export LIBS
################################################################################
-# directories
-
-MAIN_DIR = $(CURDIR)
-
-LIBALX_DIR = $(CURDIR)/libalx/
-MODULES_DIR = $(CURDIR)/modules/
-TMP_DIR = $(CURDIR)/tmp/
-BIN_DIR = $(CURDIR)/bin/
-
-export MAIN_DIR
-export LIBALX_DIR
-export MODULES_DIR
-
-# FIXME: Set local or not local when building a package
-ifeq ($(OS), linux)
- INSTALL_BIN_DIR = /usr/local/games/
-# INSTALL_BIN_DIR = /usr/games/
- INSTALL_SHARE_DIR = /usr/local/share/
-# INSTALL_SHARE_DIR = /usr/share/
- SHARE_DIR = mine-sweeper/
- INSTALL_VAR_DIR = /var/local/
-# INSTALL_VAR_DIR = /var/games/
- VAR_DIR = mine-sweeper/
-else ifeq ($(OS), win)
- INSTALL_DIR = c:/Program files (x86)/
- INSTALL_SHARE_DIR = $(INSTALL_DIR)/mine-sweeper/
- SHARE_DIR = share/
- INSTALL_VAR_DIR = $(INSTALL_DIR)/mine-sweeper/
- VAR_DIR = var/
-endif
-
-export INSTALL_DIR
-export INSTALL_SHARE_DIR
-export SHARE_DIR
-
-################################################################################
# executables
-ifeq ($(OS), linux)
- BIN_NAME = mine-sweeper
-else ifeq ($(OS), win)
- BIN_NAME = mine-sweeper.exe
-endif
+BIN_NAME = mine-sweeper
export BIN_NAME
@@ -199,60 +180,52 @@ export BIN_NAME
# That's the default target when none is given on the command line
PHONY := all
-all: libalx modules main binary
+all: bin
PHONY += libalx
libalx:
- @echo ' MAKE libalx'
+ @echo " MAKE $@"
$(Q)$(MAKE) base -C $(LIBALX_DIR)
- $(Q)$(MAKE) io -C $(LIBALX_DIR)
- $(Q)$(MAKE) curses -C $(LIBALX_DIR)
+ $(Q)$(MAKE) ncurses -C $(LIBALX_DIR)
@echo
-PHONY += modules
-modules: libalx
- @echo ' MAKE modules'
- $(Q)$(MAKE) -C $(MODULES_DIR)
+PHONY += tmp
+tmp:
+ @echo " MAKE $@"
+ $(Q)$(MAKE) -C $(TMP_DIR)
@echo
-PHONY += main
-main: libalx modules
- @echo ' MAKE main'
- $(Q)$(MAKE) -C $(TMP_DIR)
- @echo
-
-PHONY += binary
-binary: main
- @echo ' MAKE bin'
- $(Q)$(MAKE) -C $(BIN_DIR)
+PHONY += bin
+bin: tmp libalx
+ @echo " MAKE $@"
+ $(Q)$(MAKE) -C $(BIN_DIR)
@echo
PHONY += install
install: uninstall
@echo " Install:"
- @echo " MKDIR $(INSTALL_BIN_DIR)/"
+ @echo " MKDIR $(DESTDIR)/$(INSTALL_BIN_DIR)/"
$(Q)mkdir -p $(DESTDIR)/$(INSTALL_BIN_DIR)/
- @echo " CP -v $(BIN_NAME)"
+ @echo " CP $(BIN_NAME)"
$(Q)cp -v $(BIN_DIR)/$(BIN_NAME) $(DESTDIR)/$(INSTALL_BIN_DIR)/
- @echo " MKDIR $(INSTALL_SHARE_DIR)/$(SHARE_DIR)/"
- $(Q)mkdir -p $(DESTDIR)/$(INSTALL_SHARE_DIR)/$(SHARE_DIR)/
- @echo " CP -rv share/*"
- $(Q)cp -r -v ./share/* $(DESTDIR)/$(INSTALL_SHARE_DIR)/$(SHARE_DIR)/
-
- @echo " MKDIR $(INSTALL_VAR_DIR)/$(VAR_DIR)/"
- $(Q)mkdir -p $(DESTDIR)/$(INSTALL_VAR_DIR)/$(VAR_DIR)/
- $(Q)mkdir $(DESTDIR)/$(INSTALL_VAR_DIR)/$(VAR_DIR)/boards_beginner/
- $(Q)mkdir $(DESTDIR)/$(INSTALL_VAR_DIR)/$(VAR_DIR)/boards_intermediate/
- $(Q)mkdir $(DESTDIR)/$(INSTALL_VAR_DIR)/$(VAR_DIR)/boards_expert/
- $(Q)mkdir $(DESTDIR)/$(INSTALL_VAR_DIR)/$(VAR_DIR)/boards_custom/
- @echo " CP -rv var/*"
- $(Q)cp -r -v ./var/* $(DESTDIR)/$(INSTALL_VAR_DIR)/$(VAR_DIR)/
- @echo " CHOWN $(INSTALL_VAR_DIR)/$(VAR_DIR)/"
- $(Q)chown root:games -R $(DESTDIR)/$(INSTALL_VAR_DIR)/$(VAR_DIR)/
- @echo " CHMOD $(INSTALL_VAR_DIR)/$(VAR_DIR)/"
- $(Q)chmod 664 -R $(DESTDIR)/$(INSTALL_VAR_DIR)/$(VAR_DIR)/
- $(Q)chmod +X -R $(DESTDIR)/$(INSTALL_VAR_DIR)/$(VAR_DIR)/
+ @echo " MKDIR $(DESTDIR)/$(INSTALL_SHARE_DIR)/mine-sweeper/"
+ $(Q)mkdir -p $(DESTDIR)/$(INSTALL_SHARE_DIR)/mine-sweeper/
+ @echo " CP -r share/mine-sweeper/*"
+ $(Q)cp -r -v ./share/mine-sweeper/* $(DESTDIR)/$(INSTALL_SHARE_DIR)/mine-sweeper/
+ @echo " MKDIR $(DESTDIR)/$(INSTALL_VAR_DIR)/mine-sweeper/"
+ $(Q)mkdir -p $(DESTDIR)/$(INSTALL_VAR_DIR)/mine-sweeper/
+ $(Q)mkdir -p $(DESTDIR)/$(INSTALL_VAR_DIR)/mine-sweeper/boards/beginner/
+ $(Q)mkdir $(DESTDIR)/$(INSTALL_VAR_DIR)/mine-sweeper/boards/intermediate/
+ $(Q)mkdir $(DESTDIR)/$(INSTALL_VAR_DIR)/mine-sweeper/boards/expert/
+ $(Q)mkdir $(DESTDIR)/$(INSTALL_VAR_DIR)/mine-sweeper/boards/custom/
+ @echo " CP -rv var/mine-sweeper/*"
+ $(Q)cp -r -v ./var/mine-sweeper/* $(DESTDIR)/$(INSTALL_VAR_DIR)/mine-sweeper/
+ @echo " CHOWN $(DESTDIR)/$(INSTALL_VAR_DIR)/mine-sweeper/"
+ $(Q)chown root:games -R $(DESTDIR)/$(INSTALL_VAR_DIR)/mine-sweeper/
+ @echo " CHMOD $(DESTDIR)/$(INSTALL_VAR_DIR)/mine-sweeper/"
+ $(Q)chmod 664 -R $(DESTDIR)/$(INSTALL_VAR_DIR)/mine-sweeper/
+ $(Q)chmod +X -R $(DESTDIR)/$(INSTALL_VAR_DIR)/mine-sweeper/
@echo " Done"
@echo
@@ -261,25 +234,22 @@ uninstall:
@echo " Clean old installations:"
@echo " RM bin"
$(Q)rm -f $(DESTDIR)/$(INSTALL_BIN_DIR)/$(BIN_NAME)
- @echo " RM -r $(INSTALL_SHARE_DIR)/$(SHARE_DIR)/"
- $(Q)rm -f -r $(DESTDIR)/$(INSTALL_SHARE_DIR)/$(SHARE_DIR)/
- @echo " RM -r $(INSTALL_VAR_DIR)/$(VAR_DIR)/"
- $(Q)rm -f -r $(DESTDIR)/$(INSTALL_VAR_DIR)/$(VAR_DIR)/
+ @echo " RM -r $(DESTDIR)/$(INSTALL_SHARE_DIR)/mine-sweeper/"
+ $(Q)rm -f -r $(DESTDIR)/$(INSTALL_SHARE_DIR)/mine-sweeper/
+ @echo " RM -r $(DESTDIR)/$(INSTALL_VAR_DIR)/mine-sweeper/"
+ $(Q)rm -f -r $(DESTDIR)/$(INSTALL_VAR_DIR)/mine-sweeper/
@echo " Done"
@echo
PHONY += clean
clean:
- @echo ' CLEAN modules'
- $(Q)$(MAKE) clean -C $(MODULES_DIR)
- @echo ' CLEAN tmp'
- $(Q)$(MAKE) clean -C $(TMP_DIR)
- @echo ' CLEAN bin'
- $(Q)$(MAKE) clean -C $(BIN_DIR)
- @echo
+ @echo " RM *.o *.s *.a $(BIN_NAME)"
+ $(Q)find $(TMP_DIR) -type f -name '*.o' -exec rm '{}' '+'
+ $(Q)find $(TMP_DIR) -type f -name '*.s' -exec rm '{}' '+'
+ $(Q)find $(BIN_DIR) -type f -name '*$(BIN_NAME)' -exec rm '{}' '+'
-PHONY += mrproper
-mrproper: clean
+PHONY += distclean
+distclean: clean
@echo ' CLEAN libalx'
$(Q)$(MAKE) clean -C $(LIBALX_DIR)
@echo
@@ -288,14 +258,13 @@ PHONY += help
help:
@echo 'Cleaning targets:'
@echo ' clean - Remove all generated files'
- @echo ' mrproper - Remove all generated files (including libraries)'
+ @echo ' distclean - Remove all generated files (including libraries)'
@echo ''
@echo 'Other generic targets:'
@echo ' all - Build all targets marked with [*]'
@echo '* libalx - Build the libalx library'
- @echo '* modules - Build all modules'
- @echo '* object - Build the main object'
- @echo '* binary - Build the binary'
+ @echo '* tmp - Compile all files'
+ @echo '* bin - Build the binary'
@echo ' install - Install the program into the filesystem'
@echo ' uninstall - Uninstall the program off the filesystem'
@echo ''
@@ -309,8 +278,6 @@ help:
.PHONY: $(PHONY)
-
-
################################################################################
######## End of file ###########################################################
################################################################################
diff --git a/README.txt b/README.txt
index c399fe2..c399fe2 100644..100755
--- a/README.txt
+++ b/README.txt
diff --git a/bin/Makefile b/bin/Makefile
index 76d6c44..ef72a44 100644..100755
--- a/bin/Makefile
+++ b/bin/Makefile
@@ -1,45 +1,61 @@
-# -*- MakeFile -*-
+#! /usr/bin/make -f
-# directories
-
-LIBALX_LIB_DIR = $(LIBALX_DIR)/lib/
-
-MODULES_TMP_DIR = $(MODULES_DIR)/tmp/
-
-TMP_DIR = $(MAIN_DIR)/tmp/
-
-# dependencies
-_ALL = $(BIN_NAME) $(BIN_NAME).exe
+# MACRO = substitute with this
-ALL = $(BIN_NAME)
+# directories
-MAIN_OBJ_MODULES = modules.o
-MAIN_OBJS = $(TMP_DIR)/main.o \
- $(patsubst %,$(LIBALX_TMP_DIR)/%,$(MAIN_OBJ_LIBALX)) \
- $(patsubst %,$(MODULES_TMP_DIR)/%,$(MAIN_OBJ_MODULES))
+OBJS = \
+ $(TMP_DIR)/main.o \
+ $(TMP_DIR)/about/about.o \
+ $(TMP_DIR)/ctrl/start.o \
+ $(TMP_DIR)/game/core.o \
+ $(TMP_DIR)/game/iface.o \
+ $(TMP_DIR)/menu/parser.o \
+ $(TMP_DIR)/menu/clui.o \
+ $(TMP_DIR)/menu/tui.o \
+ $(TMP_DIR)/menu/iface.o \
+ $(TMP_DIR)/player/clui.o \
+ $(TMP_DIR)/player/tui.o \
+ $(TMP_DIR)/player/iface.o \
+ $(TMP_DIR)/save/save.o \
+ $(TMP_DIR)/save/score.o \
+ $(TMP_DIR)/xyzzy/xyzzy.o
+DEPS_LIBS = \
+ $(LIBALX_LIB_DIR)/libalx-ncurses.a \
+ $(LIBALX_LIB_DIR)/libalx-base.a
+
+ALL = $(BIN_NAME) size
# static libs
-STATIC_LIB_LIBALX = -L $(LIBALX_LIB_DIR) \
- -l alx-curses \
- -l alx-io \
- -l alx-base
-STATIC_LIBS = $(STATIC_LIB_LIBALX)
+STATIC_LIBS = -L $(LIBALX_LIB_DIR) \
+ -l alx-ncurses \
+ -l alx-base
# target: dependencies
# action
+PHONY := all
all: $(ALL)
-$(BIN_NAME): $(MAIN_OBJS)
- @echo " CC $@"
- $(Q)$(CC) $^ -o $@ $(STATIC_LIBS) $(LIBS)
+$(BIN_NAME): $(OBJS) $(DEPS_LIBS)
+ @echo " CC $@"
+ $(Q)$(CC) $(OBJS) -o $@ $(STATIC_LIBS) $(LIBS)
+
+size: $(BIN_NAME)
+ @echo " SZ $(BIN_NAME)"
+ $(Q)$(SZ) $(BIN_NAME)
clean:
- $(Q)rm -f $(_ALL)
+ @echo " RM $(ALL)"
+ $(Q)rm -f $(ALL)
+
+################################################################################
+# Declare the contents of the .PHONY variable as phony.
+.PHONY: $(PHONY)
################################################################################
######## End of file ###########################################################
diff --git a/modules/about/inc/about.h b/inc/mine-sweeper/about/about.h
index 804e4a7..8be4cce 100644..100755
--- a/modules/about/inc/about.h
+++ b/inc/mine-sweeper/about/about.h
@@ -6,47 +6,50 @@
/******************************************************************************
******* include guard ********************************************************
******************************************************************************/
-# ifndef MSW_ABOUT_H
- # define MSW_ABOUT_H
+#ifndef MSW_ABOUT_H
+#define MSW_ABOUT_H
/******************************************************************************
******* headers **************************************************************
******************************************************************************/
- /* FILENAME_MAX */
- #include <stdio.h>
+#include <stdio.h>
/******************************************************************************
******* macros ***************************************************************
******************************************************************************/
- # define PROG_NAME "mine-sweeper"
- # define PROG_YEAR "2015"
+#define PROG_NAME "mine-sweeper"
+#define PROG_YEAR "2015"
+
+#define SHARE_DIR "" INSTALL_SHARE_DIR "/mine-sweeper/"
+#define SHARE_COPYRIGHT_FILE "" SHARE_DIR "/COPYRIGHT.txt"
+#define SHARE_DISCLAIMER_FILE "" SHARE_DIR "/DISCLAIMER.txt"
+#define SHARE_HELP_FILE "" SHARE_DIR "/HELP.txt"
+#define SHARE_LICENSE_FILE "" SHARE_DIR "/LICENSE.txt"
+#define SHARE_USAGE_FILE "" SHARE_DIR "/USAGE.txt"
/******************************************************************************
******* enums ****************************************************************
******************************************************************************/
- enum Share_File {
- SHARE_COPYRIGHT,
- SHARE_DISCLAIMER,
- SHARE_HELP,
- SHARE_LICENSE,
- SHARE_USAGE
- };
+enum Share_File {
+ SHARE_COPYRIGHT,
+ SHARE_DISCLAIMER,
+ SHARE_HELP,
+ SHARE_LICENSE,
+ SHARE_USAGE
+};
/******************************************************************************
******* variables ************************************************************
******************************************************************************/
-extern char share_path [FILENAME_MAX];
/******************************************************************************
******* functions ************************************************************
******************************************************************************/
-void about_init (void);
-void snprint_share_file (char *dest, int destsize, int share_file);
void print_share_file (int share_file);
void print_version (void);
diff --git a/modules/ctrl/inc/start.h b/inc/mine-sweeper/ctrl/start.h
index 224999b..224999b 100644..100755
--- a/modules/ctrl/inc/start.h
+++ b/inc/mine-sweeper/ctrl/start.h
diff --git a/inc/mine-sweeper/game/core.h b/inc/mine-sweeper/game/core.h
new file mode 100755
index 0000000..b07e38f
--- /dev/null
+++ b/inc/mine-sweeper/game/core.h
@@ -0,0 +1,109 @@
+/******************************************************************************
+ * Copyright (C) 2015 Alejandro Colomar Andrés *
+ * SPDX-License-Identifier: GPL-2.0-only *
+ ******************************************************************************/
+
+
+/******************************************************************************
+ ******* include guard ********************************************************
+ ******************************************************************************/
+#ifndef MSW_GAME_CORE_H
+#define MSW_GAME_CORE_H
+
+
+/******************************************************************************
+ ******* headers **************************************************************
+ ******************************************************************************/
+#include <stdbool.h>
+#include <stddef.h>
+
+#include "mine-sweeper/game/iface.h"
+
+
+/******************************************************************************
+ ******* macros ***************************************************************
+ ******************************************************************************/
+
+
+/******************************************************************************
+ ******* enums ****************************************************************
+ ******************************************************************************/
+enum Game_Mine_Board {
+ GAME_MINE_NO = 0,
+ GAME_MINE_YES = 9
+};
+
+enum Game_Usr_Board {
+ GAME_USR_KBOOM = -1,
+ GAME_USR_HIDDEN,
+ GAME_USR_CLEAR,
+ GAME_USR_FLAG,
+ GAME_USR_POSSIBLE
+};
+
+enum Game_Action {
+ GAME_ACT_FOO = 0,
+ GAME_ACT_STEP,
+ GAME_ACT_FLAG,
+ GAME_ACT_FLAG_POSSIBLE,
+ GAME_ACT_RM_FLAG
+};
+
+enum Game_State {
+ GAME_STATE_PLAYING = 0,
+ GAME_STATE_SAFE,
+ GAME_STATE_GAMEOVER
+};
+
+
+
+/******************************************************************************
+ ******* structs / unions *****************************************************
+ ******************************************************************************/
+struct Game_Board {
+ ptrdiff_t rows;
+ ptrdiff_t cols;
+ int mines;
+ int gnd [ROWS_MAX] [COLS_MAX];
+ int usr [ROWS_MAX] [COLS_MAX];
+ int flags;
+ int clr;
+ int state;
+};
+
+
+/******************************************************************************
+ ******* variables ************************************************************
+ ******************************************************************************/
+extern struct Game_Board game_board;
+
+
+/******************************************************************************
+ ******* extern functions *****************************************************
+ ******************************************************************************/
+void game_init (void);
+void game_init_rand (ptrdiff_t rows, ptrdiff_t cols, int mines,
+ ptrdiff_t pos_row, ptrdiff_t pos_col);
+int game_init_load (ptrdiff_t *rows, ptrdiff_t *cols);
+void game_action (int action, ptrdiff_t row, ptrdiff_t col);
+
+
+/******************************************************************************
+ ******* static inline functions (prototypes) *********************************
+ ******************************************************************************/
+
+
+/******************************************************************************
+ ******* static inline functions (definitions) ********************************
+ ******************************************************************************/
+
+
+/******************************************************************************
+ ******* include guard ********************************************************
+ ******************************************************************************/
+#endif /* mine-sweeper/game/core.h */
+
+
+/******************************************************************************
+ ******* end of file **********************************************************
+ ******************************************************************************/
diff --git a/inc/mine-sweeper/game/iface.h b/inc/mine-sweeper/game/iface.h
new file mode 100755
index 0000000..c5c0277
--- /dev/null
+++ b/inc/mine-sweeper/game/iface.h
@@ -0,0 +1,175 @@
+/******************************************************************************
+ * Copyright (C) 2015 Alejandro Colomar Andrés *
+ * SPDX-License-Identifier: GPL-2.0-only *
+ ******************************************************************************/
+
+
+/******************************************************************************
+ ******* include guard ********************************************************
+ ******************************************************************************/
+#ifndef MSW_GAME_IFACE_H
+#define MSW_GAME_IFACE_H
+
+
+/******************************************************************************
+ ******* headers **************************************************************
+ ******************************************************************************/
+#include <stddef.h>
+
+
+/******************************************************************************
+ ******* macros ***************************************************************
+ ******************************************************************************/
+#define ROWS_MAX (999)
+#define COLS_MAX (999)
+#define CHEATED (-1)
+
+#define GAME_IFACE_LVL_BEGINNER_ROWS (8)
+#define GAME_IFACE_LVL_BEGINNER_COLS (8)
+#define GAME_IFACE_LVL_BEGINNER_MINES (10)
+
+#define GAME_IFACE_LVL_INTERMEDIATE_ROWS (16)
+#define GAME_IFACE_LVL_INTERMEDIATE_COLS (16)
+#define GAME_IFACE_LVL_INTERMEDIATE_MINES (40)
+
+#define GAME_IFACE_LVL_EXPERT_ROWS (16)
+#define GAME_IFACE_LVL_EXPERT_COLS (30)
+#define GAME_IFACE_LVL_EXPERT_MINES (99)
+
+
+/******************************************************************************
+ ******* enums ****************************************************************
+ ******************************************************************************/
+enum Game_Iface_Level {
+ GAME_IFACE_LVL_BEGINNER = 0,
+ GAME_IFACE_LVL_INTERMEDIATE,
+ GAME_IFACE_LVL_EXPERT,
+ GAME_IFACE_LVL_EXPERT_INV,
+ GAME_IFACE_LVL_CUSTOM
+};
+
+enum Game_Iface_Visible_Board {
+ GAME_IFACE_VIS_FOO = -1,
+ GAME_IFACE_VIS_KBOOM,
+ GAME_IFACE_VIS_HIDDEN_FIELD,
+ GAME_IFACE_VIS_HIDDEN_MINE,
+ GAME_IFACE_VIS_HIDDEN_SAFE,
+ GAME_IFACE_VIS_SAFE_MINE,
+ GAME_IFACE_VIS_0,
+ GAME_IFACE_VIS_1,
+ GAME_IFACE_VIS_2,
+ GAME_IFACE_VIS_3,
+ GAME_IFACE_VIS_4,
+ GAME_IFACE_VIS_5,
+ GAME_IFACE_VIS_6,
+ GAME_IFACE_VIS_7,
+ GAME_IFACE_VIS_8,
+ GAME_IFACE_VIS_FLAG,
+ GAME_IFACE_VIS_FLAG_FALSE,
+ GAME_IFACE_VIS_POSSIBLE,
+ GAME_IFACE_VIS_POSSIBLE_FALSE
+};
+
+/* Needs to be the same as 'enum Game_Usr_Board' in 'game.h' */
+enum Game_Iface_Usr_Board {
+ GAME_IFACE_USR_KBOOM = -1,
+ GAME_IFACE_USR_HIDDEN,
+ GAME_IFACE_USR_CLEAR,
+ GAME_IFACE_USR_FLAG,
+ GAME_IFACE_USR_POSSIBLE
+};
+
+/* Needs to be the same as 'enum Game_Action' in 'game.h' */
+enum Game_Iface_Action_Play {
+ GAME_IFACE_GAME_ACT_FOO = 0,
+ GAME_IFACE_GAME_ACT_STEP,
+ GAME_IFACE_GAME_ACT_FLAG,
+ GAME_IFACE_GAME_ACT_FLAG_POSSIBLE,
+ GAME_IFACE_GAME_ACT_RM_FLAG
+};
+
+enum Game_Iface_Action {
+ GAME_IFACE_ACT_FOO,
+ GAME_IFACE_ACT_PLAY,
+ GAME_IFACE_ACT_PAUSE,
+ GAME_IFACE_ACT_SAVE,
+ GAME_IFACE_ACT_XYZZY_ON,
+ GAME_IFACE_ACT_XYZZY_OFF,
+ GAME_IFACE_ACT_XYZZY_LIN,
+ GAME_IFACE_ACT_XYZZY_P,
+ GAME_IFACE_ACT_XYZZY_NP,
+ GAME_IFACE_ACT_QUIT
+};
+
+enum Game_Iface_State {
+ GAME_IFACE_STATE_PLAYING,
+ GAME_IFACE_STATE_SAFE,
+ GAME_IFACE_STATE_GAMEOVER,
+
+ GAME_IFACE_STATE_PAUSE,
+ GAME_IFACE_STATE_CHEATED,
+ GAME_IFACE_STATE_XYZZY,
+ GAME_IFACE_STATE_QUIT,
+
+ GAME_IFACE_STATE_FOO
+};
+
+
+/******************************************************************************
+ ******* structs / unions *****************************************************
+ ******************************************************************************/
+struct Game_Iface_Out {
+ ptrdiff_t rows;
+ ptrdiff_t cols;
+ int mines;
+ int visible [ROWS_MAX] [COLS_MAX];
+ int usr [ROWS_MAX] [COLS_MAX];
+ int flags;
+ int clr;
+ int state;
+};
+
+struct Game_Iface_Score {
+ int level;
+ int time;
+ int clicks;
+};
+
+struct Game_Iface_In {
+ int action;
+ int act_game [ROWS_MAX] [COLS_MAX];
+};
+
+
+/******************************************************************************
+ ******* variables ************************************************************
+ ******************************************************************************/
+
+
+/******************************************************************************
+ ******* extern functions *****************************************************
+ ******************************************************************************/
+void game_iface_init_rand(int level, ptrdiff_t pos_row, ptrdiff_t pos_col);
+void game_iface_init_load(void);
+void game_iface (void);
+
+
+/******************************************************************************
+ ******* static inline functions (prototypes) *********************************
+ ******************************************************************************/
+
+
+/******************************************************************************
+ ******* static inline functions (definitions) ********************************
+ ******************************************************************************/
+
+
+/******************************************************************************
+ ******* include guard ********************************************************
+ ******************************************************************************/
+#endif /* mine-sweeper/game/iface.h */
+
+
+/******************************************************************************
+ ******* end of file **********************************************************
+ ******************************************************************************/
diff --git a/modules/menu/inc/menu_clui.h b/inc/mine-sweeper/menu/clui.h
index 69060a5..69060a5 100644..100755
--- a/modules/menu/inc/menu_clui.h
+++ b/inc/mine-sweeper/menu/clui.h
diff --git a/modules/menu/inc/menu_iface.h b/inc/mine-sweeper/menu/iface.h
index 83eeead..ca9200f 100644..100755
--- a/modules/menu/inc/menu_iface.h
+++ b/inc/mine-sweeper/menu/iface.h
@@ -6,14 +6,15 @@
/******************************************************************************
******* include guard ********************************************************
******************************************************************************/
-# ifndef MSW_MENU_IFACE_H
- # define MSW_MENU_IFACE_H
+#ifndef MSW_MENU_IFACE_H
+#define MSW_MENU_IFACE_H
/******************************************************************************
******* headers **************************************************************
******************************************************************************/
- #include <stdbool.h>
+#include <stdbool.h>
+#include <stddef.h>
/******************************************************************************
@@ -31,10 +32,10 @@
******* structs **************************************************************
******************************************************************************/
struct Menu_Iface_Variables {
- int level;
- int rows;
- int cols;
- double p;
+ int level;
+ ptrdiff_t rows;
+ ptrdiff_t cols;
+ double p;
};
@@ -50,9 +51,8 @@ extern struct Menu_Iface_Variables menu_iface_variables;
******* functions ************************************************************
******************************************************************************/
void menu_iface_init (void);
-void menu_iface_init_iface (void);
-void menu_iface_cleanup (void);
-void menu_iface_board (int *level, int *rows, int *cols, int *mines);
+void menu_iface_board (int *level, ptrdiff_t *rows, ptrdiff_t *cols,
+ int *mines);
void menu_iface (void);
diff --git a/modules/menu/inc/parser.h b/inc/mine-sweeper/menu/parser.h
index 38fac23..38fac23 100644..100755
--- a/modules/menu/inc/parser.h
+++ b/inc/mine-sweeper/menu/parser.h
diff --git a/modules/menu/inc/menu_tui.h b/inc/mine-sweeper/menu/tui.h
index 71e3104..71e3104 100644..100755
--- a/modules/menu/inc/menu_tui.h
+++ b/inc/mine-sweeper/menu/tui.h
diff --git a/modules/player/inc/player_clui.h b/inc/mine-sweeper/player/clui.h
index a930918..df02a85 100644..100755
--- a/modules/player/inc/player_clui.h
+++ b/inc/mine-sweeper/player/clui.h
@@ -6,43 +6,43 @@
/******************************************************************************
******* include guard ********************************************************
******************************************************************************/
-# ifndef MSW_PLAYER_CLUI_H
- # define MSW_PLAYER_CLUI_H
+#ifndef MSW_PLAYER_CLUI_H
+#define MSW_PLAYER_CLUI_H
/******************************************************************************
******* headers **************************************************************
******************************************************************************/
- /* struct Game_Iface_... */
- #include "game_iface.h"
+#include <stdio.h>
- #include "player_iface.h"
+#include "mine-sweeper/game/iface.h"
+#include "mine-sweeper/player/iface.h"
/******************************************************************************
******* enums ****************************************************************
******************************************************************************/
- enum Player_CLUI_Char {
- PLAYER_CLUI_CHAR_ERROR = 'X',
- PLAYER_CLUI_CHAR_KBOOM = '#',
- PLAYER_CLUI_CHAR_HIDDEN_FIELD = '+',
- PLAYER_CLUI_CHAR_HIDDEN_MINE = '*',
- PLAYER_CLUI_CHAR_HIDDEN_SAFE = '-',
- PLAYER_CLUI_CHAR_SAFE_MINE = 'v',
- PLAYER_CLUI_CHAR_0 = ' ',
- PLAYER_CLUI_CHAR_1 = '1',
- PLAYER_CLUI_CHAR_2 = '2',
- PLAYER_CLUI_CHAR_3 = '3',
- PLAYER_CLUI_CHAR_4 = '4',
- PLAYER_CLUI_CHAR_5 = '5',
- PLAYER_CLUI_CHAR_6 = '6',
- PLAYER_CLUI_CHAR_7 = '7',
- PLAYER_CLUI_CHAR_8 = '8',
- PLAYER_CLUI_CHAR_FLAG = '!',
- PLAYER_CLUI_CHAR_FLAG_FALSE = 'F',
- PLAYER_CLUI_CHAR_POSSIBLE = '?',
- PLAYER_CLUI_CHAR_POSSIBLE_FALSE = 'f'
- };
+enum Player_CLUI_Char {
+ PLAYER_CLUI_CHAR_ERROR = 'X',
+ PLAYER_CLUI_CHAR_KBOOM = '#',
+ PLAYER_CLUI_CHAR_HIDDEN_FIELD = '+',
+ PLAYER_CLUI_CHAR_HIDDEN_MINE = '*',
+ PLAYER_CLUI_CHAR_HIDDEN_SAFE = '-',
+ PLAYER_CLUI_CHAR_SAFE_MINE = 'v',
+ PLAYER_CLUI_CHAR_0 = ' ',
+ PLAYER_CLUI_CHAR_1 = '1',
+ PLAYER_CLUI_CHAR_2 = '2',
+ PLAYER_CLUI_CHAR_3 = '3',
+ PLAYER_CLUI_CHAR_4 = '4',
+ PLAYER_CLUI_CHAR_5 = '5',
+ PLAYER_CLUI_CHAR_6 = '6',
+ PLAYER_CLUI_CHAR_7 = '7',
+ PLAYER_CLUI_CHAR_8 = '8',
+ PLAYER_CLUI_CHAR_FLAG = '!',
+ PLAYER_CLUI_CHAR_FLAG_FALSE = 'F',
+ PLAYER_CLUI_CHAR_POSSIBLE = '?',
+ PLAYER_CLUI_CHAR_POSSIBLE_FALSE = 'f'
+};
/******************************************************************************
@@ -57,8 +57,9 @@ void player_clui (const struct Game_Iface_Out *board,
const char *title, const char *subtitle,
int *action);
-void player_clui_save_name (const char *fpath, char *fname, int destsize);
-void player_clui_score_name (char *player_name, int destsize);
+void player_clui_save_name (const char *fpath,
+ char fname[static restrict FILENAME_MAX]);
+void player_clui_score_name (char player_name[static restrict BUFSIZ]);
/******************************************************************************
diff --git a/modules/player/inc/player_iface.h b/inc/mine-sweeper/player/iface.h
index d936dc6..79bdb7a 100644..100755
--- a/modules/player/inc/player_iface.h
+++ b/inc/mine-sweeper/player/iface.h
@@ -1,66 +1,74 @@
/******************************************************************************
* Copyright (C) 2015 Alejandro Colomar Andrés *
+ * SPDX-License-Identifier: GPL-2.0-only *
******************************************************************************/
/******************************************************************************
******* include guard ********************************************************
******************************************************************************/
-# ifndef MSW_PLAYER_IFACE_H
- # define MSW_PLAYER_IFACE_H
+#ifndef MSW_PLAYER_IFACE_H
+#define MSW_PLAYER_IFACE_H
/******************************************************************************
******* headers **************************************************************
******************************************************************************/
- /* struct Game_Iface_... */
- #include "game_iface.h"
+#include <stddef.h>
+#include <stdio.h>
+
+#include "mine-sweeper/game/iface.h"
+
+
+/******************************************************************************
+ ******* macros ***************************************************************
+ ******************************************************************************/
/******************************************************************************
******* enums ****************************************************************
******************************************************************************/
- enum Player_Iface_Mode {
- PLAYER_IFACE_FOO = 0,
- PLAYER_IFACE_CLUI,
- PLAYER_IFACE_TUI,
- PLAYER_IFACE_GUI
- };
-
- enum Player_Iface_Action {
- PLAYER_IFACE_ACT_FOO,
- PLAYER_IFACE_ACT_STEP,
- PLAYER_IFACE_ACT_FLAG,
- PLAYER_IFACE_ACT_FLAG_POSSIBLE,
- PLAYER_IFACE_ACT_RM_FLAG,
-
- PLAYER_IFACE_ACT_PAUSE,
- PLAYER_IFACE_ACT_SAVE,
- PLAYER_IFACE_ACT_XYZZY_ON,
- PLAYER_IFACE_ACT_XYZZY_OFF,
- PLAYER_IFACE_ACT_XYZZY_LIN,
- PLAYER_IFACE_ACT_XYZZY_P,
- PLAYER_IFACE_ACT_XYZZY_NP,
- PLAYER_IFACE_ACT_QUIT,
-
- PLAYER_IFACE_ACT_MOVE_UP,
- PLAYER_IFACE_ACT_MOVE_DOWN,
- PLAYER_IFACE_ACT_MOVE_RIGHT,
- PLAYER_IFACE_ACT_MOVE_LEFT,
- PLAYER_IFACE_ACT_HIGHLIGHT
- };
+enum Player_Iface_Mode {
+ PLAYER_IFACE_FOO = 0,
+ PLAYER_IFACE_CLUI,
+ PLAYER_IFACE_TUI,
+ PLAYER_IFACE_GUI
+};
+
+enum Player_Iface_Action {
+ PLAYER_IFACE_ACT_FOO,
+ PLAYER_IFACE_ACT_STEP,
+ PLAYER_IFACE_ACT_FLAG,
+ PLAYER_IFACE_ACT_FLAG_POSSIBLE,
+ PLAYER_IFACE_ACT_RM_FLAG,
+
+ PLAYER_IFACE_ACT_PAUSE,
+ PLAYER_IFACE_ACT_SAVE,
+ PLAYER_IFACE_ACT_XYZZY_ON,
+ PLAYER_IFACE_ACT_XYZZY_OFF,
+ PLAYER_IFACE_ACT_XYZZY_LIN,
+ PLAYER_IFACE_ACT_XYZZY_P,
+ PLAYER_IFACE_ACT_XYZZY_NP,
+ PLAYER_IFACE_ACT_QUIT,
+
+ PLAYER_IFACE_ACT_MOVE_UP,
+ PLAYER_IFACE_ACT_MOVE_DOWN,
+ PLAYER_IFACE_ACT_MOVE_RIGHT,
+ PLAYER_IFACE_ACT_MOVE_LEFT,
+ PLAYER_IFACE_ACT_HIGHLIGHT
+};
/******************************************************************************
- ******* structs **************************************************************
+ ******* structs / unions *****************************************************
******************************************************************************/
- struct Player_Iface_Position {
- int rows;
- int cols;
- int row;
- int col;
- int highlight;
- };
+struct Player_Iface_Position {
+ int rows;
+ int cols;
+ int row;
+ int col;
+ int highlight;
+};
/******************************************************************************
@@ -70,22 +78,33 @@ extern int player_iface_mode;
/******************************************************************************
- ******* functions ************************************************************
+ ******* extern functions *****************************************************
******************************************************************************/
-void player_iface_init (int rows, int cols);
-int player_iface_start (int *row, int *col);
+void player_iface_init (ptrdiff_t rows, ptrdiff_t cols);
+int player_iface_start (ptrdiff_t *row, ptrdiff_t *col);
void player_iface (const struct Game_Iface_Out *out,
const struct Game_Iface_Score *score,
struct Game_Iface_In *in);
-void player_iface_save_name (const char *fpath, char *fname, int destsize);
-void player_iface_score_name (char *player_name, int destsize);
+void player_iface_save_name (const char *fpath,
+ char fname[static restrict FILENAME_MAX]);
+void player_iface_score_name (char player_name[static restrict BUFSIZ]);
void player_iface_cleanup (void);
/******************************************************************************
+ ******* static inline functions (prototypes) *********************************
+ ******************************************************************************/
+
+
+/******************************************************************************
+ ******* static inline functions (definitions) ********************************
+ ******************************************************************************/
+
+
+/******************************************************************************
******* include guard ********************************************************
******************************************************************************/
-# endif /* player_iface.h */
+#endif /* mine-sweeper/player/iface.h */
/******************************************************************************
diff --git a/modules/player/inc/player_tui.h b/inc/mine-sweeper/player/tui.h
index 4af3cae..71ae32d 100644..100755
--- a/modules/player/inc/player_tui.h
+++ b/inc/mine-sweeper/player/tui.h
@@ -6,21 +6,19 @@
/******************************************************************************
******* include guard ********************************************************
******************************************************************************/
-# ifndef MSW_PLAYER_TUI_H
- # define MSW_PLAYER_TUI_H
+#ifndef MSW_PLAYER_TUI_H
+#define MSW_PLAYER_TUI_H
/******************************************************************************
******* headers **************************************************************
******************************************************************************/
-/* Standard C ----------------------------------------------------------------*/
- #include <stdbool.h>
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdio.h>
-/* Project -------------------------------------------------------------------*/
- /* struct Game_Iface_... */
- #include "game_iface.h"
-
- #include "player_iface.h"
+#include "mine-sweeper/game/iface.h"
+#include "mine-sweeper/player/iface.h"
/******************************************************************************
@@ -87,7 +85,7 @@ extern bool flag_color;
/******************************************************************************
******* functions ************************************************************
******************************************************************************/
-void player_tui_init (int rows, int cols);
+void player_tui_init (ptrdiff_t rows, ptrdiff_t cols);
int player_tui_start (const struct Player_Iface_Position *position,
const char *title, const char *subtitle,
@@ -98,8 +96,9 @@ int player_tui (const struct Game_Iface_Out *board,
const char *title, const char *subtitle,
int *action);
-void player_tui_save_name (const char *fpath, char *fname, int destsize);
-void player_tui_score_name (char *player_name, int destsize);
+void player_tui_save_name (const char *fpath,
+ char fname[static restrict FILENAME_MAX]);
+void player_tui_score_name (char player_name[static restrict BUFSIZ]);
void player_tui_cleanup (void);
diff --git a/modules/save/inc/save.h b/inc/mine-sweeper/save/save.h
index d2dee37..b50cbad 100644..100755
--- a/modules/save/inc/save.h
+++ b/inc/mine-sweeper/save/save.h
@@ -6,32 +6,26 @@
/******************************************************************************
******* include guard ********************************************************
******************************************************************************/
-# ifndef MSW_SAVE_H
- # define MSW_SAVE_H
+#ifndef MSW_SAVE_H
+#define MSW_SAVE_H
/******************************************************************************
******* headers **************************************************************
******************************************************************************/
- /* bool */
- #include <stdbool.h>
- /* FILENAME_MAX */
- #include <stdio.h>
+#include <stdbool.h>
+#include <stdio.h>
/******************************************************************************
******* macros ***************************************************************
******************************************************************************/
- # if defined (OS_LINUX)
- # define ENV_HOME "HOME"
- # elif defined (OS_WIN)
- # define ENV_HOME "USERPROFILE"
- # endif
+#define ENV_HOME "HOME"
- # define USER_GAME_DIR ".mine-sweeper/"
- # define USER_SAVED_DIR ".mine-sweeper/saved/"
- # define SAVED_NAME_DEFAULT "saved"
- # define FILE_EXTENSION ".mine"
+#define USER_GAME_DIR ".mine-sweeper/"
+#define USER_SAVED_DIR ".mine-sweeper/saved/"
+#define SAVED_NAME_DEFAULT "saved"
+#define FILE_EXTENSION ".mine"
/******************************************************************************
@@ -48,7 +42,7 @@ extern char saved_name [FILENAME_MAX];
******************************************************************************/
void save_init (void);
void save_clr (void);
-void load_game_file (void);
+int load_game_file (void);
void save_game_file (char *filepath);
diff --git a/modules/menu/inc/menu_gui.h b/inc/mine-sweeper/save/score.h
index 4269cdc..41ecb96 100644..100755
--- a/modules/menu/inc/menu_gui.h
+++ b/inc/mine-sweeper/save/score.h
@@ -6,49 +6,55 @@
/******************************************************************************
******* include guard ********************************************************
******************************************************************************/
-# ifndef MSW_MENU_GUI_H
- # define MSW_MENU_GUI_H
+#ifndef MSW_SCORE_H
+#define MSW_SCORE_H
/******************************************************************************
******* headers **************************************************************
******************************************************************************/
- /* GtkWidget */
- #include <gtk/gtk.h>
+#include <stdio.h>
+
+#include "mine-sweeper/game/iface.h"
/******************************************************************************
******* macros ***************************************************************
******************************************************************************/
- # define ROWS_GUI_MAX (22)
-#if (ROWS_GUI_MAX > ROWS_MAX)
-# error "rows max (gui)"
+#if defined (OS_LINUX)
+# define ENV_HOME "HOME"
+#elif defined (OS_WIN)
+# define ENV_HOME "USERPROFILE"
#endif
- # define COLS_GUI_MAX (33)
-#if (COLS_GUI_MAX > COLS_MAX)
-# error "cols max (gui)"
-#endif
+#define VAR_DIR "" INSTALL_VAR_DIR "/mine-sweeper/"
+#define BOARDS_DIR "" VAR_DIR "/boards/"
+#define HISCORES_DIR "" VAR_DIR "/hiscores/"
+#define BOARDS_BEGINNER_DIR "" VAR_DIR "/boards/beginner/"
+#define BOARDS_INTERMEDIATE_DIR "" VAR_DIR "/boards/intermediate/"
+#define BOARDS_EXPERT_DIR "" VAR_DIR "/boards/expert/"
+#define BOARDS_CUSTOM_DIR "" VAR_DIR "/boards/custom/"
+#define HISCORES_BEGINNER_FILE "" VAR_DIR "/hiscores/beginner.mine"
+#define HISCORES_INTERMEDIATE_FILE "" VAR_DIR "/hiscores/intermediate.mine"
+#define HISCORES_EXPERT_FILE "" VAR_DIR "/hiscores/expert.mine"
/******************************************************************************
******* variables ************************************************************
******************************************************************************/
-extern GtkWidget *window_gui;
/******************************************************************************
******* functions ************************************************************
******************************************************************************/
- void menu_gui_init (void);
- void menu_gui_cleanup (void);
- void menu_gui (void);
+void save_score (const struct Game_Iface_Score *game_iface_score);
+void print_scores (void);
/******************************************************************************
******* include guard ********************************************************
******************************************************************************/
-# endif /* menu_gui.h */
+# endif /* score.h */
/******************************************************************************
diff --git a/modules/xyzzy/inc/xyzzy.h b/inc/mine-sweeper/xyzzy/xyzzy.h
index e81d5e9..fac022a 100644..100755
--- a/modules/xyzzy/inc/xyzzy.h
+++ b/inc/mine-sweeper/xyzzy/xyzzy.h
@@ -6,8 +6,14 @@
/******************************************************************************
******* include guard ********************************************************
******************************************************************************/
-# ifndef MSW_XYZZY_H
- # define MSW_XYZZY_H
+#ifndef MSW_XYZZY_H
+#define MSW_XYZZY_H
+
+
+/******************************************************************************
+ ******* headers **************************************************************
+ ******************************************************************************/
+#include "mine-sweeper/game/iface.h"
/******************************************************************************
diff --git a/libalx b/libalx
-Subproject be176601c4928dceeb952c1f4810389c5e5a530
+Subproject b23423ffcdff33d007fd1faa4474aac9b1ef939
diff --git a/modules/Makefile b/modules/Makefile
deleted file mode 100644
index 4b389d4..0000000
--- a/modules/Makefile
+++ /dev/null
@@ -1,67 +0,0 @@
-# -*- MakeFile -*-
-
-# MACRO = substitute with this
-
-# directories
-
-ABOUT_DIR = $(MODULES_DIR)/about/
-CTRL_DIR = $(MODULES_DIR)/ctrl/
-GAME_DIR = $(MODULES_DIR)/game/
-MENU_DIR = $(MODULES_DIR)/menu/
-PLAY_DIR = $(MODULES_DIR)/player/
-SAVE_DIR = $(MODULES_DIR)/save/
-XYZZY_DIR = $(MODULES_DIR)/xyzzy/
-
-TMP_DIR = $(MODULES_DIR)/tmp/
-
-export ABOUT_DIR
-export CTRL_DIR
-export GAME_DIR
-export MENU_DIR
-export PLAY_DIR
-export SAVE_DIR
-export XYZZY_DIR
-
-# dependencies
-
-
-# target: dependencies
-# action
-
-PHONY := all
-all:
- @echo ' MAKE modules: about'
- $(Q)$(MAKE) -C $(ABOUT_DIR)
- @echo ' MAKE modules: ctrl'
- $(Q)$(MAKE) -C $(CTRL_DIR)
- @echo ' MAKE modules: game'
- $(Q)$(MAKE) -C $(GAME_DIR)
- @echo ' MAKE modules: menu'
- $(Q)$(MAKE) -C $(MENU_DIR)
- @echo ' MAKE modules: play'
- $(Q)$(MAKE) -C $(PLAY_DIR)
- @echo ' MAKE modules: save'
- $(Q)$(MAKE) -C $(SAVE_DIR)
- @echo ' MAKE modules: xyzzy'
- $(Q)$(MAKE) -C $(XYZZY_DIR)
- @echo ' MAKE modules: tmp'
- $(Q)$(MAKE) -C $(TMP_DIR)
-
-
-PHONY += clean
-clean:
- @echo ' RM *.o *.s *.a'
- $(Q)find . -type f -name '*.o' -exec rm '{}' '+'
- $(Q)find . -type f -name '*.s' -exec rm '{}' '+'
- $(Q)find . -type f -name '*.a' -exec rm '{}' '+'
-
-################################################################################
-# Declare the contents of the .PHONY variable as phony.
-.PHONY: $(PHONY)
-
-
-
-
-################################################################################
-######## End of file ###########################################################
-################################################################################
diff --git a/modules/about/Makefile b/modules/about/Makefile
deleted file mode 100644
index 42eb4c2..0000000
--- a/modules/about/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-# -*- MakeFile -*-
-
-# MACRO = substitute with this
-
-# directories
-
-TMP_DIR = $(ABOUT_DIR)/tmp/
-
-# target: dependencies
-# action
-
-all:
- $(Q)cd $(TMP_DIR) && $(MAKE) && cd ..
-
-clean:
- $(Q)cd $(TMP_DIR) && $(MAKE) clean && cd ..
-
-################################################################################
-######## End of file ###########################################################
-################################################################################
-######## End of file ###########################################################
-################################################################################
-######## End of file ###########################################################
-################################################################################
diff --git a/modules/about/src/about.c b/modules/about/src/about.c
deleted file mode 100644
index bc21f3e..0000000
--- a/modules/about/src/about.c
+++ /dev/null
@@ -1,123 +0,0 @@
-/******************************************************************************
- * Copyright (C) 2015 Alejandro Colomar Andrés *
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* headers **************************************************************
- ******************************************************************************/
-/* Standard C ----------------------------------------------------------------*/
- #include <stdio.h>
- #include <stdlib.h>
-/* libalx ------------------------------------------------------------------*/
- #include "libalx/io/alx_file.h"
-/* Project -------------------------------------------------------------------*/
- #include "about.h"
-
-
-/******************************************************************************
- ******* macros ***************************************************************
- ******************************************************************************/
- # define BUFF_SIZE_TEXT (1048576)
-
-#if defined OS_LINUX
- # define BEGINNING "\n┌──────────────────────────────────────────────────────────────────────────────┐\n"
- # define ENDING "└──────────────────────────────────────────────────────────────────────────────┘\n\n"
-#elif defined OS_WIN
- # define BEGINNING "\n________________________________________________________________________________\n"
- # define ENDING "________________________________________________________________________________\n\n"
-#endif
-
-
-/******************************************************************************
- ******* variables ************************************************************
- ******************************************************************************/
-char share_path [FILENAME_MAX];
-
-
-/******************************************************************************
- ******* main *****************************************************************
- ******************************************************************************/
-void about_init (void)
-{
- if (snprintf(share_path, FILENAME_MAX, "%s/%s/",
- INSTALL_SHARE_DIR,
- SHARE_DIR) >= FILENAME_MAX) {
- goto err_path;
- }
-
- return;
-
-
-err_path:
- printf("Path is too large and has been truncated\n");
- exit(EXIT_FAILURE);
-}
-
-void snprint_share_file (char *dest, int destsize, int share_file)
-{
- char file_name [FILENAME_MAX];
-
- switch (share_file) {
- case SHARE_COPYRIGHT:
- if (snprintf(file_name, FILENAME_MAX, "%s/%s",
- share_path,
- "COPYRIGHT.txt") >= FILENAME_MAX) {
- goto err_path;
- }
- break;
- case SHARE_DISCLAIMER:
- if (snprintf(file_name, FILENAME_MAX, "%s/%s",
- share_path,
- "DISCLAIMER.txt") >= FILENAME_MAX) {
- goto err_path;
- }
- break;
- case SHARE_HELP:
- if (snprintf(file_name, FILENAME_MAX, "%s/%s",
- share_path,
- "HELP.txt") >= FILENAME_MAX) {
- goto err_path;
- }
- break;
- case SHARE_LICENSE:
- if (snprintf(file_name, FILENAME_MAX, "%s/%s",
- share_path,
- "LICENSE.txt") >= FILENAME_MAX) {
- goto err_path;
- }
- break;
- case SHARE_USAGE:
- if (snprintf(file_name, FILENAME_MAX, "%s/%s",
- share_path,
- "USAGE.txt") >= FILENAME_MAX) {
- goto err_path;
- }
- break;
- }
-
- alx_snprint_file(dest, destsize, file_name);
-
- return;
-
-
-err_path:
- printf("Path is too large and has been truncated\n");
- printf("File could not be shown!\n");
-}
-
-void print_share_file (int share_file)
-{
- char str [BUFF_SIZE_TEXT];
-
- snprint_share_file(str, BUFF_SIZE_TEXT, share_file);
-
- printf(BEGINNING);
- printf("%s", str);
- printf(ENDING);
-}
-
-void print_version (void)
-{
- printf("" PROG_NAME " " PROG_VERSION "\n\n");
-}
diff --git a/modules/about/tmp/Makefile b/modules/about/tmp/Makefile
deleted file mode 100644
index b46460f..0000000
--- a/modules/about/tmp/Makefile
+++ /dev/null
@@ -1,45 +0,0 @@
-# -*- MakeFile -*-
-
-# MACRO = substitute with this
-
-# directories
-
-LIBALX_INC_DIR = $(LIBALX_DIR)/inc/
-
-INC_DIR = $(ABOUT_DIR)/inc/
-SRC_DIR = $(ABOUT_DIR)/src/
-
-# dependencies
-
-_ALL = about.o
-ALL = $(_ALL) about_mod.o
-
-ABOU_INC_LIBALX = libalx/io/alx_file.h
-ABOU_INC = about.h
-ABOU_DEPS = $(SRC_DIR)/about.c \
- $(patsubst %,$(LIBALX_INC_DIR)/%,$(ABOU_INC_LIBALX)) \
- $(patsubst %,$(INC_DIR)/%,$(ABOU_INC))
-ABOU_INC_DIRS = -I $(INC_DIR) \
- -I $(LIBALX_INC_DIR)
-
-# target: dependencies
-# action
-
-all: $(ALL)
-
-
-about_mod.o: $(_ALL)
- @echo " LD $@"
- $(Q)$(LD) -r $^ -o $@
-
-
-about.s: $(ABOU_DEPS)
- @echo " CC $@"
- $(Q)$(CC) $(CFLAGS) $(ABOU_INC_DIRS) -S $< -o $@
-about.o: about.s
- @echo " AS $@"
- $(Q)$(AS) $< -o $@
-
-
-clean:
- $(Q)rm -f *.o *.s
diff --git a/modules/ctrl/Makefile b/modules/ctrl/Makefile
deleted file mode 100644
index 60d7283..0000000
--- a/modules/ctrl/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-# -*- MakeFile -*-
-
-# MACRO = substitute with this
-
-# directories
-
-TMP_DIR = $(CTRL_DIR)/tmp/
-
-# target: dependencies
-# action
-
-all:
- $(Q)cd $(TMP_DIR) && $(MAKE) && cd ..
-
-clean:
- $(Q)cd $(TMP_DIR) && $(MAKE) clean && cd ..
-
-################################################################################
-######## End of file ###########################################################
-################################################################################
-######## End of file ###########################################################
-################################################################################
-######## End of file ###########################################################
-################################################################################
diff --git a/modules/ctrl/tmp/Makefile b/modules/ctrl/tmp/Makefile
deleted file mode 100644
index 82f9c1f..0000000
--- a/modules/ctrl/tmp/Makefile
+++ /dev/null
@@ -1,53 +0,0 @@
-# -*- MakeFile -*-
-
-# MACRO = substitute with this
-
-# directories
-
-GAME_INC_DIR = $(GAME_DIR)/inc/
-MENU_INC_DIR = $(MENU_DIR)/inc/
-PLAY_INC_DIR = $(PLAY_DIR)/inc/
-
-INC_DIR = $(CTRL_DIR)/inc/
-SRC_DIR = $(CTRL_DIR)/src/
-
-# dependencies
-
-_ALL = start.o
-ALL = $(_ALL) ctrl_mod.o
-
-STRT_INC_GAME = game.h game_iface.h
-STRT_INC_MENU = menu_iface.h
-STRT_INC_PLAY = player_iface.h
-STRT_INC = start.h
-STRT_DEPS = $(SRC_DIR)/start.c \
- $(patsubst %,$(GAME_INC_DIR)/%,$(STRT_INC_GAME)) \
- $(patsubst %,$(MENU_INC_DIR)/%,$(STRT_INC_MENU)) \
- $(patsubst %,$(PLAY_INC_DIR)/%,$(STRT_INC_PLAY)) \
- $(patsubst %,$(INC_DIR)/%,$(STRT_INC))
-STRT_INC_DIRS = -I $(INC_DIR) \
- -I $(GAME_INC_DIR) \
- -I $(MENU_INC_DIR) \
- -I $(PLAY_INC_DIR)
-
-# target: dependencies
-# action
-
-all: $(ALL)
-
-
-ctrl_mod.o: $(_ALL)
- @echo " LD $@"
- $(Q)$(LD) -r $^ -o $@
-
-
-start.s: $(STRT_DEPS)
- @echo " CC $@"
- $(Q)$(CC) $(CFLAGS) $(STRT_INC_DIRS) -S $< -o $@
-start.o: start.s
- @echo " AS $@"
- $(Q)$(AS) $< -o $@
-
-
-clean:
- $(Q)rm -f *.o *.s
diff --git a/modules/game/Makefile b/modules/game/Makefile
deleted file mode 100644
index 692908e..0000000
--- a/modules/game/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-# -*- MakeFile -*-
-
-# MACRO = substitute with this
-
-# directories
-
-TMP_DIR = $(GAME_DIR)/tmp/
-
-# target: dependencies
-# action
-
-all:
- $(Q)cd $(TMP_DIR) && $(MAKE) && cd ..
-
-clean:
- $(Q)cd $(TMP_DIR) && $(MAKE) clean && cd ..
-
-################################################################################
-######## End of file ###########################################################
-################################################################################
-######## End of file ###########################################################
-################################################################################
-######## End of file ###########################################################
-################################################################################
diff --git a/modules/game/inc/game_iface.h b/modules/game/inc/game_iface.h
deleted file mode 100644
index 51f0e8c..0000000
--- a/modules/game/inc/game_iface.h
+++ /dev/null
@@ -1,153 +0,0 @@
-/******************************************************************************
- * Copyright (C) 2015 Alejandro Colomar Andrés *
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* include guard ********************************************************
- ******************************************************************************/
-# ifndef MSW_GAME_IFACE_H
- # define MSW_GAME_IFACE_H
-
-
-/******************************************************************************
- ******* macros ***************************************************************
- ******************************************************************************/
- # define ROWS_MAX (999)
- # define COLS_MAX (999)
- # define CHEATED (-1)
-
- # define GAME_IFACE_LEVEL_BEGINNER_ROWS (8)
- # define GAME_IFACE_LEVEL_BEGINNER_COLS (8)
- # define GAME_IFACE_LEVEL_BEGINNER_MINES (10)
-
- # define GAME_IFACE_LEVEL_INTERMEDIATE_ROWS (16)
- # define GAME_IFACE_LEVEL_INTERMEDIATE_COLS (16)
- # define GAME_IFACE_LEVEL_INTERMEDIATE_MINES (40)
-
- # define GAME_IFACE_LEVEL_EXPERT_ROWS (16)
- # define GAME_IFACE_LEVEL_EXPERT_COLS (30)
- # define GAME_IFACE_LEVEL_EXPERT_MINES (99)
-
-
-/******************************************************************************
- ******* enums ****************************************************************
- ******************************************************************************/
- enum Game_Iface_Level {
- GAME_IFACE_LEVEL_BEGINNER = 0,
- GAME_IFACE_LEVEL_INTERMEDIATE,
- GAME_IFACE_LEVEL_EXPERT,
- GAME_IFACE_LEVEL_EXPERT_INV,
- GAME_IFACE_LEVEL_CUSTOM
- };
-
- enum Game_Iface_Visible_Board {
- GAME_IFACE_VIS_FOO = -1,
- GAME_IFACE_VIS_KBOOM,
- GAME_IFACE_VIS_HIDDEN_FIELD,
- GAME_IFACE_VIS_HIDDEN_MINE,
- GAME_IFACE_VIS_HIDDEN_SAFE,
- GAME_IFACE_VIS_SAFE_MINE,
- GAME_IFACE_VIS_0,
- GAME_IFACE_VIS_1,
- GAME_IFACE_VIS_2,
- GAME_IFACE_VIS_3,
- GAME_IFACE_VIS_4,
- GAME_IFACE_VIS_5,
- GAME_IFACE_VIS_6,
- GAME_IFACE_VIS_7,
- GAME_IFACE_VIS_8,
- GAME_IFACE_VIS_FLAG,
- GAME_IFACE_VIS_FLAG_FALSE,
- GAME_IFACE_VIS_POSSIBLE,
- GAME_IFACE_VIS_POSSIBLE_FALSE
- };
-
- /* Needs to be the same as 'enum Game_Usr_Board' in 'game.h' */
- enum Game_Iface_Usr_Board {
- GAME_IFACE_USR_KBOOM = -1,
- GAME_IFACE_USR_HIDDEN,
- GAME_IFACE_USR_CLEAR,
- GAME_IFACE_USR_FLAG,
- GAME_IFACE_USR_POSSIBLE
- };
-
- /* Needs to be the same as 'enum Game_Action' in 'game.h' */
- enum Game_Iface_Action_Play {
- GAME_IFACE_GAME_ACT_FOO = 0,
- GAME_IFACE_GAME_ACT_STEP,
- GAME_IFACE_GAME_ACT_FLAG,
- GAME_IFACE_GAME_ACT_FLAG_POSSIBLE,
- GAME_IFACE_GAME_ACT_RM_FLAG
- };
-
- enum Game_Iface_Action {
- GAME_IFACE_ACT_FOO,
- GAME_IFACE_ACT_PLAY,
- GAME_IFACE_ACT_PAUSE,
- GAME_IFACE_ACT_SAVE,
- GAME_IFACE_ACT_XYZZY_ON,
- GAME_IFACE_ACT_XYZZY_OFF,
- GAME_IFACE_ACT_XYZZY_LIN,
- GAME_IFACE_ACT_XYZZY_P,
- GAME_IFACE_ACT_XYZZY_NP,
- GAME_IFACE_ACT_QUIT
- };
-
- enum Game_Iface_State {
- GAME_IFACE_STATE_PLAYING,
- GAME_IFACE_STATE_SAFE,
- GAME_IFACE_STATE_GAMEOVER,
-
- GAME_IFACE_STATE_PAUSE,
- GAME_IFACE_STATE_CHEATED,
- GAME_IFACE_STATE_XYZZY,
- GAME_IFACE_STATE_QUIT,
-
- GAME_IFACE_STATE_FOO
- };
-
-
-/******************************************************************************
- ******* structs **************************************************************
- ******************************************************************************/
- struct Game_Iface_Out {
- int rows;
- int cols;
- int mines;
- int visible [ROWS_MAX] [COLS_MAX];
- int usr [ROWS_MAX] [COLS_MAX];
- int flags;
- int clr;
- int state;
- };
-
- struct Game_Iface_Score {
- int level;
- int time;
- int clicks;
- };
-
- struct Game_Iface_In {
- int action;
- int act_game [ROWS_MAX] [COLS_MAX];
- };
-
-
-/******************************************************************************
- ******* functions ************************************************************
- ******************************************************************************/
-void game_iface_init_rand (int level, int pos_row, int pos_col);
-void game_iface_init_load (void);
-void game_iface (void);
-
-
-/******************************************************************************
- ******* include guard ********************************************************
- ******************************************************************************/
-# endif /* game_iface.h */
-
-
-/******************************************************************************
- ******* end of file **********************************************************
- ******************************************************************************/
diff --git a/modules/game/tmp/Makefile b/modules/game/tmp/Makefile
deleted file mode 100644
index 9cea18b..0000000
--- a/modules/game/tmp/Makefile
+++ /dev/null
@@ -1,73 +0,0 @@
-# -*- MakeFile -*-
-
-# MACRO = substitute with this
-
-# directories
-
-LIBALX_INC_DIR = $(LIBALX_DIR)/inc/
-
-PLAY_INC_DIR = $(PLAY_DIR)/inc/
-SAVE_INC_DIR = $(SAVE_DIR)/inc/
-XYZZY_INC_DIR = $(XYZZY_DIR)/inc/
-
-INC_DIR = $(GAME_DIR)/inc/
-SRC_DIR = $(GAME_DIR)/src/
-
-# dependencies
-
-_ALL = game.o game_iface.o
-ALL = $(_ALL) game_mod.o
-
-GAME_INC_LIBALX = libalx/alx_seed.h
-GAME_INC_SAVE = save.h
-GAME_INC = game.h
-GAME_DEPS = $(SRC_DIR)/game.c \
- $(patsubst %,$(INC_DIR)/%,$(GAME_INC)) \
- $(patsubst %,$(LIBALX_INC_DIR)/%,$(GAME_INC_LIBALX)) \
- $(patsubst %,$(SAVE_INC_DIR)/%,$(GAME_INC_SAVE))
-GAME_INC_DIRS = -I $(INC_DIR) \
- -I $(SAVE_INC_DIR) \
- -I $(LIBALX_INC_DIR)
-
-GAMEI_INC_PLAY = player_iface.h
-GAMEI_INC_SAVE = save.h score.h
-GAMEI_INC_XYZZY = xyzzy.h
-GAMEI_INC = game_iface.h game.h
-GAMEI_DEPS = $(SRC_DIR)/game_iface.c \
- $(patsubst %,$(INC_DIR)/%,$(GAME_INC)) \
- $(patsubst %,$(PLAY_INC_DIR)/%,$(GAMEI_INC_PLAY)) \
- $(patsubst %,$(SAVE_INC_DIR)/%,$(GAME_INC_SAVE)) \
- $(patsubst %,$(XYZZY_INC_DIR)/%,$(GAMEI_INC_XYZZY))
-GAMEI_INC_DIRS = -I $(INC_DIR) \
- -I $(PLAY_INC_DIR) \
- -I $(SAVE_INC_DIR) \
- -I $(XYZZY_INC_DIR)
-
-# target: dependencies
-# action
-
-all: $(ALL)
-
-
-game_mod.o: $(_ALL)
- $(Q)$(LD) -r $^ -o $@
- @echo " LD $@"
-
-
-game.s: $(GAME_DEPS)
- $(Q)$(CC) $(CFLAGS) $(GAME_INC_DIRS) -S $< -o $@
- @echo " CC $@"
-game.o: game.s
- $(Q)$(AS) $< -o $@
- @echo " AS $@"
-
-game_iface.s: $(GAMEI_DEPS)
- $(Q)$(CC) $(CFLAGS) $(GAMEI_INC_DIRS) -S $< -o $@
- @echo " CC $@"
-game_iface.o: game_iface.s
- $(Q)$(AS) $< -o $@
- @echo " AS $@"
-
-
-clean:
- $(Q)rm -f *.o *.s
diff --git a/modules/menu/Makefile b/modules/menu/Makefile
deleted file mode 100644
index 48ed965..0000000
--- a/modules/menu/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-# -*- MakeFile -*-
-
-# MACRO = substitute with this
-
-# directories
-
-TMP_DIR = $(MENU_DIR)/tmp/
-
-# target: dependencies
-# action
-
-all:
- $(Q)cd $(TMP_DIR) && $(MAKE) && cd ..
-
-clean:
- $(Q)cd $(TMP_DIR) && $(MAKE) clean && cd ..
-
-################################################################################
-######## End of file ###########################################################
-################################################################################
-######## End of file ###########################################################
-################################################################################
-######## End of file ###########################################################
-################################################################################
diff --git a/modules/menu/src/menu_gui.c b/modules/menu/src/menu_gui.c
deleted file mode 100644
index 607ec30..0000000
--- a/modules/menu/src/menu_gui.c
+++ /dev/null
@@ -1,991 +0,0 @@
-/******************************************************************************
- * Copyright (C) 2015 Alejandro Colomar Andrés *
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* headers **************************************************************
- ******************************************************************************/
- #include <gtk/gtk.h>
- #include <math.h>
- #include <stdbool.h>
- #include <stdio.h>
- #include <stdlib.h>
-
- #include "libalx/io/alx_input.h"
-
- #include "about.h"
- #include "game_iface.h"
- #include "save.h"
- #include "score.h"
- #include "start.h"
- #include "menu_iface.h"
-
- #include "menu_gui.h"
-
-
-/******************************************************************************
- ******* macros ***************************************************************
- ******************************************************************************/
- # define LINE_SIZE (80)
- # define BUFF_SIZE_TEXT (1048576)
-
-
-/******************************************************************************
- ******* structs **************************************************************
- ******************************************************************************/
-struct Button_Data {
- GtkWidget *ptr;
- char text [LINE_SIZE];
- int num;
- int *sw;
-};
-
-struct Label_Data {
- GtkWidget *ptr;
- char text [LINE_SIZE];
-};
-
-struct Entry_dbl_Data {
- GtkWidget *ptr;
- struct Label_Data lbl;
- double *num;
- double min;
- double def;
- double max;
-};
-
-struct Entry_int_Data {
- GtkWidget *ptr;
- struct Label_Data lbl;
- int *num;
- double min;
- int64_t def;
- double max;
-};
-
-struct Entry_fname_Data {
- GtkWidget *ptr;
- struct Label_Data lbl;
- const char *fpath;
- char *fname;
-};
-
-
-/******************************************************************************
- ******* variables ************************************************************
- ******************************************************************************/
-/* * * * * * * * * *
- * * * Global * * * * * *
- * * * * * * * * * */
- GtkWidget *window_gui;
-
-/* * * * * * * * * *
- * * * Static * * * * * *
- * * * * * * * * * */
-static GtkWidget *box;
-
-
-/******************************************************************************
- ******* static functions *****************************************************
- ******************************************************************************/
- /* Init & cleanup */
-static gboolean delete_window (GtkWidget *widget,
- GdkEvent *event,
- void *data);
-static void destroy_window (GtkWidget *widget,
- void *data);
- /* Selection */
-static void callback_button (GtkWidget *widget,
- void *data);
- /* Entries */
-static void callback_entry_dbl (GtkWidget *widget,
- void *data);
-static void callback_entry_int (GtkWidget *widget,
- void *data);
- /* Text */
-static void menu_gui_disclaim (void);
-static void menu_gui_license (void);
-static void menu_gui_hiscores (void);
- /* Submenus */
-static void menu_gui_continue (void);
-static void menu_gui_select (void);
-static void menu_gui_level (void);
-static void menu_gui_custom (void);
-static void menu_gui_devel (void);
-#if 0
-static void menu_gui_verbose (void);
-#endif
-
-
-/******************************************************************************
- ******* main *****************************************************************
- ******************************************************************************/
-void menu_gui_init (void)
-{
- char title [LINE_SIZE];
-
- window_gui = gtk_window_new(GTK_WINDOW_TOPLEVEL);
-
- g_signal_connect(window_gui, "delete-event", G_CALLBACK(delete_window), NULL);
- g_signal_connect(window_gui, "destroy", G_CALLBACK(destroy_window), NULL);
-
- /* Title. PROG_VERSION defined in Makefile */
- (void)snprintf(title, LINE_SIZE, "mine-sweeper %s", PROG_VERSION);
- gtk_window_set_title(GTK_WINDOW(window_gui), title);
- gtk_container_set_border_width(GTK_CONTAINER(window_gui), 20);
-}
-
-void menu_gui_cleanup (void)
-{
-
- gtk_widget_destroy(window_gui);
-}
-
-void menu_gui (void)
-{
- bool wh;
- int sw;
- GtkWidget *separator[3];
- struct Label_Data label;
- struct Button_Data button [4];
-
- /* Text */
- (void)snprintf(label.text, LINE_SIZE, "Main menu");
- (void)snprintf(button[1].text, LINE_SIZE, "[_1] Continue");
- (void)snprintf(button[2].text, LINE_SIZE, "[_2] Disclaimer of warranty");
- (void)snprintf(button[3].text, LINE_SIZE, "[_3] Terms and conditions");
- (void)snprintf(button[0].text, LINE_SIZE, "[_0] Exit program");
-
- /* Data */
- button[1].num = 1;
- button[2].num = 2;
- button[3].num = 3;
- button[0].num = 0;
- button[1].sw = &sw;
- button[2].sw = &sw;
- button[3].sw = &sw;
- button[0].sw = &sw;
-
- /* Menu loop */
- wh = true;
- while (wh) {
-
- /* Generate widgets */
- box = gtk_vbox_new(false, 0);
- label.ptr = gtk_label_new(label.text);
- separator[0] = gtk_hseparator_new();
- button[1].ptr = gtk_button_new_with_mnemonic(button[1].text);
- separator[1] = gtk_hseparator_new();
- button[2].ptr = gtk_button_new_with_mnemonic(button[2].text);
- button[3].ptr = gtk_button_new_with_mnemonic(button[3].text);
- separator[2] = gtk_hseparator_new();
- button[0].ptr = gtk_button_new_with_mnemonic(button[0].text);
-
- /* Events */
- g_signal_connect(button[1].ptr, "clicked",
- G_CALLBACK(callback_button), (void *)&button[1]);
- g_signal_connect(button[2].ptr, "clicked",
- G_CALLBACK(callback_button), (void *)&button[2]);
- g_signal_connect(button[3].ptr, "clicked",
- G_CALLBACK(callback_button), (void *)&button[3]);
- g_signal_connect(button[0].ptr, "clicked",
- G_CALLBACK(callback_button), (void *)&button[0]);
-
- /* Container */
- gtk_container_add(GTK_CONTAINER(window_gui), box);
-
- /* Box */
- gtk_box_pack_start(GTK_BOX(box), label.ptr, false, false, 0);
- gtk_box_pack_start(GTK_BOX(box), separator[0], false, false, 5);
- gtk_box_pack_start(GTK_BOX(box), button[1].ptr, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box), separator[1], false, false, 5);
- gtk_box_pack_start(GTK_BOX(box), button[2].ptr, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box), button[3].ptr, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box), separator[2], false, false, 5);
- gtk_box_pack_start(GTK_BOX(box), button[0].ptr, true, true, 0);
-
- /* Refresh */
- gtk_widget_show_all(window_gui);
-
- /* GTK loop */
- sw = -1;
- gtk_main();
-
- /* Clear window */
- gtk_widget_destroy(box);
-
- /* Selection */
- switch (sw) {
- case 0:
- wh = false;
- break;
- case 1:
- menu_gui_continue();
- break;
- case 2:
- menu_gui_disclaim();
- break;
- case 3:
- menu_gui_license();
- break;
- }
- }
-}
-
-
-/******************************************************************************
- ******* static functions *****************************************************
- ******************************************************************************/
-/* * * * * * * * * *
- * * Cleanup * * * * * *
- * * * * * * * * * */
-static gboolean delete_window (GtkWidget *widget,
- GdkEvent *event,
- void *data)
-{
-
- gtk_main_quit();
-
- /* false: send destroy signal */
- return false;
-}
-
-static void destroy_window (GtkWidget *widget,
- void *data)
-{
-
- exit(EXIT_SUCCESS);
-}
-
-/* * * * * * * * * *
- * * Selection * * * * * *
- * * * * * * * * * */
-static void callback_button (GtkWidget *widget,
- void *data)
-{
- struct Button_Data *button;
-
- button = ((struct Button_Data *)data);
-
- *(button->sw) = button->num;
-
- gtk_main_quit();
-}
-
-/* * * * * * * * * *
- * * Entries * * * * * * *
- * * * * * * * * * */
-static void callback_entry_dbl (GtkWidget *widget,
- void *data)
-{
- struct Entry_dbl_Data *entry;
- const char *str;
- char buff [LINE_SIZE];
-
- entry = ((struct Entry_dbl_Data *)data);
-
- str = gtk_entry_get_text(GTK_ENTRY(entry->ptr));
- if (alx_sscan_dbl(entry->num, entry->min, entry->def, entry->max, str))
- goto err;
-
- gtk_main_quit();
- return;
-
-err:
- (void)snprintf(buff, LINE_SIZE, "Error in alx_sscan_dbl()");
- gtk_entry_set_text(GTK_ENTRY(entry->ptr), buff);
- gtk_editable_select_region(GTK_EDITABLE(entry->ptr),
- 0, GTK_ENTRY(entry->ptr)->text_length);
- gtk_main_quit();
-}
-
-static void callback_entry_int (GtkWidget *widget,
- void *data)
-{
- struct Entry_int_Data *entry;
- const char *str;
- int64_t Z;
- char buff [LINE_SIZE];
-
- entry = ((struct Entry_int_Data *)data);
-
- str = gtk_entry_get_text(GTK_ENTRY(entry->ptr));
- if (alx_sscan_i64(&Z, entry->min, entry->def, entry->max, str))
- goto err;
- *(entry->num) = Z;
-
- gtk_main_quit();
- return;
-
-err:
- (void)snprintf(buff, LINE_SIZE, "Error in alx_sscan_i64()");
- gtk_entry_set_text(GTK_ENTRY(entry->ptr), buff);
- gtk_editable_select_region(GTK_EDITABLE(entry->ptr),
- 0, GTK_ENTRY(entry->ptr)->text_length);
- gtk_main_quit();
-}
-
-static void callback_entry_fname (GtkWidget *widget,
- void *data)
-{
- struct Entry_fname_Data *entry;
- const char *str;
- char buff [LINE_SIZE];
-
- entry = ((struct Entry_fname_Data *)data);
-
- str = gtk_entry_get_text(GTK_ENTRY(entry->ptr));
- if (alx_sscan_fname(entry->fpath, entry->fname, true, str))
- goto err;
-
- gtk_main_quit();
- return;
-
-err:
- (void)snprintf(buff, LINE_SIZE, "Error in alx_sscan_fname()");
- gtk_entry_set_text(GTK_ENTRY(entry->ptr), buff);
- gtk_editable_select_region(GTK_EDITABLE(entry->ptr),
- 0, GTK_ENTRY(entry->ptr)->text_length);
- gtk_main_quit();
-}
-
-/* * * * * * * * * *
- * * Text * * * * * * *
- * * * * * * * * * */
-static void menu_gui_disclaim (void)
-{
- int sw;
- GtkWidget *separator[2];
- struct Label_Data label;
- struct Button_Data button [1];
- GtkWidget *label_file;
- char label_file_txt [BUFF_SIZE_TEXT];
-
- /* Text */
- (void)snprintf(label.text, LINE_SIZE, "Disclaimer of warranty");
- snprint_share_file(label_file_txt, BUFF_SIZE_TEXT, SHARE_DISCLAIMER);
- (void)snprintf(button[0].text, LINE_SIZE, "[_0] Back");
-
- /* Data */
- button[0].num = 0;
- button[0].sw = &sw;
-
- /* Generate widgets */
- box = gtk_vbox_new(false, 0);
- label.ptr = gtk_label_new(label.text);
- separator[0] = gtk_hseparator_new();
- label_file = gtk_label_new(label_file_txt);
- separator[1] = gtk_hseparator_new();
- button[0].ptr = gtk_button_new_with_mnemonic(button[0].text);
-
- /* Events */
- g_signal_connect(button[0].ptr, "clicked",
- G_CALLBACK(callback_button), (void *)&button[0]);
-
- /* Container */
- gtk_container_add(GTK_CONTAINER(window_gui), box);
-
- /* Box */
- gtk_box_pack_start(GTK_BOX(box), label.ptr, false, false, 0);
- gtk_box_pack_start(GTK_BOX(box), separator[0], false, false, 5);
- gtk_box_pack_start(GTK_BOX(box), label_file, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box), separator[1], false, false, 5);
- gtk_box_pack_start(GTK_BOX(box), button[0].ptr, true, true, 0);
-
- /* Refresh */
- gtk_widget_show_all(window_gui);
-
- /* GTK loop */
- gtk_main();
-
- /* Clear window */
- gtk_widget_destroy(box);
-}
-
-static void menu_gui_license (void)
-{
- int sw;
- GtkWidget *separator[2];
- struct Label_Data label;
- struct Button_Data button [1];
- GtkWidget *label_file;
- char label_file_txt [BUFF_SIZE_TEXT];
-
- /* Text */
- (void)snprintf(label.text, LINE_SIZE, "Terms and conditions");
- snprint_share_file(label_file_txt, BUFF_SIZE_TEXT, SHARE_LICENSE);
- (void)snprintf(button[0].text, LINE_SIZE, "[_0] Back");
-
- /* Data */
- button[0].num = 0;
- button[0].sw = &sw;
-
- /* Generate widgets */
- box = gtk_vbox_new(false, 0);
- label.ptr = gtk_label_new(label.text);
- separator[0] = gtk_hseparator_new();
- label_file = gtk_label_new(label_file_txt);
- separator[1] = gtk_hseparator_new();
- button[0].ptr = gtk_button_new_with_mnemonic(button[0].text);
-
- /* Events */
- g_signal_connect(button[0].ptr, "clicked",
- G_CALLBACK(callback_button), (void *)&button[0]);
-
- /* Container */
- gtk_container_add(GTK_CONTAINER(window_gui), box);
-
- /* Box */
- gtk_box_pack_start(GTK_BOX(box), label.ptr, false, false, 0);
- gtk_box_pack_start(GTK_BOX(box), separator[0], false, false, 5);
- gtk_box_pack_start(GTK_BOX(box), label_file, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box), separator[1], false, false, 5);
- gtk_box_pack_start(GTK_BOX(box), button[0].ptr, true, true, 0);
-
- /* Refresh */
- gtk_widget_show_all(window_gui);
-
- /* GTK loop */
- gtk_main();
-
- /* Clear window */
- gtk_widget_destroy(box);
-}
-
-static void menu_gui_hiscores (void)
-{
- int sw;
- GtkWidget *separator[2];
- struct Label_Data label;
- struct Button_Data button [1];
- GtkWidget *label_file;
- char label_file_txt [BUFF_SIZE_TEXT];
-
- /* Text */
- (void)snprintf(label.text, LINE_SIZE, "Hi scores");
- snprint_scores(label_file_txt, BUFF_SIZE_TEXT);
- (void)snprintf(button[0].text, LINE_SIZE, "[_0] Back");
-
- /* Data */
- button[0].num = 0;
- button[0].sw = &sw;
-
- /* Generate widgets */
- box = gtk_vbox_new(false, 0);
- label.ptr = gtk_label_new(label.text);
- separator[0] = gtk_hseparator_new();
- label_file = gtk_label_new(label_file_txt);
- separator[1] = gtk_hseparator_new();
- button[0].ptr = gtk_button_new_with_mnemonic(button[0].text);
-
- /* Events */
- g_signal_connect(button[0].ptr, "clicked",
- G_CALLBACK(callback_button), (void *)&button[0]);
-
- /* Container */
- gtk_container_add(GTK_CONTAINER(window_gui), box);
-
- /* Box */
- gtk_box_pack_start(GTK_BOX(box), label.ptr, false, false, 0);
- gtk_box_pack_start(GTK_BOX(box), separator[0], false, false, 5);
- gtk_box_pack_start(GTK_BOX(box), label_file, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box), separator[1], false, false, 5);
- gtk_box_pack_start(GTK_BOX(box), button[0].ptr, true, true, 0);
-
- /* Refresh */
- gtk_widget_show_all(window_gui);
-
- /* GTK loop */
- gtk_main();
-
- /* Clear window */
- gtk_widget_destroy(box);
-}
-
-/* * * * * * * * * *
- * * Submenus * * * * * *
- * * * * * * * * * */
-static void menu_gui_continue (void)
-{
- bool wh;
- int sw;
- GtkWidget *separator[4];
- struct Label_Data label;
- struct Button_Data button [6];
- struct Entry_fname_Data entry_fname[1];
-
- /* Text */
- (void)snprintf(label.text, LINE_SIZE, "Game menu");
- (void)snprintf(button[1].text, LINE_SIZE, "[_1] Start");
- (void)snprintf(button[2].text, LINE_SIZE, "[_2] Select map");
- (void)snprintf(button[3].text, LINE_SIZE, "[_3] Change difficulty");
- (void)snprintf(button[4].text, LINE_SIZE, "[_4] Hi scores");
- (void)snprintf(button[5].text, LINE_SIZE, "[_5] DEVEL");
- (void)snprintf(button[0].text, LINE_SIZE, "[_0] Back");
-
- /* Data */
- button[1].num = 1;
- button[2].num = 2;
- button[3].num = 3;
- button[4].num = 4;
- button[5].num = 5;
- button[0].num = 0;
- button[1].sw = &sw;
- button[2].sw = &sw;
- button[3].sw = &sw;
- entry_fname[0].fpath = saved_path;
- entry_fname[0].fname = saved_name;
- button[4].sw = &sw;
- button[5].sw = &sw;
- button[0].sw = &sw;
-
- /* Menu loop */
- wh = true;
- while (wh) {
- /* Text */
- (void)snprintf(entry_fname[0].lbl.text, LINE_SIZE,
- "Change file name (File: \"%s\")", saved_name);
-
- /* Generate widgets */
- box = gtk_vbox_new(false, 0);
- label.ptr = gtk_label_new(label.text);
- separator[0] = gtk_hseparator_new();
- button[1].ptr = gtk_button_new_with_mnemonic(button[1].text);
- separator[1] = gtk_hseparator_new();
- button[2].ptr = gtk_button_new_with_mnemonic(button[2].text);
- button[3].ptr = gtk_button_new_with_mnemonic(button[3].text);
- entry_fname[0].lbl.ptr = gtk_label_new(entry_fname[0].lbl.text);
- entry_fname[0].ptr = gtk_entry_new();
- button[4].ptr = gtk_button_new_with_mnemonic(button[4].text);
- separator[2] = gtk_hseparator_new();
- button[5].ptr = gtk_button_new_with_mnemonic(button[5].text);
- separator[3] = gtk_hseparator_new();
- button[0].ptr = gtk_button_new_with_mnemonic(button[0].text);
-
- /* Events */
- g_signal_connect(button[1].ptr, "clicked",
- G_CALLBACK(callback_button), (void *)&button[1]);
- g_signal_connect(button[2].ptr, "clicked",
- G_CALLBACK(callback_button), (void *)&button[2]);
- g_signal_connect(button[3].ptr, "clicked",
- G_CALLBACK(callback_button), (void *)&button[3]);
- g_signal_connect(entry_fname[0].ptr, "activate",
- G_CALLBACK(callback_entry_fname), (void *)&entry_fname[0]);
- g_signal_connect(button[4].ptr, "clicked",
- G_CALLBACK(callback_button), (void *)&button[4]);
- g_signal_connect(button[5].ptr, "clicked",
- G_CALLBACK(callback_button), (void *)&button[5]);
- g_signal_connect(button[0].ptr, "clicked",
- G_CALLBACK(callback_button), (void *)&button[0]);
-
- /* Container */
- gtk_container_add(GTK_CONTAINER(window_gui), box);
-
- /* Box */
- gtk_box_pack_start(GTK_BOX(box), label.ptr, false, false, 0);
- gtk_box_pack_start(GTK_BOX(box), separator[0], false, false, 5);
- gtk_box_pack_start(GTK_BOX(box), button[1].ptr, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box), separator[1], false, false, 5);
- gtk_box_pack_start(GTK_BOX(box), button[2].ptr, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box), button[3].ptr, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box), entry_fname[0].lbl.ptr, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box), entry_fname[0].ptr, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box), button[4].ptr, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box), separator[2], false, false, 5);
- gtk_box_pack_start(GTK_BOX(box), button[5].ptr, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box), separator[3], false, false, 5);
- gtk_box_pack_start(GTK_BOX(box), button[0].ptr, true, true, 0);
-
- /* Refresh */
- gtk_widget_show_all(window_gui);
-
- /* GTK loop */
- sw = -1;
- gtk_main();
-
- /* Clear window */
- gtk_widget_destroy(box);
-
- /* Selection */
- switch (sw) {
- case 0:
- wh = false;
- break;
- case 1:
- start_switch();
- break;
- case 2:
- menu_gui_select();
- break;
- case 3:
- menu_gui_level();
- break;
- case 4:
- menu_gui_hiscores();
- break;
- case 5:
- menu_gui_devel();
- break;
- }
- }
-}
-
-static void menu_gui_select (void)
-{
- int sw;
- GtkWidget *separator[3];
- struct Label_Data label;
- struct Button_Data button [3];
-
- /* Text */
- (void)snprintf(label.text, LINE_SIZE, "Select map");
- (void)snprintf(button[1].text, LINE_SIZE, "[_1] New map");
- (void)snprintf(button[2].text, LINE_SIZE, "[_2] Load map (File: \"%s\")",
- saved_name);
- (void)snprintf(button[0].text, LINE_SIZE, "[_0] Back");
-
- /* Data */
- button[1].num = 1;
- button[2].num = 2;
- button[0].num = 0;
- button[1].sw = &sw;
- button[2].sw = &sw;
- button[0].sw = &sw;
-
- /* Generate widgets */
- box = gtk_vbox_new(false, 0);
- label.ptr = gtk_label_new(label.text);
- separator[0] = gtk_hseparator_new();
- button[1].ptr = gtk_button_new_with_mnemonic(button[1].text);
- separator[1] = gtk_hseparator_new();
- button[2].ptr = gtk_button_new_with_mnemonic(button[2].text);
- separator[2] = gtk_hseparator_new();
- button[0].ptr = gtk_button_new_with_mnemonic(button[0].text);
-
- /* Events */
- g_signal_connect(button[1].ptr, "clicked",
- G_CALLBACK(callback_button), (void *)&button[1]);
- g_signal_connect(button[2].ptr, "clicked",
- G_CALLBACK(callback_button), (void *)&button[2]);
- g_signal_connect(button[0].ptr, "clicked",
- G_CALLBACK(callback_button), (void *)&button[0]);
-
- /* Container */
- gtk_container_add(GTK_CONTAINER(window_gui), box);
-
- /* Box */
- gtk_box_pack_start(GTK_BOX(box), label.ptr, false, false, 0);
- gtk_box_pack_start(GTK_BOX(box), separator[0], false, false, 5);
- gtk_box_pack_start(GTK_BOX(box), button[1].ptr, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box), separator[1], false, false, 5);
- gtk_box_pack_start(GTK_BOX(box), button[2].ptr, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box), separator[2], false, false, 5);
- gtk_box_pack_start(GTK_BOX(box), button[0].ptr, true, true, 0);
-
- /* Refresh */
- gtk_widget_show_all(window_gui);
-
- /* GTK loop */
- sw = -1;
- gtk_main();
-
- /* Clear window */
- gtk_widget_destroy(box);
-
- /* Selection */
- switch (sw) {
- case 0:
- break;
- case 1:
- start_mode = START_RAND;
- break;
- case 2:
- start_mode = START_LOAD;
- break;
- }
-}
-
-static void menu_gui_level (void)
-{
- int sw;
- GtkWidget *separator[3];
- struct Label_Data label;
- struct Button_Data button [5];
-
- /* Text */
- (void)snprintf(label.text, LINE_SIZE, "Select level");
- (void)snprintf(button[1].text, LINE_SIZE, "[_1] Beginner");
- (void)snprintf(button[2].text, LINE_SIZE, "[_2] Intermediate");
- (void)snprintf(button[3].text, LINE_SIZE, "[_3] Expert");
- (void)snprintf(button[4].text, LINE_SIZE, "[_4] Custom");
- (void)snprintf(button[0].text, LINE_SIZE, "[_0] Back");
-
- /* Data */
- button[1].num = 1;
- button[2].num = 2;
- button[3].num = 3;
- button[4].num = 4;
- button[0].num = 0;
- button[1].sw = &sw;
- button[2].sw = &sw;
- button[3].sw = &sw;
- button[4].sw = &sw;
- button[0].sw = &sw;
-
- /* Generate widgets */
- box = gtk_vbox_new(false, 0);
- label.ptr = gtk_label_new(label.text);
- separator[0] = gtk_hseparator_new();
- button[1].ptr = gtk_button_new_with_mnemonic(button[1].text);
- button[2].ptr = gtk_button_new_with_mnemonic(button[2].text);
- button[3].ptr = gtk_button_new_with_mnemonic(button[3].text);
- separator[1] = gtk_hseparator_new();
- button[4].ptr = gtk_button_new_with_mnemonic(button[4].text);
- separator[2] = gtk_hseparator_new();
- button[0].ptr = gtk_button_new_with_mnemonic(button[0].text);
-
- /* Events */
- g_signal_connect(button[1].ptr, "clicked",
- G_CALLBACK(callback_button), (void *)&button[1]);
- g_signal_connect(button[2].ptr, "clicked",
- G_CALLBACK(callback_button), (void *)&button[2]);
- g_signal_connect(button[3].ptr, "clicked",
- G_CALLBACK(callback_button), (void *)&button[3]);
- g_signal_connect(button[4].ptr, "clicked",
- G_CALLBACK(callback_button), (void *)&button[4]);
- g_signal_connect(button[0].ptr, "clicked",
- G_CALLBACK(callback_button), (void *)&button[0]);
-
- /* Container */
- gtk_container_add(GTK_CONTAINER(window_gui), box);
-
- /* Box */
- gtk_box_pack_start(GTK_BOX(box), label.ptr, false, false, 0);
- gtk_box_pack_start(GTK_BOX(box), separator[0], false, false, 5);
- gtk_box_pack_start(GTK_BOX(box), button[1].ptr, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box), button[2].ptr, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box), button[3].ptr, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box), separator[1], false, false, 5);
- gtk_box_pack_start(GTK_BOX(box), button[4].ptr, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box), separator[2], false, false, 5);
- gtk_box_pack_start(GTK_BOX(box), button[0].ptr, true, true, 0);
-
- /* Refresh */
- gtk_widget_show_all(window_gui);
-
- /* GTK loop */
- sw = -1;
- gtk_main();
-
- /* Clear window */
- gtk_widget_destroy(box);
-
- /* Selection */
- switch (sw) {
- case 1:
- menu_iface_variables.level = GAME_IFACE_LEVEL_BEGINNER;
- break;
- case 2:
- menu_iface_variables.level = GAME_IFACE_LEVEL_INTERMEDIATE;
- break;
- case 3:
- menu_iface_variables.level = GAME_IFACE_LEVEL_EXPERT;
- break;
- case 4:
- menu_iface_variables.level = GAME_IFACE_LEVEL_CUSTOM;
- menu_gui_custom();
- break;
- }
-}
-
-static void menu_gui_custom (void)
-{
- bool wh;
- int sw;
- GtkWidget *separator[3];
- struct Label_Data label;
- struct Button_Data button [1];
- struct Entry_int_Data entry_int[2];
- struct Entry_dbl_Data entry_dbl[1];
-
- /* Text */
- (void)snprintf(label.text, LINE_SIZE, "Custom");
- (void)snprintf(button[0].text, LINE_SIZE, "[_0] Back");
-
- /* Data */
- entry_int[0].num = &menu_iface_variables.rows;
- entry_int[0].min = 2;
- entry_int[0].def = menu_iface_variables.rows;
- entry_int[0].max = ROWS_GUI_MAX;
- entry_int[1].num = &menu_iface_variables.cols;
- entry_int[1].min = 2;
- entry_int[1].def = menu_iface_variables.cols;
- entry_int[1].max = COLS_GUI_MAX;
- entry_dbl[0].num = &menu_iface_variables.p;
- entry_dbl[0].min = 0;
- entry_dbl[0].def = menu_iface_variables.p;
- entry_dbl[0].max = 1;
- button[0].num = 0;
- button[0].sw = &sw;
-
- /* Menu loop */
- wh = true;
- while (wh) {
-
- /* Text */
- (void)snprintf(entry_int[0].lbl.text, LINE_SIZE,
- "Change rows: rows\t\t(%i)\n"
- "Introduce an integer number [%i U %i]",
- menu_iface_variables.rows, 2, ROWS_GUI_MAX);
- (void)snprintf(entry_int[1].lbl.text, LINE_SIZE,
- "Change columns: cols\t(%i)\n"
- "Introduce an integer number [%i U %i]",
- menu_iface_variables.cols, 2, COLS_GUI_MAX);
- (void)snprintf(entry_dbl[0].lbl.text, LINE_SIZE,
- "Change proportion of mines: p\t(%lf)\n"
- "Introduce a Real number [%i U %i]",
- menu_iface_variables.p, 0, 1);
-
- /* Generate widgets */
- box = gtk_vbox_new(false, 0);
- label.ptr = gtk_label_new(label.text);
- separator[0] = gtk_hseparator_new();
- entry_int[0].lbl.ptr = gtk_label_new(entry_int[0].lbl.text);
- entry_int[0].ptr = gtk_entry_new();
- entry_int[1].lbl.ptr = gtk_label_new(entry_int[1].lbl.text);
- entry_int[1].ptr = gtk_entry_new();
- separator[1] = gtk_hseparator_new();
- entry_dbl[0].lbl.ptr = gtk_label_new(entry_dbl[0].lbl.text);
- entry_dbl[0].ptr = gtk_entry_new();
- separator[2] = gtk_hseparator_new();
- button[0].ptr = gtk_button_new_with_mnemonic(button[0].text);
-
- /* Events */
- g_signal_connect(entry_int[0].ptr, "activate",
- G_CALLBACK(callback_entry_int), (void *)&entry_int[0]);
- g_signal_connect(entry_int[1].ptr, "activate",
- G_CALLBACK(callback_entry_int), (void *)&entry_int[1]);
- g_signal_connect(entry_dbl[0].ptr, "activate",
- G_CALLBACK(callback_entry_dbl), (void *)&entry_dbl[0]);
- g_signal_connect(button[0].ptr, "clicked",
- G_CALLBACK(callback_button), (void *)&button[0]);
-
- /* Container */
- gtk_container_add(GTK_CONTAINER(window_gui), box);
-
- /* Box */
- gtk_box_pack_start(GTK_BOX(box), label.ptr, false, false, 0);
- gtk_box_pack_start(GTK_BOX(box), separator[0], false, false, 5);
- gtk_box_pack_start(GTK_BOX(box), entry_int[0].lbl.ptr, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box), entry_int[0].ptr, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box), entry_int[1].lbl.ptr, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box), entry_int[1].ptr, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box), separator[1], false, false, 5);
- gtk_box_pack_start(GTK_BOX(box), entry_dbl[0].lbl.ptr, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box), entry_dbl[0].ptr, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box), separator[2], false, false, 5);
- gtk_box_pack_start(GTK_BOX(box), button[0].ptr, true, true, 0);
-
- /* Refresh */
- gtk_widget_show_all(window_gui);
-
- /* GTK loop */
- sw = -1;
- gtk_main();
-
- /* Selection */
- switch (sw) {
- case 0:
- wh = false;
- break;
-
- default:
- break;
- }
-
- /* Clear window */
- gtk_widget_destroy(box);
- }
-}
-
-static void menu_gui_devel (void)
-{
- bool wh;
- int sw;
- GtkWidget *separator[2];
- struct Label_Data label;
- struct Button_Data button [1];
- struct Entry_int_Data entry_int[1];
- int seed;
-
- /* Text */
- (void)snprintf(label.text, LINE_SIZE, "DEVELOPER OPTIONS");
- (void)snprintf(entry_int[0].lbl.text, LINE_SIZE, "Change seed (srand)");
- (void)snprintf(button[0].text, LINE_SIZE, "[_0] Back");
-
- /* Data */
- entry_int[0].num = &seed;
- entry_int[0].min = -INFINITY;
- entry_int[0].def = 1;
- entry_int[0].max = INFINITY;
- button[0].num = 0;
- button[0].sw = &sw;
-
- /* Text */
-
- /* Menu loop */
- wh = true;
- while (wh) {
- /* Generate widgets */
- box = gtk_vbox_new(false, 0);
- label.ptr = gtk_label_new(label.text);
- separator[0] = gtk_hseparator_new();
- entry_int[0].lbl.ptr = gtk_label_new(entry_int[0].lbl.text);
- entry_int[0].ptr = gtk_entry_new();
- separator[1] = gtk_hseparator_new();
- button[0].ptr = gtk_button_new_with_mnemonic(button[0].text);
-
- /* Events */
- g_signal_connect(entry_int[0].ptr, "activate",
- G_CALLBACK(callback_entry_int), (void *)&entry_int[0]);
- g_signal_connect(button[0].ptr, "clicked",
- G_CALLBACK(callback_button), (void *)&button[0]);
-
- /* Container */
- gtk_container_add(GTK_CONTAINER(window_gui), box);
-
- /* Box */
- gtk_box_pack_start(GTK_BOX(box), label.ptr, false, false, 0);
- gtk_box_pack_start(GTK_BOX(box), separator[0], false, false, 5);
- gtk_box_pack_start(GTK_BOX(box), entry_int[0].lbl.ptr, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box), entry_int[0].ptr, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box), separator[1], false, false, 5);
- gtk_box_pack_start(GTK_BOX(box), button[0].ptr, true, true, 0);
-
- /* Refresh */
- gtk_widget_show_all(window_gui);
-
- /* GTK loop */
- sw = -1;
- gtk_main();
-
- /* Selection */
- switch (sw) {
- case 0:
- wh = false;
- break;
- default:
- srand(seed);
- break;
- }
-
- /* Clear window */
- gtk_widget_destroy(box);
- }
-}
-
-
-/******************************************************************************
- ******* end of file **********************************************************
- ******************************************************************************/
diff --git a/modules/menu/tmp/Makefile b/modules/menu/tmp/Makefile
deleted file mode 100644
index ce766f4..0000000
--- a/modules/menu/tmp/Makefile
+++ /dev/null
@@ -1,165 +0,0 @@
-# -*- MakeFile -*-
-
-# MACRO = substitute with this
-
-# directories
-
-LIBALX_INC_DIR = $(LIBALX_DIR)/inc/
-
-ABOUT_INC_DIR = $(ABOUT_DIR)/inc/
-CTRL_INC_DIR = $(CTRL_DIR)/inc/
-GAME_INC_DIR = $(GAME_DIR)/inc/
-PLAY_INC_DIR = $(PLAY_DIR)/inc/
-SAVE_INC_DIR = $(SAVE_DIR)/inc/
-
-INC_DIR = $(MENU_DIR)/inc/
-SRC_DIR = $(MENU_DIR)/src/
-
-# dependencies
-
-_ALL = parser.o menu_iface.o menu_clui.o menu_tui.o menu_gui.o
-ALL = $(_ALL) menu_mod.o
-
-PARS_INC_LIBALX = libalx/alx_seed.h
-PARS_INC_ABOUT = about.h
-PARS_INC_CTRL = start.h
-PARS_INC_GAME = game_iface.h
-PARS_INC_PLAY = player_iface.h
-PARS_INC_SAVE = save.h
-PARS_INC = parser.h menu_iface.h
-PARS_DEPS = $(SRC_DIR)/parser.c \
- $(patsubst %,$(INC_DIR)/%,$(PARS_INC)) \
- $(patsubst %,$(LIBALX_INC_DIR)/%,$(PARS_INC_LIBALX)) \
- $(patsubst %,$(ABOUT_INC_DIR)/%,$(PARS_INC_ABOUT)) \
- $(patsubst %,$(CTRL_INC_DIR)/%,$(PARS_INC_CTRL)) \
- $(patsubst %,$(GAME_INC_DIR)/%,$(PARS_INC_GAME)) \
- $(patsubst %,$(PLAY_INC_DIR)/%,$(PARS_INC_PLAY)) \
- $(patsubst %,$(SAVE_INC_DIR)/%,$(PARS_INC_SAVE))
-PARS_INC_DIRS = -I $(INC_DIR) \
- -I $(LIBALX_INC_DIR) \
- -I $(ABOUT_INC_DIR) \
- -I $(CTRL_INC_DIR) \
- -I $(GAME_INC_DIR) \
- -I $(PLAY_INC_DIR) \
- -I $(SAVE_INC_DIR)
-
-MENUI_INC_CTRL = start.h
-MENUI_INC_GAME = game_iface.h
-MENUI_INC = menu_iface.h menu_clui.h menu_tui.h menu_gui.h
-MENUI_DEPS = $(SRC_DIR)/menu_iface.c \
- $(patsubst %,$(INC_DIR)/%,$(MENUI_INC)) \
- $(patsubst %,$(CTRL_INC_DIR)/%,$(MENUI_INC_CTRL)) \
- $(patsubst %,$(GAME_INC_DIR)/%,$(MENUI_INC_GAME))
-MENUI_INC_DIRS = -I $(INC_DIR) \
- -I $(CTRL_INC_DIR) \
- -I $(GAME_INC_DIR)
-
-MENUCLUI_INC_LIBALX = libalx/io/alx_input.h
-MENUCLUI_INC_ABOUT = about.h
-MENUCLUI_INC_CTRL = start.h
-MENUCLUI_INC_GAME = game_iface.h
-MENUCLUI_INC_SAVE = save.h
-MENUCLUI_INC = menu_clui.h menu_iface.h
-MENUCLUI_DEPS = $(SRC_DIR)/menu_clui.c \
- $(patsubst %,$(INC_DIR)/%,$(MENUCLUI_INC)) \
- $(patsubst %,$(LIBALX_INC_DIR)/%,$(MENUCLUI_INC_LIBALX)) \
- $(patsubst %,$(ABOUT_INC_DIR)/%,$(MENUCLUI_INC_ABOUT)) \
- $(patsubst %,$(GAME_INC_DIR)/%,$(MENUCLUI_INC_GAME)) \
- $(patsubst %,$(CTRL_INC_DIR)/%,$(MENUCLUI_INC_CTRL)) \
- $(patsubst %,$(SAVE_INC_DIR)/%,$(MENUCLUI_INC_SAVE))
-MENUCLUI_INC_DIRS = -I $(INC_DIR) \
- -I $(LIBALX_INC_DIR) \
- -I $(ABOUT_INC_DIR) \
- -I $(CTRL_INC_DIR) \
- -I $(GAME_INC_DIR) \
- -I $(SAVE_INC_DIR)
-
-MENUTUI_INC_LIBALX = libalx/curses/alx_ncur.h
-MENUTUI_INC_ABOUT = about.h
-MENUTUI_INC_CTRL = start.h
-MENUTUI_INC_GAME = game_iface.h
-MENUTUI_INC_SAVE = save.h score.h
-MENUTUI_INC = menu_tui.h menu_iface.h
-MENUTUI_DEPS = $(SRC_DIR)/menu_tui.c \
- $(patsubst %,$(INC_DIR)/%,$(MENUTUI_INC)) \
- $(patsubst %,$(LIBALX_INC_DIR)/%,$(MENUTUI_INC_LIBALX)) \
- $(patsubst %,$(ABOUT_INC_DIR)/%,$(MENUTUI_INC_ABOUT)) \
- $(patsubst %,$(GAME_INC_DIR)/%,$(MENUTUI_INC_GAME)) \
- $(patsubst %,$(CTRL_INC_DIR)/%,$(MENUTUI_INC_CTRL)) \
- $(patsubst %,$(SAVE_INC_DIR)/%,$(MENUTUI_INC_SAVE))
-MENUTUI_INC_DIRS = -I $(INC_DIR) \
- -I $(LIBALX_INC_DIR) \
- -I $(ABOUT_INC_DIR) \
- -I $(CTRL_INC_DIR) \
- -I $(GAME_INC_DIR) \
- -I $(SAVE_INC_DIR)
-
-MENUGUI_INC_LIBALX = libalx/io/alx_input.h
-MENUGUI_INC_ABOUT = about.h
-MENUGUI_INC_CTRL = start.h
-MENUGUI_INC_GAME = game_iface.h
-MENUGUI_INC_SAVE = save.h score.h
-MENUGUI_INC = menu_gui.h menu_iface.h
-MENUGUI_DEPS = $(SRC_DIR)/menu_gui.c \
- $(patsubst %,$(INC_DIR)/%,$(MENUGUI_INC)) \
- $(patsubst %,$(LIBALX_INC_DIR)/%,$(MENUGUI_INC_LIBALX)) \
- $(patsubst %,$(ABOUT_INC_DIR)/%,$(MENUGUI_INC_ABOUT)) \
- $(patsubst %,$(GAME_INC_DIR)/%,$(MENUGUI_INC_GAME)) \
- $(patsubst %,$(CTRL_INC_DIR)/%,$(MENUGUI_INC_CTRL)) \
- $(patsubst %,$(SAVE_INC_DIR)/%,$(MENUGUI_INC_SAVE))
-MENUGUI_INC_DIRS = -I $(INC_DIR) \
- -I $(LIBALX_INC_DIR) \
- -I $(ABOUT_INC_DIR) \
- -I $(CTRL_INC_DIR) \
- -I $(GAME_INC_DIR) \
- -I $(SAVE_INC_DIR)
-
-# target: dependencies
-# action
-
-all: $(ALL)
-
-
-menu_mod.o: $(_ALL)
- @echo " LD $@"
- $(Q)$(LD) -r $^ -o $@
-
-
-parser.s: $(PARS_DEPS)
- @echo " CC $@"
- $(Q)$(CC) $(CFLAGS) $(PARS_INC_DIRS) -S $< -o $@
-parser.o: parser.s
- @echo " AS $@"
- $(Q)$(AS) $< -o $@
-
-menu_iface.s: $(MENUI_DEPS)
- @echo " CC $@"
- $(Q)$(CC) $(CFLAGS) $(MENUI_INC_DIRS) -S $< -o $@
-menu_iface.o: menu_iface.s
- @echo " AS $@"
- $(Q)$(AS) $< -o $@
-
-menu_clui.s: $(MENUCLUI_DEPS)
- @echo " CC $@"
- $(Q)$(CC) $(CFLAGS) $(MENUCLUI_INC_DIRS) -S $< -o $@
-menu_clui.o: menu_clui.s
- @echo " AS $@"
- $(Q)$(AS) $< -o $@
-
-menu_tui.s: $(MENUTUI_DEPS)
- @echo " CC $@"
- $(Q)$(CC) $(CFLAGS) $(MENUTUI_INC_DIRS) -S $< -o $@
-menu_tui.o: menu_tui.s
- @echo " AS $@"
- $(Q)$(AS) $< -o $@
-
-menu_gui.s: $(MENUGUI_DEPS)
- @echo " CC $@"
- $(Q)$(CC) $(CFLAGS) $(MENUGUI_INC_DIRS) -S $< -o $@
-menu_gui.o: menu_gui.s
- @echo " AS $@"
- $(Q)$(AS) $< -o $@
-
-
-clean:
- $(Q)rm -f *.o *.s
diff --git a/modules/player/Makefile b/modules/player/Makefile
deleted file mode 100644
index bbf6245..0000000
--- a/modules/player/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-# -*- MakeFile -*-
-
-# MACRO = substitute with this
-
-# directories
-
-TMP_DIR = $(PLAY_DIR)/tmp/
-
-# target: dependencies
-# action
-
-all:
- $(Q)cd $(TMP_DIR) && $(MAKE) && cd ..
-
-clean:
- $(Q)cd $(TMP_DIR) && $(MAKE) clean && cd ..
-
-################################################################################
-######## End of file ###########################################################
-################################################################################
-######## End of file ###########################################################
-################################################################################
-######## End of file ###########################################################
-################################################################################
diff --git a/modules/player/inc/player_gui.h b/modules/player/inc/player_gui.h
deleted file mode 100644
index 9cac01f..0000000
--- a/modules/player/inc/player_gui.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/******************************************************************************
- * Copyright (C) 2015 Alejandro Colomar Andrés *
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* include guard ********************************************************
- ******************************************************************************/
-# ifndef MSW_PLAYER_GUI_H
- # define MSW_PLAYER_GUI_H
-
-
-/******************************************************************************
- ******* headers **************************************************************
- ******************************************************************************/
- /* struct Game_Iface_... */
- #include "game_iface.h"
-
- #include "player_iface.h"
-
-
-/******************************************************************************
- ******* enums ****************************************************************
- ******************************************************************************/
- enum Player_GUI_Char {
- PLAYER_GUI_CHAR_ERROR = 'X',
- PLAYER_GUI_CHAR_KBOOM = '#',
- PLAYER_GUI_CHAR_HIDDEN_FIELD = '+',
- PLAYER_GUI_CHAR_HIDDEN_MINE = '*',
- PLAYER_GUI_CHAR_HIDDEN_SAFE = '-',
- PLAYER_GUI_CHAR_SAFE_MINE = 'v',
- PLAYER_GUI_CHAR_0 = ' ',
- PLAYER_GUI_CHAR_1 = '1',
- PLAYER_GUI_CHAR_2 = '2',
- PLAYER_GUI_CHAR_3 = '3',
- PLAYER_GUI_CHAR_4 = '4',
- PLAYER_GUI_CHAR_5 = '5',
- PLAYER_GUI_CHAR_6 = '6',
- PLAYER_GUI_CHAR_7 = '7',
- PLAYER_GUI_CHAR_8 = '8',
- PLAYER_GUI_CHAR_FLAG = '!',
- PLAYER_GUI_CHAR_FLAG_FALSE = 'F',
- PLAYER_GUI_CHAR_POSSIBLE = '?',
- PLAYER_GUI_CHAR_POSSIBLE_FALSE = 'f'
- };
-
-
-/******************************************************************************
- ******* variables ************************************************************
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* functions ************************************************************
- ******************************************************************************/
-void player_gui_init (struct Player_Iface_Position *pos,
- int *action);
-
-int player_gui_start (const struct Player_Iface_Position *pos,
- const char *title, const char *subtitle);
-
-int player_gui (const struct Game_Iface_Out *board,
- const struct Player_Iface_Position *pos,
- const char *title, const char *subtitle);
-
-void player_gui_save_name (const char *fpath, char *fname, int destsize);
-void player_gui_score_name (char *player_name, int destsize);
-void player_gui_cleanup (void);
-
-
-/******************************************************************************
- ******* include guard ********************************************************
- ******************************************************************************/
-# endif /* player_gui.h */
-
-
-/******************************************************************************
- ******* end of file **********************************************************
- ******************************************************************************/
diff --git a/modules/player/src/player_gui.c b/modules/player/src/player_gui.c
deleted file mode 100644
index fcbad71..0000000
--- a/modules/player/src/player_gui.c
+++ /dev/null
@@ -1,946 +0,0 @@
-/******************************************************************************
- * Copyright (C) 2015 Alejandro Colomar Andrés *
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* headers **************************************************************
- ******************************************************************************/
- #include <math.h>
- #include <stdbool.h>
- #include <stdio.h>
-
- #include <gtk/gtk.h>
-
- #include "libalx/io/alx_input.h"
-
- #include "game_iface.h"
- #include "menu_gui.h"
- #include "player_iface.h"
-
- #include "player_gui.h"
-
-
-/******************************************************************************
- ******* macros ***************************************************************
- ******************************************************************************/
- # define LINE_SIZE (80)
- # define REFRESH_TIME_MS (100)
-
-
-/******************************************************************************
- ******* enums ****************************************************************
- ******************************************************************************/
- enum Buttons {
- BTN_CH_OFF = 0,
- BTN_CH_1,
- BTN_CH_2,
- BTN_SAVE,
- BTN_QUIT,
- BTN_QTTY
- };
-
- enum TButtons {
- TBTN_PAUSE,
- TBTN_QTTY
- };
-
-
-/******************************************************************************
- ******* structs **************************************************************
- ******************************************************************************/
- struct Label_Data {
- GtkWidget *ptr;
- char text [LINE_SIZE];
- };
-
- struct Field_Data {
- GtkWidget *ptr;
- char ch;
- int r;
- int c;
- int *row;
- int *col;
- int *act;
- };
-
- struct Button_Data {
- GtkWidget *ptr;
- char text [LINE_SIZE];
- int val;
- int *act;
- };
-
- struct TButton_Data {
- GtkWidget *ptr;
- char text [LINE_SIZE];
- char text2 [LINE_SIZE];
- int val;
- int val2;
- int *act;
- };
-
- struct Entry_fname_Data {
- GtkWidget *ptr;
- struct Label_Data lbl;
- const char *fpath;
- char *fname;
- };
-
- struct Entry_str_Data {
- GtkWidget *ptr;
- struct Label_Data lbl;
- char *str;
- int strsize;
- };
-
- struct PBar_Data {
- GtkWidget *ptr;
- double frac;
- char text [LINE_SIZE];
- };
-
- struct EBox_Data {
- GtkWidget *ptr;
- int val;
- int *act;
- };
-
- struct Timeout_Data {
- int id;
- int val;
- int *act;
- };
-
-
-/******************************************************************************
- ******* variables ************************************************************
- ******************************************************************************/
-static GtkWidget *box;
-static GtkWidget *box_help;
-static GtkWidget *box_help_in;
-static struct Button_Data button [BTN_QTTY];
-static struct TButton_Data tbutton [TBTN_QTTY];
-static struct Entry_str_Data entry_name;
-static struct Entry_fname_Data entry_fname;
-static GtkWidget *box_board;
-static GtkWidget *box_board_in;
-static struct PBar_Data pbar_board_tit;
-// static GtkWidget *box_board_tit;
-static GtkWidget *box_board_tab;
-static GtkWidget *table_board;
-static struct Field_Data field [ROWS_GUI_MAX] [COLS_GUI_MAX];
-static struct EBox_Data ebox_cheat;
-// static GtkWidget *box_board_stit;
-static struct Label_Data label_stit;
-static int last_help;
-static struct Timeout_Data timeout;
-
-static int state;
-
-
-/******************************************************************************
- ******* static functions *****************************************************
- ******************************************************************************/
- /* Start */
-static void board_init (const struct Player_Iface_Position *pos,
- int *action);
-static void show_board_start(const struct Player_Iface_Position *pos,
- const char *title, const char *subtitle);
-
-static void board_loop_start(const struct Player_Iface_Position *pos);
-
- /* Play */
-static void show_board (const struct Game_Iface_Out *board,
- const char *title, const char *subtitle);
-
-static void board_loop (const struct Game_Iface_Out *board);
-
-static char set_char (int game_iface_visible);
-static void show_char (const struct Field_Data *field);
- /* Help */
-static void help_init (int *action);
-static void show_help (const struct Game_Iface_Out *board);
-static void show_help_start (void);
-static void show_help_play (void);
-static void show_help_pause (void);
-static void show_help_xyzzy (void);
-static void show_help_cheat (void);
-static void show_help_safe (void);
-static void show_help_gameover (void);
- /* Input */
-static gboolean callback_field (GtkWidget *widget,
- GdkEventButton *event,
- void *data);
-static gboolean callback_ebox (GtkWidget *widget,
- GdkEventButton *event,
- void *data);
-static void callback_button (GtkWidget *widget, void *data);
-static gboolean callback_tbutton (GtkWidget *widget, void *data);
-static void callback_entry_fname (GtkWidget *widget, void *data);
-static void callback_entry_str (GtkWidget *widget, void *data);
-static gboolean callback_timeout (void *data);
-
-
-/******************************************************************************
- ******* main *****************************************************************
- ******************************************************************************/
-void player_gui_init (struct Player_Iface_Position *pos,
- int *action)
-{
- int i;
- int j;
-
- box = gtk_hbox_new(false, 0);
- gtk_container_add(GTK_CONTAINER(window_gui), box);
-
- /* Structure */
- GtkWidget *separator;
- box_help = gtk_vbox_new(true, 0);
- separator = gtk_vseparator_new();
- box_board = gtk_vbox_new(false, 0);
- gtk_box_pack_start(GTK_BOX(box), box_help, false, false, 5);
- gtk_box_pack_start(GTK_BOX(box), separator, false, false, 5);
- gtk_box_pack_start(GTK_BOX(box), box_board, true, true, 5);
-
- help_init(action);
- board_init(pos, action);
-
- /* Board fields */
- for (i = 0; i < pos->rows; i++) {
- for (j = 0; j < pos->cols; j++) {
- field[i][j].r = i;
- field[i][j].c = j;
- field[i][j].row = &(pos->row);
- field[i][j].col = &(pos->col);
- field[i][j].act = action;
- field[i][j].ptr = gtk_button_new_with_label("NEW");
- g_signal_connect(field[i][j].ptr, "button-press-event",
- G_CALLBACK(callback_field), (void *)&field[i][j]);
- gtk_table_attach_defaults(GTK_TABLE(table_board), field[i][j].ptr,
- field[i][j].c, field[i][j].c + 1,
- field[i][j].r, field[i][j].r + 1);
- }
- }
-
- /* Refresh */
- gtk_widget_show_all(window_gui);
-}
-
-int player_gui_start (const struct Player_Iface_Position *pos,
- const char *title, const char *subtitle)
-{
-
- show_help_start();
- show_board_start(pos, title, subtitle);
-
- /* Refresh */
- gtk_widget_show(box);
- gtk_widget_show(window_gui);
-
- gtk_main();
-
- return 0;
-}
-
-int player_gui (const struct Game_Iface_Out *board,
- const struct Player_Iface_Position *pos,
- const char *title, const char *subtitle)
-{
-
- state = board->state;
-
- show_help(board);
- show_board(board, title, subtitle);
-
- /* Refresh */
- gtk_widget_show(box);
- gtk_widget_show(window_gui);
-
- gtk_main();
-
- return 0;
-}
-
-void player_gui_save_name (const char *fpath, char *fname, int destsize)
-{
-
- entry_fname.fpath = fpath;
- entry_fname.fname = fname;
-
- gtk_widget_hide(button[BTN_CH_OFF].ptr);
- gtk_widget_hide(button[BTN_CH_1].ptr);
- gtk_widget_hide(button[BTN_CH_2].ptr);
- gtk_widget_hide(tbutton[TBTN_PAUSE].ptr);
- gtk_widget_hide(button[BTN_SAVE].ptr);
- gtk_widget_show(entry_fname.lbl.ptr);
- gtk_widget_show(entry_fname.ptr);
- gtk_widget_hide(button[BTN_QUIT].ptr);
-
- gtk_widget_hide(box_board);
-
- gtk_main();
-
- gtk_widget_show(box_board);
-
- gtk_widget_hide(entry_fname.lbl.ptr);
- gtk_widget_hide(entry_fname.ptr);
-
- /* Update last_help */
- last_help = GAME_IFACE_STATE_FOO;
-}
-
-void player_gui_score_name (char *player_name, int destsize)
-{
-
- entry_name.str = player_name;
- entry_name.strsize = destsize;
-
- gtk_widget_hide(button[BTN_CH_OFF].ptr);
- gtk_widget_hide(button[BTN_CH_1].ptr);
- gtk_widget_hide(button[BTN_CH_2].ptr);
- gtk_widget_hide(tbutton[TBTN_PAUSE].ptr);
- gtk_widget_hide(button[BTN_SAVE].ptr);
- gtk_widget_show(entry_name.lbl.ptr);
- gtk_widget_show(entry_name.ptr);
- gtk_widget_hide(button[BTN_QUIT].ptr);
-
- gtk_widget_hide(box_board);
-
- gtk_main();
-
- gtk_widget_show(box_board);
-
- gtk_widget_hide(entry_name.lbl.ptr);
- gtk_widget_hide(entry_name.ptr);
-
- /* Update last_help */
- last_help = GAME_IFACE_STATE_FOO;
-}
-
-void player_gui_cleanup (void)
-{
-
- gtk_widget_destroy(box);
-}
-
-
-/******************************************************************************
- ******* static functions *****************************************************
- ******************************************************************************/
-/* * * * * * * * * *
- * * * Start * * * * * * *
- * * * * * * * * * */
-static void board_init (const struct Player_Iface_Position *pos,
- int *action)
-{
- GtkWidget *separator[2];
-
- /* Box */
- box_board_in = gtk_vbox_new(false, 0);
- gtk_box_pack_start(GTK_BOX(box_board), box_board_in, true, true, 5);
-
- /* Title (with progress bar) */
- pbar_board_tit.ptr = gtk_progress_bar_new();
-// box_board_tit = gtk_vbox_new(false, 0);
- gtk_box_pack_start(GTK_BOX(box_board_in), pbar_board_tit.ptr, false, false, 0);
-// gtk_box_pack_start(GTK_BOX(box_board_in), box_board_tit, false, false, 0);
- gtk_progress_bar_set_text(GTK_PROGRESS_BAR(pbar_board_tit.ptr), "NEW");
-// gtk_box_pack_start(GTK_BOX(box_board_tit), label[0].ptr, false, false, 0);
-
- /* Pogress bar */
- gtk_progress_bar_set_orientation(GTK_PROGRESS_BAR(pbar_board_tit.ptr), GTK_PROGRESS_LEFT_TO_RIGHT);
-
- /* Separator */
- separator[0] = gtk_hseparator_new();
- gtk_box_pack_start(GTK_BOX(box_board_in), separator[0], false, false, 5);
-
- /* Board */
- box_board_tab = gtk_vbox_new(true, 0);
- gtk_box_pack_start(GTK_BOX(box_board_in), box_board_tab, true, true, 0);
- table_board = gtk_table_new(pos->rows, pos->cols, true);
- gtk_box_pack_start(GTK_BOX(box_board_tab), table_board, true, true, 5);
-
- /* Separator */
- separator[1] = gtk_hseparator_new();
- gtk_box_pack_start(GTK_BOX(box_board_in), separator[1], false, false, 5);
-
- /* Subtitle (with cheats) */
- ebox_cheat.ptr = gtk_event_box_new();
-// box_board_stit = gtk_vbox_new(false, 0);
- gtk_box_pack_start(GTK_BOX(box_board_in), ebox_cheat.ptr, false, false, 0);
-// gtk_box_pack_start(GTK_BOX(box_board_in), box_board_stit, false, false, 0);
- label_stit.ptr = gtk_label_new("NEW");
- gtk_container_add(GTK_CONTAINER(ebox_cheat.ptr), label_stit.ptr);
-// gtk_box_pack_start(GTK_BOX(box_board_stit), label_stit.ptr, false, false, 0);
-
- /* Cheats */
- ebox_cheat.val = PLAYER_IFACE_ACT_XYZZY_ON;
- ebox_cheat.act = action;
- g_signal_connect(ebox_cheat.ptr, "button-press-event",
- G_CALLBACK(callback_ebox), (void *)&ebox_cheat);
-
- /* Timeout */
- timeout.val = PLAYER_IFACE_ACT_FOO;
- timeout.act = action;
- timeout.id = 0;
-
- /* Refresh */
- gtk_widget_show_all(box_board);
-}
-
-static void show_board_start(const struct Player_Iface_Position *pos,
- const char *title, const char *subtitle)
-{
-
- /* Title */
- snprintf(pbar_board_tit.text, LINE_SIZE, title);
- gtk_progress_bar_set_text(GTK_PROGRESS_BAR(pbar_board_tit.ptr), pbar_board_tit.text);
-
- /* Progress bar */
- pbar_board_tit.frac = 0;
- gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(pbar_board_tit.ptr), pbar_board_tit.frac);
-
- /* Board */
- board_loop_start(pos);
-
- /* Subtitle */
- snprintf(label_stit.text, LINE_SIZE, subtitle);
- gtk_label_set_text(GTK_LABEL(label_stit.ptr), label_stit.text);
-
- /* Refresh */
- gtk_widget_show_all(box_board);
-}
-
-static void board_loop_start(const struct Player_Iface_Position *pos)
-{
- int i;
- int j;
- char c;
-
- c = PLAYER_GUI_CHAR_HIDDEN_FIELD;
-
- for (i = 0; i < pos->rows; i++) {
- for (j = 0; j < pos->cols; j++) {
- field[i][j].ch = c;
- show_char(&field[i][j]);
- }
- }
-}
-
-/* * * * * * * * * *
- * * * Play * * * * * *
- * * * * * * * * * */
-static void show_board (const struct Game_Iface_Out *board,
- const char *title, const char *subtitle)
-{
- /* Title */
- snprintf(pbar_board_tit.text, LINE_SIZE, title);
- gtk_progress_bar_set_text(GTK_PROGRESS_BAR(pbar_board_tit.ptr), pbar_board_tit.text);
-
- /* Progress bar */
- if (board->flags % board->mines) {
- /* This is a trick to have (frac <= 1) instead of (frac < 1) */
- pbar_board_tit.frac = ((double)board->flags) / ((double)board->mines);
- pbar_board_tit.frac = fmod(pbar_board_tit.frac, 1);
- } else if (board->flags) {
- pbar_board_tit.frac = 1;
- } else {
- pbar_board_tit.frac = 0;
- }
- gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(pbar_board_tit.ptr), pbar_board_tit.frac);
-
- /* Board */
- board_loop(board);
-
- /* Subtitle */
- snprintf(label_stit.text, LINE_SIZE, subtitle);
- gtk_label_set_text(GTK_LABEL(label_stit.ptr), label_stit.text);
-
- /* Timeout */
- if (board->state == GAME_IFACE_STATE_PLAYING)
- timeout.id = g_timeout_add_seconds(1, callback_timeout, (void *)&timeout);
-
- /* Refresh */
- gtk_widget_show_all(box_board);
-}
-
-static void board_loop (const struct Game_Iface_Out *board)
-{
- int i;
- int j;
-
- for (i = 0; i < board->rows; i++) {
- for (j = 0; j < board->cols; j++) {
- field[i][j].ch = set_char(board->visible[i][j]);
- show_char(&field[i][j]);
- }
- }
-}
-
-static char set_char (int game_iface_visible)
-{
- char c;
-
- switch (game_iface_visible) {
- case GAME_IFACE_VIS_KBOOM:
- c = PLAYER_GUI_CHAR_KBOOM;
- break;
- case GAME_IFACE_VIS_HIDDEN_FIELD:
- c = PLAYER_GUI_CHAR_HIDDEN_FIELD;
- break;
- case GAME_IFACE_VIS_HIDDEN_MINE:
- c = PLAYER_GUI_CHAR_HIDDEN_MINE;
- break;
- case GAME_IFACE_VIS_HIDDEN_SAFE:
- c = PLAYER_GUI_CHAR_HIDDEN_SAFE;
- break;
- case GAME_IFACE_VIS_SAFE_MINE:
- c = PLAYER_GUI_CHAR_SAFE_MINE;
- break;
- case GAME_IFACE_VIS_0:
- c = PLAYER_GUI_CHAR_0;
- break;
- case GAME_IFACE_VIS_1:
- c = PLAYER_GUI_CHAR_1;
- break;
- case GAME_IFACE_VIS_2:
- c = PLAYER_GUI_CHAR_2;
- break;
- case GAME_IFACE_VIS_3:
- c = PLAYER_GUI_CHAR_3;
- break;
- case GAME_IFACE_VIS_4:
- c = PLAYER_GUI_CHAR_4;
- break;
- case GAME_IFACE_VIS_5:
- c = PLAYER_GUI_CHAR_5;
- break;
- case GAME_IFACE_VIS_6:
- c = PLAYER_GUI_CHAR_6;
- break;
- case GAME_IFACE_VIS_7:
- c = PLAYER_GUI_CHAR_7;
- break;
- case GAME_IFACE_VIS_8:
- c = PLAYER_GUI_CHAR_8;
- break;
- case GAME_IFACE_VIS_FLAG:
- c = PLAYER_GUI_CHAR_FLAG;
- break;
- case GAME_IFACE_VIS_FLAG_FALSE:
- c = PLAYER_GUI_CHAR_FLAG_FALSE;
- break;
- case GAME_IFACE_VIS_POSSIBLE:
- c = PLAYER_GUI_CHAR_POSSIBLE;
- break;
- case GAME_IFACE_VIS_POSSIBLE_FALSE:
- c = PLAYER_GUI_CHAR_POSSIBLE_FALSE;
- break;
- default:
- c = PLAYER_GUI_CHAR_ERROR;
- break;
- }
-
- return c;
-}
-
-static void show_char (const struct Field_Data *field)
-{
- char text [2];
-
- sprintf(text, "%c", field->ch);
- gtk_button_set_label(GTK_BUTTON(field->ptr), text);
-}
-
-/* * * * * * * * * *
- * * * Help * * * * * * *
- * * * * * * * * * */
-static void help_init (int *action)
-{
-
- /* Box */
- box_help_in = gtk_vbox_new(false, 0);
- gtk_box_pack_start(GTK_BOX(box_help), box_help_in, false, false, 5);
-
- /* Text */
- snprintf(button[BTN_CH_OFF].text, LINE_SIZE, "[_0] Cheats off");
- snprintf(button[BTN_CH_1].text, LINE_SIZE, "Cheat _1");
- snprintf(button[BTN_CH_2].text, LINE_SIZE, "Cheat _2");
- snprintf(tbutton[TBTN_PAUSE].text, LINE_SIZE, "_Pause");
- snprintf(tbutton[TBTN_PAUSE].text2, LINE_SIZE, "[_P] Continue");
- snprintf(button[BTN_SAVE].text, LINE_SIZE, "_Save");
- snprintf(entry_fname.lbl.text, LINE_SIZE, "File name:");
- snprintf(entry_name.lbl.text, LINE_SIZE, "Your name:");
- snprintf(button[BTN_QUIT].text, LINE_SIZE, "_Quit");
-
- /* Data */
- /* L click */
- button[BTN_CH_OFF].val = PLAYER_IFACE_ACT_XYZZY_OFF;
- button[BTN_CH_1].val = PLAYER_IFACE_ACT_XYZZY_LIN;
- button[BTN_CH_2].val = PLAYER_IFACE_ACT_XYZZY_P;
- tbutton[TBTN_PAUSE].val = PLAYER_IFACE_ACT_PAUSE;
- button[BTN_SAVE].val = PLAYER_IFACE_ACT_SAVE;
- button[BTN_QUIT].val = PLAYER_IFACE_ACT_QUIT;
- /* R click */
- tbutton[TBTN_PAUSE].val2 = PLAYER_IFACE_ACT_PAUSE;
-
- /* Action */
- button[BTN_CH_OFF].act = action;
- button[BTN_CH_1].act = action;
- button[BTN_CH_2].act = action;
- tbutton[TBTN_PAUSE].act = action;
- button[BTN_SAVE].act = action;
- button[BTN_QUIT].act = action;
-
- /* Generate widgets */
- button[BTN_CH_OFF].ptr = gtk_button_new_with_mnemonic(button[BTN_CH_OFF].text);
- button[BTN_CH_1].ptr = gtk_button_new_with_mnemonic(button[BTN_CH_1].text);
- button[BTN_CH_2].ptr = gtk_button_new_with_mnemonic(button[BTN_CH_2].text);
- tbutton[TBTN_PAUSE].ptr = gtk_toggle_button_new_with_mnemonic(tbutton[TBTN_PAUSE].text);
- button[BTN_SAVE].ptr = gtk_button_new_with_mnemonic(button[BTN_SAVE].text);
- entry_fname.lbl.ptr = gtk_label_new(entry_fname.lbl.text);
- entry_fname.ptr = gtk_entry_new();
- entry_name.lbl.ptr = gtk_label_new(entry_name.lbl.text);
- entry_name.ptr = gtk_entry_new();
- button[BTN_QUIT].ptr = gtk_button_new_with_mnemonic(button[BTN_QUIT].text);
-
- /* Toggle buttons */
- gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tbutton[TBTN_PAUSE].ptr), false);
-
- /* Events */
- g_signal_connect(button[BTN_CH_OFF].ptr, "clicked",
- G_CALLBACK(callback_button), (void *)&button[BTN_CH_OFF]);
- g_signal_connect(button[BTN_CH_1].ptr, "clicked",
- G_CALLBACK(callback_button), (void *)&button[BTN_CH_1]);
- g_signal_connect(button[BTN_CH_2].ptr, "clicked",
- G_CALLBACK(callback_button), (void *)&button[BTN_CH_2]);
- g_signal_connect(tbutton[TBTN_PAUSE].ptr, "toggled",
- G_CALLBACK(callback_tbutton), (void *)&tbutton[TBTN_PAUSE]);
- g_signal_connect(button[BTN_SAVE].ptr, "clicked",
- G_CALLBACK(callback_button), (void *)&button[BTN_SAVE]);
- g_signal_connect(entry_fname.ptr, "activate",
- G_CALLBACK(callback_entry_fname), (void *)&entry_fname);
- g_signal_connect(entry_name.ptr, "activate",
- G_CALLBACK(callback_entry_str), (void *)&entry_name);
- g_signal_connect(button[BTN_QUIT].ptr, "clicked",
- G_CALLBACK(callback_button), (void *)&button[BTN_QUIT]);
-
- /* Box */
- gtk_box_pack_start(GTK_BOX(box_help_in), button[BTN_CH_OFF].ptr, false, false, 0);
- gtk_box_pack_start(GTK_BOX(box_help_in), button[BTN_CH_1].ptr, false, false, 0);
- gtk_box_pack_start(GTK_BOX(box_help_in), button[BTN_CH_2].ptr, false, false, 0);
- gtk_box_pack_start(GTK_BOX(box_help_in), tbutton[TBTN_PAUSE].ptr, false, false, 0);
- gtk_box_pack_start(GTK_BOX(box_help_in), button[BTN_SAVE].ptr, false, false, 0);
- gtk_box_pack_start(GTK_BOX(box_help_in), entry_fname.lbl.ptr, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box_help_in), entry_fname.ptr, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box_help_in), entry_name.lbl.ptr, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box_help_in), entry_name.ptr, true, true, 0);
- gtk_box_pack_start(GTK_BOX(box_help_in), button[BTN_QUIT].ptr, false, false, 0);
-}
-
-static void show_help (const struct Game_Iface_Out *board)
-{
-
- if (last_help != board->state) {
- switch (board->state) {
- case GAME_IFACE_STATE_PLAYING:
- show_help_play();
- break;
- case GAME_IFACE_STATE_PAUSE:
- show_help_pause();
- break;
- case GAME_IFACE_STATE_XYZZY:
- show_help_xyzzy();
- break;
- case GAME_IFACE_STATE_CHEATED:
- show_help_cheat();
- break;
- case GAME_IFACE_STATE_SAFE:
- show_help_safe();
- break;
- case GAME_IFACE_STATE_GAMEOVER:
- show_help_gameover();
- break;
- }
-
- /* Update last_help */
- last_help = board->state;
-
- /* Refresh */
- gtk_widget_show(box_help_in);
- gtk_widget_show(box_help);
- }
-}
-
-static void show_help_start (void)
-{
-
- /* Show & hide */
- gtk_widget_hide(button[BTN_CH_OFF].ptr);
- gtk_widget_hide(button[BTN_CH_1].ptr);
- gtk_widget_hide(button[BTN_CH_2].ptr);
- gtk_widget_hide(tbutton[TBTN_PAUSE].ptr);
- gtk_widget_hide(button[BTN_SAVE].ptr);
- gtk_widget_hide(entry_fname.lbl.ptr);
- gtk_widget_hide(entry_fname.ptr);
- gtk_widget_hide(entry_name.lbl.ptr);
- gtk_widget_hide(entry_name.ptr);
- gtk_widget_show(button[BTN_QUIT].ptr);
-
- /* Update last_help */
- last_help = GAME_IFACE_STATE_FOO;
-
- /* Refresh */
- gtk_widget_show(box_help_in);
- gtk_widget_show(box_help);
-}
-
-static void show_help_play (void)
-{
-
- /* Show & hide */
- gtk_widget_hide(button[BTN_CH_OFF].ptr);
- gtk_widget_hide(button[BTN_CH_1].ptr);
- gtk_widget_hide(button[BTN_CH_2].ptr);
- gtk_widget_show(tbutton[TBTN_PAUSE].ptr);
- gtk_widget_show(button[BTN_SAVE].ptr);
- gtk_widget_hide(entry_fname.lbl.ptr);
- gtk_widget_hide(entry_fname.ptr);
- gtk_widget_hide(entry_name.lbl.ptr);
- gtk_widget_hide(entry_name.ptr);
- gtk_widget_show(button[BTN_QUIT].ptr);
-}
-
-static void show_help_pause (void)
-{
-
- /* Show & hide */
- gtk_widget_hide(button[BTN_CH_OFF].ptr);
- gtk_widget_hide(button[BTN_CH_1].ptr);
- gtk_widget_hide(button[BTN_CH_2].ptr);
- gtk_widget_show(tbutton[TBTN_PAUSE].ptr);
- gtk_widget_show(button[BTN_SAVE].ptr);
- gtk_widget_hide(entry_fname.lbl.ptr);
- gtk_widget_hide(entry_fname.ptr);
- gtk_widget_hide(entry_name.lbl.ptr);
- gtk_widget_hide(entry_name.ptr);
- gtk_widget_show(button[BTN_QUIT].ptr);
-}
-
-static void show_help_xyzzy (void)
-{
-
- /* Show & hide */
- gtk_widget_show(button[BTN_CH_OFF].ptr);
- gtk_widget_show(button[BTN_CH_1].ptr);
- gtk_widget_show(button[BTN_CH_2].ptr);
- gtk_widget_hide(tbutton[TBTN_PAUSE].ptr);
- gtk_widget_show(button[BTN_SAVE].ptr);
- gtk_widget_hide(entry_fname.lbl.ptr);
- gtk_widget_hide(entry_fname.ptr);
- gtk_widget_hide(entry_name.lbl.ptr);
- gtk_widget_hide(entry_name.ptr);
- gtk_widget_show(button[BTN_QUIT].ptr);
-}
-
-static void show_help_cheat (void)
-{
-
- /* Show & hide */
- gtk_widget_hide(button[BTN_CH_OFF].ptr);
- gtk_widget_hide(button[BTN_CH_1].ptr);
- gtk_widget_hide(button[BTN_CH_2].ptr);
- gtk_widget_hide(tbutton[TBTN_PAUSE].ptr);
- gtk_widget_show(button[BTN_SAVE].ptr);
- gtk_widget_hide(entry_fname.lbl.ptr);
- gtk_widget_hide(entry_fname.ptr);
- gtk_widget_hide(entry_name.lbl.ptr);
- gtk_widget_hide(entry_name.ptr);
- gtk_widget_show(button[BTN_QUIT].ptr);
-}
-
-static void show_help_safe (void)
-{
-
- /* Show & hide */
- gtk_widget_hide(button[BTN_CH_OFF].ptr);
- gtk_widget_hide(button[BTN_CH_1].ptr);
- gtk_widget_hide(button[BTN_CH_2].ptr);
- gtk_widget_hide(tbutton[TBTN_PAUSE].ptr);
- gtk_widget_show(button[BTN_SAVE].ptr);
- gtk_widget_hide(entry_fname.lbl.ptr);
- gtk_widget_hide(entry_fname.ptr);
- gtk_widget_hide(entry_name.lbl.ptr);
- gtk_widget_hide(entry_name.ptr);
- gtk_widget_show(button[BTN_QUIT].ptr);
-}
-
-static void show_help_gameover (void)
-{
-
- /* Show & hide */
- gtk_widget_hide(button[BTN_CH_OFF].ptr);
- gtk_widget_hide(button[BTN_CH_1].ptr);
- gtk_widget_hide(button[BTN_CH_2].ptr);
- gtk_widget_hide(tbutton[TBTN_PAUSE].ptr);
- gtk_widget_hide(button[BTN_SAVE].ptr);
- gtk_widget_hide(entry_fname.lbl.ptr);
- gtk_widget_hide(entry_fname.ptr);
- gtk_widget_hide(entry_name.lbl.ptr);
- gtk_widget_hide(entry_name.ptr);
- gtk_widget_show(button[BTN_QUIT].ptr);
-}
-
-/* * * * * * * * * *
- * * * Input * * * * * * *
- * * * * * * * * * */
-static gboolean callback_field (GtkWidget *widget,
- GdkEventButton *event,
- void *data)
-{
- struct Field_Data *field_ij;
-
- if (state == GAME_IFACE_STATE_PLAYING && timeout.id)
- g_source_remove(timeout.id);
-
- field_ij = ((struct Field_Data *)data);
- *(field_ij->row) = field_ij->r;
- *(field_ij->col) = field_ij->c;
-
- switch (event->button) {
- case 1:
- //1 is left mouse btn
- if (event->type == GDK_BUTTON_PRESS)
- *(field_ij->act) = PLAYER_IFACE_ACT_STEP;
- break;
-
- case 3:
- //3 is right mouse btn
- if (event->type == GDK_BUTTON_PRESS)
- *(field_ij->act) = PLAYER_IFACE_ACT_FLAG;
- break;
- }
-
- gtk_main_quit();
-
- return false;
-}
-
-static gboolean callback_ebox (GtkWidget *widget,
- GdkEventButton *event,
- void *data)
-{
- struct EBox_Data *ebox;
-
- if ((state == GAME_IFACE_STATE_PLAYING) && timeout.id)
- g_source_remove(timeout.id);
-
- ebox = ((struct EBox_Data *)data);
-
- switch (event->button) {
- case 1:
- //1 is left mouse btn
- if (event->type == GDK_BUTTON_PRESS)
- *(ebox->act) = ebox->val;
- else if (event->type == GDK_2BUTTON_PRESS)
- ; /* TODO */
- break;
-
- case 3:
- //3 is right mouse btn
- break;
- }
-
- gtk_main_quit();
-
- return false;
-}
-
-static void callback_button (GtkWidget *widget, void *data)
-{
- struct Button_Data *button;
-
- if ((state == GAME_IFACE_STATE_PLAYING) && timeout.id)
- g_source_remove(timeout.id);
-
- button = ((struct Button_Data *)data);
- *(button->act) = button->val;
-
- gtk_main_quit();
-
-}
-
-static gboolean callback_tbutton (GtkWidget *widget, void *data)
-{
- struct TButton_Data *tbutton;
-
- if ((state == GAME_IFACE_STATE_PLAYING) && timeout.id)
- g_source_remove(timeout.id);
-
- tbutton = ((struct TButton_Data *)data);
-
- if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget))) {
- /* If control reaches here, the toggle button is down */
- *(tbutton->act) = tbutton->val;
- gtk_button_set_label(GTK_BUTTON(tbutton[TBTN_PAUSE].ptr), tbutton[TBTN_PAUSE].text2);
- } else {
- /* If control reaches here, the toggle button is up */
- *(tbutton->act) = tbutton->val2;
- gtk_button_set_label(GTK_BUTTON(tbutton[TBTN_PAUSE].ptr), tbutton[TBTN_PAUSE].text);
- }
-
- gtk_main_quit();
-
- return false;
-}
-
-static void callback_entry_fname (GtkWidget *widget, void *data)
-{
- struct Entry_fname_Data *entry;
- const char *str;
- int err;
- char buff [LINE_SIZE];
-
- entry = ((struct Entry_fname_Data *)data);
- str = gtk_entry_get_text(GTK_ENTRY(entry->ptr));
- err = alx_sscan_fname(entry->fpath, entry->fname, false, str);
-
- if (err) {
- snprintf(buff, LINE_SIZE, "Error %i", err);
- gtk_entry_set_text(GTK_ENTRY(entry->ptr), buff);
- gtk_editable_select_region(GTK_EDITABLE(entry->ptr),
- 0, GTK_ENTRY(entry->ptr)->text_length);
- }
-
- gtk_main_quit();
-}
-
-static void callback_entry_str (GtkWidget *widget, void *data)
-{
- struct Entry_str_Data *entry;
- const char *str;
-
- entry = ((struct Entry_str_Data *)data);
- str = gtk_entry_get_text(GTK_ENTRY(entry->ptr));
- snprintf(entry->str, entry->strsize, "%s", str);
-
- gtk_main_quit();
-}
-
-static gboolean callback_timeout (void *data)
-{
- struct Timeout_Data *tout;
-
- tout = ((struct Timeout_Data *)data);
- *(tout->act) = tout->val;
-
- gtk_main_quit();
-
- return false;
-}
-
-
-/******************************************************************************
- ******* end of file **********************************************************
- ******************************************************************************/
diff --git a/modules/player/tmp/Makefile b/modules/player/tmp/Makefile
deleted file mode 100644
index bd3c714..0000000
--- a/modules/player/tmp/Makefile
+++ /dev/null
@@ -1,102 +0,0 @@
-# -*- MakeFile -*-
-
-# MACRO = substitute with this
-
-# directories
-
-LIBALX_INC_DIR = $(LIBALX_DIR)/inc/
-
-GAME_INC_DIR = $(GAME_DIR)/inc/
-MENU_INC_DIR = $(MENU_DIR)/inc/
-
-INC_DIR = $(PLAY_DIR)/inc/
-SRC_DIR = $(PLAY_DIR)/src/
-
-# dependencies
-
-_ALL = player_iface.o player_clui.o player_tui.o player_gui.o
-ALL = $(_ALL) player_mod.o
-
-PLAYI_INC_GAME = game_iface.h
-PLAYI_INC = player_iface.h player_clui.h player_tui.h player_gui.h
-PLAYI_DEPS = $(SRC_DIR)/player_iface.c \
- $(patsubst %,$(INC_DIR)/%,$(PLAYI_INC)) \
- $(patsubst %,$(GAME_INC_DIR)/%,$(PLAYI_INC_GAME))
-PLAYI_INC_DIRS = -I $(INC_DIR) \
- -I $(GAME_INC_DIR)
-
-PLAYCLUI_INC_GAME = game_iface.h
-PLAYCLUI_INC = player_clui.h player_iface.h
-PLAYCLUI_DEPS = $(SRC_DIR)/player_clui.c \
- $(patsubst %,$(INC_DIR)/%,$(PLAYCLUI_INC)) \
- $(patsubst %,$(GAME_INC_DIR)/%,$(PLAYCLUI_INC_GAME))
-PLAYCLUI_INC_DIRS = -I $(INC_DIR) \
- -I $(GAME_INC_DIR)
-
-PLAYTUI_INC_LIBALX = libalx/curses/alx_ncur.h
-PLAYTUI_INC_GAME = game_iface.h
-PLAYTUI_INC = player_tui.h player_iface.h
-PLAYTUI_DEPS = $(SRC_DIR)/player_tui.c \
- $(patsubst %,$(INC_DIR)/%,$(PLAYTUI_INC)) \
- $(patsubst %,$(LIBALX_INC_DIR)/%,$(PLAYTUI_INC_LIBALX)) \
- $(patsubst %,$(GAME_INC_DIR)/%,$(PLAYTUI_INC_GAME))
-PLAYTUI_INC_DIRS = -I $(INC_DIR) \
- -I $(LIBALX_INC_DIR) \
- -I $(GAME_INC_DIR)
-
-PLAYGUI_INC_LIBALX = libalx/io/alx_input.h
-PLAYGUI_INC_GAME = game_iface.h
-PLAYGUI_INC_MENU = menu_gui.h
-PLAYGUI_INC = player_gui.h player_iface.h
-PLAYGUI_DEPS = $(SRC_DIR)/player_gui.c \
- $(patsubst %,$(INC_DIR)/%,$(PLAYGUI_INC)) \
- $(patsubst %,$(LIBALX_INC_DIR)/%,$(PLAYGUI_INC_LIBALX)) \
- $(patsubst %,$(GAME_INC_DIR)/%,$(PLAYGUI_INC_GAME)) \
- $(patsubst %,$(MENU_INC_DIR)/%,$(PLAYGUI_INC_MENU))
-PLAYGUI_INC_DIRS = -I $(INC_DIR) \
- -I $(LIBALX_INC_DIR) \
- -I $(GAME_INC_DIR) \
- -I $(MENU_INC_DIR)
-
-# target: dependencies
-# action
-
-all: $(ALL)
-
-
-player_mod.o: $(_ALL)
- @echo " LD $@"
- $(Q)$(LD) -r $^ -o $@
-
-
-player_iface.s: $(PLAYI_DEPS)
- @echo " CC $@"
- $(Q)$(CC) $(CFLAGS) $(PLAYI_INC_DIRS) -S $< -o $@
-player_iface.o: player_iface.s
- @echo " AS $@"
- $(Q)$(AS) $< -o $@
-
-player_clui.s: $(PLAYCLUI_DEPS)
- @echo " CC $@"
- $(Q)$(CC) $(CFLAGS) $(PLAYCLUI_INC_DIRS) -S $< -o $@
-player_clui.o: player_clui.s
- @echo " AS $@"
- $(Q)$(AS) $< -o $@
-
-player_tui.s: $(PLAYTUI_DEPS)
- @echo " CC $@"
- $(Q)$(CC) $(CFLAGS) $(PLAYTUI_INC_DIRS) -S $< -o $@
-player_tui.o: player_tui.s
- @echo " AS $@"
- $(Q)$(AS) $< -o $@
-
-player_gui.s: $(PLAYGUI_DEPS)
- @echo " CC $@"
- $(Q)$(CC) $(CFLAGS) $(PLAYGUI_INC_DIRS) -S $< -o $@
-player_gui.o: player_gui.s
- @echo " AS $@"
- $(Q)$(AS) $< -o $@
-
-
-clean:
- $(Q)rm -f *.o *.s
diff --git a/modules/save/Makefile b/modules/save/Makefile
deleted file mode 100644
index 614a58c..0000000
--- a/modules/save/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-# -*- MakeFile -*-
-
-# MACRO = substitute with this
-
-# directories
-
-TMP_DIR = $(SAVE_DIR)/tmp/
-
-# target: dependencies
-# action
-
-all:
- $(Q)cd $(TMP_DIR) && $(MAKE) && cd ..
-
-clean:
- $(Q)cd $(TMP_DIR) && $(MAKE) clean && cd ..
-
-################################################################################
-######## End of file ###########################################################
-################################################################################
-######## End of file ###########################################################
-################################################################################
-######## End of file ###########################################################
-################################################################################
diff --git a/modules/save/inc/score.h b/modules/save/inc/score.h
deleted file mode 100644
index fede1f7..0000000
--- a/modules/save/inc/score.h
+++ /dev/null
@@ -1,70 +0,0 @@
-/******************************************************************************
- * Copyright (C) 2015 Alejandro Colomar Andrés *
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* include guard ********************************************************
- ******************************************************************************/
-# ifndef MSW_SCORE_H
- # define MSW_SCORE_H
-
-
-/******************************************************************************
- ******* headers **************************************************************
- ******************************************************************************/
- /* FILENAME_MAX */
- #include <stdio.h>
-
-
-/******************************************************************************
- ******* macros ***************************************************************
- ******************************************************************************/
- # if defined (OS_LINUX)
- # define ENV_HOME "HOME"
- # elif defined (OS_WIN)
- # define ENV_HOME "USERPROFILE"
- # endif
-
- # define HISCORES_DIR "hiscores/"
- # define BOARDS_BEGINNER_DIR "hiscores/boards_beginner/"
- # define BOARDS_INTERMEDIATE_DIR "hiscores/boards_intermediate/"
- # define BOARDS_EXPERT_DIR "hiscores/boards_expert/"
- # define BOARDS_CUSTOM_DIR "hiscores/boards_custom/"
- # define HISCORES_BEGINNER_NAME "hiscores_beginner.mine"
- # define HISCORES_INTERMEDIATE_NAME "hiscores_intermediate.mine"
- # define HISCORES_EXPERT_NAME "hiscores_expert.mine"
-
-
-/******************************************************************************
- ******* variables ************************************************************
- ******************************************************************************/
-extern char var_path [FILENAME_MAX];
-extern char var_hiscores_path [FILENAME_MAX];
-extern char var_boards_beginner_path [FILENAME_MAX];
-extern char var_boards_intermediate_path [FILENAME_MAX];
-extern char var_boards_expert_path [FILENAME_MAX];
-extern char var_boards_custom_path [FILENAME_MAX];
-
-extern char var_hiscores_beginner_name [FILENAME_MAX];
-extern char var_hiscores_intermediate_name [FILENAME_MAX];
-extern char var_hiscores_expert_name [FILENAME_MAX];
-
-
-/******************************************************************************
- ******* functions ************************************************************
- ******************************************************************************/
-void score_init (void);
-void save_score (const struct Game_Iface_Score *game_iface_score);
-void snprint_scores (char *dest, int destsize);
-
-
-/******************************************************************************
- ******* include guard ********************************************************
- ******************************************************************************/
-# endif /* score.h */
-
-
-/******************************************************************************
- ******* end of file **********************************************************
- ******************************************************************************/
diff --git a/modules/save/src/save.c b/modules/save/src/save.c
deleted file mode 100644
index d1245e0..0000000
--- a/modules/save/src/save.c
+++ /dev/null
@@ -1,255 +0,0 @@
-/******************************************************************************
- * Copyright (C) 2015 Alejandro Colomar Andrés *
- * SPDX-License-Identifier: GPL-2.0-only *
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* headers **************************************************************
- ******************************************************************************/
- #include <errno.h>
- #include <stdbool.h>
- #include <stdio.h>
- #include <stdlib.h>
-
- /* mkdir */
- #include <sys/stat.h>
-
- #include "game.h"
- #include "player_iface.h"
-
- #include "save.h"
-
-
-/******************************************************************************
- ******* variables ************************************************************
- ******************************************************************************/
- char home_path [FILENAME_MAX];
- char user_game_path [FILENAME_MAX];
- char saved_path [FILENAME_MAX];
- char saved_name [FILENAME_MAX];
-
-
-/******************************************************************************
- ******* global functions *****************************************************
- ******************************************************************************/
-void save_init (void)
-{
-
- if (snprintf(home_path, FILENAME_MAX, "%s/",
- getenv(ENV_HOME)) >= FILENAME_MAX) {
- goto err_path;
- }
- if (snprintf(user_game_path, FILENAME_MAX, "%s/%s/",
- home_path, USER_GAME_DIR) >= FILENAME_MAX) {
- goto err_path;
- }
- if (snprintf(saved_path, FILENAME_MAX, "%s/%s/",
- home_path, USER_SAVED_DIR) >= FILENAME_MAX) {
- goto err_path;
- }
- saved_name[0] = '\0';
-
- if (mkdir(user_game_path, 0700)) {
- switch (errno) {
- case EACCES:
- printf("err = EACCES");
- exit(EXIT_FAILURE);
- case EEXIST:
- /* OK */
- return;
- default:
- printf("WTF?!");
- exit(EXIT_FAILURE);
- }
- }
- if (mkdir(saved_path, 0700)) {
- switch (errno) {
- case EACCES:
- printf("err = EACCES");
- exit(EXIT_FAILURE);
- case EEXIST:
- /* OK */
- return;
- default:
- printf("WTF?!");
- exit(EXIT_FAILURE);
- }
- }
-
- return;
-
-
-err_path:
- printf("Path is too large and has been truncated\n");
- getchar();
- exit(EXIT_FAILURE);
-}
-
-void save_clr (void)
-{
-
- if (snprintf(saved_path, FILENAME_MAX, "%s/%s/",
- home_path, USER_SAVED_DIR) >= FILENAME_MAX) {
- goto err_path;
- }
-
- return;
-
-
-err_path:
- printf("Path is too large and has been truncated\n");
- getchar();
- exit(EXIT_FAILURE);
-}
-
-void load_game_file (void)
-{
- char file_name [FILENAME_MAX];
- FILE *fp;
- int i;
- int j;
-
- if (snprintf(file_name, FILENAME_MAX, "%s/%s",
- saved_path, saved_name) >= FILENAME_MAX) {
- goto err_path;
- }
-
- fp = fopen(file_name, "r");
- if (fp) {
- fscanf(fp, "mine-sweeper saved game");
- fscanf(fp, " rows %i", &game_board.rows);
- fscanf(fp, " cols %i", &game_board.cols);
- fscanf(fp, " mines %i", &game_board.mines);
- fscanf(fp, " gnd");
- for (i = 0; i < game_board.rows; i++) {
- fscanf(fp, " %i", &game_board.gnd[i][0]);
- for (j = 1; j < game_board.cols; j++)
- fscanf(fp, ",%i", &game_board.gnd[i][j]);
- }
- fscanf(fp, " usr");
- for (i = 0; i < game_board.rows; i++) {
- fscanf(fp, " %i", &game_board.usr[i][0]);
- for (j = 1; j < game_board.cols; j++)
- fscanf(fp, ",%i", &game_board.usr[i][j]);
- }
- fscanf(fp, " flags %i", &game_board.flags);
- fscanf(fp, " cleared %i", &game_board.clr);
-
- fclose(fp);
- }
-
- return;
-
-
-err_path:
- printf("Path is too large and has been truncated\n");
- getchar();
- exit(EXIT_FAILURE);
-}
-
-void save_game_file (char *filepath)
-{
- char file_name [FILENAME_MAX];
- char tmp [FILENAME_MAX];
- char old_saved [FILENAME_MAX];
- char file_num [6];
- FILE *fp;
- int i;
- int j;
- bool x;
-
- /* Don't change saved_name variable if not in default dir */
- if (filepath)
- snprintf(old_saved, FILENAME_MAX, "%s", saved_name);
-
- /* Default path & name */
- save_clr();
- snprintf(saved_name, FILENAME_MAX, "%s", SAVED_NAME_DEFAULT);
- file_num[0] = '\0';
-
- /* Request file name */
- player_iface_save_name(filepath, saved_name, FILENAME_MAX);
-
- /* Look for an unused name of the type 'name_XXX.mine'. */
- x = true;
- for (i = 0; x; i++) {
- if (filepath == NULL) {
- if (snprintf(file_name, FILENAME_MAX, "%s/%s%s%s",
- saved_path,
- saved_name, file_num,
- FILE_EXTENSION) >= FILENAME_MAX) {
- goto err_path;
- }
- } else {
- if (snprintf(file_name, FILENAME_MAX, "%s/%s%s%s",
- filepath,
- saved_name, file_num,
- FILE_EXTENSION) >= FILENAME_MAX) {
- goto err_path;
- }
- }
-
- fp = fopen(file_name, "r");
- if (fp) {
- fclose(fp);
- file_num[0] = '_';
- file_num[1] = '0' + ((i / 100) % 10);
- file_num[2] = '0' + ((i / 10) % 10);
- file_num[3] = '0' + (i % 10);
- file_num[4] = '\0';
- } else {
- x = false;
- if (snprintf(tmp, FILENAME_MAX, "%s%s%s",
- saved_name, file_num,
- FILE_EXTENSION) >= FILENAME_MAX) {
- goto err_path;
- }
- snprintf(saved_name, FILENAME_MAX, "%s", tmp);
- }
- }
-
- /* Write to a new file */
- fp = fopen(file_name, "w");
- if (fp) {
- fprintf(fp, "mine-sweeper saved game\n");
- fprintf(fp, "rows %i\n", game_board.rows);
- fprintf(fp, "cols %i\n", game_board.cols);
- fprintf(fp, "mines %i\n", game_board.mines);
- fprintf(fp, "gnd\n");
- for (i = 0; i < game_board.rows; i++) {
- fprintf(fp, "%i", game_board.gnd[i][0]);
- for (j = 1; j < game_board.cols; j++)
- fprintf(fp, ",%i", game_board.gnd[i][j]);
- fprintf(fp, "\n");
- }
- fprintf(fp, "usr\n");
- for (i = 0; i < game_board.rows; i++) {
- fprintf(fp, "%i", game_board.usr[i][0]);
- for (j = 1; j < game_board.cols; j++)
- fprintf(fp, ",%i", game_board.usr[i][j]);
- fprintf(fp, "\n");
- }
- fprintf(fp, "flags %i\n", game_board.flags);
- fprintf(fp, "cleared %i\n", game_board.clr);
-
- fclose(fp);
- }
-
- /* Don't change saved_name if saving in non-default dir */
- if (filepath)
- snprintf(saved_name, FILENAME_MAX, "%s", old_saved);
-
- return;
-
-
-err_path:
- printf("Path is too large and has been truncated\n");
- getchar();
- exit(EXIT_FAILURE);
-}
-
-
-/******************************************************************************
- ******* end of file **********************************************************
- ******************************************************************************/
diff --git a/modules/save/src/score.c b/modules/save/src/score.c
deleted file mode 100644
index 21f7602..0000000
--- a/modules/save/src/score.c
+++ /dev/null
@@ -1,311 +0,0 @@
-/******************************************************************************
- * Copyright (C) 2015 Alejandro Colomar Andrés *
- * SPDX-License-Identifier: GPL-2.0-only *
- ******************************************************************************/
-
-
-/******************************************************************************
- ******* headers **************************************************************
- ******************************************************************************/
-/* Standard C ----------------------------------------------------------------*/
- #include <errno.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
-/* Project -------------------------------------------------------------------*/
- #include "game.h"
- #include "game_iface.h"
- #include "player_iface.h"
-
- #include "save.h"
-
- #include "score.h"
-
-
-/******************************************************************************
- ******* macros ***************************************************************
- ******************************************************************************/
- # define BUFF_SIZE (1024)
- # define BUFF_SIZE_TEXT (1048576)
-
-
-/******************************************************************************
- ******* variables ************************************************************
- ******************************************************************************/
- char var_path [FILENAME_MAX];
- char var_hiscores_path [FILENAME_MAX];
- char var_boards_beginner_path [FILENAME_MAX];
- char var_boards_intermediate_path [FILENAME_MAX];
- char var_boards_expert_path [FILENAME_MAX];
- char var_boards_custom_path [FILENAME_MAX];
-
- char var_hiscores_beginner_name [FILENAME_MAX];
- char var_hiscores_intermediate_name [FILENAME_MAX];
- char var_hiscores_expert_name [FILENAME_MAX];
-
-
-/******************************************************************************
- ******* static functions *****************************************************
- ******************************************************************************/
-static void snprint_scores_file (char *dest, int destsize, char *file_name);
-
-
-/******************************************************************************
- ******* global functions *****************************************************
- ******************************************************************************/
-void score_init (void)
-{
-
- if (snprintf(var_path, FILENAME_MAX, "%s/%s/",
- INSTALL_VAR_DIR, VAR_DIR) >= FILENAME_MAX) {
- goto err_path;
- }
- if (snprintf(var_hiscores_path, FILENAME_MAX, "%s/%s/",
- var_path, HISCORES_DIR) >= FILENAME_MAX) {
- goto err_path;
- }
- if (snprintf(var_boards_beginner_path, FILENAME_MAX, "%s/%s/",
- var_path, BOARDS_BEGINNER_DIR) >= FILENAME_MAX) {
- goto err_path;
- }
- if (snprintf(var_boards_intermediate_path, FILENAME_MAX, "%s/%s/",
- var_path, BOARDS_INTERMEDIATE_DIR) >= FILENAME_MAX) {
- goto err_path;
- }
- if (snprintf(var_boards_expert_path, FILENAME_MAX, "%s/%s/",
- var_path, BOARDS_EXPERT_DIR) >= FILENAME_MAX) {
- goto err_path;
- }
- if (snprintf(var_boards_custom_path, FILENAME_MAX, "%s/%s/",
- var_path, BOARDS_CUSTOM_DIR) >= FILENAME_MAX) {
- goto err_path;
- }
- snprintf(var_hiscores_beginner_name, FILENAME_MAX, "%s",
- HISCORES_BEGINNER_NAME);
- snprintf(var_hiscores_intermediate_name, FILENAME_MAX, "%s",
- HISCORES_INTERMEDIATE_NAME);
- snprintf(var_hiscores_expert_name, FILENAME_MAX, "%s",
- HISCORES_EXPERT_NAME);
-
- return;
-
-
-err_path:
- printf("Path is too large and has been truncated\n");
- getchar();
- exit(EXIT_FAILURE);
-}
-
-void save_score (const struct Game_Iface_Score *game_iface_score)
-{
- struct tm *date_format;
- char file_name [FILENAME_MAX];
- char player_name [BUFF_SIZE];
- FILE *fp;
- time_t date_secs;
-
- /* File name */
- switch (game_iface_score->level) {
- case GAME_IFACE_LEVEL_BEGINNER:
- if (snprintf(file_name, FILENAME_MAX, "%s/%s",
- var_hiscores_path,
- var_hiscores_beginner_name) >=
- FILENAME_MAX) {
- goto err_path;
- }
- break;
-
- case GAME_IFACE_LEVEL_INTERMEDIATE:
- if (snprintf(file_name, FILENAME_MAX, "%s/%s",
- var_hiscores_path,
- var_hiscores_intermediate_name) >=
- FILENAME_MAX) {
- goto err_path;
- }
- break;
-
- case GAME_IFACE_LEVEL_EXPERT:
- if (snprintf(file_name, FILENAME_MAX, "%s/%s",
- var_hiscores_path,
- var_hiscores_expert_name) >=
- FILENAME_MAX) {
- goto err_path;
- }
- break;
- }
-
- /* Date & time */
- date_secs = time(NULL);
- date_format = localtime(&date_secs);
-
- /* Player name (foo is default) */
- player_iface_score_name(player_name, BUFF_SIZE);
-
- /* Write to file (append) */
- errno = 0;
- fp = fopen(file_name, "a");
- if (!fp)
- goto err_fp;
- fprintf(fp, "\n");
- fprintf(fp, "name %s\n", player_name);
- fprintf(fp, "date %i\n", (int)date_secs);
- fprintf(fp, "{\n");
- fprintf(fp, " isdst %i\n", date_format->tm_isdst);
- fprintf(fp, " yday %i\n", date_format->tm_yday);
- fprintf(fp, " wday %i\n", date_format->tm_wday);
- fprintf(fp, " year %i\n", date_format->tm_year);
- fprintf(fp, " mon %i\n", date_format->tm_mon);
- fprintf(fp, " mday %i\n", date_format->tm_mday);
- fprintf(fp, " hour %i\n", date_format->tm_hour);
- fprintf(fp, " min %i\n", date_format->tm_min);
- fprintf(fp, " sec %i\n", date_format->tm_sec);
- fprintf(fp, "}\n");
- fprintf(fp, "time %i\n", game_iface_score->time);
- fprintf(fp, "clicks %i\n", game_iface_score->clicks);
- fprintf(fp, "file %s\n", saved_name);
- fclose(fp);
-
- return;
-
-
-err_path:
- printf("Path is too large and has been truncated\n");
- printf("Score could not be saved!\n");
- return;
-
-err_fp:
- printf("errno: %i", errno);
- printf("Score could not be saved!\n");
- return;
-}
-
-void snprint_scores (char *dest, int destsize)
-{
- char file_name [FILENAME_MAX];
- char tmp1 [BUFF_SIZE_TEXT];
- char tmp2 [BUFF_SIZE_TEXT];
-
- /* Beginner */
- if (snprintf(file_name, FILENAME_MAX, "%s/%s",
- var_hiscores_path,
- var_hiscores_beginner_name) >=
- FILENAME_MAX) {
- goto err_path;
- }
- (void)snprint_scores_file(dest, destsize, file_name);
-
- /* Intermediate */
- if (snprintf(file_name, FILENAME_MAX, "%s/%s",
- var_hiscores_path,
- var_hiscores_intermediate_name) >=
- FILENAME_MAX) {
- goto err_path;
- }
- (void)snprint_scores_file(tmp1, destsize, file_name);
- (void)snprintf(tmp2, destsize, "%s%s", dest, tmp1);
- (void)snprintf(dest, destsize, "%s", tmp2);
-
- /* Expert */
- if (snprintf(file_name, FILENAME_MAX, "%s/%s",
- var_hiscores_path,
- var_hiscores_expert_name) >=
- FILENAME_MAX) {
- goto err_path;
- }
- (void)snprint_scores_file(tmp1, destsize, file_name);
- (void)snprintf(tmp2, destsize, "%s%s", dest, tmp1);
- (void)snprintf(dest, destsize, "%s", tmp2);
-
- return;
-
-
-err_path:
- printf("Path is too large and has been truncated\n");
- printf("Score could not be shown!\n");
-}
-
-
-/******************************************************************************
- ******* static functions *****************************************************
- ******************************************************************************/
-static void snprint_scores_file (char *dest, int destsize, char *file_name)
-{
- FILE *fp;
- int c;
- char tmp [BUFF_SIZE_TEXT];
- char title [BUFF_SIZE];
- char name [BUFF_SIZE];
- int year;
- int mon;
- int day;
- int time;
- int hours;
- int mins;
- int secs;
- int clicks;
- char file [FILENAME_MAX];
-
- fp = fopen(file_name, "r");
- if (!fp)
- return;
-
- /* Title */
- fscanf(fp, "%[^\n]s", title);
- /* For some reason, a space after "%[^\n]s" doesn't skip spaces */
- fscanf(fp, " ");
-
- /* Print */
- (void)snprintf(dest, destsize,
- "_______________________________________________________\n"
- "%s\n\n"
- "name date clicks time file\n\n",
- title);
-
- while ((c = getc(fp)) != EOF) {
- ungetc(c, fp);
-
- /* Read */
- fscanf(fp, "name %s ", name);
- fscanf(fp, "date %*i ");
- fscanf(fp, "{ ");
- fscanf(fp, " isdst %*i ");
- fscanf(fp, " yday %*i ");
- fscanf(fp, " wday %*i ");
- fscanf(fp, " year %i ", &year);
- fscanf(fp, " mon %i ", &mon);
- fscanf(fp, " mday %i ", &day);
- fscanf(fp, " hour %*i ");
- fscanf(fp, " min %*i ");
- fscanf(fp, " sec %*i ");
- fscanf(fp, "} ");
- fscanf(fp, "time %i ", &time);
- fscanf(fp, "clicks %i ", &clicks);
- fscanf(fp, "file %s ", file);
-
- /* Adjust date & time */
- year += 1900;
- hours = (time / 3600);
- mins = ((time % 3600) / 60);
- secs = (time % 60);
-
- /* Print */
- (void)snprintf(tmp, BUFF_SIZE_TEXT,
- "%s"
- "%s\n"
- " %4i/%2i/%2i %i %i:%02i:%02i \t%s\n\n",
- dest,
- name,
- year, 1 + mon, day,
- clicks,
- hours, mins, secs,
- file);
- (void)snprintf(dest, BUFF_SIZE_TEXT, "%s", tmp);
- }
-
- fclose(fp);
-}
-
-
-/******************************************************************************
- ******* end of file **********************************************************
- ******************************************************************************/
diff --git a/modules/save/tmp/Makefile b/modules/save/tmp/Makefile
deleted file mode 100644
index c096cb0..0000000
--- a/modules/save/tmp/Makefile
+++ /dev/null
@@ -1,67 +0,0 @@
-# -*- MakeFile -*-
-
-# MACRO = substitute with this
-
-# directories
-
-GAME_INC_DIR = $(GAME_DIR)/inc/
-PLAY_INC_DIR = $(PLAY_DIR)/inc/
-
-INC_DIR = $(SAVE_DIR)/inc/
-SRC_DIR = $(SAVE_DIR)/src/
-
-# dependencies
-
-_ALL = save.o score.o
-ALL = $(_ALL) save_mod.o
-
-SAVE_INC_PLAY = player_iface.h
-SAVE_INC_GAME = game.h
-SAVE_INC = save.h
-SAVE_DEPS = $(SRC_DIR)/save.c \
- $(patsubst %,$(INC_DIR)/%,$(SAVE_INC)) \
- $(patsubst %,$(GAME_INC_DIR)/%,$(SAVE_INC_GAME)) \
- $(patsubst %,$(PLAY_INC_DIR)/%,$(SAVE_INC_PLAY))
-SAVE_INC_DIRS = -I $(INC_DIR) \
- -I $(GAME_INC_DIR) \
- -I $(PLAY_INC_DIR)
-
-SCORE_INC_PLAY = player_iface.h
-SCORE_INC_GAME = game.h game_iface.h
-SCORE_INC = score.h
-SCORE_DEPS = $(SRC_DIR)/score.c \
- $(patsubst %,$(INC_DIR)/%,$(SCORE_INC)) \
- $(patsubst %,$(GAME_INC_DIR)/%,$(SCORE_INC_GAME)) \
- $(patsubst %,$(PLAY_INC_DIR)/%,$(SCORE_INC_PLAY))
-SCORE_INC_DIRS = -I $(INC_DIR) \
- -I $(GAME_INC_DIR) \
- -I $(PLAY_INC_DIR)
-
-# target: dependencies
-# action
-
-all: $(ALL)
-
-
-save_mod.o: $(_ALL)
- @echo " LD $@"
- $(Q)$(LD) -r $^ -o $@
-
-
-save.s: $(SAVE_DEPS)
- @echo " CC $@"
- $(Q)$(CC) $(CFLAGS) $(SAVE_INC_DIRS) -S $< -o $@
-save.o: save.s
- @echo " AS $@"
- $(Q)$(AS) $< -o $@
-
-score.s: $(SCORE_DEPS)
- @echo " CC $@"
- $(Q)$(CC) $(CFLAGS) $(SCORE_INC_DIRS) -S $< -o $@
-score.o: score.s
- @echo " AS $@"
- $(Q)$(AS) $< -o $@
-
-
-clean:
- $(Q)rm -f *.o *.s
diff --git a/modules/tmp/Makefile b/modules/tmp/Makefile
deleted file mode 100644
index 3cf4748..0000000
--- a/modules/tmp/Makefile
+++ /dev/null
@@ -1,46 +0,0 @@
-# -*- MakeFile -*-
-
-# MACRO = substitute with this
-
-# directories
-
-ABOUT_TMP_DIR = $(ABOUT_DIR)/tmp/
-CTRL_TMP_DIR = $(CTRL_DIR)/tmp/
-GAME_TMP_DIR = $(GAME_DIR)/tmp/
-MENU_TMP_DIR = $(MENU_DIR)/tmp/
-PLAY_TMP_DIR = $(PLAY_DIR)/tmp/
-SAVE_TMP_DIR = $(SAVE_DIR)/tmp/
-XYZZY_TMP_DIR = $(XYZZY_DIR)/tmp/
-
-# dependencies
-
-ALL = modules.o
-
-MODS_OBJ_ABOUT = about_mod.o
-MODS_OBJ_CTRL = ctrl_mod.o
-MODS_OBJ_GAME = game_mod.o
-MODS_OBJ_MENU = menu_mod.o
-MODS_OBJ_PLAY = player_mod.o
-MODS_OBJ_SAVE = save_mod.o
-MODS_OBJ_XYZZY = xyzzy_mod.o
-MODS_OBJS = $(patsubst %,$(ABOUT_TMP_DIR)/%,$(MODS_OBJ_ABOUT)) \
- $(patsubst %,$(CTRL_TMP_DIR)/%,$(MODS_OBJ_CTRL)) \
- $(patsubst %,$(GAME_TMP_DIR)/%,$(MODS_OBJ_GAME)) \
- $(patsubst %,$(MENU_TMP_DIR)/%,$(MODS_OBJ_MENU)) \
- $(patsubst %,$(PLAY_TMP_DIR)/%,$(MODS_OBJ_PLAY)) \
- $(patsubst %,$(SAVE_TMP_DIR)/%,$(MODS_OBJ_SAVE)) \
- $(patsubst %,$(XYZZY_TMP_DIR)/%,$(MODS_OBJ_XYZZY))
-
-# target: dependencies
-# action
-
-all: $(ALL)
-
-
-modules.o: $(MODS_OBJS)
- @echo " LD $@"
- $(Q)$(LD) -r $^ -o $@
-
-
-clean:
- $(Q)rm -f *.o
diff --git a/modules/xyzzy/Makefile b/modules/xyzzy/Makefile
deleted file mode 100644
index 8cc4244..0000000
--- a/modules/xyzzy/Makefile
+++ /dev/null
@@ -1,24 +0,0 @@
-# -*- MakeFile -*-
-
-# MACRO = substitute with this
-
-# directories
-
-TMP_DIR = $(XYZZY_DIR)/tmp/
-
-# target: dependencies
-# action
-
-all:
- $(Q)cd $(TMP_DIR) && $(MAKE) && cd ..
-
-clean:
- $(Q)cd $(TMP_DIR) && $(MAKE) clean && cd ..
-
-################################################################################
-######## End of file ###########################################################
-################################################################################
-######## End of file ###########################################################
-################################################################################
-######## End of file ###########################################################
-################################################################################
diff --git a/modules/xyzzy/tmp/Makefile b/modules/xyzzy/tmp/Makefile
deleted file mode 100644
index dc82625..0000000
--- a/modules/xyzzy/tmp/Makefile
+++ /dev/null
@@ -1,45 +0,0 @@
-# -*- MakeFile -*-
-
-# MACRO = substitute with this
-
-# directories
-
-GAME_INC_DIR = $(GAME_DIR)/inc/
-
-INC_DIR = $(XYZZY_DIR)/inc/
-SRC_DIR = $(XYZZY_DIR)/src/
-
-# dependencies
-
-_ALL = xyzzy.o
-ALL = $(_ALL) xyzzy_mod.o
-
-XYZZY_INC_GAME = game_iface.h
-XYZZY_INC = xyzzy.h
-XYZZY_DEPS = $(SRC_DIR)/xyzzy.c \
- $(patsubst %,$(INC_DIR)/%,$(XYZZY_INC)) \
- $(patsubst %,$(GAME_INC_DIR)/%,$(XYZZY_INC_GAME))
-XYZZY_INC_DIRS = -I $(INC_DIR) \
- -I $(GAME_INC_DIR)
-
-# target: dependencies
-# action
-
-all: $(ALL)
-
-
-xyzzy_mod.o: $(_ALL)
- @echo " LD $@"
- $(Q)$(LD) -r $^ -o $@
-
-
-xyzzy.s: $(XYZZY_DEPS)
- @echo " CC $@"
- $(Q)$(CC) $(CFLAGS) $(XYZZY_INC_DIRS) -S $< -o $@
-xyzzy.o: xyzzy.s
- @echo " AS $@"
- $(Q)$(AS) $< -o $@
-
-
-clean:
- $(Q)rm -f *.o *.s
diff --git a/share/COPYRIGHT.txt b/share/mine-sweeper/COPYRIGHT.txt
index f4b79da..f4b79da 100644..100755
--- a/share/COPYRIGHT.txt
+++ b/share/mine-sweeper/COPYRIGHT.txt
diff --git a/share/DISCLAIMER.txt b/share/mine-sweeper/DISCLAIMER.txt
index 291440a..291440a 100644..100755
--- a/share/DISCLAIMER.txt
+++ b/share/mine-sweeper/DISCLAIMER.txt
diff --git a/share/HELP.txt b/share/mine-sweeper/HELP.txt
index 3f66acb..3f66acb 100644..100755
--- a/share/HELP.txt
+++ b/share/mine-sweeper/HELP.txt
diff --git a/share/LICENSE.txt b/share/mine-sweeper/LICENSE.txt
index 81c77e6..81c77e6 100644..100755
--- a/share/LICENSE.txt
+++ b/share/mine-sweeper/LICENSE.txt
diff --git a/share/README.txt b/share/mine-sweeper/README.txt
index c399fe2..c399fe2 100644..100755
--- a/share/README.txt
+++ b/share/mine-sweeper/README.txt
diff --git a/share/USAGE.txt b/share/mine-sweeper/USAGE.txt
index 043fe24..043fe24 100644..100755
--- a/share/USAGE.txt
+++ b/share/mine-sweeper/USAGE.txt
diff --git a/share/saved/saved_000.mine b/share/mine-sweeper/saved/saved_000.mine
index 536ccf9..536ccf9 100644..100755
--- a/share/saved/saved_000.mine
+++ b/share/mine-sweeper/saved/saved_000.mine
diff --git a/modules/game/inc/game.h b/src/about/about.c
index 6f95868..0d7cee2 100644..100755
--- a/modules/game/inc/game.h
+++ b/src/about/about.c
@@ -1,93 +1,93 @@
/******************************************************************************
* Copyright (C) 2015 Alejandro Colomar Andrés *
+ * SPDX-License-Identifier: GPL-2.0-only *
******************************************************************************/
/******************************************************************************
- ******* include guard ********************************************************
+ ******* headers **************************************************************
******************************************************************************/
-# ifndef MSW_GAME_H
- # define MSW_GAME_H
+#include "mine-sweeper/about/about.h"
+
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "libalx/base/errno/perror.h"
+#include "libalx/base/stddef/size.h"
/******************************************************************************
- ******* headers **************************************************************
+ ******* macros ***************************************************************
******************************************************************************/
-/* Standard C ----------------------------------------------------------------*/
- #include <stdbool.h>
-
-/* Project -------------------------------------------------------------------*/
- /* ¡ Need to include these in the Makefile ! */
- /* ROWS_MAX & COLS_MAX */
- #include "game_iface.h"
/******************************************************************************
******* enums ****************************************************************
******************************************************************************/
- enum Game_Mine_Board {
- GAME_MINE_NO = 0,
- GAME_MINE_YES = 9
- };
-
- enum Game_Usr_Board {
- GAME_USR_KBOOM = -1,
- GAME_USR_HIDDEN,
- GAME_USR_CLEAR,
- GAME_USR_FLAG,
- GAME_USR_POSSIBLE
- };
-
- enum Game_Action {
- GAME_ACT_FOO = 0,
- GAME_ACT_STEP,
- GAME_ACT_FLAG,
- GAME_ACT_FLAG_POSSIBLE,
- GAME_ACT_RM_FLAG
- };
-
- enum Game_State {
- GAME_STATE_PLAYING = 0,
- GAME_STATE_SAFE,
- GAME_STATE_GAMEOVER
- };
-
/******************************************************************************
- ******* structs **************************************************************
+ ******* structs / unions *****************************************************
******************************************************************************/
- struct Game_Board {
- int rows;
- int cols;
- int mines;
- int gnd [ROWS_MAX] [COLS_MAX];
- int usr [ROWS_MAX] [COLS_MAX];
- int flags;
- int clr;
- int state;
- };
/******************************************************************************
******* variables ************************************************************
******************************************************************************/
-extern struct Game_Board game_board;
/******************************************************************************
- ******* functions ************************************************************
+ ******* static functions (prototypes) ****************************************
+ ******************************************************************************/
+
+
+/******************************************************************************
+ ******* global functions *****************************************************
******************************************************************************/
-void game_init (void);
-void game_init_rand (int rows, int cols, int mines, int pos_row, int pos_col);
-void game_init_load (int *rows, int *cols);
-void game_action (int action, int row, int col);
+void print_share_file (int file)
+{
+ char *fname;
+ char cmd[_POSIX_ARG_MAX];
+
+ switch (file) {
+ case SHARE_COPYRIGHT:
+ fname = SHARE_COPYRIGHT_FILE;
+ break;
+ case SHARE_DISCLAIMER:
+ fname = SHARE_DISCLAIMER_FILE;
+ break;
+ case SHARE_HELP:
+ fname = SHARE_HELP_FILE;
+ break;
+ case SHARE_LICENSE:
+ fname = SHARE_LICENSE_FILE;
+ break;
+ case SHARE_USAGE:
+ fname = SHARE_USAGE_FILE;
+ break;
+ }
+
+ if (snprintf(cmd, sizeof(cmd), "less %s", fname) >= SSIZEOF(cmd))
+ goto err;
+ if (system(cmd))
+ alx_perror(NULL);
+
+ return;
+err:
+ alx_perror(cmd);
+}
+
+void print_version (void)
+{
+
+ printf("%s %s\n\n", PROG_NAME, PROG_VERSION);
+}
/******************************************************************************
- ******* include guard ********************************************************
+ ******* static functions (definitions) ***************************************
******************************************************************************/
-# endif /* game.h */
/******************************************************************************
diff --git a/modules/ctrl/src/start.c b/src/ctrl/start.c
index 7a31810..1e62b88 100644..100755
--- a/modules/ctrl/src/start.c
+++ b/src/ctrl/start.c
@@ -6,15 +6,17 @@
/******************************************************************************
******* headers **************************************************************
******************************************************************************/
-/* Standard C ----------------------------------------------------------------*/
- #include <errno.h>
-/* Project -------------------------------------------------------------------*/
- #include "game.h"
- #include "game_iface.h"
- #include "menu_iface.h"
- #include "player_iface.h"
+#include "mine-sweeper/ctrl/start.h"
- #include "start.h"
+#include <errno.h>
+#include <stddef.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "mine-sweeper/game/core.h"
+#include "mine-sweeper/game/iface.h"
+#include "mine-sweeper/menu/iface.h"
+#include "mine-sweeper/player/iface.h"
/******************************************************************************
@@ -41,11 +43,9 @@ void start_switch (void)
case START_FOO:
start_foo();
break;
-
case START_RAND:
start_rand();
break;
-
case START_LOAD:
start_load();
break;
@@ -58,56 +58,50 @@ void start_switch (void)
******************************************************************************/
static void start_foo (void)
{
-
- /* empty */
- ;
}
static void start_rand (void)
{
- int level;
- int rows;
- int cols;
- int mines;
- bool fail;
- int r;
- int c;
+ int level;
+ ptrdiff_t rows, cols;
+ int mines;
+ ptrdiff_t r, c;
menu_iface_board(&level, &rows, &cols, &mines);
player_iface_init(rows, cols);
- fail = player_iface_start(&r, &c);
- if (!fail) {
- game_init_rand(rows, cols, mines, r, c);
- game_iface_init_rand(level, r, c);
- /* game loop */
- game_iface();
- }
+ if (player_iface_start(&r, &c))
+ goto err;
+ game_init_rand(rows, cols, mines, r, c);
+ game_iface_init_rand(level, r, c);
+ /* game loop */
+ game_iface();
+
+err:
player_iface_cleanup();
}
static void start_load (void)
{
- int rows;
- int cols;
+ ptrdiff_t rows, cols;
/* size & game init (sets errno) */
errno = 0;
- game_init_load(&rows, &cols);
+ if (game_init_load(&rows, &cols))
+ goto err;
- if (!errno) {
- /* player iface init */
- player_iface_init(rows, cols);
+ player_iface_init(rows, cols);
+ game_iface_init_load();
- /* game iface init */
- game_iface_init_load();
+ /* game loop */
+ game_iface();
- /* game loop */
- game_iface();
+ player_iface_cleanup();
+ return;
- /* user iface cluanup */
- player_iface_cleanup();
- }
+err:
+ fprintf(stderr, "%s:%i: %s(): %s", __FILE__, __LINE__, __func__,
+ strerror(errno));
}
diff --git a/modules/game/src/game.c b/src/game/core.c
index 1f912dd..aa694b7 100644..100755
--- a/modules/game/src/game.c
+++ b/src/game/core.c
@@ -6,16 +6,18 @@
/******************************************************************************
******* headers **************************************************************
******************************************************************************/
- #include <stdbool.h>
- #include <stdlib.h>
- #include <time.h>
- #include <unistd.h>
+#include "mine-sweeper/game/core.h"
- #include "libalx/alx_seed.h"
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdlib.h>
+#include <time.h>
- #include "save.h"
+#include <unistd.h>
- #include "game.h"
+#include "libalx/base/stdlib/seed_mix.h"
+
+#include "mine-sweeper/save/save.h"
/******************************************************************************
@@ -31,22 +33,22 @@
******************************************************************************/
/* Init */
static void game_init_clr (void);
-static void game_init_mines (int pos_row, int pos_col);
+static void game_init_mines (ptrdiff_t pos_row, ptrdiff_t pos_col);
static void game_init_adjnums (void);
/* Step */
-static void game_step (int r, int c);
-static void game_discover (int r, int c);
-static void game_discover_recursive (int r, int c);
-static void game_big_step (int r, int c);
-static int game_count_flags (int r, int c);
-static void game_step_recursive (int r, int c);
+static void game_step (ptrdiff_t r, ptrdiff_t c);
+static void game_discover (ptrdiff_t r, ptrdiff_t c);
+static void game_discover_recursive (ptrdiff_t r, ptrdiff_t c);
+static void game_big_step (ptrdiff_t r, ptrdiff_t c);
+static int game_count_flags (ptrdiff_t r, ptrdiff_t c);
+static void game_step_recursive (ptrdiff_t r, ptrdiff_t c);
/* Flag */
-static void game_flag (int r, int c);
-static void game_possible (int r, int c);
-static void game_rmflag (int r, int c);
-static void game_all_flags (int r, int c);
-static int game_count_nclear (int r, int c);
-static void game_flag_recursive (int r, int c);
+static void game_flag (ptrdiff_t r, ptrdiff_t c);
+static void game_possible (ptrdiff_t r, ptrdiff_t c);
+static void game_rmflag (ptrdiff_t r, ptrdiff_t c);
+static void game_all_flags (ptrdiff_t r, ptrdiff_t c);
+static int game_count_nclear (ptrdiff_t r, ptrdiff_t c);
+static void game_flag_recursive (ptrdiff_t r, ptrdiff_t c);
/******************************************************************************
@@ -54,13 +56,16 @@ static void game_flag_recursive (int r, int c);
******************************************************************************/
void game_init (void)
{
- int seed;
- seed = seedf(clock(), time(NULL), getpid());
+ unsigned seed;
+
+ seed = alx_seed_mix(clock(), time(NULL), getpid());
srand(seed);
}
-void game_init_rand (int rows, int cols, int mines, int pos_row, int pos_col)
+void game_init_rand (ptrdiff_t rows, ptrdiff_t cols, int mines,
+ ptrdiff_t pos_row, ptrdiff_t pos_col)
{
+
/* size & mines */
game_board.rows = rows;
game_board.cols = cols;
@@ -76,16 +81,19 @@ void game_init_rand (int rows, int cols, int mines, int pos_row, int pos_col)
game_init_adjnums();
}
-void game_init_load (int *rows, int *cols)
+int game_init_load (ptrdiff_t *rows, ptrdiff_t *cols)
{
- load_game_file();
+ if (load_game_file())
+ return -1;
game_board.state = GAME_STATE_PLAYING;
*rows = game_board.rows;
*cols = game_board.cols;
+
+ return 0;
}
-void game_action (int action, int row, int col)
+void game_action (int action, ptrdiff_t row, ptrdiff_t col)
{
switch (action) {
@@ -113,11 +121,9 @@ void game_action (int action, int row, int col)
* * * * * * * * * */
static void game_init_clr (void)
{
- int i;
- int j;
- for (i = 0; i < game_board.rows; i++) {
- for (j = 0; j < game_board.cols; j++) {
+ for (ptrdiff_t i = 0; i < game_board.rows; i++) {
+ for (ptrdiff_t j = 0; j < game_board.cols; j++) {
game_board.gnd[i][j] = GAME_MINE_NO;
game_board.usr[i][j] = GAME_USR_HIDDEN;
}
@@ -127,12 +133,12 @@ static void game_init_clr (void)
game_board.state = GAME_STATE_PLAYING;
}
-static void game_init_mines (int pos_row, int pos_col)
+static void game_init_mines (ptrdiff_t pos_row, ptrdiff_t pos_col)
{
/* place mines */
- int i;
- int r;
- int c;
+ int i;
+ ptrdiff_t r;
+ ptrdiff_t c;
i = 0;
while (i < game_board.mines) {
@@ -151,16 +157,12 @@ static void game_init_mines (int pos_row, int pos_col)
static void game_init_adjnums (void)
{
- int r;
- int c;
- int i;
- int j;
- for (r = 0; r < game_board.rows; r++) {
- for (c = 0; c < game_board.cols; c++) {
+ for (ptrdiff_t r = 0; r < game_board.rows; r++) {
+ for (ptrdiff_t c = 0; c < game_board.cols; c++) {
if (game_board.gnd[r][c] >= GAME_MINE_YES) {
- for (i = r-1; i < r+2; i++) {
- for (j = c-1; j < c+2; j++) {
+ for (ptrdiff_t i = r-1; i < r+2; i++) {
+ for (ptrdiff_t j = c-1; j < c+2; j++) {
if (i >= 0 && i < game_board.rows) {
if (j >= 0 && j < game_board.cols) {
game_board.gnd[i][j]++;
@@ -176,7 +178,7 @@ static void game_init_adjnums (void)
/* * * * * * * * * *
* * * Step * * * * * * *
* * * * * * * * * */
-static void game_step (int r, int c)
+static void game_step (ptrdiff_t r, ptrdiff_t c)
{
switch (game_board.usr[r][c]) {
@@ -190,11 +192,11 @@ static void game_step (int r, int c)
}
}
-static void game_discover (int r, int c)
+static void game_discover (ptrdiff_t r, ptrdiff_t c)
{
int safe_fields;
- safe_fields = (game_board.rows * game_board.cols) - game_board.mines;
+ safe_fields = (game_board.rows * game_board.cols) - game_board.mines;
if (game_board.gnd[r][c] >= GAME_MINE_YES) {
game_board.usr[r][c] = GAME_USR_KBOOM;
game_board.state = GAME_STATE_GAMEOVER;
@@ -210,22 +212,21 @@ static void game_discover (int r, int c)
}
}
-static void game_discover_recursive (int r, int c)
+static void game_discover_recursive (ptrdiff_t r, ptrdiff_t c)
{
- int i;
- int j;
- for (i = r - 1; i < r + 2; i++) {
- for (j = c - 1; j < c + 2; j++) {
- if (i >= 0 && i < game_board.rows &&
- j >= 0 && j < game_board.cols) {
- game_discover(i, j);
- }
+ for (ptrdiff_t i = r - 1; i < r + 2; i++) {
+ for (ptrdiff_t j = c - 1; j < c + 2; j++) {
+ if (i >= 0 && i < game_board.rows) {
+ if (j >= 0 && j < game_board.cols) {
+ game_discover(i, j);
}
+ }
+ }
}
}
-static void game_big_step (int r, int c)
+static void game_big_step (ptrdiff_t r, ptrdiff_t c)
{
int cnt;
@@ -234,50 +235,48 @@ static void game_big_step (int r, int c)
game_step_recursive(r, c);
}
-static int game_count_flags (int r, int c)
+static int game_count_flags (ptrdiff_t r, ptrdiff_t c)
{
int cnt;
- int i;
- int j;
cnt = 0;
- for (i = r - 1; i < r + 2; i++) {
- for (j = c - 1; j < c + 2; j++) {
- if (i >= 0 && i < game_board.rows &&
- j >= 0 && j < game_board.cols) {
- if (game_board.usr[i][j] == GAME_USR_FLAG)
- cnt++;
- }
+ for (ptrdiff_t i = r - 1; i < r + 2; i++) {
+ for (ptrdiff_t j = c - 1; j < c + 2; j++) {
+ if (i >= 0 && i < game_board.rows) {
+ if (j >= 0 && j < game_board.cols) {
+ if (game_board.usr[i][j] == GAME_USR_FLAG)
+ cnt++;
}
+ }
+ }
}
return cnt;
}
-static void game_step_recursive (int r, int c)
+static void game_step_recursive (ptrdiff_t r, ptrdiff_t c)
{
- int i;
- int j;
-
- for (i = r - 1; i < r + 2; i++) {
- for (j = c - 1; j < c + 2; j++) {
- if (i >= 0 && i < game_board.rows &&
- j >= 0 && j < game_board.cols) {
- switch (game_board.usr[i][j]) {
- case GAME_USR_HIDDEN:
- case GAME_USR_POSSIBLE:
- game_discover(i, j);
- break;
- }
+
+ for (ptrdiff_t i = r - 1; i < r + 2; i++) {
+ for (ptrdiff_t j = c - 1; j < c + 2; j++) {
+ if (i >= 0 && i < game_board.rows) {
+ if (j >= 0 && j < game_board.cols) {
+ switch (game_board.usr[i][j]) {
+ case GAME_USR_HIDDEN:
+ case GAME_USR_POSSIBLE:
+ game_discover(i, j);
+ break;
}
}
+ }
+ }
}
}
/* * * * * * * * * *
* * * Flag * * * * * * *
* * * * * * * * * */
-static void game_flag (int r, int c)
+static void game_flag (ptrdiff_t r, ptrdiff_t c)
{
switch (game_board.usr[r][c]) {
@@ -301,7 +300,7 @@ static void game_flag (int r, int c)
}
}
-static void game_possible (int r, int c)
+static void game_possible (ptrdiff_t r, ptrdiff_t c)
{
switch (game_board.usr[r][c]) {
@@ -315,7 +314,7 @@ static void game_possible (int r, int c)
}
}
-static void game_rmflag (int r, int c)
+static void game_rmflag (ptrdiff_t r, ptrdiff_t c)
{
switch (game_board.usr[r][c]) {
@@ -330,7 +329,7 @@ static void game_rmflag (int r, int c)
}
}
-static void game_all_flags (int r, int c)
+static void game_all_flags (ptrdiff_t r, ptrdiff_t c)
{
int cnt;
@@ -339,44 +338,42 @@ static void game_all_flags (int r, int c)
game_flag_recursive(r, c);
}
-static int game_count_nclear (int r, int c)
+static int game_count_nclear (ptrdiff_t r, ptrdiff_t c)
{
int cnt;
- int i;
- int j;
cnt = 0;
- for (i = r - 1; i < r + 2; i++) {
- for (j = c - 1; j < c + 2; j++) {
- if (i >= 0 && i < game_board.rows &&
- j >= 0 && j < game_board.cols) {
- if (game_board.usr[i][j] != GAME_USR_CLEAR)
- cnt++;
- }
+ for (ptrdiff_t i = r - 1; i < r + 2; i++) {
+ for (ptrdiff_t j = c - 1; j < c + 2; j++) {
+ if (i >= 0 && i < game_board.rows) {
+ if (j >= 0 && j < game_board.cols) {
+ if (game_board.usr[i][j] != GAME_USR_CLEAR)
+ cnt++;
+ }
}
}
+ }
return cnt;
}
-static void game_flag_recursive (int r, int c)
+static void game_flag_recursive (ptrdiff_t r, ptrdiff_t c)
{
- int i;
- int j;
-
- for (i = r - 1; i < r + 2; i++) {
- for (j = c - 1; j < c + 2; j++) {
- if (i >= 0 && i < game_board.rows &&
- j >= 0 && j < game_board.cols) {
- switch (game_board.usr[i][j]) {
- case GAME_USR_HIDDEN:
- case GAME_USR_POSSIBLE:
- game_board.usr[i][j] = GAME_USR_FLAG;
- game_board.flags++;
- break;
- }
+
+ for (ptrdiff_t i = r - 1; i < r + 2; i++) {
+ for (ptrdiff_t j = c - 1; j < c + 2; j++) {
+ if (i >= 0 && i < game_board.rows) {
+ if (j >= 0 && j < game_board.cols) {
+ switch (game_board.usr[i][j]) {
+ case GAME_USR_HIDDEN:
+ case GAME_USR_POSSIBLE:
+ game_board.usr[i][j] = GAME_USR_FLAG;
+ game_board.flags++;
+ break;
}
}
+ }
+ }
}
}
diff --git a/modules/game/src/game_iface.c b/src/game/iface.c
index a2df636..13d9b93 100644..100755
--- a/modules/game/src/game_iface.c
+++ b/src/game/iface.c
@@ -6,16 +6,17 @@
/******************************************************************************
******* headers **************************************************************
******************************************************************************/
- #include <stdbool.h>
- #include <time.h>
+#include "mine-sweeper/game/iface.h"
- #include "player_iface.h"
- #include "save.h"
- #include "score.h"
- #include "xyzzy.h"
- #include "game.h"
+#include <stdbool.h>
+#include <stddef.h>
+#include <time.h>
- #include "game_iface.h"
+#include "mine-sweeper/game/core.h"
+#include "mine-sweeper/player/iface.h"
+#include "mine-sweeper/save/save.h"
+#include "mine-sweeper/save/score.h"
+#include "mine-sweeper/xyzzy/xyzzy.h"
/******************************************************************************
@@ -55,8 +56,8 @@ static void game_iface_quit (void);
/* Output */
static void game_iface_update_out (void);
static void game_iface_update_board (void);
-static void game_iface_update_vis (int r, int c);
-static void game_iface_update_usr (int r, int c);
+static void game_iface_update_vis (ptrdiff_t r, ptrdiff_t c);
+static void game_iface_update_usr (ptrdiff_t r, ptrdiff_t c);
/* Score */
static void game_iface_update_score (void);
/* Prepare input */
@@ -66,7 +67,7 @@ static void game_iface_clean_in (void);
/******************************************************************************
******* global functions *****************************************************
******************************************************************************/
-void game_iface_init_rand (int level, int pos_row, int pos_col)
+void game_iface_init_rand(int level, ptrdiff_t pos_row, ptrdiff_t pos_col)
{
/* first step */
@@ -83,7 +84,7 @@ void game_iface_init_rand (int level, int pos_row, int pos_col)
game_iface_clean_in();
}
-void game_iface_init_load (void)
+void game_iface_init_load(void)
{
game_iface_init_cheated();
@@ -95,7 +96,7 @@ void game_iface_init_load (void)
game_iface_clean_in();
}
-void game_iface (void)
+void game_iface (void)
{
while (game_iface_out.state != GAME_IFACE_STATE_QUIT) {
@@ -128,7 +129,7 @@ static void game_iface_init_cheated (void)
{
game_iface_out.state = GAME_IFACE_STATE_CHEATED;
- game_iface_score.level = GAME_IFACE_LEVEL_CUSTOM;
+ game_iface_score.level = GAME_IFACE_LVL_CUSTOM;
game_iface_score.time = CHEATED;
game_iface_score.clicks = CHEATED;
}
@@ -291,11 +292,9 @@ static void game_iface_gameover_act (void)
* * * * * * * * * */
static void game_iface_act_game (void)
{
- int i;
- int j;
- for (i = 0; i < game_board.rows; i++) {
- for (j = 0; j < game_board.cols; j++) {
+ for (ptrdiff_t i = 0; i < game_board.rows; i++) {
+ for (ptrdiff_t j = 0; j < game_board.cols; j++) {
if (game_iface_in.act_game[i][j]) {
game_action(game_iface_in.act_game[i][j], i, j);
game_iface_score.clicks++;
@@ -342,20 +341,20 @@ static void game_iface_save_score (void)
/* Save board and score */
switch (game_iface_score.level) {
- case GAME_IFACE_LEVEL_BEGINNER:
- save_game_file(var_boards_beginner_path);
+ case GAME_IFACE_LVL_BEGINNER:
+ save_game_file(BOARDS_BEGINNER_DIR);
save_score(&game_iface_score);
break;
- case GAME_IFACE_LEVEL_INTERMEDIATE:
- save_game_file(var_boards_intermediate_path);
+ case GAME_IFACE_LVL_INTERMEDIATE:
+ save_game_file(BOARDS_INTERMEDIATE_DIR);
save_score(&game_iface_score);
break;
- case GAME_IFACE_LEVEL_EXPERT:
- save_game_file(var_boards_expert_path);
+ case GAME_IFACE_LVL_EXPERT:
+ save_game_file(BOARDS_EXPERT_DIR);
save_score(&game_iface_score);
break;
- case GAME_IFACE_LEVEL_CUSTOM:
- save_game_file(var_boards_custom_path);
+ case GAME_IFACE_LVL_CUSTOM:
+ save_game_file(BOARDS_CUSTOM_DIR);
break;
}
}
@@ -400,7 +399,7 @@ static void game_iface_update_board (void)
}
}
-static void game_iface_update_vis (int r, int c)
+static void game_iface_update_vis (ptrdiff_t r, ptrdiff_t c)
{
int field_vis;
@@ -476,7 +475,7 @@ static void game_iface_update_vis (int r, int c)
game_iface_out.visible[r][c] = field_vis;
}
-static void game_iface_update_usr (int r, int c)
+static void game_iface_update_usr (ptrdiff_t r, ptrdiff_t c)
{
int field_usr;
@@ -518,7 +517,7 @@ static void game_iface_update_score (void)
break;
case GAME_IFACE_STATE_XYZZY:
case GAME_IFACE_STATE_CHEATED:
- game_iface_score.level = GAME_IFACE_LEVEL_CUSTOM;
+ game_iface_score.level = GAME_IFACE_LVL_CUSTOM;
game_iface_score.time = CHEATED;
game_iface_score.clicks = CHEATED;
break;
@@ -530,11 +529,9 @@ static void game_iface_update_score (void)
* * * * * * * * * */
static void game_iface_clean_in (void)
{
- int i;
- int j;
- for (i = 0; i < game_board.rows; i++) {
- for (j = 0; j < game_board.cols; j++)
+ for (ptrdiff_t i = 0; i < game_board.rows; i++) {
+ for (ptrdiff_t j = 0; j < game_board.cols; j++)
game_iface_in.act_game[i][j] = GAME_IFACE_GAME_ACT_FOO;
}
game_iface_in.action = GAME_IFACE_ACT_FOO;
diff --git a/src/main.c b/src/main.c
index 84349e1..db194a5 100644..100755
--- a/src/main.c
+++ b/src/main.c
@@ -6,20 +6,18 @@
/******************************************************************************
******* headers **************************************************************
******************************************************************************/
- #include <stdio.h>
+#include <stdio.h>
- #include <gtk/gtk.h>
+#include "libalx/extra/ncurses/common.h"
- #include "libalx/curses/alx_ncur.h"
-
- #include "about.h"
- #include "game.h"
- #include "menu_iface.h"
- #include "player_iface.h"
- #include "parser.h"
- #include "save.h"
- #include "score.h"
- #include "start.h"
+#include "mine-sweeper/about/about.h"
+#include "mine-sweeper/ctrl/start.h"
+#include "mine-sweeper/game/core.h"
+#include "mine-sweeper/menu/iface.h"
+#include "mine-sweeper/menu/parser.h"
+#include "mine-sweeper/player/iface.h"
+#include "mine-sweeper/save/save.h"
+#include "mine-sweeper/save/score.h"
/******************************************************************************
@@ -36,14 +34,10 @@ int main (int argc, char *argv[])
{
init_all(&argc, &argv);
- /* Print copyright () and wait for any key to continue */
print_share_file(SHARE_COPYRIGHT);
- getchar();
- /* Start () */
start_switch();
- /* Menu () */
menu_iface();
cleanup();
@@ -57,17 +51,14 @@ int main (int argc, char *argv[])
******************************************************************************/
static void init_all (int *argc, char *(*argv[]))
{
- /* Init gtk & curses */
- gtk_init_check(argc, argv);
- alx_start_curses();
- alx_pause_curses();
+
+ alx_ncurses_init();
+ alx_ncurses_pause();
/* Init modules */
menu_iface_init();
game_init();
- about_init();
save_init();
- score_init();
/* Modes */
start_mode = START_FOO;
@@ -77,19 +68,13 @@ static void init_all (int *argc, char *(*argv[]))
/* Parse command line options */
parser(*argc, *argv);
-
- /* Init iface */
- menu_iface_init_iface();
}
static void cleanup (void)
{
- /* Clean iface */
- menu_iface_cleanup();
- /* End curses */
- alx_resume_curses();
- alx_end_curses();
+ alx_ncurses_resume();
+ alx_ncurses_deinit();
}
diff --git a/modules/menu/src/menu_clui.c b/src/menu/clui.c
index d3f8d8b..d4f9118 100644..100755
--- a/modules/menu/src/menu_clui.c
+++ b/src/menu/clui.c
@@ -6,18 +6,18 @@
/******************************************************************************
******* headers **************************************************************
******************************************************************************/
- #include <math.h>
- #include <stdlib.h>
+#include "mine-sweeper/menu/clui.h"
- #include "libalx/io/alx_input.h"
+#include <limits.h>
+#include <math.h>
+#include <stdlib.h>
- #include "about.h"
- #include "game_iface.h"
-// #include "save.h"
- #include "start.h"
- #include "menu_iface.h"
+#include "libalx/base/stdio/get.h"
- #include "menu_clui.h"
+#include "mine-sweeper/about/about.h"
+#include "mine-sweeper/ctrl/start.h"
+#include "mine-sweeper/game/iface.h"
+#include "mine-sweeper/menu/iface.h"
/******************************************************************************
@@ -120,7 +120,7 @@ err_sscanf:
******************************************************************************/
static void menu_clui_rand (void)
{
- int seed;
+ unsigned seed;
char buff [BUFF_SIZE];
char c;
@@ -135,7 +135,7 @@ static void menu_clui_rand (void)
goto err_sscanf;
if (c == 'y' || c == 'Y') {
printf(" >yes\n");
- seed = alx_getint(-INFINITY, 1, INFINITY, "Seed:", NULL);
+ seed = alx_get_uint(0, 1, UINT_MAX, "Seed:", NULL, 2);
srand(seed);
} else {
printf(" >NO\n");
@@ -149,19 +149,19 @@ static void menu_clui_rand (void)
goto err_sscanf;
if (c == 'i' || c == 'I') {
printf(" >intermediate\n");
- menu_iface_variables.level = GAME_IFACE_LEVEL_INTERMEDIATE;
+ menu_iface_variables.level = GAME_IFACE_LVL_INTERMEDIATE;
menu_clui_start();
} else if (c == 'e' || c == 'E') {
printf(" >expert\n");
- menu_iface_variables.level = GAME_IFACE_LEVEL_EXPERT_INV;
+ menu_iface_variables.level = GAME_IFACE_LVL_EXPERT_INV;
menu_clui_start();
} else if (c == 'c' || c == 'C') {
printf(" >custom\n");
- menu_iface_variables.level = GAME_IFACE_LEVEL_CUSTOM;
+ menu_iface_variables.level = GAME_IFACE_LVL_CUSTOM;
menu_clui_custom();
} else {
printf(" >BEGINNER\n");
- menu_iface_variables.level = GAME_IFACE_LEVEL_BEGINNER;
+ menu_iface_variables.level = GAME_IFACE_LVL_BEGINNER;
menu_clui_start();
}
@@ -181,9 +181,12 @@ static void menu_clui_custom (void)
start_mode = START_RAND;
- menu_iface_variables.rows = alx_getint(2, menu_iface_variables.rows, ROWS_CLUI_MAX, "Rows:", NULL);
- menu_iface_variables.cols = alx_getint(2, menu_iface_variables.cols, COLS_CLUI_MAX, "Columns:", NULL);
- menu_iface_variables.p = alx_getdbl(0, menu_iface_variables.p, 1, "Proportion:", NULL);
+ menu_iface_variables.rows = alx_get_pdif(2, menu_iface_variables.rows,
+ ROWS_CLUI_MAX, "Rows:", NULL, 2);
+ menu_iface_variables.cols = alx_get_pdif(2, menu_iface_variables.cols,
+ COLS_CLUI_MAX, "Columns:", NULL, 2);
+ menu_iface_variables.p = alx_get_dbl(0.0, menu_iface_variables.p, 1.0,
+ "Proportion:", NULL, 2);
menu_clui_start();
}
diff --git a/modules/menu/src/menu_iface.c b/src/menu/iface.c
index 3927ca7..3f241bb 100644..100755
--- a/modules/menu/src/menu_iface.c
+++ b/src/menu/iface.c
@@ -6,16 +6,15 @@
/******************************************************************************
******* headers **************************************************************
******************************************************************************/
- #include <math.h>
- #include <stdbool.h>
+#include "mine-sweeper/menu/iface.h"
- #include "game_iface.h"
- #include "start.h"
- #include "menu_clui.h"
- #include "menu_tui.h"
- #include "menu_gui.h"
+#include <stdbool.h>
+#include <stddef.h>
- #include "menu_iface.h"
+#include "mine-sweeper/game/iface.h"
+#include "mine-sweeper/ctrl/start.h"
+#include "mine-sweeper/menu/clui.h"
+#include "mine-sweeper/menu/tui.h"
/******************************************************************************
@@ -32,68 +31,40 @@ struct Menu_Iface_Variables menu_iface_variables;
void menu_iface_init (void)
{
- menu_iface_variables.level = GAME_IFACE_LEVEL_BEGINNER;
+ menu_iface_variables.level = GAME_IFACE_LVL_BEGINNER;
menu_iface_variables.rows = 8;
menu_iface_variables.cols = 8;
menu_iface_variables.p = 0.16;
}
-void menu_iface_init_iface (void)
-{
-
- switch (menu_iface_mode) {
- case MENU_IFACE_CLUI:
- break;
- case MENU_IFACE_TUI:
- break;
- case MENU_IFACE_GUI:
- menu_gui_init();
- break;
- }
-}
-
-void menu_iface_cleanup (void)
-{
-
- switch (menu_iface_mode) {
- case MENU_IFACE_CLUI:
- break;
- case MENU_IFACE_TUI:
- break;
- case MENU_IFACE_GUI:
- menu_gui_cleanup();
- break;
- }
-}
-
-void menu_iface_board (int *level, int *rows, int *cols, int *mines)
+void menu_iface_board (int *level, ptrdiff_t *rows, ptrdiff_t *cols, int *mines)
{
*level = menu_iface_variables.level;
/* size & number of mines */
switch (*level) {
- case GAME_IFACE_LEVEL_BEGINNER:
- *rows = GAME_IFACE_LEVEL_BEGINNER_ROWS;
- *cols = GAME_IFACE_LEVEL_BEGINNER_COLS;
- *mines = GAME_IFACE_LEVEL_BEGINNER_MINES;
+ case GAME_IFACE_LVL_BEGINNER:
+ *rows = GAME_IFACE_LVL_BEGINNER_ROWS;
+ *cols = GAME_IFACE_LVL_BEGINNER_COLS;
+ *mines = GAME_IFACE_LVL_BEGINNER_MINES;
break;
- case GAME_IFACE_LEVEL_INTERMEDIATE:
- *rows = GAME_IFACE_LEVEL_INTERMEDIATE_ROWS;
- *cols = GAME_IFACE_LEVEL_INTERMEDIATE_COLS;
- *mines = GAME_IFACE_LEVEL_INTERMEDIATE_MINES;
+ case GAME_IFACE_LVL_INTERMEDIATE:
+ *rows = GAME_IFACE_LVL_INTERMEDIATE_ROWS;
+ *cols = GAME_IFACE_LVL_INTERMEDIATE_COLS;
+ *mines = GAME_IFACE_LVL_INTERMEDIATE_MINES;
break;
- case GAME_IFACE_LEVEL_EXPERT:
- *rows = GAME_IFACE_LEVEL_EXPERT_ROWS;
- *cols = GAME_IFACE_LEVEL_EXPERT_COLS;
- *mines = GAME_IFACE_LEVEL_EXPERT_MINES;
+ case GAME_IFACE_LVL_EXPERT:
+ *rows = GAME_IFACE_LVL_EXPERT_ROWS;
+ *cols = GAME_IFACE_LVL_EXPERT_COLS;
+ *mines = GAME_IFACE_LVL_EXPERT_MINES;
break;
- case GAME_IFACE_LEVEL_EXPERT_INV:
- *rows = GAME_IFACE_LEVEL_EXPERT_COLS;
- *cols = GAME_IFACE_LEVEL_EXPERT_ROWS;
- *mines = GAME_IFACE_LEVEL_EXPERT_MINES;
+ case GAME_IFACE_LVL_EXPERT_INV:
+ *rows = GAME_IFACE_LVL_EXPERT_COLS;
+ *cols = GAME_IFACE_LVL_EXPERT_ROWS;
+ *mines = GAME_IFACE_LVL_EXPERT_MINES;
break;
- case GAME_IFACE_LEVEL_CUSTOM:
+ case GAME_IFACE_LVL_CUSTOM:
*rows = menu_iface_variables.rows;
*cols = menu_iface_variables.cols;
*mines = menu_iface_variables.p * (*rows) * (*cols);
@@ -121,9 +92,6 @@ void menu_iface (void)
case MENU_IFACE_TUI:
menu_tui();
break;
- case MENU_IFACE_GUI:
- menu_gui();
- break;
}
}
diff --git a/modules/menu/src/parser.c b/src/menu/parser.c
index cff49e9..95815d5 100644..100755
--- a/modules/menu/src/parser.c
+++ b/src/menu/parser.c
@@ -6,27 +6,26 @@
/******************************************************************************
******* headers **************************************************************
******************************************************************************/
-/* Standard C ----------------------------------------------------------------*/
- #include <getopt.h>
- #include <stdio.h>
- #include <stdlib.h>
-/* libalx --------------------------------------------------------------------*/
- #include "libalx/alx_seed.h"
-/* Project -------------------------------------------------------------------*/
- #include "about.h"
- #include "game_iface.h"
- #include "player_iface.h"
- #include "save.h"
- #include "start.h"
- #include "menu_iface.h"
-
- #include "parser.h"
+#include "mine-sweeper/menu/parser.h"
+
+#include <getopt.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include "libalx/base/stdlib/seed_mix.h"
+
+#include "mine-sweeper/about/about.h"
+#include "mine-sweeper/ctrl/start.h"
+#include "mine-sweeper/game/iface.h"
+#include "mine-sweeper/menu/iface.h"
+#include "mine-sweeper/player/iface.h"
+#include "mine-sweeper/save/save.h"
/******************************************************************************
******* macros ***************************************************************
******************************************************************************/
- # define OPT_LIST "xhLuv""a:b:f:i:p:r:s:"
+#define OPT_LIST "xhLuv""a:b:f:i:p:r:s:"
/******************************************************************************
diff --git a/modules/menu/src/menu_tui.c b/src/menu/tui.c
index a39caea..90fec38 100644..100755
--- a/modules/menu/src/menu_tui.c
+++ b/src/menu/tui.c
@@ -6,21 +6,26 @@
/******************************************************************************
******* headers **************************************************************
******************************************************************************/
- #include <math.h>
- #include <ncurses.h>
- #include <stdbool.h>
- #include <stdlib.h>
+#include "mine-sweeper/menu/tui.h"
- #include "libalx/curses/alx_ncur.h"
+#include <math.h>
+#include <stdbool.h>
+#include <stdlib.h>
- #include "about.h"
- #include "game_iface.h"
- #include "save.h"
- #include "score.h"
- #include "start.h"
- #include "menu_iface.h"
+#include <ncurses.h>
- #include "menu_tui.h"
+#include "libalx/base/stddef/size.h"
+#include "libalx/base/stdio/wait.h"
+#include "libalx/extra/ncurses/common.h"
+#include "libalx/extra/ncurses/get.h"
+#include "libalx/extra/ncurses/menu.h"
+
+#include "mine-sweeper/about/about.h"
+#include "mine-sweeper/game/iface.h"
+#include "mine-sweeper/save/save.h"
+#include "mine-sweeper/save/score.h"
+#include "mine-sweeper/ctrl/start.h"
+#include "mine-sweeper/menu/iface.h"
/******************************************************************************
@@ -61,17 +66,15 @@ void menu_tui (void)
{
int h;
int w;
- int N;
bool wh;
int sw;
- alx_resume_curses();
+ alx_ncurses_resume();
/* Menu dimensions & options */
h = 10;
w = 34;
- N = 4;
- static const struct Alx_Menu mnu[4] = {
+ static const struct Alx_Ncurses_Menu mnu[] = {
{7, 4, "[0] Exit program"},
{2, 4, "[1] Continue"},
{4, 4, "[2] Disclaimer of warranty"},
@@ -82,7 +85,7 @@ void menu_tui (void)
wh = true;
while (wh) {
/* Menu loop */
- sw = alx_menu(h, w, N, mnu, "MENU:");
+ sw = alx_ncurses_menu(h, w, ARRAY_SIZE(mnu), mnu, "MENU:");
/* Selection */
switch (sw) {
@@ -93,21 +96,19 @@ void menu_tui (void)
menu_tui_continue();
break;
case 2:
- alx_pause_curses();
+ alx_ncurses_pause();
print_share_file(SHARE_DISCLAIMER);
- getchar();
- alx_resume_curses();
+ alx_ncurses_resume();
break;
case 3:
- alx_pause_curses();
+ alx_ncurses_pause();
print_share_file(SHARE_LICENSE);
- getchar();
- alx_resume_curses();
+ alx_ncurses_resume();
break;
}
}
- alx_pause_curses();
+ alx_ncurses_pause();
}
@@ -116,13 +117,11 @@ void menu_tui (void)
******************************************************************************/
static void menu_tui_continue (void)
{
- char str [BUFF_SIZE_TEXT];
WINDOW *win;
int h;
int w;
int r;
int c;
- int N;
int w2;
int r2;
bool wh;
@@ -133,9 +132,7 @@ static void menu_tui_continue (void)
w = 50;
r = 1;
c = (80 - w) / 2;
- /* N = 7 if DEVEL option is enabled */
- N = 6;
- static const struct Alx_Menu mnu[6] = {
+ static const struct Alx_Ncurses_Menu mnu[] = {
{11, 4, "[0] Back"},
{2, 4, "[1] Start"},
{4, 4, "[2] Select map"},
@@ -157,45 +154,43 @@ static void menu_tui_continue (void)
win = newwin(h, w, r, c);
mvwprintw(win, mnu[4].r, mnu[4].c, "%s (File: \"%s\")", mnu[4].t, saved_name);
wrefresh(win);
- sw = alx_menu_2(win, N, mnu, "CONTINUE:");
+ sw = alx_ncurses_menu_w(win, ARRAY_SIZE(mnu), mnu, "CONTINUE:");
/* Selection */
switch (sw) {
case 0:
- alx_win_del(win);
+ alx_ncurses_delwin(win);
wh = false;
break;
case 1:
- alx_win_del(win);
- alx_pause_curses();
+ alx_ncurses_delwin(win);
+ alx_ncurses_pause();
start_switch();
- alx_resume_curses();
+ alx_ncurses_resume();
break;
case 2:
- alx_win_del(win);
+ alx_ncurses_delwin(win);
menu_tui_select();
break;
case 3:
- alx_win_del(win);
+ alx_ncurses_delwin(win);
menu_tui_level();
break;
case 4:
save_clr();
- alx_w_getfname(saved_path, saved_name, true, w2, r2,
- txt[0], NULL);
- alx_win_del(win);
+ alx_ncurses_get_fname(saved_path, saved_name, true, w2, r2,
+ txt[0], NULL, 2);
+ alx_ncurses_delwin(win);
break;
case 5:
- alx_win_del(win);
- alx_pause_curses();
- snprint_scores(str, BUFF_SIZE_TEXT);
- printf("%s", str);
- getchar();
- alx_resume_curses();
+ alx_ncurses_delwin(win);
+ alx_ncurses_pause();
+ print_scores();
+ alx_ncurses_resume();
break;
/*
case 6:
- alx_win_del(win);
+ alx_ncurses_delwin(win);
menu_tui_devel();
break;
*/
@@ -210,7 +205,6 @@ static void menu_tui_select (void)
int w;
int r;
int c;
- int N;
int sw;
/* Menu dimensions & options */
@@ -218,8 +212,7 @@ static void menu_tui_select (void)
w = 70;
r = 1;
c = (80 - w) / 2;
- N = 3;
- static const struct Alx_Menu mnu[3] = {
+ static const struct Alx_Ncurses_Menu mnu[] = {
{6, 4, "[0] Back"},
{2, 4, "[1] New map"},
{4, 4, "[2] Load map"}
@@ -229,8 +222,8 @@ static void menu_tui_select (void)
win = newwin(h, w, r, c);
mvwprintw(win, mnu[2].r, mnu[2].c, "%s (File: \"%s\")", mnu[1].t, saved_name);
wrefresh(win);
- sw = alx_menu_2(win, N, mnu, "SELECT MAP:");
- alx_win_del(win);
+ sw = alx_ncurses_menu_w(win, ARRAY_SIZE(mnu), mnu, "SELECT MAP:");
+ alx_ncurses_delwin(win);
/* Selection */
switch (sw) {
@@ -248,14 +241,12 @@ static void menu_tui_level (void)
{
int h;
int w;
- int N;
int sw;
/* Menu dimensions & options */
h = 10;
w = 70;
- N = 5;
- static const struct Alx_Menu mnu[5] = {
+ static const struct Alx_Ncurses_Menu mnu[] = {
{7, 4, "[0] Back"},
{2, 4, "[1] Beginner"},
{3, 4, "[2] Intermediate"},
@@ -264,24 +255,24 @@ static void menu_tui_level (void)
};
/* Menu loop */
- sw = alx_menu(h, w, N, mnu, "SELECT LEVEL:");
+ sw = alx_ncurses_menu(h, w, ARRAY_SIZE(mnu), mnu, "SELECT LEVEL:");
/* Selection */
switch (sw) {
case 1:
- menu_iface_variables.level = GAME_IFACE_LEVEL_BEGINNER;
+ menu_iface_variables.level = GAME_IFACE_LVL_BEGINNER;
break;
case 2:
- menu_iface_variables.level = GAME_IFACE_LEVEL_INTERMEDIATE;
+ menu_iface_variables.level = GAME_IFACE_LVL_INTERMEDIATE;
break;
case 3:
- menu_iface_variables.level = GAME_IFACE_LEVEL_EXPERT;
+ menu_iface_variables.level = GAME_IFACE_LVL_EXPERT;
break;
case 4:
- menu_iface_variables.level = GAME_IFACE_LEVEL_CUSTOM;
+ menu_iface_variables.level = GAME_IFACE_LVL_CUSTOM;
menu_tui_custom();
break;
}
@@ -295,7 +286,6 @@ static void menu_tui_custom (void)
int w;
int r;
int c;
- int N;
int w2;
int r2;
bool wh;
@@ -306,8 +296,7 @@ static void menu_tui_custom (void)
w = 76;
r = 1;
c = (80 - w) / 2;
- N = 4;
- static const struct Alx_Menu mnu[4] = {
+ static const struct Alx_Ncurses_Menu mnu[] = {
{8, 4, "[0] Back"},
{2, 4, "[1] Change rows:"},
{4, 4, "[2] Change columns:"},
@@ -338,29 +327,32 @@ static void menu_tui_custom (void)
wrefresh(win);
/* Selection */
- sw = alx_menu_2(win, N, mnu, "Custom:");
+ sw = alx_ncurses_menu_w(win, ARRAY_SIZE(mnu), mnu, "Custom:");
switch (sw) {
case 0:
wh = false;
break;
case 1:
- menu_iface_variables.rows = alx_w_getint(w2, r2,
- txt[sw - 1], 2, menu_iface_variables.rows, ROWS_TUI_MAX, NULL);
+ menu_iface_variables.rows = alx_ncurses_get_pdif(
+ 2, menu_iface_variables.rows, ROWS_TUI_MAX,
+ w2, r2, txt[sw - 1], NULL, 2);
break;
case 2:
- menu_iface_variables.cols = alx_w_getint(w2, r2,
- txt[sw - 1], 2, menu_iface_variables.cols, COLS_TUI_MAX, NULL);
+ menu_iface_variables.cols = alx_ncurses_get_pdif(
+ 2, menu_iface_variables.cols, COLS_TUI_MAX,
+ w2, r2, txt[sw - 1], NULL, 2);
break;
case 3:
- menu_iface_variables.p = alx_w_getdbl(w2, r2,
- txt[sw - 1], 0, menu_iface_variables.p, 1, NULL);
+ menu_iface_variables.p = alx_ncurses_get_dbl(
+ 0.0, menu_iface_variables.p, 1.0,
+ w2, r2, txt[sw - 1], NULL, 2);
break;
}
}
- alx_win_del(win);
+ alx_ncurses_delwin(win);
}
#if 0
static void menu_tui_devel (void)
@@ -370,7 +362,6 @@ static void menu_tui_devel (void)
int w;
int r;
int c;
- int N;
int w2;
int r2;
bool wh;
@@ -381,8 +372,7 @@ static void menu_tui_devel (void)
w = 50;
r = 1;
c = (80 - w) / 2;
- N = 2;
- static const struct Alx_Menu mnu[2] = {
+ static const struct Alx_Ncurses_Menu mnu[] = {
{5, 4, "[0] Back"},
{2, 4, "[1] Change seed (srand)"}
};
@@ -399,7 +389,7 @@ static void menu_tui_devel (void)
wh = true;
while (wh) {
/* Selection */
- sw = alx_menu_2(win, N, mnu, "DEVELOPER OPTIONS:");
+ sw = alx_ncurses_menu_2(win, ARRAY_SIZE(mnu), mnu, "DEVELOPER OPTIONS:");
switch (sw) {
case 0:
diff --git a/modules/player/src/player_clui.c b/src/player/clui.c
index 7ff3e8c..ae936db 100644..100755
--- a/modules/player/src/player_clui.c
+++ b/src/player/clui.c
@@ -6,13 +6,13 @@
/******************************************************************************
******* headers **************************************************************
******************************************************************************/
- #include <stdbool.h>
- #include <stdio.h>
+#include "mine-sweeper/player/clui.h"
- #include "game_iface.h"
- #include "player_iface.h"
+#include <stdbool.h>
+#include <stdio.h>
- #include "player_clui.h"
+#include "mine-sweeper/game/iface.h"
+#include "mine-sweeper/player/iface.h"
/******************************************************************************
@@ -98,20 +98,21 @@ void player_clui (const struct Game_Iface_Out *board,
oldaction = *action;
}
-void player_clui_save_name (const char *fpath, char *fname, int destsize)
+void player_clui_save_name (const char *fpath,
+ char fname[static restrict FILENAME_MAX])
{
(void)fpath;
printf("File name:\n");
- fgets(fname, destsize, stdin);
+ fgets(fname, FILENAME_MAX, stdin);
}
-void player_clui_score_name (char *player_name, int destsize)
+void player_clui_score_name (char player_name[static restrict BUFSIZ])
{
printf("Your name:\n");
- fgets(player_name, destsize, stdin);
+ fgets(player_name, BUFSIZ, stdin);
}
diff --git a/modules/player/src/player_iface.c b/src/player/iface.c
index 537afb0..5e4bf2f 100644..100755
--- a/modules/player/src/player_iface.c
+++ b/src/player/iface.c
@@ -6,20 +6,20 @@
/******************************************************************************
******* headers **************************************************************
******************************************************************************/
- #include <stdio.h>
+#include "mine-sweeper/player/iface.h"
- #include "game_iface.h"
- #include "player_clui.h"
- #include "player_tui.h"
- #include "player_gui.h"
+#include <stddef.h>
+#include <stdio.h>
- #include "player_iface.h"
+#include "mine-sweeper/game/iface.h"
+#include "mine-sweeper/player/clui.h"
+#include "mine-sweeper/player/tui.h"
/******************************************************************************
******* macros ***************************************************************
******************************************************************************/
- # define TITLE_SIZE (20)
+#define TITLE_SIZE (20)
/******************************************************************************
@@ -54,7 +54,7 @@ static void highlight_cursor (void);
/******************************************************************************
******* global functions *****************************************************
******************************************************************************/
-void player_iface_init (int rows, int cols)
+void player_iface_init (ptrdiff_t rows, ptrdiff_t cols)
{
player_iface_position.rows = rows;
@@ -63,18 +63,13 @@ void player_iface_init (int rows, int cols)
switch (player_iface_mode) {
case PLAYER_IFACE_CLUI:
break;
-
case PLAYER_IFACE_TUI:
player_tui_init(rows, cols);
break;
-
- case PLAYER_IFACE_GUI:
- player_gui_init(&player_iface_position, &player_action);
- break;
}
}
-int player_iface_start (int *row, int *col)
+int player_iface_start (ptrdiff_t *row, ptrdiff_t *col)
{
char title[TITLE_SIZE];
char subtitle[TITLE_SIZE];
@@ -95,16 +90,10 @@ int player_iface_start (int *row, int *col)
player_clui_start(&player_iface_position,
title, subtitle, &player_action);
break;
-
case PLAYER_IFACE_TUI:
player_tui_start(&player_iface_position,
title, subtitle, &player_action);
break;
-
- case PLAYER_IFACE_GUI:
- player_gui_start(&player_iface_position,
- title, subtitle);
- break;
}
player_iface_act_start();
@@ -185,42 +174,34 @@ void player_iface (const struct Game_Iface_Out *out,
player_tui(out, &player_iface_position, title, subtitle,
&player_action);
break;
- case PLAYER_IFACE_GUI:
- player_gui(out, &player_iface_position, title, subtitle);
- break;
}
player_iface_act(in);
}
-void player_iface_save_name (const char *fpath, char *fname, int destsize)
+void player_iface_save_name (const char *fpath,
+ char fname[static restrict FILENAME_MAX])
{
switch (player_iface_mode) {
case PLAYER_IFACE_CLUI:
- player_clui_save_name(fpath, fname, destsize);
+ player_clui_save_name(fpath, fname);
break;
case PLAYER_IFACE_TUI:
- player_tui_save_name(fpath, fname, destsize);
- break;
- case PLAYER_IFACE_GUI:
- player_gui_save_name(fpath, fname, destsize);
+ player_tui_save_name(fpath, fname);
break;
}
}
-void player_iface_score_name (char *player_name, int destsize)
+void player_iface_score_name (char player_name[static restrict BUFSIZ])
{
switch (player_iface_mode) {
case PLAYER_IFACE_CLUI:
- player_clui_score_name(player_name, destsize);
+ player_clui_score_name(player_name);
break;
case PLAYER_IFACE_TUI:
- player_tui_score_name(player_name, destsize);
- break;
- case PLAYER_IFACE_GUI:
- player_gui_score_name(player_name, destsize);
+ player_tui_score_name(player_name);
break;
}
}
@@ -234,9 +215,6 @@ void player_iface_cleanup (void)
case PLAYER_IFACE_TUI:
player_tui_cleanup();
break;
- case PLAYER_IFACE_GUI:
- player_gui_cleanup();
- break;
}
fflush(stdout);
}
diff --git a/modules/player/src/player_tui.c b/src/player/tui.c
index 99cba09..d62d06a 100644..100755
--- a/modules/player/src/player_tui.c
+++ b/src/player/tui.c
@@ -6,21 +6,25 @@
/******************************************************************************
******* headers **************************************************************
******************************************************************************/
- #include <ncurses.h>
+#include "mine-sweeper/player/tui.h"
- #include "libalx/curses/alx_ncur.h"
+#include <stdbool.h>
+#include <stddef.h>
+#include <stdio.h>
- #include "game_iface.h"
+#include <ncurses.h>
- #include "player_iface.h"
+#include "libalx/extra/ncurses/common.h"
+#include "libalx/extra/ncurses/get.h"
- #include "player_tui.h"
+#include "mine-sweeper/game/iface.h"
+#include "mine-sweeper/player/iface.h"
/******************************************************************************
******* macros ***************************************************************
******************************************************************************/
- # define REFRESH_TIME_MS (100)
+#define REFRESH_TIME_MS (100)
/******************************************************************************
@@ -72,7 +76,7 @@ static void show_help_gameover (void);
/******************************************************************************
******* main *****************************************************************
******************************************************************************/
-void player_tui_init (int rows, int cols)
+void player_tui_init (ptrdiff_t rows, ptrdiff_t cols)
{
int h1;
int w1;
@@ -83,7 +87,7 @@ void player_tui_init (int rows, int cols)
int r2;
int c2;
- alx_resume_curses();
+ alx_ncurses_resume();
flag_color = false;
if (has_colors()) {
@@ -160,32 +164,33 @@ int player_tui (const struct Game_Iface_Out *board,
return 0;
}
-void player_tui_save_name (const char *fpath, char *fname, int destsize)
+void player_tui_save_name (const char *fpath,
+ char fname[static restrict FILENAME_MAX])
{
int w;
int r;
w = 60;
r = 10;
- alx_w_getfname(fpath, fname, false, w, r, "File name:", NULL);
+ alx_ncurses_get_fname(fpath, fname, false, w, r, "File name:", NULL, 2);
}
-void player_tui_score_name (char *player_name, int destsize)
+void player_tui_score_name (char player_name[static restrict BUFSIZ])
{
int w;
int r;
w = 60;
r = 10;
- alx_w_getstr(player_name, destsize, w, r, "Your name:", NULL);
+ alx_ncurses_get_nstr(BUFSIZ, player_name, w, r, "Your name:", NULL);
}
void player_tui_cleanup (void)
{
- alx_win_del(win_board);
- alx_win_del(win_help);
- alx_pause_curses();
+ alx_ncurses_delwin(win_board);
+ alx_ncurses_delwin(win_help);
+ alx_ncurses_pause();
}
@@ -201,8 +206,8 @@ static void show_board_start(const struct Player_Iface_Position *position,
werase(win_board);
box(win_board, 0, 0);
- alx_ncur_prn_title(win_board, title);
- alx_ncur_prn_subtitle(win_board, subtitle);
+ alx_ncurses_title(win_board, title);
+ alx_ncurses_subtitle(win_board, subtitle);
board_loop_start(position);
wmove(win_board, 1 + position->row, 2 + 2 * position->col);
@@ -211,19 +216,17 @@ static void show_board_start(const struct Player_Iface_Position *position,
static void board_loop_start(const struct Player_Iface_Position *position)
{
- int i;
- int j;
- int k;
- int l;
- int c;
+ ptrdiff_t k;
+ ptrdiff_t l;
+ int c;
c = PLAYER_TUI_CHAR_HIDDEN_FIELD;
- for (i = 0; i < position->rows; i++) {
+ for (ptrdiff_t i = 0; i < position->rows; i++) {
k = 1 + i;
/* hidden */
- for (j = 0; j < position->cols; j++) {
+ for (ptrdiff_t j = 0; j < position->cols; j++) {
l = 2 + 2 * j;
show_char(k, l, c);
@@ -242,39 +245,31 @@ static void show_board (const struct Game_Iface_Out *board,
const struct Player_Iface_Position *position,
const char *title, const char *subtitle)
{
- /* Clear & box */
+
werase(win_board);
box(win_board, 0, 0);
- /* Title */
- alx_ncur_prn_title(win_board, title);
- /* Subtitle */
- alx_ncur_prn_subtitle(win_board, subtitle);
+ alx_ncurses_title(win_board, title);
+ alx_ncurses_subtitle(win_board, subtitle);
- /* Board */
board_loop(board, position);
-
- /* Cursor */
wmove(win_board, 1 + position->row, 2 + 2 * position->col);
- /* Refresh */
wrefresh(win_board);
}
static void board_loop (const struct Game_Iface_Out *board,
const struct Player_Iface_Position *position)
{
- int i;
- int j;
- int k;
- int l;
- int c;
+ ptrdiff_t k;
+ ptrdiff_t l;
+ int c;
- for (i = 0; i < board->rows; i++) {
+ for (ptrdiff_t i = 0; i < board->rows; i++) {
k = 1 + i;
/* clear */
- for (j = 0; j < board->cols; j++) {
+ for (ptrdiff_t j = 0; j < board->cols; j++) {
l = 2 + 2 * j;
if (board->usr[i][j] == GAME_IFACE_USR_CLEAR) {
c = set_char(board->visible[i][j]);
@@ -283,7 +278,7 @@ static void board_loop (const struct Game_Iface_Out *board,
}
/* xyzzy */
/* hidden */
- for (j = 0; j < board->cols; j++) {
+ for (ptrdiff_t j = 0; j < board->cols; j++) {
l = 2 + 2 * j;
if (board->usr[i][j] != GAME_IFACE_USR_CLEAR) {
c = set_char(board->visible[i][j]);
@@ -291,7 +286,7 @@ static void board_loop (const struct Game_Iface_Out *board,
}
}
/* kboom */
- for (j = 0; j < board->cols; j++) {
+ for (ptrdiff_t j = 0; j < board->cols; j++) {
l = 2 + 2 * j;
if (board->usr[i][j] == GAME_IFACE_USR_KBOOM) {
c = set_char(board->visible[i][j]);
@@ -310,9 +305,9 @@ static void board_loop (const struct Game_Iface_Out *board,
static void highlight_cursor(int c,
const struct Player_Iface_Position *position)
{
- int k;
- int l;
- int pair;
+ ptrdiff_t k;
+ ptrdiff_t l;
+ int pair;
k = 1 + position->row;
l = 2 + 2 * position->col;
@@ -565,6 +560,7 @@ static int usr_input (void)
* * * * * * * * * */
static void show_help (const struct Game_Iface_Out *board)
{
+
if (last_help == board->state)
return;
diff --git a/src/save/save.c b/src/save/save.c
new file mode 100755
index 0000000..fb2ca22
--- /dev/null
+++ b/src/save/save.c
@@ -0,0 +1,238 @@
+/******************************************************************************
+ * Copyright (C) 2015 Alejandro Colomar Andrés *
+ * SPDX-License-Identifier: GPL-2.0-only *
+ ******************************************************************************/
+
+
+/******************************************************************************
+ ******* headers **************************************************************
+ ******************************************************************************/
+#include "mine-sweeper/save/save.h"
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <sys/stat.h>
+
+#include "libalx/base/errno/perror.h"
+#include "libalx/base/stdio/wait.h"
+
+#include "mine-sweeper/game/core.h"
+#include "mine-sweeper/player/iface.h"
+
+
+/******************************************************************************
+ ******* variables ************************************************************
+ ******************************************************************************/
+ char home_path [FILENAME_MAX];
+ char user_game_path [FILENAME_MAX];
+ char saved_path [FILENAME_MAX];
+ char saved_name [FILENAME_MAX];
+
+
+/******************************************************************************
+ ******* global functions *****************************************************
+ ******************************************************************************/
+void save_init (void)
+{
+
+ if (snprintf(home_path, sizeof(home_path), "%s/",
+ getenv(ENV_HOME)) >= FILENAME_MAX) {
+ goto err_path;
+ }
+ if (snprintf(user_game_path, sizeof(user_game_path), "%s/%s/",
+ home_path, USER_GAME_DIR) >= FILENAME_MAX) {
+ goto err_path;
+ }
+ if (snprintf(saved_path, sizeof(saved_path), "%s/%s/",
+ home_path, USER_SAVED_DIR) >= FILENAME_MAX) {
+ goto err_path;
+ }
+ saved_name[0] = '\0';
+
+ if (mkdir(user_game_path, 0700)) {
+ if (errno != EEXIST)
+ goto err_mkdir;
+ }
+ if (mkdir(saved_path, 0700)) {
+ if (errno != EEXIST)
+ goto err_mkdir;
+ return;
+ }
+
+ return;
+
+err_path:
+ alx_perror("Path is too large and has been truncated");
+ exit(EXIT_FAILURE);
+err_mkdir:
+ alx_perror(NULL);
+}
+
+void save_clr (void)
+{
+
+ if (snprintf(saved_path, sizeof(saved_path), "%s/%s/",
+ home_path, USER_SAVED_DIR) >= FILENAME_MAX) {
+ goto err_path;
+ }
+
+ return;
+
+
+err_path:
+ alx_perror("Path is too large and has been truncated");
+ exit(EXIT_FAILURE);
+}
+
+int load_game_file (void)
+{
+ char fname[FILENAME_MAX];
+ FILE *fp;
+ int i;
+ int j;
+
+ if (snprintf(fname, sizeof(fname), "%s/%s",
+ saved_path, saved_name) >= FILENAME_MAX) {
+ goto err_path;
+ }
+
+ fp = fopen(fname, "r");
+ if (!fp)
+ return -1;
+ fscanf(fp, "mine-sweeper saved game");
+ fscanf(fp, " rows %ti", &game_board.rows);
+ fscanf(fp, " cols %ti", &game_board.cols);
+ fscanf(fp, " mines %i", &game_board.mines);
+ fscanf(fp, " gnd");
+ for (i = 0; i < game_board.rows; i++) {
+ fscanf(fp, " %i", &game_board.gnd[i][0]);
+ for (j = 1; j < game_board.cols; j++)
+ fscanf(fp, ",%i", &game_board.gnd[i][j]);
+ }
+ fscanf(fp, " usr");
+ for (i = 0; i < game_board.rows; i++) {
+ fscanf(fp, " %i", &game_board.usr[i][0]);
+ for (j = 1; j < game_board.cols; j++)
+ fscanf(fp, ",%i", &game_board.usr[i][j]);
+ }
+ fscanf(fp, " flags %i", &game_board.flags);
+ fscanf(fp, " cleared %i", &game_board.clr);
+
+ fclose(fp);
+
+ return 0;
+
+
+err_path:
+ alx_perror("Path is too large and has been truncated");
+ alx_wait4enter();
+ exit(EXIT_FAILURE);
+}
+
+void save_game_file (char fpath[static restrict FILENAME_MAX])
+{
+ char fname[FILENAME_MAX];
+ char tmp[FILENAME_MAX];
+ char old_saved[FILENAME_MAX];
+ char file_num[6];
+ FILE *fp;
+ int i;
+ int j;
+ bool x;
+
+ /* Don't change saved_name variable if not in default dir */
+ if (fpath)
+ snprintf(old_saved, sizeof(old_saved), "%s", saved_name);
+
+ /* Default path & name */
+ save_clr();
+ snprintf(saved_name, sizeof(saved_name), "%s", SAVED_NAME_DEFAULT);
+ file_num[0] = '\0';
+
+ /* Request file name */
+ player_iface_save_name(fpath, saved_name);
+
+ /* Look for an unused name of the type 'name_XXX.mine'. */
+ x = true;
+ for (i = 0; x; i++) {
+ if (!fpath) {
+ if (snprintf(fname, sizeof(fname), "%s/%s%s%s",
+ saved_path, saved_name, file_num,
+ FILE_EXTENSION) >= FILENAME_MAX) {
+ goto err_path;
+ }
+ } else {
+ if (snprintf(fname, sizeof(fname), "%s/%s%s%s",
+ fpath, saved_name, file_num,
+ FILE_EXTENSION) >= FILENAME_MAX) {
+ goto err_path;
+ }
+ }
+
+ fp = fopen(fname, "r");
+ if (fp) {
+ fclose(fp);
+ file_num[0] = '_';
+ file_num[1] = '0' + ((i / 100) % 10);
+ file_num[2] = '0' + ((i / 10) % 10);
+ file_num[3] = '0' + (i % 10);
+ file_num[4] = '\0';
+ } else {
+ x = false;
+ if (snprintf(tmp, sizeof(tmp), "%s%s%s",
+ saved_name, file_num,
+ FILE_EXTENSION) >= FILENAME_MAX) {
+ goto err_path;
+ }
+ snprintf(saved_name, sizeof(saved_name), "%s", tmp);
+ }
+ }
+
+ /* Write to a new file */
+ fp = fopen(fname, "w");
+ if (!fp) {
+ alx_perror(fname);
+ goto err_fopen;
+ }
+ fprintf(fp, "mine-sweeper saved game\n");
+ fprintf(fp, "rows %ti\n", game_board.rows);
+ fprintf(fp, "cols %ti\n", game_board.cols);
+ fprintf(fp, "mines %i\n", game_board.mines);
+ fprintf(fp, "gnd\n");
+ for (i = 0; i < game_board.rows; i++) {
+ fprintf(fp, "%i", game_board.gnd[i][0]);
+ for (j = 1; j < game_board.cols; j++)
+ fprintf(fp, ",%i", game_board.gnd[i][j]);
+ fprintf(fp, "\n");
+ }
+ fprintf(fp, "usr\n");
+ for (i = 0; i < game_board.rows; i++) {
+ fprintf(fp, "%i", game_board.usr[i][0]);
+ for (j = 1; j < game_board.cols; j++)
+ fprintf(fp, ",%i", game_board.usr[i][j]);
+ fprintf(fp, "\n");
+ }
+ fprintf(fp, "flags %i\n", game_board.flags);
+ fprintf(fp, "cleared %i\n", game_board.clr);
+
+ fclose(fp);
+err_fopen:
+ /* Don't change saved_name if saving in non-default dir */
+ if (fpath)
+ snprintf(saved_name, sizeof(saved_name), "%s", old_saved);
+
+ return;
+
+
+err_path:
+ alx_perror("Path is too large and has been truncated");
+ alx_wait4enter();
+ exit(EXIT_FAILURE);
+}
+
+
+/******************************************************************************
+ ******* end of file **********************************************************
+ ******************************************************************************/
diff --git a/src/save/score.c b/src/save/score.c
new file mode 100755
index 0000000..1deed1c
--- /dev/null
+++ b/src/save/score.c
@@ -0,0 +1,128 @@
+/******************************************************************************
+ * Copyright (C) 2015 Alejandro Colomar Andrés *
+ * SPDX-License-Identifier: GPL-2.0-only *
+ ******************************************************************************/
+
+
+/******************************************************************************
+ ******* headers **************************************************************
+ ******************************************************************************/
+#include "mine-sweeper/save/score.h"
+
+#include <limits.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+
+#include "libalx/base/errno/perror.h"
+#include "libalx/base/stddef/size.h"
+#include "libalx/base/stdio/wait.h"
+
+#include "mine-sweeper/game/core.h"
+#include "mine-sweeper/game/iface.h"
+#include "mine-sweeper/player/iface.h"
+#include "mine-sweeper/save/save.h"
+
+
+/******************************************************************************
+ ******* macros ***************************************************************
+ ******************************************************************************/
+
+
+/******************************************************************************
+ ******* variables ************************************************************
+ ******************************************************************************/
+
+
+/******************************************************************************
+ ******* static functions *****************************************************
+ ******************************************************************************/
+
+
+/******************************************************************************
+ ******* global functions *****************************************************
+ ******************************************************************************/
+void save_score (const struct Game_Iface_Score *game_iface_score)
+{
+ struct tm *date_format;
+ char *fname;
+ char player_name[BUFSIZ];
+ FILE *fp;
+ time_t date_secs;
+
+ /* File name */
+ switch (game_iface_score->level) {
+ case GAME_IFACE_LVL_BEGINNER:
+ fname = HISCORES_BEGINNER_FILE;
+ break;
+ case GAME_IFACE_LVL_INTERMEDIATE:
+ fname = HISCORES_INTERMEDIATE_FILE;
+ break;
+ case GAME_IFACE_LVL_EXPERT:
+ fname = HISCORES_EXPERT_FILE;
+ break;
+ }
+
+ /* Date & time */
+ date_secs = time(NULL);
+ date_format = localtime(&date_secs);
+
+ /* Player name (foo is default) */
+ player_iface_score_name(player_name);
+
+ /* Write to file (append) */
+ errno = 0;
+ fp = fopen(fname, "a");
+ if (!fp)
+ goto err_fp;
+ fprintf(fp, "\n");
+ fprintf(fp, "name %s\n", player_name);
+ fprintf(fp, "date %i\n", (int)date_secs);
+ fprintf(fp, "{\n");
+ fprintf(fp, " isdst %i\n", date_format->tm_isdst);
+ fprintf(fp, " yday %i\n", date_format->tm_yday);
+ fprintf(fp, " wday %i\n", date_format->tm_wday);
+ fprintf(fp, " year %i\n", date_format->tm_year);
+ fprintf(fp, " mon %i\n", date_format->tm_mon);
+ fprintf(fp, " mday %i\n", date_format->tm_mday);
+ fprintf(fp, " hour %i\n", date_format->tm_hour);
+ fprintf(fp, " min %i\n", date_format->tm_min);
+ fprintf(fp, " sec %i\n", date_format->tm_sec);
+ fprintf(fp, "}\n");
+ fprintf(fp, "time %i\n", game_iface_score->time);
+ fprintf(fp, "clicks %i\n", game_iface_score->clicks);
+ fprintf(fp, "file %s\n", saved_name);
+ fclose(fp);
+
+ return;
+
+err_fp:
+ alx_perror("Score could not be saved");
+}
+
+void print_scores (void)
+{
+ char cmd[_POSIX_ARG_MAX];
+
+ if (snprintf(cmd, sizeof(cmd), "less %s %s %s",
+ HISCORES_BEGINNER_FILE,
+ HISCORES_INTERMEDIATE_FILE,
+ HISCORES_EXPERT_FILE) >= SSIZEOF(cmd)) {
+ goto err;
+ }
+ if (system(cmd))
+ alx_perror(NULL);
+ return;
+err:
+ alx_perror("Path is too large and has been truncated");
+}
+
+
+/******************************************************************************
+ ******* static functions *****************************************************
+ ******************************************************************************/
+
+
+/******************************************************************************
+ ******* end of file **********************************************************
+ ******************************************************************************/
diff --git a/modules/xyzzy/src/xyzzy.c b/src/xyzzy/xyzzy.c
index 4e0cb66..8d2fcc8 100644..100755
--- a/modules/xyzzy/src/xyzzy.c
+++ b/src/xyzzy/xyzzy.c
@@ -6,11 +6,11 @@
/******************************************************************************
******* headers **************************************************************
******************************************************************************/
- #include <stdbool.h>
+#include "mine-sweeper/xyzzy/xyzzy.h"
- #include "game_iface.h"
+#include <stdbool.h>
- #include "xyzzy.h"
+#include "mine-sweeper/game/iface.h"
/******************************************************************************
diff --git a/tmp/Makefile b/tmp/Makefile
index 363d0ca..4fb766e 100644..100755
--- a/tmp/Makefile
+++ b/tmp/Makefile
@@ -1,74 +1,94 @@
-# -*- MakeFile -*-
+#! /usr/bin/make -f
-# MACRO = substitute with this
+################################################################################
+# Copyright (C) 2019 Alejandro Colomar Andrés
+# SPDX-License-Identifier: GPL-2.0-only
+################################################################################
+# *AUTHOR*
+# FULL NAME "Alejandro Colomar Andrés"
+# EMAIL "1903716@gmail.com"
+################################################################################
-# directories
+################################################################################
+# dependencies
+
+OBJ = \
+ main.o
-LIBALX_INC_DIR = $(LIBALX_DIR)/inc/
+MAIN_INC = \
+ $(LIBALX_INC_DIR)/libalx/extra/ncurses/common.h \
+ $(INC_DIR)/mine-sweeper/about/about.h \
+ $(INC_DIR)/mine-sweeper/ctrl/start.h \
+ $(INC_DIR)/mine-sweeper/game/core.h \
+ $(INC_DIR)/mine-sweeper/menu/iface.h \
+ $(INC_DIR)/mine-sweeper/menu/parser.h \
+ $(INC_DIR)/mine-sweeper/player/iface.h \
+ $(INC_DIR)/mine-sweeper/save/save.h \
+ $(INC_DIR)/mine-sweeper/save/score.h
+MAIN_SRC = \
+ $(SRC_DIR)/main.c
-ABOUT_DIR = $(MODULES_DIR)/about/
-ABOUT_INC_DIR = $(ABOUT_DIR)/inc/
-CTRL_DIR = $(MODULES_DIR)/ctrl/
-CTRL_INC_DIR = $(CTRL_DIR)/inc/
+# target: dependencies
+# action
-GAME_DIR = $(MODULES_DIR)/game/
-GAME_INC_DIR = $(GAME_DIR)/inc/
+PHONY := all
+all: $(OBJ) about ctrl game menu player save xyzzy
-MENU_DIR = $(MODULES_DIR)/menu/
-MENU_INC_DIR = $(MENU_DIR)/inc/
-PLAY_DIR = $(MODULES_DIR)/player/
-PLAY_INC_DIR = $(PLAY_DIR)/inc/
+PHONY += about
+about:
+ @echo " MAKE tmp/$@"
+ $(Q)$(MAKE) -C $(TMP_DIR)/$@/
-SAVE_DIR = $(MODULES_DIR)/save/
-SAVE_INC_DIR = $(SAVE_DIR)/inc/
+PHONY += ctrl
+ctrl:
+ @echo " MAKE tmp/$@"
+ $(Q)$(MAKE) -C $(TMP_DIR)/$@/
-SRC_DIR = $(MAIN_DIR)/src/
+PHONY += game
+game:
+ @echo " MAKE tmp/$@"
+ $(Q)$(MAKE) -C $(TMP_DIR)/$@/
-# dependencies
+PHONY += menu
+menu:
+ @echo " MAKE tmp/$@"
+ $(Q)$(MAKE) -C $(TMP_DIR)/$@/
-ALL = main.o
-
-MAIN_INC_LIBALX = libalx/curses/alx_ncur.h
-MAIN_INC_ABOUT = about.h
-MAIN_INC_CTRL = start.h
-MAIN_INC_GAME = game.h
-MAIN_INC_MENU = parser.h menu_iface.h
-MAIN_INC_PLAY = player_iface.h
-MAIN_INC_SAVE = save.h score.h
-MAIN_DEPS = $(SRC_DIR)/main.c \
- $(patsubst %,$(LIBALX_INC_DIR)/%,$(MAIN_INC_LIBALX)) \
- $(patsubst %,$(ABOUT_INC_DIR)/%,$(MAIN_INC_ABOUT)) \
- $(patsubst %,$(CTRL_INC_DIR)/%,$(MAIN_INC_CTRL)) \
- $(patsubst %,$(GAME_INC_DIR)/%,$(MAIN_INC_GAME)) \
- $(patsubst %,$(MENU_INC_DIR)/%,$(MAIN_INC_MENU)) \
- $(patsubst %,$(PLAY_INC_DIR)/%,$(MAIN_INC_PLAY)) \
- $(patsubst %,$(SAVE_INC_DIR)/%,$(MAIN_INC_SAVE))
-MAIN_INC_DIRS = -I $(LIBALX_INC_DIR) \
- -I $(ABOUT_INC_DIR) \
- -I $(CTRL_INC_DIR) \
- -I $(GAME_INC_DIR) \
- -I $(MENU_INC_DIR) \
- -I $(PLAY_INC_DIR) \
- -I $(SAVE_INC_DIR)
+PHONY += player
+player:
+ @echo " MAKE tmp/$@"
+ $(Q)$(MAKE) -C $(TMP_DIR)/$@/
+PHONY += save
+save:
+ @echo " MAKE tmp/$@"
+ $(Q)$(MAKE) -C $(TMP_DIR)/$@/
-# target: dependencies
-# action
+PHONY += xyzzy
+xyzzy:
+ @echo " MAKE tmp/$@"
+ $(Q)$(MAKE) -C $(TMP_DIR)/$@/
-all: $(ALL)
-main.s: $(MAIN_DEPS)
- @echo " CC $@"
- $(Q)$(CC) $(CFLAGS) $(MAIN_INC_DIRS) -S $< -o $@
+main.s: $(MAIN_SRC) $(MAIN_INC)
+ @echo " CC mine-sweeper/tmp/$@"
+ $(Q)$(CC) $(CFLAGS) -S $< -o $@
main.o: main.s
- @echo " AS $@"
+ @echo " AS mine-sweeper/tmp/$@"
$(Q)$(AS) $< -o $@
+PHONY += clean
clean:
- $(Q)rm -f *.o *.s
+ @echo " RM *.o *.s"
+ $(Q)rm -f *.o *.s
+
+################################################################################
+# Declare the contents of the .PHONY variable as phony.
+.PHONY: $(PHONY)
+
################################################################################
######## End of file ###########################################################
diff --git a/tmp/about/Makefile b/tmp/about/Makefile
new file mode 100755
index 0000000..c0c86a2
--- /dev/null
+++ b/tmp/about/Makefile
@@ -0,0 +1,53 @@
+#! /usr/bin/make -f
+
+################################################################################
+# Copyright (C) 2019 Alejandro Colomar Andrés
+# SPDX-License-Identifier: GPL-2.0-only
+################################################################################
+# *AUTHOR*
+# FULL NAME "Alejandro Colomar Andrés"
+# EMAIL "1903716@gmail.com"
+################################################################################
+
+################################################################################
+# dependencies
+
+OBJ = \
+ about.o
+
+ABOUT_INC = \
+ $(INC_DIR)/mine-sweeper/about/about.h \
+ $(LIBALX_INC_DIR)/libalx/base/errno/perror.h \
+ $(LIBALX_INC_DIR)/libalx/base/stddef/size.h
+ABOUT_SRC = \
+ $(SRC_DIR)/about/about.c
+
+################################################################################
+# target: dependencies
+# action
+
+PHONY := all
+all: $(OBJ)
+
+
+about.s: $(ABOUT_SRC) $(ABOUT_INC)
+ @echo " CC mine-sweeper/about/$@"
+ $(Q)$(CC) $(CFLAGS) -S $< -o $@
+about.o: about.s
+ @echo " AS mine-sweeper/about/$@"
+ $(Q)$(AS) $< -o $@
+
+
+PHONY += clean
+clean:
+ @echo " RM *.o *.s"
+ $(Q)rm -f *.o *.s
+
+################################################################################
+# Declare the contents of the .PHONY variable as phony.
+.PHONY: $(PHONY)
+
+
+################################################################################
+######## End of file ###########################################################
+################################################################################
diff --git a/tmp/ctrl/Makefile b/tmp/ctrl/Makefile
new file mode 100755
index 0000000..638a870
--- /dev/null
+++ b/tmp/ctrl/Makefile
@@ -0,0 +1,55 @@
+#! /usr/bin/make -f
+
+################################################################################
+# Copyright (C) 2019 Alejandro Colomar Andrés
+# SPDX-License-Identifier: GPL-2.0-only
+################################################################################
+# *AUTHOR*
+# FULL NAME "Alejandro Colomar Andrés"
+# EMAIL "1903716@gmail.com"
+################################################################################
+
+################################################################################
+# dependencies
+
+OBJ = \
+ start.o
+
+START_INC = \
+ $(INC_DIR)/mine-sweeper/ctrl/start.h \
+ $(INC_DIR)/mine-sweeper/game/core.h \
+ $(INC_DIR)/mine-sweeper/game/iface.h \
+ $(INC_DIR)/mine-sweeper/menu/iface.h \
+ $(INC_DIR)/mine-sweeper/player/iface.h
+START_SRC = \
+ $(SRC_DIR)/ctrl/start.c
+
+################################################################################
+# target: dependencies
+# action
+
+PHONY := all
+all: $(OBJ)
+
+
+start.s: $(START_SRC) $(START_INC)
+ @echo " CC mine-sweeper/ctrl/$@"
+ $(Q)$(CC) $(CFLAGS) -S $< -o $@
+start.o: start.s
+ @echo " AS mine-sweeper/ctrl/$@"
+ $(Q)$(AS) $< -o $@
+
+
+PHONY += clean
+clean:
+ @echo " RM *.o *.s"
+ $(Q)rm -f *.o *.s
+
+################################################################################
+# Declare the contents of the .PHONY variable as phony.
+.PHONY: $(PHONY)
+
+
+################################################################################
+######## End of file ###########################################################
+################################################################################
diff --git a/tmp/game/Makefile b/tmp/game/Makefile
new file mode 100755
index 0000000..c0a1b85
--- /dev/null
+++ b/tmp/game/Makefile
@@ -0,0 +1,72 @@
+#! /usr/bin/make -f
+
+################################################################################
+# Copyright (C) 2019 Alejandro Colomar Andrés
+# SPDX-License-Identifier: GPL-2.0-only
+################################################################################
+# *AUTHOR*
+# FULL NAME "Alejandro Colomar Andrés"
+# EMAIL "1903716@gmail.com"
+################################################################################
+
+################################################################################
+# dependencies
+
+OBJ = \
+ core.o \
+ iface.o
+
+CORE_INC = \
+ $(INC_DIR)/mine-sweeper/game/core.h \
+ $(LIBALX_INC_DIR)/libalx/base/stdlib/seed_mix.h \
+ $(INC_DIR)/mine-sweeper/save/save.h
+CORE_SRC = \
+ $(SRC_DIR)/game/core.c
+
+IFACE_INC = \
+ $(INC_DIR)/mine-sweeper/game/iface.h \
+ $(LIBALX_INC_DIR)/libalx/base/stdlib/seed_mix.h \
+ $(INC_DIR)/mine-sweeper/game/core.h \
+ $(INC_DIR)/mine-sweeper/player/iface.h \
+ $(INC_DIR)/mine-sweeper/save/save.h \
+ $(INC_DIR)/mine-sweeper/save/score.h \
+ $(INC_DIR)/mine-sweeper/xyzzy/xyzzy.h
+IFACE_SRC = \
+ $(SRC_DIR)/game/iface.c
+
+################################################################################
+# target: dependencies
+# action
+
+PHONY := all
+all: $(OBJ)
+
+
+core.s: $(CORE_SRC) $(CORE_INC)
+ @echo " CC mine-sweeper/game/$@"
+ $(Q)$(CC) $(CFLAGS) -S $< -o $@
+core.o: core.s
+ @echo " AS mine-sweeper/game/$@"
+ $(Q)$(AS) $< -o $@
+
+iface.s: $(IFACE_SRC) $(IFACE_INC)
+ @echo " CC mine-sweeper/game/$@"
+ $(Q)$(CC) $(CFLAGS) -S $< -o $@
+iface.o: iface.s
+ @echo " AS mine-sweeper/game/$@"
+ $(Q)$(AS) $< -o $@
+
+
+PHONY += clean
+clean:
+ @echo " RM *.o *.s"
+ $(Q)rm -f *.o *.s
+
+################################################################################
+# Declare the contents of the .PHONY variable as phony.
+.PHONY: $(PHONY)
+
+
+################################################################################
+######## End of file ###########################################################
+################################################################################
diff --git a/tmp/menu/Makefile b/tmp/menu/Makefile
new file mode 100755
index 0000000..be2b939
--- /dev/null
+++ b/tmp/menu/Makefile
@@ -0,0 +1,116 @@
+#! /usr/bin/make -f
+
+################################################################################
+# Copyright (C) 2019 Alejandro Colomar Andrés
+# SPDX-License-Identifier: GPL-2.0-only
+################################################################################
+# *AUTHOR*
+# FULL NAME "Alejandro Colomar Andrés"
+# EMAIL "1903716@gmail.com"
+################################################################################
+
+################################################################################
+# dependencies
+
+OBJ = \
+ parser.o \
+ clui.o \
+ tui.o \
+ iface.o
+
+PARSER_INC = \
+ $(INC_DIR)/mine-sweeper/menu/parser.h \
+ $(LIBALX_INC_DIR)/libalx/base/stdlib/seed_mix.h \
+ $(INC_DIR)/mine-sweeper/about/about.h \
+ $(INC_DIR)/mine-sweeper/ctrl/start.h \
+ $(INC_DIR)/mine-sweeper/game/iface.h \
+ $(INC_DIR)/mine-sweeper/menu/iface.h \
+ $(INC_DIR)/mine-sweeper/player/iface.h \
+ $(INC_DIR)/mine-sweeper/save/save.h
+PARSER_SRC = \
+ $(SRC_DIR)/menu/parser.c
+
+CLUI_INC = \
+ $(INC_DIR)/mine-sweeper/menu/clui.h \
+ $(LIBALX_INC_DIR)/libalx/base/stdio/get.h \
+ $(INC_DIR)/mine-sweeper/about/about.h \
+ $(INC_DIR)/mine-sweeper/ctrl/start.h \
+ $(INC_DIR)/mine-sweeper/game/iface.h \
+ $(INC_DIR)/mine-sweeper/menu/iface.h \
+ $(INC_DIR)/mine-sweeper/save/save.h
+CLUI_SRC = \
+ $(SRC_DIR)/menu/clui.c
+
+TUI_INC = \
+ $(INC_DIR)/mine-sweeper/menu/tui.h \
+ $(LIBALX_INC_DIR)/libalx/extra/ncurses/common.h \
+ $(LIBALX_INC_DIR)/libalx/extra/ncurses/get.h \
+ $(LIBALX_INC_DIR)/libalx/extra/ncurses/menu.h \
+ $(INC_DIR)/mine-sweeper/about/about.h \
+ $(INC_DIR)/mine-sweeper/ctrl/start.h \
+ $(INC_DIR)/mine-sweeper/game/iface.h \
+ $(INC_DIR)/mine-sweeper/menu/iface.h \
+ $(INC_DIR)/mine-sweeper/save/save.h \
+ $(INC_DIR)/mine-sweeper/save/score.h
+TUI_SRC = \
+ $(SRC_DIR)/menu/tui.c
+
+IFACE_INC = \
+ $(INC_DIR)/mine-sweeper/menu/iface.h \
+ $(INC_DIR)/mine-sweeper/ctrl/start.h \
+ $(INC_DIR)/mine-sweeper/game/iface.h \
+ $(INC_DIR)/mine-sweeper/menu/clui.h \
+ $(INC_DIR)/mine-sweeper/menu/tui.h
+IFACE_SRC = \
+ $(SRC_DIR)/menu/iface.c
+
+################################################################################
+# target: dependencies
+# action
+
+PHONY := all
+all: $(OBJ)
+
+
+parser.s: $(PARSER_SRC) $(PARSER_INC)
+ @echo " CC mine-sweeper/menu/$@"
+ $(Q)$(CC) $(CFLAGS) -S $< -o $@
+parser.o: parser.s
+ @echo " AS mine-sweeper/menu/$@"
+ $(Q)$(AS) $< -o $@
+
+clui.s: $(CLUI_SRC) $(CLUI_INC)
+ @echo " CC mine-sweeper/menu/$@"
+ $(Q)$(CC) $(CFLAGS) -S $< -o $@
+clui.o: clui.s
+ @echo " AS mine-sweeper/menu/$@"
+ $(Q)$(AS) $< -o $@
+
+tui.s: $(TUI_SRC) $(TUI_INC)
+ @echo " CC mine-sweeper/menu/$@"
+ $(Q)$(CC) $(CFLAGS) -S $< -o $@
+tui.o: tui.s
+ @echo " AS mine-sweeper/menu/$@"
+ $(Q)$(AS) $< -o $@
+
+iface.s: $(IFACE_SRC) $(IFACE_INC)
+ @echo " CC mine-sweeper/menu/$@"
+ $(Q)$(CC) $(CFLAGS) -S $< -o $@
+iface.o: iface.s
+ @echo " AS mine-sweeper/menu/$@"
+ $(Q)$(AS) $< -o $@
+
+
+PHONY += clean
+clean:
+ @echo " RM *.o *.s"
+ $(Q)rm -f *.o *.s
+
+################################################################################
+# Declare the contents of the .PHONY variable as phony.
+.PHONY: $(PHONY)
+
+
+################################################################################
+######## End of file ###########################################################
+################################################################################
diff --git a/tmp/player/Makefile b/tmp/player/Makefile
new file mode 100755
index 0000000..b99d03a
--- /dev/null
+++ b/tmp/player/Makefile
@@ -0,0 +1,86 @@
+#! /usr/bin/make -f
+
+################################################################################
+# Copyright (C) 2019 Alejandro Colomar Andrés
+# SPDX-License-Identifier: GPL-2.0-only
+################################################################################
+# *AUTHOR*
+# FULL NAME "Alejandro Colomar Andrés"
+# EMAIL "1903716@gmail.com"
+################################################################################
+
+################################################################################
+# dependencies
+
+OBJ = \
+ clui.o \
+ tui.o \
+ iface.o
+
+CLUI_INC = \
+ $(INC_DIR)/mine-sweeper/player/clui.h \
+ $(INC_DIR)/mine-sweeper/game/iface.h \
+ $(INC_DIR)/mine-sweeper/player/iface.h
+CLUI_SRC = \
+ $(SRC_DIR)/player/clui.c
+
+TUI_INC = \
+ $(INC_DIR)/mine-sweeper/player/tui.h \
+ $(LIBALX_INC_DIR)/libalx/extra/ncurses/common.h \
+ $(LIBALX_INC_DIR)/libalx/extra/ncurses/get.h \
+ $(INC_DIR)/mine-sweeper/game/iface.h \
+ $(INC_DIR)/mine-sweeper/player/iface.h
+TUI_SRC = \
+ $(SRC_DIR)/player/tui.c
+
+IFACE_INC = \
+ $(INC_DIR)/mine-sweeper/player/iface.h \
+ $(INC_DIR)/mine-sweeper/game/iface.h \
+ $(INC_DIR)/mine-sweeper/player/clui.h \
+ $(INC_DIR)/mine-sweeper/player/tui.h
+IFACE_SRC = \
+ $(SRC_DIR)/player/iface.c
+
+################################################################################
+# target: dependencies
+# action
+
+PHONY := all
+all: $(OBJ)
+
+
+clui.s: $(CLUI_SRC) $(CLUI_INC)
+ @echo " CC mine-sweeper/player/$@"
+ $(Q)$(CC) $(CFLAGS) -S $< -o $@
+clui.o: clui.s
+ @echo " AS mine-sweeper/player/$@"
+ $(Q)$(AS) $< -o $@
+
+tui.s: $(TUI_SRC) $(TUI_INC)
+ @echo " CC mine-sweeper/player/$@"
+ $(Q)$(CC) $(CFLAGS) -S $< -o $@
+tui.o: tui.s
+ @echo " AS mine-sweeper/player/$@"
+ $(Q)$(AS) $< -o $@
+
+iface.s: $(IFACE_SRC) $(IFACE_INC)
+ @echo " CC mine-sweeper/player/$@"
+ $(Q)$(CC) $(CFLAGS) -S $< -o $@
+iface.o: iface.s
+ @echo " AS mine-sweeper/player/$@"
+ $(Q)$(AS) $< -o $@
+
+
+PHONY += clean
+clean:
+ @echo " RM *.o *.s"
+ $(Q)rm -f *.o *.s
+
+################################################################################
+# Declare the contents of the .PHONY variable as phony.
+.PHONY: $(PHONY)
+
+
+################################################################################
+######## End of file ###########################################################
+################################################################################
diff --git a/tmp/save/Makefile b/tmp/save/Makefile
new file mode 100755
index 0000000..722172b
--- /dev/null
+++ b/tmp/save/Makefile
@@ -0,0 +1,74 @@
+#! /usr/bin/make -f
+
+################################################################################
+# Copyright (C) 2019 Alejandro Colomar Andrés
+# SPDX-License-Identifier: GPL-2.0-only
+################################################################################
+# *AUTHOR*
+# FULL NAME "Alejandro Colomar Andrés"
+# EMAIL "1903716@gmail.com"
+################################################################################
+
+################################################################################
+# dependencies
+
+OBJ = \
+ save.o \
+ score.o
+
+SAVE_INC = \
+ $(INC_DIR)/mine-sweeper/save/save.h \
+ $(LIBALX_INC_DIR)/libalx/base/errno/perror.h \
+ $(LIBALX_INC_DIR)/libalx/base/stdio/wait.h \
+ $(INC_DIR)/mine-sweeper/game/core.h \
+ $(INC_DIR)/mine-sweeper/player/iface.h
+SAVE_SRC = \
+ $(SRC_DIR)/save/save.c
+
+SCORE_INC = \
+ $(INC_DIR)/mine-sweeper/save/score.h \
+ $(LIBALX_INC_DIR)/libalx/base/errno/perror.h \
+ $(LIBALX_INC_DIR)/libalx/base/stddef/size.h \
+ $(LIBALX_INC_DIR)/libalx/base/stdio/wait.h \
+ $(INC_DIR)/mine-sweeper/game/core.h \
+ $(INC_DIR)/mine-sweeper/game/iface.h \
+ $(INC_DIR)/mine-sweeper/player/iface.h
+SCORE_SRC = \
+ $(SRC_DIR)/save/score.c
+
+################################################################################
+# target: dependencies
+# action
+
+PHONY := all
+all: $(OBJ)
+
+
+save.s: $(SAVE_SRC) $(SAVE_INC)
+ @echo " CC mine-sweeper/save/$@"
+ $(Q)$(CC) $(CFLAGS) -S $< -o $@
+save.o: save.s
+ @echo " AS mine-sweeper/save/$@"
+ $(Q)$(AS) $< -o $@
+
+score.s: $(SCORE_SRC) $(SCORE_INC)
+ @echo " CC mine-sweeper/save/$@"
+ $(Q)$(CC) $(CFLAGS) -S $< -o $@
+score.o: score.s
+ @echo " AS mine-sweeper/save/$@"
+ $(Q)$(AS) $< -o $@
+
+
+PHONY += clean
+clean:
+ @echo " RM *.o *.s"
+ $(Q)rm -f *.o *.s
+
+################################################################################
+# Declare the contents of the .PHONY variable as phony.
+.PHONY: $(PHONY)
+
+
+################################################################################
+######## End of file ###########################################################
+################################################################################
diff --git a/tmp/xyzzy/Makefile b/tmp/xyzzy/Makefile
new file mode 100755
index 0000000..bc0a015
--- /dev/null
+++ b/tmp/xyzzy/Makefile
@@ -0,0 +1,52 @@
+#! /usr/bin/make -f
+
+################################################################################
+# Copyright (C) 2019 Alejandro Colomar Andrés
+# SPDX-License-Identifier: GPL-2.0-only
+################################################################################
+# *AUTHOR*
+# FULL NAME "Alejandro Colomar Andrés"
+# EMAIL "1903716@gmail.com"
+################################################################################
+
+################################################################################
+# dependencies
+
+OBJ = \
+ xyzzy.o
+
+XYZZY_INC = \
+ $(INC_DIR)/mine-sweeper/xyzzy/xyzzy.h \
+ $(INC_DIR)/mine-sweeper/game/iface.h
+XYZZY_SRC = \
+ $(SRC_DIR)/xyzzy/xyzzy.c
+
+################################################################################
+# target: dependencies
+# action
+
+PHONY := all
+all: $(OBJ)
+
+
+xyzzy.s: $(XYZZY_SRC) $(XYZZY_INC)
+ @echo " CC mine-sweeper/xyzzy/$@"
+ $(Q)$(CC) $(CFLAGS) -S $< -o $@
+xyzzy.o: xyzzy.s
+ @echo " AS mine-sweeper/xyzzy/$@"
+ $(Q)$(AS) $< -o $@
+
+
+PHONY += clean
+clean:
+ @echo " RM *.o *.s"
+ $(Q)rm -f *.o *.s
+
+################################################################################
+# Declare the contents of the .PHONY variable as phony.
+.PHONY: $(PHONY)
+
+
+################################################################################
+######## End of file ###########################################################
+################################################################################
diff --git a/var/hiscores/hiscores_beginner.mine b/var/mine-sweeper/hiscores/beginner.mine
index 57b227d..57b227d 100644..100755
--- a/var/hiscores/hiscores_beginner.mine
+++ b/var/mine-sweeper/hiscores/beginner.mine
diff --git a/var/hiscores/hiscores_expert.mine b/var/mine-sweeper/hiscores/expert.mine
index 88ef3bf..88ef3bf 100644..100755
--- a/var/hiscores/hiscores_expert.mine
+++ b/var/mine-sweeper/hiscores/expert.mine
diff --git a/var/hiscores/hiscores_intermediate.mine b/var/mine-sweeper/hiscores/intermediate.mine
index a1fd0ca..a1fd0ca 100644..100755
--- a/var/hiscores/hiscores_intermediate.mine
+++ b/var/mine-sweeper/hiscores/intermediate.mine