Репозитории ALT
S: | 20030306-alt5.qa2 |
5.1: | 20030306-alt5 |
4.1: | 20030306-alt3 |
4.0: | 20030306-alt2 |
3.0: | 20030306-alt2 |
Группа :: Игры/Аркады
Пакет: xtux
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: xtux-20030306-debian-disable-ggz.patch
Скачать
Скачать
--- xtux-0.2.030306.orig/Makefile
+++ xtux-0.2.030306/Makefile
@@ -17,13 +17,13 @@
MAKE = @make -C
-all: common ggz client server
+all: common client server
clean:
$(MAKE) $(CM_SRC_DIR) clean
$(MAKE) $(SV_SRC_DIR) clean
$(MAKE) $(CL_SRC_DIR) clean
- $(MAKE) $(GZ_SRC_DIR) clean
+ #$(MAKE) $(GZ_SRC_DIR) clean
common:
@echo
--- xtux-0.2.030306.orig/src/client/main.c
+++ xtux-0.2.030306/src/client/main.c
@@ -18,8 +18,6 @@
#include "particle.h"
#include "text_buffer.h"
-#include "ggz_client.h"
-
extern float sin_lookup[DEGREES]; /* from ../common/math.c */
extern float cos_lookup[DEGREES];
extern byte num_entity_types; /* entity.c */
@@ -184,6 +182,9 @@
client.demoname = NULL;
client.mousemode = 0;
client.server_address = NULL;
+#if 0
+ client.ggzmod = NULL;
+#endif
}
@@ -325,21 +326,21 @@
client.demo = DEMO_RECORD;
}
break;
+#if 0
case 'g':
- client.with_ggz = 1;
- ggz_client_init("xtux");
- if( ggz_client_connect() < 0 ) {
- fprintf(stderr,"Only GGZ client must call X-Tux in ggz mode\n");
- ggz_client_quit();
- exit(-1);
- }
+ client.ggzmod = ggzmod_new(GGZMOD_GGZ);
+ //ggz_client_init(client.ggzmod, "xtux");
+ ggzmod_connect(client.ggzmod);
break;
+#endif
case 'h': /* Help (default) */
default:
printf("usage: %s [OPTIONS]\n"
" -p DEMO_NAME Play demo DEMO_NAME\n"
" -r DEMO_NAME Record demo DEMO_NAME\n"
+#if 0
" -g Enable ggz mode\n"
+#endif
" -h Display help (this screen)\n\n"
"This product is FREE SOFTWARE and comes with "
"ABSOLUTELY NO WARRANTY!\n"
--- xtux-0.2.030306.orig/src/client/Makefile
+++ xtux-0.2.030306/src/client/Makefile
@@ -12,7 +12,7 @@
TOPLEVEL_PATH = ../..
COMMON_PATH = $(TOPLEVEL_PATH)/src/common
-GGZ_PATH= $(TOPLEVEL_PATH)/src/ggz/client
+GGZ_PATH= $(TOPLEVEL_PATH)/src/ggz
# Programs used in building process
MAKE = make
@@ -27,13 +27,13 @@
# Paths to header files
X11_INC = -I$(X11_PATH)/include
COMMON_INC = -I$(COMMON_PATH)
-GGZ_INC = -I$(GGZ_PATH)
+GGZ_INC =
# Libraries used in linking
X11LIB = -L$(X11_PATH)/lib -lX11
XPMLIB = -lXpm
MATHLIB = -lm
-GGZLIB = $(GGZ_PATH)/libggz.a
+#GGZLIB = -lggzmod
# Common libraries
XTUXLIB = $(COMMON_PATH)/xtuxlib.a
--- xtux-0.2.030306.orig/src/client/client.h
+++ xtux-0.2.030306/src/client/client.h
@@ -1,3 +1,5 @@
+//#include <ggzmod.h>
+
#define CLIENT
/* versions are in date format, ie "ver0/ver1/ver2" d/m/y */
#define VER0 1
@@ -81,7 +83,7 @@
byte color2;
byte dir; /* 0.255 degrees */
- int with_ggz;
+ //GGZMod * ggzmod;
} client_t;
void game_close(void);
--- xtux-0.2.030306.orig/src/client/cl_net.c
+++ xtux-0.2.030306/src/client/cl_net.c
@@ -25,8 +25,6 @@
#include "cl_netmsg_recv.h"
#include "draw.h"
-#include "ggz_client.h"
-
extern win_t win;
extern client_t client;
@@ -35,13 +33,15 @@
void cl_network_init(void)
{
- if(!client.with_ggz) {
+ //if(!client.ggzmod) {
client.server_address = strdup("localhost");
client.port = DEFAULT_PORT;
+#if 0
} else {
client.server_address = strdup("GGZ host");
client.port = 0;
}
+#endif
}
@@ -69,7 +69,7 @@
addr.sin_family = AF_INET;
addr.sin_port = htons(port);
- if(!client.with_ggz) {
+ //if(!client.ggzmod) {
sock = net_init_socket();
if( (addr.sin_addr.s_addr = inet_addr(sv_name)) == INADDR_NONE ) {
@@ -88,16 +88,18 @@
sock = -1;
return 0;
}
+#if 0
} else {
/* ggz mode */
signal(SIGPIPE, SIG_IGN); /* Ignore Pipe errors */
- if( (sock = ggz_client_get_sock()) < 0 ) {
+ if( (sock = ggzmod_get_fd(client.ggzmod)) < 0 ) {
sock = -1;
return 0;
}
/* avoid perdig effect */
sleep(3);
}
+#endif
}
switch( client.demo ) {
--- xtux-0.2.030306.orig/src/client/menu.c
+++ xtux-0.2.030306/src/client/menu.c
@@ -809,7 +809,7 @@
menu_select_map(XK_VoidSymbol);
break;
case 3: /* Hostname */
- if( !client.with_ggz && ((buf = menu_read_text(x, y, 300, 27, SC_URL)) != NULL) ) {
+ if( /*!client.ggzmod &&*/ ((buf = menu_read_text(x, y, 300, 27, SC_URL)) != NULL) ) {
if( client.server_address )
free(client.server_address);
client.server_address = buf;
@@ -818,7 +818,7 @@
printf("Url = %s\n", client.server_address);
break;
case 4: /* Port */
- if( !client.with_ggz && ((buf = menu_read_text(x, y, 300, 27, SC_NUM)) != NULL) )
+ if( /*!client.ggzmod &&*/ ((buf = menu_read_text(x, y, 300, 27, SC_NUM)) != NULL) )
client.port = atoi(buf);
if( client.debug )
printf("Port = %d\n", client.port);
--- xtux-0.2.030306.orig/src/server/Makefile
+++ xtux-0.2.030306/src/server/Makefile
@@ -22,17 +22,19 @@
# Paths to header files
COMMON_INC = -I$(COMMON_PATH)
-GGZ_INC = -I$(GGZ_PATH)/server -I$(GGZ_PATH)/easysock
+GGZ_INC =
+#GGZ_INC = -I$(GGZ_PATH)/server -I$(GGZ_PATH)/easysock
# Libraries used in linking
MATHLIB = -lm
# Common libraries
XTUXLIB = $(COMMON_PATH)/xtuxlib.a
-GGZLIB = $(GGZ_PATH)/server/libggzd.a $(GGZ_PATH)/easysock/libeasysock.a
+#GGZLIB = -lggzmod
+#GGZLIB = $(GGZ_PATH)/server/libggzd.a $(GGZ_PATH)/easysock/libeasysock.a
# Objects to build
-OBJECTS = main.o sv_net.o sv_netmsg_recv.o sv_netmsg_send.o world.o game.o entity.o weapon.o misc.o sv_map.o ai.o hitscan.o item.o event.o xtuxggz.o
+OBJECTS = main.o sv_net.o sv_netmsg_recv.o sv_netmsg_send.o world.o game.o entity.o weapon.o misc.o sv_map.o ai.o hitscan.o item.o event.o #xtuxggz.o
all: server
--- xtux-0.2.030306.orig/src/server/main.c
+++ xtux-0.2.030306/src/server/main.c
@@ -14,7 +14,7 @@
#include "weapon.h"
#include "game.h"
-#include "xtuxggz.h"
+//#include "xtuxggz.h"
server_t server;
map_t *map = NULL;
@@ -133,11 +133,13 @@
printf("error parsing FPS switch\n");
}
break;
+#if 0
case 'g': /* GGZ mode */
- server.with_ggz = 1;
- if( xtuxggz_init() ==-1)
+ server.ggz = ggzmod_new(GGZMOD_GAME);
+ if( xtuxggz_init(server.ggz) ==-1)
exit(-1);
break;
+#endif
case 'v': /* Print version number */
printf("%s\n", VERSION);
exit(EXIT_SUCCESS);
--- xtux-0.2.030306.orig/src/server/server.h
+++ xtux-0.2.030306/src/server/server.h
@@ -3,6 +3,8 @@
* Created 21 Jan 2000 David Lawrence
*/
+//#include <ggzmod.h>
+
#define SERVER
/* versions are in date format, ie "ver0/ver1/ver2" d/m/y */
#define VER0 1
@@ -19,5 +21,5 @@
int exit_when_empty;
int quit;
msec_t now;
- int with_ggz;
+ //GGZMod *ggz;
} server_t;
--- xtux-0.2.030306.orig/src/server/sv_net.c
+++ xtux-0.2.030306/src/server/sv_net.c
@@ -19,7 +19,7 @@
#include "sv_netmsg_send.h"
#include "event.h"
-#include "xtuxggz.h"
+//#include "xtuxggz.h"
#ifndef INADDR_ANY
#define INADDR_ANY (0x00000000)
@@ -54,9 +54,11 @@
{
struct sockaddr_in addr;
- if( server.with_ggz ) {
+#if 0
+ if( server.ggz ) {
sock = xtuxggz_giveme_sock();
} else {
+#endif
sock = net_init_socket();
memset((char*)&addr, 0, sizeof(addr));
addr.sin_family = AF_INET;
@@ -76,7 +78,9 @@
perror("listen");
return -1;
}
+#if 0
}
+#endif
/* Set server socket to nonblocking */
fcntl(sock, F_SETFL, O_NONBLOCK);
@@ -317,15 +321,19 @@
select(maxfd + 1, &read_fds, 0, 0, &tv);
if( FD_ISSET(sock, &read_fds) ) {
- if( server.with_ggz ) {
+#if 0
+ if( server.ggz ) {
if( xtuxggz_is_sock_set(&newsock) != 1 )
newsock=-1;
else
fprintf(stderr,"-----NEW PLAYER----\n");
} else {
+#endif
addrlen = sizeof(naddr);
newsock = accept(sock,(struct sockaddr *)&naddr,(socklen_t *)&addrlen);
+#if 0
}
+#endif
if( newsock < 0 ) {
perror("accept");
--- xtux-0.2.030306.orig/src/server/sv_netmsg_recv.c
+++ xtux-0.2.030306/src/server/sv_netmsg_recv.c
@@ -14,7 +14,7 @@
#include "event.h"
#include "game.h"
-#include "xtuxggz.h"
+//#include "xtuxggz.h"
extern server_t server;
extern game_t game;
@@ -70,10 +70,10 @@
server.clients++;
cl->status = JOINING;
- if( !server.with_ggz )
+ //if( !server.ggz )
strncpy(cl->name, msg.join.name, NETMSG_STRLEN);
- else
- xtuxggz_find_ggzname(cl->nc->fd, cl->name, NETMSG_STRLEN);
+ //else
+// xtuxggz_find_ggzname(cl->nc->fd, cl->name, NETMSG_STRLEN);
printf("%s attempting to JOIN (%d clients)\n", cl->name, server.clients);
if( msg.join.protocol != NETMSG_PROTOCOL_VERSION ) {
--- xtux-0.2.030306.orig/src/server/xtuxggz.c
+++ xtux-0.2.030306/src/server/xtuxggz.c
@@ -12,68 +12,52 @@
#include <netinet/in.h>
#include <errno.h>
-#include "easysock.h"
-#include "ggz_protocols.h"
-#include "ggz_server.h"
+//#include "easysock.h"
+//#include "ggz_protocols.h"
+#include <ggzmod.h>
static int ggz_sock;
+static GGZMod *ggz;
+static int status = 0;
+static int newfd = 0;
-int game_handle_ggz(int ggz_fd, int* p_fd)
+void ggz_handle(GGZMod *ggz, GGZModEvent op, void *data)
{
- int op, seat, status = -1;
- int i;
-
- if (es_read_int(ggz_fd, &op) < 0)
- return -1;
-
switch (op) {
- case REQ_GAME_LAUNCH:
- if (ggz_game_launch() == 0) {
-
+ case GGZMOD_EVENT_STATE:
+ if (ggzmod_get_state(ggz) == GGZMOD_STATE_PLAYING) {
+#if 0
for (i = 0; i < ggz_seats_num(); i++) {
if( ggz_seats[i].assign == GGZ_SEAT_BOT ) {
/* bots are not present in xtux */
}
}
- } else {
- perror("Error en game launch()");
+#endif
+ status = 0;
}
- status = 0;
break;
-
- case REQ_GAME_JOIN:
- if (ggz_player_join(&seat, p_fd) == 0) {
-/* net_printf(*p_fd,TOKEN_GGZ"\n"); */
- status = 1;
- }
+
+#if 0
+ case GGZMOD_EVENT_TABLE: {
+ GGZSeat *old_seat = (GGZSeat*)data;
+ GGZSeat new_seat = ggzmod_get_seat(ggz, old_seat->num);
+ newfd = new_seat.fd;
+ status = 1;
break;
+ }
- case REQ_GAME_LEAVE:
- if ( (status = ggz_player_leave(&seat, p_fd)) == 0) {
-/* TODO player `p_fd' leaves the game */
- status = 2;
-
- /*
- * if all the ggz players left the game send a
- * GAME_OVER to the ggz server
- * This fixes the `phantom table' effect.
- * TODO: Remove this after version 0.0.5 of ggz
- */
- for (i = 0; i < ggz_seats_num(); i++) {
- if( ggz_seats[i].assign == GGZ_SEAT_PLAYER )
- break;
- }
- if(i==ggz_seats_num() ) {
- if( es_write_int(ggz_sock, REQ_GAME_OVER) < 0)
- fprintf(stderr,"Error sending REQ_GAME_OVER\n");
- }
+ case GGZMOD_EVENT_LEAVE: {
+ GGZSeat *s = (GGZSeat*) data;
+ status = 2;
+ if (ggzmod_count_seats(ggz, GGZ_SEAT_PLAYER) == 0) {
+ /* the game will exit when all human players are gone */
+ ggzmod_set_state(ggz, GGZMOD_STATE_DONE);
+ status = 3;
}
break;
-
- case RSP_GAME_OVER:
- status = 3; /* Signal safe to exit */
- break;
+ }
+#endif
default:
/* Unrecognized opcode */
@@ -81,36 +65,50 @@
break;
}
- return status;
+ return;
}
int xtuxggz_find_ggzname( int fd, char *n, int len )
{
- int i;
+#if 0
+ GGZSeat seat;
+ int i, max;
if(!n)
return -1;
- for (i = 0; i < ggz_seats_num(); i++) {
- if( ggz_seats[i].fd == fd ) {
- if( ggz_seats[i].name ) {
- strncpy(n,ggz_seats[i].name,len);
+ max = ggzmod_get_num_seats(ggz);
+ for (i = 0; i < max; i++) {
+ seat = ggzmod_get_seat(ggz,i);
+ if( seat.fd == fd ) {
+ if( seat.name ) {
+ strncpy(n,seat.name,len);
n[len]=0;
return 0;
} else
return -1;
}
}
+#endif
return -1;
}
-int xtuxggz_init(void)
+int xtuxggz_init(GGZMod *server_ggz)
{
+ ggz = server_ggz;
+
/* Initialize ggz */
- ggz_server_init("xtux");
+ ggzmod_set_handler(ggz, GGZMOD_EVENT_STATE, &ggz_handle);
+#if 0
+ ggzmod_set_handler(ggz, GGZMOD_EVENT_TABLE, &ggz_handle);
+ ggzmod_set_handler(ggz, GGZMOD_EVENT_LEAVE, &ggz_handle);
+#endif
+
+ if (ggzmod_connect(ggz) < 0)
+ return -1;
- if ( (ggz_sock = ggz_server_connect()) < 0) {
- ggz_server_quit();
+ ggz_sock = ggzmod_get_fd(ggz);
+ if (ggz_sock < 0) {
fprintf(stderr,"Only the GGZ server must call Xtux server in GGZ mode!\n");
return -1;
}
@@ -132,13 +130,17 @@
*/
int xtuxggz_is_sock_set(int *newfd)
{
- return (game_handle_ggz(ggz_sock, newfd));
+ status = 0;
+ ggzmod_dispatch(ggz);
+ if(status == 1)
+ *newfd = 1;
+ return status;
}
int xtuxggz_exit()
{
- if(ggz_sock) close(ggz_sock);
- ggz_server_quit();
+ if(ggz_sock >= 0) close(ggz_sock);
+ ggz_sock = -1;
return 0;
}