summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruno Dilly <bdilly@profusion.mobi>2012-10-04 22:41:35 +0000
committerBruno Dilly <bdilly@profusion.mobi>2012-10-04 22:41:35 +0000
commit134702633734037938465ad6c4b0d59fb8738d6b (patch)
treef079043506eb6660956f9f9187eceabef4fd51bc
parent46991342bb6fc8548d0aa8f1f1485d09d118b093 (diff)
efbb: clear targets del callback on level unload
Otherwise it will create the timer to show win layout when user calls the menu, or loses and retry the game. SVN revision: 77474
-rw-r--r--src/bin/main.c27
1 files changed, 13 insertions, 14 deletions
diff --git a/src/bin/main.c b/src/bin/main.c
index f4845f4..84cfa02 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -44,13 +44,13 @@ struct _Game {
44 Ecore_Timer *end_timer; 44 Ecore_Timer *end_timer;
45 Eina_List *levels; 45 Eina_List *levels;
46 Eina_List *extra_obj; 46 Eina_List *extra_obj;
47 Eina_List *targets;
47 48
48 Etrophy_Gamescore *gamescore; 49 Etrophy_Gamescore *gamescore;
49 Score *score; 50 Score *score;
50 Level *cur_level; 51 Level *cur_level;
51 World *world; 52 World *world;
52 53
53 int targets;
54 int old_cx; 54 int old_cx;
55 int strength; 55 int strength;
56 int angle; 56 int angle;
@@ -113,17 +113,11 @@ _win_cb(void *data)
113} 113}
114 114
115static void 115static void
116_target_dec(void *data, EPhysics_Body *body __UNUSED__, 116_target_dec(void *data, EPhysics_Body *body, void *event_info __UNUSED__)
117 void *event_info __UNUSED__)
118{ 117{
119 Game *game = data; 118 Game *game = data;
120 119 game->targets = eina_list_remove(game->targets, body);
121 if (!game->cur_world) 120 if (!eina_list_count(game->targets))
122 return;
123
124 game->targets--;
125
126 if (!game->targets)
127 game->end_timer = ecore_timer_add(3, _win_cb, game); 121 game->end_timer = ecore_timer_add(3, _win_cb, game);
128} 122}
129 123
@@ -660,7 +654,7 @@ _create_target(Game *game, const char *type, int w, int h, int x, int y)
660 _target_dec, game); 654 _target_dec, game);
661 ephysics_body_event_callback_add(body, EPHYSICS_CALLBACK_BODY_DEL, 655 ephysics_body_event_callback_add(body, EPHYSICS_CALLBACK_BODY_DEL,
662 _body_del, NULL); 656 _body_del, NULL);
663 game->targets++; 657 game->targets = eina_list_append(game->targets, body);
664 658
665 DBG("Target created at (%i, %i)", x, y); 659 DBG("Target created at (%i, %i)", x, y);
666} 660}
@@ -694,6 +688,11 @@ static void
694level_unload(Game *game) 688level_unload(Game *game)
695{ 689{
696 Evas_Object *extra_object; 690 Evas_Object *extra_object;
691 EPhysics_Body *target;
692
693 EINA_LIST_FREE(game->targets, target)
694 ephysics_body_event_callback_del(target, EPHYSICS_CALLBACK_BODY_DEL,
695 _target_dec);
697 696
698 if (game->cur_world) 697 if (game->cur_world)
699 { 698 {
@@ -945,12 +944,13 @@ _wstopped(void *data, EPhysics_World *world __UNUSED__,
945 944
946 if (((cannon_ammo_get(game->cannon) > 0) || 945 if (((cannon_ammo_get(game->cannon) > 0) ||
947 (cannon_loaded_get(game->cannon))) && 946 (cannon_loaded_get(game->cannon))) &&
948 ((game->targets > 0) && (!level_time_attack_get(game->cur_level)))) 947 ((eina_list_count(game->targets)) &&
948 (!level_time_attack_get(game->cur_level))))
949 return; 949 return;
950 950
951 game->camera_moving = EINA_FALSE; 951 game->camera_moving = EINA_FALSE;
952 952
953 if (game->targets <= 0) 953 if (!eina_list_count(game->targets))
954 { 954 {
955 _level_win(game); 955 _level_win(game);
956 return; 956 return;
@@ -1000,7 +1000,6 @@ _level_load(Game *game)
1000 Eina_List *l; 1000 Eina_List *l;
1001 int hiscore; 1001 int hiscore;
1002 1002
1003 game->targets = 0;
1004 game->old_cx = 0; 1003 game->old_cx = 0;
1005 1004
1006 game->bg = bg_add(game->win, level_bg_get(game->cur_level)); 1005 game->bg = bg_add(game->win, level_bg_get(game->cur_level));