/* * Apply abilities to be granted this level */ void apply_level_abilities(s32b level) { s32b z, i; /***** Apply each descriptors abilities, in order *****/ for (z = 1; z <= flag_max_key(&p_ptr->descriptors); z++) { player_descriptor *d_ptr = &descriptor_info[flag_get(&p_ptr->descriptors, z)]; /* Check all the */ for (i = 0; i < d_ptr->abilities.size; i++) { flag_node *n = &d_ptr->abilities.node[i]; if (n->flags & FLAG_FLAG_USED) { if (flag_get(&d_ptr->abilities, n->key) == level) { if ((level > 1) && (!ab_info[n->key].acquired)) cmsg_format(TERM_L_GREEN, "You have learned the ability '%s'.", ab_info[n->key].name); ab_info[n->key].acquired = TRUE; } } } } }
/* * Calc which body parts the player have, based on the * monster he incarnate, note that that's bnot a hack * since body parts of the player when in it's own body * are also defined in r_info(monster 0) */ void calc_body() { monster_type *body = &p_ptr->body_monster; monster_race *r_ptr = &r_info[body->r_idx]; s32b i; if (p_ptr->body_monster.r_idx == 0) { /* Setup for player race */ for (i = 0; i < INVEN_TOTAL; i++) { /* Get the race/subrace slots */ s32b max = flag_get(&p_ptr->descriptor.body_parts, i); if (max < 0) max = 0; flag_set(get_inven(p_ptr, i), INVEN_LIMIT_KEY, max); } } else { /* Setup for monster race */ for (i = 0; i < INVEN_TOTAL; i++) { s32b max = flag_get(&r_ptr->body_parts, i); if (max < 0) max = 0; flag_set(get_inven(p_ptr, i), INVEN_LIMIT_KEY, max); } } /* Do we need more parts ? ;) */ process_hooks(HOOK_BODY_PARTS, "()"); /* Ok now if the player lost a body part, he must drop the object he had on it */ for (i = 0; i < INVEN_TOTAL; i++) { flags_type *inven = get_inven(p_ptr, i); s32b j; /* For all objects that are in excess, drop them */ for (j = flag_max_key(inven); j > inventory_limit_inven(inven); j--) { /* Drop it NOW ! */ if (i > INVEN_INVEN) inven_takeoff(compute_slot(i, j), 255, TRUE, FALSE); else inven_drop(compute_slot(i, j), 255, p_ptr->py, p_ptr->px, FALSE); } } }
void scene::update_hierarchy(bool forced) { if(!forced && !flag_get(FRAME_NEEDS_UPDATE_HIERARCHY)) return; SCENE_OBJECT *p_obj; // Update all positions of local objects OBJECT_HIERARCHY_ITERATOR it = render_hierarchy_next_new(); while((p_obj = render_hierarchy_next(&it))) { if(p_obj->object_is_geometry()) { ((SCENE_OBJECT_GEOMETRY *)p_obj)->object_world_hierarchy_update(forced); } } // Update complete hierarchy int changed = 0; it = render_hierarchy_next_new(); while((p_obj = render_hierarchy_next(&it))) { if(p_obj->object_is_geometry()) { changed += ((SCENE_OBJECT_GEOMETRY *)p_obj)->object_box_hierarchy_update(forced); } } flag_clear(FRAME_NEEDS_UPDATE_HIERARCHY); if(changed) { flag_set(SCENE_NEEDS_UPDATE_BOX); } }
/* Ask & execute a power */ void do_cmd_power() { s32b x_idx; power_type *x_ptr; bool push = TRUE; /* Get the skill, if available */ if (repeat_pull(&x_idx)) { if ((x_idx < 0) || (x_idx >= power_max)) return; x_ptr = &powers_type[x_idx]; push = FALSE; } else if (!command_arg) x_ptr = select_power(&x_idx); else { x_idx = command_arg - 1; if ((x_idx < 0) || (x_idx >= power_max)) return; x_ptr = &powers_type[x_idx]; } if (x_ptr == NULL) return; if (push) repeat_push(x_idx); if (flag_get(&p_ptr->powers, x_idx)) power_activate(x_idx); else msg_print("You do not have access to this power."); }
void mesh_geometry::draw_normals(void) { lock(); if(position_get()) { if(flag_get(GEOMETRY_NORMALS_DIRTY)) normals_update(); int i,vertexnum = vertexnum_get(); VECT *p_vert = position_get(); VECT *p_norm = normal_get(); if(p_norm == NULL) return; mesh_material::set_default(); glColor3f(0.0f,0.0f,1.0f); glBegin(GL_LINES); for(i = 0; i < vertexnum; i++) { glVertex3fv((float *)(p_vert+i)); VECT endpoint = p_norm[i]*10.0f; endpoint += p_vert[i]; glVertex3fv((float *)(&endpoint)); } glEnd(); } unlock(); }
void scene::update_box(bool forced) { if(!forced && !flag_get(SCENE_NEEDS_UPDATE_BOX)) return; scene_box_update(); flag_clear(SCENE_NEEDS_UPDATE_BOX); }
void scene::update_animations(bool forced) { if(!forced && !flag_get(FRAME_NEEDS_UPDATE_ANIMATIONS)) return; flag_clear(FRAME_NEEDS_UPDATE_ANIMATIONS); }
/* * Recalc the skill value */ void recalc_skills_theory(s16b *invest, s32b *base_val, s32b *base_mod, s32b *bonus) { s32b i, j; /* First we assign the normal points */ for (i = 0; i < max_s_idx; i++) { /* Calc the base */ s_info[i].value = base_val[i] + (base_mod[i] * invest[i]) + bonus[i]; /* It cannot exceed SKILL_MAX */ if (s_info[i].value > SKILL_MAX) s_info[i].value = SKILL_MAX; } /* Then we modify related skills */ for (i = 0; i < max_s_idx; i++) { for (j = 1; j < max_s_idx; j++) { /* Ignore self */ if (j == i) continue; /* Exclusive skills */ if ((flag_get(&s_info[i].action, j) == SKILL_EXCLUSIVE) && invest[i]) { /* Turn it off */ p_ptr->skill_points += invest[j]; invest[j] = 0; s_info[j].value = 0; } /* Non-exclusive skills */ else if (flag_get(&s_info[i].action, j)) { /* Increase / decrease with a % */ s32b val = s_info[j].value + (invest[i] * s_info[j].mod * flag_get(&s_info[i].action, j) / 100); /* It cannot exceed SKILL_MAX */ if (val > SKILL_MAX) val = SKILL_MAX; /* Save the modified value */ s_info[j].value = val; } } } }
/* * Gets the base value of a skill, given a race/class/... */ void compute_skills(s32b *v, s32b *m, s32b i) { s32b z; s32b value, mod; /***** Apply each descriptors skills, in order *****/ for (z = 1; z <= flag_max_key(&p_ptr->descriptors); z++) { player_descriptor *d_ptr = &descriptor_info[flag_get(&p_ptr->descriptors, z)]; value = flag_get(&d_ptr->skill_base, i); mod = flag_get(&d_ptr->skill_mod, i); *v = modify_aux(*v, value, flag_get2(&d_ptr->skill_base, i)); *m = modify_aux(*m, mod, flag_get2(&d_ptr->skill_mod, i)); } }
/* * Apply special make code */ static void invoke_on_make(flags_type *flags, object_type *o_ptr, s32b power) { if (flag_exists(flags, FLAG_ON_MAKE)) { open_lua_functions_registry(flag_get(flags, FLAG_ON_MAKE), flag_get2(flags, FLAG_ON_MAKE)); call_lua(NULL, "(O,d)", "", o_ptr, power); close_lua_functions_registry(); } }
/*! The main function. */ void job_on_the_field(struct programs_t *progs, struct debug_t *debug, struct tm *tm_clock) { if (flag_get(progs, FL_LED)) led_set(GREEN, ON); if (flag_get(progs, FL_LOG)) { debug_print_P(PSTR("Executing programs at "), debug); date(debug); } prog_run(progs, tm_clock, debug); if (prog_alarm(progs)) { if (flag_get(progs, FL_LED)) led_set(RED, BLINK); if (flag_get(progs, FL_LOG)) debug_print_P(PSTR("ALARM! queue run skipped!\n"), debug); } else { if (flag_get(progs, FL_LOG)) { debug_print_P(PSTR("Run queue at "), debug); date(debug); } queue_run(progs, tm_clock, debug); } /* print the temperature updated * from the prog_run call */ if (flag_get(progs, FL_LOG)) temperature_print(progs, debug); led_set(GREEN, OFF); }
/* * Make a treasure object * * The location must be a legal, clean, floor grid. */ bool make_gold(object_type *j_ptr) { s32b i; s32b k_idx; s32b base; /* First time set up the list of TV_GOLD svals */ if (!gold_list) init_gold_list(); /* Hack -- Pick a Treasure variety */ i = ((randint(object_level + 2) + 2) / 2) - 1; /* Apply "extra" magic */ if (rand_int(GREAT_OBJ) == 0) { i += randint(object_level + 1); } /* Hack -- Creeping Coins only generate "themselves" */ if (coin_type) i = coin_type; /* Do not create "illegal" Treasure Types */ if (i > flag_max_key(gold_list)) i = flag_max_key(gold_list); /* lookup the i'th SV from gold_list and use that */ k_idx = flag_get(gold_list, i); /* Prepare a gold object */ object_prep(j_ptr, k_idx); /* Base coin cost from flag */ base = flag_get(&k_info[k_idx].flags,FLAG_GOLD_VALUE); /* Determine how much the treasure is "worth" (maybe use getter.random instead?) */ flag_set(&j_ptr->flags, FLAG_GOLD_VALUE, (base + randint(base))); /* Success */ return (TRUE); }
void mesh_geometry::normals_update(bool force) { if((force || flag_get(GEOMETRY_NORMALS_DIRTY)) && vertexnum_get() && facenum_get()) { lock(); normals_calc(position_get(),vertexnum_get(), faces_get(),facenum_get(), normal_get()); unlock(); flag_set(GEOMETRY_NORMALS_DIRTY); } }
NODE *addpts(NODE * zero, int r, int c, int rr, int cc, int *node_ct) { NODE *add_in(); if (rr < nrows - 1) { if (!flag_get(seen, rr + 1, cc)) zero = add_in(r, c, rr + 1, cc, zero, node_ct); } if (cc < ncols - 1) { if (!flag_get(seen, rr, cc + 1)) zero = add_in(r, c, rr, cc + 1, zero, node_ct); } if (rr > 0) { if (!flag_get(seen, rr - 1, cc)) zero = add_in(r, c, rr - 1, cc, zero, node_ct); } if (cc > 0) { if (!flag_get(seen, rr, cc - 1)) zero = add_in(r, c, rr, cc - 1, zero, node_ct); } return (zero); }
// ******************************** // Mesh geometry // ******************************** void mesh_geometry::box_update(bool force) { if((force || flag_get(GEOMETRY_BOX_DIRTY)) && vertexnum_get() && facenum_get()) { if(!p_box) { p_box = box_create(box_type); } lock(); p_box->set(position_get(), vertexnum_get(), faces_get(), facenum_get()); unlock(); flag_clear(GEOMETRY_BOX_DIRTY); box_change_set(); } }
void radare_search_seek_hit(int idx) { flag_t *flag; char buf[64]; radare_flag_name (buf, 0, hit_idx); flag = flag_get(buf); if (flag == NULL) { if (idx>0) hit_idx -= idx; } else radare_seek(flag->offset, SEEK_SET); hit_idx += idx; if (hit_idx<1) hit_idx=1; }
/* * Gets friend_faction friendly rating friendly toward faction * >0 means friend, =0 means neutral, <0 means ennemy */ s32b get_faction_friendliness(u32b faction, u32b friend_faction) { flags_type *faction_table; /* We love each others !*/ if (faction == friend_faction) return 100; /* Get the factions table, make if unexisting */ if (!flag_exists(&factions, faction)) { faction_table = flag_new(2); flag_set_flags(&factions, faction, faction_table); } else faction_table = flag_get_flags(&factions, faction); /* If not present defaults to 0(neutral) */ return flag_get(faction_table, friend_faction); }
void scene::update_renderlist(bool forced) { if(!forced && !flag_get(FRAME_NEEDS_UPDATE_RENDERLIST)) return; int rendered = 0; render_list.render_list_head_init(); OBJECT_HIERARCHY_ITERATOR it = render_hierarchy_next_new(); SCENE_OBJECT *p_obj; while((p_obj = render_hierarchy_next(&it))) { if(p_obj->object_is_rendered()) { if(((SCENE_OBJECT_GEOMETRY *)p_obj)->visible()) { render_list.render_list_insert(p_obj); rendered++; } } } flag_clear(FRAME_NEEDS_UPDATE_RENDERLIST); }
static power_type* select_power(s32b *x_idx) { s32b which; s32b max = 0, i, start = 0; power_type* ret; bool mode = easy_inven; s32b *p; C_MAKE(p, power_max, s32b); /* Count the max */ for (i = 0; i < power_max; i++) { if (flag_get(&p_ptr->powers, i)) { p[max++] = i; } } /* Exit if there aren't powers */ if (max == 0) { *x_idx = -1; ret = NULL; msg_print("You don't have any special powers."); } else { character_icky++; Term_save(); while (1) { print_power_batch(p, start, max, mode); which = inkey(); if (which == ESCAPE) { *x_idx = -1; ret = NULL; break; } else if (which == '*' || which == '?' || which == ' ') { mode = (mode) ? FALSE : TRUE; Term_load(); character_icky--; } else if (which == '+') { start += 20; if (start >= max) start -= 20; Term_load(); character_icky--; } else if (which == '-') { start -= 20; if (start < 0) start += 20; Term_load(); character_icky--; } else { which = tolower(which); if (start + A2I(which) >= max) { bell(); continue; } if (start + A2I(which) < 0) { bell(); continue; } *x_idx = p[start + A2I(which)]; ret = &powers_type[p[start + A2I(which)]]; break; } } Term_load(); character_icky--; } C_FREE(p, power_max, s32b); return ret; }
int find_con(int r, int c, double *d1, double *d2, DCELL * con1, DCELL * con2) { int ct, low_ct, node_ct; int rr, cc, dor, doc; double dd, shortest; DCELL value; G_set_d_null_value(con1, 1); G_set_d_null_value(con2, 1); *d1 = *d2 = 1.0; shortest = nrows * ncols; for (rr = minr; rr <= maxr; rr++) { for (cc = minc; cc <= maxc; cc++) FLAG_UNSET(seen, rr, cc); } minr = nrows; minc = ncols; maxr = maxc = -1; FLAG_SET(seen, r, c); if (r < minr) minr = r; if (r > maxr) maxr = r; if (c < minc) minc = c; if (c > maxc) maxc = c; node_ct = 0; zero = addpts(zero, r, c, r, c, &node_ct); low_ct = 0; while (1) { ct = low_ct++; if (node_ct <= ct) return 1; rr = zero[ct].r; cc = zero[ct].c; dor = ABS(rr - r); doc = ABS(cc - c); if (rr >= 0 && cc >= 0 && rr < nrows && cc < ncols && zero[ct].d < shortest && !flag_get(mask, rr, cc)) { dseg_get(&con, rr, cc, &value); if (G_is_d_null_value(&value)) zero = addpts(zero, r, c, rr, cc, &node_ct); else if (G_is_d_null_value(con1)) { *con1 = value; *d1 = MIN(dor, doc) * 1.414 + ABS(dor - doc); shortest = *d1 * 2.0 * i_val_l_f; } else if (*con1 == value) { dd = MIN(dor, doc) * 1.414 + ABS(dor - doc); if (dd < *d1) { *d1 = dd; shortest = dd * 2.0 * i_val_l_f; } } else if (G_is_d_null_value(con2)) { *con2 = value; *d2 = MIN(dor, doc) * 1.414 + ABS(dor - doc); shortest = *d2; } else { dd = MIN(dor, doc) * 1.414 + ABS(dor - doc); shortest = MIN(shortest, dd); } } } return 0; }
s32b get_skill_raw(s32b skill) { return (skill > -1) ? s_info[skill].value + flag_get(&p_ptr->skill_bonuses, skill) : 0; }
static int config_init(const int argc, const char **argv, struct st_config *c) { c->script = argv[ARGC_SCRIPTFILE]; c->romimage = NULL; c->ramimage = NULL; c->mapper = CONFIG_OVERRIDE_UNDEF; c->mirror = CONFIG_OVERRIDE_UNDEF; c->backupram = CONFIG_OVERRIDE_UNDEF; c->mapper = CONFIG_OVERRIDE_UNDEF; c->syntaxtest = 0; c->cpu_flash_driver = &FLASH_DRIVER_UNDEF; c->ppu_flash_driver = &FLASH_DRIVER_UNDEF; c->write_wait = 0; //mode 別 target file 初期化 switch(argv[ARGC_MODE][0]){ case 'd': c->mode = MODE_ROM_DUMP; c->romimage = argv[ARGC_DUMP_OUT_NESFILE]; break; case 'r': c->mode = MODE_RAM_READ; c->ramimage = argv[ARGC_READ_OUT_RAMFILE]; break; case 'w': c->mode = MODE_RAM_WRITE; c->ramimage = argv[ARGC_WRITE_IN_RAMFILE]; break; case 'f': c->mode = MODE_ROM_PROGRAM; c->romimage = argv[ARGC_PROGRAM_IN_NESFILE]; //容量が少ない ROM の詰め方のカスタマイズ switch(argv[ARGC_MODE][1]){ case '\0': c->transtype_cpu = VALUE_TRANSTYPE_TOP; c->transtype_ppu = VALUE_TRANSTYPE_TOP; break; case 't': c->transtype_cpu = VALUE_TRANSTYPE_TOP; break; case 'b': c->transtype_cpu = VALUE_TRANSTYPE_BOTTOM; break; default: printf("%s unkown flash trans mode cpu %c\n", PREFIX_CONFIG_ERROR, argv[ARGC_MODE][1]); return NG; } if(argv[ARGC_MODE][1] == '\0'){ break; } switch(argv[ARGC_MODE][2]){ case '\0': case 't': c->transtype_ppu = VALUE_TRANSTYPE_TOP; break; case 'b': c->transtype_ppu = VALUE_TRANSTYPE_BOTTOM; break; default: printf("%s unkown flash trans mode ppu %c\n", PREFIX_CONFIG_ERROR, argv[ARGC_MODE][2]); return NG; } break; case 't': if(DEBUG == 1){ c->mode = MODE_TEST; break; } //下へ default: printf("%s unkown mode %s\n", PREFIX_CONFIG_ERROR, argv[ARGC_MODE]); return NG; }; if(config_file_load(c) == NG){ return NG; } /*mode 別 argc check. DEBUG==0 argc: 4,5,6 DEBUG==1 argc: 3,4,5,6 */ switch(c->mode){ case MODE_ROM_DUMP:{ int flag_error = OK, mapper_error = OK; switch(argc){ case 3: return NG; case 5: flag_error = flag_get(argv[ARGC_DUMP_FLAG], c); break; case 6: flag_error = flag_get(argv[ARGC_DUMP_FLAG], c); mapper_error = value_get(argv[ARGC_DUMP_MAPPER], &c->mapper); break; } if(flag_error != OK){ printf("%s unknown flag %s\n", PREFIX_CONFIG_ERROR, argv[ARGC_DUMP_FLAG]); return NG; } if(mapper_error != OK){ printf("%s unknown mapper %s\n", PREFIX_CONFIG_ERROR, argv[ARGC_DUMP_MAPPER]); return NG; } }break; case MODE_RAM_READ: case MODE_RAM_WRITE: if(argc != ARGC_RW_NUM){ printf("%s too many argument\n", PREFIX_CONFIG_ERROR); return NG; } break; case MODE_ROM_PROGRAM: if(c->reader->flash_support == false){ puts("this reader is not supported flash memory programming mode"); return NG; } switch(argc){ case 3: case 4: printf("%s few argument\n", PREFIX_CONFIG_ERROR); return NG; case 5: if(flash_pointer_init(argv[ARGC_PROGRAM_CPU_DEVICE], &(c->cpu_flash_driver)) == NG){ return NG; } break; case 6: if(flash_pointer_init(argv[ARGC_PROGRAM_CPU_DEVICE], &(c->cpu_flash_driver)) == NG){ return NG; } if(flash_pointer_init(argv[ARGC_PROGRAM_PPU_DEVICE], &(c->ppu_flash_driver)) == NG){ return NG; } break; } break; } return OK; }
void do_get_new_skill() { char *items[4]; s32b skl[4]; s32b val[4], mod[4]; bool *used; s32b *available_skills; s32b max = 0, max_a = 0, res, i; C_MAKE(used, max_s_idx, bool); C_MAKE(available_skills, max_s_idx, s32b); /* Check if some skills didn't influence other stuff */ recalc_skills(TRUE); /* Grab the ones we can gain */ max = 0; for (i = 0; i < max_s_idx; i++) { if (has_flag(&s_info[i], FLAG_RANDOM_GAIN)) available_skills[max++] = i; } available_skills[max++] = -1; /* Init */ for (max = 0; max < max_s_idx; max++) { used[max] = FALSE; } /* Count the number of available skills */ while (available_skills[max_a] != -1) max_a++; /* Get 4 skills */ for (max = 0; max < 4; max++) { s32b i; skill_type *s_ptr; /* Get an non used skill */ do { i = rand_int(max_a); /* Does it pass the check? */ if (!magik(get_flag(&s_info[i], FLAG_RANDOM_GAIN))) continue; } while (used[available_skills[i]]); s_ptr = &s_info[available_skills[i]]; used[available_skills[i]] = TRUE; if (s_ptr->mod) { if (s_ptr->mod < 500) { val[max] = s_ptr->mod * 1; mod[max] = 100; if (mod[max] + s_ptr->mod > 500) mod[max] = 500 - s_ptr->mod; } else { val[max] = s_ptr->mod * 3; mod[max] = 0; } } else { mod[max] = 300; val[max] = 1000; } if (s_ptr->value + val[max] > SKILL_MAX) val[max] = SKILL_MAX - s_ptr->value; skl[max] = available_skills[i]; items[max] = (char *)string_make(format("%-40s: +%02ld.%03ld value, +%01d.%03d modifier", s_ptr->name, val[max] / SKILL_STEP, val[max] % SKILL_STEP, mod[max] / SKILL_STEP, mod[max] % SKILL_STEP)); } while (TRUE) { res = ask_menu("Choose a skill to learn(a-d to choose, ESC to cancel)?", (char **)items, 4); /* Ok ? lets learn ! */ if (res > -1) { skill_type *s_ptr; bool oppose = FALSE; s32b oppose_skill = -1; /* Check we don't oppose an existing skill */ for (i = 0; i < max_s_idx; i++) { if ((flag_get(&s_info[i].action, skl[res]) == SKILL_EXCLUSIVE) && (s_info[i].value != 0)) { oppose = TRUE; oppose_skill = i; break; } } /* Ok we oppose, so be sure */ if (oppose) { cptr msg; /* * Because this is SO critical a question, we must flush * input to prevent killing character off -- pelpel */ flush(); /* Prepare prompt */ msg = format("This skill is mutually exclusive with " "at least %s, continue?", s_info[oppose_skill].name); /* The player rejected the choice */ if (!get_check(msg)) continue; } s_ptr = &s_info[skl[res]]; s_ptr->value += val[res]; s_ptr->mod += mod[res]; if (mod[res]) { msg_format("You can now learn the %s skill.", s_ptr->name); } else { msg_format("Your knowledge of the %s skill increases.", s_ptr->name); } break; } } /* Free them ! */ for (max = 0; max < 4; max++) { string_free(items[max]); } /* Check if some skills didn't influence other stuff */ recalc_skills(FALSE); C_FREE(used, max_s_idx, bool); C_FREE(available_skills, max_s_idx, s32b); }
/*! main */ int main(void) { struct debug_t *debug; struct programs_t *progs; struct cmdli_t *cmdli; /* convenient pre-allocated structure */ struct tm *tm_clock; char c; /* anti warning for non initialized variables */ debug = NULL; progs = NULL; cmdli = NULL; tm_clock = NULL; /* Init sequence, turn on both led */ led_init(); led_set(BOTH, ON); io_init(); usb_init(); debug = debug_init(debug); progs = prog_init(progs); cmdli = cmdli_init(cmdli); tm_clock = date_init(tm_clock, debug); set_sleep_mode(SLEEP_MODE_PWR_SAVE); sei(); date_hwclock_start(); led_set(BOTH, OFF); while (1) { /* PC is connected but debug is off. */ if (usb_connected && (!debug->active)) debug_start(debug); if (debug->active && (!usb_connected)) debug_stop(debug); /* If PC is connected * then check for a command sent from the user * and execute it. * Anyway do NOT go to sleep. */ if (debug->active) { c = uart_getchar(0, 0); if (c) { /* echo */ uart_putchar(0, c); cmdli_exec(c, cmdli, progs, debug); } } else { go_to_sleep(progs->valve, debug); if (prog_alarm(progs) && flag_get(progs, FL_LED)) led_set(RED, BLINK); } /* if there is a job to do (open, close valves). */ if (date_timetorun(tm_clock, debug)) job_on_the_field(progs, debug, tm_clock); } /* This part should never be reached */ date_hwclock_stop(); cli(); date_free(tm_clock); cmdli_free(cmdli); prog_free(progs); debug_free(debug); return(0); }