ggzdmod.h

Go to the documentation of this file.
00001 /* 
00002  * File: ggzdmod.h
00003  * Author: GGZ Dev Team
00004  * Project: ggzdmod
00005  * Date: 10/14/01
00006  * Desc: GGZ game module functions
00007  * $Id: ggzdmod.h 9062 2007-04-21 03:51:10Z jdorje $
00008  *
00009  * This file contains the main interface for the ggzdmod library.  This
00010  * library facilitates the communication between the GGZ server (ggzd)
00011  * and game servers.  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 #include <ggz_common.h>
00033 
00191 #ifndef __GGZDMOD_H__
00192 #define __GGZDMOD_H__
00193 
00194 #define GGZDMOD_VERSION_MAJOR 0
00195 #define GGZDMOD_VERSION_MINOR 0
00196 #define GGZDMOD_VERSION_MICRO 14
00197 #define GGZDMOD_VERSION_IFACE "6:0:0"
00198 
00199 #ifdef __cplusplus
00200 extern "C" {
00201 #endif
00202 
00226 typedef enum {
00227     GGZDMOD_STATE_CREATED,  
00228     GGZDMOD_STATE_WAITING,  
00229     GGZDMOD_STATE_PLAYING,  
00230     GGZDMOD_STATE_DONE  
00231 } GGZdModState;
00232 
00241 typedef enum {
00246     GGZDMOD_EVENT_STATE,
00247 
00253     GGZDMOD_EVENT_JOIN,
00254 
00260     GGZDMOD_EVENT_LEAVE,
00261 
00274     GGZDMOD_EVENT_SEAT,
00275 
00281     GGZDMOD_EVENT_SPECTATOR_JOIN,
00282 
00286     GGZDMOD_EVENT_SPECTATOR_LEAVE,
00287 
00293     GGZDMOD_EVENT_SPECTATOR_SEAT,
00294 
00299     GGZDMOD_EVENT_PLAYER_DATA,
00300 
00304     GGZDMOD_EVENT_SPECTATOR_DATA,
00305 
00312     GGZDMOD_EVENT_ERROR
00313 
00314     /* GGZDMOD_EVENT_ERROR must be last in the list! */
00315 } GGZdModEvent;
00316 
00322 typedef enum {
00323     GGZDMOD_GGZ,    
00324     GGZDMOD_GAME    
00325 } GGZdModType;
00326 
00333 typedef struct GGZdMod GGZdMod;
00334 
00353 typedef void (*GGZdModHandler) (GGZdMod * mod, GGZdModEvent event,
00354                 const void *data);
00355 
00360 typedef struct {
00361     unsigned int num;   
00362     GGZSeatType type;   
00363     const char *name;   
00364     int fd;         
00365     void *playerdata;   
00366 } GGZSeat;
00367 #define GGZSpectator GGZSeat
00368 
00377 int ggzdmod_is_ggz_mode(void);
00378 
00379 /* 
00380  * Creation functions
00381  */
00382 
00389 GGZdMod *ggzdmod_new(GGZdModType type);
00390 
00396 void ggzdmod_free(GGZdMod * ggzdmod);
00397 
00398 
00399 /* 
00400  * Accessor functions
00401  */
00402 
00409 int ggzdmod_get_fd(GGZdMod * ggzdmod);
00410 
00415 GGZdModType ggzdmod_get_type(GGZdMod * ggzdmod);
00416 
00421 GGZdModState ggzdmod_get_state(GGZdMod * ggzdmod);
00422 
00428 int ggzdmod_get_num_seats(GGZdMod * ggzdmod);
00429 
00435 GGZSeat ggzdmod_get_seat(GGZdMod * ggzdmod, int seat);
00436 
00442 char * ggzdmod_get_bot_class(GGZdMod * ggzdmod, const char * name);
00443 
00456 void ggzdmod_set_playerdata(GGZdMod * ggzdmod, bool is_spectator, int seat_num,
00457                 void *playerdata);
00458 
00467 void * ggzdmod_get_gamedata(GGZdMod * ggzdmod);
00468 
00473 void ggzdmod_set_gamedata(GGZdMod * ggzdmod, void * data);
00474 
00485 int ggzdmod_get_max_num_spectators(GGZdMod *ggzdmod);
00486 
00492 GGZSeat ggzdmod_get_spectator(GGZdMod * ggzdmod, int spectator);
00493 
00506 int ggzdmod_set_handler(GGZdMod * ggzdmod, GGZdModEvent e,
00507             GGZdModHandler func);
00508 
00520 int ggzdmod_count_seats(GGZdMod * ggzdmod, GGZSeatType seat_type);
00521 
00532 int ggzdmod_count_spectators(GGZdMod * ggzdmod);
00533 
00534 
00535 /* 
00536  * Event/Data handling
00537  */
00538 
00550 int ggzdmod_dispatch(GGZdMod * ggzdmod);
00551 
00562 int ggzdmod_loop(GGZdMod * ggzdmod);
00563 
00564 
00565 /* 
00566  * Control functions
00567  */
00568 
00578 int ggzdmod_set_state(GGZdMod * ggzdmod, GGZdModState state);
00579 
00590 int ggzdmod_connect(GGZdMod * ggzdmod);
00591 
00602 int ggzdmod_disconnect(GGZdMod * ggzdmod);
00603 
00604 
00605 /* 
00606  * Logging functions
00607  */
00608 
00617 int ggzdmod_log(GGZdMod * ggzdmod, const char *fmt, ...)
00618         ggz__attribute((format(printf, 2, 3)));
00619         
00620         
00630 void ggzdmod_check(GGZdMod *ggzdmod);
00631 
00632 typedef enum {
00633     GGZ_GAME_WIN,
00634     GGZ_GAME_LOSS,
00635     GGZ_GAME_TIE,
00639     GGZ_GAME_FORFEIT,
00643     GGZ_GAME_NONE
00644 } GGZGameResult;
00645 
00657 void ggzdmod_report_game(GGZdMod *ggzdmod,
00658              int *teams,
00659              GGZGameResult *results, int *scores);
00660 
00671 void ggzdmod_report_savegame(GGZdMod *ggzdmod, const char *savegame);
00672 
00675 void ggzdmod_request_num_seats(GGZdMod * ggzdmod, int num_seats);
00676 
00678 void ggzdmod_request_boot(GGZdMod * ggzdmod, const char *name);
00679 
00681 void ggzdmod_request_bot(GGZdMod * ggzdmod, int seat_num);
00682 
00684 void ggzdmod_request_open(GGZdMod * ggzdmod, int seat_num);
00685 
00686 #ifdef __cplusplus
00687 }
00688 #endif
00689 
00690 #endif /* __GGZDMOD_H__ */

Generated on Fri Nov 30 14:59:07 2007 for GGZdMod by  doxygen 1.5.1