Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions control/config.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ char

# Poseidon Settings: https://openkore.com/wiki/Poseidon
# They must be the same as Query Server config in Poseidon.txt
poseidonServer 127.0.0.1
poseidonPort 24390
poseidonQueryServerIp 127.0.0.1
poseidonQueryServerPort 24390

bindIp
forceMapIP
Expand Down
9 changes: 5 additions & 4 deletions control/poseidon.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Ragnarok Server
# Here you'll define the IP Address and the Port where Poseidon
# will keep waiting for your ragnarok online client to connect.
ragnarokserver_ip=127.0.0.1
ragnarokserver_port=6900
poseidonRoServerIp=127.0.0.1
poseidonRoServerPort=6900

# Query Server
# Here you'll define the IP Address and the Port where Poseidon
# will keep waiting for open kore to connect and send the GG/HS queries.
queryserver_ip=127.0.0.1
queryserver_port=24390
poseidonQueryServerIp=0.0.0.0
poseidonQueryServerPort=24390

# Server Type
# Here you have to specify your current server type in order
Expand All @@ -18,3 +18,4 @@ queryserver_port=24390
server_type=Default

debug=0
#debugPacket_exclude=007F, 0360, 0187
7 changes: 3 additions & 4 deletions src/Poseidon/Client.pm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# Copyright (c) 2005-2006 OpenKore Development Team
# Copyright (c) 2005-2025 OpenKore Development Team
############################################################
##
# MODULE DESCRIPTION: Poseidon GameGuard query handler.
Expand All @@ -24,7 +24,6 @@ use Utils qw(dataWaiting);
use Plugins;
use Misc;

use constant DEFAULT_POSEIDON_SERVER_PORT => 24390;
use constant POSEIDON_SUPPORT_URL => 'https://openkore.com/wiki/Poseidon';

our $instance;
Expand Down Expand Up @@ -139,8 +138,8 @@ sub getResult {
sub getInstance {
if (!$instance) {
$instance = Poseidon::Client->_new(
$config{poseidonServer} || 'localhost',
$config{poseidonPort} || DEFAULT_POSEIDON_SERVER_PORT);
$config{poseidonQueryServerIp} || 'localhost',
$config{poseidonQueryServerPort} || 24390);
}
return $instance;
}
Expand Down
64 changes: 32 additions & 32 deletions src/Poseidon/Config.pm
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
###########################################################
# Poseidon server
#
# 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 2
# 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 2
# of the License, or (at your option) any later version.
#
# Copyright (c) 2005-2006 OpenKore Development Team
# Copyright (c) 2005-2025 OpenKore Development Team
#
# Credits:
# isieo - schematic of XKore 2 and other interesting ideas
Expand All @@ -18,57 +18,57 @@
package Poseidon::Config;

use strict;
require Exporter;
require Exporter;

our @ISA = qw(Exporter);
our @ISA = qw(Exporter);
our @EXPORT=qw(%config);

our %config = ();

