Read eqemu_config.json into eqemu_server.pl utility script

This commit is contained in:
Akkadius 2017-07-23 02:55:02 -05:00
parent 618252882c
commit 055daddcaf

View File

@ -52,7 +52,12 @@ do_self_update_check_routine() if !$skip_self_update_check;
check_xml_to_json_conversion() if $ARGV[0] eq "convert_xml"; check_xml_to_json_conversion() if $ARGV[0] eq "convert_xml";
get_windows_wget(); get_windows_wget();
get_perl_version(); get_perl_version();
if(-e "eqemu_config.json") {
read_eqemu_config_json();
}
else {
read_eqemu_config_xml(); read_eqemu_config_xml();
}
get_mysql_path(); get_mysql_path();
#::: Remove old eqemu_update.pl #::: Remove old eqemu_update.pl
@ -1126,6 +1131,26 @@ sub read_eqemu_config_xml {
close(CONFIG); close(CONFIG);
} }
sub read_eqemu_config_json {
use JSON;
my $json = new JSON();
my $content;
open(my $fh, '<', "eqemu_config.json") or die "cannot open file $filename"; {
local $/;
$content = <$fh>;
}
close($fh);
$config = $json->decode($content);
$db = $config->{"server"}{"database"}{"db"} . "\n";
$host = $config->{"server"}{"database"}{"host"} . "\n";
$user = $config->{"server"}{"database"}{"username"} . "\n";
$password = $config->{"server"}{"database"}{"password"} . "\n";
$long_name = $config->{"server"}{"world"}{"longname"} . "\n";
}
#::: Fetch Latest PEQ AA's #::: Fetch Latest PEQ AA's
sub aa_fetch{ sub aa_fetch{
if(!$db){ if(!$db){