Games-Axmud

 view release on metacpan or  search on metacpan

scripts/axmud.pl  view on Meta::CPAN

# Licence and credits
@LICENSE_LIST = (
    'This program is free software; you can redistribute it and/or modify it under',
    'the terms of the GNU General Public License as published by the Free Software',
    'Foundation; either version 3 of the License, or (at your option) any later',
    'version.',
    ' ',
    'This program is distributed in the hope that it will be useful, but WITHOUT ANY',
    'WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A',
    'PARTICULAR PURPOSE. See the GNU General Public License for more details.',
    ' ',
    'You should have received a copy of the GNU General Public License along with',
    'this program. If see <http://www.gnu.org/licenses/>',
);

@CREDIT_LIST = (
    'Axbasic based on Language::Basic by Amir Karger',
    'Binomial heap code copied (unmodified) from Heap::Binomial by John Macdonald',
    'Chat task based on Kildclient plugin by Eduardo M Kalinowski',
    'Pathfinding algorithms based on AI::Pathfinding::AStar by Aaron Dalton',
    'Roman numeral conversion based on Text::Roman by Stanislaw Pusep',
    'Simple list code based on Gtk3::SimpleList by Thierry Vignaud',
    'Telnet code based on Net::Telnet by Jay Rogers',
    'Window manager control code based on X11::WMCtrl by Gavin Brown',
    'Images/icons by Dave Stokes, www.fatcow.com and A S Lewis. License information',
    '   and full attributions can be found in ../share/images/COPYING and',
    '   ../share/icons/COPYING',
    'Sound by KevanGC, AirMan, AngryFlash, battlestar10, Brandondorf, Cam Martinez,',
    '   Christopher, Conor, Daniel Simon, DrumM8, G-rant, Grant Evans, Grandpa,',
    '   J Blow, J Bravo, Kevan, KevanGC, Lisa Redfern, Maximilien, Mike Koenig,',
    '   Muska666, Pool Shot, PsychoBird, RA The Sun God, Ragdoll485, Samantha Enrico,',
    '   Simon Craggs, Snore Man, Sonidor, Sound Explorer, Stephan, Sweeper, tamskp,',
    '   Tim Fryer, Vladimir, Willem Hunt and Yannick Lemieux. License information and',
    '   full attributions can be found in ../share/items/sounds/COPYING',
    'Documentation and help files by A S Lewis. Licence information can be found in',
    '   ../share/docs/COPYING and ../share/help/COPYING',
);

# External dependencies (Glib is commented out as it's already been used)
use Archive::Extract;
use Archive::Tar;
use Archive::Zip;
use Compress::Zlib;
use Encode qw(decode encode encodings find_encoding from_to);
use Fcntl qw(:flock);
use File::Basename;
use File::Copy qw(copy move);
use File::Copy::Recursive qw(dirmove);
use File::Fetch;
use File::Find;
use File::HomeDir qw(my_home);
use File::Path qw(remove_tree);
use File::ShareDir ':ALL';
use File::ShareDir::Install;
#use Glib qw(TRUE FALSE);
use GooCanvas2;
use Gtk3 '-init';
use HTTP::Tiny;
use IO::Socket::INET;
#use IO::Socket::INET6;
#use IO::Socket::SSL;
use IPC::Run qw(start);
use JSON;
use Math::Round;
use Math::Trig;
use Module::Load qw(load);
use Net::OpenSSH;
use POSIX qw(ceil floor);
use Regexp::IPv6 qw($IPv6_re);
use Safe;
use Scalar::Util qw(looks_like_number);
use Socket qw(AF_INET SOCK_STREAM inet_aton sockaddr_in);
use Symbol qw(qualify);
use Storable qw(lock_nstore lock_retrieve);
use Time::HiRes qw(gettimeofday usleep);
use Time::Piece;

# Net::SSLeay issues can cause inability to install IO::Socket::SSL on some systems. If it's not
#   available, set a global flag so that GA::Session won't try to connect to a world with SSL
my $rc = eval {
    require IO::Socket::SSL;
    IO::Socket::SSL->import();
    1;
};

if ($rc) {
    $NO_SSL_FLAG = TRUE;
} else {
    $NO_SSL_FLAG = FALSE;
}

# As of v2.0, IO::Socket::INET6 can't be installed on MS Windows. Since the module is not
#   referenced directly by Axmud code, we don't need to set a global flag
eval {
    require IO::Socket::INET6;
    IO::Socket::INET6->import();
    1;
};

# Internal dependencies
use Games::Axmud;
use Language::Axbasic;
use Language::Axbasic::Expression;  # Due to way original Language::Basic was written,
use Language::Axbasic::Function;    #   quickest way to integrate it is to 'use' all the Axbasic
use Language::Axbasic::Statement;   #   source code files here
use Language::Axbasic::Subroutine;
use Language::Axbasic::Variable;

# Axmud's source file directory (folder)
$TOP_DIR = File::Basename::dirname(__FILE__);
# All files required after the Axmud script has been compiled are stored in /share
$SHARE_DIR = File::ShareDir::dist_dir('Games-Axmud');
# Axmud's data directory. Axmud creates any data files from scratch if they don't already exist
# (Use literal backwards slashes on MS Windows so that commands like ';listdirectory' show what the
#   use is expecting to see)
if ($^O eq 'MSWin32') {
    $DEFAULT_DATA_DIR = File::HomeDir->my_home . '\\' . $NAME_SHORT . '-data';
} else {
    $DEFAULT_DATA_DIR = File::HomeDir->my_home . '/' . $NAME_SHORT . '-data';
}
# If a file 'datadir.cfg' exists and contains (in its first line) a directory, use that as the
#   data directory instead of using the default location
$DATA_DIR = $DEFAULT_DATA_DIR;
if (-e $TOP_DIR . '/datadir.cfg') {

    my ($fileHandle, $firstLine);

    if (open $fileHandle, '<', $TOP_DIR . '/datadir.cfg') {

        $firstLine = <$fileHandle>;
        close $fileHandle;
    }

    if (defined $firstLine) {

        chomp $firstLine;
        $DATA_DIR = $firstLine;
    }
}

# Put paths to plugins (all of them Perl modules) into @INC
push (@INC,



( run in 3.835 seconds using v1.01-cache-2.11-cpan-39bf76dae61 )