static bool _has_spells(int realm, int book) { int i; for (i = 0; i < 8; i++) { int s_idx = book * 8 + i; magic_type *s_ptr; if (is_magic(realm)) s_ptr = &mp_ptr->info[realm - 1][s_idx]; else s_ptr = &technic_info[realm - MIN_TECHNIC][s_idx]; if (s_ptr->slevel >= 99) continue; if (p_ptr->pclass == CLASS_SORCERER || p_ptr->pclass == CLASS_RED_MAGE) { if (s_ptr->slevel > p_ptr->max_plv) continue; else if (s_ptr->slevel > p_ptr->lev) return TRUE; } else if ((realm == p_ptr->realm1) ? ((p_ptr->spell_forgotten1 & (1L << s_idx))) : ((p_ptr->spell_forgotten2 & (1L << s_idx)))) { return TRUE; } else if (realm == p_ptr->realm1 ? (p_ptr->spell_learned1 & (1L << s_idx)) : (p_ptr->spell_learned2 & (1L << s_idx))) { return TRUE; } } return FALSE; }
static void _spoil_spell_book(doc_ptr doc, int class_idx, int realm_idx, int book_idx) { int spell_idx; int k_idx = lookup_kind(realm2tval(realm_idx), book_idx); player_magic *magic_ptr = &m_info[class_idx]; doc_printf(doc, "<color:o>%-25.25s</color><color:G> Lvl Cst Fail </color>\n", k_name + k_info[k_idx].name); for (spell_idx = book_idx*8; spell_idx < (book_idx+1)*8; spell_idx++) { magic_type *spell_ptr = NULL; if (is_magic(realm_idx)) spell_ptr = &magic_ptr->info[realm_idx - 1][spell_idx]; else spell_ptr = &technic_info[realm_idx - MIN_TECHNIC][spell_idx]; if (0 < spell_ptr->slevel && spell_ptr->slevel <= PY_MAX_LEVEL) { doc_printf(doc, "%-25.25s %3d %3d %3d%%\n", do_spell(realm_idx, spell_idx, SPELL_NAME), spell_ptr->slevel, spell_ptr->smana, spell_ptr->sfail ); } else { doc_printf(doc, "<color:D>%-26.26s</color>\n", "Illegible"); } } doc_newline(doc); }
pinfo_init() { register int end, i; if (!is_magic()) { end = dpgline[0]; for (i = 1; i <= end; i++) pageptr[(hpgline[i])] = '\0'; end = dpgattr[0] >> 1; for (i = 0; i < end; i++) { pageptr[PGTLRG+i] = (char)FALSE; pageptr[PGTCNT+i] = (char)FALSE; } pageptr[HPNPBOT] = pageptr[HPNPCENT] = (char)TRUE; pageptr[HPNPTOP] = pageptr[HPNPALT] = pageptr[HPNPLEFT] = pageptr[HPNPRIGT] = (char)FALSE; ((int*)pageptr)[HPNOFF] = ((int*)pageptr)[HMNOFF] = 0; pageptr[HROUGH] = (char)FALSE; end = doptradio[0]; for (i = 2; i <= end; i += 2) { pageptr[(hoptradio[i])] = (char)FALSE; pageptr[(hoptradio[i+1])] = (char)TRUE; } size_systems(); pageptr[PSYSUSR] = (char)sysrec; set_magic(); }
void magic( square *a ) { int i = 0; while ( !is_magic( a ) ) { permute(a); printf("%d, ", i++); } }
int main(void) { char num[12]; scanf("%s", num); if(is_magic(num)) printf("YES\n"); else printf("NO\n"); return 0; }
idxdim read_matrix_header(FILE *fp, int &magic) { int ndim, v, magic_vincent; int ndim_min = 3; // std header requires at least 3 dims even empty ones. idxdim dims; // read magic number if (fread(&magic, sizeof (int), 1, fp) != 1) { fclose(fp); eblthrow("cannot read magic number"); } magic_vincent = endian(magic); magic_vincent &= ~0xF; // magic contained in higher bits // read number of dimensions if (is_magic(magic)) { // regular magic number, read next number if (fread(&ndim, sizeof (int), 1, fp) != 1) { fclose(fp); eblthrow("cannot read number of dimensions"); } // check number is valid if (ndim > MAXDIMS) { fclose(fp); eblthrow("too many dimensions: " << ndim << " (MAXDIMS = " << MAXDIMS << ")."); } } else if (is_magic_vincent(magic_vincent)) { // vincent magic number // ndim is contained in lower bits of the magic number ndim = endian(magic) & 0xF; ndim_min = ndim; magic = magic_vincent; } else { // unkown magic fclose(fp); eblthrow("unknown magic number: " << reinterpret_cast<void*>(magic) << " or " << magic << " vincent: " << magic_vincent); } // read each dimension for (int i = 0; (i < ndim) || (i < ndim_min); ++i) { if (fread(&v, sizeof (int), 1, fp) != 1) { fclose(fp); eblthrow("failed to read matrix dimensions"); } // if vincent, convert to endian first if (is_magic_vincent(magic_vincent)) v = endian(v); if (i < ndim) { // ndim may be less than ndim_min if (v <= 0) { // check that dimension is valid fclose(fp); eblthrow("dimension is negative or zero"); } dims.insert_dim(i, v); // insert dimension } } return dims; }
//-------------------------------------------------------------------------- bool macho_file_t::parse_header() { qlseek(li, start_offset); uint32 magic; if ( qlread(li, &magic, sizeof(magic)) != sizeof(magic) ) return false; if ( magic == FAT_MAGIC || magic == FAT_CIGAM ) return parse_fat_header(); else return is_magic(magic) || is_cigam(magic); }
static bool _check_realm(int class_idx, int realm_idx) { int bit = (1 << (realm_idx-1)); /* cf CH_LIFE and REALM_LIFE (etc) in defines.h */ if (realm_choices1[class_idx] & bit) return TRUE; if (realm_choices2[class_idx] & bit) return TRUE; if (class_idx == CLASS_SORCERER || class_idx == CLASS_RED_MAGE) { if (is_magic(realm_idx) && realm_idx != REALM_NECROMANCY) return TRUE; } return FALSE; }
int main() { int n, i, j; do scanf("%d",&n); while(n <= 0); int sqr[n][n]; for(i = 0; i < n; i++) { for(j = 0; j < n; j++) scanf("%d",&sqr[i][j]); printf("\n"); } printf("%d",is_magic(n, sqr)); return 0; }
int main(int argc, char *argv[]) { enum {N=3}; /* matrix to test */ int m[N][N] = {{2,7,6}, {9,5,1}, {4,3,8}}; int i, j, is_mag; for (i = 0; i < N; i++) { for (j = 0; j < N; j++) printf("%d\t", m[i][j]); printf("\n"); } is_mag = is_magic(N, (int **)&m[0][0]); printf("The matrix is "); if (is_mag) printf("magic!\n"); else printf("not magic!\n"); return 0; }
static void _dump_book(doc_ptr doc, int realm, int book) { int k_idx = lookup_kind(realm2tval(realm), book); int i, increment = 64; caster_info *caster_ptr = get_caster_info(); if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0; else if (realm == p_ptr->realm1) increment = 0; else if (realm == p_ptr->realm2) increment = 32; if (realm == REALM_HISSATSU) { doc_printf(doc, "<color:G> %-25.25s Lvl SP %-15.15s Cast</color>\n", k_name + k_info[k_idx].name, "Desc"); } else { if (caster_ptr && (caster_ptr->options & CASTER_USE_HP)) doc_printf(doc, "<color:G> %-23.23s Profic Lvl HP Fail %-15.15s Cast Fail</color>\n", k_name + k_info[k_idx].name, "Desc"); else doc_printf(doc, "<color:G> %-23.23s Profic Lvl SP Fail %-15.15s Cast Fail</color>\n", k_name + k_info[k_idx].name, "Desc"); } for (i = 0; i < 8; i++) { int s_idx = book * 8 + i; magic_type *s_ptr; int cost; bool max = FALSE; char proficiency[10]; char info[80]; cptr comment; char line[160]; char color = 'w'; if (is_magic(realm)) s_ptr = &mp_ptr->info[realm - 1][s_idx]; else s_ptr = &technic_info[realm - MIN_TECHNIC][s_idx]; if (s_ptr->slevel >= 99) continue; if (realm == REALM_HISSATSU) cost = s_ptr->smana; else { s16b exp = experience_of_spell(s_idx, realm); int exp_level = spell_exp_level(exp); cost = mod_need_mana(s_ptr->smana, s_idx, realm); max = FALSE; if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE; else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE; else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE; strncpy(proficiency, exp_level_str[exp_level], 4); proficiency[3] = ']'; proficiency[4] = '\0'; } strcpy(info, do_spell(realm, s_idx, SPELL_INFO)); comment = info; if (p_ptr->pclass == CLASS_SORCERER || p_ptr->pclass == CLASS_RED_MAGE) { if (s_ptr->slevel > p_ptr->max_plv) { comment = "unknown"; color = 'D'; } else if (s_ptr->slevel > p_ptr->lev) { comment = "forgotten"; color = 'y'; } } else if ((realm == p_ptr->realm1) ? ((p_ptr->spell_forgotten1 & (1L << s_idx))) : ((p_ptr->spell_forgotten2 & (1L << s_idx)))) { comment = "forgotten"; color = 'y'; } else if (!((realm == p_ptr->realm1) ? (p_ptr->spell_learned1 & (1L << s_idx)) : (p_ptr->spell_learned2 & (1L << s_idx)))) { comment = "unknown"; if (s_ptr->slevel > p_ptr->lev) color = 'D'; else color = 'B'; } else if (!((realm == p_ptr->realm1) ? (p_ptr->spell_worked1 & (1L << s_idx)) : (p_ptr->spell_worked2 & (1L << s_idx)))) { comment = "untried"; } sprintf(line, " %c) ", I2A(i)); if (realm == REALM_HISSATSU) { spell_stats_ptr stats = spell_stats_old(realm, s_idx); strcat( line, format( "<color:%c>%-25s %3d %3d %-15.15s %5d</color>", color, do_spell(realm, s_idx, SPELL_NAME), s_ptr->slevel, cost, comment, stats->ct_cast ) ); } else { spell_stats_ptr stats = spell_stats_old(realm, s_idx); strcat( line, format( "<color:%c>%-25s%c%-4s %3d %3d %3d%% %-15.15s %5d %4d %3d%%</color>", color, do_spell(realm, s_idx, SPELL_NAME), (max ? '!' : ' '), proficiency, s_ptr->slevel, cost, spell_chance(s_idx, realm), comment, stats->ct_cast, stats->ct_fail, spell_stats_fail(stats) ) ); } doc_printf(doc, "%s\n", line); } doc_newline(doc); }
/* * quaff: * Let the hero drink a potion */ int quaff() { struct object *obj; struct linked_list *item, *titem; struct thing *th; int wh; char buf[LINLEN]; bool bless, curse; /* * Make certain that it is somethings that we want to drink */ if ((item = get_item("quaff", POTION)) == NULL) return 0; obj = OBJPTR(item); if (obj->o_type != POTION) { msg("That's undrinkable!"); after = FALSE; return 0; } wh = obj->o_which; bless = o_on(obj, ISBLESS); curse = o_on(obj, ISCURSED); del_pack(item); /* get rid of it */ /* * Calculate the effect it has on the poor guy. */ switch(wh) { case P_CONFUSE: if (!bless) { if (pl_on(ISINVINC)) msg("You remain level-headed."); else { chg_abil(WIS,-1,TRUE); /* confuse his mind */ if (pl_off(ISHUH)) { msg("Wait, what's going on here. Huh? What? Who?"); if (pl_on(ISHUH)) lengthen(unconfuse,rnd(8)+HUHDURATION); else fuse(unconfuse,TRUE,rnd(8)+HUHDURATION); player.t_flags |= ISHUH; } } p_know[P_CONFUSE] = TRUE; } when P_POISON: if (!bless) { if (pl_off(ISINVINC) && !iswearing(R_SUSTSTR) && !iswearing(R_SUSAB)) { chg_abil(CON,-1,TRUE); chg_abil(STR,-(rnd(3)+1),TRUE); msg("You feel very sick now."); } else msg("You feel momentarily sick."); p_know[P_POISON] = TRUE; } when P_HEALING: if (!curse) { heal_self(4, TRUE); msg("You begin to feel better."); if (!iswearing(R_SLOW)) notslow(FALSE); sight(FALSE); p_know[P_HEALING] = TRUE; } when P_STRENGTH: if (!curse) { msg("You feel stronger, now. What bulging muscles!"); chg_abil(STR,1,TRUE); p_know[P_STRENGTH] = TRUE; } when P_MFIND: /* * Potion of monster detection - find all monsters */ if (mlist != NULL && !curse) { dispmons(); mpos = 0; msg("You begin to sense the presence of monsters--More--"); p_know[P_MFIND] = TRUE; wait_for(cw,' '); msg(""); /* clear line */ } else msg("You have a strange feeling for a moment, then it passes."); when P_TFIND: /* * Potion of magic detection. Show the potions and scrolls */ if (lvl_obj != NULL && !curse) { struct linked_list *mobj; struct object *tp; bool show; show = FALSE; wclear(hw); for (mobj = lvl_obj; mobj != NULL; mobj = next(mobj)) { tp = OBJPTR(mobj); if (is_magic(tp)) { show = TRUE; mvwaddch(hw, tp->o_pos.y, tp->o_pos.x, MAGIC); } } for(titem = mlist; titem != NULL; titem = next(titem)) { struct linked_list *pitem; th = THINGPTR(titem); for(pitem=th->t_pack;pitem!=NULL;pitem=next(pitem)) { if (is_magic(ldata(pitem))) { show = TRUE; mvwaddch(hw,th->t_pos.y, th->t_pos.x, MAGIC); } } } if (show) { msg("You begin to sense the presence of magic."); overlay(hw,cw); p_know[P_TFIND] = TRUE; break; } } msg("You have a strange feeling for a moment, then it passes."); when P_PARALYZE: if (!bless) { if (pl_on(ISINVINC)) msg("You feel numb for a moment."); else { msg("You can't move."); player.t_nocmd = HOLDTIME; } p_know[P_PARALYZE] = TRUE; } when P_SEEINVIS: if (!curse) { int invlen = roll(40,20); msg("This potion tastes like %s juice.", fruit); if (pl_off(CANSEE)) { player.t_flags |= CANSEE; fuse(unsee, TRUE, invlen); light(&hero); } else lengthen(unsee, invlen); sight(FALSE); } when P_RAISE: if (!curse) { msg("You suddenly feel much more skillful."); p_know[P_RAISE] = TRUE; chg_abil(DEX,1,TRUE); chg_abil(WIS,1,TRUE); chg_abil(CON,1,TRUE); raise_level(); } when P_XHEAL: if (!curse) { heal_self(8, TRUE); if (rnd(100) < 50) chg_abil(CON,1,TRUE); msg("You begin to feel much better."); p_know[P_XHEAL] = TRUE; if (!iswearing(R_SLOW)) notslow(FALSE); unconfuse(); extinguish(unconfuse); sight(FALSE); } when P_HASTE: if (!curse) { add_haste(TRUE); msg("You feel yourself moving much faster."); p_know[P_HASTE] = TRUE; } when P_INVINC: if (!curse) { int time = rnd(400) + 350; msg("You feel invincible."); if (player.t_flags & ISINVINC) lengthen(notinvinc,time); else fuse(notinvinc,TRUE,time); player.t_flags |= ISINVINC; p_know[P_INVINC] = TRUE; } when P_SMART: if (!curse) { msg("You feel more perceptive."); p_know[P_SMART] = TRUE; chg_abil(WIS,1,TRUE); } when P_RESTORE: if (!curse) { msg("Hey, this tastes great. You feel warm all over."); him->s_re = max_stats.s_re; him->s_ef = max_stats.s_re; ringabil(); /* add in rings */ updpack(); /* update weight */ p_know[P_RESTORE] = TRUE; extinguish(rchg_str); /* kill restore in from ulodyte */ } when P_BLIND: if (!bless) { if (pl_on(ISINVINC)) msg("The light dims for a moment."); else { chg_abil(WIS,-1,TRUE); msg("A cloak of darkness falls around you."); if (pl_off(ISBLIND)) { player.t_flags |= ISBLIND; fuse(sight, TRUE, rnd(400) + 450); light(&hero); } } p_know[P_BLIND] = TRUE; } when P_ETH: if (!curse) { int ethlen = roll(40,20); msg("You feel more vaporous."); if (pl_on(ISETHER)) lengthen(noteth,ethlen); else fuse(noteth,TRUE,ethlen); player.t_flags |= ISETHER; p_know[P_ETH] = TRUE; } when P_NOP: msg("This potion tastes extremely dull."); when P_DEX: if (!curse) { chg_abil(DEX,1,TRUE); /* increase dexterity */ p_know[P_DEX] = TRUE; msg("You feel much more agile."); } when P_REGEN: if (!curse) { int reglen = rnd(450) + 450; if (pl_on(ISREGEN)) lengthen(notregen, reglen); else fuse(notregen, TRUE, reglen); player.t_flags |= ISREGEN; msg("You feel yourself improved."); p_know[P_REGEN] = TRUE; } when P_DECREP: case P_SUPHERO: { int howmuch = rnd(3) + 1; if (wh == P_DECREP) { if (!bless) { if (iswearing(R_SUSAB) || pl_on(ISINVINC)) { msg("You feel momentarily woozy."); howmuch = 0; } else { msg("You feel crippled."); howmuch = -howmuch; if (!iswearing(R_SUSTSTR)) chg_abil(STR,howmuch,TRUE); } } else howmuch = 0; } else { /* potion of superhero */ if (curse) howmuch = 0; msg("You feel invigorated."); chg_abil(STR,howmuch,TRUE); } chg_abil(CON,howmuch,TRUE); chg_abil(DEX,howmuch,TRUE); chg_abil(WIS,howmuch,TRUE); /* change abilities */ p_know[wh] = TRUE; } otherwise: msg("What an odd tasting potion!"); return 0; } nochange = FALSE; if (p_know[wh] && p_guess[wh]) { free(p_guess[wh]); p_guess[wh] = NULL; } else if(!p_know[wh] && p_guess[wh] == NULL) { strcpy(buf, p_colors[wh]); msg(callit); if (get_str(buf, cw) == NORM) { p_guess[wh] = new(strlen(buf) + 1); strcpy(p_guess[wh], buf); }
void * http_go_proc(task_t *t) { int index = TASK_THRINDEX(t); Request h; ArgumentList prefs; userkey k; HTTP_Status result; DistillerStatus dist_result; const char *content_type; Argument *arg; int thresh; gm_Bool no_distill = gm_False; gm_Bool is_text_html = gm_False; #ifdef LOGGING struct loginfo lo; char logmsg[MAX_LOGMSG_LEN]; #endif /* LOGGING */ /* * New task data should be the request structure. */ init_Request(&h); h.cli_fd = (int)TASK_DATA(t); /* socket FD of client */ SET_TASK_DATA(t,&h); INST_begin_timestamp(index); INST_set_size(index,0); INST_set_thread_state(index, THR_ACCEPTED); INST_timestamp(index, m_arrival); #ifdef LOGGING LOGGING_init_loginfo(&lo); h.lo = &lo; #endif /* LOGGING */ /* * this should read all the headers. */ if (TASK_METADATA(t) == NULL) { int result; assert( DistillerBufferAlloc(&h.cli_hdrs, PERF_HTTP_TOTAL_HEADERLEN) == gm_True); result = readline_or_timeout(&h, READ_ALL_HEADERS, NULL); INST_timestamp(index, m_headersdone); if (result == -1) { /* client request timed out, or error reading hdrs */ /* TC::1 client timeout, or request doesn't sanity check */ goto HTTPGO_FINISH; /* NOTREACHED */ } } else { #ifdef NEWFE /* * This task is a child of a previous */ strncpy(h.cli_hdrs.mime_headers, TASK_METADATA(t), PERF_HTTP_TOTAL_HEADERLEN-1); FREE(TASK_METADATA(t)); #endif /* NEWFE */ } /* parse the headers and request line, filling them in to the loginfo */ result = parse_status_and_headers(&h); if (result != HTTP_NO_ERR) { /* BUG:: last arg of http_error_return should be a substitution arg */ /* TC::2 parse_status_and_headers returns an error */ http_error_return(&h, result); printf("Error occured here!\n"); goto HTTPGO_FINISH; } /* * We have a reasonable looking request. Get prefs for this user. */ k = userkey_from_sock_ipaddr(h.cli_fd); #ifdef LOGGING lo.ipaddr = k; #endif /* LOGGING */ (void)get_userprefs(k, &prefs); /* * Extract any arguments embedded in the URL itself, and add them * to the arg list. * TC::3 url is magic vs nonmagic */ if (is_magic ((char *) h.url)) { /* demagifying a url will never lengthen it so this is a good * upper bounds on the length of the non magical url */ char *demagicURL = ALLOCA(strlen(h.url)+1); assert(demagicURL); strcpy(demagicURL, h.url); from_magic((char *) demagicURL, h.url, &prefs); } /* determine the threshold for bypassing */ arg = getArgumentFromIdInList(&prefs, FRONT_MTU); thresh = (arg == NULL ? PERF_FRONT_MTU : ARG_INT(*arg)); /* determine if distillation is turned off for this * request. EXCEPTION: Force distillation for Prefs html form. */ arg = getArgumentFromIdInList(&prefs, FRONT_NO_DISTILL); if (arg != NULL && ARG_INT(*arg) && strcasecmp(fe_get_prefs_url, h.url) != 0) { /* TC::4 no_distill is set */ no_distill = gm_True; } else { no_distill = gm_False; } /* Short-circuit the following special URL's: * - "set my prefs as follows" (e.g. form submission) */ if (is_setpref_url(h.url)) { /* * handle what send user prefs form sends back. * TC::5 is_setpref_url returns true */ result = parse_and_change_prefs(h.url, k, h.errmsg); if (result == HTTP_NO_ERR) { /* TC::5.1 setpref url succeeds in setting prefs */ correct_write(h.cli_fd, "HTTP/1.0 200\r\nContent-type: text/html\r\n\r\n", -1); correct_write(h.cli_fd, "<html><head><title>Preferences Set</title></head>" "<body><center><h1>Preferences set</h1>" "Your new preferences have been set. Press the back " "button twice to resume browsing." "<p></center></body></html>", -1); } else { /* TC::5.2 setpref url fails in setting prefs */ http_error_return(&h, result); } } else if (is_getpref_url(h.url)) { /* TC::6 gimme my prefs*/ send_prefs(&prefs, h.cli_fd); } else if (is_server_url(h.url)==gm_False && strcasecmp(h.method, "get") != 0 && strcasecmp(h.method, "post") != 0) { /* * Doesn't appear to be an HTTP GET or POST request; so act as a * "dumb tunnel" for passing the request to the server (actually, via * the cache) and relaying the result to the client. */ /* TC::7 tunnel */ proxy_debug_3(DBG_HTTP, "Tunneling '%s'", DistillerBufferData(&h.cli_hdrs)); INST_set_thread_state(index, THR_DISTILLERSEND); tunnel(&h); } else { /* * It's not a special URL, and the request appears to be a GET/POST. * Add in the client's IP address as an INT32 argument so that * the distiller driver can get at it. */ SET_ARG_INT(prefs.arg[prefs.nargs], (INT32) k); SET_ARG_ID(prefs.arg[prefs.nargs], FRONT_CLIENT_IP); prefs.nargs++; result = server_dispatch(&prefs, t); /* * If we get a transport-level error (i.e. fetch from cache failed * due to an internal cache error), wrap the error in HTML (if * needed) and return error to user. * Otherwise, if the transaction succeeded but the server return * code indicates failure (i.e. != 200), **OR** if the server data * is smaller than a threshold size, bypass the server data * directly to the client. * Otherwise, attempt to distill. */ if (result != HTTP_NO_ERR) { /* transport level error: wrap in HTML for delivery to user */ /* TC::8 server_dispatch returns transport level error */ http_error_return(&h, result); goto HTTPGO_FINISH; } content_type = get_header_value(&h.svr_hdrs, "content-type", NULL, NULL, NULL); if (content_type == NULL) { /* TC::9 content-type can't be deduced */ content_type = "application/octet-stream"; } is_text_html = ( ((strncasecmp(content_type, "text/html", 9) == 0) || (strncasecmp(content_type, "text/plain", 10) == 0)) ? gm_True : gm_False); /*if ( (*h.url != '/' && strncasecmp(h.url, fe_agg_string, strlen(fe_agg_string)) != 0) &&*/ /* bypass ONLY if it is not a server-type URL */ /* TC::10.1 bypass because non-200s status */ /* TC::10.2 bypass because not text/html and too small to distill */ /* TC::4 bypass because no_distill is set */ /* bypass server data directly to user */ if ( is_server_url(h.url)==gm_False) { char *bypass_reason = NULL; if (h.svr_http_status != 200) { bypass_reason = "201 Non-OK server status"; } else if (is_text_html == gm_False && DistillerBufferLength(&h.svr_data) <= thresh) { bypass_reason = "202 content-type not text/html and content-length too short"; } else if (no_distill == gm_True) { bypass_reason = "203 distillation not indicated"; } if (bypass_reason) { INST_set_thread_state(index, THR_WRITEBACK); /* * Set return headers to indicate why the bypass occurred. */ insert_header(&h.svr_hdrs, TRANSEND_STATUS_HEADER, bypass_reason, 0); complete_bypass(&h); goto HTTPGO_FINISH; } } /* all is well: continue by dispatching to a worker for distillation */ dist_result = proxy_dispatch(&prefs, t); switch(dist_result) { case distOk: /* TC::11 distillation succeeded */ INST_timestamp(index, m_wbstart); insert_header(&h.pxy_hdrs, TRANSEND_STATUS_HEADER, "200 distillation OK", 0); correct_write(h.cli_fd, (char *)DistillerBufferData(&h.pxy_hdrs), (int)DistillerBufferLength(&h.pxy_hdrs)); /* -1 to avoid NULL term gunk */ correct_write(h.cli_fd, (char *)DistillerBufferData(&h.pxy_data), (int)DistillerBufferLength(&h.pxy_data)); INST_timestamp(thrindex, m_wbdone); break; case distDistillerNotFound: case distLaunchTimeout: case distBadInput: case distConnectionBroken: /* forward original if distiller for this type not found, connection repeatedly broken, or couldn't be launched */ /* TC::12 bypass because distillation failed */ insert_header(&h.svr_hdrs, (dist_result == distBadInput ? TRANSEND_STATUS_HEADER : TRANSEND_ERROR_HEADER), FE_getDistillerStatusString(dist_result), 0); if ((arg = getArgumentFromIdInList(&prefs, FRONT_DEVELOPER)) && ARG_INT(*arg)) { /* return explicit error message */ int tmp_len = snprintf(h.errmsg, HTTP_ERRMSG_MAX, "<i>[set arg <tt>i%d</tt> to 0 to suppress " "this diagnostic]</i><br>", FRONT_DEVELOPER); strncat(h.errmsg, FE_getDistillerStatusString(dist_result), HTTP_ERRMSG_MAX - tmp_len - 1); http_error_return(&h, HTTP_ERR_UNSPECIFIED); } else { /*if (*h.url == '/' || strncasecmp(h.url, fe_agg_string, strlen(fe_agg_string)) == 0) {*/ if (is_server_url(h.url)==gm_True) { /* this is a URL in the frontend's namespace, or an aggregator URL */ strcpy(h.errmsg, h.url); http_error_return(&h, HTTP_ERR_AGGREGATOR_ERROR); } else { complete_bypass(&h); } } break; case distRedispatch: /* * Redispatch count expired: too many redispatches (probably indicates * infinite loop in redispatch route.) */ snprintf(h.errmsg, HTTP_ERRMSG_MAX, "%d", PERF_REQUEST_TTL); http_error_return(&h, HTTP_ERR_ROUTING_ERROR); break; default: /* TC::13 some other distillation error */ insert_header(&h.svr_hdrs, TRANSEND_STATUS_HEADER, FE_getDistillerStatusString(dist_result), 0); http_error_return(&h, HTTP_ERR_UNSPECIFIED); break; } /* switch(dist_result) */ } /* if...else...else...endif */ /* all cases exit through this single exit point */ HTTPGO_FINISH: free_Request(&h); INST_timestamp(index, m_wbdone); INST_end_timestamp(index); if (TASK_PARENT(t) == 0 && TASK_CHILD_INDEX(t) == 0) { /* this is a "root task" */ close(h.cli_fd); } #ifdef LOGGING /* log the request info */ /* BUG::relies on formatting of the userkey */ /* I compare the IP address to 127.0.0.1 so that I don't log connections from localhost, namely the fe_check script. I also MD5 the IP address. */ k = lo.ipaddr; if (((UINT32) k) != ((UINT32) htonl(0x7F000001))) { /* MD5_CTX theHash; UINT32 res; MD5Init(&theHash); MD5Update(&theHash, magicKey, sizeof(magicKey)); MD5Update(&theHash, &k, sizeof(UINT32)); MD5Final(&theHash); memcpy(&res, theHash.digest, sizeof(UINT32)); res = ntohl(res); snprintf(logmsg, MAX_LOGMSG_LEN-1, "(HTTP) %lu %lu \"%s\" %d %ld %ld\n", res, lo.date, lo.url, lo.http_response, lo.size_before, lo.size_after);*/ snprintf(logmsg, MAX_LOGMSG_LEN-1, "(HTTP) %08x %08x \"%s\" %d %ld %ld\n", (UINT32) k, lo.date, lo.url, lo.http_response, lo.size_before, lo.size_after); gm_log(logmsg); } #endif /* LOGGING */ return (void *)0; }
void do_chase(struct thing *th, int flee) { struct room *rer; /* room of chaser */ struct room *ree; /* room of chasee */ struct room *old_room; /* old room of monster */ struct room *new_room; /* new room of monster */ int i, mindist = INT_MAX, maxdist = INT_MIN, dist = INT_MIN; int last_door = -1; /* Door we just came from */ int stoprun = FALSE; /* TRUE means we are there */ int rundoor; /* TRUE means run to a door */ int hit_bad = FALSE; /* TRUE means hit bad monster */ int mon_attack; /* TRUE means find a monster to hit */ char sch; struct linked_list *item; coord this; /* Temporary destination for chaser */ if (!th->t_ischasing) return; /* Make sure the monster can move */ if (th->t_no_move != 0) { th->t_no_move--; return; } /* * Bad monsters check for a good monster to hit, friendly monsters * check for a bad monster to hit. */ mon_attack = FALSE; if (good_monster(*th)) { hit_bad = TRUE; mon_attack = TRUE; } else if (on(*th, ISMEAN)) { hit_bad = FALSE; mon_attack = TRUE; } if (mon_attack) { struct linked_list *mon_to_hit; mon_to_hit = f_mons_a(th->t_pos.y, th->t_pos.x, hit_bad); if (mon_to_hit) { mon_mon_attack(th, mon_to_hit, pick_weap(th), NOTHROWN); return; } } /* no nearby monster to hit */ rer = roomin(th->t_pos); /* Find room of chaser */ ree = roomin(th->t_chasee->t_pos); /* Find room of chasee */ /* * We don't count doors as inside rooms for this routine */ if (mvwinch(stdscr, th->t_pos.y, th->t_pos.x) == DOOR) rer = NULL; this = th->t_chasee->t_pos; /* * If we are not in a corridor and not a phasing monster, then if we * are running after the player, we run to a door if he is not in the * same room. If we are fleeing, we run to a door if he IS in the * same room. Note: We don't bother with doors in mazes. Phasing * monsters don't need to look for doors. There are no doors in mazes * and throne rooms. */ if (levtype != MAZELEV && levtype != THRONE && rer != NULL && off(*th, CANINWALL)) { if (flee) rundoor = (rer == ree); else rundoor = (rer != ree); } else rundoor = FALSE; if (rundoor) { coord d_exit; /* A particular door */ int exity, exitx; /* Door's coordinates */ if (th->t_doorgoal != -1) { /* Do we already have the goal? */ this = rer->r_exit[th->t_doorgoal]; dist = 0; /* Indicate that we have our door */ } else for (i = 0; i < rer->r_nexits; i++) { /* Loop through doors */ d_exit = rer->r_exit[i]; exity = d_exit.y; exitx = d_exit.x; /* Avoid secret doors */ if (mvwinch(stdscr, exity, exitx) == DOOR) { /* Were we just on this door? */ if (ce(d_exit, th->t_oldpos)) last_door = i; else { dist = DISTANCE(th->t_chasee->t_pos, d_exit); /* * If fleeing, we want to * maximize distance from * door to what we flee, and * minimize distance from * door to us. */ if (flee) dist-=DISTANCE(th->t_pos,d_exit); /* * Maximize distance if * fleeing, otherwise * minimize it */ if ((flee && (dist > maxdist)) || (!flee && (dist < mindist))) { th->t_doorgoal = i; /* Use this door */ this = d_exit; mindist = maxdist = dist; } } } } /* Could we not find a door? */ if (dist == INT_MIN) { /* If we were on a door, go ahead and use it */ if (last_door != -1) { th->t_doorgoal = last_door; this = th->t_oldpos; dist = 0; /* Indicate that we found a door */ } } /* Indicate that we do not want to flee from the door */ if (dist != INT_MIN) flee = FALSE; } else th->t_doorgoal = -1; /* Not going to any door */ /* * this now contains what we want to run to this time so we run to * it. If we hit it we either want to fight it or stop running */ if (!chase(th, &this, flee)) { if (ce(th->t_nxtpos, hero)) { /* merchants try to sell something */ if (on(*th, CANSELL)) { sell(th); return; } else if (off(*th, ISFRIENDLY) && off(*th, ISCHARMED) && (off(*th, CANFLY) || (on(*th, CANFLY) && rnd(2)))) attack(th, pick_weap(th), FALSE); return; } else if (on(*th, NOMOVE)) stoprun = TRUE; } if (!curr_mons) return; /* Did monster get itself killed? */ if (on(*th, NOMOVE)) return; /* If we have a scavenger, it can pick something up */ if ((item = find_obj(th->t_nxtpos.y, th->t_nxtpos.x)) != NULL) { struct linked_list *node, *top = item; struct object *obt; while(top) { /* grab all objects that qualify */ struct object *obj = OBJPTR(item); obt = OBJPTR(top); node = obt->next_obj; if (on(*th, ISSCAVENGE) || ((on(*th, CANWIELD) || on(*th, CANSHOOT)) && (obj->o_type == WEAPON || obj->o_type == ARMOR)) || (on(*th, CANCAST) && is_magic(obj))) { rem_obj(top, FALSE); attach(th->t_pack, top); } top = node; } light(&hero); } mvwaddch(cw, th->t_pos.y, th->t_pos.x, th->t_oldch); sch = CCHAR( mvwinch(cw, th->t_nxtpos.y, th->t_nxtpos.x) ); /* Get old and new room of monster */ old_room = roomin(th->t_pos); new_room = roomin(th->t_nxtpos); /* If the monster can illuminate rooms, check for a change */ if (on(*th, HASFIRE)) { /* Is monster entering a room? */ if (old_room != new_room && new_room != NULL) { new_room->r_flags |= HASFIRE; new_room->r_fires++; if (cansee(th->t_nxtpos.y, th->t_nxtpos.x) && new_room->r_fires==1) light(&hero); } /* Is monster leaving a room? */ if (old_room != new_room && old_room != NULL) { if (--(old_room->r_fires) <= 0) { old_room->r_flags &= ~HASFIRE; if (cansee(th->t_pos.y, th->t_pos.x)) light(&th->t_pos); } } } /* * If monster is entering player's room and player can see it, stop * the player's running. */ if (new_room != old_room && new_room != NULL && new_room == ree && cansee(th->t_nxtpos.y, th->t_nxtpos.x) && (off(*th, ISINVIS) || (off(*th, ISSHADOW) || rnd(10) == 0) || on(player, CANSEE)) && off(*th, CANSURPRISE)) running = FALSE; if (rer != NULL && (rer->r_flags & ISDARK) && !(rer->r_flags & HASFIRE) && sch == FLOOR && DISTANCE(th->t_nxtpos, th->t_pos) < see_dist && off(player, ISBLIND)) th->t_oldch = ' '; else th->t_oldch = sch; if (cansee(th->t_nxtpos.y, th->t_nxtpos.x) && off(*th, ISINWALL) && ((off(*th, ISINVIS) && (off(*th, ISSHADOW) || rnd(100) < 10)) || on(player, CANSEE)) && off(*th, CANSURPRISE)) mvwaddch(cw, th->t_nxtpos.y, th->t_nxtpos.x, th->t_type); mvwaddch(mw, th->t_pos.y, th->t_pos.x, ' '); mvwaddch(mw, th->t_nxtpos.y, th->t_nxtpos.x, th->t_type); /* Record monster's last position (if new one is different) */ if (!ce(th->t_nxtpos, th->t_pos)) th->t_oldpos = th->t_pos; th->t_pos = th->t_nxtpos; /* Mark the monster's new position */ /* If the monster is on a trap, trap it */ sch = CCHAR(mvinch(th->t_nxtpos.y, th->t_nxtpos.x)); if (isatrap(sch)) { debug("Monster trapped by %c.", sch); if (cansee(th->t_nxtpos.y, th->t_nxtpos.x)) th->t_oldch = sch; be_trapped(th, th->t_nxtpos); } /* And stop running if need be */ if (stoprun && ce(th->t_pos, th->t_chasee->t_pos)) { th->t_ischasing = FALSE; turn_off(*th, ISRUN); } }
void quaff() { THING *obj, *tp, *mp; bool discardit = FALSE; bool show, trip; obj = get_item("quaff", POTION); /* * Make certain that it is somethings that we want to drink */ if (obj == NULL) return; if (obj->o_type != POTION) { if (!terse) msg("yuk! Why would you want to drink that?"); else msg("that's undrinkable"); return; } if (obj == cur_weapon) cur_weapon = NULL; /* * Calculate the effect it has on the poor guy. */ trip = on(player, ISHALU); discardit = (bool)(obj->o_count == 1); leave_pack(obj, FALSE, FALSE); switch (obj->o_which) { case P_CONFUSE: do_pot(P_CONFUSE, !trip); when P_POISON: pot_info[P_POISON].oi_know = TRUE; if (ISWEARING(R_SUSTSTR)) msg("you feel momentarily sick"); else { chg_str(-(rnd(3) + 1)); msg("you feel very sick now"); come_down(); } when P_HEALING: pot_info[P_HEALING].oi_know = TRUE; if ((pstats.s_hpt += roll(pstats.s_lvl, 4)) > max_hp) pstats.s_hpt = ++max_hp; sight(); msg("you begin to feel better"); when P_STRENGTH: pot_info[P_STRENGTH].oi_know = TRUE; chg_str(1); msg("you feel stronger, now. What bulging muscles!"); when P_MFIND: player.t_flags |= SEEMONST; fuse((void(*)())turn_see, TRUE, HUHDURATION, AFTER); if (!turn_see(FALSE)) msg("you have a %s feeling for a moment, then it passes", choose_str("normal", "strange")); when P_TFIND: /* * Potion of magic detection. Show the potions and scrolls */ show = FALSE; if (lvl_obj != NULL) { wclear(hw); for (tp = lvl_obj; tp != NULL; tp = next(tp)) { if (is_magic(tp)) { show = TRUE; wmove(hw, tp->o_pos.y, tp->o_pos.x); waddch(hw, MAGIC); pot_info[P_TFIND].oi_know = TRUE; } } for (mp = mlist; mp != NULL; mp = next(mp)) { for (tp = mp->t_pack; tp != NULL; tp = next(tp)) { if (is_magic(tp)) { show = TRUE; wmove(hw, mp->t_pos.y, mp->t_pos.x); waddch(hw, MAGIC); } } } } if (show) { pot_info[P_TFIND].oi_know = TRUE; show_win("You sense the presence of magic on this level.--More--"); } else msg("you have a %s feeling for a moment, then it passes", choose_str("normal", "strange")); when P_LSD: if (!trip) { if (on(player, SEEMONST)) turn_see(FALSE); start_daemon(visuals, 0, BEFORE); seenstairs = seen_stairs(); } do_pot(P_LSD, TRUE); when P_SEEINVIS: sprintf(prbuf, "this potion tastes like %s juice", fruit); show = on(player, CANSEE); do_pot(P_SEEINVIS, FALSE); if (!show) invis_on(); sight(); when P_RAISE: pot_info[P_RAISE].oi_know = TRUE; msg("you suddenly feel much more skillful"); raise_level(); when P_XHEAL: pot_info[P_XHEAL].oi_know = TRUE; if ((pstats.s_hpt += roll(pstats.s_lvl, 8)) > max_hp) { if (pstats.s_hpt > max_hp + pstats.s_lvl + 1) ++max_hp; pstats.s_hpt = ++max_hp; } sight(); come_down(); msg("you begin to feel much better"); when P_HASTE: pot_info[P_HASTE].oi_know = TRUE; after = FALSE; if (add_haste(TRUE)) msg("you feel yourself moving much faster"); when P_RESTORE: if (ISRING(LEFT, R_ADDSTR)) add_str(&pstats.s_str, -cur_ring[LEFT]->o_arm); if (ISRING(RIGHT, R_ADDSTR)) add_str(&pstats.s_str, -cur_ring[RIGHT]->o_arm); if (pstats.s_str < max_stats.s_str) pstats.s_str = max_stats.s_str; if (ISRING(LEFT, R_ADDSTR)) add_str(&pstats.s_str, cur_ring[LEFT]->o_arm); if (ISRING(RIGHT, R_ADDSTR)) add_str(&pstats.s_str, cur_ring[RIGHT]->o_arm); msg("hey, this tastes great. It make you feel warm all over"); when P_BLIND: do_pot(P_BLIND, TRUE); when P_LEVIT: do_pot(P_LEVIT, TRUE); #ifdef MASTER otherwise: msg("what an odd tasting potion!"); return; #endif } status(); /* * Throw the item away */ call_it(&pot_info[obj->o_which]); if (discardit) discard(obj); return; }
int muste_magic(char *argv) { int i,j,method,spec,offs,raja,magic; s_init(argv); if (g<3) { sur_print("\nUsage: MAGIC CREATE <dim>"); WAIT; return(1); } results_line=r1+r; i=sp_init(r1+r-1); if (i<0) return(-1); dim=atoi(word[2]); i=varaa_tilat(dim); if (i<0) return(-1); if (dim%2==0) { sur_print("\nCurrently only odd dimensions allowed!"); WAIT; return(-1); } method=1; // Default method for odd dimensions spec=1; offs=dim>>1; magic=0; i=spfind("METHOD"); if (i>=0) { method=atoi(spb[i]); } i=spfind("OFFSET"); if (i>=0) { offs=atoi(spb[i])-1; } if (offs<0 || offs>=(dim*dim)) { if (strcmp(spb[i],"ALL")==0) offs=-1; else { sprintf(sbuf,"\nERROR! OFFSET must be between 1 and %d!",dim*dim); sur_print(sbuf); WAIT; return(-1); } } raja=offs+1; if (offs<0) // ALL { raja=dim*dim; offs=0; } for (j=offs; j<raja; j++) { tyhjenna(dim); switch(method) { case 0: i=magic_random(dim); break; case 1: i=magic_staircase(dim); break; case 2: i=magic_pyramid(dim); break; case 3: i=magic_variation_staircase(dim); break; case 4: i=spfind("MOVE"); if (i>=0) { spec=atoi(spb[i]); } if (spec<1 || spec>8) { sur_print("\nERROR! Knight's move should be:"); sur_print("\n1 - 2 up, 1 right 5 - 2 down, 1 left"); sur_print("\n2 - 1 up, 2 right 6 - 1 down, 2 left"); sur_print("\n3 - 2 right, 1 down 7 - 2 left, 1 up"); sur_print("\n4 - 1 right, 2 down 8 - 1 left, 2 up"); sur_print("\nUse specification MOVE to define the move."); WAIT; return(-1); } i=magic_knights_move(dim,j,spec); break; default: break; } i=is_magic(dim); if (i<0) { if (method==0) print_square(dim); /* sprintf(sbuf,"Non magic! Offset=%d",j+1); print_line(); print_square(dim); if (i<99) sprintf(sbuf,"Wrong sum(s) in diagonal(s)!"); print_line(); if (i<9) sprintf(sbuf,"Wrong sum(s) in column(s)!"); print_line(); sprintf(sbuf,"Wrong sum(s) in row(s)!"); print_line(); */ } else { magic++; print_square_info(dim,j+1); print_square(dim); sprintf(sbuf," "); print_line(); } } if (magic<1) { sprintf(sbuf,"Non magic! "); print_line(); } s_end(argv); return(1); }
/* * quaff: * Quaff a potion from the pack */ quaff() { register THING *obj, *th; register bool discardit = FALSE; obj = get_item("quaff", POTION); /* * Make certain that it is somethings that we want to drink */ if (obj == NULL) return; if (obj->o_type != POTION) { if (!terse) msg("yuk! Why would you want to drink that?"); else msg("that's undrinkable"); return; } if (obj == cur_weapon) cur_weapon = NULL; /* * Calculate the effect it has on the poor guy. */ switch (obj->o_which) { case P_CONFUSE: p_know[P_CONFUSE] = TRUE; if (!on(player, ISHUH)) { if (on(player, ISHUH)) lengthen(unconfuse, rnd(8)+HUHDURATION); else fuse(unconfuse, 0, rnd(8)+HUHDURATION, AFTER); player.t_flags |= ISHUH; msg("wait, what's going on here. Huh? What? Who?"); } when P_POISON: p_know[P_POISON] = TRUE; if (!ISWEARING(R_SUSTSTR)) { chg_str(-(rnd(3)+1)); msg("you feel very sick now"); } else msg("you feel momentarily sick"); when P_HEALING: p_know[P_HEALING] = TRUE; if ((pstats.s_hpt += roll(pstats.s_lvl, 4)) > max_hp) pstats.s_hpt = ++max_hp; sight(); msg("you begin to feel better"); when P_STRENGTH: p_know[P_STRENGTH] = TRUE; chg_str(1); msg("you feel stronger, now. What bulging muscles!"); when P_MFIND: player.t_flags |= SEEMONST; fuse(turn_see, TRUE, HUHDURATION, AFTER); if (mlist == NULL) msg("you have a strange feeling for a moment"); else p_know[P_MFIND] |= turn_see(FALSE); when P_TFIND: /* * Potion of magic detection. Show the potions and scrolls */ if (lvl_obj != NULL) { register THING *tp; register bool show; show = FALSE; wclear(hw); for (tp = lvl_obj; tp != NULL; tp = next(tp)) { if (is_magic(tp)) { show = TRUE; mvwaddch(hw, tp->o_pos.y, tp->o_pos.x, MAGIC); p_know[P_TFIND] = TRUE; } } for (th = mlist; th != NULL; th = next(th)) { for (tp = th->t_pack; tp != NULL; tp = next(tp)) { if (is_magic(tp)) { show = TRUE; mvwaddch(hw, th->t_pos.y, th->t_pos.x, MAGIC); p_know[P_TFIND] = TRUE; } } } if (show) { show_win(hw, "You sense the presence of magic on this level.--More--"); break; } } msg("you have a strange feeling for a moment, then it passes"); when P_PARALYZE: p_know[P_PARALYZE] = TRUE; no_command = HOLDTIME; player.t_flags &= ~ISRUN; msg("you can't move"); when P_SEEINVIS: if (!on(player, CANSEE)) { fuse(unsee, 0, SEEDURATION, AFTER); look(FALSE); invis_on(); } sight(); msg("this potion tastes like %s juice", fruit); when P_RAISE: p_know[P_RAISE] = TRUE; msg("you suddenly feel much more skillful"); raise_level(); when P_XHEAL: p_know[P_XHEAL] = TRUE; if ((pstats.s_hpt += roll(pstats.s_lvl, 8)) > max_hp) { if (pstats.s_hpt > max_hp + pstats.s_lvl + 1) ++max_hp; pstats.s_hpt = ++max_hp; } sight(); msg("you begin to feel much better"); when P_HASTE: p_know[P_HASTE] = TRUE; if (add_haste(TRUE)) msg("you feel yourself moving much faster"); when P_RESTORE: if (ISRING(LEFT, R_ADDSTR)) add_str(&pstats.s_str, -cur_ring[LEFT]->o_ac); if (ISRING(RIGHT, R_ADDSTR)) add_str(&pstats.s_str, -cur_ring[RIGHT]->o_ac); if (pstats.s_str < max_stats.s_str) pstats.s_str = max_stats.s_str; if (ISRING(LEFT, R_ADDSTR)) add_str(&pstats.s_str, cur_ring[LEFT]->o_ac); if (ISRING(RIGHT, R_ADDSTR)) add_str(&pstats.s_str, cur_ring[RIGHT]->o_ac); msg("hey, this tastes great. It make you feel warm all over"); when P_BLIND: p_know[P_BLIND] = TRUE; if (!on(player, ISBLIND)) { player.t_flags |= ISBLIND; fuse(sight, 0, SEEDURATION, AFTER); look(FALSE); } msg("a cloak of darkness falls around you"); when P_NOP: msg("this potion tastes extremely dull"); otherwise: msg("what an odd tasting potion!"); return; } status(); /* * Throw the item away */ inpack--; if (obj->o_count > 1) obj->o_count--; else { detach(pack, obj); discardit = TRUE; } call_it(p_know[obj->o_which], &p_guess[obj->o_which]); if (discardit) discard(obj); }