From 247baf298bf2425fd91297ea18d716e714cb3dc5 Mon Sep 17 00:00:00 2001 From: oroborus Date: Fri, 4 Jul 2008 19:16:27 +0000 Subject: - podpora bigAren :-) - radar git-svn-id: http://opensvn.csie.org/tuxanci_ng@90 0ee4d065-81f0-4d1e-b06c-ff20ad07cc3e --- arena/ba_in_a_captivity_of_8-bit.map | 107 ++++++++++++++++++++++++++++++++ arena/in_a_captivity_of_8-bit.map | 10 ++- config.h | 2 +- image/radar.png | Bin 0 -> 314 bytes lang/cs.lang | 2 +- modules/modWall.c | 18 +++++- server.conf | 6 +- src/base/arena.c | 12 +--- src/base/gun.c | 3 +- src/base/proto.c | 9 +++ src/base/server.c | 15 +++-- src/base/server.h | 2 + src/base/shot.c | 69 ++++++++++----------- src/base/tux.c | 1 + src/client/Makefile | 4 +- src/client/game.c | 1 + src/client/radar.c | 117 +++++++++++++++++++++++++++++++++++ src/client/radar.h | 24 +++++++ src/modules/modWall.c | 33 +++++++--- src/screen/screen_world.c | 14 +++++ src/server/publicServer.c | 6 +- 21 files changed, 377 insertions(+), 78 deletions(-) create mode 100644 arena/ba_in_a_captivity_of_8-bit.map create mode 100644 image/radar.png create mode 100644 src/client/radar.c create mode 100644 src/client/radar.h diff --git a/arena/ba_in_a_captivity_of_8-bit.map b/arena/ba_in_a_captivity_of_8-bit.map new file mode 100644 index 0000000..049fa0b --- /dev/null +++ b/arena/ba_in_a_captivity_of_8-bit.map @@ -0,0 +1,107 @@ + +name In a captivity of 8-bit +netName BAIACO8B +screen ba_in_a_captivity_of_8-bit.png + +loadModule file="modWall.so" +loadModule file="modTeleport.so" + +loadMusic file="in_a_captivity_of_8-bit.ogg" name="in_a_captivity_of_8-bit" + +loadImage file="l3.nic.png" name="nic" alpha="no" +loadImage file="l3.ihlan.png" name="ihlan" alpha="yes" +loadImage file="l3.kvader1.png" name="kvader1" alpha="yes" +loadImage file="l3.kvader2.png" name="kvader2" alpha="yes" +loadImage file="l3.teleport.png" name="teleport" alpha="yes" + +arena background="nic" w="2500" h="2500" + +playMusic music="in_a_captivity_of_8-bit" + +#wall rel="1" x="512" y="320" w="125" h="100" img_x="-12" img_y="-195" layer="0" image="ihlan" +#wall rel="1" x="273" y="152" w="180" h="75" img_x="-23" img_y="-90" layer="0" image="kvader1" +#wall rel="1" x="90" y="275" w="87" h="205" img_x="-28" img_y="-88" layer="0" image="kvader2" + +wwall rel="1" x="1518" y="426" w="125" h="100" img_x="-12" img_y="-195" layer="0" image="ihlan" +wall rel="1" x="1479" y="1228" w="125" h="100" img_x="-12" img_y="-195" layer="0" image="ihlan" +wall rel="1" x="1139" y="2241" w="125" h="100" img_x="-12" img_y="-195" layer="0" image="ihlan" +wall rel="1" x="1854" y="1988" w="125" h="100" img_x="-12" img_y="-195" layer="0" image="ihlan" +wall rel="1" x="270" y="140" w="125" h="100" img_x="-12" img_y="-195" layer="0" image="ihlan" +wall rel="1" x="1254" y="1107" w="125" h="100" img_x="-12" img_y="-195" layer="0" image="ihlan" +wall rel="1" x="1717" y="803" w="125" h="100" img_x="-12" img_y="-195" layer="0" image="ihlan" +wall rel="1" x="2228" y="771" w="125" h="100" img_x="-12" img_y="-195" layer="0" image="ihlan" +wall rel="1" x="1986" y="2311" w="125" h="100" img_x="-12" img_y="-195" layer="0" image="ihlan" +wall rel="1" x="2125" y="2299" w="125" h="100" img_x="-12" img_y="-195" layer="0" image="ihlan" +wall rel="1" x="2000" y="71" w="125" h="100" img_x="-12" img_y="-195" layer="0" image="ihlan" +wall rel="1" x="1077" y="1214" w="125" h="100" img_x="-12" img_y="-195" layer="0" image="ihlan" +wall rel="1" x="302" y="1194" w="125" h="100" img_x="-12" img_y="-195" layer="0" image="ihlan" +wall rel="1" x="2175" y="109" w="125" h="100" img_x="-12" img_y="-195" layer="0" image="ihlan" +wall rel="1" x="571" y="1964" w="125" h="100" img_x="-12" img_y="-195" layer="0" image="ihlan" +wall rel="1" x="328" y="387" w="125" h="100" img_x="-12" img_y="-195" layer="0" image="ihlan" +wall rel="1" x="1616" y="1378" w="125" h="100" img_x="-12" img_y="-195" layer="0" image="ihlan" +wall rel="1" x="2471" y="659" w="125" h="100" img_x="-12" img_y="-195" layer="0" image="ihlan" +wall rel="1" x="147" y="1607" w="125" h="100" img_x="-12" img_y="-195" layer="0" image="ihlan" +wall rel="1" x="1748" y="1825" w="125" h="100" img_x="-12" img_y="-195" layer="0" image="ihlan" +wall rel="1" x="433" y="1769" w="125" h="100" img_x="-12" img_y="-195" layer="0" image="ihlan" +wall rel="1" x="73" y="1854" w="125" h="100" img_x="-12" img_y="-195" layer="0" image="ihlan" +wall rel="1" x="125" y="1002" w="125" h="100" img_x="-12" img_y="-195" layer="0" image="ihlan" +wall rel="1" x="2165" y="1153" w="125" h="100" img_x="-12" img_y="-195" layer="0" image="ihlan" +wall rel="1" x="952" y="963" w="125" h="100" img_x="-12" img_y="-195" layer="0" image="ihlan" +wall rel="1" x="1035" y="642" w="125" h="100" img_x="-12" img_y="-195" layer="0" image="ihlan" +wall rel="1" x="708" y="1804" w="180" h="75" img_x="-23" img_y="-90" layer="0" image="kvader1" +wall rel="1" x="1850" y="964" w="180" h="75" img_x="-23" img_y="-90" layer="0" image="kvader1" +wall rel="1" x="1074" y="1011" w="180" h="75" img_x="-23" img_y="-90" layer="0" image="kvader1" +wall rel="1" x="475" y="1525" w="180" h="75" img_x="-23" img_y="-90" layer="0" image="kvader1" +wall rel="1" x="765" y="497" w="180" h="75" img_x="-23" img_y="-90" layer="0" image="kvader1" +wall rel="1" x="1875" y="2156" w="180" h="75" img_x="-23" img_y="-90" layer="0" image="kvader1" +wall rel="1" x="315" y="1233" w="180" h="75" img_x="-23" img_y="-90" layer="0" image="kvader1" +wall rel="1" x="340" y="698" w="180" h="75" img_x="-23" img_y="-90" layer="0" image="kvader1" +wall rel="1" x="23" y="1815" w="180" h="75" img_x="-23" img_y="-90" layer="0" image="kvader1" +wall rel="1" x="1084" y="2088" w="180" h="75" img_x="-23" img_y="-90" layer="0" image="kvader1" +wall rel="1" x="295" y="1808" w="180" h="75" img_x="-23" img_y="-90" layer="0" image="kvader1" +wall rel="1" x="1663" y="9" w="180" h="75" img_x="-23" img_y="-90" layer="0" image="kvader1" +wall rel="1" x="1162" y="1772" w="180" h="75" img_x="-23" img_y="-90" layer="0" image="kvader1" +wall rel="1" x="236" y="180" w="180" h="75" img_x="-23" img_y="-90" layer="0" image="kvader1" +wall rel="1" x="823" y="2115" w="180" h="75" img_x="-23" img_y="-90" layer="0" image="kvader1" +wall rel="1" x="271" y="1271" w="180" h="75" img_x="-23" img_y="-90" layer="0" image="kvader1" +wall rel="1" x="1087" y="1531" w="180" h="75" img_x="-23" img_y="-90" layer="0" image="kvader1" +wall rel="1" x="1394" y="2122" w="180" h="75" img_x="-23" img_y="-90" layer="0" image="kvader1" +wall rel="1" x="2499" y="1013" w="180" h="75" img_x="-23" img_y="-90" layer="0" image="kvader1" +wall rel="1" x="1510" y="1870" w="180" h="75" img_x="-23" img_y="-90" layer="0" image="kvader1" +wall rel="1" x="378" y="764" w="180" h="75" img_x="-23" img_y="-90" layer="0" image="kvader1" +wall rel="1" x="1997" y="2237" w="180" h="75" img_x="-23" img_y="-90" layer="0" image="kvader1" +wall rel="1" x="1787" y="693" w="180" h="75" img_x="-23" img_y="-90" layer="0" image="kvader1" +wall rel="1" x="1360" y="1190" w="180" h="75" img_x="-23" img_y="-90" layer="0" image="kvader1" +wall rel="1" x="2130" y="1811" w="180" h="75" img_x="-23" img_y="-90" layer="0" image="kvader1" +wall rel="1" x="2471" y="2445" w="87" h="205" img_x="-28" img_y="-88" layer="0" image="kvader2" +wall rel="1" x="2454" y="2425" w="87" h="205" img_x="-28" img_y="-88" layer="0" image="kvader2" +wall rel="1" x="1698" y="1634" w="87" h="205" img_x="-28" img_y="-88" layer="0" image="kvader2" +wall rel="1" x="1815" y="2469" w="87" h="205" img_x="-28" img_y="-88" layer="0" image="kvader2" +wall rel="1" x="2084" y="1934" w="87" h="205" img_x="-28" img_y="-88" layer="0" image="kvader2" +wall rel="1" x="2057" y="1490" w="87" h="205" img_x="-28" img_y="-88" layer="0" image="kvader2" +wall rel="1" x="1873" y="1207" w="87" h="205" img_x="-28" img_y="-88" layer="0" image="kvader2" +wall rel="1" x="829" y="644" w="87" h="205" img_x="-28" img_y="-88" layer="0" image="kvader2" +wall rel="1" x="1658" y="768" w="87" h="205" img_x="-28" img_y="-88" layer="0" image="kvader2" +wall rel="1" x="1490" y="2181" w="87" h="205" img_x="-28" img_y="-88" layer="0" image="kvader2" +wall rel="1" x="1797" y="2020" w="87" h="205" img_x="-28" img_y="-88" layer="0" image="kvader2" +wall rel="1" x="610" y="720" w="87" h="205" img_x="-28" img_y="-88" layer="0" image="kvader2" +wall rel="1" x="1413" y="147" w="87" h="205" img_x="-28" img_y="-88" layer="0" image="kvader2" +wall rel="1" x="1337" y="2397" w="87" h="205" img_x="-28" img_y="-88" layer="0" image="kvader2" +wall rel="1" x="560" y="274" w="87" h="205" img_x="-28" img_y="-88" layer="0" image="kvader2" +wall rel="1" x="1571" y="967" w="87" h="205" img_x="-28" img_y="-88" layer="0" image="kvader2" +wall rel="1" x="893" y="532" w="87" h="205" img_x="-28" img_y="-88" layer="0" image="kvader2" +wall rel="1" x="1018" y="377" w="87" h="205" img_x="-28" img_y="-88" layer="0" image="kvader2" +wall rel="1" x="346" y="91" w="87" h="205" img_x="-28" img_y="-88" layer="0" image="kvader2" +wall rel="1" x="877" y="333" w="87" h="205" img_x="-28" img_y="-88" layer="0" image="kvader2" +wall rel="1" x="675" y="1282" w="87" h="205" img_x="-28" img_y="-88" layer="0" image="kvader2" +wall rel="1" x="2490" y="434" w="87" h="205" img_x="-28" img_y="-88" layer="0" image="kvader2" +wall rel="1" x="2430" y="49" w="87" h="205" img_x="-28" img_y="-88" layer="0" image="kvader2" +wall rel="1" x="2169" y="2171" w="87" h="205" img_x="-28" img_y="-88" layer="0" image="kvader2" +wall rel="1" x="1852" y="440" w="87" h="205" img_x="-28" img_y="-88" layer="0" image="kvader2" + + +teleport x="100" y="100" w="58" h="58" layer="-1" image="teleport" +teleport x="2342" y="100" w="58" h="58" layer="-1" image="teleport" +teleport x="100" y="2342" w="58" h="58" layer="-1" image="teleport" +teleport x="2342" y="2342" w="58" h="58" layer="-1" image="teleport" + diff --git a/arena/in_a_captivity_of_8-bit.map b/arena/in_a_captivity_of_8-bit.map index 02316d4..3316aef 100644 --- a/arena/in_a_captivity_of_8-bit.map +++ b/arena/in_a_captivity_of_8-bit.map @@ -18,9 +18,13 @@ arena background="nic" w="800" h="600" playMusic music="in_a_captivity_of_8-bit" -wall x="512" y="320" w="125" h="100" img_x="500" img_y="125" layer="0" image="ihlan" -wall x="273" y="152" w="180" h="75" img_x="250" img_y="62" layer="0" image="kvader1" -wall x="90" y="275" w="87" h="205" img_x="62" img_y="187" layer="0" image="kvader2" +wall rel="1" x="512" y="320" w="125" h="100" img_x="-12" img_y="-195" layer="0" image="ihlan" +wall rel="1" x="273" y="152" w="180" h="75" img_x="-23" img_y="-90" layer="0" image="kvader1" +wall rel="1" x="90" y="275" w="87" h="205" img_x="-28" img_y="-88" layer="0" image="kvader2" + +#wall x="512" y="320" w="125" h="100" img_x="500" img_y="125" layer="0" image="ihlan" +#wall x="273" y="152" w="180" h="75" img_x="250" img_y="62" layer="0" image="kvader1" +#wall x="90" y="275" w="87" h="205" img_x="62" img_y="187" layer="0" image="kvader2" teleport x="112" y="112" w="58" h="58" layer="-1" image="teleport" teleport x="375" y="375" w="58" h="58" layer="-1" image="teleport" diff --git a/config.h b/config.h index b1739d2..806db7f 100644 --- a/config.h +++ b/config.h @@ -1,4 +1,4 @@ -#define TUXANCI_NG_VERSION "svn89" +#define TUXANCI_NG_VERSION "svn90" #define DESTDIR "/usr/local/" diff --git a/image/radar.png b/image/radar.png new file mode 100644 index 0000000..f7d6f62 Binary files /dev/null and b/image/radar.png differ diff --git a/lang/cs.lang b/lang/cs.lang index 5b1cb9e..9920dfa 100644 --- a/lang/cs.lang +++ b/lang/cs.lang @@ -43,4 +43,4 @@ SERVER Vytvoření serveru CLIENT Síťová hra IP_ADDR IP adresa serveru: NET_PORT Síťový port: -BROWSER Vyhledávač \ No newline at end of file +BROWSER Vyhledávač diff --git a/modules/modWall.c b/modules/modWall.c index 056bb5c..d917309 100755 --- a/modules/modWall.c +++ b/modules/modWall.c @@ -322,10 +322,22 @@ void cmd(char *line) int destroy() { - destroySpaceWithObject(spaceWall, destroyWall); + if( spaceWall != NULL ) + { + destroySpaceWithObject(spaceWall, destroyWall); + } + #ifndef PUBLIC_SERVER - destroySpace(spaceImgWall); + if( spaceImgWall != NULL ) + { + destroySpace(spaceImgWall); + } #endif - destroyList(listWall); + + if( listWall != NULL ) + { + destroyList(listWall); + } + return 0; } diff --git a/server.conf b/server.conf index 26271b5..e34a73b 100644 --- a/server.conf +++ b/server.conf @@ -1,7 +1,7 @@ NAME oroborus gameserver IP4 0.0.0.0 -IP6 ::1 +#IP6 ::1 PORTv4 2200 -PORTv6 2206 +#PORTv6 2206 MAX_CLIENTS 32 -ARENA IACO8B +ARENA BAIACO8B diff --git a/src/base/arena.c b/src/base/arena.c index bd471a2..9de1dce 100644 --- a/src/base/arena.c +++ b/src/base/arena.c @@ -90,8 +90,8 @@ void findFreeSpace(arena_t *arena, int *x, int *y, int w, int h) assert( y != NULL ); do{ - z_x = random() % WINDOW_SIZE_X;//arena->w; - z_y = random() % WINDOW_SIZE_Y;//arena->h; + z_x = random() % (arena->w-w); + z_y = random() % (arena->h-h); }while( isFreeSpace(arena, z_x, z_y ,w ,h) == 0 ); *x = z_x; @@ -201,16 +201,10 @@ void eventArena(arena_t *arena) { int i; - //eventConflictTuxWithTeleport(arena->listTux, arena->listTeleport); - //eventConflictTuxWithShot(arena); - for( i = 0 ; i < 8 ; i++) { - eventMoveListShot(arena); checkShotIsInTuxScreen(arena); - //eventConflictShotWithWall(arena->listWall, arena->listShot); - //eventConflictShotWithTeleport(arena->listTeleport, arena->listShot); - //eventConflictShotWithPipe(arena->listPipe, arena->listShot); + eventMoveListShot(arena); eventConflictShotWithItem(arena); eventConflictTuxWithShot(arena); eventModule(); diff --git a/src/base/gun.c b/src/base/gun.c index 0a7e1a1..c59bd98 100644 --- a/src/base/gun.c +++ b/src/base/gun.c @@ -95,6 +95,7 @@ static void addShotTrivial(tux_t *tux, int x, int y, int px, int py, int gun) //addList( getCurrentArena()->listShot, shot ); addObjectToSpace(getCurrentArena()->spaceShot, shot); +/* if( getNetTypeGame() == NET_GAME_TYPE_SERVER ) { client_t *thisClient; @@ -108,7 +109,7 @@ static void addShotTrivial(tux_t *tux, int x, int y, int px, int py, int gun) proto_send_shot_server(PROTO_SEND_ALL_SEES_TUX, thisClient, shot); } - +*/ } static void addShot(tux_t *tux,int x, int y, int px, int py) diff --git a/src/base/proto.c b/src/base/proto.c index 9c9c3c7..b109115 100644 --- a/src/base/proto.c +++ b/src/base/proto.c @@ -26,6 +26,7 @@ #include "screen/screen_analyze.h" #include "client/client.h" #include "client/term.h" +#include "client/radar.h" #endif #ifdef PUBLIC_SERVER @@ -325,6 +326,7 @@ void proto_recv_event_client(char *msg) if( tux != NULL ) { actionTux(tux, action); + addToRadar(tux->id, tux->x, tux->y, RADAR_TYPE_TUX); } } @@ -438,6 +440,8 @@ void proto_recv_newtux_client(char *msg) addObjectToSpace(getCurrentArena()->spaceTux, tux); } + addToRadar(id, x, y, RADAR_TYPE_TUX); + moveObjectInSpace(getCurrentArena()->spaceTux, tux, x, y); tux->status = status; tux->position = position; @@ -534,6 +538,7 @@ void proto_recv_del_client(char *msg) sprintf(term_msg, "tux with id %d is disconnect\n", tux->id); appendTextInTerm(term_msg); + delFromRadar(id); delObjectFromSpaceWithObject(getCurrentArena()->spaceTux, tux, destroyTux); return; } @@ -543,6 +548,7 @@ void proto_recv_del_client(char *msg) if( shot != NULL ) { //printf("delete shot..\n"); + delFromRadar(id); delObjectFromSpaceWithObject(getCurrentArena()->spaceShot, shot, destroyShot); return; } @@ -552,6 +558,7 @@ void proto_recv_del_client(char *msg) if( item != NULL ) { //printf("delete item..\n"); + delFromRadar(id); delObjectFromSpaceWithObject(getCurrentArena()->spaceItem, item, destroyItem); return; } @@ -601,6 +608,8 @@ void proto_recv_additem_client(char *msg) return; } + addToRadar(id, x, y, RADAR_TYPE_ITEM); + item = newItem(x, y, type, author_id); replaceItemID(item, id); diff --git a/src/base/server.c b/src/base/server.c index fba543c..941b62e 100644 --- a/src/base/server.c +++ b/src/base/server.c @@ -120,7 +120,8 @@ static void eventPeriodicSyncClient(void *p_nothink) continue; } - proto_send_newtux_server(PROTO_SEND_ALL_SEES_TUX, thisClientSend, thisTux); + //proto_send_newtux_server(PROTO_SEND_ALL_SEES_TUX, thisClientSend, thisTux); + proto_send_newtux_server(PROTO_SEND_BUT, thisClientSend, thisTux); } } @@ -228,6 +229,7 @@ client_t* newUdpClient(sock_udp_t *sock_udp) new->status = NET_STATUS_OK; new->listRecvMsg = newList(); new->listSendMsg = newCheckFront(); + new->listSeesShot = newList(); new->protect = newProtect(); new->socket_udp = sock_udp; @@ -248,6 +250,7 @@ void destroyClient(client_t *p) closeUdpSocket(p->socket_udp); destroyListItem(p->listRecvMsg, free); + destroyListItem(p->listSeesShot, free); destroyCheckFront(p->listSendMsg); destroyProtect(p->protect); @@ -367,11 +370,11 @@ static void addMsgAllClientSeesTux(char *msg, tux_t *tux, int type, int id) arena = getCurrentArena(); space = arena->spaceTux; - x = tux->x-(WINDOW_SIZE_X/2)*1.25; - y = tux->y-(WINDOW_SIZE_Y/2)*1.25; + x = tux->x - WINDOW_SIZE_X; + y = tux->y - WINDOW_SIZE_Y; - w = WINDOW_SIZE_X*1.5; - h = WINDOW_SIZE_Y*1.5; + w = 2 * WINDOW_SIZE_X; + h = 2 * WINDOW_SIZE_Y; if( x < 0 ) { @@ -730,7 +733,7 @@ int selectServerUdpSocket() #ifdef PUBLIC_SERVER tv.tv_sec = 0; - tv.tv_usec = 5000; + tv.tv_usec = 1000; #endif FD_ZERO(&readfds); diff --git a/src/base/server.h b/src/base/server.h index 4a946ea..670258c 100644 --- a/src/base/server.h +++ b/src/base/server.h @@ -52,6 +52,8 @@ typedef struct client_struct list_t *listSendMsg; list_t *listRecvMsg; + + list_t *listSeesShot; } client_t; #ifdef PUBLIC_SERVER diff --git a/src/base/shot.c b/src/base/shot.c index 1858bc0..96f5692 100644 --- a/src/base/shot.c +++ b/src/base/shot.c @@ -294,6 +294,7 @@ void eventMoveListShot(arena_t *arena) } } +#if 0 static int myAbs(int n) { return ( n > 0 ? n : -n ); @@ -303,14 +304,30 @@ static int getSppedShot(shot_t *shot) { return ( myAbs(shot->px) > myAbs(shot->py) ? myAbs(shot->px) : myAbs(shot->py) ); } +#endif + +static int isValueInList(list_t *list, int x) +{ + int i; + for( i = 0 ; i < list->count ; i++ ) + { + if( x == ( *(int *)list->list[i] ) ) + { + return 1; + } + } + + return 0; +} void checkShotIsInTuxScreen(arena_t *arena) { int screen_x, screen_y; shot_t *thisShot; tux_t *thisTux; - int speed; + client_t *thisClient; + list_t *listClient; int i, j; if( getNetTypeGame() != NET_GAME_TYPE_SERVER ) @@ -318,12 +335,14 @@ void checkShotIsInTuxScreen(arena_t *arena) return; } - for( i = 0 ; i < arena->spaceTux->list->count ; i++ ) + listClient = getListServerClient(); + + for( i = 0 ; i < listClient->count ; i++ ) { - thisTux = (tux_t *)arena->spaceTux->list->list[i]; - speed = 25; + thisClient = (client_t *)listClient->list[i]; + thisTux = (tux_t *)thisClient->tux; - if( thisTux->control != TUX_CONTROL_NET ) + if( thisTux == NULL || thisTux->control != TUX_CONTROL_NET ) { continue; } @@ -331,47 +350,23 @@ void checkShotIsInTuxScreen(arena_t *arena) getCenterScreen(&screen_x, &screen_y, thisTux->x, thisTux->y); listDoEmpty(listHelp); - getObjectFromSpace(arena->spaceShot, screen_x-speed, screen_y, speed, WINDOW_SIZE_Y, listHelp); - for( j = 0 ; j count ; j++ ) - { - thisShot = (shot_t *)listHelp->list[j]; - client_t *thisClient; - thisClient = getClientFromTux(thisTux); - proto_send_shot_server(PROTO_SEND_ONE, thisClient, thisShot); - } - - listDoEmpty(listHelp); - getObjectFromSpace(arena->spaceShot, screen_x+WINDOW_SIZE_X, screen_y, speed, WINDOW_SIZE_Y, listHelp); + getObjectFromSpace(arena->spaceShot, screen_x, screen_y, WINDOW_SIZE_X, WINDOW_SIZE_Y, listHelp); for( j = 0 ; j count ; j++ ) { thisShot = (shot_t *)listHelp->list[j]; - client_t *thisClient; - thisClient = getClientFromTux(thisTux); - proto_send_shot_server(PROTO_SEND_ONE, thisClient, thisShot); - } - listDoEmpty(listHelp); - getObjectFromSpace(arena->spaceShot, screen_x, screen_y-speed, WINDOW_SIZE_X, speed, listHelp); - - for( j = 0 ; j count ; j++ ) - { - thisShot = (shot_t *)listHelp->list[j]; - client_t *thisClient; - thisClient = getClientFromTux(thisTux); - proto_send_shot_server(PROTO_SEND_ONE, thisClient, thisShot); + if( isValueInList(thisClient->listSeesShot, thisShot->id) == 0 ) + { + addList(thisClient->listSeesShot, newInt(thisShot->id) ); + proto_send_shot_server(PROTO_SEND_ONE, thisClient, thisShot); + } } - listDoEmpty(listHelp); - getObjectFromSpace(arena->spaceShot, screen_x, screen_y+WINDOW_SIZE_Y, WINDOW_SIZE_X, speed, listHelp); - - for( j = 0 ; j count ; j++ ) + while( thisClient->listSeesShot->count > 100 ) { - thisShot = (shot_t *)listHelp->list[j]; - client_t *thisClient; - thisClient = getClientFromTux(thisTux); - proto_send_shot_server(PROTO_SEND_ONE, thisClient, thisShot); + delListItem(thisClient->listSeesShot, 0, free); } } } diff --git a/src/base/tux.c b/src/base/tux.c index 9d34cc9..f60bd1b 100644 --- a/src/base/tux.c +++ b/src/base/tux.c @@ -21,6 +21,7 @@ #include "client/image.h" #include "client/layer.h" #include "client/term.h" +#include "client/radar.h" #include "audio/sound.h" diff --git a/src/client/Makefile b/src/client/Makefile index c5637ea..f8fee47 100644 --- a/src/client/Makefile +++ b/src/client/Makefile @@ -1,6 +1,6 @@ -all: client.o configFile.o font.o game.o image.o interface.o keytable.o language.o layer.o panel.o screen.o term.o +all: client.o configFile.o font.o game.o image.o interface.o keytable.o language.o layer.o panel.o radar.o screen.o term.o client.o: client.c client.h $(CC) $(CFLAGS) -o client.o -c client.c @@ -26,6 +26,8 @@ layer.o: layer.c layer.h panel.o: panel.c panel.h $(CC) $(CFLAGS) -o panel.o -c panel.c +radar.o: radar.c radar.h + $(CC) $(CFLAGS) -o radar.o -c radar.c screen.o: screen.c screen.h $(CC) $(CFLAGS) -o screen.o -c screen.c diff --git a/src/client/game.c b/src/client/game.c index 7ea9145..66da14e 100644 --- a/src/client/game.c +++ b/src/client/game.c @@ -23,6 +23,7 @@ #include "client/keytable.h" #include "client/language.h" #include "client/panel.h" +#include "client/radar.h" #include "audio/audio.h" #include "audio/sound.h" diff --git a/src/client/radar.c b/src/client/radar.c new file mode 100644 index 0000000..d993d41 --- /dev/null +++ b/src/client/radar.c @@ -0,0 +1,117 @@ + +#include +#include + +#include "base/main.h" +#include "base/list.h" +#include "base/tux.h" +#include "base/arena.h" + +#include "client/interface.h" +#include "client/image.h" +#include "client/radar.h" + +static SDL_Surface *g_radar; +static list_t *listRadar; + +typedef struct radar_item_struct +{ + int id; + int x, y; + int type; +} radar_item_t; + +static radar_item_t* newRadarItem(int id, int x, int y, int type) +{ + radar_item_t *new; + + new = malloc( sizeof(radar_item_t) ); + new->id = id; + new->x = x; + new->y = y; + new->type = type; + + return new; +} + +static void destroyRadarItem(radar_item_t *p) +{ + assert( p != NULL ); + free(p); +} + +void addToRadar(int id, int x, int y, int type) +{ + int i; + + for( i = 0 ; i < listRadar->count ; i++ ) + { + radar_item_t *thisRadarItem; + + thisRadarItem = (radar_item_t *)listRadar->list[i]; + + if( thisRadarItem->id == id ) + { + thisRadarItem->x = x; + thisRadarItem->y = y; + thisRadarItem->type = type; + return; + } + } + + addList(listRadar, newRadarItem(id, x, y, type) ); +} + +void delFromRadar(int id) +{ + int i; + + for( i = 0 ; i < listRadar->count ; i++ ) + { + radar_item_t *thisRadarItem; + + thisRadarItem = (radar_item_t *)listRadar->list[i]; + + if( thisRadarItem->id == id ) + { + delListItem(listRadar, i, destroyRadarItem); + return; + } + } +} + +void initRadar() +{ + assert( isImageInicialized() == TRUE ); + assert( isInterfaceInicialized() == TRUE ); + + g_radar = addImageData("radar.png", IMAGE_ALPHA, "radar", IMAGE_GROUP_USER); + listRadar = newList(); +} + +void drawRadar(arena_t *arena) +{ + int i; + + drawImage(g_radar, RADAR_LOCATION_X, RADAR_LOCATION_Y, 0, 0, RADAR_SIZE_X+2, RADAR_SIZE_Y+2); + + for( i = 0 ; i < listRadar->count ; i++ ) + { + radar_item_t *thisRadarItem; + int x, y; + + thisRadarItem = (radar_item_t *)listRadar->list[i]; + + x = ( ( (float)RADAR_SIZE_X) / ( (float)arena->w ) ) * ( (float)thisRadarItem->x ); + y = ( ( (float)RADAR_SIZE_Y) / ( (float)arena->h ) ) * ( (float)thisRadarItem->y ); + + drawImage(g_radar, + RADAR_LOCATION_X+1+x, RADAR_LOCATION_Y+1+y, + 2*thisRadarItem->type, RADAR_SIZE_Y+2, 2, 2); + } +} + +void quitRadar() +{ + destroyListItem(listRadar, destroyRadarItem); +} diff --git a/src/client/radar.h b/src/client/radar.h new file mode 100644 index 0000000..989856a --- /dev/null +++ b/src/client/radar.h @@ -0,0 +1,24 @@ + +#ifndef RADAR_H + +#define RADAR_H + +#include "base/arena.h" + +#define RADAR_LOCATION_X (WINDOW_SIZE_X-110) +#define RADAR_LOCATION_Y (10) + +#define RADAR_SIZE_X 100 +#define RADAR_SIZE_Y 100 + +#define RADAR_TYPE_YOU 3 +#define RADAR_TYPE_TUX 1 +#define RADAR_TYPE_ITEM 2 + +extern void initRadar(); +extern void addToRadar(int id, int x, int y, int type); +extern void delFromRadar(int id); +extern void drawRadar(arena_t *arena); +extern void quitRadar(); + +#endif diff --git a/src/modules/modWall.c b/src/modules/modWall.c index c5e01ce..35d84e6 100755 --- a/src/modules/modWall.c +++ b/src/modules/modWall.c @@ -1,4 +1,3 @@ - #include #include #include @@ -214,8 +213,14 @@ static void cmd_wall(char *line) char str_h[STR_NUM_SIZE]; char str_layer[STR_NUM_SIZE]; char str_image[STR_SIZE]; + char str_rel[STR_SIZE]; + int x, y, w, h, img_x, img_y, layer; + int rel; wall_t *new; + rel = 0; + + if( export_fce->fce_getValue(line, "rel", str_rel, STR_NUM_SIZE) != 0 ); if( export_fce->fce_getValue(line, "x", str_x, STR_NUM_SIZE) != 0 )return; if( export_fce->fce_getValue(line, "y", str_y, STR_NUM_SIZE) != 0 )return; if( export_fce->fce_getValue(line, "w", str_w, STR_NUM_SIZE) != 0 )return; @@ -225,18 +230,28 @@ static void cmd_wall(char *line) if( export_fce->fce_getValue(line, "layer", str_layer, STR_NUM_SIZE) != 0 )return; if( export_fce->fce_getValue(line, "image", str_image, STR_SIZE) != 0 )return; + + rel = atoi(str_rel); + x = atoi(str_x); + y = atoi(str_y); + w = atoi(str_w); + h = atoi(str_h); + img_x = atoi(str_img_x); + img_y = atoi(str_img_y); + layer = atoi(str_layer); + + if( rel == 1 ) + { + img_x += x; + img_y += y; + } + #ifndef PUBLIC_SERVER - new = newWall(atoi(str_x), atoi(str_y), - atoi(str_w), atoi(str_h), - atoi(str_img_x), atoi(str_img_y), - atoi(str_layer), export_fce->fce_getImage(IMAGE_GROUP_USER, str_image) ); + new = newWall(x, y, w, h, img_x, img_y, layer, export_fce->fce_getImage(IMAGE_GROUP_USER, str_image) ); #endif #ifdef PUBLIC_SERVER - new = newWall(atoi(str_x), atoi(str_y), - atoi(str_w), atoi(str_h), - atoi(str_img_x), atoi(str_img_y), - atoi(str_layer) ); + new = newWall(x, y, w, h, img_x, img_y, layer); #endif if( spaceWall == NULL ) diff --git a/src/screen/screen_world.c b/src/screen/screen_world.c index 78628b2..380fd43 100644 --- a/src/screen/screen_world.c +++ b/src/screen/screen_world.c @@ -24,6 +24,7 @@ #include "client/term.h" #include "client/font.h" #include "client/panel.h" +#include "client/radar.h" #ifndef NO_SOUND #include "audio/music.h" @@ -196,6 +197,11 @@ void drawWorld() { drawArena(arena); drawPanel(arena->spaceTux->list); + + if( arena->w > WINDOW_SIZE_X || arena->h > WINDOW_SIZE_Y ) + { + drawRadar(arena); + } } drawTerm(); @@ -481,6 +487,11 @@ void eventWorld() eventArena(arena); //eventModule(); + addToRadar(tuxWithControlRightKeyboard->id, + tuxWithControlRightKeyboard->x, + tuxWithControlRightKeyboard->y, + RADAR_TYPE_YOU); + eventTerm(); eventEnd(); eventEsc(); @@ -495,6 +506,7 @@ void startWorld() lastServerLag = LAG_SERVER_UNKNOWN; initListID(); + initRadar(); initModule(); setGameType(); initTerm(); @@ -556,6 +568,8 @@ void stoptWorld() destroyArena(arena); } + quitRadar(); + #ifndef NO_SOUND stopMusic(); #endif diff --git a/src/server/publicServer.c b/src/server/publicServer.c index c69857a..1d2ccf0 100644 --- a/src/server/publicServer.c +++ b/src/server/publicServer.c @@ -246,12 +246,10 @@ void eventPublicServer() return; } -/* - printf("interval = %d\n", interval); -*/ + //printf("interval = %d\n", interval); + lastActive = getMyTime(); - //fce_interval(); eventArena(arena); } -- cgit v1.2.3