mirror of
https://github.com/EQEmu/Server.git
synced 2026-01-07 14:33:52 +00:00
Added code for conversion of quests for factions (based on Akkas start)
Made sure a temporary table needed for quest conversion was not removed prior.
This commit is contained in:
parent
abf39c4ff7
commit
380e5d5084
@ -787,6 +787,7 @@ sub show_menu_prompt {
|
||||
elsif ($input eq "conversions") {
|
||||
print "\n>>> Conversions Menu\n\n";
|
||||
print " [quest_heading_convert] Converts old heading format in quest scripts to new (live format)\n";
|
||||
print " [quest_faction_convert] Converts to new faction values imported from client\n";
|
||||
print " \n> main - go back to main menu\n";
|
||||
print "Enter a command #> ";
|
||||
$last_menu = trim($input);
|
||||
@ -905,6 +906,10 @@ sub show_menu_prompt {
|
||||
quest_heading_convert();
|
||||
$dc = 1;
|
||||
}
|
||||
elsif ($input eq "quest_faction_convert") {
|
||||
quest_faction_convert();
|
||||
$dc = 1;
|
||||
}
|
||||
elsif ($input eq "source_peq_db") {
|
||||
fetch_peq_db_full();
|
||||
$dc = 1;
|
||||
@ -2493,3 +2498,105 @@ sub quest_heading_convert {
|
||||
|
||||
print "Total matches: " . $total_matches . "\n";
|
||||
}
|
||||
|
||||
|
||||
sub quest_faction_convert {
|
||||
|
||||
if(trim(get_mysql_result("SELECT value FROM variables WHERE varname = 'new_faction_conversion'")) eq "true") {
|
||||
print "Conversion script has already ran... doing this again would skew proper faction values in function calls...\n";
|
||||
exit;
|
||||
}
|
||||
|
||||
%matches = (
|
||||
0 => [ "GetCharacterFactionLevel", 0],
|
||||
1 => [ "GetModCharacterFactionLevel", 0],
|
||||
2 => [ "SetFactionLevel2", 1],
|
||||
3 => [ "GetFactionLevel", 5 ],
|
||||
4 => [ "CheckNPCFactionAlly", 0 ],
|
||||
5 => [ ":Faction", 0 ],
|
||||
);
|
||||
|
||||
$total_matches = 0;
|
||||
|
||||
use Scalar::Util qw(looks_like_number);
|
||||
|
||||
my @files;
|
||||
my $start_dir = "quests/.";
|
||||
find(
|
||||
sub {push @files, $File::Find::name unless -d;},
|
||||
$start_dir
|
||||
);
|
||||
for my $file (@files) {
|
||||
|
||||
#::: Skip non script files
|
||||
if ($file !~ /lua|pl/i) {
|
||||
next;
|
||||
}
|
||||
|
||||
if ($file =~ /lua|pl/i) {
|
||||
$print_buffer = "";
|
||||
$changes_made = 0;
|
||||
|
||||
#::: Open and read line by line
|
||||
open(FILE, $file);
|
||||
while (<FILE>) {
|
||||
chomp;
|
||||
$line = $_;
|
||||
|
||||
#::: Loop through matches
|
||||
foreach my $key (sort (keys %matches)) {
|
||||
$argument_position = $matches{$key}[1];
|
||||
$match = $matches{$key}[0];
|
||||
|
||||
if ($line =~ /$match\(/i || $line =~ /$match \(/i) {
|
||||
$line_temp = $line;
|
||||
$line_temp =~ s/^.*$match\(//gi;
|
||||
$line_temp =~ s/^.*$match \(//gi;
|
||||
$line_temp =~ s/"//g;
|
||||
$line_temp =~ s/\);.*//;
|
||||
|
||||
@line_data = split(",", $line_temp);
|
||||
|
||||
$faction_value = $line_data[$argument_position];
|
||||
$faction_value_clean = trim($faction_value);
|
||||
|
||||
if (looks_like_number($faction_value_clean)) {
|
||||
$new_faction = get_mysql_result("select clientid from client_server_faction_map where serverid = $faction_value_clean");
|
||||
chomp $new_faction;
|
||||
if ($new_faction == 0) {
|
||||
$new_faction = get_mysql_result("select new_faction from custom_faction_mappings where old_faction = $faction_value_clean");
|
||||
chomp $new_faction;
|
||||
}
|
||||
if ($new_faction > 0) {
|
||||
print "BEFORE: " . $line . "\n";
|
||||
$line =~ s/$faction_value_clean/$new_faction/g;
|
||||
print "AFTER: " . $line . "\n";
|
||||
$changes_made = 1;
|
||||
}
|
||||
else {
|
||||
print "Unknown Faction: '$match' FACTION VALUE: '" . $faction_value_clean . "'\n";
|
||||
}
|
||||
}
|
||||
|
||||
$total_matches++;
|
||||
}
|
||||
}
|
||||
|
||||
$print_buffer .= $line . "\n";
|
||||
}
|
||||
close(FILE);
|
||||
|
||||
#::: Write changes
|
||||
if ($changes_made == 1) {
|
||||
open(NEW_FILE, '>', $file);
|
||||
print NEW_FILE $print_buffer;
|
||||
close NEW_FILE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#::: Mark conversion as ran
|
||||
print get_mysql_result("INSERT INTO `variables` (varname, value, information, ts) VALUES ('new_faction_conversion', 'true', 'Script ran against quests folder to convert new faction values', NOW())");
|
||||
|
||||
print "Total matches: " . $total_matches . "\n";
|
||||
}
|
||||
|
||||
@ -156,16 +156,12 @@ set faction_id = m.clientid;
|
||||
|
||||
ALTER TABLE `faction_values` ADD PRIMARY KEY `lookup` (`char_id`,`faction_id`);
|
||||
|
||||
/*
|
||||
Delete temporary tables
|
||||
*/
|
||||
|
||||
DROP TABLE IF EXISTS `custom_faction_mappings`;
|
||||
|
||||
/*
|
||||
* The following to be deleted in a future update, once everyone is
|
||||
* happy with the conversion
|
||||
|
||||
DROP TABLE IF EXISTS custom_faction_mappings;
|
||||
DROP TABLE IF EXISTS faction_list_mod_prefix;
|
||||
DROP TABLE IF EXISTS faction_list_prefix;
|
||||
DROP TABLE IF EXISTS npc_faction_prefix;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user