summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--config.h9
-rw-r--r--deb_config.h3
-rw-r--r--packaging/deb/control8
-rw-r--r--packaging/deb/r2
-rw-r--r--server.conf2
-rw-r--r--sound/gun_revolver.oggbin7441 -> 9460 bytes
-rw-r--r--sound/gun_tommy.oggbin9460 -> 7441 bytes
-rw-r--r--src/base/arena.c4
-rw-r--r--src/base/gun.c4
-rw-r--r--src/base/server.c143
-rw-r--r--src/base/tux.c2
-rw-r--r--src/base/tux.h1
-rw-r--r--src/net_unix/udp.c3
-rw-r--r--src/net_unix/udp.h1
-rw-r--r--src/screen/screen_browser.c25
-rw-r--r--src/server/serverConfigFile.c20
-rw-r--r--src/widget/widget_select.c8
-rw-r--r--src/widget/widget_select.h1
-rw-r--r--src/widget/widget_textfield.c1
19 files changed, 167 insertions, 70 deletions
diff --git a/config.h b/config.h
index e3a44dc..b1739d2 100644
--- a/config.h
+++ b/config.h
@@ -1,11 +1,4 @@
-/*
-#define DEBUG_SERVER_SEND
-#define DEBUG_SERVER_RECV
-#define DEBUG_CLIENT_SEND
-#define DEBUG_CLIENT_RECV
-*/
-
-#define TUXANCI_NG_VERSION "svn88"
+#define TUXANCI_NG_VERSION "svn89"
#define DESTDIR "/usr/local/"
diff --git a/deb_config.h b/deb_config.h
index f8448fe..5bc118e 100644
--- a/deb_config.h
+++ b/deb_config.h
@@ -1,4 +1,3 @@
-#define TUXANCI_NG_VERSION "svn50"
+#define TUXANCI_NG_VERSION "svn68"
#define DESTDIR "/usr/"
-#define SUPPORT_NET_SDL_UDP
diff --git a/packaging/deb/control b/packaging/deb/control
index 7d3dee8..8d7ddd0 100644
--- a/packaging/deb/control
+++ b/packaging/deb/control
@@ -1,12 +1,12 @@
Package: tuxanci-ng
-Version: svn50
+Version: svn68
Section: Game
Priority: optional
-Depends: libc6 (>= 2.2.4-4), libsdl1.2debian (>= 1.2), libsdl-image1.2 (>= 1.2), libsdl-mixer1.2 (>= 1.2), libsdl-net1.2 (>= 1.2), libsdl-ttf2.0-0 (>= 2.0)
+Depends: libc6 (>= 2.2.4-4), libsdl1.2debian (>= 1.2), libsdl-image1.2 (>= 1.2), libsdl-mixer1.2 (>= 1.2), libsdl-ttf2.0-0 (>= 2.0)
Architecture: i386
Installed-Size: 4630
Maintainer: Dušan Ďurech <dusan.d@centrum.sk>
-Description: Game tuxanci next generation SVN revision 50
- Game tuxanci next generation SVN revision 50
+Description: Game tuxanci next generation SVN revision 68
+ Game tuxanci next generation SVN revision 68
.
http://www.tuxanci.org
diff --git a/packaging/deb/r b/packaging/deb/r
index a80efbc..3817d24 100644
--- a/packaging/deb/r
+++ b/packaging/deb/r
@@ -1,2 +1,2 @@
-50
+68
diff --git a/server.conf b/server.conf
index 25c26fa..26271b5 100644
--- a/server.conf
+++ b/server.conf
@@ -1,4 +1,4 @@
-NAME oroborus-gameserver
+NAME oroborus gameserver
IP4 0.0.0.0
IP6 ::1
PORTv4 2200
diff --git a/sound/gun_revolver.ogg b/sound/gun_revolver.ogg
index 79dcefd..3c2ea41 100644
--- a/sound/gun_revolver.ogg
+++ b/sound/gun_revolver.ogg
Binary files differ
diff --git a/sound/gun_tommy.ogg b/sound/gun_tommy.ogg
index 3c2ea41..79dcefd 100644
--- a/sound/gun_tommy.ogg
+++ b/sound/gun_tommy.ogg
Binary files differ
diff --git a/src/base/arena.c b/src/base/arena.c
index 448ee5b..bd471a2 100644
--- a/src/base/arena.c
+++ b/src/base/arena.c
@@ -150,10 +150,10 @@ void drawArena(arena_t *arena)
getCenterScreen(&screen_x, &screen_y, tux->x, tux->y);
for( i = screen_y/arena->background->h ;
- i <= screen_y/arena->background->h + WINDOW_SIZE_Y/arena->background->h ; i++ )
+ i <= screen_y/arena->background->h + WINDOW_SIZE_Y/arena->background->h+1 ; i++ )
{
for( j = screen_x/arena->background->w ;
- j <= screen_x/arena->background->w + WINDOW_SIZE_X/arena->background->w ; j++ )
+ j <= screen_x/arena->background->w + WINDOW_SIZE_X/arena->background->w+1 ; j++ )
{
addLayer(arena->background,
j * arena->background->w,
diff --git a/src/base/gun.c b/src/base/gun.c
index 3cd6122..0a7e1a1 100644
--- a/src/base/gun.c
+++ b/src/base/gun.c
@@ -13,9 +13,11 @@
#include "base/proto.h"
#include "base/net_multiplayer.h"
-#ifndef PUBLIC_SERVER
+#ifndef NO_SOUND
#include "audio/sound.h"
+#endif
+#ifndef PUBLIC_SERVER
#include "client/interface.h"
#include "client/term.h"
diff --git a/src/base/server.c b/src/base/server.c
index e91e85c..fba543c 100644
--- a/src/base/server.c
+++ b/src/base/server.c
@@ -22,6 +22,7 @@
#include "base/net_multiplayer.h"
#include "base/checkFront.h"
#include "base/protect.h"
+#include "base/index.h"
#ifndef PUBLIC_SERVER
#include "screen/screen_world.h"
@@ -38,6 +39,8 @@ static sock_udp_t *sock_server_udp;
static sock_udp_t *sock_server_udp_second;
static list_t *listClient;
+static list_t *listClientIndex;
+
static list_t *listServerTimer;
static time_t timeUpdate;
static int maxClients;
@@ -52,6 +55,18 @@ time_t getUpdateServer()
return time(NULL) - timeUpdate;
}
+static void eventDelClient(client_t *client)
+{
+ int offset;
+
+ offset = getFormIndex(listClientIndex, getSockUdpPort(client->socket_udp));
+
+ assert( offset != -1 );
+
+ delFromIndex(listClientIndex, getSockUdpPort(client->socket_udp));
+ delListItem(listClient, offset, destroyClient);
+}
+
static void delZombieCLient(void *p_nothink)
{
client_t *thisClient;
@@ -78,7 +93,8 @@ static void delZombieCLient(void *p_nothink)
proto_send_del_server(PROTO_SEND_ALL, NULL, thisClient->tux->id);
}
- delListItem(listClient, i, destroyClient);
+ eventDelClient(thisClient);
+ i--;
}
}
@@ -86,39 +102,25 @@ static void delZombieCLient(void *p_nothink)
static void eventPeriodicSyncClient(void *p_nothink)
{
- client_t *thisClientInfo;
client_t *thisClientSend;
tux_t *thisTux;
- int i, j;
+ int i;
- for( i = 0 ; i < listClient->count; i++)
+#ifndef PUBLIC_SERVER
+ proto_send_newtux_server(PROTO_SEND_ALL_SEES_TUX, NULL, getControlTux(TUX_CONTROL_KEYBOARD_RIGHT));
+#endif
+
+ for( i = 0 ; i < listClient->count; i++ )
{
thisClientSend = (client_t *) listClient->list[i];
+ thisTux = thisClientSend->tux;
- if( thisClientSend->tux == NULL )
+ if( thisTux == NULL )
{
continue;
}
-#ifndef PUBLIC_SERVER
- thisTux = getControlTux(TUX_CONTROL_KEYBOARD_RIGHT);
- if( isTuxSeesTux(thisClientSend->tux, thisTux) )
- proto_send_newtux_server(PROTO_SEND_ONE, thisClientSend, thisTux);
-#endif
-
- for( j = 0 ; j < listClient->count; j++)
- {
- thisClientInfo = (client_t *) listClient->list[j];
- thisTux = thisClientInfo->tux;
-
- if( thisTux != NULL &&
- thisClientSend != thisClientInfo &&
- isTuxSeesTux(thisClientSend->tux, thisTux) )
- {
- proto_send_newtux_server(PROTO_SEND_ONE,
- thisClientSend, thisTux);
- }
- }
+ proto_send_newtux_server(PROTO_SEND_ALL_SEES_TUX, thisClientSend, thisTux);
}
}
@@ -147,7 +149,10 @@ static void initServer()
{
startUpdateServer();
listServerTimer = NULL;
+
listClient = newList();
+ listClientIndex = newIndex();
+
setServerMaxClients(SERVER_MAX_CLIENTS);
setServerTimer();
}
@@ -350,10 +355,68 @@ static void addMsgAllClient(char *msg, int type, int id)
static void addMsgAllClientSeesTux(char *msg, tux_t *tux, int type, int id)
{
+ arena_t *arena;
+ space_t *space;
+ int x, y, w, h;
int i;
assert( msg != NULL );
+ listDoEmpty(listHelp);
+
+ arena = getCurrentArena();
+ space = arena->spaceTux;
+
+ x = tux->x-(WINDOW_SIZE_X/2)*1.25;
+ y = tux->y-(WINDOW_SIZE_Y/2)*1.25;
+
+ w = WINDOW_SIZE_X*1.5;
+ h = WINDOW_SIZE_Y*1.5;
+
+ if( x < 0 )
+ {
+ x = 0;
+ }
+
+ if( y < 0 )
+ {
+ y = 0;
+ }
+
+ if( w+x >= arena->w )
+ {
+ w = arena->w - (x+1);
+ }
+
+ if( h+y >= arena->h )
+ {
+ h = arena->h - (y+1);
+ }
+
+ getObjectFromSpace(space, x, y, w, h, listHelp);
+ //printf("%d %d %d %d %d\n", x, y, w, h, listHelp->count);
+
+ for( i = 0 ; i < listHelp->count ; i++ )
+ {
+ tux_t *thisTux;
+ client_t *thisClient;
+
+ thisTux = (tux_t *)listHelp->list[i];
+
+ if( thisTux == tux )
+ {
+ continue;
+ }
+
+ thisClient = thisTux->client;
+
+ if( thisClient != NULL )
+ {
+ addMsgClient(thisClient, msg, type, id);
+ }
+ }
+
+#if 0
for( i = 0 ; i < listClient->count ; i++ )
{
client_t *thisClient;
@@ -373,6 +436,7 @@ static void addMsgAllClientSeesTux(char *msg, tux_t *tux, int type, int id)
addMsgClient(thisClient, msg, type, id);
}
}
+#endif
}
void protoSendClient(int type, client_t *client, char *msg, int type2, int id)
@@ -474,11 +538,20 @@ void sendInfoCreateClient(client_t *client)
static void eventCreateNewUdpClient(sock_udp_t *socket_udp)
{
client_t *client;
+ int offset;
assert( socket_udp != NULL );
client = newUdpClient( socket_udp );
- addList(listClient, client);
+
+ offset = addToIndex(listClientIndex, getSockUdpPort(client->socket_udp) );
+
+ if( offset == -1 )
+ {
+ return;
+ }
+
+ insList(listClient, offset, client);
}
static void eventClientBuffer(client_t *client)
@@ -575,20 +648,17 @@ void eventClientListBuffer()
static client_t* findUdpClient(sock_udp_t *sock_udp)
{
- int i;
- client_t *thisClient;
+ int offset;
- for( i = 0 ; i < listClient->count; i++)
- {
- thisClient = (client_t *) listClient->list[i];
+ offset = getFormIndex(listClientIndex, getSockUdpPort(sock_udp));
- if( getSockUdpPort(thisClient->socket_udp) == getSockUdpPort(sock_udp) )
- {
- return thisClient;
- }
+ if( offset == -1 )
+ {
+ return NULL;
}
- return NULL;
+ return (client_t *) listClient->list[offset];
+
}
static void eventClientUdpSelect(sock_udp_t *sock_server)
@@ -773,7 +843,10 @@ void quitUdpServer()
proto_send_end_server(PROTO_SEND_ALL, NULL);
assert( listClient != NULL );
+
destroyListItem(listClient, destroyClient);
+ destroyIndex(listClientIndex);
+
destroyTimer(listServerTimer);
if( sock_server_udp != NULL )
diff --git a/src/base/tux.c b/src/base/tux.c
index cd7cd4a..9d34cc9 100644
--- a/src/base/tux.c
+++ b/src/base/tux.c
@@ -230,6 +230,7 @@ void replaceTuxID(tux_t *tux, int id)
tux->id = id;
}
+#if 0
int isTuxSeesTux(tux_t *tux, tux_t *thisTux)
{
int tux_x, tux_y, tux_w, tux_h;
@@ -244,6 +245,7 @@ int isTuxSeesTux(tux_t *tux, tux_t *thisTux)
return conflictSpace(screen_x-WINDOW_SIZE_X/4, screen_y-WINDOW_SIZE_Y/4,
WINDOW_SIZE_X*1.25, WINDOW_SIZE_Y*1.25, thisTux_x, thisTux_y, thisTux_w, thisTux_h);
}
+#endif
static void timer_spawnTux(void *p)
{
diff --git a/src/base/tux.h b/src/base/tux.h
index 8a39cf9..c8f6e51 100644
--- a/src/base/tux.h
+++ b/src/base/tux.h
@@ -127,7 +127,6 @@ extern void eventListTux(list_t *listTux);
extern tux_t* getTuxID(list_t *listTux, int id);
extern void getTuxProportion(tux_t *tux, int *x,int *y, int *w, int *h);
extern void replaceTuxID(tux_t *tux, int id);
-extern int isTuxSeesTux(tux_t *tux, tux_t *thisTux);
extern void setTuxProportion(tux_t *tux, int x, int y);
extern void getStatusTux(void *p, int *id, int *x,int *y, int *w, int *h);
extern void setStatusTux(void *p, int x, int y, int w, int h);
diff --git a/src/net_unix/udp.c b/src/net_unix/udp.c
index 79df4b0..13cb916 100644
--- a/src/net_unix/udp.c
+++ b/src/net_unix/udp.c
@@ -249,10 +249,11 @@ void getSockUdpIp(sock_udp_t *p, char *str_ip, int len)
assert( p != NULL );
assert( str_ip != NULL );
- //strcpy(str_ip, inet_ntoa(p->sockAddr.sin_addr));
if( p->proto == PROTO_UDPv4 )
{
+ //strcpy(str_ip, inet_ntoa(p->sockAddr.sin_addr));
+ //printf("strcpy(str_ip, inet_ntoa(p->sockAddr.sin_addr));\n");
inet_ntop(AF_INET, &(p->sockAddr.sin_addr), str_ip, len);
}
diff --git a/src/net_unix/udp.h b/src/net_unix/udp.h
index a8d935f..a9a38f6 100644
--- a/src/net_unix/udp.h
+++ b/src/net_unix/udp.h
@@ -28,5 +28,4 @@ extern int writeUdpSocket(sock_udp_t *src, sock_udp_t *dst, void *address, int l
extern void getSockUdpIp(sock_udp_t *p, char *str_ip, int len);
extern int getSockUdpPort(sock_udp_t *p);
extern void closeUdpSocket(sock_udp_t *p);
-
#endif
diff --git a/src/screen/screen_browser.c b/src/screen/screen_browser.c
index 0eb82af..44b0411 100644
--- a/src/screen/screen_browser.c
+++ b/src/screen/screen_browser.c
@@ -98,8 +98,9 @@ void stopScreenBrowser()
unsigned i = 0;
server_t *server;
- destroyListItem(select_server->list, free);
- select_server->list = newList();
+ //destroyListItem(select_server->list, free);
+ //select_server->list = newList();
+ removeAllFromWidgetSelect(select_server);
while (1) {
i = 0;
@@ -397,16 +398,16 @@ static int LoadServers ()
}
struct timeval tv;
- // Mno¾ina
+ // Mno�ina
fd_set myset;
- // Mno¾ina obsahuje náhodná data. Odstraním je.
+ // Mno�ina obsahuje n�hodn� data. Odstran�m je.
FD_ZERO(&myset);
- // Zaplnìní mno¾iny sokety
+ // Zapln�n� mno�iny sokety
FD_SET(s, &myset);
- // Vyplním èasový údaj (napøíklad na 3 minuty)
- tv.tv_sec = 3;// Poèet sekund
- tv.tv_usec = 0;// Poèet mikrosekund
- // Zavolám select (V Linuxu musím mít nastavenou promìnnou max.)
+ // Vypln�m �asov� �daj (nap��klad na 3 minuty)
+ tv.tv_sec = 3;// Po�et sekund
+ tv.tv_usec = 0;// Po�et mikrosekund
+ // Zavol�m select (V Linuxu mus�m m�t nastavenou prom�nnou max.)
int ret = select (s+1, NULL, &myset, NULL, &tv);
if (ret == -1)
@@ -418,9 +419,9 @@ static int LoadServers ()
/* send request for server list */
send (s, "l", 1, 0);
- // Mno¾ina obsahuje náhodná data. Odstraním je.
+ // Mno�ina obsahuje n�hodn� data. Odstran�m je.
FD_ZERO(&myset);
- // Zaplnìní mno¾iny sokety
+ // Zapln�n� mno�iny sokety
FD_SET(s, &myset);
ret = select (s+1, &myset, NULL, NULL, &tv);
@@ -546,7 +547,7 @@ void initScreenBrowser()
{
SDL_Surface *image;
- image = addImageData("screen_main.png", IMAGE_NO_ALPHA, "screen_browser", IMAGE_GROUP_BASE);
+ image = getImage(IMAGE_GROUP_BASE, "screen_main");
image_backgorund = newWidgetImage(0, 0, image);
button_back = newWidgetButton(getMyText("BACK"), 100, WINDOW_SIZE_Y-100, eventWidget);
diff --git a/src/server/serverConfigFile.c b/src/server/serverConfigFile.c
index c6456ee..48d57eb 100644
--- a/src/server/serverConfigFile.c
+++ b/src/server/serverConfigFile.c
@@ -49,6 +49,24 @@ void initServerConfigFile()
}
+static char *findValue(char *s)
+{
+ int len;
+ int i;
+
+ len = strlen(s);
+
+ for( i = 0 ; i < len-1 ; i++)
+ {
+ if( s[i] == ' ' && s[i+1] != ' ' )
+ {
+ return s+i+1;
+ }
+ }
+
+ return NULL;
+}
+
char* getServerConfigFileValue(char *env, char *s)
{
int i;
@@ -69,7 +87,7 @@ char* getServerConfigFileValue(char *env, char *s)
if( strncmp(line, env, len) == 0 )
{
- return strrchr(line,' ')+1;
+ return findValue(line);
}
}
diff --git a/src/widget/widget_select.c b/src/widget/widget_select.c
index f51239c..4d10bc4 100644
--- a/src/widget/widget_select.c
+++ b/src/widget/widget_select.c
@@ -34,6 +34,14 @@ void addToWidgetSelect(widget_select_t *p, char *s)
addList(p->list, strdup(s) );
}
+void removeAllFromWidgetSelect(widget_select_t *p)
+{
+ while( p->list->count > 0 )
+ {
+ delListItem(p->list, 0, free);
+ }
+}
+
void drawWidgetSelect(widget_select_t *p)
{
int x, y, w, h;
diff --git a/src/widget/widget_select.h b/src/widget/widget_select.h
index 2765f11..7bbe5c0 100644
--- a/src/widget/widget_select.h
+++ b/src/widget/widget_select.h
@@ -18,6 +18,7 @@ typedef struct widget_select
extern widget_select_t* newWidgetSelect(int x, int y, void (*fce_event)(void *));
extern void addToWidgetSelect(widget_select_t *p, char *s);
+extern void removeAllFromWidgetSelect(widget_select_t *p);
extern void drawWidgetSelect(widget_select_t *p);
extern void eventWidgetSelect(widget_select_t *p);
extern void destroyWidgetSelect(widget_select_t *p);
diff --git a/src/widget/widget_textfield.c b/src/widget/widget_textfield.c
index 2e4a9ec..f93f298 100644
--- a/src/widget/widget_textfield.c
+++ b/src/widget/widget_textfield.c
@@ -16,6 +16,7 @@ widget_textfield_t* newWidgetTextfield(char *text, int x, int y)
new->y = y;
new->time = 0;
new->timeBlick = 0;
+ new->atime = 0;
new->active = FALSE;
getTextSize(text, &new->w, &new->h);