summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordavemds <dave@gurumeditation.it>2014-01-23 20:38:45 +0100
committerdavemds <dave@gurumeditation.it>2014-01-23 20:38:45 +0100
commit4381b2d9bd27d2d7ccb1539d8c0042e7e77e3495 (patch)
tree799aea143756aaa35b1226857741b0795fda7758
parent2b090e72f8e7d4bd25e3f1bf98a1739699c1a51b (diff)
No need to keep the number of items in an Eina_List, eina_list_count is fast.
-rw-r--r--src/e_mod_penguins.c22
-rw-r--r--src/e_mod_penguins.h1
2 files changed, 10 insertions, 13 deletions
diff --git a/src/e_mod_penguins.c b/src/e_mod_penguins.c
index 48c131b..46fc643 100644
--- a/src/e_mod_penguins.c
+++ b/src/e_mod_penguins.c
@@ -242,14 +242,13 @@ _load_custom_action(Penguins_Population *pop, const char *filename, char *name)
242 c->r_min = r_min; 242 c->r_min = r_min;
243 c->r_max = r_max; 243 c->r_max = r_max;
244 244
245 pop->custom_num++; 245 pop->customs = eina_list_append(pop->customs, c);
246 snprintf(buf, sizeof(buf), "start_custom_%d_left", pop->custom_num); 246
247 snprintf(buf, sizeof(buf), "start_custom_%d_left", eina_list_count(pop->customs));
247 c->left_program_name = strdup(buf); 248 c->left_program_name = strdup(buf);
248 snprintf(buf, sizeof(buf), "start_custom_%d_right", pop->custom_num); 249 snprintf(buf, sizeof(buf), "start_custom_%d_right", eina_list_count(pop->customs));
249 c->right_program_name = strdup(buf); 250 c->right_program_name = strdup(buf);
250 251
251 pop->customs = eina_list_append(pop->customs, c);
252
253 return c; 252 return c;
254} 253}
255 254
@@ -262,7 +261,6 @@ _theme_load(Penguins_Population *pop)
262 261
263 pop->actions = NULL; 262 pop->actions = NULL;
264 pop->customs = NULL; 263 pop->customs = NULL;
265 pop->custom_num = 0;
266 264
267 name = edje_file_data_get(pop->conf->theme, "PopulationName"); 265 name = edje_file_data_get(pop->conf->theme, "PopulationName");
268 if (!name) return; 266 if (!name) return;
@@ -795,7 +793,7 @@ _cb_custom_end(void *data, Evas_Object *o, const char *emi, const char *src)
795{ 793{
796 Penguins_Actor* tux = data; 794 Penguins_Actor* tux = data;
797 795
798 //printf("PENGUINS: Custom action end.\n"); 796 printf("PENGUINS: Custom action end.\n");
799 if (!tux->custom) 797 if (!tux->custom)
800 return; 798 return;
801 799
@@ -820,11 +818,11 @@ _start_custom_at(Penguins_Actor *tux, int at_y)
820{ 818{
821 int ran; 819 int ran;
822 820
823 if (tux->pop->custom_num < 1) 821 if (eina_list_count(tux->pop->customs) < 1)
824 return; 822 return;
825 823
826 ran = random() % (tux->pop->custom_num); 824 ran = random() % (eina_list_count(tux->pop->customs));
827 //printf("START CUSTOM NUM %d RAN %d\n",tux->pop->custom_num, ran); 825 printf("START CUSTOM NUM %d RAN %d\n", eina_list_count(tux->pop->customs), ran);
828 826
829 tux->custom = eina_list_nth(tux->pop->customs, ran); 827 tux->custom = eina_list_nth(tux->pop->customs, ran);
830 if (!tux->custom) return; 828 if (!tux->custom) return;
@@ -844,8 +842,8 @@ _start_custom_at(Penguins_Actor *tux, int at_y)
844 else 842 else
845 edje_object_signal_emit(tux->obj, tux->custom->right_program_name, "epenguins"); 843 edje_object_signal_emit(tux->obj, tux->custom->right_program_name, "epenguins");
846 844
847 //printf("START Custom Action n %d (%s) repeat: %d\n", ran, tux->custom->left_program_name, tux->r_count); 845 printf("START Custom Action n %d (%s) repeat: %d\n", ran, tux->custom->left_program_name, tux->r_count);
848 846
849 edje_object_signal_callback_add(tux->obj,"custom_done","edje", _cb_custom_end, tux); 847 edje_object_signal_callback_add(tux->obj,"custom_done","edje", _cb_custom_end, tux);
850 848 printf("DONE\n");
851} 849}
diff --git a/src/e_mod_penguins.h b/src/e_mod_penguins.h
index 8d1c5f4..f27b3d1 100644
--- a/src/e_mod_penguins.h
+++ b/src/e_mod_penguins.h
@@ -18,7 +18,6 @@ typedef struct _Penguins_Population
18 Eina_List *penguins; // list of Penguins_Actor* 18 Eina_List *penguins; // list of Penguins_Actor*
19 Eina_Hash *actions; // key:action_name val:Penguins_Action* 19 Eina_Hash *actions; // key:action_name val:Penguins_Action*
20 Eina_List *customs; // list of Penguins_Custom_Action 20 Eina_List *customs; // list of Penguins_Custom_Action
21 int custom_num; // TODO: REMOVEME
22 21
23 E_Config_DD *conf_edd; 22 E_Config_DD *conf_edd;
24 Penguins_Config *conf; 23 Penguins_Config *conf;