mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 22:58:34 +00:00
svn -> git Migration
This commit is contained in:
@@ -0,0 +1,89 @@
|
||||
sub EVENT_SAY
|
||||
{
|
||||
if($text=~/mob/i)
|
||||
{
|
||||
my @moblist = $entity_list->GetMobList();
|
||||
foreach $ent (@moblist)
|
||||
{
|
||||
$ent->Shout("I'm a mob!");
|
||||
}
|
||||
}
|
||||
|
||||
if($text=~/npc/i)
|
||||
{
|
||||
my @npclist = $entity_list->GetNPCList();
|
||||
foreach $ent (@npclist)
|
||||
{
|
||||
$ent->Shout("I'm a npc!");
|
||||
}
|
||||
}
|
||||
|
||||
if($text=~/client/i)
|
||||
{
|
||||
my @clientlist = $entity_list->GetClientList();
|
||||
foreach $ent (@clientlist)
|
||||
{
|
||||
$ent->Shout("I'm a client!");
|
||||
}
|
||||
}
|
||||
|
||||
if($text=~/corpse/i)
|
||||
{
|
||||
my @corpselist = $entity_list->GetCorpseList();
|
||||
my $index = 0;
|
||||
my $index_two = 0;
|
||||
foreach $ent (@corpselist)
|
||||
{
|
||||
if($ent->GetOwnerName() eq $client->GetName())
|
||||
{
|
||||
$index_two++;
|
||||
}
|
||||
$index++;
|
||||
}
|
||||
quest::say("There are $index corpses in the zone and $index_two of them belong to you.");
|
||||
}
|
||||
|
||||
if($text=~/summon/i)
|
||||
{
|
||||
my @corpselist = $entity_list->GetCorpseList();
|
||||
foreach $ent (@corpselist)
|
||||
{
|
||||
if($ent->GetOwnerName() eq $client->GetName())
|
||||
{
|
||||
$ent->Summon($client, 1773);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($text=~/rez/i)
|
||||
{
|
||||
my @corpselist = $entity_list->GetCorpseList();
|
||||
foreach $ent (@corpselist)
|
||||
{
|
||||
if($ent->GetOwnerName() eq $client->GetName())
|
||||
{
|
||||
$ent->CastRezz(994, $npc);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub EVENT_AGGRO_SAY
|
||||
{
|
||||
if($text=~/hate/i)
|
||||
{
|
||||
my @hatelist = $npc->GetHateList();
|
||||
foreach $ent (@hatelist)
|
||||
{
|
||||
my $h_ent = $ent->GetEnt();
|
||||
my $h_dmg = $ent->GetDamage();
|
||||
my $h_hate = $ent->GetHate();
|
||||
if($h_ent)
|
||||
{
|
||||
my $h_ent_name = $h_ent->GetName();
|
||||
quest::say("$h_ent_name is on my hate list with $h_hate hate and $h_dmg damage.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
sub EVENT_SAY {
|
||||
if($text=~/despawn/i)
|
||||
{
|
||||
quest::disable_spawn2(10842);
|
||||
quest::say("Yes sir!");
|
||||
}
|
||||
elsif($text=~/enable/i)
|
||||
{
|
||||
quest::enable_spawn2(10842);
|
||||
quest::say("Yes sir!");
|
||||
}
|
||||
elsif($text=~/spawn/i)
|
||||
{
|
||||
quest::spawn_from_spawn2(10842);
|
||||
quest::say("Yes sir!");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
#! /usr/bin/perl
|
||||
|
||||
#use strict;
|
||||
#use warnings;
|
||||
use DBI;
|
||||
use Getopt::Std;
|
||||
|
||||
#get config info from eqemu_config.xml to connect to the db & point to spells_us.txt
|
||||
getopts('c:t:i:s:oh');
|
||||
my $conf = "eqemu_config.xml"; #default
|
||||
my $table = "spells_new"; #default
|
||||
my $id = "id"; #default
|
||||
my $spellf = "spells_us.txt"; #default
|
||||
|
||||
if ($opt_h) { #help (-h)
|
||||
printf "\nUsage: export_spells.pl [-c path] [-t table] [-i column] [-s path] [-o]\n";
|
||||
printf " -c path path/to/eqemu_config.xml. defaults to $conf\n";
|
||||
printf " -t table table to load the spells from. defaults to $table\n";
|
||||
printf " -i column name of the column in the database table to order by. defaults to $id\n";
|
||||
printf " -s path path/to/export/spells_us.txt. defaults to $spellf\n";
|
||||
printf " -o overwrite $spellf if it exists\n";
|
||||
printf "\n";
|
||||
exit;
|
||||
}
|
||||
if ($opt_c) {$conf = $opt_c;} #use config file from -c, if defined
|
||||
if ($opt_t) {$table = $opt_t;} #use db table -t, if defined
|
||||
if ($opt_i) {$id = $opt_i;} #use column name -i, if defined
|
||||
if ($opt_s) {$spellf = $opt_s;} #use spells file from -s, if defined
|
||||
|
||||
my $db = "eq";
|
||||
my $user = "eq";
|
||||
my $pass = "eq";
|
||||
my $host = "localhost";
|
||||
open(F, "<$conf") or die "Unable to open config: $conf\n";
|
||||
my $indb = 0;
|
||||
while(<F>) {
|
||||
s/\r//g;
|
||||
if(/<database>/i) {
|
||||
$indb = 1;
|
||||
}
|
||||
next unless($indb == 1);
|
||||
if(/<\/database>/i) {
|
||||
$indb = 0;
|
||||
last;
|
||||
}
|
||||
if(/<host>(.*)<\/host>/i) {
|
||||
$host = $1;
|
||||
} elsif(/<username>(.*)<\/username>/i) {
|
||||
$user = $1;
|
||||
} elsif(/<password>(.*)<\/password>/i) {
|
||||
$pass = $1;
|
||||
} elsif(/<db>(.*)<\/db>/i) {
|
||||
$db = $1;
|
||||
}
|
||||
}
|
||||
if(!$db || !$user || !$pass || !$host) {
|
||||
die "Invalid database info, missing one of: host, user, password, database\n";
|
||||
}
|
||||
|
||||
#connect to the db before we waste time loading the spells file
|
||||
my $source = "DBI:mysql:database=$db;host=$host";
|
||||
my $dbh = DBI->connect($source, $user, $pass) || die "Could not create db handle\n";
|
||||
|
||||
if ((-e $spellf) && !$opt_o) { #spell file already exists & we don't want to overwrite
|
||||
die "'$spellf' already exists; Use -o if you want to overwrite\n";
|
||||
}
|
||||
|
||||
#open spell file
|
||||
open(SPELLS, ">$spellf") or die "Unable to open spell file for export: $spellf\n";
|
||||
|
||||
#parse through spells & write to spells_us.txt
|
||||
my $sth = $dbh->prepare("SELECT * FROM $table ORDER BY $id ASC");
|
||||
$sth->execute(); #run the query on the db
|
||||
my($numspells, $loadedspells, $highid); #define some variables, cause we're cool like that
|
||||
while (my $val = $sth->fetch()) {
|
||||
++$numspells;
|
||||
printf("Exporting \"%s\" (%d) \r", @$val[1], @$val[0]); # name (id)
|
||||
my $line = join("^", @$val) . "\n"; #convert to delimited string, with a newline at the end
|
||||
print SPELLS $line; #write to the file
|
||||
$highid = @$val[0]; #set to current id
|
||||
}
|
||||
|
||||
close (SPELLS); #since we're done with it...
|
||||
|
||||
#summary of results
|
||||
print "Spells Exported: $numspells \n";
|
||||
print "Highest ID: $highid\n\n";
|
||||
@@ -0,0 +1,112 @@
|
||||
use DBI;
|
||||
|
||||
my $db = peq;
|
||||
my $user = eqemu;
|
||||
my $pass = eqemu;
|
||||
my $host = localhost;
|
||||
|
||||
my $source = "DBI:mysql:database=$db;host=$host";
|
||||
my $dbh = DBI->connect($source, $user, $pass) || die "Could not create db handle\n";
|
||||
|
||||
my $select_query = "SELECT id,name,base,mod_c1,mod_c2,mod_c3,mod_c4,mod_c5,mod_c6,mod_c7,mod_c8,mod_c9,mod_c10,mod_c11,mod_c12,";
|
||||
$select_query .= "mod_c13,mod_c14,mod_c15,mod_c16,mod_r1,mod_r2,mod_r3,mod_r4,mod_r5,mod_r6,mod_r7,mod_r8,mod_r9,mod_r10,mod_r11,";
|
||||
$select_query .= "mod_r12,mod_r14,mod_r42,mod_r75,mod_r108,mod_r128,mod_r130,mod_r161,mod_r330,mod_r367,mod_r522,mod_d140,mod_d201,";
|
||||
$select_query .= "mod_d202,mod_d203,mod_d204,mod_d205,mod_d206,mod_d207,mod_d208,mod_d209,mod_d210,mod_d211,mod_d212,mod_d213,";
|
||||
$select_query .= "mod_d214,mod_d215,mod_d216 FROM faction_list";
|
||||
|
||||
my $count = 0;
|
||||
my $sth = $dbh->prepare($select_query);
|
||||
$sth->execute();
|
||||
while (my $ref = $sth->fetchrow_hashref()) {
|
||||
for(my $i = 1; $i <= 16; $i++) {
|
||||
my $field_name = "mod_c" . $i;
|
||||
if($ref->{$field_name} != 0) {
|
||||
my $mod_name = "c" . $i;
|
||||
my $rsth = $dbh->prepare("REPLACE INTO `faction_list_mod` (`faction_id`,`mod`,`mod_name`) VALUES(?, ?, ?)");
|
||||
$rsth->execute($ref->{id}, $ref->{$field_name}, $mod_name);
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
for(my $i = 1; $i <= 12; $i++) {
|
||||
my $field_name = "mod_r" . $i;
|
||||
if($ref->{$field_name} != 0) {
|
||||
my $mod_name = "r" . $i;
|
||||
my $rsth = $dbh->prepare("REPLACE INTO `faction_list_mod` (`faction_id`,`mod`,`mod_name`) VALUES(?, ?, ?)");
|
||||
$rsth->execute($ref->{id}, $ref->{$field_name}, $mod_name);
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
|
||||
if($ref->{"mod_r14"} != 0) {
|
||||
my $rsth = $dbh->prepare("REPLACE INTO `faction_list_mod` (`faction_id`,`mod`,`mod_name`) VALUES(?, ?, ?)");
|
||||
$rsth->execute($ref->{id}, $ref->{"mod_r14"}, "r14");
|
||||
$count++;
|
||||
}
|
||||
|
||||
if($ref->{"mod_r42"} != 0) {
|
||||
my $rsth = $dbh->prepare("REPLACE INTO `faction_list_mod` (`faction_id`,`mod`,`mod_name`) VALUES(?, ?, ?)");
|
||||
$rsth->execute($ref->{id}, $ref->{"mod_r42"}, "r42");
|
||||
$count++;
|
||||
}
|
||||
|
||||
if($ref->{"mod_r75"} != 0) {
|
||||
my $rsth = $dbh->prepare("REPLACE INTO `faction_list_mod` (`faction_id`,`mod`,`mod_name`) VALUES(?, ?, ?)");
|
||||
$rsth->execute($ref->{id}, $ref->{"mod_r75"}, "r75");
|
||||
$count++;
|
||||
}
|
||||
|
||||
if($ref->{"mod_r108"} != 0) {
|
||||
my $rsth = $dbh->prepare("REPLACE INTO `faction_list_mod` (`faction_id`,`mod`,`mod_name`) VALUES(?, ?, ?)");
|
||||
$rsth->execute($ref->{id}, $ref->{"mod_r108"}, "r108");
|
||||
$count++;
|
||||
}
|
||||
|
||||
if($ref->{"mod_r128"} != 0) {
|
||||
my $rsth = $dbh->prepare("REPLACE INTO `faction_list_mod` (`faction_id`,`mod`,`mod_name`) VALUES(?, ?, ?)");
|
||||
$rsth->execute($ref->{id}, $ref->{"mod_r128"}, "r128");
|
||||
$count++;
|
||||
}
|
||||
|
||||
if($ref->{"mod_r130"} != 0) {
|
||||
my $rsth = $dbh->prepare("REPLACE INTO `faction_list_mod` (`faction_id`,`mod`,`mod_name`) VALUES(?, ?, ?)");
|
||||
$rsth->execute($ref->{id}, $ref->{"mod_r130"}, "r130");
|
||||
$count++;
|
||||
}
|
||||
|
||||
if($ref->{"mod_r161"} != 0) {
|
||||
my $rsth = $dbh->prepare("REPLACE INTO `faction_list_mod` (`faction_id`,`mod`,`mod_name`) VALUES(?, ?, ?)");
|
||||
$rsth->execute($ref->{id}, $ref->{"mod_r161"}, "r161");
|
||||
$count++;
|
||||
}
|
||||
|
||||
if($ref->{"mod_r330"} != 0) {
|
||||
my $rsth = $dbh->prepare("REPLACE INTO `faction_list_mod` (`faction_id`,`mod`,`mod_name`) VALUES(?, ?, ?)");
|
||||
$rsth->execute($ref->{id}, $ref->{"mod_r330"}, "r330");
|
||||
$count++;
|
||||
}
|
||||
|
||||
if($ref->{"mod_r367"} != 0) {
|
||||
my $rsth = $dbh->prepare("REPLACE INTO `faction_list_mod` (`faction_id`,`mod`,`mod_name`) VALUES(?, ?, ?)");
|
||||
$rsth->execute($ref->{id}, $ref->{"mod_r367"}, "r367");
|
||||
$count++;
|
||||
}
|
||||
|
||||
if($ref->{"mod_r522"} != 0) {
|
||||
my $rsth = $dbh->prepare("REPLACE INTO `faction_list_mod` (`faction_id`,`mod`,`mod_name`) VALUES(?, ?, ?)");
|
||||
$rsth->execute($ref->{id}, $ref->{"mod_r522"}, "r522");
|
||||
$count++;
|
||||
}
|
||||
|
||||
for(my $i = 201; $i <= 216; $i++) {
|
||||
my $field_name = "mod_d" . $i;
|
||||
if($ref->{$field_name} != 0) {
|
||||
my $mod_name = "d" . $i;
|
||||
my $rsth = $dbh->prepare("REPLACE INTO `faction_list_mod` (`faction_id`,`mod`,`mod_name`) VALUES(?, ?, ?)");
|
||||
$rsth->execute($ref->{id}, $ref->{$field_name}, $mod_name);
|
||||
$count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print "$count entries created.\n";
|
||||
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
my $date = $ARGV[0];
|
||||
my $opcodes_out = $ARGV[1];
|
||||
|
||||
my %opcodes = ();
|
||||
|
||||
open(F, "<worldopcodes.xml") || die "Unable to open worldopcodes.xml";
|
||||
while(<F>) {
|
||||
chomp;
|
||||
next unless (/updated="$date"/);
|
||||
if(/^.*id="([0-9a-fA-F]+)".*name="(OP_[^"]+)".*$/) {
|
||||
$opcodes{$2} = $1;
|
||||
}
|
||||
}
|
||||
close(F);
|
||||
open(F, "<zoneopcodes.xml") || die "Unable to open zoneopcodes.xml";
|
||||
while(<F>) {
|
||||
chomp;
|
||||
next unless (/updated="$date"/);
|
||||
if(/^.*id="([0-9a-fA-F]+)".*name="(OP_[^"]+)".*$/) {
|
||||
$opcodes{$2} = $1;
|
||||
}
|
||||
}
|
||||
close(F);
|
||||
|
||||
my %fixes = (
|
||||
'OP_TributeInfo' => 'OP_SendTributes',
|
||||
'OP_CancelInvite' => 'OP_GroupCancelInvite',
|
||||
'OP_GMFind' => 'OP_FindPersonRequest',
|
||||
'OP_CommonMessage' => 'OP_ChannelMessage',
|
||||
'OP_FindResponse' => 'OP_FindPersonReply',
|
||||
'OP_SpawnRename' => 'OP_MobRename',
|
||||
'OP_SendZonePoints' => 'OP_SendZonepoints',
|
||||
'OP_RequestZoneChange' => 'OP_RequestClientZoneChange',
|
||||
'OP_Lockouts' => 'OP_LockoutTimerInfo',
|
||||
'OP_GuildList' => 'OP_ZoneGuildList',
|
||||
'OP_Action2' => 'OP_Damage'
|
||||
);
|
||||
|
||||
foreach my $seq (keys(%fixes)) {
|
||||
if(defined($opcodes{$seq})) {
|
||||
$opcodes{ $fixes{$seq} } = $opcodes{$seq};
|
||||
delete($opcodes{$seq});
|
||||
}
|
||||
}
|
||||
|
||||
open(F, "<$opcodes_out") || die "Unable to open $opcodes_out";
|
||||
while(<F>) {
|
||||
chomp;
|
||||
my $line = $_;
|
||||
$line =~ s/# ShowEQ [0-9\/]+//g;
|
||||
my $found = 0;
|
||||
foreach my $op (keys(%opcodes)) {
|
||||
if($line =~ /^$op=0x.*$/) {
|
||||
print "$op=0x".$opcodes{$op}."\t\t\t# ShowEQ $date\n";
|
||||
delete($opcodes{$op});
|
||||
$found = 1;
|
||||
last;
|
||||
}
|
||||
}
|
||||
if(!$found) {
|
||||
print "$line\n";
|
||||
}
|
||||
}
|
||||
close(F);
|
||||
|
||||
foreach my $op (keys(%opcodes)) {
|
||||
print "# Unmatched: $op=0x".$opcodes{$op}."\n";
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
#! /usr/bin/perl
|
||||
|
||||
#use strict;
|
||||
#use warnings;
|
||||
use DBI;
|
||||
use Getopt::Std;
|
||||
|
||||
#get config info from eqemu_config.xml to connect to the db & point to spells_us.txt
|
||||
getopts('c:s:t:dh');
|
||||
my $conf = "eqemu_config.xml"; #default
|
||||
my $spellf = "spells_us.txt"; #default
|
||||
my $table = "spells_new"; #default
|
||||
|
||||
if ($opt_h) { #help (-h)
|
||||
printf "\nUsage: import_spells.pl [-c path] [-s path] [-t table] [-d]\n";
|
||||
printf " -c path path/to/eqemu_config.xml. defaults to $conf\n";
|
||||
printf " -s path path/to/spells_us.txt. defaults to $spellf\n";
|
||||
printf " -t table table to load the spells into. defaults to $table\n";
|
||||
printf " -d erase all spells from the database first\n\n";
|
||||
exit;
|
||||
}
|
||||
if ($opt_c) {$conf = $opt_c;} #use config file from -c, if defined
|
||||
if ($opt_s) {$spellf = $opt_s;} #use spells file from -s, if defined
|
||||
if ($opt_t) {$table = $opt_t;} #use db table -t, if defined
|
||||
|
||||
my $db = "eq";
|
||||
my $user = "eq";
|
||||
my $pass = "eq";
|
||||
my $host = "localhost";
|
||||
open(F, "<$conf") or die "Unable to open config: $conf\n";
|
||||
my $indb = 0;
|
||||
while(<F>) {
|
||||
s/\r//g;
|
||||
if(/<database>/i) {
|
||||
$indb = 1;
|
||||
}
|
||||
next unless($indb == 1);
|
||||
if(/<\/database>/i) {
|
||||
$indb = 0;
|
||||
last;
|
||||
}
|
||||
if(/<host>(.*)<\/host>/i) {
|
||||
$host = $1;
|
||||
} elsif(/<username>(.*)<\/username>/i) {
|
||||
$user = $1;
|
||||
} elsif(/<password>(.*)<\/password>/i) {
|
||||
$pass = $1;
|
||||
} elsif(/<db>(.*)<\/db>/i) {
|
||||
$db = $1;
|
||||
}
|
||||
}
|
||||
if(!$db || !$user || !$pass || !$host) {
|
||||
die "Invalid database info, missing one of: host, user, password, database\n";
|
||||
}
|
||||
|
||||
#connect to the db before we waste time loading the spells file
|
||||
my $source1 = "DBI:mysql:database=information_schema;host=$host";
|
||||
my $source2 = "DBI:mysql:database=$db;host=$host";
|
||||
|
||||
#pull the column names from the db so we don't have to maintain a list. should also help if there are more columns in the db than the spells file
|
||||
my $dbh = DBI->connect($source1, $user, $pass) || die "Could not create db handle\n";
|
||||
my $sth = $dbh->prepare("SELECT COLUMN_NAME FROM COLUMNS WHERE TABLE_SCHEMA='$db' AND TABLE_NAME='$table' ORDER BY ORDINAL_POSITION ASC");
|
||||
$sth->execute(); #run the query on the db
|
||||
#create an array of the column names. i have a feeling there might be a more direct way to do it, but oh well
|
||||
while (my $val = $sth->fetch()) {
|
||||
push(@col_names, @$val[0]); # $column[#]
|
||||
}
|
||||
|
||||
#switch to the emu db
|
||||
$dbh = DBI->connect($source2, $user, $pass) || die "Could not create db handle\n";
|
||||
|
||||
if ($opt_d) { #drop all data in the spells table
|
||||
print "Are you sure you want to erase all spells from the '$table' table?\n";
|
||||
print "y/N ? ";
|
||||
my $confirm = <STDIN>;
|
||||
if ($confirm=~/^y/i) { #as long as it begins with a Y, that's the important part
|
||||
print "Deleting spells from the '$table' table... ";
|
||||
$dbh->do("DELETE from $table");
|
||||
print "Done.\n\n";
|
||||
} else {
|
||||
print "\nSkipping erasing spells from the '$table' table\n\n";
|
||||
}
|
||||
}
|
||||
|
||||
#open spell file
|
||||
open(SPELLS, "<$spellf") or die "Unable to open spells: $spellf\n";
|
||||
#parse through spells
|
||||
my($numspells, $loadedspells, $highid); #define some variables, cause we're cool like that
|
||||
while(<SPELLS>) {
|
||||
++$numspells;
|
||||
|
||||
chomp(); #get rid of those pesky new lines
|
||||
s/'/\\'/g; #make query safe(r) by escaping quotes (\')
|
||||
@s = split(/\^/); #separate by the ^ delimiter
|
||||
|
||||
my @t_col_names = @col_names; #so we can safely pop any unneeded columns, but still have all of them the next time around
|
||||
my $col_diff = abs(scalar(@t_col_names) - scalar(@s)); #we need to find out if the db or spells file has more columns, so we don't blow something up. this will get the amount of extra columns
|
||||
#we're going to do this each loop, just in case someone screws up a line in the spell file, or starts messing with the table in the middle of the import
|
||||
if (scalar(@s) < scalar(@t_col_names)) {
|
||||
for (my $z = 1; $z <= $col_diff; $z++) {
|
||||
pop(@t_col_names);
|
||||
}
|
||||
} elsif (scalar(@s) > scalar(@t_col_names)) {
|
||||
for (my $z = 1; $z <= $col_diff; $z++) {
|
||||
pop(@s);
|
||||
}
|
||||
}
|
||||
|
||||
my $insert1 = join("`,`", @t_col_names);
|
||||
my $insert2 = join("','", @s); #put everything in quotes & separate w/ commas for the query, plus the beginning & ending quotes. this doesn't print out to the console correctly (for me), but hopefully the query will be fine
|
||||
my $insert = sprintf("REPLACE INTO %s (`%s`) VALUES ('%s')", $table, $insert1, $insert2);
|
||||
|
||||
printf("Loading \"%s\" (%d) \r", $s[1], $s[0]); # name (id)
|
||||
|
||||
my $i = $dbh->do($insert); #put these bad boys into the db
|
||||
if ($i < 1) { #if the query didn't update anything into the db, or errored
|
||||
printf("Error loading \"%s\" (%s) \n", $s[1], $s[0]);
|
||||
} else {
|
||||
$loadedspells++; #to compare db inserts to total spells
|
||||
}
|
||||
|
||||
$highid = $s[0]; #set to current id
|
||||
}
|
||||
|
||||
print "Spells Loaded: $loadedspells of $numspells \n";
|
||||
print "Highest ID: $highid\n\n";
|
||||
@@ -0,0 +1,77 @@
|
||||
#! /usr/bin/perl
|
||||
|
||||
use DBI;
|
||||
use Getopt::Std;
|
||||
|
||||
getopts('d:h');
|
||||
$conf = "eqemu_config.xml";
|
||||
if($opt_h) {
|
||||
die "Usage: load_13thfloor_items.pl [-d path/to/eqemu_config.xml]\n";
|
||||
}
|
||||
if($opt_d) {
|
||||
$conf = $opt_d;
|
||||
}
|
||||
|
||||
$db = "eq";
|
||||
$user = "eq";
|
||||
$pass = "eq";
|
||||
$host = "localhost";
|
||||
open(F, "<$conf") or die "Unable to open config $conf\n";
|
||||
$indb = 0;
|
||||
while(<F>) {
|
||||
s/\r//g;
|
||||
if(/<database>/i) {
|
||||
$indb = 1;
|
||||
}
|
||||
next unless($indb == 1);
|
||||
if(/<\/database>/i) {
|
||||
$indb = 0;
|
||||
last;
|
||||
}
|
||||
if(/<host>(.*)<\/host>/i) {
|
||||
$host = $1;
|
||||
} elsif(/<username>(.*)<\/username>/i) {
|
||||
$user = $1;
|
||||
} elsif(/<password>(.*)<\/password>/i) {
|
||||
$pass = $1;
|
||||
} elsif(/<db>(.*)<\/db>/i) {
|
||||
$db = $1;
|
||||
}
|
||||
}
|
||||
if(!$db || !$user || !$pass || !$host) {
|
||||
die "Invalid db.ini, missing one of: host, user, password, database\n";
|
||||
}
|
||||
|
||||
$source="DBI:mysql:database=$db;host=$host";
|
||||
|
||||
my $dbh = DBI->connect($source, $user, $pass) || die "Could not create db handle\n";
|
||||
|
||||
$_=<STDIN>;
|
||||
chomp();
|
||||
s/'/\\'/g;
|
||||
@fields=split("(?<!\\\\)\\|", $_);
|
||||
|
||||
%conversions = (
|
||||
"itemtype" => "itemuse"
|
||||
);
|
||||
|
||||
$insert="replace into items (".join(",",@fields).",source,updated) values ('";
|
||||
$insert=~s/UNK130/potionbeltslots/;
|
||||
$insert=~s/UNK133/stackable/;
|
||||
|
||||
#select(STDOUT); $|=1;
|
||||
while(<STDIN>) {
|
||||
chomp();
|
||||
s/'/\\'/g;
|
||||
@f=split("(?<!\\\\)\\|", $_);
|
||||
$insert2=join("','",@f);
|
||||
$#f--;
|
||||
grep(s/\\\|/\\\\\|/g,@f);
|
||||
grep(s/"/\\\\"/g,@f);
|
||||
$statement=sprintf("%s%s','13THFLOOR',now())",$insert,$insert2,join('|',@f));
|
||||
$dbh->do($statement);
|
||||
printf("Processing: %d %s \r",$f[4],$f[1]);
|
||||
++$count;
|
||||
}
|
||||
printf("Processed: %d items(s) \n",$count);
|
||||
|
||||
@@ -0,0 +1,226 @@
|
||||
#!/usr/bin/perl -W
|
||||
|
||||
use strict;
|
||||
|
||||
sub usage() {
|
||||
print "Usage: ppreader.pl [-o|-n|-p|-r|-c] (old_pp) (old2_pp)\n";
|
||||
print " -o - print offsets for old struct\n";
|
||||
print " -n - print offsets for new struct\n";
|
||||
print " -p - print pp converter from old to new\n";
|
||||
print " -c - print pp converter between two old PPs\n";
|
||||
print " -r - read al alternative header and print offsets\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if($#ARGV < 0) {
|
||||
usage();
|
||||
}
|
||||
|
||||
my $mode = $ARGV[0];
|
||||
|
||||
my $temp = ".temp";
|
||||
|
||||
|
||||
|
||||
if($mode eq "-r") {
|
||||
my $file = $ARGV[1];
|
||||
my $struct = $ARGV[2];
|
||||
print STDERR "Reading $struct from $file...\n";
|
||||
(my $old_order, my $old_fields, my $old_offsets) = readpp($struct, $file);
|
||||
foreach my $f(@{$old_order}) {
|
||||
my $off = $old_offsets->{$f};
|
||||
my $code = $old_fields->{$f};
|
||||
printf("/*%04lu*/%s\n", $off, $code);
|
||||
}
|
||||
} elsif($mode eq "-o") {
|
||||
print STDERR "Reading old player profile...\n";
|
||||
my $old_struct = $ARGV[1];
|
||||
(my $old_order, my $old_fields, my $old_offsets) = readpp($old_struct, "../common/eq_old_structs.h");
|
||||
foreach my $f(@{$old_order}) {
|
||||
my $off = $old_offsets->{$f};
|
||||
my $code = $old_fields->{$f};
|
||||
printf("/*%04lu*/%s\n", $off, $code);
|
||||
}
|
||||
} elsif($mode eq "-n") {
|
||||
print STDERR "Reading new player profile...\n";
|
||||
(my $order, my $fields, my $offsets) = readpp("PlayerProfile_Struct", "../common/eq_packet_structs.h");
|
||||
foreach my $f(@{$order}) {
|
||||
my $off = $offsets->{$f};
|
||||
my $code = $fields->{$f};
|
||||
printf("/*%04lu*/%s\n", $off, $code);
|
||||
}
|
||||
} elsif($mode eq "-p") {
|
||||
if($#ARGV != 1) {
|
||||
usage();
|
||||
}
|
||||
my $old_struct = $ARGV[1];
|
||||
|
||||
print STDERR "Reading old player profile...\n";
|
||||
(my $old_order, my $old_fields, my $old_offsets) = readpp($old_struct, "../common/eq_old_structs.h");
|
||||
print STDERR "Reading new player profile...\n";
|
||||
(my $order, my $fields, my $offsets) = readpp("PlayerProfile_Struct", "../common/eq_packet_structs.h");
|
||||
|
||||
compare_pps($old_order, $old_fields, $old_offsets,
|
||||
$order, $fields, $offsets);
|
||||
} elsif($mode eq "-c") {
|
||||
if($#ARGV != 2) {
|
||||
usage();
|
||||
}
|
||||
my $old_struct = $ARGV[1];
|
||||
my $old2_struct = $ARGV[2];
|
||||
|
||||
print STDERR "Reading old player profile...\n";
|
||||
(my $old_order, my $old_fields, my $old_offsets) = readpp($old_struct, "../common/eq_old_structs.h");
|
||||
print STDERR "Reading old2 player profile...\n";
|
||||
(my $order, my $fields, my $offsets) = readpp($old2_struct, "../common/eq_old_structs.h");
|
||||
|
||||
compare_pps($old_order, $old_fields, $old_offsets,
|
||||
$order, $fields, $offsets);
|
||||
} else {
|
||||
print "Invalid mode specified.";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
||||
sub compare_pps {
|
||||
(my $old_order, my $old_fields, my $old_offsets, my $order, my $fields, my $offsets) = @_;
|
||||
|
||||
#will not catch order changes very well for now
|
||||
|
||||
my $last_diff = 0;
|
||||
my $first = $old_order->[0];
|
||||
my $taildrop = 0;
|
||||
my $final = "";
|
||||
my $f;
|
||||
foreach $f(@{$old_order}) {
|
||||
if(!defined($offsets->{$f})) {
|
||||
if($taildrop eq "") {
|
||||
$taildrop = $f;
|
||||
}
|
||||
my $guess = $old_offsets->{$f} + $last_diff;
|
||||
# print STDERR "field $f was lost in new profile, it could be at $guess.\n";
|
||||
next;
|
||||
}
|
||||
|
||||
my $diff = $offsets->{$f} - $old_offsets->{$f};
|
||||
|
||||
if($last_diff != $diff) {
|
||||
#a change in deltas... print a rule for last block
|
||||
my $tail = $f;
|
||||
if($taildrop ne "") {
|
||||
$tail = $taildrop;
|
||||
}
|
||||
# print "// delta change from $last_diff to $diff at field $f ($tail)\n";
|
||||
print "\t\tmemcpy(\&pp->$first, \&ops->$first, StructDist(ops, $first, $tail));\n";
|
||||
|
||||
$first = $f;
|
||||
$last_diff = $diff;
|
||||
$taildrop = "";
|
||||
|
||||
} else {
|
||||
#another field with the same delta...
|
||||
$final = $f;
|
||||
$taildrop = "";
|
||||
next;
|
||||
}
|
||||
}
|
||||
#finally do the last rule
|
||||
my $tail = $f;
|
||||
if($taildrop ne "") {
|
||||
$tail = $taildrop;
|
||||
}
|
||||
print "\t\tmemcpy(\&pp->$first, \&ops->$first, StructDist(ops, $first, $tail));\n";
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
sub readpp {
|
||||
(my $sname, my $fname) = @_;
|
||||
open(F, "<$fname") || die("Unable to open $fname\n");
|
||||
my @order = ();
|
||||
my %fields = ();
|
||||
my %offsets = ();
|
||||
my $in = 0;
|
||||
while(<F>) {
|
||||
s/\r?\n//g;
|
||||
if(/struct\s+$sname/) {
|
||||
$in = 1;
|
||||
}
|
||||
next if(!$in);
|
||||
|
||||
if($_ =~ /\}\s*;/) {
|
||||
$in = 0;
|
||||
last;
|
||||
}
|
||||
if($_ !~ /^\/\*[0-9]+\*\/(\s*)([^ \t]+)(\s+)([^ \t;]+);(.*)$/) {
|
||||
print STDERR "Unable to parse line '$_'\n";
|
||||
next;
|
||||
}
|
||||
my $field = $4;
|
||||
my $array = "";
|
||||
my $code = "$1$2$3$4;$5";
|
||||
if($field =~ /([^ \t]+)\[(.+)\]\[(.+)\]/) {
|
||||
$field = $1."[0][0]";
|
||||
} elsif($field =~ /([^ \t]+)\[(.+)\]/) {
|
||||
$field = $1."[0]";
|
||||
$array = $2;
|
||||
}
|
||||
$fields{$field} = $code;
|
||||
push(@order, $field);
|
||||
}
|
||||
close(F);
|
||||
|
||||
open(F, ">$temp.cpp") || die("Unable to open $temp.cpp");
|
||||
print F <<"EOC";
|
||||
#include "../common/types.h"
|
||||
#include "$fname"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
|
||||
int main() {
|
||||
$sname p;
|
||||
unsigned long start = (unsigned long) &p;
|
||||
EOC
|
||||
|
||||
foreach my $field(keys(%fields)) {
|
||||
print F "\tprintf(\"$field,%lu\\n\", ((unsigned long) \&p.$field) - start);\n";
|
||||
}
|
||||
print F "\n\treturn(0);\n}\n\n";
|
||||
close(F);
|
||||
|
||||
if(system("g++ $temp.cpp -I. -o $temp") != 0) {
|
||||
die("Error compiling $temp.cpp\n");
|
||||
}
|
||||
|
||||
system("./$temp >$temp.out");
|
||||
open(F, "<$temp.out");
|
||||
while(<F>) {
|
||||
chomp;
|
||||
if($_ !~ /(.+),([0-9]+)/) {
|
||||
print "Unable to read our own output '$_'\n";
|
||||
next;
|
||||
}
|
||||
if(!defined($fields{$1})) {
|
||||
print "Read invalid field name '$1' from own output.\n";
|
||||
next;
|
||||
}
|
||||
$offsets{$1} = $2;
|
||||
}
|
||||
close(F);
|
||||
|
||||
# unlink("$temp.cpp");
|
||||
# unlink("$temp.out");
|
||||
# unlink("$temp");
|
||||
|
||||
return(\@order, \%fields, \%offsets);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,81 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
#use strict;
|
||||
use DBI;
|
||||
use Getopt::Std;
|
||||
|
||||
getopts('i:d:h');
|
||||
$dbini = "db.ini";
|
||||
if($opt_h) {
|
||||
die "Usage: serialize_items.pl [-i path/to/item_fieldlist.h] [-d path/to/db.ini]\n";
|
||||
}
|
||||
$itemfields = "item_fieldlist.h";
|
||||
if($opt_d) {
|
||||
$dbini = $opt_d;
|
||||
}
|
||||
if($opt_i) {
|
||||
$itemfields = $opt_i;
|
||||
}
|
||||
|
||||
@fieldlist = ();
|
||||
open(F, "<$itemfields") or die "Unable to open field list $itemfields\n";
|
||||
while(<F>) {
|
||||
if(/F\((.+)\)/) {
|
||||
push(@fieldlist, $1);
|
||||
$sr=$#fieldlist if ($1 =~ /^sellrate$/i);
|
||||
$id=$#fieldlist if ($1 =~ /^id$/i);
|
||||
$name=$#fieldlist if ($1 =~ /^name$/i);
|
||||
$lore=$#fieldlist if ($1 =~ /^lore$/i);
|
||||
}
|
||||
}
|
||||
close(F);
|
||||
|
||||
$db = "";
|
||||
$user = "";
|
||||
$pass = "";
|
||||
$host = "";
|
||||
open(F, "<$dbini") or die "Unable to open database config $dbini\n";
|
||||
while(<F>) {
|
||||
s/\r//g;
|
||||
if(/host\s*=\s*(.*)/) {
|
||||
$host = $1;
|
||||
} elsif(/user\s*=\s*(.*)/) {
|
||||
$user = $1;
|
||||
} elsif(/password\s*=\s*(.*)/) {
|
||||
$pass = $1;
|
||||
} elsif(/database\s*=\s*(.*)/) {
|
||||
$db = $1;
|
||||
}
|
||||
}
|
||||
if(!$db || !$user || !$pass || !$host) {
|
||||
die "Invalid db.ini, missing one of: host, user, password, database\n";
|
||||
}
|
||||
|
||||
$source="DBI:mysql:database=$db;host=$host";
|
||||
|
||||
my $dbh = DBI->connect($source, $user, $pass) || die "Could not create db handle\n";
|
||||
|
||||
select(STDOUT); $|=0;
|
||||
|
||||
$sth = $dbh->prepare("select ".join(",",@fieldlist).",serialization from items");
|
||||
$sth->execute();
|
||||
while (my @data = $sth->fetchrow_array) {
|
||||
$data[$sr]=sprintf("%.6f",$data[$sr]);
|
||||
$orig_serialization=$data[$#data];
|
||||
$#data--;
|
||||
|
||||
$data[$name]=~s/\|/\\|/g;
|
||||
$data[$lore]=~s/\|/\\|/g;
|
||||
$serialized=join('|',@data);
|
||||
$serialized=~s/"/\\"/g;
|
||||
|
||||
printf("Processing: %d %s",$data[$id],$data[$name]);
|
||||
if ($serialized ne $orig_serialization) {
|
||||
printf(" (UPDATED)\n");
|
||||
$dbh->do("update items set serialized=now(),serialization=".$dbh->quote($serialized)." where id=".$data[$id]);
|
||||
} else {
|
||||
print " \r";
|
||||
}
|
||||
}
|
||||
|
||||
print "\n";
|
||||
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
|
||||
sed 's#^.*[ \t]\([^ \t]*\);.*$#\tOUT(\1);#g'
|
||||
@@ -0,0 +1,53 @@
|
||||
#copy this file into your server's dir
|
||||
#include this file with: require "throwpackets.pl";
|
||||
# and add:
|
||||
# command_add("throwfile", "[opcode name] [filename] - Send a file's hex contents as a packet", 250);
|
||||
#to your commands_init to enable this
|
||||
|
||||
|
||||
sub throwfile {
|
||||
my $op = shift;
|
||||
my $file = shift;
|
||||
my $p = FileToPacket($op, $file);
|
||||
if(!$p) {
|
||||
$client->Message(13, "Unable to read file or parse contents.");
|
||||
return;
|
||||
}
|
||||
$p->SendTo($client);
|
||||
$client->Message(0, "Sent.");
|
||||
}
|
||||
|
||||
sub HexToPacket {
|
||||
my $op = shift;
|
||||
my $hex = shift;
|
||||
my @lines = split(/\r?\n/, $hex);
|
||||
my $body = "";
|
||||
my @pieces = ();
|
||||
foreach my $l (@lines) {
|
||||
if($l =~ /[0-9a-fA-Fx]+:\s*(.*)\s+\|/) {
|
||||
$l = $1;
|
||||
}
|
||||
$l =~ s/\s+-\s+/ /g;
|
||||
$body .= $l;
|
||||
}
|
||||
foreach my $p (split(/\s+/, $body)) {
|
||||
push(@pieces, "0x$p");
|
||||
}
|
||||
my $p = new PerlPacket($op);
|
||||
$p->FromArray(\@pieces, $#pieces+1);
|
||||
return($p);
|
||||
}
|
||||
|
||||
sub FileToPacket {
|
||||
my $op = shift;
|
||||
my $file = shift;
|
||||
my $c = "";
|
||||
open(F, "<$file") || return(undef);
|
||||
while(<F>) {
|
||||
$c .= $_;
|
||||
}
|
||||
close(F);
|
||||
return(HexToPacket($op, $c));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user