-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathitem-s.cgi
134 lines (116 loc) · 3.19 KB
/
item-s.cgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
use utf8;
# アイテム使用処理 2005/01/06 由來
$NOMENU=1;
$Q{er}='stock';
Lock();
DataRead();
CheckUserPass();
$Q{cnt}=int($Q{cnt2} ? $Q{cnt2} : $Q{cnt1});
$Q{cnt}=0 if $Q{cnt}<=0;
$itemno=$Q{item};
$no=$Q{no};
$target=$Q{tg};
$message=$Q{msg};
$select=$Q{select};
CheckItemNo($itemno);
OutError(l('標的が見つかりません')) if $target && !defined($id2idx{$target});
$itemcode=GetPath($ITEM_DIR,"use",$ITEM[$itemno]->{code});
OutError(l('使えません')) if $itemcode eq '' || !(-e $itemcode);
$ITEM=$ITEM[$itemno];
@item::DT=@DT;
$item::DT=$DT;
@item::ITEM=@ITEM;
$item::ITEM=$ITEM;
RequireFile('inc-item.cgi');
require $itemcode;
$USE=GetUseItem($no);
OutError(l('使えません')) if !$USE || !$USE->{useok};
$item::USE=$USE;
if($USE->{arg}=~/message(\d*)/)
{
my $limit=$1||80;
# require $JCODE_FILE;
# $message=EscapeHTML(jcode::sjis($message,$CHAR_SHIFT_JIS&&'sjis'));
$message=EscapeHTML($message);
OutError(l('入力文字数が多すぎます (<>&"は4~6文字に換算されます)')) if length $message>$limit;
}
my %select_hash;
if($USE->{arg}=~/select/)
{
my @fld=split(/;/,$USE->{argselect});
shift(@fld) if @fld%2==1;
%select_hash=@fld;
while(@fld)
{
last if shift @fld eq $select;
shift @fld;
}
OutError(l('選択肢が不正です')) if !@fld;
}
$USE->{arg}={};
$USE->{arg}->{target}=$target;
$USE->{arg}->{targetidx}=$id2idx{$target};
$USE->{arg}->{count}=$Q{cnt};
$USE->{arg}->{message}=$message;
$USE->{arg}->{select}=$select;
$USE->{arg}->{select_hash}=\%select_hash;
UseItem($USE,$Q{cnt});
RequireFile('inc-html-ownerinfo.cgi');
my $count=$USE->{result}->{count};
$disp.="<BIG>●".l("結果")."</BIG><br><br>";
if(!$count)
{
$disp.=l("実行できませんでした");
}
else
{
$disp.=$USE->{result}->{function_return}."<BR>" if $USE->{result}->{function_return};
$disp.=$USE->{result}->{count}.$USE->{scale}."<BR>";
$disp.=l('費用').":".GetMoneyString($USE->{money}*$USE->{result}->{count})."<BR>" if $USE->{money}*$USE->{result}->{count};
my $timestr = l('時間#A');
$timestr =~ s/#A//g;
$disp.=$timestr.":".GetTime2HMS(GetItemUseTime($USE)*$count)."<BR><BR>";
foreach my $MESSAGE (@{$USE->{result}->{addmsg}})
{$disp.=$MESSAGE."<BR>" if $MESSAGE;}
if($USE->{result}->{additem}[0])
{
my $result=$USE->{result}->{message}->{resultok};
$disp.=$result."<BR>" if $result;
foreach my $MESSAGE (@{$USE->{result}->{trashmsg}})
{$disp.=$MESSAGE."<BR>" if $MESSAGE;}
$disp.=l('入手').":";
foreach my $ADDITEM (@{$USE->{result}->{additem}})
{
my $no=$ADDITEM->[0];
$disp.=$ITEM[$no]->{name};
$disp.=" +".$ADDITEM->[1]." (".l("残%1",$DT->{item}[$no-1]).") ";
}
$disp.="<BR>";
}
else
{
my $result=$USE->{result}->{message}->{resultng};
$disp.=$result."<BR>" if $result;
}
foreach my $MESSAGE (@{$USE->{result}->{usemsg}})
{
$disp.=$MESSAGE."<BR>" if $MESSAGE;
}
if($USE->{result}->{useitem}[0])
{
$disp.=l('消費').":";
foreach my $USEITEM (@{$USE->{result}->{useitem}})
{
my $no=$USEITEM->[0];
$disp.=$ITEM[$no]->{name};
$disp.=" -".$USEITEM->[1]." (".l("残%1",$DT->{item}[$no-1]).") ";
}
$disp.="<BR>";
}
}
RenewLog();
DataWrite();
DataCommitOrAbort();
UnLock();
OutSkin();
1;