int cmd_s_dir_attributes(CalcHandle *h, const char *name) { VirtualPacket* pkt; size_t len = strlen(name) < 8 ? 8 : strlen(name); ticalcs_info(" unknown directory list command in <%s>:", name); pkt = nsp_vtl_pkt_new_ex(1 + len + 1, NSP_SRC_ADDR, nsp_src_port, NSP_DEV_ADDR, PORT_FILE_MGMT); pkt->cmd = CMD_FM_ATTRIBUTES; pkt->data[0] = 0x01; put_str(pkt->data + 1, name); TRYF(nsp_send_data(h, pkt)); nsp_vtl_pkt_del(pkt); return 0; }
/* * Prints players max/cur spell points */ static void prt_sp(int row, int col) { char cur_sp[32], max_sp[32]; byte color = player_sp_attr(); /* Do not show mana unless we have some */ if (!p_ptr->msp) return; put_str("SP ", row, col); strnfmt(max_sp, sizeof(max_sp), "%4d", p_ptr->msp); strnfmt(cur_sp, sizeof(cur_sp), "%4d", p_ptr->csp); /* Show mana */ c_put_str(color, cur_sp, row, col + 3); c_put_str(TERM_WHITE, "/", row, col + 7); c_put_str(TERM_L_GREEN, max_sp, row, col + 8); }
/** * Display the tombstone */ static void print_tomb(void) { ang_file *fp; char buf[1024]; int line = 0; time_t death_time = (time_t)0; Term_clear(); (void)time(&death_time); /* Open the death file */ path_build(buf, sizeof(buf), ANGBAND_DIR_SCREENS, "dead.txt"); fp = file_open(buf, MODE_READ, FTYPE_TEXT); if (fp) { while (file_getl(fp, buf, sizeof(buf))) put_str(buf, line++, 0); file_close(fp); } line = 7; put_str_centred(line++, 8, 8+31, "%s", op_ptr->full_name); put_str_centred(line++, 8, 8+31, "the"); if (player->total_winner) put_str_centred(line++, 8, 8+31, "Magnificent"); else put_str_centred(line++, 8, 8+31, "%s", player->class->title[(player->lev - 1) / 5]); line++; put_str_centred(line++, 8, 8+31, "%s", player->class->name); put_str_centred(line++, 8, 8+31, "Level: %d", (int)player->lev); put_str_centred(line++, 8, 8+31, "Exp: %d", (int)player->exp); put_str_centred(line++, 8, 8+31, "AU: %d", (int)player->au); put_str_centred(line++, 8, 8+31, "Killed on Level %d", player->depth); put_str_centred(line++, 8, 8+31, "by %s.", player->died_from); line++; put_str_centred(line++, 8, 8+31, "by %-.24s", ctime(&death_time)); }
/* ** subtest_xhp(test_list, status, ch) ** ** (xhp) erase does not clear standout mode */ static void subtest_xhp( struct test_list *t, int *state, int *ch) { if (enter_standout_mode) { put_crlf(); put_mode(enter_standout_mode); put_str("Stand out"); put_mode(exit_standout_mode); put_cr(); ptextln("If any part of this line is standout then (xhp) should be set."); sprintf(temp, "(xhp) Erase-standout-glitch is %s in the data base", ceol_standout_glitch ? "true" : "false"); ptextln(temp); generic_done_message(t, state, ch); } }
int f_zgetsyi( oprtype *a, opctype op) { triple *r; r = maketriple(op); if (!strexpr(&(r->operand[0]))) return FALSE; if (window_token != TK_COMMA) r->operand[1] = put_str("",0); else { advancewindow(); if (!strexpr(&r->operand[1])) return FALSE; } ins_triple(r); *a = put_tref(r); return TRUE; }
/* ** subtest_rmam(test_list, status, ch) ** ** test exit automatic margins mode (rmam) */ static void subtest_rmam( struct test_list *t, int *state, int *ch) { int j; if (!exit_am_mode) { ptext("(rmam) not present. "); } else if (!can_go_home) { ptext("(rmam) not tested, no way to home cursor. "); } else if (over_strike) { put_clear(); go_home(); tc_putp(exit_am_mode); ptext("\n(rmam) will reset (am)"); go_home(); for (j = 0; j < columns; j++) put_this(' '); ptext("(rmam) will not reset (am)"); go_home(); put_newlines(2); } else { put_clear(); go_home(); tc_putp(exit_am_mode); ptext("\n(rmam) will reset (am)"); go_home(); for (j = 0; j < columns; j++) put_this(' '); ptext("(rmam) will not reset (am) "); go_home(); put_str(" "); go_home(); put_newlines(2); } ptext("Exit-automatic-margins "); generic_done_message(t, state, ch); }
static void dump_modules(int sel, int max) { int i; char buf[40], pre = ' ', post = ')'; cptr name; char ind; for (i = 0; i < max; i++) { ind = I2A(i % 26); if (i >= 26) ind = toupper(ind); if (sel == i) { pre = '['; post = ']'; } else { pre = ' '; post = ')'; } call_lua("get_module_name", "(d)", "s", i, &name); strnfmt(buf, 40, "%c%c%c %s", pre, ind, post, name); if (sel == i) { call_lua("get_module_desc", "(d)", "s", i, &name); print_desc_aux(name, 5, 0); c_put_str(TERM_L_BLUE, buf, 10 + (i / 4), 20 * (i % 4)); } else put_str(buf, 10 + (i / 4), 20 * (i % 4)); } }
/* ** subtest_in(test_list, status, ch) ** ** (in) insert null glitch */ static void subtest_in( struct test_list *t, int *state, int *ch) { if (enter_insert_mode && exit_insert_mode) { ptextln("\nTesting (in) with (smir) and (rmir)"); putln("\tIf these two lines line up ..."); put_str("\tIf these two lines line up ..."); put_cr(); tc_putp(enter_insert_mode); putchp(' '); tc_putp(exit_insert_mode); ptext("\nthen (in) should be set. "); sprintf(temp, "(in) Insert-null-glitch is %s in the data base.", insert_null_glitch ? "true" : "false"); ptextln(temp); generic_done_message(t, state, ch); } }
void put_columns(const char *s, int len, int w) { /* put out s in column format */ int l; if (char_count + w > columns) { put_crlf(); } l = char_count % w; if (l) { while (l < w) { putchp(' '); l++; } } if (char_count && char_count + len >= columns) { put_crlf(); } l = char_count; put_str(s); char_count = l + len; }
/* -- output a header format '111 (222)' -- */ static void put_inf2r(struct SYMBOL *s1, struct SYMBOL *s2, int action) { char buf[256], *p, *q; if (s1 == 0) { s1 = s2; s2 = 0; } p = s1->as.text; if (p[1] == ':') p += 2; while (isspace((unsigned char) *p)) p++; if (s1->as.text[0] == 'T' && s1->as.text[1] == ':') p = trim_title(p, s1 == info['T' - 'A']); if (s2 != 0) { buf[sizeof buf - 1] = '\0'; strncpy(buf, p, sizeof buf - 1); q = buf + strlen(buf); if (q < buf + sizeof buf - 4) { *q++ = ' '; *q++ = '('; p = s2->as.text; if (p[1] == ':') p += 2; while (isspace((unsigned char) *p)) p++; strncpy(q, p, buf + sizeof buf - 2 - q); q += strlen(q); *q++ = ')'; *q = '\0'; } p = buf; } put_str(p, action); }
static void put_value (Sophon_VM *vm, Sophon_IOFunc func, Sophon_Ptr data, Sophon_Value v) { if (sophon_value_is_undefined(v)) { put_u8(func, data, TAG_UNDEF); } else if (sophon_value_is_null(v)) { put_u8(func, data, TAG_NULL); } else if (sophon_value_is_bool(v)) { Sophon_Bool b; b = sophon_value_to_bool(vm, v); put_u8(func, data, TAG_BOOL); put_u8(func, data, b ? 1 : 0); } else if (sophon_value_is_string(v)) { Sophon_String *str; sophon_value_to_string(vm, v, &str); put_u8(func, data, (str->gc_flags & SOPHON_GC_FL_INTERN) ? TAG_INTERN_STRING : TAG_STRING); put_str(vm, func, data, str); } else if (sophon_value_is_number(v)) { Sophon_Number n; sophon_value_to_number(vm, v, &n); if (n == (Sophon_Number)(Sophon_Int)(n)) { put_u8(func, data, TAG_INT); put_u32(func, data, (Sophon_Int)n); } else { put_u8(func, data, TAG_DOUBLE); put_double(func, data, n); } } else { SOPHON_ASSERT(0); } }
/* ** crum_ll(test_list, status, ch) ** ** (ll) test Last line */ static void crum_ll( struct test_list *t, int *state, int *ch) { /* (ll) may be simulated with (cup). Don't complain if (cup) is present. */ if (cursor_to_ll) { put_clear(); put_str("This line could be anywhere."); tc_putp(cursor_to_ll); ptext("This line should be on the bottom"); go_home(); put_crlf(); } else if (cursor_address) { return; } else { ptextln("(ll) Move to last line is not defined. "); } generic_done_message(t, state, ch); }
int execute_pipe(char *str) { char **put_in_sst; char ***temp; if (str) { put_in_sst = put_in_ss(str); if (put_in_sst) { temp = put_in_sss(put_in_sst); if (temp) { loop_pipe(temp); freed(temp); } ft_free2d(put_in_sst); } return (1); } else put_str(ANSI_COLOR_RED"str passed to pipe is 'NULL'"ANSI_COLOR_RESET); return (0); }
static void line_pattern(void) { /* put up a pattern that will help count the number of lines */ int i, j; put_clear(); if (over_strike) { for (i = 0; i < 100; i++) { if (i) { put_crlf(); } for (j = i / 10; j; j--) { put_this(' '); } put_this('0' + ((i + 1) % 10)); } } else /* I assume it will scroll */ { for (i = 100; i; i--) { sprintf(temp, "\r\n%d", i); put_str(temp); } } }
static void put_func (Sophon_VM *vm, Sophon_IOFunc func, Sophon_Ptr data, Sophon_Function *f) { StoreVarParams svp; Sophon_U16 i; SOPHON_ASSERT(!(f->flags & SOPHON_FUNC_FL_NATIVE)); if (f->name) put_str(vm, func, data, f->name); else put_u32(func, data, 0); put_u8(func, data, f->flags); put_u8(func, data, f->argc); put_u16(func, data, f->varc); put_u16(func, data, f->stack_size); put_u16(func, data, f->ibuf_size); SOPHON_ASSERT(f->var_hash.count == f->varc + f->argc); svp.func = func; svp.data = data; sophon_hash_for_each(vm, &f->var_hash, store_var, &svp); func(data, f->f.ibuf, f->ibuf_size); #ifdef SOPHON_LINE_INFO put_u16(func, data, f->lbuf_size); for (i = 0; i < f->lbuf_size; i++) { put_u16(func, data, f->lbuf[i].line); put_u16(func, data, f->lbuf[i].offset); } #endif }
int cmd_s_put_file(CalcHandle *h, const char *name, uint32_t size) { VirtualPacket* pkt; int o; size_t len = strlen(name) < 8 ? 8 : strlen(name); ticalcs_info(" sending variable:"); pkt = nsp_vtl_pkt_new_ex(6 + len, NSP_SRC_ADDR, nsp_src_port, NSP_DEV_ADDR, PORT_FILE_MGMT); pkt->cmd = CMD_FM_PUT_FILE; pkt->data[0] = 0x01; o = put_str(pkt->data + 1, name); o++; pkt->data[o+0] = MSB(MSW(size)); pkt->data[o+1] = LSB(MSW(size)); pkt->data[o+2] = MSB(LSW(size)); pkt->data[o+3] = LSB(LSW(size)); TRYF(nsp_send_data(h, pkt)); nsp_vtl_pkt_del(pkt); return 0; }
/* * Display the winner crown */ static void display_winner(void) { char buf[1024]; ang_file *fp; int wid, hgt; int i = 2; int width = 0; path_build(buf, sizeof(buf), ANGBAND_DIR_FILE, "crown.txt"); fp = file_open(buf, MODE_READ, -1); Term_clear(); Term_get_size(&wid, &hgt); if (fp) { /* Get us the first line of file, which tells us how long the */ /* longest line is */ file_getl(fp, buf, sizeof(buf)); sscanf(buf, "%d", &width); if (!width) width = 25; /* Dump the file to the screen */ while (file_getl(fp, buf, sizeof(buf))) put_str(buf, i++, (wid/2) - (width/2)); file_close(fp); } put_str_centred(i, 0, wid, "All Hail the Mighty %s!", p_ptr->sex->winner); flush(); pause_line(Term); }
/* * Allow user to choose a imitation. * * If a valid spell is chosen, saves it in '*sn' and returns TRUE * If the user hits escape, returns FALSE, and set '*sn' to -1 * If there are no legal choices, returns FALSE, and sets '*sn' to -2 * * The "prompt" should be "cast", "recite", or "study" * The "known" should be TRUE for cast/pray, FALSE for study * * nb: This function has a (trivial) display bug which will be obvious * when you run it. It's probably easy to fix but I haven't tried, * sorry. */ static int get_mane_power(int *sn, bool baigaesi) { int i = 0; int num = 0; int y = 1; int x = 18; int minfail = 0; int plev = p_ptr->lev; int chance = 0; int ask; char choice; char out_val[160]; char comment[80]; #ifdef JP cptr p = "能力"; #else cptr p = "power"; #endif monster_power spell; bool flag, redraw; /* Assume cancelled */ *sn = (-1); /* Nothing chosen yet */ flag = FALSE; /* No redraw yet */ redraw = FALSE; num = p_ptr->mane_num; /* Build a prompt (accept all spells) */ (void)strnfmt(out_val, 78, #ifdef JP "(%c-%c, '*'で一覧, ESC) どの%sをまねますか?", #else "(%c-%c, *=List, ESC=exit) Use which %s? ", #endif I2A(0), I2A(num - 1), p); /* Get a spell from the user */ choice= always_show_list ? ESCAPE:1 ; while (!flag) { if(choice==ESCAPE) choice = ' '; else if( !get_com(out_val, &choice, TRUE) )break; /* Request redraw */ if ((choice == ' ') || (choice == '*') || (choice == '?')) { /* Show the list */ if (!redraw) { char psi_desc[80]; /* Show list */ redraw = TRUE; /* Save the screen */ screen_save(); /* Display a list of spells */ prt("", y, x); #ifdef JP put_str("名前", y, x + 5); #else put_str("Name", y, x + 5); #endif #ifdef JP put_str("失率 効果", y, x + 36); #else put_str("Fail Info", y, x + 35); #endif /* Dump the spells */ for (i = 0; i < num; i++) { /* Access the spell */ spell = monster_powers[p_ptr->mane_spell[i]]; chance = spell.manefail; /* Reduce failure rate by "effective" level adjustment */ if (plev > spell.level) chance -= 3 * (plev - spell.level); /* Reduce failure rate by INT/WIS adjustment */ chance -= 3 * (adj_mag_stat[p_ptr->stat_ind[spell.use_stat]] + adj_mag_stat[p_ptr->stat_ind[A_DEX]] - 2) / 2; if (spell.manedam) chance = chance * p_ptr->mane_dam[i] / spell.manedam; chance += p_ptr->to_m_chance; /* Extract the minimum failure rate */ minfail = adj_mag_fail[p_ptr->stat_ind[spell.use_stat]]; /* Minimum failure rate */ if (chance < minfail) chance = minfail; /* Stunning makes spells harder */ if (p_ptr->stun > 50) chance += 25; else if (p_ptr->stun) chance += 15; /* Always a 5 percent chance of working */ if (chance > 95) chance = 95; /* Get info */ mane_info(comment, p_ptr->mane_spell[i], (baigaesi ? p_ptr->mane_dam[i]*2 : p_ptr->mane_dam[i])); /* Dump the spell --(-- */ sprintf(psi_desc, " %c) %-30s %3d%%%s", I2A(i), spell.name, chance, comment); prt(psi_desc, y + i + 1, x); } /* Clear the bottom line */ prt("", y + i + 1, x); } /* Hide the list */ else { /* Hide list */ redraw = FALSE; /* Restore the screen */ screen_load(); } /* Redo asking */ continue; } /* Note verify */ ask = isupper(choice); /* Lowercase */ if (ask) choice = tolower(choice); /* Extract request */ i = (islower(choice) ? A2I(choice) : -1); /* Totally Illegal */ if ((i < 0) || (i >= num)) { bell(); continue; } /* Save the spell index */ spell = monster_powers[p_ptr->mane_spell[i]]; /* Verify it */ if (ask) { char tmp_val[160]; /* Prompt */ #ifdef JP (void) strnfmt(tmp_val, 78, "%sをまねますか?", monster_powers[p_ptr->mane_spell[i]].name); #else (void)strnfmt(tmp_val, 78, "Use %s? ", monster_powers[p_ptr->mane_spell[i]].name); #endif /* Belay that order */ if (!get_check(tmp_val)) continue; } /* Stop the loop */ flag = TRUE; } /* Restore the screen */ if (redraw) screen_load(); /* Show choices */ p_ptr->window |= (PW_SPELL); /* Window stuff */ window_stuff(); /* Abort if needed */ if (!flag) return (FALSE); /* Save the choice */ (*sn) = i; damage = (baigaesi ? p_ptr->mane_dam[i]*2 : p_ptr->mane_dam[i]); /* Success */ return (TRUE); }
int m_job(void) { int argcnt; triple *ref,*next; oprtype label, offset, routine, plist, timeout, arglst, *argptr, argval; static readonly unsigned char empty_plist[1] = { jp_eol }; bool is_timeout,dummybool; error_def(ERR_MAXACTARG); error_def(ERR_RTNNAME); error_def(ERR_COMMAORRPARENEXP); error_def(ERR_JOBACTREF); label = put_str(zero_ident.c,sizeof(mident)); offset = put_ilit((mint)0); if (!lref(&label, &offset, FALSE, indir_job, TRUE, &dummybool)) return FALSE; if ((TRIP_REF == label.oprclass) && (OC_COMMARG == label.oprval.tref->opcode)) return TRUE; if (TK_CIRCUMFLEX != window_token) { if (!run_time) routine = put_str(routine_name,sizeof(mident)); else routine = put_tref(newtriple(OC_CURRTN)); } else { advancewindow(); switch(window_token) { case TK_IDENT: routine = put_str(window_ident.c,sizeof(mident)); advancewindow(); break; case TK_ATSIGN: if (!indirection(&routine)) return FALSE; break; default: stx_error(ERR_RTNNAME); return FALSE; } } argcnt = 0; if (TK_LPAREN == window_token) { advancewindow(); argptr = &arglst; while(TK_RPAREN != window_token) { if (argcnt > MAX_ACTUALS) { stx_error(ERR_MAXACTARG); return FALSE; } if (TK_PERIOD == window_token) { stx_error(ERR_JOBACTREF); return FALSE; } if (!expr(&argval)) return FALSE; ref = newtriple(OC_PARAMETER); ref->operand[0] = argval; *argptr = put_tref(ref); argptr = &ref->operand[1]; argcnt++; if (TK_COMMA == window_token) advancewindow(); else if (TK_RPAREN != window_token) { stx_error(ERR_COMMAORRPARENEXP); return FALSE; } } advancewindow(); /* jump over close paren */ } if (TK_COLON == window_token) { advancewindow(); if (TK_COLON == window_token) { is_timeout = TRUE; plist = put_str((char *)empty_plist,sizeof(empty_plist)); } else { if (!jobparameters(&plist)) return FALSE; is_timeout = (TK_COLON == window_token); } if (is_timeout) { advancewindow(); if (!intexpr(&timeout)) return FALSE; } else timeout = put_ilit(NO_M_TIMEOUT); } else { is_timeout = FALSE; plist = put_str((char *)empty_plist,sizeof(empty_plist)); timeout = put_ilit(NO_M_TIMEOUT); } ref = newtriple(OC_JOB); ref->operand[0] = put_ilit(argcnt + 5); /* parameter list + five fixed arguments */ next = newtriple(OC_PARAMETER); ref->operand[1] = put_tref(next); next->operand[0] = label; ref = newtriple(OC_PARAMETER); next->operand[1] = put_tref(ref); ref->operand[0] = offset; next = newtriple(OC_PARAMETER); ref->operand[1] = put_tref(next); next->operand[0] = routine; ref = newtriple(OC_PARAMETER); next->operand[1] = put_tref(ref); ref->operand[0] = plist; next = newtriple(OC_PARAMETER); ref->operand[1] = put_tref(next); next->operand[0] = timeout; if (argcnt) next->operand[1] = arglst; if (is_timeout) newtriple(OC_TIMTRU); return TRUE; }
/* * Display the scores in a given range. */ static void display_scores_aux(const high_score scores[], int from, int to, int highlight) { char ch; int j, k, n, place; int count; /* Assume we will show the first 10 */ if (from < 0) from = 0; if (to < 0) to = 10; if (to > MAX_HISCORES) to = MAX_HISCORES; /* Hack -- Count the high scores */ for (count = 0; count < MAX_HISCORES; count++) { if (!scores[count].what[0]) break; } /* Forget about the last entries */ if (count > to) count = to; /* Show 5 per page, until "done" */ for (k = from, j = from, place = k+1; k < count; k += 5) { char out_val[160]; char tmp_val[160]; /* Clear screen */ Term_clear(); /* Title */ put_str(format("%s Hall of Fame", VERSION_NAME), 0, 26); /* Indicate non-top scores */ if (k > 0) put_str(format("(from position %d)", place), 0, 40); /* Dump 5 entries */ for (n = 0; j < count && n < 5; place++, j++, n++) { const high_score *score = &scores[j]; byte attr; int pr, pc, clev, mlev, cdun, mdun; cptr user, gold, when, aged; /* Hack -- indicate death in yellow */ attr = (j == highlight) ? TERM_L_GREEN : TERM_WHITE; /* Extract the race/class */ pr = atoi(score->p_r); pc = atoi(score->p_c); /* Extract the level info */ clev = atoi(score->cur_lev); mlev = atoi(score->max_lev); cdun = atoi(score->cur_dun); mdun = atoi(score->max_dun); /* Hack -- extract the gold and such */ for (user = score->uid; isspace((unsigned char)*user); user++) /* loop */; for (when = score->day; isspace((unsigned char)*when); when++) /* loop */; for (gold = score->gold; isspace((unsigned char)*gold); gold++) /* loop */; for (aged = score->turns; isspace((unsigned char)*aged); aged++) /* loop */; /* Dump some info */ strnfmt(out_val, sizeof(out_val), "%3d.%9s %s the %s %s, Level %d", place, score->pts, score->who, p_info[pr].name, c_info[pc].name, clev); /* Append a "maximum level" */ if (mlev > clev) my_strcat(out_val, format(" (Max %d)", mlev), sizeof(out_val)); /* Dump the first line */ c_put_str(attr, out_val, n*4 + 2, 0); /* Died where? */ if (!cdun) strnfmt(out_val, sizeof(out_val), "Killed by %s in the town", score->how); else strnfmt(out_val, sizeof(out_val), "Killed by %s on dungeon level %d", score->how, cdun); /* Append a "maximum level" */ if (mdun > cdun) my_strcat(out_val, format(" (Max %d)", mdun), sizeof(out_val)); /* Dump the info */ c_put_str(attr, out_val, n*4 + 3, 15); /* Clean up standard encoded form of "when" */ if ((*when == '@') && strlen(when) == 9) { strnfmt(tmp_val, sizeof(tmp_val), "%.4s-%.2s-%.2s", when + 1, when + 5, when + 7); when = tmp_val; } /* And still another line of info */ strnfmt(out_val, sizeof(out_val), "(User %s, Date %s, Gold %s, Turn %s).", user, when, gold, aged); c_put_str(attr, out_val, n*4 + 4, 15); } /* Wait for response */ prt("[Press ESC to exit, any other key to continue.]", 23, 17); ch = inkey(); prt("", 23, 0); /* Hack -- notice Escape */ if (ch == ESCAPE) break; } return; }
int m_zprint(void) { oprtype lab1,lab2,off1,off2,rtn; triple *ref,*next; bool got_some; error_def(ERR_LABELEXPECTED); error_def(ERR_RTNNAME); got_some = FALSE; lab1 = put_str(&zero_ident.c[0],sizeof(mident)); off1 = put_ilit(0); if (window_token != TK_EOL && window_token != TK_SPACE && !lref(&lab1,&off1,TRUE,indir_zprint,TRUE,&got_some)) return FALSE; if (lab1.oprclass == TRIP_REF && lab1.oprval.tref->opcode == OC_COMMARG) return TRUE; if (window_token != TK_CIRCUMFLEX) { if (!run_time) rtn = put_str(routine_name, mid_len ((mident *)routine_name)); else rtn = put_tref(newtriple(OC_CURRTN)); } else { got_some = TRUE; advancewindow(); switch(window_token) { case TK_IDENT: rtn = put_str(window_ident.c, mid_len (&window_ident)); advancewindow(); break; case TK_ATSIGN: if (!indirection(&rtn)) return FALSE; break; default: stx_error(ERR_RTNNAME); return FALSE; } } if (window_token == TK_COLON) { if (!got_some) { stx_error(ERR_LABELEXPECTED); return FALSE; } lab2 = put_str(&zero_ident.c[0],sizeof(mident)); off2 = put_ilit(0); advancewindow(); if (!lref(&lab2,&off2,TRUE,indir_zprint,FALSE,&got_some)) return FALSE; if (!got_some) { stx_error(ERR_LABELEXPECTED); return FALSE; } } else { lab2 = lab1; off2 = off1; } ref = newtriple(OC_ZPRINT); ref->operand[0] = rtn; next = newtriple(OC_PARAMETER); ref->operand[1] = put_tref(next); next->operand[0] = lab1; ref = newtriple(OC_PARAMETER); next->operand[1] = put_tref(ref); ref->operand[0] = off1; next = newtriple(OC_PARAMETER); ref->operand[1] = put_tref(next); next->operand[0] = lab2; ref = newtriple(OC_PARAMETER); next->operand[1] = put_tref(ref); ref->operand[0] = off2; return TRUE; }
static bool choose_kamae(void) { char choice; int new_kamae = 0; int i; rect_t display = ui_menu_rect(); char buf[80]; if (display.cx > 40) display.cx = 40; if (p_ptr->confused) { msg_print("You are too confused."); return FALSE; } screen_save(); Term_erase(display.x, display.y, display.cx); put_str("Choose Form: ", display.y, display.x + 1); Term_erase(display.x, display.y + 1, display.cx); put_str(" a) No form", display.y + 1, display.x + 1); for (i = 0; i < MAX_KAMAE; i++) { if (p_ptr->lev >= kamae_shurui[i].min_level) { sprintf(buf," %c) %-12s %s",I2A(i+1), kamae_shurui[i].desc, kamae_shurui[i].info); Term_erase(display.x, display.y + 2 + i, display.cx); put_str(buf, display.y + 2 + i, display.x + 1); } } while(1) { choice = inkey(); if (choice == ESCAPE) { screen_load(); return FALSE; } else if ((choice == 'a') || (choice == 'A')) { if (p_ptr->action == ACTION_KAMAE) set_action(ACTION_NONE); else msg_print("You are not assuming a posture."); screen_load(); return TRUE; } else if ((choice == 'b') || (choice == 'B')) { new_kamae = 0; break; } else if (((choice == 'c') || (choice == 'C')) && (p_ptr->lev > 29)) { new_kamae = 1; break; } else if (((choice == 'd') || (choice == 'D')) && (p_ptr->lev > 34)) { new_kamae = 2; break; } else if (((choice == 'e') || (choice == 'E')) && (p_ptr->lev > 39)) { new_kamae = 3; break; } } set_action(ACTION_KAMAE); if (p_ptr->special_defense & (KAMAE_GENBU << new_kamae)) msg_print("You reassume a posture."); else { p_ptr->special_defense &= ~(KAMAE_MASK); p_ptr->update |= (PU_BONUS); p_ptr->redraw |= (PR_STATE); msg_format("You assume a posture of %s form.",kamae_shurui[new_kamae].desc); p_ptr->special_defense |= (KAMAE_GENBU << new_kamae); } p_ptr->redraw |= PR_STATE; screen_load(); return TRUE; }
/* ** subtest_xenl(test_list, status, ch) ** ** (xenl) eat newline glitch */ static void subtest_xenl( struct test_list *t, int *state, int *ch) { int i, j, k; if (over_strike) { /* test (xenl) on overstrike terminals */ if (!can_go_home || !can_clear_screen) { ptextln("(xenl) Newline-glitch not tested, can't home cursor and clear."); generic_done_message(t, state, ch); return; } put_clear(); /* this test must be done in raw mode. Otherwise UNIX will translate CR to CRLF. */ if (stty_query(TTY_OUT_TRANS)) tty_raw(1, char_mask); ptext("\nreset (xenl). Does "); i = char_count; put_str("not ignore CR, does "); k = char_count; put_str("not ignore LF"); go_home(); for (j = 0; j < columns; j++) put_this(' '); put_cr(); for (j = 0; j < i; j++) putchp(' '); put_str("@@@\n@@"); go_home(); for (j = 0; j < columns; j++) put_this(' '); put_lf(); for (j = 0; j < k; j++) putchp(' '); put_str("@@@\r@@"); tty_set(); go_home(); put_newlines(4); sprintf(temp, "(xenl) Newline-glitch is %s in the data base", eat_newline_glitch ? "true" : "false"); ptextln(temp); } else { /* test (xenl) when (os) is reset */ if (!can_go_home) { ptextln("(xenl) Newline-glitch not tested, can't home cursor"); generic_done_message(t, state, ch); return; } /* (xenl) test */ put_clear(); /* this test must be done in raw mode. Otherwise UNIX will translate CR to CRLF. */ if (stty_query(TTY_OUT_TRANS)) tty_raw(1, char_mask); for (j = 0; j < columns; j++) put_this(' '); put_cr(); ptext("(xenl) should be set. Does not ignore CR"); go_home(); put_crlf(); for (j = 0; j < columns; j++) put_this(' '); put_lf(); /* test (cud1) */ ptext("(xenl) should be set. Ignores (cud1)"); go_home(); put_newlines(3); if (scroll_forward && cursor_down && strcmp(scroll_forward, cursor_down)) { for (j = 0; j < columns; j++) put_this(' '); put_ind(); /* test (ind) */ ptext("(xenl) should be set. Ignores (ind)"); go_home(); put_newlines(5); } tty_set(); ptextln("If you don't see text above telling you to set it, (xenl) should be false"); sprintf(temp, "(xenl) Newline-glitch is %s in the data base", eat_newline_glitch ? "true" : "false"); ptextln(temp); } generic_done_message(t, state, ch); }
/** * Special display, part 2b */ void display_player_stat_info(void) { int i, row, col; char buf[80]; /* Row */ row = 2; /* Column */ col = 42; /* Print out the labels for the columns */ c_put_str(COLOUR_WHITE, " Self", row-1, col+5); c_put_str(COLOUR_WHITE, " RB", row-1, col+12); c_put_str(COLOUR_WHITE, " CB", row-1, col+16); c_put_str(COLOUR_WHITE, " EB", row-1, col+20); c_put_str(COLOUR_WHITE, " Best", row-1, col+24); /* Display the stats */ for (i = 0; i < STAT_MAX; i++) { /* Reduced or normal */ if (player->stat_cur[i] < player->stat_max[i]) /* Use lowercase stat name */ put_str(stat_names_reduced[i], row+i, col); else /* Assume uppercase stat name */ put_str(stat_names[i], row+i, col); /* Indicate natural maximum */ if (player->stat_max[i] == 18+100) put_str("!", row+i, col+3); /* Internal "natural" maximum value */ cnv_stat(player->stat_max[i], buf, sizeof(buf)); c_put_str(COLOUR_L_GREEN, buf, row+i, col+5); /* Race Bonus */ strnfmt(buf, sizeof(buf), "%+3d", player->race->r_adj[i]); c_put_str(COLOUR_L_BLUE, buf, row+i, col+12); /* Class Bonus */ strnfmt(buf, sizeof(buf), "%+3d", player->class->c_adj[i]); c_put_str(COLOUR_L_BLUE, buf, row+i, col+16); /* Equipment Bonus */ strnfmt(buf, sizeof(buf), "%+3d", player->state.stat_add[i]); c_put_str(COLOUR_L_BLUE, buf, row+i, col+20); /* Resulting "modified" maximum value */ cnv_stat(player->state.stat_top[i], buf, sizeof(buf)); c_put_str(COLOUR_L_GREEN, buf, row+i, col+24); /* Only display stat_use if there has been draining */ if (player->stat_cur[i] < player->stat_max[i]) { cnv_stat(player->state.stat_use[i], buf, sizeof(buf)); c_put_str(COLOUR_YELLOW, buf, row+i, col+31); } } }
triple *entryref(opctype op1, opctype op2, mint commargcode, boolean_t can_commarg, boolean_t labref, boolean_t textname) { oprtype offset, label, routine, rte1; char rtn_text[SIZEOF(mident_fixed)], lab_text[SIZEOF(mident_fixed)]; mident rtnname, labname; mstr rtn_str, lbl_str; triple *ref, *next, *rettrip; boolean_t same_rout; rtnname.len = labname.len = 0; rtnname.addr = &rtn_text[0]; labname.addr = &lab_text[0]; /* These cases don't currently exist but if they start to exist, the code in this * routine needs to be revisited for proper operation as the textname conditions * were assumed not to happen if can_commarg was FALSE (which it is in the one * known use of textname TRUE - in m_zgoto). */ assert(!(can_commarg && textname)); switch (window_token) { case TK_INTLIT: int_label(); /* caution: fall through */ case TK_IDENT: memcpy(labname.addr, window_ident.addr, window_ident.len); labname.len = window_ident.len; advancewindow(); if ((TK_PLUS != window_token) && (TK_CIRCUMFLEX != window_token) && !IS_MCODE_RUNNING && can_commarg) { rettrip = newtriple(op1); rettrip->operand[0] = put_mlab(&labname); return rettrip; } label.oprclass = 0; break; case TK_ATSIGN: if(!indirection(&label)) return NULL; if ((TK_PLUS != window_token) && (TK_CIRCUMFLEX != window_token) && (TK_COLON != window_token) && can_commarg) { rettrip = ref = maketriple(OC_COMMARG); ref->operand[0] = label; ref->operand[1] = put_ilit(commargcode); ins_triple(ref); return rettrip; } labname.len = 0; break; case TK_PLUS: stx_error(ERR_LABELEXPECTED); return NULL; default: labname.len = 0; label.oprclass = 0; break; } if (!labref && (TK_PLUS == window_token)) { /* Have line offset specified */ advancewindow(); if (!intexpr(&offset)) return NULL; } else offset.oprclass = 0; if (TK_CIRCUMFLEX == window_token) { /* Have a routine name specified */ advancewindow(); switch(window_token) { case TK_IDENT: MROUT2XTERN(window_ident.addr, rtnname.addr, window_ident.len); rtn_str.len = rtnname.len = window_ident.len; rtn_str.addr = rtnname.addr; advancewindow(); if (!IS_MCODE_RUNNING) { /* Triples for indirect code */ same_rout = (MIDENT_EQ(&rtnname, &routine_name) && can_commarg); if (!textname) { /* Resolve routine and label names to addresses for most calls */ if (!label.oprclass && !offset.oprclass) { /* Routine only (no label or offset) */ if (same_rout) { rettrip = newtriple(op1); rettrip->operand[0] = put_mlab(&labname); } else { rettrip = maketriple(op2); if (rtnname.addr[0] == '%') rtnname.addr[0] = '_'; rettrip->operand[0] = put_cdlt(&rtn_str); mlabel2xtern(&lbl_str, &rtnname, &labname); rettrip->operand[1] = put_cdlt(&lbl_str); ins_triple(rettrip); } return rettrip; } else if (!same_rout) { rte1 = put_str(rtn_str.addr, rtn_str.len); if (rtnname.addr[0] == '%') rtnname.addr[0] = '_'; routine = put_cdlt(&rtn_str); ref = newtriple(OC_RHDADDR); ref->operand[0] = rte1; ref->operand[1] = routine; routine = put_tref(ref); } else routine = put_tref(newtriple(OC_CURRHD)); } else { /* Return the actual names used */ if (!label.oprclass && !offset.oprclass) { /* Routine only (no label or offset) */ rettrip = maketriple(op2); rettrip->operand[0] = put_str(rtn_str.addr, rtn_str.len); ref = newtriple(OC_PARAMETER); ref->operand[0] = put_str(labname.addr, labname.len); ref->operand[1] = put_ilit(0); rettrip->operand[1] = put_tref(ref); ins_triple(rettrip); return rettrip; } else routine = put_str(rtn_str.addr, rtn_str.len); } } else { /* Triples for normal compiled code */ routine = put_str(rtn_str.addr, rtn_str.len); if (!textname) { /* If not returning text name, convert text name to routine header address */ ref = newtriple(OC_RHDADDR1); ref->operand[0] = routine; routine = put_tref(ref); } } break; case TK_ATSIGN: if (!indirection(&routine)) return NULL; if (!textname) { /* If not returning text name, convert text name to routine header address */ ref = newtriple(OC_RHDADDR1); ref->operand[0] = routine; routine = put_tref(ref); } break; default: stx_error(ERR_RTNNAME); return NULL; } } else { if (!label.oprclass && (0 == labname.len)) { stx_error(ERR_LABELEXPECTED); return NULL; } if (!textname) routine = put_tref(newtriple(OC_CURRHD)); else { /* If we need a name, the mechanism to retrieve it differs between normal and indirect compilation */ if (!IS_MCODE_RUNNING) /* For normal compile, use routine name set when started compile */ routine = put_str(routine_name.addr, routine_name.len); else /* For an indirect compile, obtain the currently running routine header and pull the routine * name out of that. */ routine = put_str(frame_pointer->rvector->routine_name.addr, frame_pointer->rvector->routine_name.len); } } if (!offset.oprclass) offset = put_ilit(0); if (!label.oprclass) label = put_str(labname.addr, labname.len); ref = textname ? newtriple(OC_PARAMETER) : newtriple(OC_LABADDR); ref->operand[0] = label; next = newtriple(OC_PARAMETER); ref->operand[1] = put_tref(next); next->operand[0] = offset; if (!textname) next->operand[1] = routine; /* Not needed if giving text names */ rettrip = next = newtriple(op2); next->operand[0] = routine; next->operand[1] = put_tref(ref); return rettrip; }
static void _list_forms(int ct) { char temp[140]; int i; int y = 1; int x = 10; int col_height = _col_height(ct); int col_width; Term_erase(x, y, 255); if (col_height == ct) { Term_erase(x, y, 255); put_str("Lv Cost Fail", y, x + 29); } else { col_width = 42; x = 1; Term_erase(x, y, 255); put_str("Lv Cost Fail", y, x + 29); put_str("Lv Cost Fail", y, x + col_width + 29); } for (i = 0; i < ct; i++) { char letter = '\0'; byte attr = TERM_WHITE; int level = _forms[i].level; int race_idx = _forms[i].race; race_t *race_ptr = get_race_t_aux(race_idx, 0); int cost = _form_cost(race_ptr->exp); int fail = calculate_fail_rate(level, _forms[i].fail, p_ptr->stat_ind[A_DEX]); if (i < 26) letter = I2A(i); else if (i < 52) letter = 'A' + i - 26; else letter = '0' + i - 52; sprintf(temp, " %c) ", letter); strcat(temp, format("%-23.23s %2d %4d %3d%%", race_ptr->name, level, cost, fail)); if (fail == 100) attr = TERM_L_DARK; if (i < col_height) { c_prt(attr, temp, y + i + 1, x); } else { c_prt(attr, temp, y + (i - col_height) + 1, (x + col_width)); } } }
int m_zwatch(void) { boolean_t is_count; opctype op; oprtype count, name,action; triple *next, *ref; DCL_THREADGBL_ACCESS; SETUP_THREADGBL_ACCESS; if (TK_MINUS == TREF(window_token)) { advancewindow(); switch (TREF(window_token)) { case TK_ASTERISK: name = put_str(zero_ident.addr, zero_ident.len); count = put_ilit(CANCEL_ALL); advancewindow(); break; case TK_IDENT: name = put_str((TREF(window_ident)).addr, (TREF(window_ident)).len); count = put_ilit(CANCEL_ONE); advancewindow(); break; case TK_ATSIGN: if (!indirection(&name)) return FALSE; count = put_ilit(CANCEL_ONE); break; default: stx_error(ERR_VAREXPECTED); return FALSE; } action = put_str("",0); op = OC_WATCHREF; } else { if (TK_EQUAL == TREF(window_token)) { advancewindow(); op = OC_WATCHMOD; } else op = OC_WATCHREF; switch (TREF(window_token)) { case TK_IDENT: name = put_str((TREF(window_ident)).addr, (TREF(window_ident)).len); advancewindow(); break; case TK_ATSIGN: if (!indirection(&name)) return FALSE; if ((OC_WATCHREF == op) && (TK_COLON != TREF(window_token))) { ref = maketriple(OC_COMMARG); ref->operand[0] = name; ref->operand[1] = put_ilit((mint) indir_zwatch); ins_triple(ref); return TRUE; } break; default: stx_error(ERR_VAREXPECTED); return FALSE; } if (TK_COLON != TREF(window_token)) { action = put_str("",0); count = put_ilit(0); } else { advancewindow(); if (TK_COLON == TREF(window_token)) { is_count = TRUE; action = put_str("", 0); } else { if (EXPR_FAIL == expr(&action, MUMPS_STR)) return FALSE; is_count = (TK_COLON == TREF(window_token)); } if (is_count) { advancewindow(); if (EXPR_FAIL == expr(&count, MUMPS_INT)) return FALSE; } else count = put_ilit(0); } } ref = newtriple(op); ref->operand[0] = name; next = newtriple(OC_PARAMETER); ref->operand[1] = put_tref(next); next->operand[0] = action; next->operand[1] = count; return TRUE; }
static int rv10_write_header(AVFormatContext *ctx, int data_size, int index_pos) { RMMuxContext *rm = ctx->priv_data; AVIOContext *s = ctx->pb; StreamInfo *stream; unsigned char *data_offset_ptr, *start_ptr; const char *desc, *mimetype; int nb_packets, packet_total_size, packet_max_size, size, packet_avg_size, i; int bit_rate, v, duration, flags, data_pos; AVDictionaryEntry *tag; start_ptr = s->buf_ptr; ffio_wfourcc(s, ".RMF"); avio_wb32(s,18); /* header size */ avio_wb16(s,0); avio_wb32(s,0); avio_wb32(s,4 + ctx->nb_streams); /* num headers */ ffio_wfourcc(s,"PROP"); avio_wb32(s, 50); avio_wb16(s, 0); packet_max_size = 0; packet_total_size = 0; nb_packets = 0; bit_rate = 0; duration = 0; for(i=0;i<ctx->nb_streams;i++) { StreamInfo *stream = &rm->streams[i]; bit_rate += stream->bit_rate; if (stream->packet_max_size > packet_max_size) packet_max_size = stream->packet_max_size; nb_packets += stream->nb_packets; packet_total_size += stream->packet_total_size; /* select maximum duration */ v = (int) (1000.0 * (float)stream->total_frames / stream->frame_rate); if (v > duration) duration = v; } avio_wb32(s, bit_rate); /* max bit rate */ avio_wb32(s, bit_rate); /* avg bit rate */ avio_wb32(s, packet_max_size); /* max packet size */ if (nb_packets > 0) packet_avg_size = packet_total_size / nb_packets; else packet_avg_size = 0; avio_wb32(s, packet_avg_size); /* avg packet size */ avio_wb32(s, nb_packets); /* num packets */ avio_wb32(s, duration); /* duration */ avio_wb32(s, BUFFER_DURATION); /* preroll */ avio_wb32(s, index_pos); /* index offset */ /* computation of data the data offset */ data_offset_ptr = s->buf_ptr; avio_wb32(s, 0); /* data offset : will be patched after */ avio_wb16(s, ctx->nb_streams); /* num streams */ flags = 1 | 2; /* save allowed & perfect play */ if (!s->seekable) flags |= 4; /* live broadcast */ avio_wb16(s, flags); /* comments */ ffio_wfourcc(s,"CONT"); size = 4 * 2 + 10; for(i=0; i<FF_ARRAY_ELEMS(ff_rm_metadata); i++) { tag = av_dict_get(ctx->metadata, ff_rm_metadata[i], NULL, 0); if(tag) size += strlen(tag->value); } avio_wb32(s,size); avio_wb16(s,0); for(i=0; i<FF_ARRAY_ELEMS(ff_rm_metadata); i++) { tag = av_dict_get(ctx->metadata, ff_rm_metadata[i], NULL, 0); put_str(s, tag ? tag->value : ""); } for(i=0;i<ctx->nb_streams;i++) { int codec_data_size; stream = &rm->streams[i]; if (stream->enc->codec_type == AVMEDIA_TYPE_AUDIO) { desc = "The Audio Stream"; mimetype = "audio/x-pn-realaudio"; codec_data_size = 73; } else { desc = "The Video Stream"; mimetype = "video/x-pn-realvideo"; codec_data_size = 34; } ffio_wfourcc(s,"MDPR"); size = 10 + 9 * 4 + strlen(desc) + strlen(mimetype) + codec_data_size; avio_wb32(s, size); avio_wb16(s, 0); avio_wb16(s, i); /* stream number */ avio_wb32(s, stream->bit_rate); /* max bit rate */ avio_wb32(s, stream->bit_rate); /* avg bit rate */ avio_wb32(s, stream->packet_max_size); /* max packet size */ if (stream->nb_packets > 0) packet_avg_size = stream->packet_total_size / stream->nb_packets; else packet_avg_size = 0; avio_wb32(s, packet_avg_size); /* avg packet size */ avio_wb32(s, 0); /* start time */ avio_wb32(s, BUFFER_DURATION); /* preroll */ /* duration */ if (!s->seekable || !stream->total_frames) avio_wb32(s, (int)(3600 * 1000)); else avio_wb32(s, (int)(stream->total_frames * 1000 / stream->frame_rate)); put_str8(s, desc); put_str8(s, mimetype); avio_wb32(s, codec_data_size); if (stream->enc->codec_type == AVMEDIA_TYPE_AUDIO) { int coded_frame_size, fscode, sample_rate; sample_rate = stream->enc->sample_rate; coded_frame_size = (stream->enc->bit_rate * stream->enc->frame_size) / (8 * sample_rate); /* audio codec info */ avio_write(s, ".ra", 3); avio_w8(s, 0xfd); avio_wb32(s, 0x00040000); /* version */ ffio_wfourcc(s, ".ra4"); avio_wb32(s, 0x01b53530); /* stream length */ avio_wb16(s, 4); /* unknown */ avio_wb32(s, 0x39); /* header size */ switch(sample_rate) { case 48000: case 24000: case 12000: fscode = 1; break; default: case 44100: case 22050: case 11025: fscode = 2; break; case 32000: case 16000: case 8000: fscode = 3; } avio_wb16(s, fscode); /* codec additional info, for AC-3, seems to be a frequency code */ /* special hack to compensate rounding errors... */ if (coded_frame_size == 557) coded_frame_size--; avio_wb32(s, coded_frame_size); /* frame length */ avio_wb32(s, 0x51540); /* unknown */ avio_wb32(s, stream->enc->bit_rate / 8 * 60); /* bytes per minute */ avio_wb32(s, stream->enc->bit_rate / 8 * 60); /* bytes per minute */ avio_wb16(s, 0x01); /* frame length : seems to be very important */ avio_wb16(s, coded_frame_size); avio_wb32(s, 0); /* unknown */ avio_wb16(s, stream->enc->sample_rate); /* sample rate */ avio_wb32(s, 0x10); /* unknown */ avio_wb16(s, stream->enc->channels); put_str8(s, "Int0"); /* codec name */ if (stream->enc->codec_tag) { avio_w8(s, 4); /* tag length */ avio_wl32(s, stream->enc->codec_tag); } else { av_log(ctx, AV_LOG_ERROR, "Invalid codec tag\n"); return -1; } avio_wb16(s, 0); /* title length */ avio_wb16(s, 0); /* author length */ avio_wb16(s, 0); /* copyright length */ avio_w8(s, 0); /* end of header */ } else { /* video codec info */ avio_wb32(s,34); /* size */ ffio_wfourcc(s, "VIDO"); if(stream->enc->codec_id == AV_CODEC_ID_RV10) ffio_wfourcc(s,"RV10"); else ffio_wfourcc(s,"RV20"); avio_wb16(s, stream->enc->width); avio_wb16(s, stream->enc->height); avio_wb16(s, (int) stream->frame_rate); /* frames per seconds ? */ avio_wb32(s,0); /* unknown meaning */ avio_wb16(s, (int) stream->frame_rate); /* unknown meaning */ avio_wb32(s,0); /* unknown meaning */ avio_wb16(s, 8); /* unknown meaning */ /* Seems to be the codec version: only use basic H263. The next versions seems to add a diffential DC coding as in MPEG... nothing new under the sun */ if(stream->enc->codec_id == AV_CODEC_ID_RV10) avio_wb32(s,0x10000000); else avio_wb32(s,0x20103001); //avio_wb32(s,0x10003000); } } /* patch data offset field */ data_pos = s->buf_ptr - start_ptr; rm->data_pos = data_pos; data_offset_ptr[0] = data_pos >> 24; data_offset_ptr[1] = data_pos >> 16; data_offset_ptr[2] = data_pos >> 8; data_offset_ptr[3] = data_pos; /* data stream */ ffio_wfourcc(s, "DATA"); avio_wb32(s,data_size + 10 + 8); avio_wb16(s,0); avio_wb32(s, nb_packets); /* number of packets */ avio_wb32(s,0); /* next data header */ return 0; }
/*! * @brief プレイヤーが詠唱中の呪術から一つを選んで停止する * @return なし */ bool stop_hex_spell(void) { int spell; char choice; char out_val[160]; bool flag = FALSE; int y = 1; int x = 20; int sp[MAX_KEEP]; if (!hex_spelling_any()) { #ifdef JP msg_print("呪文を詠唱していません。"); #else msg_print("You are casting no spell."); #endif return FALSE; } /* Stop all spells */ else if ((p_ptr->magic_num2[0] == 1) || (p_ptr->lev < 35)) { return stop_hex_spell_all(); } else { #ifdef JP strnfmt(out_val, 78, "どの呪文の詠唱を中断しますか?(呪文 %c-%c, 'l'全て, ESC)", I2A(0), I2A(p_ptr->magic_num2[0] - 1)); #else strnfmt(out_val, 78, "Which spell do you stop casting? (Spell %c-%c, 'l' to all, ESC)", I2A(0), I2A(p_ptr->magic_num2[0] - 1)); #endif screen_save(); while (!flag) { int n = 0; Term_erase(x, y, 255); prt(" 名前", y, x + 5); for (spell = 0; spell < 32; spell++) { if (hex_spelling(spell)) { Term_erase(x, y + n + 1, 255); put_str(format("%c) %s", I2A(n), do_spell(REALM_HEX, spell, SPELL_NAME)), y + n + 1, x + 2); sp[n++] = spell; } } if (!get_com(out_val, &choice, TRUE)) break; if (isupper(choice)) choice = tolower(choice); if (choice == 'l') /* All */ { screen_load(); return stop_hex_spell_all(); } if ((choice < I2A(0)) || (choice > I2A(p_ptr->magic_num2[0] - 1))) continue; flag = TRUE; } } screen_load(); if (flag) { int n = sp[A2I(choice)]; do_spell(REALM_HEX, n, SPELL_STOP); p_ptr->magic_num1[0] &= ~(1L << n); p_ptr->magic_num2[0]--; } /* Redraw status */ p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS); p_ptr->redraw |= (PR_EXTRA | PR_HP | PR_MANA); return flag; }
static int get_snipe_power(int *sn, bool only_browse) { int i; int num = 0; int y = 1; int x = 20; int plev = p_ptr->lev; int ask; char choice; char out_val[160]; cptr p = "power"; snipe_power spell; bool flag, redraw; #ifdef ALLOW_REPEAT /* TNB */ repeat_push(*sn); /* Assume cancelled */ *sn = (-1); /* Repeat previous command */ /* Get the spell, if available */ if (repeat_pull(sn)) { /* Verify the spell */ if ((snipe_powers[*sn].min_lev <= plev) && (snipe_powers[*sn].mana_cost <= (int)p_ptr->concent)) { /* Success */ return (TRUE); } } #endif /* ALLOW_REPEAT -- TNB */ /* Nothing chosen yet */ flag = FALSE; /* No redraw yet */ redraw = FALSE; for (i = 0; i < MAX_SNIPE_POWERS; i++) { if ((snipe_powers[i].min_lev <= plev) && ((only_browse) || (snipe_powers[i].mana_cost <= (int)p_ptr->concent))) { num = i; } } /* Build a prompt (accept all spells) */ if (only_browse) { (void)strnfmt(out_val, 78, "(%^ss %c-%c, *=List, ESC=exit) Use which %s? ", p, I2A(0), I2A(num), p); } else { (void)strnfmt(out_val, 78, "(%^ss %c-%c, *=List, ESC=exit) Use which %s? ", p, I2A(0), I2A(num), p); } /* Get a spell from the user */ choice = always_show_list ? ESCAPE : 1; while (!flag) { if(choice == ESCAPE) choice = ' '; else if( !get_com(out_val, &choice, FALSE) )break; /* Request redraw */ if ((choice == ' ') || (choice == '*') || (choice == '?')) { /* Show the list */ if (!redraw) { char psi_desc[80]; /* Show list */ redraw = TRUE; /* Save the screen */ if (!only_browse) screen_save(); /* Display a list of spells */ prt("", y, x); put_str("Name", y, x + 5); if (only_browse) put_str("Lv Pow", y, x + 35); /* Dump the spells */ for (i = 0; i < MAX_SNIPE_POWERS; i++) { Term_erase(x, y + i + 1, 255); /* Access the spell */ spell = snipe_powers[i]; if (spell.min_lev > plev) continue; if (!only_browse && (spell.mana_cost > (int)p_ptr->concent)) continue; /* Dump the spell --(-- */ if (only_browse) sprintf(psi_desc, " %c) %-30s%2d %4d", I2A(i), spell.name, spell.min_lev, spell.mana_cost); else sprintf(psi_desc, " %c) %-30s", I2A(i), spell.name); prt(psi_desc, y + i + 1, x); } /* Clear the bottom line */ prt("", y + i + 1, x); } /* Hide the list */ else { /* Hide list */ redraw = FALSE; /* Restore the screen */ if (!only_browse) screen_load(); } /* Redo asking */ continue; } /* Note verify */ ask = isupper(choice); /* Lowercase */ if (ask) choice = tolower(choice); /* Extract request */ i = (islower(choice) ? A2I(choice) : -1); /* Totally Illegal */ if ((i < 0) || (i > num) || (!only_browse &&(snipe_powers[i].mana_cost > (int)p_ptr->concent))) { bell(); continue; } /* Save the spell index */ spell = snipe_powers[i]; /* Verify it */ if (ask) { char tmp_val[160]; /* Prompt */ (void)strnfmt(tmp_val, 78, "Use %s? ", snipe_powers[i].name); /* Belay that order */ if (!get_check(tmp_val)) continue; } /* Stop the loop */ flag = TRUE; } /* Restore the screen */ if (redraw && !only_browse) screen_load(); /* Show choices */ p_ptr->window |= (PW_SPELL); /* Window stuff */ window_stuff(); /* Abort if needed */ if (!flag) return (FALSE); /* Save the choice */ (*sn) = i; #ifdef ALLOW_REPEAT /* TNB */ repeat_push(*sn); #endif /* ALLOW_REPEAT -- TNB */ /* Success */ return (TRUE); }