ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/Deliantra/bin/cf-slotutil
(Generate patch)

Comparing deliantra/Deliantra/bin/cf-slotutil (file contents):
Revision 1.1 by root, Sun Sep 28 05:58:01 2008 UTC vs.
Revision 1.2 by root, Sun Sep 28 07:34:51 2008 UTC

81 } 81 }
82 } 82 }
83} 83}
84 84
85sub insert { 85sub insert {
86 my ($apply) = @_;
87
86 shift @ARGV; 88 shift @ARGV;
87 my $format = <STDIN>; 89 my $format = <STDIN>;
88 my @slots = unpack $format, <STDIN>; 90 my @slots = unpack $format, <STDIN>;
89 91
90 my %res; 92 my %res;
128 print $fh Deliantra::archlist_to_string [ 130 print $fh Deliantra::archlist_to_string [
129 map $arch->{$_}, 131 map $arch->{$_},
130 sort keys %$arch 132 sort keys %$arch
131 ]; 133 ];
132 close $fh; 134 close $fh;
135
136 if ($apply) {
137 rename "$path~", $path;
138 } else {
133 system "diff", "-u", $path, "$path~"; 139 system "diff", "-u", $path, "$path~";
134 unlink "$path~"; 140 unlink "$path~";
141 }
135 } 142 }
136 }; 143 };
137} 144}
138 145
139binmode STDIN, ":utf8"; 146binmode STDIN, ":utf8";
140binmode STDOUT, ":utf8"; 147binmode STDOUT, ":utf8";
141 148
142if ($ARGV[0] eq "extract") { 149if ($ARGV[0] eq "extract") {
143 extract; 150 extract;
144} elsif ($ARGV[0] eq "diff") { 151} elsif ($ARGV[0] eq "diff") {
145 insert; 152 insert 0;
153} elsif ($ARGV[0] eq "apply") {
154 insert 1;
146} else { 155} else {
147 die <<EOF; 156 die <<EOF;
148Usage: 157Usage:
149 158
150 $0 extract 'filter' slot... 159 $0 extract 'filter' slot...
151 160
152 extract slots from server archetypes file (NOT the .arc files!) 161 extract slots from server archetypes file (NOT the .arc files!)
153 Example: $0 extract '%type == 101' level 162 Example: $0 extract '%type == 101' level
154 163
155 $0 diff [really] 164 $0 diff
156 165
157 generates a diff against the .arc files found 166 generates a diff against the .arc files found
158 in \$DELIANTRA_ARCHDIR or ".". 167 in \$DELIANTRA_ARCHDIR or ".".
159 168
160 Example: $0 diff <file 169 Example: $0 diff <file
161 170
171 $0 apply
172
173 like diff, but applies it in-place
174
162EOF 175EOF
163} 176}
164 177
165 178
166 179

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines