int main(int argc, char *argv[]) { char* line = NULL; size_t len = 0; ssize_t read; char action[8]; int lights[1000][1000]; int from[2] = {0, 0}; int to[2] = {0, 0}; init(lights); while ((read = getline(&line, &len, stdin)) != -1) { sscanf(line, "%[ togleurnf] %d,%d through %d,%d", action, &from[0], &from[1], &to[0], &to[1]); if (strcmp(action, "turn on ") == 0) { turn_on(lights, from, to); } else if (strcmp(action, "turn off ") == 0) { turn_off(lights, from, to); } else if (strcmp(action, "toggle ") == 0) { toggle(lights, from, to); } else { puts("bad action"); return 1; } } printf("%d\n", count(lights)); return 0; }
void electrificate(void) { int affect_dist = 4 + player.t_stats.s_lvl / 4; struct linked_list *item, *nitem; for (item = mlist; item != NULL; item = nitem) { struct thing *tp = THINGPTR(item); char *mname = monsters[tp->t_index].m_name; nitem = next(item); if (DISTANCE(tp->t_pos, hero) < affect_dist) { int damage = roll(2, player.t_stats.s_lvl); debug("Charge does %d (%d)", damage, tp->t_stats.s_hpt - damage); if (on(*tp, NOBOLT)) continue; if ((tp->t_stats.s_hpt -= damage) <= 0) { msg("The %s is killed by an electric shock.", mname); killed(&player, item, NOMESSAGE, POINTS); continue; } if (rnd(tp->t_stats.s_intel / 5) == 0) { turn_on(*tp, ISFLEE); msg("The %s is shocked by electricity.", mname); } else msg("The %s is zapped by your electricity.", mname); summon_help(tp, NOFORCE); turn_off(*tp, ISFRIENDLY); turn_off(*tp, ISCHARMED); turn_on(*tp, ISRUN); turn_off(*tp, ISDISGUISE); chase_it(&tp->t_pos, &player); fighting = after = running = FALSE; } } }
fuse scent(fuse_arg *arg) { NOOP(arg); turn_off(player, ISUNSMELL); msg("You begin to smell the damp dungeon air again."); }
fuse unscent(fuse_arg *arg) { NOOP(arg); turn_off(player, CANSCENT); msg("The smell of monsters goes away."); }
fuse unsupereat(fuse_arg *arg) { NOOP(arg); turn_off(player, SUPEREAT); msg("You stop feeling so hungry."); }
/* * shero: * restore lost abilities from cursed potion of shero */ void shero(void) { msg("You feel normal again."); chg_str(2, FALSE, TRUE); chg_dext(2, FALSE, TRUE); turn_off(player, ISUNHERO); }
/* * undisguise: * player stops looking like a monster */ void undisguise(void) { msg("Your skin feels itchy for a moment."); turn_off(player, ISDISGUISE); PLAYER = VPLAYER; light(&hero); }
/* * unbhero: * super heroism wears off, but no bad effects */ void unbhero(void) { msg("Your feeling of invincibility goes away."); turn_off(player, SUPERHERO); chg_str(-10, FALSE, FALSE); chg_dext(-5, FALSE, FALSE); }
/* * appear: * Become visible again */ void appear(void) { turn_off(player, ISINVIS); PLAYER = VPLAYER; msg("The tingling feeling leaves your body."); light(&hero); }
/* * daemon for curing the diseased */ void cure_disease(void) { turn_off(player, HASDISEASE); if (off (player, HASINFEST)) msg(terse ? "You feel yourself improving." : "You begin to feel yourself improving again."); }
/* * unphase: * Player can no longer walk through walls */ void unphase(void) { turn_off(player, CANINWALL); msg("Your dizzy feeling leaves you."); if (!step_ok(hero.y, hero.x, NOMONST, &player)) death(D_PETRIFY); }
/* * unsee: * He lost his see invisible power */ void unsee(void) { if (!ISWEARING(R_SEEINVIS)) { turn_off(player, CANSEE); msg("The tingling feeling leaves your eyes."); } }
fuse unhear(fuse_arg *arg) { NOOP(arg); turn_off(player, CANHEAR); msg("The sounds of monsters fades away."); }
fuse unmshield(fuse_arg *arg) { NOOP(arg); turn_off(player, HASMSHIELD); msg("The fog dissapates."); }
fuse hear(fuse_arg *arg) { NOOP(arg); turn_off(player, ISDEAF); msg("You can hear again."); }
fuse ungaze(fuse_arg *arg) { NOOP(arg); msg("The shiny particles swirl to the floor."); turn_off(player, CANREFLECT); }
fuse noslow(fuse_arg *arg) { NOOP(arg); turn_off(player, ISSLOW); msg("You feel yourself speeding up."); }
fuse nohaste(fuse_arg *arg) { NOOP(arg); turn_off(player, ISHASTE); msg("You feel yourself slowing down."); }
fuse unclrhead(fuse_arg *arg) { NOOP(arg); turn_off(player, ISCLEAR); msg("The blue aura about your head fades away."); }
fuse unconfuse(fuse_arg *arg) { NOOP(arg); turn_off(player, ISHUH); msg("You feel less confused now."); return; }
/* * daemon for adding back dexterity */ void un_itch(void) { if (lost_dext) { chg_dext(lost_dext, FALSE, FALSE); lost_dext = 0; turn_off(player, HASITCH); } }
fuse unelectrify(fuse_arg *arg) { NOOP(arg); turn_off(player, ISELECTRIC); msg("The sparks and violet glow from your body fade away."); light(&hero); }
void close () { if (fd >= 0) { turn_off (); // close (fd); tcp_abort (fd); fd = -1; } }
nevil::object::object(int x, int y, double size_x, double size_y , double height, const Enki::Color &off_color, const Enki::Color &on_color) : _off_color(off_color) , _on_color(on_color) { pos = Enki::Point(x, y); setRectangular(size_x, size_y, height, -1); turn_off(); }
static void gb_vibrator_worker(struct work_struct *work) { struct delayed_work *delayed_work = to_delayed_work(work); struct gb_vibrator_device *vib = container_of(delayed_work, struct gb_vibrator_device, delayed_work); turn_off(vib); }
fuse unhot(fuse_arg *arg) { NOOP(arg); turn_off(player, NOFIRE); if (!is_wearing(R_FIRERESIST)) msg("You feel a flush of warmth."); }
fuse unfly(fuse_arg *arg) { NOOP(arg); turn_off(player, CANFLY); if (!is_wearing(R_LEVITATION)) msg("You float gently to the ground."); }
fuse unshield(fuse_arg *arg) { NOOP(arg); turn_off(player, HASSHIELD); pstats.s_arm -= pstats.s_acmod; pstats.s_acmod = 0; msg("Your skin feels normal."); }
fuse unbreathe(fuse_arg *arg) { NOOP(arg); turn_off(player, HASOXYGEN); if (!is_wearing(R_BREATHE)) msg("You start huffing and puffing."); }
fuse unregen(fuse_arg *arg) { NOOP(arg); turn_off(player, ISREGEN); if (!is_wearing(R_REGEN)) msg("Your metabolism slows down."); }