summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorinfo@mode42.com <info@mode42.com>2026-08-09 11:54:17 +0000
committerinfo@mode42.com <info@mode42.com>2026-08-09 11:54:17 +0000
commita989bd16c40e04bba5a5404b0ef0cd22f19d2707 (patch)
tree604a0439c7d8c022cbd483d62bdc2cfc1c8d18f8 /include
parenta72e5ea7558e5172c08d397d6f1e0e0f9273e694 (diff)
now including entertain/chess
Diffstat (limited to 'include')
-rw-r--r--include/hybbx/chess.h106
-rw-r--r--include/hybbx/plugin.h20
-rw-r--r--include/hybbx/service.h10
3 files changed, 30 insertions, 106 deletions
diff --git a/include/hybbx/chess.h b/include/hybbx/chess.h
deleted file mode 100644
index bdfaa7b..0000000
--- a/include/hybbx/chess.h
+++ /dev/null
@@ -1,106 +0,0 @@
-#ifndef HYBBX_CHESS_H
-#define HYBBX_CHESS_H
-
-#include "hybbx/types.h"
-#include "hybbx/limits.h"
-#include "hybbx/storage.h"
-#include "hybbx/service.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define CHESS_BOARD_SIZE 8
-#define CHESS_SQ_MAX 4
-#define CHESS_MOVE_MAX 8
-#define CHESS_SAN_MAX 8
-#define CHESS_GAME_MAX 16 /* array upper bound */
-#define CHESS_SPECTATOR_MAX 32
-#define CHESS_REFRESH_SEC 15
-#define CHESS_DEFAULT_MAX 8 /* default active games if INI omits [chess] */
-
-#define CHESS_EMPTY '.'
-
-typedef enum {
- CHESS_COLOR_NONE = 0,
- CHESS_WHITE,
- CHESS_BLACK
-} chess_color_t;
-
-typedef enum {
- CHESS_RESULT_NONE = 0,
- CHESS_WHITE_WINS,
- CHESS_BLACK_WINS,
- CHESS_DRAW_STALEMATE,
- CHESS_DRAW_AGREEMENT
-} chess_result_t;
-
-typedef struct chess_board {
- char sq[CHESS_BOARD_SIZE][CHESS_BOARD_SIZE];
-} chess_board_t;
-
-typedef struct chess_game {
- int active;
- char white_name[HYBBX_USER_NAME_MAX];
- char black_name[HYBBX_USER_NAME_MAX];
- struct hybbx_session *white_session;
- struct hybbx_session *black_session;
- struct hybbx_session *spectators[CHESS_SPECTATOR_MAX];
- unsigned spectator_count;
- chess_board_t board;
- chess_color_t turn;
- unsigned move_number;
- chess_result_t result;
- char last_move_san[CHESS_SAN_MAX];
- unsigned tick_counter;
- char game_id[8];
-} chess_game_t;
-
-void hybbx_chess_init(void);
-void hybbx_chess_shutdown(void);
-void hybbx_chess_config_apply(const struct hybbx_config *config);
-unsigned hybbx_chess_max_games(void);
-void hybbx_chess_shutdown(void);
-
-chess_game_t *hybbx_chess_create_game(struct hybbx_session *white,
- const char *white_name);
-chess_game_t *hybbx_chess_find_open_game(void);
-chess_game_t *hybbx_chess_find_game_by_id(const char *id);
-chess_game_t *hybbx_chess_get_game(unsigned index);
-int hybbx_chess_join_game(chess_game_t *game,
- struct hybbx_session *black,
- const char *black_name);
-int hybbx_chess_add_spectator(chess_game_t *game,
- struct hybbx_session *spec);
-void hybbx_chess_remove_spectator(chess_game_t *game,
- struct hybbx_session *spec);
-int hybbx_chess_is_player(const chess_game_t *game,
- const struct hybbx_session *session);
-int hybbx_chess_is_spectator(const chess_game_t *game,
- const struct hybbx_session *session);
-chess_color_t hybbx_chess_player_color(const chess_game_t *game,
- const struct hybbx_session *session);
-int hybbx_chess_make_move(chess_game_t *game,
- const char *from, const char *to,
- char promote, char *err, size_t errlen);
-void hybbx_chess_render_board(const chess_board_t *board,
- struct hybbx_session *session,
- const char *label);
-void hybbx_chess_send_board(chess_game_t *game,
- struct hybbx_session *session);
-void hybbx_chess_tick(struct hybbx_service *service);
-void hybbx_chess_resign(chess_game_t *game,
- struct hybbx_session *who);
-void hybbx_chess_offer_draw(chess_game_t *game,
- struct hybbx_session *who);
-
-/* Command handler - called from command.c dispatch */
-hybbx_result_t cmd_chess(struct hybbx_service *service,
- struct hybbx_session *session,
- const struct hybbx_parsed_command *cmd);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* HYBBX_CHESS_H */
diff --git a/include/hybbx/plugin.h b/include/hybbx/plugin.h
index ea72a65..9a51211 100644
--- a/include/hybbx/plugin.h
+++ b/include/hybbx/plugin.h
@@ -9,6 +9,7 @@ extern "C" {
struct hybbx_service;
struct hybbx_session;
+struct hybbx_parsed_command;
/**
* Transport plugin interface (link adapters / host-client bridges).
@@ -19,6 +20,10 @@ struct hybbx_session;
* Core uses TCP/IPv4+IPv6 and HBX internally. Plugins terminate the wire
* to external services (telnet TCP, serial TNC, ARDOP host TCP, …) and
* expose a byte stream to hybbx_session via the write callback.
+ *
+ * Optional extensions (NULL = not used):
+ * tick — called every ~1s from service loop (game clocks, AI, …)
+ * on_command — intercept "/verb" before core dispatch (entertainment, …)
*/
typedef struct hybbx_transport_plugin {
const char *name;
@@ -48,6 +53,21 @@ typedef struct hybbx_transport_plugin {
hybbx_result_t (*write)(struct hybbx_session *session,
const char *data, size_t len);
+ /**
+ * Periodic tick — called every ~1 second from the service loop.
+ * NULL → no periodic work. Used by game clocks, AI timers, etc.
+ */
+ void (*tick)(struct hybbx_service *service);
+
+ /**
+ * Command intercept — called before core command dispatch.
+ * Return HYBBX_OK if handled, HYBBX_ERR_NOT_FOUND to fall through.
+ * NULL → no command handling.
+ */
+ hybbx_result_t (*on_command)(struct hybbx_service *service,
+ struct hybbx_session *session,
+ const struct hybbx_parsed_command *cmd);
+
} hybbx_transport_plugin_t;
/**
diff --git a/include/hybbx/service.h b/include/hybbx/service.h
index 4730b8b..b9aa7fa 100644
--- a/include/hybbx/service.h
+++ b/include/hybbx/service.h
@@ -15,6 +15,8 @@
#include "hybbx/storage.h"
#include "hybbx/texts.h"
+struct hybbx_parsed_command;
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -167,6 +169,14 @@ struct hybbx_session *hybbx_service_find_registered_session(
struct hybbx_circuit_hub;
struct hybbx_circuit_hub *hybbx_service_circuit_hub(hybbx_service_t *service);
+/**
+ * Try plugin on_command interceptors.
+ * Returns HYBBX_OK if a plugin handled the command, HYBBX_ERR_NOT_FOUND otherwise.
+ */
+hybbx_result_t hybbx_service_try_plugin_command(hybbx_service_t *service,
+ struct hybbx_session *session,
+ const struct hybbx_parsed_command *cmd);
+
#ifdef __cplusplus
}
#endif
git clone -b <branch> https://cgit.mode42.com/<repo>.git
git clone -b <branch> git://cgit.mode42.com/<repo>.git

info@mode42.com