ggzmod.h

Go to the documentation of this file.
00001 /* 
00002  * File: ggzmod.h
00003  * Author: GGZ Dev Team
00004  * Project: ggzmod
00005  * Date: 10/14/01
00006  * Desc: GGZ game module functions
00007  * $Id: ggzmod.h 8945 2007-01-16 17:42:57Z josef $
00008  *
00009  * This file contains the main interface for the ggzmod library.  This
00010  * library facilitates the communication between the GGZ core client (ggz)
00011  * and game clients.  This file provides a unified interface that can be
00012  * used at both ends.
00013  *
00014  * Copyright (C) 2001-2002 GGZ Development Team.
00015  *
00016  * This library is free software; you can redistribute it and/or
00017  * modify it under the terms of the GNU Lesser General Public
00018  * License as published by the Free Software Foundation; either
00019  * version 2.1 of the License, or (at your option) any later version.
00020  * 
00021  * This library is distributed in the hope that it will be useful,
00022  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00023  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00024  * Lesser General Public License for more details.
00025  * 
00026  * You should have received a copy of the GNU Lesser General Public
00027  * License along with this library; if not, write to the Free Software
00028  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00029  */
00030 
00031 #include <ggz.h> /* libggz */
00032 
00056 #ifndef __GGZMOD_H__
00057 #define __GGZMOD_H__
00058 
00059 #define GGZMOD_VERSION_MAJOR 0
00060 #define GGZMOD_VERSION_MINOR 0
00061 #define GGZMOD_VERSION_MICRO 14
00062 #define GGZMOD_VERSION_IFACE "5:0:1"
00063 
00064 #include <ggz_common.h>
00065 
00066 #ifdef __cplusplus
00067 extern "C" {
00068 #endif
00069 
00093 typedef enum {
00097     GGZMOD_STATE_CREATED,
00098 
00104     GGZMOD_STATE_CONNECTED,
00105 
00111     GGZMOD_STATE_WAITING,
00112 
00117     GGZMOD_STATE_PLAYING,
00118 
00125     GGZMOD_STATE_DONE
00126 } GGZModState;
00127 
00136 typedef enum {
00141     GGZMOD_EVENT_STATE,
00142 
00148     GGZMOD_EVENT_SERVER,
00149 
00156     GGZMOD_EVENT_PLAYER,
00157 
00163     GGZMOD_EVENT_SEAT,
00164 
00171     GGZMOD_EVENT_SPECTATOR_SEAT,
00172 
00182     GGZMOD_EVENT_CHAT,
00183 
00189     GGZMOD_EVENT_STATS,
00190 
00196     GGZMOD_EVENT_INFO,
00197     
00204     GGZMOD_EVENT_ERROR
00205 } GGZModEvent;
00206 
00212 typedef enum {
00213     GGZMOD_GGZ, 
00214     GGZMOD_GAME 
00215 } GGZModType;
00216 
00221 typedef struct {
00222     unsigned int num;   
00223     GGZSeatType type;   
00224     const char * name;  
00225 } GGZSeat;
00226 
00232 typedef struct {
00233     unsigned int num;   
00234     const char * name;  
00235 } GGZSpectatorSeat;
00236 
00237 typedef struct {
00238     const char *player;
00239     const char *message;    
00240 } GGZChat;
00241 
00242 typedef struct {
00243     unsigned int num;   
00244     const char *realname;   
00245     const char *photo;  
00246     const char *host;   
00247 } GGZPlayerInfo;
00248 
00255 typedef struct GGZMod GGZMod;
00256 
00271 typedef void (*GGZModHandler) (GGZMod * mod, GGZModEvent e, const void *data);
00272 
00282 int ggzmod_is_ggz_mode(void);
00283 
00284 /* 
00285  * Creation functions
00286  */
00287 
00294 GGZMod *ggzmod_new(GGZModType type);
00295 
00301 void ggzmod_free(GGZMod * ggzmod);
00302 
00303 /* 
00304  * Accessor functions
00305  */
00306 
00312 int ggzmod_get_fd(GGZMod * ggzmod);
00313 
00318 GGZModType ggzmod_get_type(GGZMod * ggzmod);
00319 
00324 GGZModState ggzmod_get_state(GGZMod * ggzmod);
00325 
00330 int ggzmod_get_server_fd(GGZMod * ggzmod);
00331 
00337 int ggzmod_get_num_seats(GGZMod *ggzmod);
00338 
00344 GGZSeat ggzmod_get_seat(GGZMod *ggzmod, int seat);
00345 
00355 int ggzmod_get_num_spectator_seats(GGZMod *ggzmod);
00356 
00362 GGZSpectatorSeat ggzmod_get_spectator_seat(GGZMod * ggzmod, int seat);
00363 
00373 const char * ggzmod_get_player(GGZMod *ggzmod,
00374                    int *is_spectator, int *seat_num);
00375 
00384 void * ggzmod_get_gamedata(GGZMod * ggzmod);
00385 
00390 void ggzmod_set_gamedata(GGZMod * ggzmod, void * data);
00391 
00403 void ggzmod_set_handler(GGZMod * ggzmod, GGZModEvent e, GGZModHandler func);
00404 
00405 
00406 /* 
00407  * Event/Data handling
00408  */
00409 
00421 int ggzmod_dispatch(GGZMod * ggzmod);
00422 
00423 /* 
00424  * Control functions
00425  */
00426 
00436 int ggzmod_set_state(GGZMod * ggzmod, GGZModState state);
00437 
00445 int ggzmod_connect(GGZMod * ggzmod);
00446 
00454 int ggzmod_disconnect(GGZMod * ggzmod);
00455 
00456 
00459 void ggzmod_request_stand(GGZMod * ggzmod);
00460 
00464 void ggzmod_request_sit(GGZMod * ggzmod, int seat_num);
00465 
00469 void ggzmod_request_boot(GGZMod * ggzmod, const char *name);
00470 
00474 void ggzmod_request_bot(GGZMod * ggzmod, int seat_num);
00475 
00479 void ggzmod_request_open(GGZMod * ggzmod, int seat_num);
00480 
00485 void ggzmod_request_chat(GGZMod *ggzmod, const char *chat_msg);
00486 
00490 int ggzmod_player_get_record(GGZMod *ggzmod, GGZSeat *seat,
00491                  int *wins, int *losses,
00492                  int *ties, int *forfeits);
00493 
00497 int ggzmod_player_get_rating(GGZMod *ggzmod, GGZSeat *seat, int *rating);
00498 
00502 int ggzmod_player_get_ranking(GGZMod *ggzmod, GGZSeat *seat, int *ranking);
00503 
00507 int ggzmod_player_get_highscore(GGZMod *ggzmod, GGZSeat *seat, int *highscore);
00508 
00512 int ggzmod_spectator_get_record(GGZMod *ggzmod, GGZSpectatorSeat *seat,
00513                 int *wins, int *losses,
00514                 int *ties, int *forfeits);
00515 
00519 int ggzmod_spectator_get_rating(GGZMod *ggzmod, GGZSpectatorSeat *seat, int *rating);
00520 
00524 int ggzmod_spectator_get_ranking(GGZMod *ggzmod, GGZSpectatorSeat *seat, int *ranking);
00525 
00529 int ggzmod_spectator_get_highscore(GGZMod *ggzmod, GGZSpectatorSeat *seat, int *highscore);
00530 
00531 
00541 int ggzmod_player_request_info(GGZMod *ggzmod, int seat_num);
00542 
00548 GGZPlayerInfo* ggzmod_player_get_info(GGZMod *ggzmod, int seat);
00549 
00550 #ifdef __cplusplus
00551 }
00552 #endif
00553 
00554 #endif /* __GGZMOD_H__ */

Generated on Fri Nov 30 14:59:06 2007 for GGZMod by  doxygen 1.5.1