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

Comparing deliantra/Deliantra-Client/bin/deliantra (file contents):
Revision 1.120 by root, Tue Dec 27 07:23:33 2011 UTC vs.
Revision 1.121 by root, Tue Dec 27 09:17:27 2011 UTC

1#!/opt/bin/perl 1#!/opt/bin/perl
2 2
3our @STARTUP_DONE; 3#############################################################################
4# if running under PAR, see if we have an updated version on disk, then use that
4 5
5# do splash-screen thingy on win32 6# this code does more or less the same as the one in Deliantra.pm
6BEGIN {
7 if (%PAR::LibCache && $^O eq "MSWin32") {
8 while (my ($filename, $zip) = each %PAR::LibCache) {
9 $zip->extractMember ("SPLASH.bmp", "$ENV{PAR_TEMP}/SPLASH.bmp");
10 }
11 7
12 require Win32::GUI::SplashScreen; 8our $PAR; # true if running under PAR
9our $EXE_ID; # identifies this binary "branch" (usually the name of the person who builds + os + some unique id per perl binary build)
10our $EXE_VER; # the (string) version of this binary payload
11our $VARDIR;
12our $UPDDIR;
13our $UPDPAR;
14our %ORIG_INC;
13 15
14 Win32::GUI::SplashScreen::Show ( 16if (!$UPDDIR && %PAR::LibCache && require "par-info.pl") {
15 -file => "$ENV{PAR_TEMP}/SPLASH.bmp", 17 # must set EXE_ID and EXE_VER
16 ); 18 $PAR = 1;
17 19
18 push @STARTUP_DONE, sub { 20 $VARDIR = $ENV{HOME} ? "$ENV{HOME}/.deliantra"
19 Win32::GUI::SplashScreen::Done (1); 21 : $ENV{AppData} ? "$ENV{APPDATA}/deliantra"
20 }; 22 : do { require File::Spec; File::Spec->tmpdir . "/deliantra" };
21 }
22}
23 23
24# TODO: find most recent .par 24 $UPDDIR = "$VARDIR/upd-$EXE_ID";
25 mkdir $UPDDIR;
26 if (opendir my $fh, $UPDDIR) {
27 my @files = sort grep /\.par$/, readdir $fh;
28 $UPDPAR = pop @files; # highest version == newest
25 29
26use common::sense; 30 # try to unlink all older versions
31 unlink "$UPDDIR/$_"
32 for @files;
27 33
28use Carp 'verbose'; 34 # override exe par with downloaded par
35 %ORIG_INC = %INC;
36 # par apparently has no way of overriding, so we try to clear its state
37 @PAR::LibCache = ();
38 %PAR::LibCache = ();
39 PAR->import ("$UPDDIR/$UPDPAR");
29 40
30# do things only needed for single-binary version (par) 41 # now we try to re-exec "script/deliantra"
31BEGIN { 42 if (my $member = eval { $zip->memberNamed ('script/deliantra') }) {
32 if (%PAR::LibCache) { 43 return PAR::_run_member ($member);
33 @INC = grep ref, @INC; # weed out all paths except PAR's loader refs
34
35 my $root = $ENV{PAR_TEMP};
36
37 while (my ($filename, $zip) = each %PAR::LibCache) {
38 for ($zip->memberNames) {
39 next unless /^root\/(.*)/;
40 $zip->extractMember ($_, "$root/$1")
41 unless -e "$root/$1";
42 }
43 }
44
45 if ($^O eq "MSWin32") {
46 # pango is relocatable on win32
47 } else {
48 # OS X
49 $ENV{PANGO_RC_FILE} = "$root/pango.rc";
50 $ENV{DYLD_LIBRARY_PATH} = $root;
51 chdir $root; # for pango modules, maybe other things
52 }
53
54 unshift @INC, $root;
55 }
56}
57
58# prepend private library directory and prepare env
59BEGIN {
60 for (grep !ref, @INC) {
61 my $path = "$_/Deliantra/Client/private";
62 if (-d $path) {
63 unshift @INC, $path;
64 last;
65 } 44 }
66 } 45 }
67} 46}
68 47
69use DC::Main (); 48
49#############################################################################
50# splash-screen
51
52our @STARTUP_DONE;
53
54if ($PAR && $^O eq "MSWin32") {
55 while (my ($filename, $zip) = each %PAR::LibCache) {
56 $zip->extractMember ("SPLASH.bmp", "$ENV{PAR_TEMP}/SPLASH.bmp");
57 }
58
59 require Win32::GUI::SplashScreen;
60
61 Win32::GUI::SplashScreen::Show (
62 -file => "$ENV{PAR_TEMP}/SPLASH.bmp",
63 );
64
65 push @STARTUP_DONE, sub {
66 Win32::GUI::SplashScreen::Done (1);
67 };
68}
69
70#############################################################################
71# work around various deficiencies and bugs in PAR
72
73# do things only needed for single-binary version (par)
74if ($PAR) {
75 @INC = grep ref, @INC; # weed out all paths except PAR's loader refs
76 # alternatively: @INC = (); PAR->import;
77
78 my $root = $ENV{PAR_TEMP};
79
80 while (my ($filename, $zip) = each %PAR::LibCache) {
81 for ($zip->memberNames) {
82 next unless /^root\/(.*)/;
83 $zip->extractMember ($_, "$root/$1")
84 unless -e "$root/$1";
85 }
86 }
87
88 if ($^O eq "MSWin32") {
89 # pango is relocatable on win32
90 } else {
91 # OS X
92 $ENV{PANGO_RC_FILE} = "$root/pango.rc";
93 $ENV{DYLD_LIBRARY_PATH} = $root;
94 chdir $root; # for pango modules, maybe other things
95 }
96
97 unshift @INC, $root;
98}
99
100# prepend private library directory and prepare env
101for (grep !ref, @INC) {
102 my $path = "$_/Deliantra/Client/private";
103 if (-d $path) {
104 unshift @INC, $path;
105 last;
106 }
107}
108
109#############################################################################
110# load and run the main program
111
112require DC::Main;
70 113
71# need to do it again because that pile of garbage called PAR nukes it before main 114# need to do it again because that pile of garbage called PAR nukes it before main
72unshift @INC, $ENV{PAR_TEMP} 115unshift @INC, $ENV{PAR_TEMP}
73 if %PAR::LibCache; 116 if $PAR;
74 117
75DC::Main::run; 118DC::Main::run ();
76 119
77=head1 NAME 120=head1 NAME
78 121
79deliantra - A Deliantra MORPG game client 122deliantra - A Deliantra MORPG game client
80 123

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines