ggzcore.h(3)
okay bestie, welcome to ggzcore.h(3) โ the GGZCore manual page ๐
this is the interface for the ggzcore library used by GGZ clients, and we're about to go through it together. no cap.
๐ NAME ๐
ggzcore.h โ the interface for the ggzcore library used by GGZ clients. periodt.
โจ SYNOPSIS โจ
first things first, you gotta include these:
#include <stdarg.h>
#include <sys/types.h>
#include <ggz_common.h>
๐ Defines ๐
okay so here's the define section, and it's giving version numbers plus a whole squad of debug tags. let's go one by one, bestie โจ
#define GGZCORE_VERSION_MAJOR 0โ the major version, and it's literally0. humble beginnings.#define GGZCORE_VERSION_MINOR 0โ minor version, also0.#define GGZCORE_VERSION_MICRO 11โ micro version, sitting at11.#define GGZCORE_VERSION_IFACE '7:0:0'โ the interface version string, exactly'7:0:0'.#define GGZCORE_DBG_CONF 'GGZCORE:CONF'โ this is aggz_debugdebugging type for the configuration system. so if you're debugging config stuff, this is the tag.#define GGZCORE_DBG_GAME 'GGZCORE:GAME'โggz_debugdebugging type for game communication.#define GGZCORE_DBG_HOOK 'GGZCORE:HOOK'โggz_debugdebugging type for the hook system.#define GGZCORE_DBG_MODULE 'GGZCORE:MODULE'โggz_debugdebugging type for accessing modules.#define GGZCORE_DBG_NET 'GGZCORE:NET'โggz_debugdebugging type for network interaction.#define GGZCORE_DBG_POLL 'GGZCORE:POLL'โggz_debugdebugging type for debugging while polling.#define GGZCORE_DBG_ROOM 'GGZCORE:ROOM'โggz_debugdebugging type for room events and data.#define GGZCORE_DBG_SERVER 'GGZCORE:SERVER'โggz_debugdebugging type for server events and data.#define GGZCORE_DBG_STATE 'GGZCORE:STATE'โggz_debugdebugging type for state changes.#define GGZCORE_DBG_TABLE 'GGZCORE:TABLE'โggz_debugdebugging type for table data.#define GGZCORE_DBG_XML 'GGZCORE:XML'โggz_debugdebugging type for XML processing.#define ggzcore_server_get_channel(server) (-1)โ deprecated function. do not use. like, not even a little.#define ggzcore_server_create_channel(server) (void)0โ deprecated function. do not use.#define ggzcore_module_launch(m) ((int)(-1))โ this macro exists, and that's the whole vibe.#define ggzcore_game_set_server_fd(game, fd) (void)0โ deprecated function. do not use.
๐ฆ Typedefs ๐ฆ
now the typedefs, and some of these come with their own little descriptions. iconic.
typedef _GGZOptions GGZOptionsโ that's it, that's the typedef.
typedef GGZHookReturn(* GGZHookFunc )(unsigned int id, const void
*event_data, const void *user_data)
โ a function pointer type, bestie. the signature is right there.
typedef void(* GGZDestroyFunc )(void *data)โ this is the GGZ object destroy function type.typedef _GGZServer GGZServerโ a server object containing all information about a connection.typedef _GGZRoom GGZRoomโ contains information about a single room on a server.typedef _GGZPlayer GGZPlayerโ contains information about a single player.typedef _GGZTable GGZTableโ contains information about a single table.typedef _GGZGameType GGZGameTypeโ contains information about a _game type_.typedef _GGZModule GGZModuleโ contains information about a single module. a game module, on the client, is an executable designed to play a game. each game type may have many modules that play it.typedef _GGZGame GGZGameโ contains information about a single game table. this contains information about a table we are present at or are about to launch. it is thus associated with both aGGZTableand aGGZModule.
๐ Enumerations ๐
and finally for part 1, the enums. so many enums. let's get into it ๐
โจ enum GGZOptionFlags โจ
enum GGZOptionFlags { GGZ_OPT_PARSER = 0x0001, GGZ_OPT_MODULES =
0x0002, GGZ_OPT_THREADED_IO = 0x0004, GGZ_OPT_EMBEDDED = 0x0008,
GGZ_OPT_RECONNECT = 0x0010 }
no extra description in the original, so we're just keeping it exact.
๐ enum GGZHookReturn ๐
enum GGZHookReturn { GGZ_HOOK_OK, GGZ_HOOK_REMOVE, GGZ_HOOK_ERROR,
GGZ_HOOK_CRISIS }
๐ฆ enum GGZLoginType ๐ฆ
enum GGZLoginType { GGZ_LOGIN, GGZ_LOGIN_GUEST, GGZ_LOGIN_NEW }
๐ enum GGZServerEvent ๐
enum GGZServerEvent { GGZ_CONNECTED, GGZ_CONNECT_FAIL, GGZ_NEGOTIATED,
GGZ_NEGOTIATE_FAIL, GGZ_LOGGED_IN, GGZ_LOGIN_FAIL, GGZ_MOTD_LOADED,
GGZ_ROOM_LIST, GGZ_TYPE_LIST, GGZ_SERVER_PLAYERS_CHANGED,
GGZ_ENTERED, GGZ_ENTER_FAIL, GGZ_LOGOUT, GGZ_NET_ERROR,
GGZ_PROTOCOL_ERROR, GGZ_CHAT_FAIL, GGZ_STATE_CHANGE,
GGZ_CHANNEL_CONNECTED, GGZ_CHANNEL_READY, GGZ_CHANNEL_FAIL,
GGZ_NUM_SERVER_EVENTS }
๐ธ enum GGZRoomEvent ๐ธ
enum GGZRoomEvent { GGZ_PLAYER_LIST, GGZ_TABLE_LIST, GGZ_CHAT_EVENT,
GGZ_ROOM_ENTER, GGZ_ROOM_LEAVE, GGZ_TABLE_UPDATE,
GGZ_TABLE_LAUNCHED, GGZ_TABLE_LAUNCH_FAIL, GGZ_TABLE_JOINED,
GGZ_TABLE_JOIN_FAIL, GGZ_TABLE_LEFT, GGZ_TABLE_LEAVE_FAIL,
GGZ_PLAYER_LAG, GGZ_PLAYER_STATS, GGZ_PLAYER_COUNT }
โญ enum GGZGameEvent โญ
enum GGZGameEvent { GGZ_GAME_LAUNCHED, GGZ_GAME_LAUNCH_FAIL,
GGZ_GAME_NEGOTIATED, GGZ_GAME_NEGOTIATE_FAIL, GGZ_GAME_PLAYING }
๐ enum GGZStateID ๐
the states a server connection may be in. periodt.
enum GGZStateID { GGZ_STATE_OFFLINE, GGZ_STATE_CONNECTING,
GGZ_STATE_RECONNECTING, GGZ_STATE_ONLINE, GGZ_STATE_LOGGING_IN,
GGZ_STATE_LOGGED_IN, GGZ_STATE_ENTERING_ROOM, GGZ_STATE_IN_ROOM,
GGZ_STATE_BETWEEN_ROOMS, GGZ_STATE_LAUNCHING_TABLE,
GGZ_STATE_JOINING_TABLE, GGZ_STATE_AT_TABLE,
GGZ_STATE_LEAVING_TABLE, GGZ_STATE_LOGGING_OUT }
๐ enum GGZModuleEnvironment ๐
the environment a game frontend expects.
enum GGZModuleEnvironment { GGZ_ENVIRONMENT_PASSIVE,
GGZ_ENVIRONMENT_CONSOLE, GGZ_ENVIRONMENT_FRAMEBUFFER,
GGZ_ENVIRONMENT_XWINDOW, GGZ_ENVIRONMENT_XFULLSCREEN }
โจ Functions โจ
Okay bestie, function time. Every signature, every note, no skips. ๐
int ggzcore_init (GGZOptions options)โ no description in the original, just the signature. Mysterious queen behavior. ๐void ggzcore_reload (void)โ again, no blurb, just the call. She's giving silent but deadly. ๐ฆvoid ggzcore_destroy (void)โ signature only, no extra notes. Periodt. ๐GGZServer * ggzcore_server_new (void)โ create a new server object. New server, who dis? ๐int ggzcore_server_reset (GGZServer *server)โ reset the server object. Fresh start energy. โจint ggzcore_server_add_event_hook (GGZServer *server, const GGZServerEvent event, const GGZHookFunc func)โ register a callback handler for a server event. Hook her up. ๐int ggzcore_server_add_event_hook_full (GGZServer *server, const GGZServerEvent event, const GGZHookFunc func, const void *data)โ register a callback handler for a server event โ the full version, withdatain the signature. ๐int ggzcore_server_remove_event_hook (GGZServer *server, const GGZServerEvent event, const GGZHookFunc func)โ remove a single hook function from an event's hook list</remove>. Bye bestie. ๐ซถint ggzcore_server_remove_event_hook_id (GGZServer *server, const GGZServerEvent event, const unsigned int hook_id)โ remove a hook function with given ID from the event's hook list. ID-based removal, so precise. ๐ฅint ggzcore_server_set_hostinfo (GGZServer *server, const char *host, const unsigned int port, const unsigned int use_tls)โ set host info for connecting to the server. Gotta know where to go. ๐int ggzcore_server_set_logininfo (GGZServer *server, const GGZLoginType type, const char *handle, const char *password, const char *email)โ set login info for logging in to the server. Credentials, but make it cute. ๐int ggzcore_server_log_session (GGZServer *server, const char *filename)โ initiate logging of ggzcore events. Receipts, bestie. ๐งพconst char * ggzcore_server_get_host (const GGZServer *server)โ get the hostname of the server. Where we at? ๐int ggzcore_server_get_port (const GGZServer *server)โ get the port of the server. Number goes brrr. ๐ขGGZLoginType ggzcore_server_get_type (const GGZServer *server)โ get the login type being used for this server. What kind of login is this? ๐const char * ggzcore_server_get_handle (const GGZServer *server)โ get the handle being used for this server. Your name in the chat. ๐const char * ggzcore_server_get_password (const GGZServer *server)โ get the password being used for this server. Shhh, don't tell. ๐int ggzcore_server_get_fd (const GGZServer *server)โ get the socket used for connection with the server. The literal connection. ๐GGZStateID ggzcore_server_get_state (const GGZServer *server)โ get the state of the server connection. State check, vibe check. โจint ggzcore_server_get_tls (const GGZServer *server)โ get the current TLS status of this server. Secure-ish? Let's see. ๐int ggzcore_server_get_num_players (const GGZServer *server)โ get the total number of players on the server. How many besties are online? ๐ฏint ggzcore_server_get_num_rooms (const GGZServer *server)โ return the number of rooms on the server, or -1 on error. Rooms, rooms, rooms. ๐ชGGZRoom * ggzcore_server_get_cur_room (const GGZServer *server)โ return the current room, or NULL if there is none. Where u at? ๐GGZRoom * ggzcore_server_get_nth_room (const GGZServer *server, const unsigned int num)โ return the nth room on the server, or NULL on error. Pick a room, any room. ๐ฒint ggzcore_server_get_num_gametypes (const GGZServer *server)โ return the overall number of game types on the server. How many games we talkin'? ๐ฎGGZGameType * ggzcore_server_get_nth_gametype (const GGZServer *server, const unsigned int num)โ get the nth gametype, or NULL on error. Gametype number n, let's go. ๐น๏ธGGZGame * ggzcore_server_get_cur_game (const GGZServer *server)โ return the player's current game. The game currently being played. ๐พint ggzcore_server_is_online (const GGZServer *server)โ return TRUE iff the server is online (connected?). Are we connected or not? ๐ญint ggzcore_server_is_logged_in (const GGZServer *server)โ return TRUE iff we are logged into the server. Logged in? Check. โint ggzcore_server_is_in_room (const GGZServer *server)โ return TRUE iff we are in a room on the server. Room status: maybe. ๐ชint ggzcore_server_is_at_table (const GGZServer *server)โ return TRUE iff we are at a table on the server. Table check, bestie. ๐ชint ggzcore_server_connect (GGZServer *server)โ connect to the server. Let's link up. ๐int ggzcore_server_login (GGZServer *server)โ log in to the server. Enter the chat. ๐ฌint ggzcore_server_motd (GGZServer *server)โ request the MOTD from the server. Message of the day, iconic. ๐ขint ggzcore_server_list_rooms (GGZServer *server, const int type, const char verbose)โ request room list. Show me the rooms. ๐int ggzcore_server_list_gametypes (GGZServer *server, const char verbose)โ request game type list. Show me the game types. ๐ฏint ggzcore_server_join_room (GGZServer *server, const unsigned int room)โ join a room on the server. Slide into that room. ๐int ggzcore_server_logout (GGZServer *server)โ log out of a server. Leaving the chat. ๐int ggzcore_server_disconnect (GGZServer *server)โ disconnect from a server after having logged out. Bye for real. ๐int ggzcore_server_data_is_pending (GGZServer *server)โ check for data pending from the server socket. Any tea incoming? ๐ตint ggzcore_server_read_data (GGZServer *server, int fd)โ read data for the server on the specified FD. Read the room, literally. ๐void ggzcore_server_free (GGZServer *server)โ free GGZServer object and accompanying data. Cleanup era. ๐งนGGZRoom * ggzcore_room_new (void)โ allocate space for a new room object. New room, new me. ๐ฆint ggzcore_room_init (GGZRoom *room, GGZServer *server, const unsigned int id, const char *name, const unsigned int game, const char *desc)โ initialize room object. Set her up. ๐void ggzcore_room_free (GGZRoom *room)โ de-allocate room object and its children. Free the room and the little rooms too. ๐งGGZServer * ggzcore_room_get_server (GGZRoom *room)โ return the server for this room (or NULL on error). Which server owns this room? ๐int ggzcore_room_get_id (const GGZRoom *room)โ return the ID number of the room (or negative on error). Room ID, no cap. ๐ขchar * ggzcore_room_get_name (GGZRoom *room)โ return the name of the room (or NULL on error). What's this room called? ๐ท๏ธchar * ggzcore_room_get_desc (GGZRoom *room)โ return the description of the room (or NULL on error). The room's whole vibe. ๐GGZGameType * ggzcore_room_get_gametype (GGZRoom *room)โ return the type of game played in this room (or NULL on error). What game we playin'? ๐ฎint ggzcore_room_get_num_players (GGZRoom *room)โ return the number of players in the room (or negative on error). How many besties in here? ๐ฏGGZPlayer * ggzcore_room_get_nth_player (GGZRoom *room, const unsigned int num)โ return the nth player in the room (or NULL on error). Player number n, step up. ๐int ggzcore_room_get_num_tables (GGZRoom *room)โ return the number of tables in the room (or negative on error). Count the tables. ๐ชGGZTable * ggzcore_room_get_nth_table (GGZRoom *room, const unsigned int num)โ return the nth table in the room (or NULL on error). Table n, let's go. ๐ฝ๏ธGGZTable * ggzcore_room_get_table_by_id (GGZRoom *room, const unsigned int id)โ return the table in this room with matching ID (NULL on error). Find that table by ID. ๐int ggzcore_room_add_event_hook (GGZRoom *room, const GGZRoomEvent event, const GGZHookFunc func)โ register a handler (hook) for the room event. Hook it up. ๐ชint ggzcore_room_add_event_hook_full (GGZRoom *room, const GGZRoomEvent event, const GGZHookFunc func, const void *data)โ register a handler (hook) for thee room event, with data โ yes, "thee" is in the original, typo stays, iconic. ๐int ggzcore_room_remove_event_hook (GGZRoom *room, const GGZRoomEvent event, const GGZHookFunc func)โ remove a hook from an event. Unhook, periodt. โ๏ธint ggzcore_room_remove_event_hook_id (GGZRoom *room, const GGZRoomEvent event, const unsigned int hook_id)โ remove a hook from an event, by ID. Bye by ID. ๐int ggzcore_room_list_players (GGZRoom *room)โ call to request a list of players in the room. Who's in the room? ๐int ggzcore_room_list_tables (GGZRoom *room, const int type, const char global)โ call to request a list of tables in the room. Show me the tables. ๐ชint ggzcore_room_chat (GGZRoom *room, const GGZChatType opcode, const char *player, const char *msg)โ chat! The whole point, bestie. ๐ฌint ggzcore_room_launch_table (GGZRoom *room, GGZTable *table)โ launch a table in the room. Start that table. ๐int ggzcore_room_join_table (GGZRoom *room, const unsigned int table_id, int spectator)โ join a table in the room, so that you can then play at it. Pull up to the table. ๐ชint ggzcore_room_leave_table (GGZRoom *room, int force)โ leave the table you are currently playing at. Exit the table. ๐ชchar * ggzcore_player_get_name (const GGZPlayer *player)โ return the name of the player. Who's that? ๐ท๏ธGGZPlayerType ggzcore_player_get_type (const GGZPlayer *player)โ return the type of the player (admin/registered/guest). Admin, registered, or guest? ๐GGZRoom * ggzcore_player_get_room (const GGZPlayer *player)โ return the player's room, or NULL if none. Which room they in? ๐ชGGZTable * ggzcore_player_get_table (const GGZPlayer *player)โ return the player's table, or NULL if none. Which table they at? ๐ชint ggzcore_player_get_lag (const GGZPlayer *player)โ return the player's lag class (1..5). Lag class 1 through 5, fr fr. ๐ขint ggzcore_player_get_record (const GGZPlayer *player, int *wins, int *losses, int *ties, int *forfeits)โ get the player's win-loss record. Wins, losses, ties, forfeits โ the receipts. ๐int ggzcore_player_get_rating (const GGZPlayer *player, int *rating)โ get the player's rating. Rating check. โญint ggzcore_player_get_ranking (const GGZPlayer *player, int *ranking)โ get the player's ranking. Ranking check. ๐int ggzcore_player_get_highscore (const GGZPlayer *player, int *highscore)โ get the player's highscore. High score, main character energy. ๐GGZTable * ggzcore_table_new (void)โ create a new table object. New table, who dis? ๐ชint ggzcore_table_init (GGZTable *table, const GGZGameType *gametype, const char *desc, const unsigned int num_seats)โ set data on a table object. Table setup era. ๐void ggzcore_table_free (GGZTable *table)โ free the table object. Clean up the table. ๐งนint ggzcore_table_set_seat (GGZTable *table, const unsigned int seat, GGZSeatType type, const char *name)โ set a seat type at a table, pre-launch. Pre-launch seat assignment. ๐ชint ggzcore_table_remove_player (GGZTable *table, char *name)โ find and remove the player from the table. Find 'em and remove 'em. ๐int ggzcore_table_get_id (const GGZTable *table)โ return the ID of the table. Table ID, no cap. ๐ขconst GGZRoom * ggzcore_table_get_room (const GGZTable *table)โ return the room this table is in. Which room owns this table? ๐const GGZGameType * ggzcore_table_get_type (const GGZTable *table)โ return the game type of the table. What game is this table for? ๐ฎconst char * ggzcore_table_get_desc (const GGZTable *table)โ return the table's description (or NULL). Table desc, maybe NULL. ๐GGZTableState ggzcore_table_get_state (const GGZTable *table)โ return the state of the table. State of the table. โจint ggzcore_table_get_num_seats (const GGZTable *table)โ return the number of seats at the table. How many seats? ๐ชint ggzcore_table_set_desc (GGZTable *table, const char *desc)โ set the table description. Set the vibe. ๐int ggzcore_table_get_seat_count (const GGZTable *table, GGZSeatType type)โ count the seats of the given type. Count seats by type. ๐ขconst char * ggzcore_table_get_nth_player_name (const GGZTable *table, const unsigned int num)โ return the name of a player at the table, or NULL on error. Player n name check. ๐ท๏ธint ggzcore_table_get_num_spectator_seats (const GGZTable *table)โ return the number of spectator seats at the table, or -1. Spectator seat count, or -1. ๐const char * ggzcore_table_get_nth_spectator_name (const GGZTable *table, const unsigned int num)โ return the name of the nth spectator, or NULL if seat is empty. Spectator n, maybe empty. ๐ปGGZSeatType ggzcore_table_get_nth_player_type (const GGZTable *table, const unsigned int num)โ return the type of a player at the table, or GGZ_PLAYER_NONE on error. Player n type, orGGZ_PLAYER_NONE. ๐unsigned int ggzcore_gametype_get_id (const GGZGameType *type)โ bestie, this gets the ID of this gametype. ๐const char * ggzcore_gametype_get_name (const GGZGameType *type)โ returns the name of the game type. โจconst char * ggzcore_gametype_get_prot_engine (const GGZGameType *type)โ gets the protocol 'engine' used by the game type. ๐const char * ggzcore_gametype_get_prot_version (const GGZGameType *type)โ gets the version of the protocol the game uses. ๐ฆconst char * ggzcore_gametype_get_version (const GGZGameType *type)โ gets the version of the game itself. ๐ธconst char * ggzcore_gametype_get_author (const GGZGameType *type)โ gets the author of the game. ๐const char * ggzcore_gametype_get_url (const GGZGameType *type)โ gets a URL for more info about the game. ๐const char * ggzcore_gametype_get_desc (const GGZGameType *type)โ gets a description of the game. ๐int ggzcore_gametype_get_max_players (const GGZGameType *type)โ gets the maximum number of players the game can support. ๐ฏint ggzcore_gametype_get_max_bots (const GGZGameType *type)โ gets the maximum number of bots the game can support. ๐คint ggzcore_gametype_get_spectators_allowed (const GGZGameType *type)โ returns TRUE iff spectators are allowed for this game type. ๐int ggzcore_gametype_num_players_is_valid (const GGZGameType *type, unsigned int num)โ returns TRUE iff the given number of players is valid. โint ggzcore_gametype_num_bots_is_valid (const GGZGameType *type, unsigned int num)โ returns TRUE iff the given number of bots is valid. ๐คโint ggzcore_conf_initialize (const char *g_path, const char *u_path)โ no description, just the signature. ๐int ggzcore_conf_write_string (const char *section, const char *key, const char *value)โ no description, just the signature. ๐int ggzcore_conf_write_int (const char *section, const char *key, int value)โ no description, just the signature. ๐int ggzcore_conf_write_list (const char *section, const char *key, int argc, char **argv)โ no description, just the signature. ๐char * ggzcore_conf_read_string (const char *section, const char *key, const char *def)โ no description, just the signature. ๐int ggzcore_conf_read_int (const char *section, const char *key, int def)โ no description, just the signature. ๐int ggzcore_conf_read_list (const char *section, const char *key, int *argcp, char ***argvp)โ no description, just the signature. ๐int ggzcore_conf_remove_section (const char *section)โ no description, just the signature. ๐int ggzcore_conf_remove_key (const char *section, const char *key)โ no description, just the signature. ๐int ggzcore_conf_commit (void)โ no description, just the signature. ๐unsigned int ggzcore_module_get_num (void)โ this returns the number of registered modules. ๐int ggzcore_module_add (const char *name, const char *version, const char *prot_engine, const char *prot_version, const char *author, const char *frontend, const char *url, const char *exe_path, const char *icon_path, const char *help_path, GGZModuleEnvironment environment)โ no description, just the signature. ๐int ggzcore_module_get_num_by_type (const char *game, const char *engine, const char *version)โ returns how many modules support this game and protocol. ๐ขGGZModule * ggzcore_module_get_nth_by_type (const char *game, const char *engine, const char *version, const unsigned int num)โ returns n-th module that supports this game and protocol. ๐ฏconst char * ggzcore_module_get_name (GGZModule *module)โ return the name of the module. ๐ท๏ธconst char * ggzcore_module_get_version (GGZModule *module)โ return the (game?) version of the module. ๐ฎconst char * ggzcore_module_get_prot_engine (GGZModule *module)โ return the name of the module's protocol engine. โ๏ธconst char * ggzcore_module_get_prot_version (GGZModule *module)โ return the version of the module's protocol engine. ๐ขconst char * ggzcore_module_get_author (GGZModule *module)โ return the author of the module. โ๏ธconst char * ggzcore_module_get_frontend (GGZModule *module)โ return the module's frontend type. ๐ฅ๏ธconst char * ggzcore_module_get_url (GGZModule *module)โ return the URL associated with the module. ๐const char * ggzcore_module_get_icon_path (GGZModule *module)โ no description, just the signature. ๐const char * ggzcore_module_get_help_path (GGZModule *module)โ return the help path of the module (?). โchar ** ggzcore_module_get_argv (GGZModule *module)โ return the executable arguments for the module. Seeexec(). ๐GGZModuleEnvironment ggzcore_module_get_environment (GGZModule *module)โ return the preferred environment type. ๐GGZGame * ggzcore_game_new (void)โ make a new game object. ๐ฒint ggzcore_game_init (GGZGame *game, GGZServer *server, GGZModule *module)โ initialize the game object. ๐void ggzcore_game_free (GGZGame *game)โ free the game object. ๐๏ธint ggzcore_game_add_event_hook (GGZGame *game, const GGZGameEvent event, const GGZHookFunc func)โ register a hook for a game event. ๐ชint ggzcore_game_add_event_hook_full (GGZGame *game, const GGZGameEvent event, const GGZHookFunc func, const void *data)โ register a hook for a game event. ๐ชint ggzcore_game_remove_event_hook (GGZGame *game, const GGZGameEvent event, const GGZHookFunc func)โ remove a hook from a game event. โ๏ธint ggzcore_game_remove_event_hook_id (GGZGame *game, const GGZGameEvent event, const unsigned int hook_id)โ remove a specified hook from a game event. โ๏ธint ggzcore_game_get_control_fd (GGZGame *game)โ return the control (ggzmod) socket for the game. ๐GGZModule * ggzcore_game_get_module (GGZGame *game)โ return the module set for the game. ๐ฆint ggzcore_game_launch (GGZGame *game)โ launch thee game! ๐ (yes, "thee", we keep it exactly)int ggzcore_game_read_data (GGZGame *game)โ read data from the game. When data is pending on the control socket, call this function. ๐
๐ Detailed Description ๐
The interface for the ggzcore library used by GGZ clients. (That's literally it, bestie. It's the main character. ๐)
โจ Define Documentation โจ
#define ggzcore_module_launch(m) ((int)(-1))
This attempts to launch the specified module and returns 0 if successful or -1 on error. (So if you see -1, it's not slaying. ๐ญ)
๐ Typedef Documentation ๐
typedef void(* GGZDestroyFunc)(void *data)
GGZ object destroy function type.
Todo: This is not currently used. ๐
typedef struct _GGZGameType GGZGameType
Contains information about a _game type_.
Note: Each room has one game type; a game may be used in multiple rooms. ๐
typedef GGZHookReturn(* GGZHookFunc)(unsigned int id, const void *event_data, const void *user_data)
GGZ Event hook function type, used as a vallback for events. (Yes, "vallback" โ iconic typo, we keep it. ๐ )
typedef struct _GGZOptions GGZOptions
Options structure for ggzcore library. โ๏ธ
๐ Enumeration Type Documentation ๐
enum GGZGameEvent
A GGZGameEvent is an event associated with the game, that is triggered by a communication from the server or from the game. When a game event occurs, the associated event handle will be called, and will be passed the event data (a void*) along with the (optional) user data. All game events apply to the current game. Game events are usually triggered by calling ggzcore_server_read_data or ggzcore_game_read_data. ๐ก
See also:
ggzcore_game_add_event_hookggzcore_server_read_data
Enumeration values:
GGZ_GAME_LAUNCHED
A game was launched by the player (you). After this the core client should call ggzcore_game_get_control_fd, monitor the socket that function returns, and call ggzcore_game_read_data when there is data pending. This event is triggered inside of ggzcore_game_launch. ๐
Parameters:
dataNULL
See also:
ggzcore_game_launch
GGZ_GAME_LAUNCH_FAIL
Your game launch has failed. Triggered instead of GGZ_GAME_LAUNCHED when there's a failure somewhere. ๐ญ
Parameters:
dataNULL
See also:
GGZ_GAME_LAUNCHED
GGZ_GAME_NEGOTIATED
Negotiation with server was successful. This should happen some time after the launch succeeds. The core client need do nothing at this point. ๐ค
Parameters:
dataNULL
GGZ_GAME_NEGOTIATE_FAIL
Negotiation was not successful, game launch failed.
Todo: Currently this can't actually happen... ๐
GGZ_GAME_PLAYING
Game reached the 'playing' state. When this happens the core client should call ggzcore_room_launch_table or ggzcore_room_join_table to finalize the game join. ๐ฎ
Parameters:
dataNULL
enum GGZHookReturn
GGZ Hook function return types. ๐ช
Enumeration values:
GGZ_HOOK_OK
Success! ๐
GGZ_HOOK_REMOVE
Remove this hook immediately. โ๏ธ
GGZ_HOOK_ERROR
A localized error. โ ๏ธ
GGZ_HOOK_CRISIS
A major error; stop processing the event. ๐
enum GGZLoginType
This controls the type of login a user chooses. A different value will require different information to be sent to the server. ๐
Enumeration values:
GGZ_LOGIN
Standard login; uname and correct passwd needed. ๐
GGZ_LOGIN_GUEST
Guest login; only a uname is required. ๐ค
GGZ_LOGIN_NEW
New user login; only a uname is required. Password will be assigned by the server (but can be passed along). ๐
enum GGZModuleEnvironment
The environment a game frontend expects. ๐
Core clients should offer those game modules which fit their own environment. ๐ฅ๏ธ
Enumeration values:
GGZ_ENVIRONMENT_PASSIVE
No GUI, no interaction with user. ๐ค
GGZ_ENVIRONMENT_CONSOLE
Text console. ๐
GGZ_ENVIRONMENT_FRAMEBUFFER
VESA or framebuffer. ๐ผ๏ธ
GGZ_ENVIRONMENT_XWINDOW
X11 windowed mode (default). ๐ช
GGZ_ENVIRONMENT_XFULLSCREEN
X11 fullscreen mode. ๐ฅ๏ธ
enum GGZOptionFlags
Enumeration values:
GGZ_OPT_MODULES
Load the default configuration file (unused). ๐
GGZ_OPT_THREADED_IO
Load the game module list. ๐งต
GGZ_OPT_EMBEDDED
Provide multi-threaded network IO (unused). ๐
GGZ_OPT_RECONNECT
Reconnect automatically after connection loss. ๐
enum GGZRoomEvent
A GGZRoomEvent is an event associated with the room, that is triggered by a communication from the server. When a room event occurs, the associated event handler will be called, and will be passed the event data (a void*), along with the (optional) user data. All room events apply to the current room unless a room number is given. Room events are almost always triggered by calling ggzcore_server_read_data. ๐
See also:
ggzcore_room_add_event_hookggzcore_server_read_data
Enumeration values:
GGZ_PLAYER_LIST
The list of players in a room has arrived. ๐
Parameters:
dataThe room id (int *)
Note: This will only be issued for the current room. ๐ช
See also:
ggzcore_room_list_players
GGZ_TABLE_LIST
Received the list of active tables. ๐ช
Parameters:
dataNULL
See also:
ggzcore_room_list_tables
GGZ_CHAT_EVENT
Received a chat message of any kind. This can happen at any time when you're in a room. ๐ฌ
โฆfinishing up the event we were mid-way through last time, bestie: ๐
- Parameters:
dataโ theGGZChatEventDataassociated with the chat. - See also:
GGZChatEventData
GGZ_ROOM_ENTER
A player has entered the room with you. New bestie just walked in ๐ซถ
- Parameters:
dataโ aGGZRoomChangeEventDatastructure.
GGZ_ROOM_LEAVE
A player has left your room. the vibes shifted ๐
- Parameters:
dataโ aGGZRoomChangeEventDatastructure.
GGZ_TABLE_UPDATE
One of the tables in the current room has changed. somewhere. somehow. ๐
Todo: how are you supposed to know which table has changed? (the docs are asking too, bestie, nobody knows ๐ญ)
- Parameters:
dataโNULL
GGZ_TABLE_LAUNCHED
The table you tried to launch has launched! it's giving success โจ
- See also:
ggzcore_room_launch_table - Parameters:
dataโNULL
GGZ_TABLE_LAUNCH_FAIL
The table you tried to launch couldn't be launched. not the launch we ordered ๐
- See also:
GGZ_TABLE_LAUNCHED - Parameters:
dataโ a pointer to aGGZErrorEventData
GGZ_TABLE_JOINED
Your table join attempt has succeeded. ate, no crumbs ๐
- See also:
ggzcore_room_join_table - Parameters:
dataโ the table index (int*) of the table we joined.
GGZ_TABLE_JOIN_FAIL
Joining a table did not succeed. the table said no ๐
- See also:
GGZ_TABLE_JOINED - Parameters:
dataโ a helpful error string.
GGZ_TABLE_LEFT
You have successfully left the table you were at. graceful exit, iconic ๐
- See also:
ggzcore_room_leave_table - Parameters:
dataโ theGGZTableLeaveEventDataassociated with the leave. - See also:
GGZTableLeaveEventData
GGZ_TABLE_LEAVE_FAIL
Your attempt to leave the table has failed. you're stuck there, bestie ๐ญ
- See also:
GGZ_TABLE_LEFT - Parameters:
dataโ a helpful error string.
GGZ_PLAYER_LAG
A player's lag (measure of connection speed) has been updated. the ping is pinging ๐
- See also:
ggzcore_player_get_lag - Parameters:
dataโ the name of the player whose lag has changed.
GGZ_PLAYER_STATS
A player's stats have been updated. numbers went up (or down) ๐
- See also:
GGZ_PLAYER_LIST,ggzcore_player_get_record,ggzcore_player_get_rating,ggzcore_player_get_ranking,ggzcore_player_get_highscore - Parameters:
dataโ the name of the player whose stats have changed.
GGZ_PLAYER_COUNT
The number of players in a room has arrived. math o'clock ๐ข
- Parameters:
dataโ the room id (int *)
enum GGZServerEvent ๐ฐ๏ธ
A GGZServerEvent is an event triggered by a communication from the server. Every single time an event goes down, the associated event handler gets called, and it gets handed the event data (a void*). Most events are generated as a result of ggzcore_server_read_data.
- See also:
ggzcore_server_add_event_hook
Enumeration values:
GGZ_CONNECTED
We have just made a connection to the server. After this point the server's socket should be accessible and should be monitored for data. It happens in direct response to ggzcore_server_connect. Heads up though: most events after this will only happen by calling ggzcore_server_read_data on the server's FD! ๐
- Parameters:
dataโNULL - See also:
ggzcore_server_connect
GGZ_CONNECT_FAIL
Error: we have failed to connect to the server. This is generated in place of GGZ_CONNECTED if the connection could not be made. The server object is otherwise unaffected. the door did not open ๐ญ
- Parameters:
dataโ an error string (created bystrerror) - See also:
ggzcore_server_connect
GGZ_NEGOTIATED
We have negotiated a connection to the server. This will happen automatically once a connection has been established, if the server socket is monitored. mutual understanding achieved ๐ค
Note: this just means we've determined ggzd is at the other end.
- Parameters:
dataโNULL - See also:
ggzcore_server_read_data
GGZ_NEGOTIATE_FAIL
Error: negotiation failure. Could be the wrong version. This will happen in place of a GGZ_NEGOTIATED if the server could not be negotiated with. talks broke down
- Parameters:
dataโ a useless error string. - See also:
ggzcore_server_read_data
GGZ_LOGGED_IN
We have successfully logged in. We can now start doing stuff. This will not happen until the client sends their login information. we're IN ๐
- See also:
ggzcore_server_login - Parameters:
dataโNULL - See also:
ggzcore_server_read_data
GGZ_LOGIN_FAIL
Error: login failure. This will happen in place of GGZ_LOGGED_IN if the login failed. The server object will be otherwise unaffected.
- Parameters:
dataโ a pointer to aGGZErrorEventData. - See also:
GGZErrorEventData,ggzcore_server_read_data
GGZ_MOTD_LOADED
The MOTD has been read from the server and can be displayed. The server will send us the MOTD automatically after login; it can also be requested by ggzcore_server_motd. It is up to the client whether or not to display it. See the online documentation (somewhere?) about the MOTD markup format. ๐
- Parameters:
dataโ pointer to aGGZMotdEventDataincluding the full MOTD text. - See also:
ggzcore_server_motd
Todo: the MOTD cannot be accessed outside of this event โ See also: ggzcore_server_read_data!
GGZ_ROOM_LIST
The room list arrived. ๐ This will only happen after the list is requested by ggzcore_server_list_rooms(). The list may be accessed through ggzcore_server_get_num_rooms() and ggzcore_server_get_nth_room(). Until this event arrives these functions will be useless!
- Parameters:
dataโNULL - See also:
ggzcore_server_read_data
GGZ_TYPE_LIST
The list of game types is available. ๐ฎ This will only happen after the list is requested by ggzcore_server_list_types(). The list may be accessed through ggzcore_server_get_num_gametypes() and ggzcore_server_get_nth_gametype(). Until this event arrives these functions will be useless!
- Parameters:
dataโNULL - See also:
ggzcore_server_read_data
GGZ_SERVER_PLAYERS_CHANGED
The number of players on the server has changed. This event is issued rather frequently every time players enter or leave. people coming and going, all day ๐ช
- Parameters:
dataโNULL - See also:
ggzcore_server_get_num_players,ggzcore_server_read_data
GGZ_ENTERED
We have successfully entered a room. This will be issued to tell us a room join has succeeded, after it has been requested. ๐ชโจ
- Parameters:
dataโNULL - See also:
ggzcore_server_join_room,ggzcore_server_read_data
GGZ_ENTER_FAIL
Error: we have tried to enter a room and failed. This will be issued to tell us a room join has failed. bounced at the door
- Parameters:
dataโ a pointer to aGGZErrorEventData. - See also:
GGZErrorEventData,ggzcore_server_join_room,ggzcore_server_read_data
GGZ_LOGOUT
Logged out of the server. This will happen when the server completes the communication; usually after ggzcore_net_send_logout is called.
- Parameters:
dataโNULL - See also:
ggzcore_server_read_data
GGZ_NET_ERROR
Error: a network (transmission) error occurred. The server will automatically disconnect. the connection said bye without asking ๐ก๐
- Parameters:
dataโ a generally unhelpful error string. - See also:
ggzcore_server_read_data
GGZ_PROTOCOL_ERROR
Error: a communication protocol error occured. This can happen in a variety of situations when the server sends us something we can't handle. The server will be automatically disconnected.
- Parameters:
dataโ a technical error string. - See also:
ggzcore_server_read_data
GGZ_CHAT_FAIL
Error: a chat message could not be sent. This will happen when we try to send a chat and the server rejects it. left on read, but by the server ๐ญ
- Parameters:
dataโ a pointer to aGGZErrorEventData. - See also:
GGZErrorEventData,ggzcore_server_read_data
GGZ_STATE_CHANGE
The internal state of ggzcore has changed. This may happen at any time. plot twist, whenever ๐
- Parameters:
dataโNULL - See also:
GGZStateID,ggzcore_server_get_state
GGZ_CHANNEL_CONNECTED
Status event: a requested direct game connection has been established. To start a game (table), a channel must be created. This event will alert that the channel has been established. The channel's FD should then be monitored for input, which should then be passed back to the server object for handling.
- Parameters:
dataโNULL - Note: this event is deprecated and should not be used. ๐ซ
- See also:
ggzcore_server_get_channel,ggzcore_server_read_data
GGZ_CHANNEL_READY
Game channel is ready for read/write operations. After the channel has been connected, if we continue to monitor the socket eventually it will be negotiated and ready to use. At this point it is ready for the game client to use.
- Parameters:
dataโNULL - Note: this event is deprecated and should not be used. ๐ซ
- See also:
ggzcore_server_read_data
GGZ_CHANNEL_FAIL
Error: failure during setup of direct connection to game server. If the channel could not be prepared, this event will happen instead of GGZ_CHANNEL_READY or GGZ_CHANNEL_CONNECTED event. At this point the channel is no longer useful (I think).
- Parameters:
dataโ an unhelpful error string - Note: this event is deprecated and should not be used. ๐ซ
- See also:
ggzcore_server_read_data
GGZ_NUM_SERVER_EVENTS
Terminator. Do not use. ๐
enum GGZStateID ๐
The states a server connection may be in.
On the client side, a simplistic state machine is used to tell what's going on. A game client should usually consult the current state when determining what actions are possible. vibe check, but for your connection
Enumeration values:
GGZ_STATE_OFFLINE
Not connected (at all). ๐ค
GGZ_STATE_CONNECTING
In the process of connecting. ๐
GGZ_STATE_RECONNECTING
Continuous reconnection attempts. ๐
GGZ_STATE_ONLINE
Connected, but not doing anything. ๐ถ
GGZ_STATE_LOGGING_IN
In the process of logging in. ๐
GGZ_STATE_LOGGED_IN
Online and logged in! ๐
GGZ_STATE_ENTERING_ROOM
Moving into a room. ๐ช
GGZ_STATE_IN_ROOM
Online, logged in, and in a room. ๐
GGZ_STATE_BETWEEN_ROOMS
Moving between rooms. ๐ถ
GGZ_STATE_LAUNCHING_TABLEโ bestie is trying to launch a table rn ๐ฒGGZ_STATE_JOINING_TABLEโ trying to join a table, hold on โจGGZ_STATE_AT_TABLEโ you're online, logged in, in a room, and sitting at a table. main character energy fr ๐GGZ_STATE_LEAVING_TABLEโ waiting to leave a table, like waiting for the group chat to stop typing ๐ญGGZ_STATE_LOGGING_OUTโ currently in the process of logging out, bye bestie ๐ฆ
โจ Function Documentation โจ
int ggzcore_conf_commit (void)
ggzcore_conf_commit() โ commits the core user config file to disk ๐พ
Returns: : int : โ 0 if successful, -1 on error.
int ggzcore_conf_initialize (const char * g_path, const char * u_path)
ggzcore_conf_initialize() โ opens the global and/or user configuration files for the frontend.
Either g_path or u_path can be NULL if the file is not to be used. And the user config file? It will be created if it does not exist. it's giving โจbirthโจ
Returns: : 0 on success, negative on failure.
int ggzcore_conf_read_int (const char * section, const char * key, int def)
ggzcore_conf_read_int() โ read an integer from the configuration file(s) ๐ข
Parameters:
sectionโ section to get value fromkeyโ key value was stored underdefโ default value to return if none is found
Returns: an integer from the configuration file OR the default value.
Note: there is no guaranteed way to find out if the call failed ๐ญ like, it just won't tell you. If you must know, callggzcore_conf_read_stringwith aNULLdefault value and check for theNULLreturn. iykyk.
int ggzcore_conf_read_list (const char * section, const char * key, int * argcp, char *** argvp)
ggzcore_conf_read_list() โ read a list from the configuration file(s) ๐
Parameters:
sectionโ section to get value fromkeyโ key value was stored underargcpโ ptr tointwhich will receive the list entry countargvpโ a pointer to a dynamically allocated array thatggzcore_conf_read_list()will build
Returns: int : 0 if successful, -1 on error.
char* ggzcore_conf_read_string (const char * section, const char * key, const char * def)
ggzcore_conf_read_string() โ read a string from the configuration file(s) ๐
Parameters:
sectionโ section to get value fromkeyโ key value was stored underdefโ default value to return if none is found
Returns: a dynamically allocated string from the configuration file OR a dynamically allocated copy of the default string.
Note: the default may be set toNULL, in which case aNULLwill be returned if the value could not be found in either configuration file. so like, that's your escape hatch ๐ซถ
int ggzcore_conf_remove_key (const char * section, const char * key)
ggzcore_conf_remove_key() โ removes a key entry from the user config file โ๏ธ
Parameters:
sectionโ section to removekeyโ key entry to remove
Returns: int : 0 if success, -1 on error, 1 on soft error (section/key didn't exist).
int ggzcore_conf_remove_section (const char * section)
ggzcore_conf_remove_section() โ removes a section from the user config file ๐๏ธ
Parameters:
sectionโ section to remove
Returns: int : 0 if successful, -1 on error, 1 on soft error (section did not exist).
int ggzcore_conf_write_int (const char * section, const char * key, int value)
ggzcore_conf_write_int() โ write an integer to the user config file ๐๏ธ
Parameters:
sectionโ section to store value inkeyโ key to store value undervalueโ value to store
Returns: int : 0 if successful, -1 on error.
int ggzcore_conf_write_list (const char * section, const char * key, int argc, char ** argv)
ggzcore_conf_write_list() โ write a list to the user config file ๐
Parameters:
sectionโ section to store value inkeyโ key to store value underargcโ count of string arguments in listargvโ array ofNULLterminated strings
Returns: int : 0 if successful, -1 on error.
int ggzcore_conf_write_string (const char * section, const char * key, const char * value)
ggzcore_conf_write_string() โ write a string to the user config file ๐ธ
Parameters:
sectionโ section to store value inkeyโ key to store value undervalueโ value to store
Returns: int : 0 if successful, -1 on error.
void ggzcore_destroy (void)
ggzcore_destroy() โ cleanup function for ggzcore lib. it's the little goodbye at the end of the hangout ๐
int ggzcore_game_add_event_hook (GGZGame * game, const GGZGameEvent event, const GGZHookFunc func)
Register a hook for a game event ๐ช
See also:
ggzcore_server_add_event_hookggzcore_room_add_event_hook
int ggzcore_game_add_event_hook_full (GGZGame * game, const GGZGameEvent event, const GGZHookFunc func, const void * data)
Register a hook for a game event. (the full version, she does more ๐ )
See also:
ggzcore_server_add_event_hook_fullggzcore_room_add_event_hook_full
int ggzcore_game_read_data (GGZGame * game)
Read data from the game. When data is pending on the control socket, call this function. like a little knock at the door ๐
Returns: negative on error.
See also:
ggzcore_game_get_control_fd
int ggzcore_game_remove_event_hook (GGZGame * game, const GGZGameEvent event, const GGZHookFunc func)
Remove a hook from a game event โ๏ธ
See also:
ggzcore_server_remove_event_hookggzcore_room_remove_event_hook
int ggzcore_game_remove_event_hook_id (GGZGame * game, const GGZGameEvent event, const unsigned int hook_id)
Remove a specified hook from a game event. you know exactly which one, no cap ๐ฏ
See also:
ggzcore_server_remove_event_hook_idggzcore_room_remove_event_hook_id
unsigned int ggzcore_gametype_get_id (const GGZGameType * type)
Get the ID of this gametype ๐ท๏ธ
Note: this is not normally useful for a GGZ client to know. like, it's giving internal lore ๐ซฃ
int ggzcore_gametype_get_max_bots (const GGZGameType * type)
Get the maximum number of bots the game can support ๐ค
See also:
ggzcore_gametype_bots_is_valid
int ggzcore_gametype_get_max_players (const GGZGameType * type)
Get the maximum number of players the game can support ๐
See also:
ggzcore_gametype_num_players_is_valid
int ggzcore_init (GGZOptions options)
ggzcore_init() โ initialization function for ggzcore lib ๐
Parameters:
optionsโ options structure
Returns: int : 0 if successful, -1 on failure.
int ggzcore_module_add (const char * name, const char * version, const char * prot_engine, const char * prot_version, const char * author, const char * frontend, const char * url, const char * exe_path, const char * icon_path, const char * help_path, GGZModuleEnvironment environment)
This adds a local module to the list. It returns 0 if successful or -1 on failure. that's it, that's the whole thing ๐
const char* ggzcore_module_get_icon_path (GGZModule * module)
This is (intended to be) an optional xpm file that the module can provide to use for representing the game graphically ๐ผ๏ธ
int ggzcore_player_get_highscore (const GGZPlayer * player, int * highscore)
Get the player's highscore ๐
Returns: TRUE if there is a highscore; FALSE if not or on error.
int ggzcore_player_get_ranking (const GGZPlayer * player, int * ranking)
Get the player's ranking ๐
Returns: TRUE if there is a ranking; FALSE if not or on error.
int ggzcore_player_get_rating (const GGZPlayer * player, int * rating)
Get the player's rating โญ
Returns: TRUE if there is a rating; FALSE if not or on error.
int ggzcore_player_get_record (const GGZPlayer * player, int * wins, int * losses, int * ties, int * forfeits)
Get the player's win-loss record ๐ฅ
Returns: TRUE if there is a record; FALSE if not or on error.
void ggzcore_reload (void)
ggzcore_reload() โ reload game module database ๐
int ggzcore_room_add_event_hook (GGZRoom * room, const GGZRoomEvent event, const GGZHookFunc func)
Register a handler (hook) for the room event ๐ช
A room event will happen when data is received from the server. To make updates to the frontend, the client will need to register a hook function to handle the event. This hook function will be called each time the room event occurs. More than one hook function may be specified, in which case they will all be called (in FIFO order). first come, first served bestie ๐๏ธ
Parameters:
roomโ The room object to associate the hook with.eventโ The event the handler is going to be 'hooked' onto.funcโ The event handler itself. This is called during the event.
Returns: The hook ID, or negative on error.
See also:
ggzcore_room_add_event_hook_fullggzcore_room_remove_event_hookggzcore_room_remove_event_hook_id
int ggzcore_room_add_event_hook_full (GGZRoom * room, const GGZRoomEvent event, const GGZHookFunc func, const void * data)
Register a handler (hook) for thee room event, with data ๐
This function is similar to ggzcore_room_add_event_hook, except that user data will be associated with the hook. This data will be passed back to the function each time it is invoked on this event. it remembers your stuff, so thoughtful ๐ซถ
Parameters:
roomโ The room object to associate the hook with.eventโ The event the handler is going to be 'hooked' onto.funcโ The event handler itself. This is called during the event.dataโ The user data associated with the hook.
Returns: The hook ID, or negative on error.
See also:
ggzcore_room_add_event_hook
int ggzcore_room_chat (GGZRoom * room, const GGZChatType opcode, const char * player, const char * msg)
Chat! ๐ฌ that's it. that's the function.
Parameters:
roomโ Your current room.opcodeโ The chat type.playerโ The name of the target player (only for certain chat types)msgโ The text of the chat message (some chat types don't need it)
Returns: 0 on success, negative on (any) failure.
Note: the chat message should be in UTF-8.
int ggzcore_room_join_table (GGZRoom * room, const unsigned int table_id, int spectator)
Join a table in the room, so that you can then play at it ๐ฎ
Parameters:
roomโ Your current room.table_idโ The table to join.spectatorโTRUEif you wish to spectate,FALSEif you want to play
Returns: 0 on success, negative on (any) failure.
int ggzcore_room_launch_table (GGZRoom * room, GGZTable * table)
Launch a table in the room ๐
When a player wants to launch a new table, this is the function to do it. You must first create the table and set up the number and type of seats. Then call this function to initiate the launch. build it, seat it, launch it โจ
Parameters:
roomโ Your current room.tableโ The table to launch.
Returns: 0 on success, negative on (any) failure.
int ggzcore_room_leave_table (GGZRoom * room, int force)
Leave the table you are currently playing at ๐ช
This function tries to leave your current table.
You should 'force' the leave only if the game client is inoperable, since for some games this will destroy the game server as well. ๐ญ seriously, dramatic consequences, handle with care ๐
Okay bestie we're back and we are still deep in the function list ๐ no thoughts, just handlers. Carrying on exactly where we left off.
So that function from a second ago wraps up like this:
roomโ your current room ๐forceโTRUEto force the leave,FALSEto leave it up toggzd
Returns: 0 on success, negative on (any) failure. Like, any failure. All of them. ๐
int ggzcore_room_list_players (GGZRoom * room)
Call this one to request a list of players in the room ๐ฅ
See also: GGZ_PLAYER_LIST
int ggzcore_room_list_tables (GGZRoom * room, const int type, const char global)
Call it to request a list of tables in the room ๐ชโจ
roomโ your current roomtypeโ currently ignored (???)globalโ currently ignored (???)
yeah bestie the docs literally wrote (???) for both of those. Not me adding mystery, the mystery was already there ๐
See also: GGZ_TABLE_LIST
int ggzcore_room_remove_event_hook (GGZRoom * room, const GGZRoomEvent event, const GGZHookFunc func)
Remove a hook from an event ๐ชโ
It removes a specific hook function from the hook list for the given room event. And here's the tea: if more than one copy of the function exists in the list, the oldest one gets removed. So it's a first-in-first-out situation, periodt.
roomโ the room object to associate the hook with.eventโ the event the handler is to be unhooked from.funcโ the event handler function to remove.
Returns: 0 on success, negative on failure.
See also: ggzcore_room_add_event_hook
int ggzcore_room_remove_event_hook_id (GGZRoom * room, const GGZRoomEvent event, const unsigned int hook_id)
Remove a hook from an event, but make it a by ID situation ๐ฏ
It removes a specific hook from the hook list for the given room. The ID should be the same as the one returned when the hook was added โ so like, keep your receipts bestie ๐งพ
roomโ the room object to associate the hook with.eventโ the event the handler is to be unhooked from.idโ the ID of the hook to remove, as returned by the add functionreturnโ0on success, negative on failure
okay so the original really does list return inside the Parameters list. Iconic. I'm keeping it exactly as written because the facts do not move, only the vibe does ๐ซถ
See also: ggzcore_room_add_event_hook
int ggzcore_server_add_event_hook (GGZServer * server, const GGZServerEvent event, const GGZHookFunc func)
Register a callback handler for a server event ๐โจ
Call this to register the given GGZHookFunc as a handler for the given event. Then any time that event happens, the handler function will be called. It's giving "set it and forget it" but make it networking.
serverโ the GGZ server object.eventโ the server event to be handled.funcโ the handler function to be called when the event occurs.
Returns: a hook ID value to identify this handler ๐
Note: equivalent toggzcore_server_add_event_hook_fullwithdata==NULL. Also, more than one handler can be registered for each event โ the more the merrier, no cap ๐
int ggzcore_server_add_event_hook_full (GGZServer * server, const GGZServerEvent event, const GGZHookFunc func, const void * data)
Register a callback handler for a server event โ the full version, the deluxe edition ๐
See also: ggzcore_server_add_event_hook
dataโ an arbitrary pointer that will be passed to the hook function.
int ggzcore_server_connect (GGZServer * server)
Connect to the server ๐
Call this function to initially connect to a GGZ server. The connection info gets set with the ggzcore_server_set_hostinfo function.
This one is asynchronous and will return very quickly โ like, blink and it's back. After the connection is (hopefully ๐) established, we'll receive either a GGZ_CONNECTED or GGZ_CONNECT_FAIL server event. If the connection succeeds, negotiations with the GGZ server begin automatically. Once that's complete, we get either a GGZ_NEGOTIATED or GGZ_NEGOTIATE_FAIL event.
serverโ the GGZ server object.
Returns: 0 on success, -1 on failure.
Note: on success aGGZ_CONNECTEDevent will be generated. On failure aGGZ_CONNECT_FAILevent may or may not be generated. Yeah bestie, "may or may not", we love a chaotic maybe ๐ญ
int ggzcore_server_get_fd (const GGZServer * server)
Get the socket used for connection with the server ๐๐
This returns the file descriptor of the primary socket for the TCP connection to the server. All GGZ data goes across this socket โ every last byte of it.
serverโ the GGZ server object.
Returns: the file descriptor of the connection socket.
See also: ggzcore_server_connect
const char* ggzcore_server_get_handle (const GGZServer * server)
Get the handle being used for this server ๐ท๏ธ
serverโ the GGZ server object.
Returns: a string containing the handle, or NULL on error.
See also: ggzcore_server_set_logininfo
const char* ggzcore_server_get_host (const GGZServer * server)
Get the hostname of the server ๐
serverโ the GGZ server object.
Returns: a string containing the host name, or NULL on error.
See also: ggzcore_server_set_hostinfo
int ggzcore_server_get_num_gametypes (const GGZServer * server)
Return the overall number of game types on the server ๐ฎ
serverโ the GGZ server object.
Returns: the number of game types on this server, or -1 on error.
Note: this number is 0 until
Okay so that sentence genuinely just stops there in the original. Mid-thought. The audacity ๐ we keep it exactly as it is.
See also: GGZ_TYPE_LIST
int ggzcore_server_get_num_players (const GGZServer * server)
Get the total number of players on the server ๐ฅ๐ฅ
serverโ the GGZ server objectreturnโ an approximate number of players in all rooms of the server.
int ggzcore_server_get_num_rooms (const GGZServer * server)
Return the number of rooms on the server, or -1 on error ๐ช
Note: until we retrieve the list of rooms, this will return 0.
const char* ggzcore_server_get_password (const GGZServer * server)
Get the password being used for this server ๐
serverโ the GGZ server object.
Returns: a string containing the password, or NULL on error.
See also: ggzcore_server_set_logininfo
int ggzcore_server_get_port (const GGZServer * server)
Get the port of the server ๐ข
serverโ the GGZ server object.
Returns: the port number of the server, or -1 on error.
See also: ggzcore_server_set_hostinfo
GGZStateID ggzcore_server_get_state (const GGZServer * server)
Get the state of the server connection ๐
serverโ the GGZ server object.
Returns: the state of the connection, or -1 on error.
int ggzcore_server_get_tls (const GGZServer * server)
Get the current TLS status of this server ๐โจ
serverโ the GGZ server object
Returns: whether TLS is active or not.
GGZLoginType ggzcore_server_get_type (const GGZServer * server)
Get the login type being used for this server ๐
serverโ the GGZ server object.
Returns: the login type set for the server, or -1 on error.
See also: ggzcore_server_set_logininfo
int ggzcore_server_join_room (GGZServer * server, const unsigned int room)
Join a room on the server ๐ช๐
serverโ the GGZ server object.roomโ the number of the room to join.
Returns: 0 on success, -1 on failure (e.g. non-existing room number). So like, don't ask for a room that isn't there bestie ๐ญ
int ggzcore_server_list_gametypes (GGZServer * server, const char verbose)
Request the game type list ๐ฎ๐
serverโ the GGZ server object.verboseโ receive detailed gametype information or not.
Returns: 0 on success, -1 on failure.
Note: a GGZ_TYPE_LIST event will be the asynchronous response on success.
int ggzcore_server_list_rooms (GGZServer * server, const int type, const char verbose)
Request the room list ๐ช๐
serverโ the GGZ server object.typeโ not used yet.verboseโ receive all information about a room or only the essentials.
Returns: 0 on success, -1 on failure.
Note: a GGZ_ROOM_LIST might be generated thereafter. Might. The suspense is real ๐ซ
int ggzcore_server_log_session (GGZServer * server, const char * filename)
Initiate logging of ggzcore events ๐โจ
Normally, ggzcore traffic is not logged anywhere. With this function, such output can be directed into a file. It contains all the network messages received from the server โ the whole receipt ๐งพ
serverโ the GGZ server object.filenameโ the file the messages are written to.
Returns: 0 on success, -1 on error.
int ggzcore_server_login (GGZServer * server)
Log in to the server ๐๐
Call this function to log in to the server once a connection has been established. Typically you must first connect to the server, then wait to receive the GGZ_CONNECTED and GGZ_NEGOTIATED events before attempting to log in. Login info is set using the ggzcore_server_set_logininfo function.
This one is asynchronous too and will return immediately. After the login request is sent, we wait to receive either a GGZ_LOGGED_IN or GGZ_LOGIN_FAIL server event.
serverโ the GGZ server object.
Returns: 0 on success, -1 on failure.
Note: on failure, no events will be generated. Silence. Nothing. Crickets ๐ฆ
GGZServer* ggzcore_server_new (void)
Create a new server object ๐ฑ๐
Call this function to create a server object. This object holds all state data for communicating with a ggz server. It is necessary for any kind of connection โ like, you literally cannot skip this one.
int ggzcore_server_read_data (GGZServer * server, int fd)
Read data for the server on the specified FD ๐ฅ
Returns: negative on error.
int ggzcore_server_remove_event_hook (GGZServer * server, const GGZServerEvent event, const GGZHookFunc func)
Remove a single hook function from an event's hook list ๐ชโ
serverโ the GGZ server object.eventโ the server event the hook is associated with.funcโ the function to be removed from the hook list.
Returns: 0 on success (hook removed); -1 on failure (no hook removed).
Note: at most one copy of the function will be removed.
See also: ggzcore_server_remove_event_hook_id
int ggzcore_server_remove_event_hook_id (GGZServer * server, const GGZServerEvent event, const unsigned int hook_id)
Remove a hook function with the given ID from the event's hook list ๐ฏ๐ช
serverโ the GGZ server object.eventโ the server event the hook is associated with.hook_idโ the ID of the hook event.
Returns: 0 on success (hook removed); -1 on failure (no hook removed).
Note: the hook ID is given by ggzcore_server_add_event_hook
int ggzcore_server_reset (GGZServer * server)
Reset the server object ๐
After you've disconnected, call this function to discard all state data and reset the state of the server object. You can then connect again โ fresh start, clean slate, main character rebirth energy โจ
Note: you should disconnect before resetting.
int ggzcore_server_set_hostinfo (GGZServer * server, const char * host, const unsigned int port, const unsigned int use_tls)
Set host info for connecting to the server ๐๐ง
Call this function to set host info for the GGZ server before trying to connect to it.
okay so here's the tail end of that function's deets, don't scroll past bestie:
serverโ the GGZ server object. yes. that one.hostโ a string containing the hostname.portโ the port to connect to.use_tlsโ if it's set, the connection gets encrypted. ๐
Returns: 0 on success, -1 on error. classic.
Note: should never fail when given valid input. like, it's supposed to be chill. no promises tho.
See also: ggzcore_server_connect
๐ธ int ggzcore_server_set_logininfo (GGZServer * server, const GGZLoginType type, const char * handle, const char * password, const char * email) ๐ธ
Set login info for logging in to the server.
Call this function to set login info for the GGZ server before trying to login. And listen โ this should only be called when the server is in certain states. so like, vibe check the state first, okay? ๐
Parameters:
serverโ the GGZ server object.typeโ the type of login to attempt.handleโ the username to use with the server.passwordโ the password to use (may beNULLwith some login types).emailโ the email address to use (may beNULLwith some login types).
Returns: 0 on success, -1 on error.
๐ฆ int ggzcore_table_get_seat_count (const GGZTable * table, GGZSeatType type) ๐ฆ
Count the seats of the given type.
Give it a table and a seat type, and it hands you back the number of seats at that table matching the type. it's giving census but for chairs ๐
Parameters:
tableโ a GGZ table.typeโ aGGZSeatType.
Returns: the number of seats matching the type, or -1 on error.
๐ int ggzcore_table_init (GGZTable * table, const GGZGameType * gametype, const char * desc, const unsigned int num_seats) ๐
Set data on a table object.
Note: useful when launching a game. ๐
โญ GGZTable* ggzcore_table_new (void) โญ
Create a new table object. fresh table, no cap.
Note: useful when launching a game. (yes again, it's that useful.)
๐ int ggzcore_table_set_seat (GGZTable * table, const unsigned int seat, GGZSeatType type, const char * name) ๐
Set a seat type at a table, pre-launch.
When you're launching a table, call this function to set up a particular seat at the table. It can also be used to fiddle with already existing tables โ but bestie, that would be extremely unwise. like genuinely. don't. ๐
Parameters:
tableโ the table object to change.seatโ the seat number at the table to change.typeโ the type of seat to make it (open,reserved, orbot).nameโ the name of the seat (must be valid for reserved seats).
Returns: 0 on success, -1 on error.
Todo: how do we stop the GGZ client from fiddling with random tables? ๐ญ an open question, iconically unresolved.
๐ AUTHOR ๐
Generated automatically by Doxygen for GGZCore from the source code.
and that's a wrap on ggzcore.h(3) bestie!! ๐ซถ this whole thing is Version 0.0.11, dated 21 May 2005, and it lives in the manual as ggzcore.h(3). go forth and slay, and remember: don't fiddle with random tables. ๐โจ
๐ฆ where this page comes from
- fedora 43: ggz-base-libs-devel 0.99.5-41.fc43 ยท LicenseRef-Callaway-LGPLv2+ AND GPL-2.0-or-later
- fedora 43: ggz-base-libs-devel 0.99.5-41.fc43 ยท LicenseRef-Callaway-LGPLv2+ AND GPL-2.0-or-later
- nixos 26.05: ggz-base-libs 0.99.5
- nixpkgs unstable: ggz-base-libs 0.99.5
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms