From 69d02b7e7209e3b346e556c4d69112ba9dc69231 Mon Sep 17 00:00:00 2001 From: KayenEQ Date: Mon, 9 Mar 2015 06:40:13 -0400 Subject: [PATCH 01/21] perl $npc->GetCombatState --- zone/npc.cpp | 4 +--- zone/perl_npc.cpp | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/zone/npc.cpp b/zone/npc.cpp index a9a383d55..22fb5f188 100644 --- a/zone/npc.cpp +++ b/zone/npc.cpp @@ -1839,7 +1839,7 @@ void NPC::PetOnSpawn(NewSpawn_Struct* ns) if(swarmOwner->IsClient()) { SetPetOwnerClient(true); //Simple flag to determine if pet belongs to a client - SetAllowBeneficial(1);//Allow temp pets to receive buffs and heals if owner is client. + SetAllowBeneficial(true);//Allow temp pets to receive buffs and heals if owner is client. //This will allow CLIENT swarm pets NOT to be targeted with F8. ns->spawn.targetable_with_hotkey = 0; no_target_hotkey = 1; @@ -2258,8 +2258,6 @@ bool NPC::CanTalk() 0,0,420,0,0,0,0,425,0,0,0,0,0,0,0,433,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,458,0,0,0,0,0,0,0,0,467,0,0,470,0,0,473}; - int talk_check = TalkRace[GetRace() - 1]; - if (TalkRace[GetRace() - 1] > 0) return true; diff --git a/zone/perl_npc.cpp b/zone/perl_npc.cpp index febee6941..0c9cec797 100644 --- a/zone/perl_npc.cpp +++ b/zone/perl_npc.cpp @@ -2530,6 +2530,32 @@ XS(XS_NPC_ClearLastName) XSRETURN_EMPTY; } +XS(XS_NPC_GetCombatState); /* prototype to pass -Wmissing-prototypes */ +XS(XS_NPC_GetCombatState) +{ + dXSARGS; + if (items != 1) + Perl_croak(aTHX_ "Usage: NPC::GetCombatState(THIS)"); + { + NPC * THIS; + bool RETVAL; + + if (sv_derived_from(ST(0), "NPC")) { + IV tmp = SvIV((SV*)SvRV(ST(0))); + THIS = INT2PTR(NPC *,tmp); + } + else + Perl_croak(aTHX_ "THIS is not of type NPC"); + if(THIS == nullptr) + Perl_croak(aTHX_ "THIS is nullptr, avoiding crash."); + + RETVAL = THIS->GetCombatEvent(); + ST(0) = boolSV(RETVAL); + sv_2mortal(ST(0)); + } + XSRETURN(1); +} + #ifdef __cplusplus extern "C" #endif @@ -2643,6 +2669,7 @@ XS(boot_NPC) newXSproto(strcpy(buf, "RemoveDefensiveProc"), XS_NPC_RemoveDefensiveProc, file, "$$"); newXSproto(strcpy(buf, "ChangeLastName"), XS_NPC_ChangeLastName, file, "$:$"); newXSproto(strcpy(buf, "ClearLastName"), XS_NPC_ClearLastName, file, "$"); + newXSproto(strcpy(buf, "GetCombatState"), XS_NPC_GetCombatState, file, "$"); XSRETURN_YES; } From 2cf2ef4fac63652ee606cd31f1243a35c43cc155 Mon Sep 17 00:00:00 2001 From: KayenEQ Date: Tue, 10 Mar 2015 00:33:11 -0400 Subject: [PATCH 02/21] Fix to check if weapon actually has a valid proc before trying to proc it. --- zone/attack.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/zone/attack.cpp b/zone/attack.cpp index 2946c0ef7..950663a38 100644 --- a/zone/attack.cpp +++ b/zone/attack.cpp @@ -3650,6 +3650,7 @@ void Mob::CommonDamage(Mob* attacker, int32 &damage, const uint16 spell_id, cons (frontal_stun_resist && zone->random.Roll(frontal_stun_resist))) && !attacker->BehindMob(this, attacker->GetX(), attacker->GetY())) { Log.Out(Logs::Detail, Logs::Combat, "Frontal stun resisted. %d chance.", frontal_stun_resist); + } else { // Normal stun resist check. if (stun_resist && zone->random.Roll(stun_resist)) { @@ -3994,7 +3995,7 @@ void Mob::TryWeaponProc(const ItemInst *inst, const Item_Struct *weapon, Mob *on // We can proc once here, either weapon or one aug bool proced = false; // silly bool to prevent augs from going if weapon does skillinuse = GetSkillByItemType(weapon->ItemType); - if (weapon->Proc.Type == ET_CombatProc) { + if (weapon->Proc.Type == ET_CombatProc && IsValidSpell(weapon->Proc.Effect)) { float WPC = ProcChance * (100.0f + // Proc chance for this weapon static_cast(weapon->ProcRate)) / 100.0f; if (zone->random.Roll(WPC)) { // 255 dex = 0.084 chance of proc. No idea what this number should be really. @@ -4032,7 +4033,7 @@ void Mob::TryWeaponProc(const ItemInst *inst, const Item_Struct *weapon, Mob *on if (!aug) continue; - if (aug->Proc.Type == ET_CombatProc) { + if (aug->Proc.Type == ET_CombatProc && IsValidSpell(aug->Proc.Effect)) { float APC = ProcChance * (100.0f + // Proc chance for this aug static_cast(aug->ProcRate)) / 100.0f; if (zone->random.Roll(APC)) { From be9066235b1b06e26c63b15030df74104d177bcb Mon Sep 17 00:00:00 2001 From: Akkadius Date: Tue, 10 Mar 2015 22:37:17 -0500 Subject: [PATCH 03/21] [eqemu_update.pl] Add Option 6) Download Latest map and water files --- changelog.txt | 3 +++ utils/scripts/eqemu_update.pl | 26 ++++++++++++++++++++++++-- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/changelog.txt b/changelog.txt index 09cd52d88..f3a7c7f9e 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,8 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- +== 03/10/2015 == +Akkadius: [eqemu_update.pl] Add Option 6) Download Latest map and water files + == 03/04/2015 == Akkadius: Fix Spell Book Deletion diff --git a/utils/scripts/eqemu_update.pl b/utils/scripts/eqemu_update.pl index 04c5367b3..921fdf3e4 100644 --- a/utils/scripts/eqemu_update.pl +++ b/utils/scripts/eqemu_update.pl @@ -14,7 +14,7 @@ if($Config{osname}=~/linux/i){ $OS = "Linux"; } if($Config{osname}=~/Win|MS/i){ $OS = "Windows"; } #::: If current version is less than what world is reporting, then download a new one... -$current_version = 2; +$current_version = 3; if($ARGV[0] eq "V"){ if($ARGV[1] > $current_version){ @@ -160,6 +160,7 @@ sub ShowMenuPrompt { 3 => \&Run_Database_Check, 4 => \&AA_Fetch, 5 => \&OpCodes_Fetch, + 6 => \&MapFiles_Fetch, 0 => \&Exit, ); @@ -215,6 +216,7 @@ Database Management Menu (Please Select): 3) $option[3] 4) AAs - Get Latest AA's from PEQ (This deletes AA's already in the database) 5) OPCodes - Download latest opcodes from repository + 6) Maps - Download latest map and water files 0) Exit EO_MENU @@ -325,7 +327,7 @@ sub OpCodes_Fetch{ 3 => ["Titanium", "https://raw.githubusercontent.com/EQEmu/Server/master/utils/patches/patch_Titanium.conf"], 4 => ["Secrets of Faydwer", "https://raw.githubusercontent.com/EQEmu/Server/master/utils/patches/patch_SoF.conf"], 5 => ["Seeds of Destruction", "https://raw.githubusercontent.com/EQEmu/Server/master/utils/patches/patch_SoD.conf"], - 6 => ["Underfoot", "https://raw.githubusercontent.com/EQEmu/Server/master/utils/patches/patch_UF.conf"], + 6 => ["Underfoot", "https://raw.githubusercontent.com/EQEmu/Server/master/utils/patches/patch_Underfoot.conf"], 7 => ["Rain of Fear", "https://raw.githubusercontent.com/EQEmu/Server/master/utils/patches/patch_RoF.conf"], 8 => ["Rain of Fear 2", "https://raw.githubusercontent.com/EQEmu/Server/master/utils/patches/patch_RoF2.conf"], ); @@ -346,6 +348,26 @@ sub OpCodes_Fetch{ print "\nDone...\n\n"; } +sub MapFiles_Fetch{ + print "\n --- Fetching Latest Maps --- \n"; + GetRemoteFile("https://raw.githubusercontent.com/Akkadius/EQEmuMaps/master/!eqemu_maps_manifest.txt", "db_update/eqemu_maps_manifest.txt"); + #::: Get Data from manifest + open (FILE, "db_update/eqemu_maps_manifest.txt"); + $i = 0; + while () { + chomp; + $o = $_; + $maps_manifest[$i] = $o; + $i++; + } + #::: Download + for($m = 0; $m <= $i; $m++){ + GetRemoteFile("https://raw.githubusercontent.com/Akkadius/EQEmuMaps/master/" . $maps_manifest[$m], "maps/" . $maps_manifest[$m]); + } + + print "\n --- Done Fetching Latest Maps --- \n"; +} + #::: Responsible for Database Upgrade Routines sub Run_Database_Check{ #::: Run 2 - Running pending updates... From c313bd8d077705d91f110c8b9e5f5cebb97b5def Mon Sep 17 00:00:00 2001 From: Akkadius Date: Tue, 10 Mar 2015 22:40:20 -0500 Subject: [PATCH 04/21] Re-rename UF.conf again [skip ci] --- utils/scripts/eqemu_update.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/scripts/eqemu_update.pl b/utils/scripts/eqemu_update.pl index 921fdf3e4..20a5313a6 100644 --- a/utils/scripts/eqemu_update.pl +++ b/utils/scripts/eqemu_update.pl @@ -327,7 +327,7 @@ sub OpCodes_Fetch{ 3 => ["Titanium", "https://raw.githubusercontent.com/EQEmu/Server/master/utils/patches/patch_Titanium.conf"], 4 => ["Secrets of Faydwer", "https://raw.githubusercontent.com/EQEmu/Server/master/utils/patches/patch_SoF.conf"], 5 => ["Seeds of Destruction", "https://raw.githubusercontent.com/EQEmu/Server/master/utils/patches/patch_SoD.conf"], - 6 => ["Underfoot", "https://raw.githubusercontent.com/EQEmu/Server/master/utils/patches/patch_Underfoot.conf"], + 6 => ["Underfoot", "https://raw.githubusercontent.com/EQEmu/Server/master/utils/patches/patch_UF.conf"], 7 => ["Rain of Fear", "https://raw.githubusercontent.com/EQEmu/Server/master/utils/patches/patch_RoF.conf"], 8 => ["Rain of Fear 2", "https://raw.githubusercontent.com/EQEmu/Server/master/utils/patches/patch_RoF2.conf"], ); From b36d9fe1155f2d550dbd25c5cd56fbdee5a25d49 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Tue, 10 Mar 2015 22:44:30 -0500 Subject: [PATCH 05/21] Update world binary with eqemu_update.pl script version [skip ci] --- common/database_conversions.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/database_conversions.cpp b/common/database_conversions.cpp index f6c43687f..443763961 100644 --- a/common/database_conversions.cpp +++ b/common/database_conversions.cpp @@ -494,7 +494,7 @@ bool Database::CheckDatabaseConversions() { /* Check for a new version of this script, the arg passed would have to be higher than the copy they have downloaded locally and they will re fetch */ - system("perl eqemu_update.pl V 2"); + system("perl eqemu_update.pl V 3"); /* Run Automatic Database Upgrade Script */ system("perl eqemu_update.pl ran_from_world"); From 6a241d44ccf13854ed48c87d9081b83d8a8e8dd4 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Tue, 10 Mar 2015 22:59:07 -0500 Subject: [PATCH 06/21] Fix small issue where eqemu_update.pl script would bomb at the very end of the maps download because of blank string [skip ci] --- utils/scripts/eqemu_update.pl | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/utils/scripts/eqemu_update.pl b/utils/scripts/eqemu_update.pl index 20a5313a6..2c41306fb 100644 --- a/utils/scripts/eqemu_update.pl +++ b/utils/scripts/eqemu_update.pl @@ -14,7 +14,7 @@ if($Config{osname}=~/linux/i){ $OS = "Linux"; } if($Config{osname}=~/Win|MS/i){ $OS = "Windows"; } #::: If current version is less than what world is reporting, then download a new one... -$current_version = 3; +$current_version = 2; if($ARGV[0] eq "V"){ if($ARGV[1] > $current_version){ @@ -362,7 +362,10 @@ sub MapFiles_Fetch{ } #::: Download for($m = 0; $m <= $i; $m++){ - GetRemoteFile("https://raw.githubusercontent.com/Akkadius/EQEmuMaps/master/" . $maps_manifest[$m], "maps/" . $maps_manifest[$m]); + print "'" . $maps_manifest[$m] . "'\n"; + if($maps_manifest[$m] ne ""){ + GetRemoteFile("https://raw.githubusercontent.com/Akkadius/EQEmuMaps/master/" . $maps_manifest[$m], "maps/" . $maps_manifest[$m]); + } } print "\n --- Done Fetching Latest Maps --- \n"; From bcf8b1af8e8a49fd88a4152ac1a352c8e6fc362a Mon Sep 17 00:00:00 2001 From: Akkadius Date: Wed, 11 Mar 2015 21:01:43 -0500 Subject: [PATCH 07/21] [eqemu_update.pl] Add Option 7) Plugins - Download latest Perl plugins [eqemu_update.pl] Add Option 8) Quests - Download latest PEQ quests and stage updates [eqemu_update.pl] Set version 5 of script [skip ci] --- changelog.txt | 5 + common/database_conversions.cpp | 2 +- utils/scripts/eqemu_update.pl | 302 +++++++++++++++++++++++++++----- 3 files changed, 268 insertions(+), 41 deletions(-) diff --git a/changelog.txt b/changelog.txt index f3a7c7f9e..ad6b6f5d5 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,10 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- +== 03/11/2015 == +Akkadius: [eqemu_update.pl] Add Option 7) Plugins - Download latest Perl plugins +Akkadius: [eqemu_update.pl] Add Option 8) Quests - Download latest PEQ quests and stage updates +Akkadius: [eqemu_update.pl] Set version 5 of script + == 03/10/2015 == Akkadius: [eqemu_update.pl] Add Option 6) Download Latest map and water files diff --git a/common/database_conversions.cpp b/common/database_conversions.cpp index 443763961..bda4e7f9b 100644 --- a/common/database_conversions.cpp +++ b/common/database_conversions.cpp @@ -494,7 +494,7 @@ bool Database::CheckDatabaseConversions() { /* Check for a new version of this script, the arg passed would have to be higher than the copy they have downloaded locally and they will re fetch */ - system("perl eqemu_update.pl V 3"); + system("perl eqemu_update.pl V 5"); /* Run Automatic Database Upgrade Script */ system("perl eqemu_update.pl ran_from_world"); diff --git a/utils/scripts/eqemu_update.pl b/utils/scripts/eqemu_update.pl index 2c41306fb..73e1423eb 100644 --- a/utils/scripts/eqemu_update.pl +++ b/utils/scripts/eqemu_update.pl @@ -9,12 +9,22 @@ $menu_displayed = 0; use Config; +use File::Copy qw(copy); +use POSIX qw(strftime); +use File::Path; +use File::Find; +use URI::Escape; + +use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); + +$time_stamp = strftime('%m-%d-%Y', gmtime()); + $console_output .= " Operating System is: $Config{osname}\n"; if($Config{osname}=~/linux/i){ $OS = "Linux"; } if($Config{osname}=~/Win|MS/i){ $OS = "Windows"; } #::: If current version is less than what world is reporting, then download a new one... -$current_version = 2; +$current_version = 5; if($ARGV[0] eq "V"){ if($ARGV[1] > $current_version){ @@ -36,6 +46,8 @@ print "Perl Version is " . $perl_version . "\n"; if($perl_version > 5.12){ no warnings 'uninitialized'; } no warnings; +($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(); + my $confile = "eqemu_config.xml"; #default open(F, "<$confile") or die "Unable to open config: $confile\n"; my $indb = 0; @@ -161,6 +173,8 @@ sub ShowMenuPrompt { 4 => \&AA_Fetch, 5 => \&OpCodes_Fetch, 6 => \&MapFiles_Fetch, + 7 => \&Plugins_Fetch, + 8 => \&QuestFiles_Fetch, 0 => \&Exit, ); @@ -203,20 +217,19 @@ sub MenuOptions { $option[3] = "Run pending REQUIRED updates... (" . scalar (@total_updates) . ")"; } else{ - $option[3] = "Check for pending REQUIRED Database updates - Stages updates for automatic upgrade..."; + $option[3] = "Check and stage pending REQUIRED Database updates"; } return <new; - $ua->timeout(10); - $ua->env_proxy; - my $response = $ua->get($URL); - - if ($response->is_success){ - open (FILE, '> ' . $Dest_File . ''); - print FILE $response->decoded_content; - close (FILE); - print " URL: " . $URL . "\n"; - print " Saved: " . $Dest_File . " \n"; + #::: For non-text type requests... + if($content_type == 1){ + use LWP::Simple qw(getstore); + if(!getstore($URL, $Dest_File)){ + print "Error, no connection or failed request...\n\n"; + } + else{ + print " o URL: (" . $URL . ")\n"; + print " o Saved: (" . $Dest_File . ") \n"; + } } - else { - print "Error, no connection to the internet...\n\n"; - die $response->status_line; + else{ + require LWP::UserAgent; + my $ua = LWP::UserAgent->new; + $ua->timeout(10); + $ua->env_proxy; + my $response = $ua->get($URL); + + if ($response->is_success){ + open (FILE, '> ' . $Dest_File . ''); + print FILE $response->decoded_content; + close (FILE); + print " o URL: (" . $URL . ")\n"; + print " o Saved: (" . $Dest_File . ") \n"; + } + else { + print "Error, no connection or failed request...\n\n"; + } } } if($OS eq "Linux"){ #::: wget -O db_update/db_update_manifest.txt https://raw.githubusercontent.com/EQEmu/Server/master/utils/sql/db_update_manifest.txt $wget = `wget --no-check-certificate --quiet -O $Dest_File $URL`; - print " URL: " . $URL . "\n"; - print " Saved: " . $Dest_File . " \n"; + print " o URL: (" . $URL . ")\n"; + print " o Saved: (" . $Dest_File . ") \n"; if($wget=~/unable to resolve/i){ - print "Error, no connection to the internet...\n\n"; - die; + print "Error, no connection or failed request...\n\n"; + #die; } } } @@ -343,32 +389,208 @@ sub OpCodes_Fetch{ print "\nDownloading (" . $opcodes{$loop}[0] . ") File: '" . $file_name . "'...\n\n"; GetRemoteFile($opcodes{$loop}[1], $file_name); - $loop++; + $loop++; } print "\nDone...\n\n"; } +sub CopyFile{ + $l_source_file = $_[0]; + $l_dest_file = $_[1]; + if($l_dest_file=~/\//i){ + my @dir_path = split('/', $l_dest_file); + $build_path = ""; + $di = 0; + while($dir_path[$di]){ + $build_path .= $dir_path[$di] . "/"; + #::: If path does not exist, create the directory... + if (!-d $build_path) { + mkdir($build_path); + } + if(!$dir_path[$di + 2] && $dir_path[$di + 1]){ + # print $actual_path . "\n"; + $actual_path = $build_path; + last; + } + $di++; + } + } + copy $l_source_file, $l_dest_file; +} + sub MapFiles_Fetch{ print "\n --- Fetching Latest Maps --- \n"; - GetRemoteFile("https://raw.githubusercontent.com/Akkadius/EQEmuMaps/master/!eqemu_maps_manifest.txt", "db_update/eqemu_maps_manifest.txt"); + + GetRemoteFile("https://raw.githubusercontent.com/Akkadius/EQEmuMaps/master/!eqemu_maps_manifest.txt", "updates_staged/eqemu_maps_manifest.txt"); + #::: Get Data from manifest - open (FILE, "db_update/eqemu_maps_manifest.txt"); + open (FILE, "updates_staged/eqemu_maps_manifest.txt"); $i = 0; - while () { + while (){ chomp; $o = $_; - $maps_manifest[$i] = $o; - $i++; - } - #::: Download - for($m = 0; $m <= $i; $m++){ - print "'" . $maps_manifest[$m] . "'\n"; - if($maps_manifest[$m] ne ""){ - GetRemoteFile("https://raw.githubusercontent.com/Akkadius/EQEmuMaps/master/" . $maps_manifest[$m], "maps/" . $maps_manifest[$m]); + @manifest_map_data = split(',', $o); + if($manifest_map_data[0] ne ""){ + $maps_manifest[$i] = [$manifest_map_data[0], $manifest_map_data[1]]; + $i++; } } - print "\n --- Done Fetching Latest Maps --- \n"; + #::: Download + $fc = 0; + for($m = 0; $m <= $i; $m++){ + my $file_existing = $maps_manifest[$m][0]; + my $file_existing_size = (stat $file_existing)[7]; + if($file_existing_size != $maps_manifest[$m][1]){ + print "Updating: '" . $maps_manifest[$m][0] . "'\n"; + GetRemoteFile("https://raw.githubusercontent.com/Akkadius/EQEmuMaps/master/" . $maps_manifest[$m][0], $maps_manifest[$m][0], 1); + $fc++; + } + } + + if($fc == 0){ + print "\nNo Map Updates found... \n\n"; + } +} + +sub QuestFiles_Fetch{ + print "\n --- Fetching Latest Quests --- \n"; + + GetRemoteFile("https://github.com/EQEmu/Quests-Plugins/archive/master.zip", "updates_staged/Quests-Plugins-master.zip", 1); + + print "\nFetched latest quests...\n"; + my $zip = Archive::Zip->new(); + unless ( $zip->read( 'updates_staged\Quests-Plugins-master.zip' ) == AZ_OK ) { + die 'read error'; + } + print "Extracting...\n"; + $zip->extractTree('', 'updates_staged/'); + + $fc = 0; + use File::Find; + use File::Compare; + use Text::Diff; + my @files; + my $start_dir = "updates_staged/Quests-Plugins-master/quests/"; + find( + sub { push @files, $File::Find::name unless -d; }, + $start_dir + ); + for my $file (@files) { + if($file=~/\.pl|\.lua|\.ext/i){ + $staged_file = $file; + $dest_file = $file; + $dest_file =~s/updates_staged\/Quests-Plugins-master\///g; + + if (!-e $dest_file) { + CopyFile($staged_file, $dest_file); + print "Installing :: '" . $dest_file . "'\n"; + } + else{ + $diff = diff($dest_file, $staged_file, { STYLE => "Unified" }); + if($diff ne ""){ + $backup_dest = "updates_backups/" . $time_stamp . "/" . $dest_file; + + print $diff . "\n"; + print "\nFile Different :: '" . $dest_file . "'\n"; + print "\nDo you wish to update this Quest? '" . $dest_file . "' [Yes (Enter) - No (N)] - A backup will be found in '" . $backup_dest . "'\n"; + my $input = ; + if($input=~/N/i){} + else{ + #::: Make a backup + CopyFile($dest_file, $backup_dest); + #::: Copy staged to running + copy($staged_file, $dest_file); + print "Installing :: '" . $dest_file . "'\n\n"; + } + $fc++; + } + } + } + } + + #::: Cleanup staged folder... + rmtree("updates_staged/"); + + if($fc == 0){ + print "\nNo Quest Updates found... \n\n"; + } +} + +sub Plugins_Fetch{ + print "\n --- Fetching Latest Plugins --- \n"; + + GetRemoteFile("https://github.com/EQEmu/Quests-Plugins/archive/master.zip", "updates_staged/Quests-Plugins-master.zip", 1); + + print "\nFetched latest plugins...\n"; + my $zip = Archive::Zip->new(); + unless ( $zip->read( 'updates_staged\Quests-Plugins-master.zip' ) == AZ_OK ) { + die 'read error'; + } + print "Extracting...\n"; + $zip->extractTree('', 'updates_staged/'); + + $fc = 0; + use File::Find; + use File::Compare; + use Text::Diff; + my @files; + my $start_dir = "updates_staged/Quests-Plugins-master/plugins/"; + find( + sub { push @files, $File::Find::name unless -d; }, + $start_dir + ); + for my $file (@files) { + if($file=~/\.pl|\.lua|\.ext/i){ + $staged_file = $file; + $dest_file = $file; + $dest_file =~s/updates_staged\/Quests-Plugins-master\///g; + + if (!-e $dest_file) { + CopyFile($staged_file, $dest_file); + print "Installing :: '" . $dest_file . "'\n"; + } + else{ + $diff = diff($dest_file, $staged_file, { STYLE => "Unified" }); + if($diff ne ""){ + $backup_dest = "updates_backups/" . $time_stamp . "/" . $dest_file; + + print $diff . "\n"; + print "\nFile Different :: '" . $dest_file . "'\n"; + print "\nDo you wish to update this Plugin? '" . $dest_file . "' [Yes (Enter) - No (N)] - A backup will be found in '" . $backup_dest . "'\n"; + my $input = ; + if($input=~/N/i){} + else{ + #::: Make a backup + CopyFile($dest_file, $backup_dest); + #::: Copy staged to running + copy($staged_file, $dest_file); + print "Installing :: '" . $dest_file . "'\n\n"; + } + $fc++; + } + } + } + } + + #::: Cleanup staged folder... + rmtree("updates_staged/"); + + if($fc == 0){ + print "\nNo Plugin Updates found... \n\n"; + } +} + +sub AreFileSizesDifferent{ + $file_1 = $_[0]; + $file_2 = $_[1]; + my $file_1 = (stat $file_1)[7]; + my $file_2 = (stat $file_2)[7]; + # print $file_1 . " :: " . $file_2 . "\n"; + if($file_1 != $file_2){ + return 1; + } + return; } #::: Responsible for Database Upgrade Routines From 9344cfb4e321adeca8d3461b9707ba23b9071989 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Wed, 11 Mar 2015 21:06:58 -0500 Subject: [PATCH 08/21] [eqemu_update.pl] Add Option 20) to self update script [skip ci] --- utils/scripts/eqemu_update.pl | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/utils/scripts/eqemu_update.pl b/utils/scripts/eqemu_update.pl index 73e1423eb..e09a5598c 100644 --- a/utils/scripts/eqemu_update.pl +++ b/utils/scripts/eqemu_update.pl @@ -164,6 +164,10 @@ else{ ShowMenuPrompt(); } +sub UpdateSelf{ + GetRemoteFile("https://raw.githubusercontent.com/EQEmu/Server/master/utils/scripts/eqemu_update.pl", "eqemu_update.pl"); + die "Rerun eqemu_update.pl"; +} sub ShowMenuPrompt { my %dispatch = ( @@ -175,6 +179,7 @@ sub ShowMenuPrompt { 6 => \&MapFiles_Fetch, 7 => \&Plugins_Fetch, 8 => \&QuestFiles_Fetch, + 20 => \&UpdateSelf, 0 => \&Exit, ); @@ -230,6 +235,7 @@ Database Management Menu (Please Select): 6) Maps - Download latest map and water files 7) Plugins - Download latest Perl plugins 8) Quests - Download latest PEQ quests and stage updates + 20) Force update this script (Redownload) 0) Exit EO_MENU From b3a0370e71443500f55e87a073b2a60b37d70cb8 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Thu, 12 Mar 2015 00:08:10 -0500 Subject: [PATCH 09/21] [eqemu_update.pl] Linux compatibility adjustments [skip ci] --- common/database_conversions.cpp | 2 +- utils/scripts/eqemu_update.pl | 61 ++++++++++++++++++++++----------- 2 files changed, 42 insertions(+), 21 deletions(-) diff --git a/common/database_conversions.cpp b/common/database_conversions.cpp index bda4e7f9b..7213e3a50 100644 --- a/common/database_conversions.cpp +++ b/common/database_conversions.cpp @@ -494,7 +494,7 @@ bool Database::CheckDatabaseConversions() { /* Check for a new version of this script, the arg passed would have to be higher than the copy they have downloaded locally and they will re fetch */ - system("perl eqemu_update.pl V 5"); + system("perl eqemu_update.pl V 6"); /* Run Automatic Database Upgrade Script */ system("perl eqemu_update.pl ran_from_world"); diff --git a/utils/scripts/eqemu_update.pl b/utils/scripts/eqemu_update.pl index e09a5598c..d5dddd407 100644 --- a/utils/scripts/eqemu_update.pl +++ b/utils/scripts/eqemu_update.pl @@ -15,8 +15,6 @@ use File::Path; use File::Find; use URI::Escape; -use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); - $time_stamp = strftime('%m-%d-%Y', gmtime()); $console_output .= " Operating System is: $Config{osname}\n"; @@ -24,7 +22,7 @@ if($Config{osname}=~/linux/i){ $OS = "Linux"; } if($Config{osname}=~/Win|MS/i){ $OS = "Windows"; } #::: If current version is less than what world is reporting, then download a new one... -$current_version = 5; +$current_version = 6; if($ARGV[0] eq "V"){ if($ARGV[1] > $current_version){ @@ -465,17 +463,13 @@ sub QuestFiles_Fetch{ GetRemoteFile("https://github.com/EQEmu/Quests-Plugins/archive/master.zip", "updates_staged/Quests-Plugins-master.zip", 1); print "\nFetched latest quests...\n"; - my $zip = Archive::Zip->new(); - unless ( $zip->read( 'updates_staged\Quests-Plugins-master.zip' ) == AZ_OK ) { - die 'read error'; - } - print "Extracting...\n"; - $zip->extractTree('', 'updates_staged/'); + mkdir('updates_staged'); + UnZip('updates_staged/Quests-Plugins-master.zip', 'updates_staged/'); $fc = 0; use File::Find; use File::Compare; - use Text::Diff; + my @files; my $start_dir = "updates_staged/Quests-Plugins-master/quests/"; find( @@ -493,7 +487,7 @@ sub QuestFiles_Fetch{ print "Installing :: '" . $dest_file . "'\n"; } else{ - $diff = diff($dest_file, $staged_file, { STYLE => "Unified" }); + $diff = Diff($dest_file, $staged_file); if($diff ne ""){ $backup_dest = "updates_backups/" . $time_stamp . "/" . $dest_file; @@ -529,17 +523,13 @@ sub Plugins_Fetch{ GetRemoteFile("https://github.com/EQEmu/Quests-Plugins/archive/master.zip", "updates_staged/Quests-Plugins-master.zip", 1); print "\nFetched latest plugins...\n"; - my $zip = Archive::Zip->new(); - unless ( $zip->read( 'updates_staged\Quests-Plugins-master.zip' ) == AZ_OK ) { - die 'read error'; - } - print "Extracting...\n"; - $zip->extractTree('', 'updates_staged/'); + + UnZip('updates_staged/Quests-Plugins-master.zip', 'updates_staged/'); $fc = 0; use File::Find; use File::Compare; - use Text::Diff; + my @files; my $start_dir = "updates_staged/Quests-Plugins-master/plugins/"; find( @@ -557,10 +547,9 @@ sub Plugins_Fetch{ print "Installing :: '" . $dest_file . "'\n"; } else{ - $diff = diff($dest_file, $staged_file, { STYLE => "Unified" }); + $diff = Diff($dest_file, $staged_file); if($diff ne ""){ $backup_dest = "updates_backups/" . $time_stamp . "/" . $dest_file; - print $diff . "\n"; print "\nFile Different :: '" . $dest_file . "'\n"; print "\nDo you wish to update this Plugin? '" . $dest_file . "' [Yes (Enter) - No (N)] - A backup will be found in '" . $backup_dest . "'\n"; @@ -587,6 +576,38 @@ sub Plugins_Fetch{ } } +sub Diff{ + $file_1 = $_[0]; + $file_2 = $_[1]; + if($OS eq "Windows"){ + eval "use Text::Diff"; + $diff = diff($file_1, $file_2, { STYLE => "Unified" }); + return $diff; + } + if($OS eq "Linux"){ + # print 'diff -u "$file_1" "$file_2"' . "\n"; + return `diff -u "$file_1" "$file_2"`; + } +} + +sub UnZip{ + $archive_to_unzip = $_[0]; + $dest_folder = $_[1]; + + if($OS eq "Windows"){ + eval "use Archive::Zip qw( :ERROR_CODES :CONSTANTS )"; + my $zip = Archive::Zip->new(); + unless ( $zip->read($archive_to_unzip) == AZ_OK ) { + die 'read error'; + } + print "Extracting...\n"; + $zip->extractTree('', $dest_folder); + } + if($OS eq "Linux"){ + print `unzip -o "$archive_to_unzip" -d "$dest_folder"`; + } +} + sub AreFileSizesDifferent{ $file_1 = $_[0]; $file_2 = $_[1]; From 2bcb96432660332bb48d8277344eefa935a2013c Mon Sep 17 00:00:00 2001 From: Akkadius Date: Thu, 12 Mar 2015 00:33:52 -0500 Subject: [PATCH 10/21] [eqemu_update.pl V7] Add Option 9) LUA Modules - Download latest LUA Modules (Required for Lua) [skip ci] --- changelog.txt | 3 ++ common/database_conversions.cpp | 2 +- utils/scripts/eqemu_update.pl | 66 ++++++++++++++++++++++++++++++++- 3 files changed, 69 insertions(+), 2 deletions(-) diff --git a/changelog.txt b/changelog.txt index ad6b6f5d5..30cdf9ba7 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,8 @@ EQEMu Changelog (Started on Sept 24, 2003 15:50) ------------------------------------------------------- +== 03/12/2015 == +Akkadius: [eqemu_update.pl V7] Add Option 9) LUA Modules - Download latest LUA Modules (Required for Lua) + == 03/11/2015 == Akkadius: [eqemu_update.pl] Add Option 7) Plugins - Download latest Perl plugins Akkadius: [eqemu_update.pl] Add Option 8) Quests - Download latest PEQ quests and stage updates diff --git a/common/database_conversions.cpp b/common/database_conversions.cpp index 7213e3a50..a96f51967 100644 --- a/common/database_conversions.cpp +++ b/common/database_conversions.cpp @@ -494,7 +494,7 @@ bool Database::CheckDatabaseConversions() { /* Check for a new version of this script, the arg passed would have to be higher than the copy they have downloaded locally and they will re fetch */ - system("perl eqemu_update.pl V 6"); + system("perl eqemu_update.pl V 7"); /* Run Automatic Database Upgrade Script */ system("perl eqemu_update.pl ran_from_world"); diff --git a/utils/scripts/eqemu_update.pl b/utils/scripts/eqemu_update.pl index d5dddd407..f1ec5b688 100644 --- a/utils/scripts/eqemu_update.pl +++ b/utils/scripts/eqemu_update.pl @@ -22,7 +22,7 @@ if($Config{osname}=~/linux/i){ $OS = "Linux"; } if($Config{osname}=~/Win|MS/i){ $OS = "Windows"; } #::: If current version is less than what world is reporting, then download a new one... -$current_version = 6; +$current_version = 7; if($ARGV[0] eq "V"){ if($ARGV[1] > $current_version){ @@ -177,6 +177,7 @@ sub ShowMenuPrompt { 6 => \&MapFiles_Fetch, 7 => \&Plugins_Fetch, 8 => \&QuestFiles_Fetch, + 9 => \&LUA_Modules_Fetch, 20 => \&UpdateSelf, 0 => \&Exit, ); @@ -233,6 +234,7 @@ Database Management Menu (Please Select): 6) Maps - Download latest map and water files 7) Plugins - Download latest Perl plugins 8) Quests - Download latest PEQ quests and stage updates + 9) LUA Modules - Download latest LUA Modules (Required for Lua) 20) Force update this script (Redownload) 0) Exit @@ -485,6 +487,7 @@ sub QuestFiles_Fetch{ if (!-e $dest_file) { CopyFile($staged_file, $dest_file); print "Installing :: '" . $dest_file . "'\n"; + $fc++; } else{ $diff = Diff($dest_file, $staged_file); @@ -517,6 +520,66 @@ sub QuestFiles_Fetch{ } } +sub LUA_Modules_Fetch{ + print "\n --- Fetching Latest LUA Modules --- \n"; + + GetRemoteFile("https://github.com/EQEmu/Quests-Plugins/archive/master.zip", "updates_staged/Quests-Plugins-master.zip", 1); + + print "\nFetched latest LUA Modules...\n"; + + UnZip('updates_staged/Quests-Plugins-master.zip', 'updates_staged/'); + + $fc = 0; + use File::Find; + use File::Compare; + + my @files; + my $start_dir = "updates_staged/Quests-Plugins-master/quests/lua_modules/"; + find( + sub { push @files, $File::Find::name unless -d; }, + $start_dir + ); + for my $file (@files) { + if($file=~/\.pl|\.lua|\.ext/i){ + $staged_file = $file; + $dest_file = $file; + $dest_file =~s/updates_staged\/Quests-Plugins-master\/quests\///g; + + if (!-e $dest_file) { + CopyFile($staged_file, $dest_file); + print "Installing :: '" . $dest_file . "'\n"; + $fc++; + } + else{ + $diff = Diff($dest_file, $staged_file); + if($diff ne ""){ + $backup_dest = "updates_backups/" . $time_stamp . "/" . $dest_file; + print $diff . "\n"; + print "\nFile Different :: '" . $dest_file . "'\n"; + print "\nDo you wish to update this LUA Module? '" . $dest_file . "' [Yes (Enter) - No (N)] - A backup will be found in '" . $backup_dest . "'\n"; + my $input = ; + if($input=~/N/i){} + else{ + #::: Make a backup + CopyFile($dest_file, $backup_dest); + #::: Copy staged to running + copy($staged_file, $dest_file); + print "Installing :: '" . $dest_file . "'\n\n"; + } + $fc++; + } + } + } + } + + #::: Cleanup staged folder... + rmtree("updates_staged/"); + + if($fc == 0){ + print "\nNo LUA Modules Updates found... \n\n"; + } +} + sub Plugins_Fetch{ print "\n --- Fetching Latest Plugins --- \n"; @@ -545,6 +608,7 @@ sub Plugins_Fetch{ if (!-e $dest_file) { CopyFile($staged_file, $dest_file); print "Installing :: '" . $dest_file . "'\n"; + $fc++; } else{ $diff = Diff($dest_file, $staged_file); From c5fb9ba6ddf0063160aa7660c631bd32e5da1900 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Thu, 12 Mar 2015 01:05:25 -0500 Subject: [PATCH 11/21] [eqemu_update.pl] Make it so script is still useable when eqemu_config.xml is not present with no DB configurations [skip ci] --- utils/scripts/eqemu_update.pl | 104 ++++++++++++++++++---------------- 1 file changed, 56 insertions(+), 48 deletions(-) diff --git a/utils/scripts/eqemu_update.pl b/utils/scripts/eqemu_update.pl index f1ec5b688..c60a1bc3b 100644 --- a/utils/scripts/eqemu_update.pl +++ b/utils/scripts/eqemu_update.pl @@ -22,7 +22,7 @@ if($Config{osname}=~/linux/i){ $OS = "Linux"; } if($Config{osname}=~/Win|MS/i){ $OS = "Windows"; } #::: If current version is less than what world is reporting, then download a new one... -$current_version = 7; +$current_version = 6; if($ARGV[0] eq "V"){ if($ARGV[1] > $current_version){ @@ -46,8 +46,11 @@ no warnings; ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(); +#::: Cleanup staged folder... +rmtree("updates_staged/"); + my $confile = "eqemu_config.xml"; #default -open(F, "<$confile") or die "Unable to open config: $confile\n"; +open(F, "<$confile"); my $indb = 0; while() { s/\r//g; @@ -107,12 +110,12 @@ if($path eq ""){ mkdir('db_update'); #::: Check if db_version table exists... -if(trim(GetMySQLResult("SHOW COLUMNS FROM db_version LIKE 'Revision'")) ne ""){ +if(trim(GetMySQLResult("SHOW COLUMNS FROM db_version LIKE 'Revision'")) ne "" && $db){ print GetMySQLResult("DROP TABLE db_version"); print "Old db_version table present, dropping...\n\n"; } -if(GetMySQLResult("SHOW TABLES LIKE 'db_version'") eq ""){ +if(GetMySQLResult("SHOW TABLES LIKE 'db_version'") eq "" && $db){ print GetMySQLResult(" CREATE TABLE db_version ( version int(11) DEFAULT '0' @@ -133,24 +136,24 @@ if($bin_db_ver == $local_db_ver && $ARGV[0] eq "ran_from_start"){ exit; } else{ - print $console_output; + print $console_output if $db; } +if($db){ + print " Binary Database Version: (" . $bin_db_ver . ")\n"; + print " Local Database Version: (" . $local_db_ver . ")\n\n"; -print " Binary Database Version: (" . $bin_db_ver . ")\n"; -print " Local Database Version: (" . $local_db_ver . ")\n\n"; + #::: If World ran this script, and our version is up to date, continue... + if($bin_db_ver <= $local_db_ver && $ARGV[0] eq "ran_from_world"){ + print " Database up to Date: Continuing World Bootup...\n"; + print "============================================================\n"; + exit; + } -#::: If World ran this script, and our version is up to date, continue... -if($bin_db_ver <= $local_db_ver && $ARGV[0] eq "ran_from_world"){ - print " Database up to Date: Continuing World Bootup...\n"; - print "============================================================\n"; - exit; + print "Retrieving latest database manifest...\n"; + GetRemoteFile("https://raw.githubusercontent.com/EQEmu/Server/master/utils/sql/db_update_manifest.txt", "db_update/db_update_manifest.txt"); } -print "Retrieving latest database manifest...\n"; -GetRemoteFile("https://raw.githubusercontent.com/EQEmu/Server/master/utils/sql/db_update_manifest.txt", "db_update/db_update_manifest.txt"); -# GetRemoteFile("https://dl.dropboxusercontent.com/u/50023467/dl/db_update_manifest.txt", "db_update/db_update_manifest.txt"); - if($local_db_ver < $bin_db_ver && $ARGV[0] eq "ran_from_world"){ print "You have missing database updates, type 1 or 2 to backup your database before running them as recommended...\n\n"; #::: Display Menu @@ -217,6 +220,7 @@ sub ShowMenuPrompt { } sub MenuOptions { + if(@total_updates){ $option[3] = "Run pending REQUIRED updates... (" . scalar (@total_updates) . ")"; } @@ -225,7 +229,7 @@ sub MenuOptions { } return < Date: Thu, 12 Mar 2015 11:19:41 -0500 Subject: [PATCH 12/21] [eqemu_update.pl] Set version back to 7... [skip ci] --- utils/scripts/eqemu_update.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/scripts/eqemu_update.pl b/utils/scripts/eqemu_update.pl index c60a1bc3b..302b4113b 100644 --- a/utils/scripts/eqemu_update.pl +++ b/utils/scripts/eqemu_update.pl @@ -22,7 +22,7 @@ if($Config{osname}=~/linux/i){ $OS = "Linux"; } if($Config{osname}=~/Win|MS/i){ $OS = "Windows"; } #::: If current version is less than what world is reporting, then download a new one... -$current_version = 6; +$current_version = 7; if($ARGV[0] eq "V"){ if($ARGV[1] > $current_version){ From cd82aae183a1626e86659cb969575e6ea97d2119 Mon Sep 17 00:00:00 2001 From: Akkadius Date: Thu, 12 Mar 2015 11:40:46 -0500 Subject: [PATCH 13/21] [eqemu_update.pl] Small line adjustment [skip ci] --- utils/scripts/eqemu_update.pl | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/utils/scripts/eqemu_update.pl b/utils/scripts/eqemu_update.pl index 302b4113b..3b1a0272c 100644 --- a/utils/scripts/eqemu_update.pl +++ b/utils/scripts/eqemu_update.pl @@ -509,7 +509,7 @@ sub QuestFiles_Fetch{ print $diff . "\n"; print "\nFile Different :: '" . $dest_file . "'\n"; - print "\nDo you wish to update this Quest? '" . $dest_file . "' [Yes (Enter) - No (N)] - A backup will be found in '" . $backup_dest . "'\n"; + print "\nDo you wish to update this Quest? '" . $dest_file . "' [Yes (Enter) - No (N)] \nA backup will be found in '" . $backup_dest . "'\n"; my $input = ; if($input=~/N/i){} else{ @@ -565,7 +565,7 @@ sub LUA_Modules_Fetch{ $backup_dest = "updates_backups/" . $time_stamp . "/" . $dest_file; print $diff . "\n"; print "\nFile Different :: '" . $dest_file . "'\n"; - print "\nDo you wish to update this LUA Module? '" . $dest_file . "' [Yes (Enter) - No (N)] - A backup will be found in '" . $backup_dest . "'\n"; + print "\nDo you wish to update this LUA Module? '" . $dest_file . "' [Yes (Enter) - No (N)] \nA backup will be found in '" . $backup_dest . "'\n"; my $input = ; if($input=~/N/i){} else{ @@ -621,7 +621,7 @@ sub Plugins_Fetch{ $backup_dest = "updates_backups/" . $time_stamp . "/" . $dest_file; print $diff . "\n"; print "\nFile Different :: '" . $dest_file . "'\n"; - print "\nDo you wish to update this Plugin? '" . $dest_file . "' [Yes (Enter) - No (N)] - A backup will be found in '" . $backup_dest . "'\n"; + print "\nDo you wish to update this Plugin? '" . $dest_file . "' [Yes (Enter) - No (N)] \nA backup will be found in '" . $backup_dest . "'\n"; my $input = ; if($input=~/N/i){} else{ From 3b9f62f0a1521fbdadd3698375a8565516a8db04 Mon Sep 17 00:00:00 2001 From: JJ Date: Wed, 18 Mar 2015 02:49:00 -0400 Subject: [PATCH 14/21] Exported ReloadZoneStaticData to perl and lua. Usage: (perl) quest::reloadzonestaticdata(); (lua) eq.reloadzonestaticdata(); --- zone/embparser_api.cpp | 11 +++++++++++ zone/lua_general.cpp | 5 +++++ zone/questmgr.cpp | 7 +++++++ zone/questmgr.h | 1 + 4 files changed, 24 insertions(+) diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index 8b49f01b2..1729978b0 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -3429,6 +3429,16 @@ XS(XS__clear_npctype_cache) XSRETURN_EMPTY; } +XS(XS__reloadzonestaticdata); +XS(XS__reloadzonestaticdata) +{ + dXSARGS; + + quest_manager.ReloadZoneStaticData(); + + XSRETURN_EMPTY; +} + XS(XS__qs_send_query); XS(XS__qs_send_query) { @@ -3686,6 +3696,7 @@ EXTERN_C XS(boot_quest) newXS(strcpy(buf, "qs_send_query"), XS__qs_send_query, file); newXS(strcpy(buf, "rain"), XS__rain, file); newXS(strcpy(buf, "rebind"), XS__rebind, file); + newXS(strcpy(buf, "reloadzonestaticdata"), XS__reloadzonestaticdata, file); newXS(strcpy(buf, "removetitle"), XS__removetitle, file); newXS(strcpy(buf, "repopzone"), XS__repopzone, file); newXS(strcpy(buf, "resettaskactivity"), XS__resettaskactivity, file); diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index 50afdb6e9..59a5d3740 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -1242,6 +1242,10 @@ void lua_clear_npctype_cache(int npctype_id) { quest_manager.ClearNPCTypeCache(npctype_id); } +void lua_reloadzonestaticdata() { + quest_manager.ReloadZoneStaticData(); +} + double lua_clock() { timeval read_time; gettimeofday(&read_time, nullptr); @@ -1592,6 +1596,7 @@ luabind::scope lua_register_general() { luabind::def("enable_recipe", &lua_enable_recipe), luabind::def("disable_recipe", &lua_disable_recipe), luabind::def("clear_npctype_cache", &lua_clear_npctype_cache), + luabind::def("reloadzonestaticdata", &lua_reloadzonestaticdata), luabind::def("clock", &lua_clock), luabind::def("create_npc", &lua_create_npc), luabind::def("debug", (void(*)(std::string))&lua_debug), diff --git a/zone/questmgr.cpp b/zone/questmgr.cpp index 97992e0bc..47d92b68e 100644 --- a/zone/questmgr.cpp +++ b/zone/questmgr.cpp @@ -2927,6 +2927,13 @@ void QuestManager::ClearNPCTypeCache(int npctype_id) { } } +void QuestManager::ReloadZoneStaticData() +{ + if (zone) { + zone->ReloadStaticData(); + } +} + Client *QuestManager::GetInitiator() const { if(!quests_running_.empty()) { running_quest e = quests_running_.top(); diff --git a/zone/questmgr.h b/zone/questmgr.h index 7051bbb2b..d2f018b8c 100644 --- a/zone/questmgr.h +++ b/zone/questmgr.h @@ -249,6 +249,7 @@ public: bool EnableRecipe(uint32 recipe_id); bool DisableRecipe(uint32 recipe_id); void ClearNPCTypeCache(int npctype_id); + void ReloadZoneStaticData(); Client *GetInitiator() const; NPC *GetNPC() const; From 1c454d9569823876f2a886ba2c39b2ed6360f5a2 Mon Sep 17 00:00:00 2001 From: KayenEQ Date: Thu, 19 Mar 2015 16:22:17 -0400 Subject: [PATCH 15/21] Fix for pets not receiving group buffs cast on them correctly. --- zone/spells.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zone/spells.cpp b/zone/spells.cpp index b0ed519d9..08030b8b5 100644 --- a/zone/spells.cpp +++ b/zone/spells.cpp @@ -2151,7 +2151,7 @@ bool Mob::SpellFinished(uint16 spell_id, Mob *spell_target, uint16 slot, uint16 // it can affect up to 7 people if the targeted group is not our own // Allow pets who cast group spells to affect the group. - if (spell_target->IsPetOwnerClient()){ + if (spell_target->IsPetOwnerClient() && IsPetOwnerClient()){ Mob* owner = spell_target->GetOwner(); if (owner) From 6c26bc9c8f05700e851f11d69dc5f018cecc2760 Mon Sep 17 00:00:00 2001 From: KimLS Date: Fri, 20 Mar 2015 13:10:36 -0700 Subject: [PATCH 16/21] Fix for alt currency reclaim exploit and fix for exploit in trader code where price != set price --- zone/client_packet.cpp | 2 +- zone/trading.cpp | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index 1bf44e3ee..a04d4359c 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -2604,7 +2604,7 @@ void Client::Handle_OP_AltCurrencyReclaim(const EQApplicationPacket *app) ++iter; } - if (item_id == 0) { + if (item_id == 0 || reclaim->count == 0) { return; } diff --git a/zone/trading.cpp b/zone/trading.cpp index 0e44a91bc..a521e63cc 100644 --- a/zone/trading.cpp +++ b/zone/trading.cpp @@ -1583,6 +1583,8 @@ void Client::BuyTraderItem(TraderBuy_Struct* tbs, Client* Trader, const EQApplic return; } + tbs->Price = BuyItem->GetPrice(); + Log.Out(Logs::Detail, Logs::Trading, "Buyitem: Name: %s, IsStackable: %i, Requested Quantity: %i, Charges on Item %i", BuyItem->GetItem()->Name, BuyItem->IsStackable(), tbs->Quantity, BuyItem->GetCharges()); // If the item is not stackable, then we can only be buying one of them. From f021ee54911f6dde063580ea23c853d61b1842a3 Mon Sep 17 00:00:00 2001 From: KimLS Date: Sun, 22 Mar 2015 14:47:45 -0700 Subject: [PATCH 17/21] Fix for traders not correctly setting price --- zone/client_packet.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zone/client_packet.cpp b/zone/client_packet.cpp index a04d4359c..21ab1c7cf 100644 --- a/zone/client_packet.cpp +++ b/zone/client_packet.cpp @@ -13385,6 +13385,10 @@ void Client::Handle_OP_Trader(const EQApplicationPacket *app) if (database.GetItem(gis->Items[i])) { database.SaveTraderItem(this->CharacterID(), gis->Items[i], gis->SerialNumber[i], gis->Charges[i], ints->ItemCost[i], i); + + auto inst = FindTraderItemBySerialNumber(gis->SerialNumber[i]); + if(inst) + inst->SetPrice(ints->ItemCost[i]); } else { //return; //sony doesnt memset so assume done on first bad item From 0cf5cca4159c4a73265c7260afac7051bd843a4a Mon Sep 17 00:00:00 2001 From: KimLS Date: Sun, 22 Mar 2015 23:18:08 -0700 Subject: [PATCH 18/21] Other half of bazaar exploit --- zone/trading.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/zone/trading.cpp b/zone/trading.cpp index a521e63cc..b6c869b61 100644 --- a/zone/trading.cpp +++ b/zone/trading.cpp @@ -1652,7 +1652,12 @@ void Client::BuyTraderItem(TraderBuy_Struct* tbs, Client* Trader, const EQApplic outtbs->Price = TotalCost; } - this->TakeMoneyFromPP(TotalCost); + if(!TakeMoneyFromPP(TotalCost)) { + database.SetHackerFlag(account_name, name, "Attempted to buy something in bazaar but did not have enough money."); + TradeRequestFailed(app); + safe_delete(outapp); + return; + } Log.Out(Logs::Detail, Logs::Trading, "Customer Paid: %d in Copper", TotalCost); From 340ed6c59d5e2bf4558cc3f4f39b3219dd6917cc Mon Sep 17 00:00:00 2001 From: KayenEQ Date: Tue, 24 Mar 2015 01:42:34 -0400 Subject: [PATCH 19/21] Fix for sympathetic proc code to allow for it to be properly checked from spell buffs. --- common/spdat.h | 1 + zone/spell_effects.cpp | 11 +++++------ 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/common/spdat.h b/common/spdat.h index b70d708f0..487b5d00a 100644 --- a/common/spdat.h +++ b/common/spdat.h @@ -38,6 +38,7 @@ #define MAX_RESISTABLE_EFFECTS 12 // Number of effects that are typcially checked agianst resists. #define MaxLimitInclude 16 //Number(x 0.5) of focus Limiters that have inclusive checks used when calcing focus effects #define MAX_SKILL_PROCS 4 //Number of spells to check skill procs from. (This is arbitrary) [Single spell can have multiple proc checks] +#define MAX_SYMPATHETIC_PROCS 10 // Number of sympathetic procs a client can have (This is arbitrary) const int Z_AGGRO=10; diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index 24eac51ee..e03d5672a 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -5183,7 +5183,6 @@ int16 Client::GetSympatheticFocusEffect(focusType type, uint16 spell_id) { return 0; uint16 proc_spellid = 0; - uint8 MAX_SYMPATHETIC = 10; float ProcChance = 0.0f; std::vector SympatheticProcList; @@ -5195,7 +5194,7 @@ int16 Client::GetSympatheticFocusEffect(focusType type, uint16 spell_id) { for(int x = EmuConstants::EQUIPMENT_BEGIN; x <= EmuConstants::EQUIPMENT_END; x++) { - if (SympatheticProcList.size() > MAX_SYMPATHETIC) + if (SympatheticProcList.size() > MAX_SYMPATHETIC_PROCS) continue; TempItem = nullptr; @@ -5215,7 +5214,7 @@ int16 Client::GetSympatheticFocusEffect(focusType type, uint16 spell_id) { for (int y = AUG_BEGIN; y < EmuConstants::ITEM_COMMON_SIZE; ++y) { - if (SympatheticProcList.size() > MAX_SYMPATHETIC) + if (SympatheticProcList.size() > MAX_SYMPATHETIC_PROCS) continue; ItemInst *aug = nullptr; @@ -5243,11 +5242,11 @@ int16 Client::GetSympatheticFocusEffect(focusType type, uint16 spell_id) { int buff_max = GetMaxTotalSlots(); for (buff_slot = 0; buff_slot < buff_max; buff_slot++) { - if (SympatheticProcList.size() > MAX_SYMPATHETIC) + if (SympatheticProcList.size() > MAX_SYMPATHETIC_PROCS) continue; focusspellid = buffs[buff_slot].spellid; - if (IsValidSpell(focusspellid)) + if (!IsValidSpell(focusspellid)) continue; proc_spellid = CalcFocusEffect(type, focusspellid, spell_id); @@ -5275,7 +5274,7 @@ int16 Client::GetSympatheticFocusEffect(focusType type, uint16 spell_id) { if (aa_AA < 1 || aa_value < 1) continue; - if (SympatheticProcList.size() > MAX_SYMPATHETIC) + if (SympatheticProcList.size() > MAX_SYMPATHETIC_PROCS) continue; proc_spellid = CalcAAFocus(type, aa_AA, spell_id); From 202c59eb4821e0baf284a80840995e3aa430d4c4 Mon Sep 17 00:00:00 2001 From: KayenEQ Date: Tue, 24 Mar 2015 07:13:22 -0400 Subject: [PATCH 20/21] More sympathetic proc fixes --- zone/client.h | 2 +- zone/mob.cpp | 53 +++++++++++++++++++++++------------------- zone/mob.h | 2 ++ zone/spell_effects.cpp | 24 +++++++++++++++++-- 4 files changed, 54 insertions(+), 27 deletions(-) diff --git a/zone/client.h b/zone/client.h index 3a90e87eb..533db7b04 100644 --- a/zone/client.h +++ b/zone/client.h @@ -1268,7 +1268,7 @@ protected: bool client_data_loaded; int16 GetFocusEffect(focusType type, uint16 spell_id); - int16 GetSympatheticFocusEffect(focusType type, uint16 spell_id); + uint16 GetSympatheticFocusEffect(focusType type, uint16 spell_id); Mob* bind_sight_target; diff --git a/zone/mob.cpp b/zone/mob.cpp index b4d28c6c0..2053594be 100644 --- a/zone/mob.cpp +++ b/zone/mob.cpp @@ -3615,36 +3615,41 @@ bool Mob::TryFadeEffect(int slot) void Mob::TrySympatheticProc(Mob *target, uint32 spell_id) { - if(target == nullptr || !IsValidSpell(spell_id)) + if(target == nullptr || !IsValidSpell(spell_id) || !IsClient()) return; - int focus_spell = CastToClient()->GetSympatheticFocusEffect(focusSympatheticProc,spell_id); + uint16 focus_spell = CastToClient()->GetSympatheticFocusEffect(focusSympatheticProc,spell_id); - if(IsValidSpell(focus_spell)){ - int focus_trigger = spells[focus_spell].base2[0]; - // For beneficial spells, if the triggered spell is also beneficial then proc it on the target - // if the triggered spell is detrimental, then it will trigger on the caster(ie cursed items) - if(IsBeneficialSpell(spell_id)) - { - if(IsBeneficialSpell(focus_trigger)) - SpellFinished(focus_trigger, target); + if(!IsValidSpell(focus_spell)) + return; - else - SpellFinished(focus_trigger, this, 10, 0, -1, spells[focus_trigger].ResistDiff); - } - // For detrimental spells, if the triggered spell is beneficial, then it will land on the caster - // if the triggered spell is also detrimental, then it will land on the target - else - { - if(IsBeneficialSpell(focus_trigger)) - SpellFinished(focus_trigger, this); + uint16 focus_trigger = GetSympatheticSpellProcID(focus_spell); - else - SpellFinished(focus_trigger, target, 10, 0, -1, spells[focus_trigger].ResistDiff); - } + if(!IsValidSpell(focus_trigger)) + return; - CheckNumHitsRemaining(NumHit::MatchingSpells, -1, focus_spell); - } + // For beneficial spells, if the triggered spell is also beneficial then proc it on the target + // if the triggered spell is detrimental, then it will trigger on the caster(ie cursed items) + if(IsBeneficialSpell(spell_id)) + { + if(IsBeneficialSpell(focus_trigger)) + SpellFinished(focus_trigger, target); + + else + SpellFinished(focus_trigger, this, 10, 0, -1, spells[focus_trigger].ResistDiff); + } + // For detrimental spells, if the triggered spell is beneficial, then it will land on the caster + // if the triggered spell is also detrimental, then it will land on the target + else + { + if(IsBeneficialSpell(focus_trigger)) + SpellFinished(focus_trigger, this); + + else + SpellFinished(focus_trigger, target, 10, 0, -1, spells[focus_trigger].ResistDiff); + } + + CheckNumHitsRemaining(NumHit::MatchingSpells, -1, focus_spell); } int32 Mob::GetItemStat(uint32 itemid, const char *identifier) diff --git a/zone/mob.h b/zone/mob.h index 6d7b386cf..979d9728a 100644 --- a/zone/mob.h +++ b/zone/mob.h @@ -1063,6 +1063,8 @@ protected: void PrintRoute(); virtual float GetSympatheticProcChances(uint16 spell_id, int16 ProcRateMod, int32 ItemProcRate = 0); + int16 GetSympatheticSpellProcRate(uint16 spell_id); + uint16 GetSympatheticSpellProcID(uint16 spell_id); enum {MAX_PROCS = 4}; tProc PermaProcs[MAX_PROCS]; diff --git a/zone/spell_effects.cpp b/zone/spell_effects.cpp index e03d5672a..21ba36e0a 100644 --- a/zone/spell_effects.cpp +++ b/zone/spell_effects.cpp @@ -5177,7 +5177,7 @@ int16 Mob::CalcFocusEffect(focusType type, uint16 focus_id, uint16 spell_id, boo return(value*lvlModifier/100); } -int16 Client::GetSympatheticFocusEffect(focusType type, uint16 spell_id) { +uint16 Client::GetSympatheticFocusEffect(focusType type, uint16 spell_id) { if (IsBardSong(spell_id)) return 0; @@ -5253,7 +5253,7 @@ int16 Client::GetSympatheticFocusEffect(focusType type, uint16 spell_id) { if (IsValidSpell(proc_spellid)){ - ProcChance = GetSympatheticProcChances(spell_id, spells[focusspellid].base[0]); + ProcChance = GetSympatheticProcChances(spell_id, GetSympatheticSpellProcRate(spell_id)); if(zone->random.Roll(ProcChance)) SympatheticProcList.push_back(proc_spellid); } @@ -5929,6 +5929,26 @@ float Mob::GetSympatheticProcChances(uint16 spell_id, int16 ProcRateMod, int32 I return ProcChance; } +int16 Mob::GetSympatheticSpellProcRate(uint16 spell_id) +{ + for (int i = 0; i < EFFECT_COUNT; i++){ + if (spells[spell_id].effectid[i] == SE_SympatheticProc) + return spells[spell_id].base[i]; + } + + return 0; +} + +uint16 Mob::GetSympatheticSpellProcID(uint16 spell_id) +{ + for (int i = 0; i < EFFECT_COUNT; i++){ + if (spells[spell_id].effectid[i] == SE_SympatheticProc) + return spells[spell_id].base2[i]; + } + + return 0; +} + bool Mob::DoHPToManaCovert(uint16 mana_cost) { if (spellbonuses.HPToManaConvert){ From 9ef4825a7274cd391406babf3c359f078f1e4c36 Mon Sep 17 00:00:00 2001 From: KimLS Date: Tue, 24 Mar 2015 16:37:12 -0700 Subject: [PATCH 21/21] Fix for gaps in path files during add --- zone/pathing.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/zone/pathing.cpp b/zone/pathing.cpp index e01cb6916..8224f3692 100644 --- a/zone/pathing.cpp +++ b/zone/pathing.cpp @@ -1478,6 +1478,11 @@ int32 PathManager::AddNode(float x, float y, float z, float best_z, int32 reques { for(uint32 i = 0; i < Head.PathNodeCount; ++i) { + if(PathNodes[i].id - new_id > 1) { + new_id = PathNodes[i].id - 1; + break; + } + if(PathNodes[i].id > new_id) new_id = PathNodes[i].id; }