1#!/usr/local/bin/perl -w
2
3 # UMark
4 # Copyright (C)2003-2004 Jeffrey Bakker
5
6 # This program is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 2 of the License, or
9 # (at your option) any later version.
10
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 # GNU General Public License for more details.
15
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19
20 # This script is used to gather the information, in which reveals
21 # the complete path to execute UT200x. UMark will use this information
22 # to determine which games are installed, and how to launch it.
23
24
25use strict;
26
27my $line;
28
29my $ut2003;
30my $ut2004;
31my $ut2k3d;
32my $ut2k4d;
33
34my $build3r = "n/a";
35my $build3d = "n/a";
36my $build4r = "n/a";
37my $build4d = "n/a";
38
39$build4d = "n/a";
40$ut2k4d = "n/a";
41
42if(system("which ut2003 1>/dev/null") != 0)
43{
44	$ut2003 = "n/a";
45}
46else
47{
48	($ut2003 = `ls -l \`which ut2003\``) =~ s/.*->\s{0,}//g;
49	chomp $ut2003;
50	$ut2003 =~ s!/ut2003$!!;
51
52	open(LOG3, "<$ENV{'HOME'}/.ut2003/System/UT2003.log");
53	my @log3 = <LOG3>;
54	close(LOG3);
55
56	foreach $line (@log3)
57	{
58		if($line =~ m/Init: Version: /)
59		{
60			$build3r = $line;
61#			print $line;
62		}
63	}
64	if($build3r ne "n/a")
65	{
66		$build3r =~ s/Init: Version: ([0-9][0-9][0-9][0-9]) .*/$1/;
67		chomp $build3r;
68	}
69	else
70	{
71		print "UT2003 Retail is installed, but you need to run it as this current user at least once first to create a log file. You need to re-run this script in order to benchmark this game with UMark.\n";
72		$ut2003 = "n/a";
73	}
74}
75
76if(system("which ut2004 1>/dev/null") != 0)
77{
78	$ut2004 = "n/a";
79	$ut2k4d = "n/a";
80}
81else
82{
83	($ut2004 = `ls -l \`which ut2004\``) =~ s/.*->\s{0,}//g;
84	chomp $ut2004;
85	$ut2004 =~ s!/ut2004$!!;
86	$ut2004 =~ s!/$!!;
87
88	open(LOG4, "<$ENV{'HOME'}/.ut2004/System/UT2004.log");
89	my @log4 = <LOG4>;
90	close(LOG4);
91
92	foreach $line (@log4)
93	{
94		if($line =~ m/Init: Version: /)
95		{
96			$build4r = $line;
97#			print $line;
98		}
99	}
100	if($build4r ne "n/a")
101	{
102		$build4r =~ s/Init: Version: ([0-9][0-9][0-9][0-9]) .*/$1/;
103		chomp $build4r;
104	}
105	else
106	{
107		print "UT2004 Retail is installed, but you need to run it as this current user at least once first to create a log file. You also need to re-run this script in order to benchmark this game with UMark.\n";
108		$ut2004 = "n/a";
109	}
110
111	# ut2004 retail or demo?
112	if($ut2004 =~ m/ut2004demo/)
113	{
114		$ut2k4d = $ut2004;
115		$ut2004 = "n/a";
116
117		$build4r = "n/a";
118
119		open(LOG4, "<$ENV{'HOME'}/.ut2004demo/System/UT2004.log");
120		@log4 = <LOG4>;
121		close(LOG4);
122
123		foreach $line (@log4)
124		{
125			if($line =~ m/Init: Version: /)
126			{
127				$build4d = $line;
128#				print $line;
129			}
130		}
131		if($build4d ne "n/a")
132		{
133			$build4d =~ s/Init: Version: ([0-9][0-9][0-9][0-9]) .*/$1/;
134			chomp $build4d;
135		}
136		else
137		{
138			print "UT2004 Demo is installed, but you need to run it as this current user at least once first to create a log file. You also need to re-run this script in order to benchmark this game with UMark.\n";
139			$ut2k4d = "n/a";
140		}
141
142		chomp $ut2k4d;
143		$ut2k4d =~ s!/ut2004-demo$!!;
144		$ut2k4d =~ s!/$!!;
145	}
146}
147
148if(system("which ut2003_demo 1>/dev/null") != 0)
149{
150	$ut2k3d = "n/a";
151}
152else
153{
154	($ut2k3d = `ls -l \`which ut2003_demo\``) =~ s/.*->\s{0,}//g;
155	chomp $ut2k3d;
156	$ut2k3d =~ s!/ut2003_demo$!!;
157
158	open(LOG3, "<$ENV{'HOME'}/.ut2003/System/UT2003.log");
159	my @log3 = <LOG3>;
160	close(LOG3);
161
162	foreach $line (@log3)
163	{
164		if($line =~ m/Init: Version: /)
165		{
166			$build3d = $line;
167#			print $line;
168		}
169	}
170	if($build3d ne "n/a")
171	{
172		$build3d =~ s/Init: Version: ([0-9][0-9][0-9][0-9]) .*/$1/;
173		chomp $build3d;
174	}
175	else
176	{
177		print "UT2003 Demo is installed, but you need to run it as this current user at least once first to create a log file. You also need to re-run this script in order to benchmark this game with UMark.\n";
178		$ut2k3d = "n/a";
179	}
180}
181
182chomp $ut2003;
183chomp $ut2004;
184chomp $ut2k3d;
185chomp $ut2k4d;
186
187print "UT2003 Retail Version $build3r installed in $ut2003\n";
188print "UT2004 Retail Version $build4r installed in $ut2004\n";
189print "UT2003 Demo Version $build3d installed in $ut2k3d\n";
190print "UT2004 Demo Version $build4d installed in $ut2k4d\n";
191
192open(UMARKRC, ">$ENV{'HOME'}/.umarkrc");
193select(UMARKRC);
194
195print "$build3r|$ut2003\n";
196print "$build4r|$ut2004\n";
197print "$build3d|$ut2k3d\n";
198print "$build4d|$ut2k4d\n";
199
200close(UMARKRC);
201