summaryrefslogtreecommitdiff
path: root/src/base
diff options
context:
space:
mode:
Diffstat (limited to 'src/base')
-rw-r--r--src/base/arena.c30
-rw-r--r--src/base/gun.c16
-rw-r--r--src/base/item.c27
-rw-r--r--src/base/item.h3
-rw-r--r--src/base/main.c6
-rw-r--r--src/base/main.h4
-rw-r--r--src/base/proto.c17
-rw-r--r--src/base/server.c7
-rw-r--r--src/base/tux.c41
9 files changed, 31 insertions, 120 deletions
diff --git a/src/base/arena.c b/src/base/arena.c
index 5b069f1..4abf1f7 100644
--- a/src/base/arena.c
+++ b/src/base/arena.c
@@ -135,6 +135,21 @@ void getCenterScreen(int *screen_x, int *screen_y, int x, int y)
#ifndef PUBLIC_SERVER
+static void action_drawTux(space_t *space, tux_t *tux, void *p)
+{
+ drawTux(tux);
+}
+
+static void action_drawItem(space_t *space, item_t *item, void *p)
+{
+ drawItem(item);
+}
+
+static void action_drawShot(space_t *space, shot_t *shot, void *p)
+{
+ drawShot(shot);
+}
+
void drawArena(arena_t *arena)
{
int screen_x, screen_y;
@@ -168,17 +183,14 @@ void drawArena(arena_t *arena)
}
- listDoEmpty(listHelp);
- getObjectFromSpace(arena->spaceTux, screen_x, screen_y, WINDOW_SIZE_X, WINDOW_SIZE_Y, listHelp);
- drawListTux(listHelp);
+ actionSpaceFromLocation(arena->spaceTux, action_drawTux, NULL,
+ screen_x, screen_y, WINDOW_SIZE_X, WINDOW_SIZE_Y);
- listDoEmpty(listHelp);
- getObjectFromSpace(arena->spaceItem, screen_x, screen_y, WINDOW_SIZE_X, WINDOW_SIZE_Y, listHelp);
- drawListItem(listHelp);
+ actionSpaceFromLocation(arena->spaceItem, action_drawItem, NULL,
+ screen_x, screen_y, WINDOW_SIZE_X, WINDOW_SIZE_Y);
- listDoEmpty(listHelp);
- getObjectFromSpace(arena->spaceShot, screen_x, screen_y, WINDOW_SIZE_X, WINDOW_SIZE_Y, listHelp);
- drawListShot(listHelp);
+ actionSpaceFromLocation(arena->spaceShot, action_drawShot, NULL,
+ screen_x, screen_y, WINDOW_SIZE_X, WINDOW_SIZE_Y);
//printSpace(arena->spaceShot);
diff --git a/src/base/gun.c b/src/base/gun.c
index aeb2478..45234af 100644
--- a/src/base/gun.c
+++ b/src/base/gun.c
@@ -19,8 +19,6 @@
#ifndef PUBLIC_SERVER
#include "interface.h"
-#include "term.h"
-
#include "screen_world.h"
#endif
@@ -85,13 +83,7 @@ static void addShotTrivial(tux_t *tux, int x, int y, int px, int py, int gun)
shot = newShot(tux->x + dest_x, tux->y + dest_y, dest_px, dest_py, gun, tux->id);
- if(1)// isFreeSpace(getCurrentArena(), shot->x, shot->y, shot->w, shot->h) )
- {
- addObjectToSpace(getCurrentArena()->spaceShot, shot);
- return;
- }
-
- destroyShot(shot);
+ addObjectToSpace(getCurrentArena()->spaceShot, shot);
}
static void addShot(tux_t *tux,int x, int y, int px, int py)
@@ -261,15 +253,9 @@ static void putInGunMine(tux_t *tux)
if( isFreeSpace(getCurrentArena(), x, y, ITEM_MINE_WIDTH, ITEM_MINE_HEIGHT) )
{
item_t *item;
-
-#ifndef PUBLIC_SERVER
- char msg[STR_SIZE];
#ifndef NO_SOUND
playSound("put_mine", SOUND_GROUP_BASE);
#endif
- sprintf(msg, "tux with id %d pu mine\n", tux->id);
- appendTextInTerm(msg);
-#endif
tux->shot[tux->gun]--;
diff --git a/src/base/item.c b/src/base/item.c
index c341754..2cbae3f 100644
--- a/src/base/item.c
+++ b/src/base/item.c
@@ -16,7 +16,6 @@
#include "interface.h"
#include "image.h"
#include "layer.h"
-#include "term.h"
#include "screen_world.h"
#include "screen_setting.h"
@@ -29,7 +28,6 @@
#ifdef PUBLIC_SERVER
#include "publicServer.h"
-#include "publicServer.h"
#endif
#ifndef PUBLIC_SERVER
@@ -166,9 +164,6 @@ void replaceItemID(item_t *item, int id)
void addNewItem(space_t *spaceItem, int author_id)
{
-#ifndef PUBLIC_SERVER
- char msg[STR_SIZE];
-#endif
arena_t *arena;
item_t *item;
int new_x, new_y;
@@ -237,12 +232,6 @@ void addNewItem(space_t *spaceItem, int author_id)
{
proto_send_additem_server(PROTO_SEND_ALL, NULL, item);
}
-
-#ifndef PUBLIC_SERVER
- sprintf(msg, "in arena is new item\n");
- appendTextInTerm(msg);
-#endif
-
}
#ifndef PUBLIC_SERVER
@@ -449,21 +438,13 @@ static void eventTuxIsDeadWithItem(tux_t *tux, item_t *item)
static void tuxGiveBonus(tux_t *tux, item_t *item)
{
-#ifndef PUBLIC_SERVER
- char msg[STR_SIZE];
#ifndef NO_SOUND
playSound("item_bonus", SOUND_GROUP_BASE);
#endif
-#endif
tux->bonus = item->type;
tux->bonus_time = TUX_MAX_BONUS;
-#ifndef PUBLIC_SERVER
- sprintf(msg, "tux with id %d bonus enabled\n", tux->id);
- appendTextInTerm(msg);
-#endif
-
if( getNetTypeGame() == NET_GAME_TYPE_SERVER )
{
proto_send_newtux_server(PROTO_SEND_ALL, NULL, tux);
@@ -472,22 +453,14 @@ static void tuxGiveBonus(tux_t *tux, item_t *item)
static void tuxGiveGun(tux_t *tux, item_t *item)
{
-#ifndef PUBLIC_SERVER
- char msg[STR_SIZE];
#ifndef NO_SOUND
playSound("item_gun", SOUND_GROUP_BASE);
#endif
-#endif
tux->pickup_time = 0;
tux->shot[ item->type ] += GUN_MAX_SHOT;
tux->gun = item->type;
-#ifndef PUBLIC_SERVER
- sprintf(msg, "tux with id %d has new gun\n", tux->id);
- appendTextInTerm(msg);
-#endif
-
if( getNetTypeGame() == NET_GAME_TYPE_SERVER )
{
proto_send_newtux_server(PROTO_SEND_ALL, NULL, tux);
diff --git a/src/base/item.h b/src/base/item.h
index 9dcb678..822283e 100644
--- a/src/base/item.h
+++ b/src/base/item.h
@@ -68,7 +68,8 @@ extern void getStatusItem(void *p, int *id, int *x, int *y ,int *w, int *h);
extern void setStatusItem(void *p, int x, int y, int w, int h);
extern void replaceItemID(item_t *item, int id);
extern void addNewItem(space_t *spaceItem, int author_id);
-#ifndef PUBLIC_SERVER
+#ifndef PUBLIC_SERVER
+extern void drawItem(item_t *p);
extern void drawListItem(list_t *listItem);
#endif
extern void eventListItem(space_t *listSpace);
diff --git a/src/base/main.c b/src/base/main.c
index cc9330f..93a65b4 100644
--- a/src/base/main.c
+++ b/src/base/main.c
@@ -27,8 +27,6 @@
static int my_argc;
static char **my_argv;
-list_t *listHelp;
-
char* getParam(char *s)
{
int i;
@@ -113,6 +111,7 @@ int tryExistFile (const char *s)
else
return 0;
}
+
#ifdef __WIN32__
int WINAPI WinMain(
HINSTANCE hInstance,
@@ -124,9 +123,8 @@ int WINAPI WinMain(
int main(int argc, char *argv[])
#endif
{
- listHelp = newList();
-
srand( (unsigned) time(NULL) );
+
#ifndef __WIN32__
my_argc = argc;
my_argv = argv;
diff --git a/src/base/main.h b/src/base/main.h
index d0b11e6..5fbd81a 100644
--- a/src/base/main.h
+++ b/src/base/main.h
@@ -13,10 +13,6 @@
#define WINDOW_SIZE_X 800
#define WINDOW_SIZE_Y 600
-#include "list.h"
-
-extern list_t *listHelp;
-
extern char* getParam(char *s);
extern char* getParamElse(char *s1, char *s2);
extern bool_t isParamFlag(char *s);
diff --git a/src/base/proto.c b/src/base/proto.c
index e42e4d9..453398f 100644
--- a/src/base/proto.c
+++ b/src/base/proto.c
@@ -386,13 +386,6 @@ void proto_send_newtux_server(int type, client_t *client, tux_t *tux)
getTuxProportion(tux, &x, &y, NULL, NULL);
}
- if( type == PROTO_SEND_ONE &&
- tux->bonus == BONUS_HIDDEN &&
- client->tux == tux )
- {
- getTuxProportion(tux, &x, &y, NULL, NULL);
- }
-
sprintf(msg, "newtux %d %d %d %d %d %d %d %s %d %d %d %d %d %d %d %d %d %d %d\n",
tux->id ,x, y, tux->status, tux->position ,tux->frame, tux->score, tux->name,
tux->gun, tux->bonus, tux->shot[GUN_SIMPLE], tux->shot[GUN_DUAL_SIMPLE],
@@ -436,10 +429,6 @@ void proto_recv_newtux_client(char *msg)
if( tux == NULL )
{
- char term_msg[STR_SIZE];
- sprintf(term_msg, "connect new client( id = %d)\n", id);
- appendTextInTerm(term_msg);
-
tux = newTux();
replaceTuxID(tux, id);
tux->control = TUX_CONTROL_NET;
@@ -549,12 +538,6 @@ void proto_recv_del_client(char *msg)
if( tux != NULL )
{
- char term_msg[STR_SIZE];
-
- //printf("delete tux..\n");
- sprintf(term_msg, "tux with id %d is disconnect\n", tux->id);
- appendTextInTerm(term_msg);
-
delFromRadar(id);
delObjectFromSpaceWithObject(getCurrentArena()->spaceTux, tux, destroyTux);
return;
diff --git a/src/base/server.c b/src/base/server.c
index cf1f70f..ce4f848 100644
--- a/src/base/server.c
+++ b/src/base/server.c
@@ -364,6 +364,7 @@ static void addMsgAllClient(char *msg, int type, int id)
static void addMsgAllClientSeesTux(char *msg, tux_t *tux, int type, int id)
{
+ list_t *listHelp;
arena_t *arena;
space_t *space;
int x, y, w, h;
@@ -371,8 +372,6 @@ static void addMsgAllClientSeesTux(char *msg, tux_t *tux, int type, int id)
assert( msg != NULL );
- listDoEmpty(listHelp);
-
arena = getCurrentArena();
space = arena->spaceTux;
@@ -387,6 +386,8 @@ static void addMsgAllClientSeesTux(char *msg, tux_t *tux, int type, int id)
if( w+x >= arena->w )w = arena->w - (x+1);
if( h+y >= arena->h )h = arena->h - (y+1);
+ listHelp = newList();
+
getObjectFromSpace(space, x, y, w, h, listHelp);
//printf("%d %d %d %d %d\n", x, y, w, h, listHelp->count);
@@ -409,6 +410,8 @@ static void addMsgAllClientSeesTux(char *msg, tux_t *tux, int type, int id)
addMsgClient(thisClient, msg, type, id);
}
}
+
+ destroyList(listHelp);
}
void protoSendClient(int type, client_t *client, char *msg, int type2, int id)
diff --git a/src/base/tux.c b/src/base/tux.c
index bbc63e0..6823452 100644
--- a/src/base/tux.c
+++ b/src/base/tux.c
@@ -21,7 +21,6 @@
#include "font.h"
#include "image.h"
#include "layer.h"
-#include "term.h"
#include "radar.h"
#ifndef NO_SOUND
@@ -309,22 +308,14 @@ static void timer_tuxCanSwitchGun(void *p)
void eventTuxIsDead(tux_t *tux)
{
-#ifndef PUBLIC_SERVER
- char msg[STR_SIZE];
-#endif
-
if( tux->status == TUX_STATUS_DEAD )
{
return;
}
-#ifndef PUBLIC_SERVER
- sprintf(msg, "tux with id %d is dead\n", tux->id);
#ifndef NO_SOUND
playSound("dead", SOUND_GROUP_BASE);
#endif
- appendTextInTerm(msg);
-#endif
tux->status = TUX_STATUS_DEAD;
memset(tux->shot, 0, sizeof(int) * GUN_COUNT);
@@ -376,17 +367,10 @@ static void eventTuxIsDeadWIthShot(tux_t *tux, shot_t *shot)
void tuxTeleport(tux_t *tux)
{
int x, y;
-#ifndef PUBLIC_SERVER
- char msg[STR_SIZE];
-#endif
-#ifndef PUBLIC_SERVER
- sprintf(msg, "tux with id %d teleporting\n", tux->id);
#ifndef NO_SOUND
playSound("teleport", SOUND_GROUP_BASE);
#endif
- appendTextInTerm(msg);
-#endif
if( getNetTypeGame() != NET_GAME_TYPE_CLIENT )
{
@@ -532,9 +516,6 @@ void moveTux(tux_t *tux, int n)
void switchTuxGun(tux_t *tux)
{
int i;
-#ifndef PUBLIC_SERVER
- char msg[STR_SIZE];
-#endif
if( tux->control != TUX_CONTROL_NET &&
tux->isCanSwitchGun == FALSE )
@@ -550,13 +531,9 @@ void switchTuxGun(tux_t *tux)
tux->isCanSwitchGun = FALSE;
addTaskToTimer(getCurrentArena()->listTimer, TIMER_ONE, timer_tuxCanSwitchGun,
newInt(tux->id), TUX_TIME_CAN_SWITCH_GUN );
-#ifndef PUBLIC_SERVER
#ifndef NO_SOUND
playSound("switch_gun", SOUND_GROUP_BASE);
#endif
- sprintf(msg, "tux with id %d switch gun\n", tux->id);
- appendTextInTerm(msg);
-#endif
return;
}
}
@@ -570,13 +547,9 @@ void switchTuxGun(tux_t *tux)
addTaskToTimer(getCurrentArena()->listTimer, TIMER_ONE, timer_tuxCanSwitchGun,
newInt(tux->id), TUX_TIME_CAN_SWITCH_GUN );
-#ifndef PUBLIC_SERVER
#ifndef NO_SOUND
playSound("switch_gun", SOUND_GROUP_BASE);
#endif
- sprintf(msg, "tux with id %d switch gun\n", tux->id);
- appendTextInTerm(msg);
-#endif
return;
}
@@ -649,14 +622,9 @@ static void pickUpGun(tux_t *tux)
if( tux->pickup_time == TUX_MAX_PICKUP && getNetTypeGame() != NET_GAME_TYPE_CLIENT )
{
-#ifndef PUBLIC_SERVER
- char msg[STR_SIZE];
#ifndef NO_SOUND
playSound("switch_gun", SOUND_GROUP_BASE);
#endif
- sprintf(msg, "tux with id %d pickup\n", tux->id);
- appendTextInTerm(msg);
-#endif
tux->gun = GUN_SIMPLE;
tux->shot[ tux->gun ] = GUN_MAX_SHOT;
@@ -681,10 +649,6 @@ static void eventBonus(tux_t *tux)
if( tux->bonus_time == 0 && getNetTypeGame() != NET_GAME_TYPE_CLIENT )
{
-#ifndef PUBLIC_SERVER
- char msg[STR_SIZE];
-#endif
-
if( tux->bonus == BONUS_GHOST )
{
int x, y, w, h;
@@ -702,11 +666,6 @@ static void eventBonus(tux_t *tux)
tux->bonus = BONUS_NONE;
-#ifndef PUBLIC_SERVER
- sprintf(msg, "tux with id %d bonus disabled\n", tux->id);
- appendTextInTerm(msg);
-#endif
-
if( getNetTypeGame() == NET_GAME_TYPE_SERVER )
{
proto_send_newtux_server(PROTO_SEND_ALL, NULL, tux);