/* * stomach: * Digest the hero's food */ stomach() { register int oldfood; //MDK_LOG("status: food_left=%d\n", food_left); if (food_left <= 0) { if (food_left-- < -STARVETIME) death('s'); /* * the hero is fainting */ if (no_command || rnd(5) != 0) return; no_command += rnd(8) + 4; player.t_flags &= ~ISRUN; running = FALSE; count = 0; hungry_state = 3; if (on(player, ISTrip)) { if (!terse) addmsg("the munchies overpower your motor capabilities. "); msg("You freak out"); } else { if (!terse) addmsg("you feel too weak from lack of food. "); msg("You faint"); } } else { oldfood = food_left; food_left -= ring_eat(LEFT) + ring_eat(RIGHT) + 1 - amulet; if (food_left < MORETIME && oldfood >= MORETIME) { hungry_state = 2; if (on(player, ISTrip)) msg("the munchies are interfering with your motor capabilites"); else msg("you are starting to feel weak"); } else if (food_left < 2 * MORETIME && oldfood >= 2 * MORETIME) { hungry_state = 1; if (on(player, ISTrip)) { if (!terse) addmsg("you are "); msg("getting the munchies"); } else if (!terse) msg("you are starting to get hungry"); else msg("getting hungry"); } } }
/* * digest the hero's food */ stomach() { register int oldfood; if (food_left <= 0) { /* * the hero is fainting */ if (no_command || rnd(100) > 20) return; no_command = rnd(8)+4; if (!terse) addmsg("You feel too weak from lack of food. "); msg("You faint"); running = FALSE; count = 0; hungry_state = 3; } else { oldfood = food_left; food_left -= ring_eat(LEFT) + ring_eat(RIGHT) + 1 - amulet; if (food_left < MORETIME && oldfood >= MORETIME) { msg("You are starting to feel weak"); hungry_state = 2; } else if (food_left < 2 * MORETIME && oldfood >= 2 * MORETIME) { if (!terse) msg("You are starting to get hungry"); else msg("Getting hungry"); hungry_state = 1; } } }
void telnet_read_ring(DESC * client) { int iter, complete; unsigned char subopt_buffer[32]; dprintk ("Ring Read started, input length = %d, ringhead = %d, ringtail = %d. ", ring_length(client), client->ringhead, client->ringtail); while (ring_length(client) > 0) { dprintk ("Parsing data 0x%02x, %d bytes in ring, ringhead = %d, ringtail = %d", ring_char(client, 0), ring_length(client), client->ringhead, client->ringtail); switch (ring_char(client, 0)) { case TELNET_IAC: if(ring_length(client) < 2) return; dprintk("TELNET COMMADN %d", ring_char(client, 1)); switch ((unsigned char) ring_char(client, 1)) { case TELNET_WILL: telnet_handle_will(client, ring_char(client, 2)); ring_eat(client, 3); break; case TELNET_WONT: telnet_handle_wont(client, ring_char(client, 2)); ring_eat(client, 3); break; case TELNET_SB: complete = 0; for(iter = 2; !complete && iter < ring_avail(client); iter++) { subopt_buffer[iter - 2] = ring_char(client, iter); if(ring_char(client, iter) == TELNET_SE) { telnet_handle_subop(client, subopt_buffer, iter - 2); complete = 1; ring_eat(client, iter + 1); } } if(!complete) return; break; case TELNET_IAC: client->inputbuffer[client->inputtail++] = TELNET_IAC; default: ring_eat(client, 2); break; } break; case 0: ring_eat(client, 1); break; case '\r': case '\n': if(ring_length(client) > 1 && (ring_char(client, 1) == '\r' || ring_char(client, 1) == '\n')) { ring_eat(client, 1); } if(client->inputtail == 0) { ring_eat(client, 1); continue; } client->inputbuffer[client->inputtail] = 0; client_accept_input(client); dprintk("Would Parse: %s", client->inputbuffer); client->inputtail = 0; ring_eat(client, 1); break; default: client->inputbuffer[client->inputtail++] = ring_char(client, 0); ring_eat(client, 1); break; } } if(client->ringhead == client->ringtail) { client->ringhead = client->ringtail = 0; } telnet_check_options(client); dprintk ("Ring Read finished. RingState = { head = %d, tail = %d }, InputState = { tail = %d }", client->ringhead, client->ringtail, client->inputtail); }
daemon stomach(daemon_arg *arg) { int oldfood, old_hunger; int amount; int power_scale; NOOP(arg); old_hunger = hungry_state; if (food_left <= 0) { /* the hero is fainting */ if (no_command || rnd(100) > 20) return; no_command = rnd(8) + 4; running = FALSE; count = 0; hungry_state = F_FAINT; feed_me(hungry_state); } else { oldfood = food_left; amount = ring_eat(LEFT_1) + ring_eat(LEFT_2) + ring_eat(LEFT_3) + ring_eat(LEFT_4) + ring_eat(RIGHT_1) + ring_eat(RIGHT_2) + ring_eat(RIGHT_3) + ring_eat(RIGHT_4) + foodlev; if (on(player, SUPEREAT)) /* artifact or regeneration munchies */ amount *= 2; if (on(player, POWEREAT)) /* Used an artifact power */ { amount += 40; turn_off(player, POWEREAT); } power_scale = (on(player, POWERDEXT) + on(player, POWERSTR) + on(player, POWERWISDOM) + on(player, POWERINTEL) + on(player, POWERCONST) + 1); food_left -= amount * power_scale; if (food_left < MORETIME && oldfood >= MORETIME) { hungry_state = F_WEAK; running = FALSE; feed_me(hungry_state); } else if (food_left < 2 * MORETIME && oldfood >= 2 * MORETIME) { hungry_state = F_HUNGRY; running = FALSE; feed_me(hungry_state); } } if (old_hunger != hungry_state) updpack(); wghtchk(NULL); }
/* * digest the hero's food */ void stomach(void) { register int oldfood, old_hunger; register int amount; int power_scale; old_hunger = hungry_state; if (food_left <= 0) { /* * the hero is fainting */ if (no_command || rnd(100) > 20) return; no_command = rnd(8)+4; if (!terse) addmsg("You feel too weak from lack of food. "); msg("You faint."); running = FALSE; count = 0; hungry_state = F_FAINT; } else { oldfood = food_left; amount = ring_eat(LEFT_1) + ring_eat(LEFT_2) + ring_eat(LEFT_3) + ring_eat(LEFT_4) + ring_eat(RIGHT_1) + ring_eat(RIGHT_2) + ring_eat(RIGHT_3) + ring_eat(RIGHT_4) + foodlev; if (on(player, SUPEREAT)) amount *= 2; if (on(player, POWEREAT)) { amount += 40; turn_off(player, POWEREAT); } power_scale = on(player, POWERDEXT) + on(player, POWERSTR) + on(player, POWERWISDOM) + on(player, POWERINTEL) + on(player, POWERCONST) + 1; food_left -= amount * power_scale; if (food_left < MORETIME && oldfood >= MORETIME) { msg("You are starting to feel weak."); hungry_state = F_WEAK; } else if (food_left < 2 * MORETIME && oldfood >= 2 * MORETIME) { msg(terse ? "Getting hungry." : "You are starting to get hungry."); hungry_state = F_HUNGRY; } } if (old_hunger != hungry_state) updpack(TRUE); wghtchk(); }