int kanji_tknext(const char *s,int a,bool f) { int pa,pb; if (s[a]=='\0') return a; if (a>strlen(s)) return strlen(s); if (iskanji(s[a])) { pa=kanji_getctype(s[a],s[a+1]); do { a+=2; } while(iskanji(s[a])&& (pa&kanji_getctype(s[a],s[a+1]))!=0); pb=char_getctype(s[a]); }else { pa=char_getctype(s[a]); do { ++a; pb=char_getctype(s[a]); } while(pa==pb&&!iskanji(s[a])); } if (a==0|| iskanji(s[a])|| pb!=CT_skip|| !f) return a; ++a; while(pb==char_getctype(s[a])&&!iskanji(s[a])) ++a; return a; }
int IsKanjiPosition() { int i; i=GetBufferOffset(); return i+1<=strlen(csrle.buf) && iskanji(csrle.buf[i]) && iskanji(csrle.buf[i+1]); }
static void putstr(int mode, STR tp) { if (mode == ESCOFF) { fprintf(cur_fpo, "%s", tp); } else if (*tp == '\0') { fprintf(cur_fpo, "||"); // ヌル文字列を表す } else { if (num(tp)) { // read.h fputc('\\', cur_fpo); // 数値ではなく数字の場合は見分けるために'\\'を接頭辞としてつける } do { if (iskanji(*tp) && iskanji2(*(tp+1))) { fputc(*tp++, cur_fpo); fputc(*tp++, cur_fpo); } else if (!isprkana(*tp)) { fprintf(cur_fpo, "#\\%03d", *tp++); } else { if (isesc(*tp)) { fputc('\\', cur_fpo); } fputc(*tp++, cur_fpo); } } while (*tp != '\0'); } }
void RearrangeLineWhenInsSB (CONINFO* con) { u_int addr; int i; int prev = CODEIS_S; u_char ch, ch1; addr = text_offset (con, con->x, con->y) + 1; for (i = 0; i < con->xmax - con->x - 1; i++) { ch = con->textBuff [addr + i]; ch1 = con->textBuff [addr + i + 1]; if (iskanji (con, ch, ch1)) { switch (prev) { case CODEIS_S: case CODEIS_2: con->flagBuff [addr + i] = con->db | LATCH_1; prev = CODEIS_1; break; case CODEIS_1: con->flagBuff [addr + i] = con->db | LATCH_2; prev = CODEIS_1; break; } } else if (ch) { con->flagBuff [addr + i] = con->sb | LATCH_S; prev = CODEIS_S; } else prev = CODEIS_S; } }
/* read a line from stdin */ char * read_line (char *prompt) { static STRING_T *ds = 0; int c; #ifdef SHIFT_JIS size_t ds_length = 0; #endif if (ds == 0) ds = DScreate (); DSresize (ds, 0, 0); fputs (prompt, stdout); fflush (stdout); #ifndef SHIFT_JIS /* Normal terminal input. Assumes that I don't have to handle control characters here. */ while ((c = getchar ()) != EOF && c != '\n') DSappendchar (ds, c, 1); #else /* SHIFT_JIS */ /* Rolling our own getchar loop here. The thing to watch out for is that a backspace has to destroy BOTH characters of a Shift-JIS code and that a carriage return is equivalent to a newline. */ do { while (!kbhit_f ()) ; /* key wait */ c = getch (); if (c == '\r') c = '\n'; if (c == '\b') { /* handle backspace */ ds_length = DSlength (ds); if (ds_length >= 2 && iskanji (DSgetat (ds, ds_length - 2))) { DSresize (ds, ds_length - 2, 0); fputs ("\b \b\b \b", stdout); } else if (ds_length > 0) { DSresize (ds, ds_length - 1, 0); fputs ("\b \b", stdout); } } else { /* normal character */ putchar (c); DSappendchar (ds, c, 1); } fflush (stdout); } while (c != EOF && c != '\n'); #endif /* SHIFT_JIS */ return DScstr (ds); }
int IsThisKanjiPosition(int offset,const char *buffer) { int i; int Iskanji_flg; Iskanji_flg=FALSE; for (i = 0; i <= offset; i++) { if (iskanji(buffer[i]) && iskanji(buffer[i+1])) { i++; Iskanji_flg = TRUE; } else { Iskanji_flg = FALSE; } } if (i == offset+1) Iskanji_flg=FALSE; return Iskanji_flg; }
/* strが同じ文字の繰り返しかどうか調べる */ static bool string_is_repeat(char *str, int len) { char c = str[0]; int i; if (len < 2) return (FALSE); #ifdef JP if (iskanji(c)) return (FALSE); #endif for (i = 1; i < len; i++) { #ifdef JP if(c != str[i] || iskanji(str[i])) return (FALSE); #else if(c != str[i]) return (FALSE); #endif } return (TRUE); }
/*! * @brief シンダリンを日本語の読みに変換する * @param kana 変換後の日本語文字列ポインタ * @param sindarin 変換前のシンダリン文字列ポインタ * @return なし * @details */ void sindarin_to_kana(char *kana, const char *sindarin) { char buf[256]; int idx; sprintf(kana, "%s$", sindarin); for (idx = 0; kana[idx]; idx++) if (isupper(kana[idx])) kana[idx] = tolower(kana[idx]); for (idx = 0; s2j_table[idx].key1 != NULL; idx++) { cptr pat1 = s2j_table[idx].key1; cptr pat2 = s2j_table[idx].key2; int len = strlen(pat1); char *src = kana; char *dest = buf; while (*src) { if (strncmp(src, pat1, len) == 0) { strcpy(dest, pat2); src += len; dest += strlen(pat2); } else { if (iskanji(*src)) { *dest = *src; src++; dest++; } *dest = *src; src++; dest++; } } *dest = 0; strcpy(kana, buf); } idx = 0; while (kana[idx] != '$') idx++; kana[idx] = '\0'; }
int main() { int c, d; while ((c = getchar()) != EOF) { if (iskanji(c)) { d = getchar(); if (iskanji2(d)) { jis(&c, &d); putchar(c | 0x80); putchar(d | 0x80); } else { putchar(c); if (d != EOF) putchar(d); } } else putchar(c); } return EXIT_SUCCESS; }
// 2009/8/26 // // " -> \", \ -> \\ とする // in: dst .. 変換後の文字列を格納するバッファ // src .. 元の文字列バッファ // void encode_copy(TCHAR *dst, TCHAR *src) { int flag; flag = FALSE; while(*src != '\0') { if(flag) { flag = FALSE; } else { if(iskanji((unsigned char)*src)) { flag = TRUE; } else if(*src == '\\' || *src == '"') { *dst++ = '\\'; } } *dst++ = *src++; } *dst = '\0'; }
/* Win版の床の中点と壁の豆腐をピリオドとシャープにする。*/ static void win2unix(int col, char *buf) { char kabe; if ( col == 9 ) kabe = '%'; else kabe = '#'; while (*buf) { #ifdef JP if (iskanji(*buf)) { buf += 2; continue; } #endif if (*buf == 127) *buf = kabe; else if(*buf == 31) *buf = '.'; buf++; } }
// // ディレクトリのみ切り出す // in: path .. フルパス名 // void extract_directory(TCHAR *path) { int flag; TCHAR *pt; pt = NULL; flag = FALSE; while(*path != '\0') { if(flag) { flag = FALSE; } else { if(iskanji((unsigned char)*path)) { flag = TRUE; } else if(*path == '\\') { pt = path; } } path++; } if(pt != NULL) { *pt = '\0'; } }
_WCRTLINK FJSTRING _WCI86FAR _fjstrrev( JCHAR _WCFAR *s ) { JCHAR _WCFAR *p, _WCFAR *q, _WCFAR *r; p = s; q = p + _fstrlen( p ); while( p < q ) { if( iskanji( *p ) ) { if( iskanji2( *( r = p + 1 ) ) ) { *p ^= *r; *r ^= *p; *p++ ^= *r; } } p++; } p = s; while( p < --q ) { *p ^= *q; *q ^= *p; *p++ ^= *q; } return( s ); }
static void putstr(int mode, STR tp) {//N// if(mode == ESCOFF) { fprintf(cur_fpo, "%s", tp); } else if(*tp == '\0') { fprintf(cur_fpo, "||"); } else { if(num(tp)) { fputc('\\', cur_fpo); } do { if(iskanji(*tp) && iskanji2(*(tp+1))) { fputc(*tp++, cur_fpo); fputc(*tp++, cur_fpo); } else if(!isprkana(*tp)) { fprintf(cur_fpo, "#\\%03d", *tp++); } else { if(isesc(*tp)) { fputc('\\', cur_fpo); } fputc(*tp++, cur_fpo); } } while(*tp != '\0'); } }
// // ファイル名のみ取り出す // in: name .. ファイル名を格納するバッファ // path .. フルパス名 // void extract_name_only(TCHAR *name, TCHAR *path) { int flag; TCHAR *pt; pt = path; flag = FALSE; while(*path != '\0') { if(flag) { flag = FALSE; } else { if(iskanji((unsigned char)*path)) { flag = TRUE; } else if(*path == '\\' || *path == ':') { pt = path + 1; } } path++; } while(*pt != '\0' && *pt != '.') { *name++ = *pt++; } *name = '\0'; }
/*! * @brief nameバッファ内からベースアイテム名を返す / Strip an "object name" into a buffer * @param buf ベースアイテム格納先の参照ポインタ * @param k_idx ベースアイテムID * @return なし */ void strip_name(char *buf, int k_idx) { char *t; object_kind *k_ptr = &k_info[k_idx]; cptr str = (k_name + k_ptr->name); /* Skip past leading characters */ while ((*str == ' ') || (*str == '&')) str++; /* Copy useful chars */ for (t = buf; *str; str++) { #ifdef JP if (iskanji(*str)) {*t++ = *str++; *t++ = *str; continue;} #endif if (*str != '~') *t++ = *str; } /* Terminate the new name */ *t = '\0'; }
static int subform(STR tp, CELLP args) { CELLP tmp = args; STR tps; char c, s, fmt[NAMELEN] = {0}; while (*tp != '\0') { // "~"が出てくるまでは単に出力するだけ for (;; ++tp) { if (*tp == '\0') { return 0; } if (*tp == '~') { break; } if (iskanji(*tp)) { fputc(*tp++ , cur_fpo); } fputc(*tp, cur_fpo); } // 各種指定のチェック tps = tp; if (*(++tp) == '-') { ++tp; } while (isdigit(*tp)) { ++tp; } if (*tp == ',') { ++tp; } while (isdigit(*tp)) { ++tp; } if (*tp == ':') { ++tp; s = 0; } else { s = 1; } if (*tp == '@') { ++tp; c = 1; } else { c = 0; } switch (*tp) { case 'd': case 'x': case 'o': if (s) { // 継続オプションのないときは引数をすすめる tmp = args; args = args->cdr; } if (tmp->id != _CELL) { return (int)error(NEA); } if (tmp->car->id != _FIX) { return (int)error(IAF); } ins_l((STR)fmt, tps, ++tp); fprintf(cur_fpo, fmt, ((NUMP)(tmp->car))->value.fix); break; case 'e': case 'f': case 'g': if (s) { tmp = args; args = args->cdr; } if (tmp->id != _CELL) { return (int)error(IAFL); } if (tmp->car->id != _FLT) { return (int)error(IAFL); } copyform((STR)fmt, tps, ++tp); fprintf(cur_fpo, fmt, ((NUMP)(tmp->car))->value.flt); break; case 'c': if (s) { tmp = args; args = args->cdr; } if (tmp->id != _CELL) { return (int)error(NEA); } if (tmp->car->id != _FIX) { return (int)error(IAF); } copyform((STR)fmt, tps, ++tp); fprintf(cur_fpo, fmt, ((NUMP)(tmp->car))->value.fix); break; case 'a': if (s) { tmp = args; args = args->cdr; } if (tmp->id != _CELL) { return (int)error(NEA); } if (tmp->car->id != _ATOM) { // 引数がシンボルでないときはprincで出力 print_s(tmp->car, ESCOFF); ++tp; } else { // 引数がシンボルのときは、引字名を"%s"出力する copyform((STR)fmt, tps, ++tp); *(fmt + (tp - tps) -1) = 's'; fprintf(cur_fpo, fmt, ((ATOMP)(tmp->car))->name); } break; case 's': if (s) { tmp = args; args = args->cdr; } if (tmp->id != _CELL) { return (int)error(NEA); } print_s(tmp->car, ESCON); ++tp; break; case 'p': if (s) { tmp = args; args = args->cdr; } ++tp; if (tmp->id != _CELL) { return (int)error(NEA); } if (tmp->car->id != _FIX) { break; } if (((NUMP)(tmp->car))->value.fix == 1) { if (c) { fputc('y', cur_fpo); } break; } if (c) { fprintf(cur_fpo, "ies"); } else { fputc('s', cur_fpo); } break; case 'n': fputc('\n', cur_fpo); ++tp; break; case 'r': fputc('\r', cur_fpo); ++tp; break; case 't': fputc('\t', cur_fpo); ++tp; break; case 'b': fputc('\b', cur_fpo); ++tp; break; default: args = tmp; copyform((STR)fmt, ++tps, ++tp); fprintf(cur_fpo, fmt); } } return 0; }
pattern_type parse_pattern(const TCHAR *ptn, pattern_type typeold, const TCHAR **patternp, const TCHAR **patternendp, const TCHAR **prerepp, const TCHAR **prerependp, const TCHAR **optionp, const TCHAR **optionendp, TCHAR *msg) { if (ptn == NULL) { *patternp = NULL; *patternendp = NULL; *prerepp = NULL; *prerependp = NULL; *optionp = NULL; *optionendp = NULL; return typeold; } pattern_type type = PTN_MATCH; const TCHAR *p = ptn; const TCHAR *ptnend = ptn + _tcslen(ptn); TCHAR sep = '/'; // default separater if (*p != sep) { if (*p != 's' && *p != 'm' && *p != 'y' && (p[0] != 't' || p[1] != 'r')) { asc2tcs(msg, "does not start with 'm', 's', 'tr' or 'y'", BREGEXP_MAX_ERROR_MESSAGE_LEN); return PTN_ERROR; } if (*p == 's') { type = PTN_SUBST; // substitute command } else if (*p == 'y') { type = PTN_TRANS; // translate command } else if (*p == 't') { type = PTN_TRANS; // translate command p++; } sep = *++p; } p++; // skip separater *patternp = p; const TCHAR *res = p; const TCHAR *resend = NULL, *rp = NULL, *rpend = NULL; TCHAR prev = 0; while (p < ptnend) { #ifndef UNICODE if (iskanji(*p)) { prev = 0; p += 2; continue; } #endif if (*p == '\\' && prev == '\\') { prev = 0; p++; continue; } if (*p == '/' && prev == '\\') { // \/ means / prev = 0; p++; continue; } if (*p == sep && prev != '\\') { if (resend == NULL) { resend = p; rp = ++p; continue; } else { rpend = p; } p++; break; } prev = *p++; } if ((resend == NULL) || (rpend == NULL && type != PTN_MATCH)) { asc2tcs(msg, "unmatch separater", BREGEXP_MAX_ERROR_MESSAGE_LEN); return PTN_ERROR; } if (rpend == NULL) { p = resend + 1; rp = NULL; } *patternendp = resend; *prerepp = rp; *prerependp = rpend; *optionp = p; *optionendp = ptnend; return type; }
/*! * @brief 字句解析(LLVM-IR用) * * 字句解析を行い、トークンを拾います。 * * @param[in] line 入力する文字列 * @param[out] token 文字列から取得できた最初のトークン * @return 常に0です。 */ int get_token_llvm(char *line, char *token) { char *p,*ptk,str; char *pp; // ポインタの初期化 p = line; ptk = token; // 空白かタブの場合、読み飛ばす while(*p == ' ' || *p == '\t') ++p; // バッファが空の場合は終了する if(*p == '\0'){ pp = malloc(strlen(p)+1); // 残りの文字列をlineに戻す strcpy(pp,p); strcpy(line,pp); free(pp); token[0] = '\0'; return 1; } if(iskanji(p)){ // 漢字の判定 do{ *ptk++ = *p++; // 1バイト目 if(!iskanji(p)){ // 2バイト目 //printf("can't decode 2Byte Character(KANJI).\n"); //exit(1); } //*ptk++ = *p++; }while(iskanji(p) && *p != '\0'); strcpy(token, "KANJI"); // 漢字を検出した場合はポインタを戻して、NULL文字とする }else if(*p == 'c' && *(p+1) == '"'){ *ptk++ = *p++; // c"で始まる(これはキャラクター宣言である) do{ *ptk++ = *p++; }while(*p != '"' && *p !='\0'); *ptk++ = *p++; }else if(isalpha(*p)){ // 1文字目は英字、2文字目以降は英数字 do{ *ptk++ = *p++; }while((isalnum(*p) || *p == '_' || *p == '*' || *p =='.') && *p !='\0'); // 2文字目以降は英数字、又は"_"である }else if(*p == '0'){ // 数字(0で始まる数字) *ptk++ = *p++; if(*p == 'x' || *p == 'X'){ do{ *ptk++ = *p++; }while((isdigit(*p) || *p =='.' || (*p >= 'a' && *p <= 'f') || (*p >= 'A' && *p <= 'F')) && *p !='\0'); }else if(isdigit(*p)){ do{ *ptk++ = *p++; }while((isdigit(*p) || *p =='.') && *p !='\0'); }else if(*p == '.'){ // 小数点以下の数値 do{ *ptk++ = *p++; }while((isdigit(*p) || *p =='.') && *p !='\0'); } }else if(isdigit(*p)){ // 数字(0以外で始まる数字) do{ *ptk++ = *p++; }while((isdigit(*p) || *p =='.') && *p !='\0'); }else if(*p == '-'){ // マイナス値 do{ *ptk++ = *p++; }while((isdigit(*p) || *p =='.') && *p !='\0'); }else if(*p == '.'){ // ラベル名 str = *p; do{ *ptk++ = *p++; }while((isalnum(*p) || *p == '_' || *p == '.') && *p !='\0'); }else if(*p == '@'){ str = *p; do{ *ptk++ = *p++; }while((isalnum(*p) || *p == '_' || *p == '.') && *p !='\0'); }else if(*p == '%'){ str = *p; do{ *ptk++ = *p++; }while((isalnum(*p) || *p == '_' || *p == '.' || *p == '*') && *p !='\0'); }else if(*p == '!'){ str = *p; do{ *ptk++ = *p++; }while((isalnum(*p) || *p == '_' || *p == '.') && *p !='\0'); }else if(*p == '#'){ str = *p; do{ *ptk++ = *p++; }while((isalnum(*p) || *p == '_' || *p == '.') && *p !='\0'); }else if(*p == '='){ // 等しい: =, == str = *p; *ptk++ = *p++; if(*p == str){ *ptk++ = *p++; } }else if(*p == '>' || *p == ']'){ // ポインタ: >*, ]* str = *p; *ptk++ = *p++; if(*p == '*'){ *ptk++ = *p++; } }else if(*p == '.'){ // ... str = *p; *ptk++ = *p++; do{ *ptk++ = *p++; }while((*p == str) && *p !='\0'); }else if(*p == '\\'){ do{ *ptk++ = *p++; }while(isalnum(*p) && *p !='\0'); // 2文字目以降は英数字 }else if((*p == '\r') || (*p == '\n')){ // 改行 str = '\0'; *ptk++ = *p++; }else{ // その他の文字 *ptk++ = *p++; } *ptk = '\0'; // 文字の終端 pp = malloc(strlen(p)+1); // 残りの文字列をlineに戻す strcpy(pp,p); strcpy(line,pp); free(pp); return 0; }
/*! * @brief 字句解析 * * 字句解析を行い、トークンを拾います。 * * @param[in] line 入力する文字列 * @param[out] token 文字列から取得できた最初のトークン * @return 常に0です。 */ int get_token(char *line, char *token) { char *p,*ptk,str; char *pp; // ポインタの初期化 p = line; ptk = token; // 空白かタブの場合、読み飛ばす while(*p == ' ' || *p == '\t') ++p; // バッファが空の場合は終了する if(*p == '\0'){ pp = malloc(strlen(p)+1); // 残りの文字列をlineに戻す strcpy(pp,p); strcpy(line,pp); free(pp); token[0] = '\0'; return 1; } if(iskanji(p)){ // 漢字の判定 do{ *ptk++ = *p++; // 1バイト目 if(!iskanji(p)){ // 2バイト目 //printf("can't decode 2Byte Character(KANJI).\n"); //exit(1); } //*ptk++ = *p++; }while(iskanji(p) && *p != '\0'); strcpy(token, "KANJI"); // 漢字を検出した場合はポインタを戻して、NULL文字とする }else if(isalpha(*p)){ // 1文字目は英字、2文字目以降は英数字 do{ *ptk++ = *p++; }while((isalnum(*p) || *p == '_') && *p !='\0'); // 2文字目以降は英数字、又は"_"である }else if(*p == '0'){ // 数字(0で始まる数字) *ptk++ = *p++; if(*p == 'x' || *p == 'X'){ do{ *ptk++ = *p++; }while((isdigit(*p) || *p =='.' || (*p >= 'a' && *p <= 'f') || (*p >= 'A' && *p <= 'F')) && *p !='\0'); }else if(isdigit(*p)){ do{ *ptk++ = *p++; }while((isdigit(*p) || *p =='.') && *p !='\0'); }else if(*p == '.'){ // 小数点以下の数値 do{ *ptk++ = *p++; }while((isdigit(*p) || *p =='.') && *p !='\0'); } }else if(isdigit(*p)){ // 数字(0以外で始まる数字) do{ *ptk++ = *p++; }while((isdigit(*p) || *p =='.') && *p !='\0'); }else if(*p == '\'' || *p == '"'){ // 文字・文字列定数: ', ", '', "", str = *p; do{ *ptk++ = *p++; }while(*p != str && *p !='\0'); *ptk++ = *p++; }else if(*p == '*'){ // 乗算、コメント: *, *=, **, */ str = *p; *ptk++ = *p++; if(*p == str || *p == '/' || *p == '='){ *ptk++ = *p++; }else{ // ポインター do{ *ptk++ = *p++; }while((isalnum(*p) || *p == '_') && *p !='\0'); // 2文字目以降は英数字、又は"_"である } }else if(*p == '+'){ // 加算: +, ++, += str = *p; *ptk++ = *p++; if(*p == str || *p == '='){ *ptk++ = *p++; } }else if(*p == '-'){ // 減算: -, --, ->, -= str = *p; *ptk++ = *p++; if(*p == str || *p == '>' || *p == '='){ *ptk++ = *p++; } }else if(*p == '/'){ // 除算、コメント: /, /=, //, /* str = *p; *ptk++ = *p++; if(*p == str || *p == '*' || *p == '='){ *ptk++ = *p++; } }else if(*p == '&' || *p == '|'){ // 論理演算子: &, |, &&, ||, &=, |= str = *p; *ptk++ = *p++; if(*p == str || *p == '='){ *ptk++ = *p++; } }else if(*p == '>' || *p == '<'){ // 比較、シフト: >, <, >>, <<, >=, <= str = *p; *ptk++ = *p++; if(*p == str || *p == '='){ *ptk++ = *p++; } }else if(*p == '!'){ // 等しくない: !, != str = *p; *ptk++ = *p++; if(*p == '='){ *ptk++ = *p++; } }else if(*p == '='){ // 等しい: =, == str = *p; *ptk++ = *p++; if(*p == str){ *ptk++ = *p++; } }else{ // その他の文字 *ptk++ = *p++; } *ptk = '\0'; // 文字の終端 pp = malloc(strlen(p)+1); // 残りの文字列をlineに戻す strcpy(pp,p); strcpy(line,pp); free(pp); return 0; }
/**************************************************************************** * very important interface, output the buff * ****************************************************************************/ void VtWrite (CONINFO *con, const char *buff, int nchars) { u_char ch, ch1; /* This is all the esc sequence strings */ #if 0 { FILE *fff; int i; fff = fopen("/tmp/ccegb-esc.log", "a"); for(i = 0; i < nchars; i++) fprintf (fff, "%c", buff[i]); fprintf (fff," (%d, %d)\n", con->x, con->y); fclose (fff); } #endif while (nchars-- > 0) { ch = *buff++; ch1 = *buff; if (!ch) continue; if (con->esc) con->esc (con, ch); // in escape mode, parse the parameters else { switch (ch) { case CHAR_BEL: // 0x07 Ping (); break; case CHAR_DEL: // 0x7F break; case CHAR_BS: // 0x08 if (con->x) con->x--; con->wrap = false; break; case CHAR_HT: //0x09 con->x += con->tab - (con->x % con->tab); con->wrap = false; if (con->x > con->xmax) con->x -= con->xmax + 1; else break; case CHAR_VT: // 0x0B case CHAR_FF: // 0x0C #if 1 con->trans = CS_LEFT; con->sb = 0; con->db = LATCH_1; /* no break? */ #endif case CHAR_LF: // 0x0A con->wrap = false; if (con->y == con->ymax) con->scroll ++; else con->y ++; break; case CHAR_CR: // 0x0D con->x = 0; con->wrap = false; break; case CHAR_ESC: // 0x1B con->esc = EscStart; continue; case CHAR_SO: // 0x0E con->trans = con->g[1] | G1_SET; continue; case CHAR_SI: // 0x0F con->trans = con->g[0]; continue; default: if (con->x == con->xmax + 1) { con->wrap = true; con->x --; } if (con->wrap) { con->x -= con->xmax; if (con->y == con->ymax) con->scroll ++; else con->y ++; con->wrap = false; buff --; nchars ++; #ifdef USECCEWAY /* Upate position of second half of the double-byte char */ if (con->knj1) { con->knj1x = con->x; con->knj1y = con->y; con->knj2x = con->x + 1; con->knj2y = con->y; } #endif break; } #ifndef USECCEWAY if (iskanji (con, ch, ch1)) { if (con->ins) TextInsertChar (con, 1); switch (FirstOrSecondByte (con, ch)) { case CODEIS_1: TextWput1 (con, ch); break; case CODEIS_2: TextWput2 (con, ch); break; default: TextSput (con, ch); RearrangeLineWhenInsSB (con); break; } con->x ++; continue; } else { if (con->ins) TextInsertChar (con, 1); TextSput (con, ch); RearrangeLineWhenInsSB (con); con->x ++; continue; } #else if ( con->knj1 && iskanji_byte2 (con, ch) && ( ((con->x == con->knj2x) && (con->y == con->knj2y)) || ((con->x == con->knj1x) && (con->y == con->knj1y)) ) ) { short oldx, oldy; /* special handling for Japanese char */ if (con->knj1 & 0x80) { switch(con->sysCoding) { case CODE_EUC: if (con->knj1 == (u_char)CHAR_SS2) { /* handling 'kata-kana' */ if (con->ins) TextInsertChar (con, 1); TextSput (con, ch); con->x ++; con->knj1 = 0; continue; } con->knj1 &= 0x7F; ch &= 0x7F; break; case CODE_SJIS: sjistojis (con->knj1, ch); break; } // case } else { if (con->db == (DF_BIG5_0|LATCH_1)) muletobig5 (con->db, con->knj1, ch); } oldx = con->x; oldy = con->y; con->x = con->knj1x; con->y = con->knj1y; if (con->ins) TextInsertChar (con, 2); TextWput (con, con->knj1, ch); con->x = oldx + 2; con->y = oldy; con->knj1 = 0; continue; } else if (con->trans == CS_DBCS || (iskanji (con, ch, ch1) && con->trans == CS_LEFT)) { if (con->x == con->xmax) con->wrap = true; else { con->knj1x = con->x; con->knj1y = con->y; con->knj2x = con->x + 1; con->knj2y = con->y; } /* First Half of the double-byte char */ con->knj1 = ch; continue; } else { if (con->ins) TextInsertChar (con, 1); TextSput (con, con->trans == CS_RIGHT ? ch | 0x80: ch); con->x ++; continue; } #endif } /* switch */ } if (con->scroll > 0) ScrollUp (con, con->scroll); else if (con->scroll < 0) ScrollDown (con, -con->scroll); con->scroll = 0; } /* while */ }
/* * Identify a character, allow recall of monsters * * Several "special" responses recall "multiple" monsters: * ^A (all monsters) * ^U (all unique monsters) * ^N (all non-unique monsters) * * The responses may be sorted in several ways, see below. * * Note that the player ghosts are ignored. XXX XXX XXX */ void do_cmd_query_symbol(void) { int i, n, r_idx; char sym, query; char buf[128]; bool all = FALSE; bool uniq = FALSE; bool norm = FALSE; char temp[80] = ""; bool recall = FALSE; u16b why = 0; u16b *who; /* Get a character, or abort */ #ifdef JP if (!get_com("知りたい文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^M名前): ", &sym)) return; #else if (!get_com("Enter character to be identified(^A:All,^U:Uniqs,^N:Non uniqs,^M:Name): ", &sym)) return; #endif /* Find that character info, and describe it */ for (i = 0; ident_info[i]; ++i) { if (sym == ident_info[i][0]) break; } /* Describe */ if (sym == KTRL('A')) { all = TRUE; #ifdef JP strcpy(buf, "全モンスターのリスト"); #else strcpy(buf, "Full monster list."); #endif } else if (sym == KTRL('U')) { all = uniq = TRUE; #ifdef JP strcpy(buf, "ユニーク・モンスターのリスト"); #else strcpy(buf, "Unique monster list."); #endif } else if (sym == KTRL('N')) { all = norm = TRUE; #ifdef JP strcpy(buf, "ユニーク外モンスターのリスト"); #else strcpy(buf, "Non-unique monster list."); #endif } /* XTRA HACK WHATSEARCH */ else if (sym == KTRL('M')) { all = TRUE; #ifdef JP if (!get_string("名前(英語の場合小文字で可)",temp, 70)) #else if (!get_string("Enter name:",temp, 70)) #endif { temp[0] = 0; all = FALSE; } #ifdef JP sprintf(buf, "名前:%sにマッチ",temp); #else sprintf(buf, "Monsters with a name \"%s\"",temp); #endif } else if (ident_info[i]) { #ifdef JP sprintf(buf, "%c - %s", sym, ident_info[i] + 2); #else sprintf(buf, "%c - %s.", sym, ident_info[i] + 2); #endif } else { #ifdef JP sprintf(buf, "%c - %s", sym, "無効な文字"); #else sprintf(buf, "%c - %s.", sym, "Unknown Symbol"); #endif } /* Display the result */ prt(buf, 0, 0); /* Allocate the "who" array */ C_MAKE(who, max_r_idx, u16b); /* Collect matching monsters */ for (n = 0, i = 1; i < max_r_idx; i++) { monster_race *r_ptr = &r_info[i]; /* Nothing to recall */ if (!cheat_know && !r_ptr->r_sights) continue; /* Require non-unique monsters if needed */ if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue; /* Require unique monsters if needed */ if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue; /* XTRA HACK WHATSEARCH */ if (temp[0]) { int xx; char temp2[80]; for (xx=0; temp[xx] && xx<80; xx++) { #ifdef JP if (iskanji(temp[xx])) { xx++; continue; } #endif if (isupper(temp[xx])) temp[xx]=tolower(temp[xx]); } #ifdef JP strcpy(temp2, r_name+r_ptr->E_name); #else strcpy(temp2, r_name+r_ptr->name); #endif for (xx=0; temp2[xx] && xx<80; xx++) { if (isupper(temp2[xx])) temp2[xx] = tolower(temp2[xx]); } #ifdef JP if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp)) #else if (my_strstr(temp2, temp)) #endif who[n++]=i; } else /* Collect "appropriate" monsters */ if (all || (r_ptr->d_char == sym)) who[n++] = i; } if (!n) { /* XXX XXX Free the "who" array */ C_KILL(who, max_r_idx, u16b); return; } /* Prompt XXX XXX XXX */ #ifdef JP put_str("思い出を見ますか? (k:殺害順/y/n): ", 0, 36); #else put_str("Recall details? (k/y/n): ", 0, 40); #endif /* Query */ query = inkey(); /* Restore */ prt(buf, 0, 0); why = 2; /* Select the sort method */ ang_sort_comp = ang_sort_comp_hook; ang_sort_swap = ang_sort_swap_hook; /* Sort the array */ ang_sort(who, &why, n); /* Sort by kills (and level) */ if (query == 'k') { why = 4; query = 'y'; } /* Catch "escape" */ if (query != 'y') { /* XXX XXX Free the "who" array */ C_KILL(who, max_r_idx, u16b); return; } /* Sort if needed */ if (why == 4) { /* Select the sort method */ ang_sort_comp = ang_sort_comp_hook; ang_sort_swap = ang_sort_swap_hook; /* Sort the array */ ang_sort(who, &why, n); } /* Start at the end */ i = n - 1; /* Scan the monster memory */ while (1) { /* Extract a race */ r_idx = who[i]; /* Hack -- Auto-recall */ monster_race_track(r_idx); /* Hack -- Handle stuff */ handle_stuff(); /* Hack -- Begin the prompt */ roff_top(r_idx); /* Hack -- Complete the prompt */ #ifdef JP Term_addstr(-1, TERM_WHITE, " ['r'思い出, ESC]"); #else Term_addstr(-1, TERM_WHITE, " [(r)ecall, ESC]"); #endif /* Interact */ while (1) { /* Recall */ if (recall) { /* Save the screen */ screen_save(); /* Recall on screen */ screen_roff(who[i], 0); /* Hack -- Complete the prompt (again) */ #ifdef JP Term_addstr(-1, TERM_WHITE, " ['r'思い出, ESC]"); #else Term_addstr(-1, TERM_WHITE, " [(r)ecall, ESC]"); #endif } /* Command */ query = inkey(); /* Unrecall */ if (recall) { /* Restore */ screen_load(); } /* Normal commands */ if (query != 'r') break; /* Toggle recall */ recall = !recall; } /* Stop scanning */ if (query == ESCAPE) break; /* Move to "prev" monster */ if (query == '-') { if (++i == n) { i = 0; if (!expand_list) break; } } /* Move to "next" monster */ else { if (i-- == 0) { i = n - 1; if (!expand_list) break; } } } /* Free the "who" array */ C_KILL(who, max_r_idx, u16b); /* Re-display the identity */ prt(buf, 0, 0); }
/* * research_mon * -KMW- */ bool research_mon(void) { int i, n, r_idx; char sym, query; char buf[128]; s16b oldkills; byte oldwake; bool oldcheat; bool notpicked; bool recall = FALSE; u16b why = 0; monster_race *r2_ptr; u16b *who; #ifdef JP /* XTRA HACK WHATSEARCH */ bool all = FALSE; bool uniq = FALSE; bool norm = FALSE; char temp[80] = ""; /* XTRA HACK REMEMBER_IDX */ static int old_sym = '\0'; static int old_i = 0; #endif oldcheat = cheat_know; /* Save the screen */ screen_save(); /* Get a character, or abort */ #ifdef JP if (!get_com("モンスターの文字を入力して下さい(記号 or ^A全,^Uユ,^N非ユ,^M名前):", &sym)) #else if (!get_com("Enter character of monster: ", &sym)) #endif { /* Restore */ screen_load(); return (FALSE); } /* Allocate the "who" array */ C_MAKE(who, max_r_idx, u16b); /* Find that character info, and describe it */ for (i = 0; ident_info[i]; ++i) { if (sym == ident_info[i][0]) break; } #ifdef JP /* XTRA HACK WHATSEARCH */ if (sym == KTRL('A')) { all = TRUE; strcpy(buf, "全モンスターのリスト"); } else if (sym == KTRL('U')) { all = uniq = TRUE; strcpy(buf, "ユニーク・モンスターのリスト"); } else if (sym == KTRL('N')) { all = norm = TRUE; strcpy(buf, "ユニーク外モンスターのリスト"); } else if (sym == KTRL('M')) { all = TRUE; if (!get_string("名前(英語の場合小文字で可)", temp, 70)) { all = FALSE; temp[0] = 0; } sprintf(buf, "名前:%sにマッチ",temp); } else if (ident_info[i]) { sprintf(buf, "%c - %s.", sym, ident_info[i] + 2); } #else if (ident_info[i]) { sprintf(buf, "%c - %s.", sym, ident_info[i] + 2); } #endif else { #ifdef JP sprintf(buf, "%c - %s", sym, "無効な文字"); #else sprintf(buf, "%c - %s.", sym, "Unknown Symbol"); #endif } /* Display the result */ prt(buf, 16, 10); /* Collect matching monsters */ for (n = 0, i = 1; i < max_r_idx; i++) { monster_race *r_ptr = &r_info[i]; cheat_know = TRUE; #ifdef JP /* XTRA HACK WHATSEARCH */ /* Require non-unique monsters if needed */ if (norm && (r_ptr->flags1 & (RF1_UNIQUE))) continue; /* Require unique monsters if needed */ if (uniq && !(r_ptr->flags1 & (RF1_UNIQUE))) continue; /* 名前検索 */ if (temp[0]){ char temp2[80]; int xx; for (xx=0; temp[xx] && xx<80; xx++){ if (iskanji(temp[xx])) { xx++; continue; } if (isupper(temp[xx])) temp[xx]=tolower(temp[xx]); } strcpy(temp2, r_name+r_ptr->E_name); for (xx=0; temp2[xx] && xx<80; xx++) if (isupper(temp2[xx])) temp2[xx]=tolower(temp2[xx]); if (my_strstr(temp2, temp) || my_strstr(r_name + r_ptr->name, temp) ) who[n++]=i; } else if (all || (r_ptr->d_char == sym)) who[n++] = i; #else /* Collect "appropriate" monsters */ if (r_ptr->d_char == sym) who[n++] = i; #endif } /* Nothing to recall */ if (!n) { cheat_know = oldcheat; /* Free the "who" array */ C_KILL(who, max_r_idx, u16b); /* Restore */ screen_load(); return (FALSE); } /* Sort by level */ why = 2; query = 'y'; /* Sort if needed */ if (why) { /* Select the sort method */ ang_sort_comp = ang_sort_comp_hook; ang_sort_swap = ang_sort_swap_hook; /* Sort the array */ ang_sort(who, &why, n); } /* Start at the end */ #ifdef JP /* XTRA HACK REMEMBER_IDX */ if (old_sym == sym && old_i < n) i = old_i; else i = n - 1; #else i = n - 1; #endif notpicked = TRUE; /* Scan the monster memory */ while (notpicked) { /* Extract a race */ r_idx = who[i]; /* Save this monster ID */ p_ptr->monster_race_idx = r_idx; /* Hack -- Handle stuff */ handle_stuff(); /* Hack -- Begin the prompt */ roff_top(r_idx); /* Hack -- Complete the prompt */ #ifdef JP Term_addstr(-1, TERM_WHITE, " ['r'思い出, ' 'で続行, ESC]"); #else Term_addstr(-1, TERM_WHITE, " [(r)ecall, ESC, space to continue]"); #endif /* Interact */ while (1) { /* Recall */ if (recall) { /* Recall on screen */ r2_ptr = &r_info[r_idx]; oldkills = r2_ptr->r_tkills; oldwake = r2_ptr->r_wake; screen_roff(who[i], 1); r2_ptr->r_tkills = oldkills; r2_ptr->r_wake = oldwake; cheat_know = oldcheat; notpicked = FALSE; #ifdef JP /* XTRA HACK REMEMBER_IDX */ old_sym = sym; old_i = i; #endif } /* Command */ query = inkey(); /* Normal commands */ if (query != 'r') break; /* Toggle recall */ recall = !recall; } /* Stop scanning */ if (query == ESCAPE) break; /* Move to "prev" monster */ if (query == '-') { if (++i == n) { i = 0; if (!expand_list) break; } } /* Move to "next" monster */ else { if (i-- == 0) { i = n - 1; if (!expand_list) break; } } } /* Re-display the identity */ /* prt(buf, 5, 5);*/ cheat_know = oldcheat; /* Free the "who" array */ C_KILL(who, max_r_idx, u16b); /* Restore */ screen_load(); return (!notpicked); }
void CDlgPluginSetup::OnOK() { // TODO: この位置にその他の検証用のコードを追加してください CSuperTagEditorApp *pApp = (CSuperTagEditorApp *)AfxGetApp(); CString strINI; wchar_t drive[_MAX_DRIVE]; wchar_t dir[_MAX_DIR]; wchar_t buff[_MAX_PATH] = {'\0'}; { wchar_t* szName = pApp->MakeFileName(L"ini"); _tsplitpath(szName, drive, dir, NULL, NULL); _tmakepath(buff, drive, dir, L"Plugin", L"ini"); strINI = buff; delete szName; //DeleteFile(strINI); } Profile_Initialize(strINI, FALSE); CString strSection; for (int nIndex=0;nIndex<m_listPlugin.GetItemCount();nIndex++) { PSTEPlugin pPlugin = (PSTEPlugin)m_listPlugin.GetItemData(nIndex); pPlugin->bUse = ListView_GetCheckState(m_listPlugin.GetSafeHwnd(), nIndex) ? true : false; strSection.Format(L"Load%03d", nIndex); // 相対パスに変換 wchar_t pDrive[_MAX_DRIVE]; wchar_t pDir[_MAX_DIR]; wchar_t pFname[_MAX_FNAME]; wchar_t pExt[_MAX_EXT]; wchar_t pBuff[_MAX_PATH] = {'\0'}; _tsplitpath(pPlugin->sFileName, pDrive, pDir, pFname, pExt); if (wcscmp(pDrive, drive) == 0) { //wchar_t pWDir[_MAX_DIR]; //wchar_t pWFname[_MAX_FNAME]; //wchar_t pRDir[_MAX_DIR] = {'\0'}; //wchar_t pRFname[_MAX_FNAME]; CString strRelDir = L""; ULONG nPathSeparatorIndex; BOOL bAnyParent; ULONG i; nPathSeparatorIndex = 0; i = 0; #ifndef iskanji #define iskanji(c) ((c) >= 0x81 && (c) <= 0x9f || (c) >= 0xe0 && (c) <= 0xfc) #endif while ((dir[i] == pDir[i] ) && (dir[i] != 0)) { if (!iskanji(dir[i])) { if (dir[i] == '\\' ) { nPathSeparatorIndex = i; } } else { i++; } i++; } if (dir[nPathSeparatorIndex] != '\\') { strRelDir = pDir; } else { i = nPathSeparatorIndex + 1; bAnyParent = FALSE; while (dir[i] != 0) { if (dir[i] == '\\') { bAnyParent = TRUE; strRelDir += L"..\\"; } i++; } if (!bAnyParent) { strRelDir += L".\\"; } } strRelDir += pDir+nPathSeparatorIndex+1; _tmakepath(pBuff, NULL, strRelDir, pFname, pExt); } else { // 変換なし _tmakepath(pBuff, pDrive, pDir, pFname, pExt); } MyWriteProfileString(strSection, L"Path", pBuff/*pPlugin->sFileName*/); //WritePrivateProfileString(strSection, L"Path", pPlugin->sFileName, strINI); MyWriteProfileString(strSection, L"Use", pPlugin->bUse ? L"1" : L"0"); //WritePrivateProfileString(strSection, L"Use", pPlugin->bUse ? L"1" : L"0", strINI); } Profile_Flush(strINI); Profile_Free(); CDialog::OnOK(); }
/* translate_string - translate a string with escapes into regular string */ static STRING_T * translate_string (char *s, int tc) { static STRING_T *r = 0; /* The following are arrays of characters to foil cstrings, as they are not to be translated. */ static char escs[] = { 'a', 'b', 'e', 'f', 't', 'v', '\\', '\'', '\"', '.' }; static char xlat[] = { '\a', '\b', '\033', '\f', '\t', '\v', '\\', '\'', '\"', '.' }; static char xdigs[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; char *p; int x; #ifdef SHIFT_JIS char *org = s; /* The original place in the string. */ int iskj; /* The iskanji() return value. */ #endif /* SHIFT_JIS */ if (r == 0) r = DScreate (); DSresize (r, 0, 0); while (*s && *s != tc) { #ifndef SHIFT_JIS if (*s == '\\') #else /* SHIFT_JIS */ iskj = (org < s) && iskanji (s[-1]); if ((*s == '\\') && !(iskj)) #endif /* SHIFT_JIS */ { /* found an escape */ s++; if ((p = strchr (escs, *s)) != 0) DSappendchar (r, xlat[p - escs], 1); else if (*s == 'x') { /* handle hex digits */ s++; x = 0; while (isxdigit ((unsigned char) *s)) { p = strchr (xdigs, tolower ((unsigned char) *s)); x <<= 4; x |= (p - xdigs); s++; } s--; DSappendchar (r, (x & 255), 1); } else if (*s == 'd') { /* handle decimal digits */ s++; x = 0; while (isdigit ((unsigned char) *s)) x = (x * 10) + (*s++ - '0'); s--; DSappendchar (r, (x & 255), 1); } else if (*s >= '0' && *s <= '7') { /* handle octal digits */ x = 0; while (isdigit ((unsigned char) *s)) { x <<= 3; x |= (*s - '0'); s++; } s--; DSappendchar (r, (x & 255), 1); } else if (*s == '^') { /* control character */ s++; x = toupper ((unsigned char) *s) ^ 64; DSappendchar (r, x, 1); } } else DSappendchar (r, *s, 1); s++; } return r; }
/* * Get object inscription with auto inscription of object flags. */ static void get_inscription(char *buff, const object_type *o_ptr) { cptr insc = quark_str(o_ptr->inscription); char *ptr = buff; /* Not fully identified */ if (!(o_ptr->ident & IDENT_MENTAL)) { /* Copy until end of line or '#' */ while (*insc) { if (*insc == '#') break; #ifdef JP if (iskanji(*insc)) *buff++ = *insc++; #endif *buff++ = *insc++; } *buff = '\0'; return; } *buff = '\0'; for (; *insc; insc++) { /* Ignore fake artifact inscription */ if (*insc == '#') break; /* {%} will be automatically converted */ else if ('%' == *insc) { bool kanji = FALSE; bool all; cptr start = ptr; /* check for too long inscription */ if (ptr >= buff + MAX_NLEN) continue; #ifdef JP if ('%' == insc[1]) { insc++; kanji = FALSE; } else { kanji = TRUE; } #endif if ('a' == insc[1] && 'l' == insc[2] && 'l' == insc[3]) { all = TRUE; insc += 3; } else { all = FALSE; } ptr = get_ability_abbreviation(ptr, o_ptr, kanji, all, TRUE); if (ptr == start) ADD_INSC(" "); } else { *ptr++ = *insc; } } *ptr = '\0'; }
/* * Creates a description of the item "o_ptr", and stores it in "out_val". * * One can choose the "verbosity" of the description, including whether * or not the "number" of items should be described, and how much detail * should be used when describing the item. * * The given "buf" must be MAX_NLEN chars long to hold the longest possible * description, which can get pretty long, including incriptions, such as: * "no more Maces of Disruption (Defender) (+10,+10) [+5] (+3 to stealth)". * Note that the inscription will be clipped to keep the total description * under MAX_NLEN-1 chars (plus a terminator). * * Note the use of "object_desc_num()" and "object_desc_int()" as hyper-efficient, * portable, versions of some common "sprintf()" commands. * * Note that all ego-items (when known) append an "Ego-Item Name", unless * the item is also an artifact, which should NEVER happen. * * Note that all artifacts (when known) append an "Artifact Name", so we * have special processing for "Specials" (artifact Lites, Rings, Amulets). * The "Specials" never use "modifiers" if they are "known", since they * have special "descriptions", such as "The Necklace of the Dwarves". * * Special Lite's use the "k_info" base-name (Phial, Star, or Arkenstone), * plus the artifact name, just like any other artifact, if known. * * Special Ring's and Amulet's, if not "aware", use the same code as normal * rings and amulets, and if "aware", use the "k_info" base-name (Ring or * Amulet or Necklace). They will NEVER "append" the "k_info" name. But, * they will append the artifact name, just like any artifact, if known. * * Hack -- Display "The One Ring" as "a Plain Gold Ring" until aware. * * Mode: * OD_NAME_ONLY : The Cloak of Death * OD_NAME_AND_ENCHANT : The Cloak of Death [1,+3] * OD_OMIT_INSCRIPTION : The Cloak of Death [1,+3] (+2 to Stealth) * 0 : The Cloak of Death [1,+3] (+2 to Stealth) {nifty} * * OD_OMIT_PREFIX : Forbidden numeric prefix * OD_NO_PLURAL : Forbidden use of plural * OD_STORE : Assume to be aware and known * OD_NO_FLAVOR : Allow to hidden flavor * OD_FORCE_FLAVOR : Get un-shuffled flavor name */ void object_desc(char *buf, const object_type *o_ptr, u32b mode) { /* Extract object kind name */ cptr kindname = get_object_name(o_ptr); /* Extract default "base" string */ cptr basenm = kindname; /* Assume no "modifier" string */ cptr modstr = ""; int power; bool aware = FALSE; bool known = FALSE; bool flavor = TRUE; bool show_weapon = FALSE; bool show_armour = FALSE; cptr s, s0; char *t; char p1 = '(', p2 = ')'; char b1 = '[', b2 = ']'; char c1 = '{', c2 = '}'; char tmp_val[MAX_NLEN+160]; char tmp_val2[MAX_NLEN+10]; char fake_insc_buf[30]; u32b f1, f2, f3; bool fullname = FALSE; object_type *bow_ptr; object_kind *k_ptr = &k_info[o_ptr->k_idx]; object_kind *flavor_k_ptr = &k_info[k_ptr->flavor]; /* Extract some flags */ object_flags(o_ptr, &f1, &f2, &f3); /* See if the object is "aware" */ if (object_aware_p(o_ptr)) aware = TRUE; /* See if the object is "known" */ if (object_known_p(o_ptr)) known = TRUE; /* Allow flavors to be hidden when aware */ if (aware && ((mode & OD_NO_FLAVOR) || plain_descriptions)) flavor = FALSE; /* Object is in the inventory of a store or spoiler */ if ((mode & OD_STORE) || (o_ptr->ident & IDENT_STORE)) { /* Don't show flavors */ flavor = FALSE; /* Pretend known and aware */ aware = TRUE; known = TRUE; } /* Force to be flavor name only */ if (mode & OD_FORCE_FLAVOR) { aware = FALSE; flavor = TRUE; known = FALSE; /* Cancel shuffling */ flavor_k_ptr = k_ptr; } /* Analyze the object */ switch (o_ptr->tval) { /* Some objects are easy to describe */ case TV_SKELETON: case TV_BOTTLE: case TV_JUNK: case TV_SPIKE: case TV_FLASK: case TV_CHEST: case TV_FOOD: { break; } /* Figurines/Statues */ case TV_FIGURINE: case TV_STATUE: { monster_race *r_ptr = &r_info[o_ptr->pval]; #ifdef JP modstr = r_name + r_ptr->name; #else cptr t = r_name + r_ptr->name; if (!(r_ptr->flags1 & RF1_UNIQUE)) { sprintf(tmp_val2, "%s%s", (is_a_vowel(*t) ? "an " : "a "), t); modstr = tmp_val2; } else { modstr = t; } #endif break; } /* Corpses */ case TV_CORPSE: { monster_race *r_ptr = &r_info[o_ptr->pval]; modstr = r_name + r_ptr->name; #ifdef JP basenm = "#%"; #else if (r_ptr->flags1 & RF1_UNIQUE) basenm = "& % of #"; else basenm = "& # %"; #endif break; } /* Missiles/ Bows/ Weapons */ case TV_SHOT: case TV_BOLT: case TV_ARROW: case TV_BOW: case TV_HAFTED: case TV_POLEARM: case TV_SWORD: case TV_DIGGING: { show_weapon = TRUE; break; } /* Armour */ case TV_BOOTS: case TV_GLOVES: case TV_CLOAK: case TV_CROWN: case TV_HELM: case TV_SHIELD: case TV_SOFT_ARMOR: case TV_HARD_ARMOR: case TV_DRAG_ARMOR: { show_armour = TRUE; break; } /* Lites (including a few "Specials") */ case TV_LITE: { break; } /* Amulets (including a few "Specials") */ case TV_AMULET: { /* Known artifacts */ if (aware) { if (artifact_p(o_ptr)) break; if (k_ptr->gen_flags & TRG_INSTA_ART) break; } /* Color the object */ modstr = k_name + flavor_k_ptr->flavor_name; #ifdef JP if (!flavor) basenm = "%のアミュレット"; else if (aware) basenm = "%の#アミュレット"; else basenm = "#アミュレット"; #else if (!flavor) basenm = "& Amulet~ of %"; else if (aware) basenm = "& # Amulet~ of %"; else basenm = "& # Amulet~"; #endif break; } /* Rings (including a few "Specials") */ case TV_RING: { /* Known artifacts */ if (aware) { if (artifact_p(o_ptr)) break; if (k_ptr->gen_flags & TRG_INSTA_ART) break; } /* Color the object */ modstr = k_name + flavor_k_ptr->flavor_name; #ifdef JP if (!flavor) basenm = "%の指輪"; else if (aware) basenm = "%の#指輪"; else basenm = "#指輪"; #else if (!flavor) basenm = "& Ring~ of %"; else if (aware) basenm = "& # Ring~ of %"; else basenm = "& # Ring~"; #endif if (!k_ptr->to_h && !k_ptr->to_d && (o_ptr->to_h || o_ptr->to_d)) show_weapon = TRUE; break; } case TV_STAFF: { /* Color the object */ modstr = k_name + flavor_k_ptr->flavor_name; #ifdef JP if (!flavor) basenm = "%のスタッフ"; else if (aware) basenm = "%の#スタッフ"; else basenm = "#スタッフ"; #else if (!flavor) basenm = "& Staff~ of %"; else if (aware) basenm = "& # Staff~ of %"; else basenm = "& # Staff~"; #endif break; } case TV_WAND: { /* Color the object */ modstr = k_name + flavor_k_ptr->flavor_name; #ifdef JP if (!flavor) basenm = "%のワンド"; else if (aware) basenm = "%の#ワンド"; else basenm = "#ワンド"; #else if (!flavor) basenm = "& Wand~ of %"; else if (aware) basenm = "& # Wand~ of %"; else basenm = "& # Wand~"; #endif break; } case TV_ROD: { /* Color the object */ modstr = k_name + flavor_k_ptr->flavor_name; #ifdef JP if (!flavor) basenm = "%のロッド"; else if (aware) basenm = "%の#ロッド"; else basenm = "#ロッド"; #else if (!flavor) basenm = "& Rod~ of %"; else if (aware) basenm = "& # Rod~ of %"; else basenm = "& # Rod~"; #endif break; } case TV_SCROLL: { /* Color the object */ modstr = k_name + flavor_k_ptr->flavor_name; #ifdef JP if (!flavor) basenm = "%の巻物"; else if (aware) basenm = "\"#\"と書かれた%の巻物"; else basenm = "\"#\"と書かれた巻物"; #else if (!flavor) basenm = "& Scroll~ of %"; else if (aware) basenm = "& Scroll~ titled \"#\" of %"; else basenm = "& Scroll~ titled \"#\""; #endif break; } case TV_POTION: { /* Color the object */ modstr = k_name + flavor_k_ptr->flavor_name; #ifdef JP if (!flavor) basenm = "%の薬"; else if (aware) basenm = "%の#薬"; else basenm = "#薬"; #else if (!flavor) basenm = "& Potion~ of %"; else if (aware) basenm = "& # Potion~ of %"; else basenm = "& # Potion~"; #endif break; } /* Magic Books */ case TV_LIFE_BOOK: { #ifdef JP basenm = "生命の魔法書%"; #else if (mp_ptr->spell_type == ST_PRAYER) basenm = "& Book~ of Life Magic %"; else basenm = "& Life Spellbook~ %"; #endif break; } case TV_SORCERY_BOOK: { #ifdef JP basenm = "仙術の魔法書%"; #else if (mp_ptr->spell_type == ST_PRAYER) basenm = "& Book~ of Sorcery %"; else basenm = "& Sorcery Spellbook~ %"; #endif break; } /* Hack -- Gold/Gems */ case TV_GOLD: { strcpy(buf, basenm); return; } /* Used in the "inventory" routine */ default: { #ifdef JP strcpy(buf, "(なし)"); #else strcpy(buf, "(nothing)"); #endif return; } } /* Use full name from a_info */ if (known && o_ptr->name1) { artifact_type *a_ptr = &a_info[o_ptr->name1]; if (prefix(a_name + a_ptr->name, "$")) { basenm = a_name + a_info[o_ptr->name1].name + 1; fullname = TRUE; } } /* Start dumping the result */ t = tmp_val; #ifdef JP if (basenm[0] == '&') s = basenm + 2; else s = basenm; /* No prefix */ if (mode & OD_OMIT_PREFIX) { /* Nothing */ } else if (o_ptr->number > 1) { t = object_desc_kosuu(t, o_ptr); t = object_desc_str(t, "の "); } /* 英語の場合アーティファクトは The が付くので分かるが * 日本語では分からないのでマークをつける */ if (known) { if (artifact_p(o_ptr)) t = object_desc_str(t, "★"); else if (o_ptr->art_name) t = object_desc_str(t, "☆"); } #else /* The object "expects" a "number" */ if (basenm[0] == '&') { /* Skip the ampersand (and space) */ s = basenm + 2; /* No prefix */ if (mode & OD_OMIT_PREFIX) { /* Nothing */ } /* Hack -- None left */ else if (o_ptr->number <= 0) { t = object_desc_str(t, "no more "); } /* Extract the number */ else if (o_ptr->number > 1) { t = object_desc_num(t, o_ptr->number); t = object_desc_chr(t, ' '); } /* Hack -- The only one of its kind */ else if ((known && (artifact_p(o_ptr) || o_ptr->art_name)) || ((o_ptr->tval == TV_CORPSE) && (r_info[o_ptr->pval].flags1 & RF1_UNIQUE))) { t = object_desc_str(t, "The "); } /* A single one */ else { bool vowel; switch (*s) { case '#': vowel = is_a_vowel(modstr[0]); break; case '%': vowel = is_a_vowel(*kindname); break; default: vowel = is_a_vowel(*s); break; } if (vowel) { /* A single one, with a vowel */ t = object_desc_str(t, "an "); } else { /* A single one, without a vowel */ t = object_desc_str(t, "a "); } } } /* Hack -- objects that "never" take an article */ else { /* No ampersand */ s = basenm; /* No pref */ if (mode & OD_OMIT_PREFIX) { /* Nothing */ } /* Hack -- all gone */ else if (o_ptr->number <= 0) { t = object_desc_str(t, "no more "); } /* Prefix a number if required */ else if (o_ptr->number > 1) { t = object_desc_num(t, o_ptr->number); t = object_desc_chr(t, ' '); } /* Hack -- The only one of its kind */ else if (known && (artifact_p(o_ptr) || o_ptr->art_name)) { t = object_desc_str(t, "The "); } /* Hack -- single items get no prefix */ else { /* Nothing */ } } #endif /* Paranoia -- skip illegal tildes */ /* while (*s == '~') s++; */ #ifdef JP /* 伝説のアイテム、名のあるアイテムの名前を付加する */ if (known) { /* ランダム・アーティファクト */ if (o_ptr->art_name) { cptr temp = quark_str(o_ptr->art_name); /* '『' から始まらない伝説のアイテムの名前は最初に付加する */ /* 英語版のセーブファイルから来た 'of XXX' は,「XXXの」と表示する */ if (strncmp(temp, "of ", 3) == 0) { t = object_desc_str(t, &temp[3]); t = object_desc_str(t, "の"); } else if ((strncmp(temp, "『", 2) != 0) && (temp[0] != '\'')) t = object_desc_str(t, temp); } /* 伝説のアイテム */ else if (o_ptr->name1 && !fullname) { artifact_type *a_ptr = &a_info[o_ptr->name1]; /* '『' から始まらない伝説のアイテムの名前は最初に付加する */ if (strncmp(a_name + a_ptr->name, "『", 2) != 0) { t = object_desc_str(t, a_name + a_ptr->name); } } /* 名のあるアイテム */ else if (o_ptr->name2) { ego_item_type *e_ptr = &e_info[o_ptr->name2]; t = object_desc_str(t, e_name + e_ptr->name); } } #endif /* Copy the string */ for (s0 = NULL; *s || s0; ) { /* The end of the flavour/kind string. */ if (!*s) { s = s0 + 1; s0 = NULL; } /* Begin to append the modifier (flavor) */ else if ((*s == '#') && !s0) { s0 = s; s = modstr; /* Paranoia -- Never append multiple modstrs */ modstr = ""; } /* Begin to append the kind name */ else if ((*s == '%') && !s0) { s0 = s; s = kindname; /* Paranoia -- Never append multiple kindnames */ kindname = ""; } #ifndef JP /* Pluralizer */ else if (*s == '~') { /* Add a plural if needed */ if (!(mode & OD_NO_PLURAL) && (o_ptr->number != 1)) { char k = t[-1]; /* XXX XXX XXX Mega-Hack */ /* Hack -- "Cutlass-es" and "Torch-es" */ if ((k == 's') || (k == 'h')) *t++ = 'e'; /* Add an 's' */ *t++ = 's'; } s++; } #endif /* Normal */ else { /* Copy */ *t++ = *s++; } } /* Terminate */ *t = '\0'; #ifdef JP /* '『'から始まる伝説のアイテムの名前は最後に付加する */ if (known) { /* ランダムアーティファクトの名前はセーブファイルに記録 されるので、英語版の名前もそれらしく変換する */ if (o_ptr->art_name) { char temp[256]; int itemp; strcpy(temp, quark_str(o_ptr->art_name)); /* MEGA HACK by ita */ if (strncmp(temp, "『", 2) == 0) t = object_desc_str(t, temp); else if (temp[0] == '\'') { itemp = strlen(temp); temp[itemp - 1] = 0; t = object_desc_str(t, "『"); t = object_desc_str(t, &temp[1]); t = object_desc_str(t, "』"); } } else if (o_ptr->name1) { artifact_type *a_ptr = &a_info[o_ptr->name1]; if (strncmp(a_name + a_ptr->name, "『", 2) == 0) { t = object_desc_str(t, a_name + a_ptr->name); } } else if (o_ptr->ego_name) { t = object_desc_str(t, quark_str(o_ptr->ego_name)); } else if (o_ptr->inscription) { cptr str = quark_str(o_ptr->inscription); while(*str) { if (iskanji(*str)) { str += 2; continue; } if (*str == '#') break; str++; } if (*str) { /* Find the '#' */ cptr str = my_strchr(quark_str(o_ptr->inscription), '#'); /* Add the false name */ t = object_desc_str(t,"『"); t = object_desc_str(t, &str[1]); t = object_desc_str(t,"』"); } } } #else /* Hack -- Append "Artifact" or "Special" names */ if (known && !fullname) { /* Is it a new random artifact ? */ if (o_ptr->art_name) { t = object_desc_chr(t, ' '); t = object_desc_str(t, quark_str(o_ptr->art_name)); } /* Grab any artifact name */ else if (o_ptr->name1) { artifact_type *a_ptr = &a_info[o_ptr->name1]; t = object_desc_chr(t, ' '); t = object_desc_str(t, a_name + a_ptr->name); } /* Grab any ego-item name */ else { if (o_ptr->name2) { ego_item_type *e_ptr = &e_info[o_ptr->name2]; t = object_desc_chr(t, ' '); t = object_desc_str(t, e_name + e_ptr->name); } if (o_ptr->ego_name) { t = object_desc_chr(t, ' '); t = object_desc_str(t, quark_str(o_ptr->ego_name)); } else if (o_ptr->inscription && my_strchr(quark_str(o_ptr->inscription), '#')) { /* Find the '#' */ cptr str = my_strchr(quark_str(o_ptr->inscription), '#'); /* Add the false name */ t = object_desc_chr(t, ' '); t = object_desc_str(t, &str[1]); } } } #endif /* No more details wanted */ if (mode & OD_NAME_ONLY) goto object_desc_done; /* Hack -- Chests must be described in detail */ if (o_ptr->tval == TV_CHEST) { /* Not searched yet */ if (!known) { /* Nothing */ } /* May be "empty" */ else if (!o_ptr->pval) { #ifdef JP t = object_desc_str(t, "(空)"); #else t = object_desc_str(t, " (empty)"); #endif } /* May be "disarmed" */ else if (o_ptr->pval < 0) { if (chest_traps[0 - o_ptr->pval]) { #ifdef JP t = object_desc_str(t, "(解除済)"); #else t = object_desc_str(t, " (disarmed)"); #endif } else { #ifdef JP t = object_desc_str(t, "(非施錠)"); #else t = object_desc_str(t, " (unlocked)"); #endif } } /* Describe the traps, if any */ else { /* Describe the traps */ switch (chest_traps[o_ptr->pval]) { case 0: { #ifdef JP t = object_desc_str(t, "(施錠)"); #else t = object_desc_str(t, " (Locked)"); #endif break; } case CHEST_LOSE_STR: { #ifdef JP t = object_desc_str(t, "(毒針)"); #else t = object_desc_str(t, " (Poison Needle)"); #endif break; } case CHEST_LOSE_CON: { #ifdef JP t = object_desc_str(t, "(毒針)"); #else t = object_desc_str(t, " (Poison Needle)"); #endif break; } case CHEST_POISON: { #ifdef JP t = object_desc_str(t, "(ガス・トラップ)"); #else t = object_desc_str(t, " (Gas Trap)"); #endif break; } case CHEST_PARALYZE: { #ifdef JP t = object_desc_str(t, "(ガス・トラップ)"); #else t = object_desc_str(t, " (Gas Trap)"); #endif break; } case CHEST_EXPLODE: { #ifdef JP t = object_desc_str(t, "(爆発装置)"); #else t = object_desc_str(t, " (Explosion Device)"); #endif break; } case CHEST_SUMMON: { #ifdef JP t = object_desc_str(t, "(召喚のルーン)"); #else t = object_desc_str(t, " (Summoning Runes)"); #endif break; } default: { #ifdef JP t = object_desc_str(t, "(マルチ・トラップ)"); #else t = object_desc_str(t, " (Multiple Traps)"); #endif break; } } } } /* Display the item like a weapon */ if (f3 & TR3_SHOW_MODS) show_weapon = TRUE; /* Display the item like a weapon */ if (o_ptr->to_h && o_ptr->to_d) show_weapon = TRUE; /* Display the item like armour */ if (o_ptr->ac) show_armour = TRUE; /* Dump base weapon info */ switch (o_ptr->tval) { /* Missiles and Weapons */ case TV_SHOT: case TV_BOLT: case TV_ARROW: case TV_HAFTED: case TV_POLEARM: case TV_SWORD: case TV_DIGGING: /* Append a "damage" string */ t = object_desc_chr(t, ' '); t = object_desc_chr(t, p1); t = object_desc_num(t, o_ptr->dd); t = object_desc_chr(t, 'd'); t = object_desc_num(t, o_ptr->ds); t = object_desc_chr(t, p2); /* All done */ break; /* Bows get a special "damage string" */ case TV_BOW: /* Mega-Hack -- Extract the "base power" */ power = bow_tmul(o_ptr->sval); /* Apply the "Extra Might" flag */ if (f3 & TR3_XTRA_MIGHT) power++; /* Append a special "damage" string */ t = object_desc_chr(t, ' '); t = object_desc_chr(t, p1); t = object_desc_chr(t, 'x'); t = object_desc_num(t, power); t = object_desc_chr(t, p2); /* All done */ break; } /* Add the weapon bonuses */ if (known) { /* Show the tohit/todam on request */ if (show_weapon) { t = object_desc_chr(t, ' '); t = object_desc_chr(t, p1); t = object_desc_int(t, o_ptr->to_h); t = object_desc_chr(t, ','); t = object_desc_int(t, o_ptr->to_d); t = object_desc_chr(t, p2); } /* Show the tohit if needed */ else if (o_ptr->to_h) { t = object_desc_chr(t, ' '); t = object_desc_chr(t, p1); t = object_desc_int(t, o_ptr->to_h); t = object_desc_chr(t, p2); } /* Show the todam if needed */ else if (o_ptr->to_d) { t = object_desc_chr(t, ' '); t = object_desc_chr(t, p1); t = object_desc_int(t, o_ptr->to_d); t = object_desc_chr(t, p2); } } bow_ptr = &inventory[INVEN_BOW]; /* If have a firing weapon + ammo matches bow */ if (bow_ptr->k_idx && (o_ptr->tval == p_ptr->tval_ammo)) { int avgdam = o_ptr->dd * (o_ptr->ds + 1) * 10 / 2; int tmul = bow_tmul(bow_ptr->sval); s16b energy_fire = bow_energy(bow_ptr->sval); /* See if the bow is "known" - then set damage bonus */ if (object_known_p(bow_ptr)) avgdam += (bow_ptr->to_d * 10); /* Effect of ammo */ if (known) avgdam += (o_ptr->to_d * 10); /* Get extra "power" from "extra might" */ if (p_ptr->xtra_might) tmul++; tmul = tmul * (100 + (int)(adj_str_td[p_ptr->stat_ind[A_STR]]) - 128); /* Launcher multiplier */ avgdam *= tmul; avgdam /= (100 * 10); if (avgdam < 0) avgdam = 0; /* Display (shot damage/ avg damage) */ t = object_desc_chr(t, ' '); t = object_desc_chr(t, p1); t = object_desc_num(t, avgdam); t = object_desc_chr(t, '/'); if (p_ptr->num_fire == 0) { t = object_desc_chr(t, '0'); } else { /* Calc effects of energy */ avgdam *= (p_ptr->num_fire * 100); avgdam /= energy_fire * 100; t = object_desc_num(t, avgdam); } t = object_desc_chr(t, p2); } /* Add the armor bonuses */ if (known) { /* Show the armor class info */ if (show_armour) { t = object_desc_chr(t, ' '); t = object_desc_chr(t, b1); t = object_desc_num(t, o_ptr->ac); t = object_desc_chr(t, ','); t = object_desc_int(t, o_ptr->to_a); t = object_desc_chr(t, b2); } /* No base armor, but does increase armor */ else if (o_ptr->to_a) { t = object_desc_chr(t, ' '); t = object_desc_chr(t, b1); t = object_desc_int(t, o_ptr->to_a); t = object_desc_chr(t, b2); } } /* Hack -- always show base armor */ else if (show_armour) { t = object_desc_chr(t, ' '); t = object_desc_chr(t, b1); t = object_desc_num(t, o_ptr->ac); t = object_desc_chr(t, b2); } /* No more details wanted */ if (mode & OD_NAME_AND_ENCHANT) goto object_desc_done; if (known) /* Known item only */ { /* * Hack -- Wands and Staffs have charges. Make certain how many charges * a stack of staffs really has is clear. -LM- */ if (((o_ptr->tval == TV_STAFF) || (o_ptr->tval == TV_WAND))) { /* Dump " (N charges)" */ t = object_desc_chr(t, ' '); t = object_desc_chr(t, p1); /* Clear explaination for staffs. */ if ((o_ptr->tval == TV_STAFF) && (o_ptr->number > 1)) { t = object_desc_num(t, o_ptr->number); t = object_desc_str(t, "x "); } t = object_desc_num(t, o_ptr->pval); #ifdef JP t = object_desc_str(t, "回分"); #else t = object_desc_str(t, " charge"); if (o_ptr->pval != 1) t = object_desc_chr(t, 's'); #endif t = object_desc_chr(t, p2); } /* Hack -- Rods have a "charging" indicator. Now that stacks of rods may * be in any state of charge or discharge, this now includes a number. -LM- */ else if (o_ptr->tval == TV_ROD) { /* Hack -- Dump " (# charging)" if relevant */ if (o_ptr->timeout) { /* Stacks of rods display an exact count of charging rods. */ if (o_ptr->number > 1) { /* Paranoia. */ if (k_ptr->pval == 0) k_ptr->pval = 1; /* Find out how many rods are charging, by dividing * current timeout by each rod's maximum timeout. * Ensure that any remainder is rounded up. Display * very discharged stacks as merely fully discharged. */ power = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval; if (power > o_ptr->number) power = o_ptr->number; /* Display prettily. */ t = object_desc_str(t, " ("); t = object_desc_num(t, power); #ifdef JP t = object_desc_str(t, "本 充填中)"); #else t = object_desc_str(t, " charging)"); #endif } /* "one Rod of Perception (1 charging)" would look tacky. */ else { #ifdef JP t = object_desc_str(t, "(充填中)"); #else t = object_desc_str(t, " (charging)"); #endif } } } /* Dump "pval" flags for wearable items */ if (f1 & TR1_PVAL_MASK) { /* Start the display */ t = object_desc_chr(t, ' '); t = object_desc_chr(t, p1); /* Dump the "pval" itself */ t = object_desc_int(t, o_ptr->pval); /* Do not display the "pval" flags */ if (f3 & TR3_HIDE_TYPE) { /* Nothing */ } /* Speed */ else if (f1 & TR1_SPEED) { /* Dump " to speed" */ #ifdef JP t = object_desc_str(t, "加速"); #else t = object_desc_str(t, " to speed"); #endif } /* Attack speed */ else if (f1 & TR1_BLOWS) { /* Add " attack" */ #ifdef JP t = object_desc_str(t, "攻撃"); #else t = object_desc_str(t, " attack"); /* Add "attacks" */ if (ABS(o_ptr->pval) != 1) t = object_desc_chr(t, 's'); #endif } /* Stealth */ else if (f1 & TR1_STEALTH) { /* Dump " to stealth" */ #ifdef JP t = object_desc_str(t, "隠密"); #else t = object_desc_str(t, " to stealth"); #endif } /* Search */ else if (f1 & TR1_SEARCH) { /* Dump " to searching" */ #ifdef JP t = object_desc_str(t, "探索"); #else t = object_desc_str(t, " to searching"); #endif } /* Infravision */ else if (f1 & TR1_INFRA) { /* Dump " to infravision" */ #ifdef JP t = object_desc_str(t, "赤外線視力"); #else t = object_desc_str(t, " to infravision"); #endif } /* Finish the display */ t = object_desc_chr(t, p2); } /* Hack -- Process Lanterns/Torches */ if ((o_ptr->tval == TV_LITE) && ((o_ptr->sval == SV_LITE_TORCH) || (o_ptr->sval == SV_LITE_LANTERN))) { /* Hack -- Turns of light for normal lites */ #ifdef JP t = object_desc_chr(t, '('); #else t = object_desc_str(t, " (with "); #endif t = object_desc_num(t, o_ptr->xtra3); #ifdef JP t = object_desc_str(t, "ターンの寿命)"); #else t = object_desc_str(t, " turns of light)"); #endif } /* Indicate charging objects, but not rods. */ if (o_ptr->timeout && (o_ptr->tval != TV_ROD)) { /* Hack -- Dump " (charging)" if relevant */ #ifdef JP t = object_desc_str(t, "(充填中)"); #else t = object_desc_str(t, " (charging)"); #endif } } /* No more details wanted */ if (mode & OD_OMIT_INSCRIPTION) goto object_desc_done; /* Prepare real inscriptions in a buffer */ tmp_val2[0] = '\0'; /* Auto abbreviation inscribe */ if ((abbrev_extra || abbrev_all) && (o_ptr->ident & IDENT_MENTAL)) { if (!o_ptr->inscription || !my_strchr(quark_str(o_ptr->inscription), '%')) { bool kanji, all; #ifdef JP kanji = TRUE; #else kanji = FALSE; #endif all = abbrev_all; get_ability_abbreviation(tmp_val2, o_ptr, kanji, all, FALSE); } } /* Use the standard inscription if available */ if (o_ptr->inscription) { char buff[1024]; if (tmp_val2[0]) strcat(tmp_val2, ", "); /* Get inscription and convert {%} */ get_inscription(buff, o_ptr); /* strcat with correct treating of kanji */ my_strcat(tmp_val2, buff, sizeof(tmp_val2)); } /* No fake inscription yet */ fake_insc_buf[0] = '\0'; /* Use the game-generated "feeling" otherwise, if available */ if (o_ptr->feeling) { strcpy(fake_insc_buf, game_inscriptions[o_ptr->feeling]); } /* Note "cursed" if the item is known to be cursed */ else if (cursed_p(o_ptr) && (known || (o_ptr->ident & IDENT_SENSE))) { #ifdef JP strcpy(fake_insc_buf, "呪われている"); #else strcpy(fake_insc_buf, "cursed"); #endif } /* Note "unidentified" if the item is unidentified */ else if (((o_ptr->tval == TV_RING) || (o_ptr->tval == TV_AMULET) || (o_ptr->tval == TV_LITE) || (o_ptr->tval == TV_FIGURINE)) && aware && !known && !(o_ptr->ident & IDENT_SENSE)) { #ifdef JP strcpy(fake_insc_buf, "未鑑定"); #else strcpy(fake_insc_buf, "unidentified"); #endif } /* Mega-Hack -- note empty wands/staffs */ else if (!known && (o_ptr->ident & IDENT_EMPTY)) { #ifdef JP strcpy(fake_insc_buf, "空"); #else strcpy(fake_insc_buf, "empty"); #endif } /* Note "tried" if the object has been tested unsuccessfully */ else if (!aware && object_tried_p(o_ptr)) { #ifdef JP strcpy(fake_insc_buf, "未判明"); #else strcpy(fake_insc_buf, "tried"); #endif } /* Note the discount, if any */ if (o_ptr->discount) { /* Hidden by real inscription unless in a store */ if (!tmp_val2[0] || (o_ptr->ident & IDENT_STORE)) { char discount_num_buf[4]; /* Append to other fake inscriptions if any */ if (fake_insc_buf[0]) strcat(fake_insc_buf, ", "); (void)object_desc_num(discount_num_buf, o_ptr->discount); strcat(fake_insc_buf, discount_num_buf); #ifdef JP strcat(fake_insc_buf, "%引き"); #else strcat(fake_insc_buf, "% off"); #endif } } /* Append the inscription, if any */ if (fake_insc_buf[0] || tmp_val2[0]) { /* Append the inscription */ t = object_desc_chr(t, ' '); t = object_desc_chr(t, c1); /* Append fake inscriptions */ if (fake_insc_buf[0]) { t = object_desc_str(t, fake_insc_buf); } /* Append a separater */ if (fake_insc_buf[0] && tmp_val2[0]) { t = object_desc_chr(t, ','); t = object_desc_chr(t, ' '); } /* Append real inscriptions */ if (tmp_val2[0]) { t = object_desc_str(t, tmp_val2); } t = object_desc_chr(t, c2); } object_desc_done: my_strcpy(buf, tmp_val, MAX_NLEN); }