summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/interface.c2
-rw-r--r--src/item.c108
-rw-r--r--src/proto.c9
-rw-r--r--src/screen_world.c2
-rw-r--r--src/server.c6
-rw-r--r--src/tux.c6
6 files changed, 84 insertions, 49 deletions
diff --git a/src/interface.c b/src/interface.c
index 8e07c32..2353bed 100755
--- a/src/interface.c
+++ b/src/interface.c
@@ -65,7 +65,7 @@ int initSDL()
SDL_WM_SetCaption(WINDOW_TITLE, NULL);
//SDL_ShowCursor(0);
- //SDL_EnableKeyRepeat(1,1);
+ SDL_EnableKeyRepeat(1,1);
timer = SDL_AddTimer(INTERVAL, TimerCallback, NULL);
srand((unsigned)time(NULL));
diff --git a/src/item.c b/src/item.c
index ae9ab71..658e66e 100644
--- a/src/item.c
+++ b/src/item.c
@@ -333,7 +333,7 @@ void eventConflictShotWithItem(list_t *listItem, list_t *listShot)
x = ( thisItem->x + thisItem->w/2 ) - ITEM_BIG_EXPLOSION_WIDTH/2;
y = ( thisItem->y + thisItem->h/2 ) - ITEM_BIG_EXPLOSION_HEIGHT/2;
- addList(listItem, newItem(x, y, ITEM_BIG_EXPLOSION, NULL) );
+ addList(listItem, newItem(x, y, ITEM_BIG_EXPLOSION, thisItem->author) );
delListItem(listItem, j, destroyItem);
j--;
@@ -355,11 +355,75 @@ void eventConflictShotWithItem(list_t *listItem, list_t *listShot)
}
}
-void eventGiveTuxItem(tux_t *tux, list_t *listItem)
+static void eventTuxIsDeadWithItem(tux_t *tux, item_t *item)
+{
+ if( tux->bonus == BONUS_GHOST )
+ {
+ return;
+ }
+
+ if( tux->bonus == BONUS_TELEPORT )
+ {
+ tuxTeleport(tux);
+ }
+
+ if( item->author != NULL && item->author != tux )
+ {
+#ifndef BUBLIC_SERVER
+ char term_msg[STR_SIZE];
+
+ sprintf(term_msg, "tux with id %d set score to %d\n",
+ item->author->id, item->author->score+1);
+
+ appendTextInTerm(term_msg);
+#endif
+ item->author->score++;
+
+ if( getNetTypeGame() == NET_GAME_TYPE_SERVER )
+ {
+ proto_send_score_server(PROTO_SEND_ALL, NULL, item->author);
+ }
+ }
+
+ countRoundInc();
+ eventTuxIsDead(tux);
+}
+
+static void tuxGiveBonus(tux_t *tux, item_t *item)
{
#ifndef BUBLIC_SERVER
char msg[STR_SIZE];
+ playSound("item_bonus", SOUND_GROUP_BASE);
#endif
+ tux->bonus = item->type;
+ tux->bonus_time = TUX_MAX_BONUS;
+
+#ifndef BUBLIC_SERVER
+ sprintf(msg, "tux with id %d bonus enabled\n", tux->id);
+ appendTextInTerm(msg);
+#endif
+}
+
+static void tuxGiveGun(tux_t *tux, item_t *item)
+{
+#ifndef BUBLIC_SERVER
+ char msg[STR_SIZE];
+ playSound("item_gun", SOUND_GROUP_BASE);
+#endif
+
+ tux->pickup_time = 0;
+ tux->shot[ item->type ] += GUN_MAX_SHOT;
+ tux->gun = item->type;
+
+#ifndef BUBLIC_SERVER
+ sprintf(msg, "tux with id %d has new gun\n", tux->id);
+ appendTextInTerm(msg);
+#endif
+
+}
+
+void eventGiveTuxItem(tux_t *tux, list_t *listItem)
+{
item_t *thisItem;
int x, y, w, h;
int i;
@@ -388,45 +452,26 @@ void eventGiveTuxItem(tux_t *tux, list_t *listItem)
case GUN_SCATTER :
case GUN_LASSER :
case GUN_MINE :
- tux->pickup_time = 0;
-#ifndef BUBLIC_SERVER
- playSound("item_gun", SOUND_GROUP_BASE);
-#endif
- tux->shot[ thisItem->type ] += GUN_MAX_SHOT;
- tux->gun = thisItem->type;
+ tuxGiveGun(tux, thisItem);
delListItem(listItem, i, destroyItem);
i--;
-
-#ifndef BUBLIC_SERVER
- sprintf(msg, "tux with id %d has new gun\n", tux->id);
- appendTextInTerm(msg);
-#endif
break;
case ITEM_MINE :
if( tux->bonus != BONUS_GHOST )
{
- if( thisItem->author != NULL )
- {
- thisItem->author->score++;
- }
+ //eventTuxIsDeadWithItem(tux, thisItem);
+ addList(listItem, newItem(x, y,
+ ITEM_EXPLOSION, thisItem->author) );
delListItem(listItem, i, destroyItem);
- addList(listItem, newItem(x, y, ITEM_EXPLOSION, NULL) );
i--;
}
break;
case ITEM_EXPLOSION :
case ITEM_BIG_EXPLOSION :
- if( tux->bonus == BONUS_TELEPORT )
- {
- tuxTeleport(tux);
- }
- else
- {
- eventTuxIsDead(tux);
- }
+ eventTuxIsDeadWithItem(tux, thisItem);
break;
case BONUS_SPEED :
@@ -435,18 +480,9 @@ void eventGiveTuxItem(tux_t *tux, list_t *listItem)
case BONUS_GHOST :
case BONUS_4X :
case BONUS_HIDDEN :
-#ifndef BUBLIC_SERVER
- playSound("item_bonus", SOUND_GROUP_BASE);
-#endif
- tux->bonus = thisItem->type;
- tux->bonus_time = TUX_MAX_BONUS;
+ tuxGiveBonus(tux, thisItem);
delListItem(listItem, i, destroyItem);
i--;
-
-#ifndef BUBLIC_SERVER
- sprintf(msg, "tux with id %d bonus enabled\n", tux->id);
- appendTextInTerm(msg);
-#endif
break;
}
diff --git a/src/proto.c b/src/proto.c
index 4372217..974f84c 100644
--- a/src/proto.c
+++ b/src/proto.c
@@ -219,9 +219,10 @@ void proto_recv_event_server(client_t *client, char *msg)
sscanf(msg, "%s %d", cmd, &action);
+ proto_send_event_server(PROTO_SEND_BUT, client, client->tux, action);
+
actionTux(client->tux, action);
- proto_send_event_server(PROTO_SEND_BUT, client, client->tux, action);
}
void proto_send_newtux_server(int type, client_t *client, tux_t *tux)
@@ -517,12 +518,6 @@ void proto_send_ping_client()
void proto_recv_ping_server(client_t *client, char *msg)
{
- assert( msg != NULL );
- assert( client != NULL );
-
-#if defined SUPPORT_NET_UNIX_UDP || defined SUPPORT_NET_SDL_UDP
- client->lastPing = getMyTime();
-#endif
}
#ifndef BUBLIC_SERVER
diff --git a/src/screen_world.c b/src/screen_world.c
index 49d94ac..a1ef1c1 100644
--- a/src/screen_world.c
+++ b/src/screen_world.c
@@ -97,7 +97,7 @@ void countRoundInc()
}
count++;
- printf("count %d\n", count);
+ printf("count = %d\n", count);
if( count >= max_count )
{
diff --git a/src/server.c b/src/server.c
index e1dacf1..98fc96c 100644
--- a/src/server.c
+++ b/src/server.c
@@ -296,7 +296,7 @@ void sendInfoCreateClient(client_t *client)
thisClient = (client_t *) listClient->list[i];
thisTux = thisClient->tux;
- if( thisTux != client->tux )
+ if( thisTux != NULL && thisTux != client->tux )
{
proto_send_newtux_server(PROTO_SEND_ONE, thisClient, client->tux);
proto_send_newtux_server(PROTO_SEND_ONE, client, thisTux);
@@ -402,6 +402,10 @@ static void eventClientBuffer(client_t *client)
if( strncmp(line, "ping", 4) == 0 )proto_recv_ping_server(client, line);
if( strncmp(line, "end", 3) == 0 )proto_recv_end_server(client, line);
}
+
+#if defined SUPPORT_NET_UNIX_UDP || defined SUPPORT_NET_SDL_UDP
+ client->lastPing = getMyTime();
+#endif
}
}
diff --git a/src/tux.c b/src/tux.c
index 60cdd2a..d92d8af 100644
--- a/src/tux.c
+++ b/src/tux.c
@@ -201,7 +201,7 @@ void drawTux(tux_t *tux)
addLayer(g_image,
tux->x - TUX_IMG_WIDTH / 2,
( tux->y + TUX_HEIGHT / 2 ) - TUX_IMG_HEIGHT,
- tux->frame * TUX_IMG_WIDTH, 0,
+ (tux->frame/TUX_KEY) * TUX_IMG_WIDTH, 0,
TUX_IMG_WIDTH, TUX_IMG_HEIGHT, TUX_LAYER);
}
@@ -583,9 +583,9 @@ void moveTux(tux_t *tux, int n)
}
else
{
+ eventGiveTuxItem(tux, getWorldArena()->listItem);
tux->frame++;
-
- if( tux->frame == TUX_MAX_ANIMATION_FRAME ) tux->frame = 0;
+ if( tux->frame == TUX_KEY * TUX_MAX_ANIMATION_FRAME ) tux->frame = 0;
}
// printf("move %d %d %d\n", tux->id, tux->x, tux->y);