File: add_throw.perl

package info (click to toggle)
crossfire 1.70.0-1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 22,864 kB
  • sloc: ansic: 80,929; sh: 11,201; perl: 2,424; lex: 2,045; makefile: 1,334
file content (31 lines) | stat: -rw-r--r-- 683 bytes parent folder | download | duplicates (7)
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
#!/usr/bin/perl
# Adds the throwing skill to to the old player files.  This script
# is likely no longer needed, since skills have been around for quite a while.
#

$end = 0;
if (!-e $ARGV[0]) {
	die("Can not find file $ARGV[0]\n");
}
if (-e $ARGV[0].".old") {
	die("$ARGV[0].new already exists.\n");
}
rename($ARGV[0], $ARGV[0].".old");
open(PLAYER,"<".$ARGV[0].".old") || die("can not open $ARGV[0].old");
open(PL_NEW,">".$ARGV[0]) || die("can not open $ARGV[0]");

while (<PLAYER>) {
	if (/^end$/) {
		if ($end) {
			print PL_NEW "arch skill_throwing\nend\nend\n";
		}
		else {print PL_NEW $_;}
		$end=1;
	}
	else {
		print PL_NEW $_;
		$end=0;
	}
}
close(PLAYER);
close(PL_NEW);