# Function to Parse the Environment Variables
sub parse_config_file {
my $File = shift;
my $File = shift;
my ($Key, $Value);

# Return early to avoid loading poseidon.txt (which might not exist at this point)
if ($config{ragnarokserver_ip} ne "" && $config{ragnarokserver_port} ne "" && $config{queryserver_ip} ne "" && $config{debug} ne ""
&& $config{queryserver_port} ne "" && $config{queryserver_ip} ne "" && $config{server_type} ne "") {
if ($config{poseidonRoServerIp} ne "" && $config{poseidonRoServerPort} ne "" && $config{poseidonQueryServerIp} ne "" && $config{debug} ne ""
&& $config{poseidonQueryServerPort} ne "" && $config{poseidonQueryServerIp} ne "" && $config{serverType} ne "") {
print "\t[debug] Skipping config file\n" if $config{debug};
return;
}
open (CONFIG, "<", "../../control/".$File) or open (CONFIG, "<", "./control/".$File) or open (CONFIG, "<", $File) or die "ERROR: Config file not found : ".$File;
while (my $line = <CONFIG>) {
chomp ($line); # Remove trailling \n
$line =~ s/^\s*//; # Remove spaces at the start of the line
$line =~ s/\s*$//; # Remove spaces at the end of the line
if ($line !~ /^#/ && $line ne "") { # Ignore lines starting with # and blank lines
($Key, $Value) = split (/=/, $line); # Split each line into name value pairs

open (CONFIG, "<", "../../control/".$File) or open (CONFIG, "<", "./control/".$File) or open (CONFIG, "<", $File) or die "ERROR: Config file not found : ".$File;

while (my $line = <CONFIG>) {
chomp ($line); # Remove trailling \n
$line =~ s/^\s*//; # Remove spaces at the start of the line
$line =~ s/\s*$//; # Remove spaces at the end of the line
if ($line !~ /^#/ && $line ne "") { # Ignore lines starting with # and blank lines
($Key, $Value) = split (/=/, $line); # Split each line into name value pairs
if ($config{$Key} ne "") { # Skip key if we already know it from command line arguments
print "\t[debug] Skipping ".$Key." key in config file\n" if $config{debug}; # Will only work with command line --debug=1 argument, unless debug key is moved to the top of poseidon.txt
next;
}
$config{$Key} = $Value; # Create a hash of the name value pairs
}
}
close(CONFIG);
$config{$Key} = $Value; # Create a hash of the name value pairs
}
}

close(CONFIG);
}

sub parseArguments {
use Getopt::Long;
GetOptions(
'file=s', \$config{file},
'ragnarokserver_ip=s', \$config{ragnarokserver_ip},
'ragnarokserver_port=s', \$config{ragnarokserver_port},
'queryserver_ip=s', \$config{queryserver_ip},
'queryserver_port=s', \$config{queryserver_port},
'server_type=s', \$config{server_type},
'poseidonRoServerIp=s', \$config{poseidonRoServerIp},
'poseidonRoServerPort=s', \$config{poseidonRoServerPort},
'poseidonQueryServerIp=s', \$config{poseidonQueryServerIp},
'poseidonQueryServerPort=s',\$config{poseidonQueryServerPort},
'serverType=s', \$config{serverType},
'debug=s', \$config{debug},
);

$config{file} = "poseidon.txt" if ($config{file} eq "");
}

1;
1;
4 changes: 2 additions & 2 deletions src/Poseidon/Distfiles
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ EmbedServer.pm
poseidon.pl
QueryServer.pm
RagnarokServer.pm
servertypes.txt
TECHNICAL.TXT
ServerTypes.txt
Readme.txt
33 changes: 15 additions & 18 deletions src/Poseidon/QueryServer.pm
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
###########################################################
# Poseidon server - OpenKore communication channel
#
# 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 2
# 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 2
# of the License, or (at your option) any later version.
#
# Copyright (c) 2005-2006 OpenKore Development Team
# Copyright (c) 2005-2025 OpenKore Development Team
###########################################################
package Poseidon::QueryServer;

Expand Down Expand Up @@ -66,8 +66,8 @@ sub process {
$client->close();
return;
}
print "[PoseidonServer]-> Received query from bot client " . $client->getIndex() . "\n";

print "[Poseinon Qery server] <- Received request from OpenKore (" . $client->getIndex() . ")\n";

my %request = (
packet => $args->{packet},
Expand Down Expand Up @@ -95,25 +95,23 @@ sub process {
sub onClientNew {
my ($self, $client, $index) = @_;
$client->{"$CLASS parser"} = new Bus::MessageParser();
print "[PoseidonServer]-> New Bot Client Connected : " . $client->getIndex() . "\n";
print "[Poseinon Qery server] <- OpenKore (" . $client->getIndex() . ") connected.\n";
}

sub onClientExit {
my ($self, $client, $index) = @_;
print "[PoseidonServer]-> Bot Client Disconnected : " . $client->getIndex() . "\n";
print "[Poseinon Qery server] -> OpenKore (" . $client->getIndex() . ") disconnected.\n";
}

sub onClientData
{
sub onClientData {
my ($self, $client, $msg) = @_;
my ($ID, $args);

my $parser = $client->{"$CLASS parser"};

$parser->add($msg);

while ($args = $parser->readNext(\$ID))
{

while ($args = $parser->readNext(\$ID)) {
$self->process($client, $ID, $args);
}
}
Expand All @@ -126,8 +124,7 @@ sub iterate {
$server = $self->{"$CLASS server"};
$queue = $self->{"$CLASS queue"};

if ($server->getState() eq 'requested')
{
if ($server->getState() eq 'requested') {
# Send the response to the client.
if (@{$queue} > 0 && $queue->[0]{client}) {
my ($data, %args);
Expand All @@ -137,12 +134,12 @@ sub iterate {
$data = serialize("Poseidon Reply", \%args);
$queue->[0]{client}->send($data);
$queue->[0]{client}->close();
print "[PoseidonServer]-> Sent result to client : " . $queue->[0]{client}->getIndex() . "\n";
print "[Poseinon Qery server] -> Response sent to OpenKore (" . $queue->[0]{client}->getIndex() . ")\n";
}
shift @{$queue};

} elsif (@{$queue} > 0 && $server->getState() eq 'ready') {
print "[PoseidonServer]-> Querying Ragnarok Online client [" . getFormattedDateShort(time, 1) . "]...\n";
print "[Poseinon Qery server] -> Querying RO client [" . getFormattedDateShort(time, 1) . "] ...\n";
$server->query($queue->[0]{packet});
}
}
Expand Down
Loading
Loading