From 2c2c09531f095d9dea8738da126783415ae1cfbb Mon Sep 17 00:00:00 2001 From: Ali Date: Thu, 21 May 2020 14:44:07 +0300 Subject: [PATCH 01/12] [ci skip] Revert back to using wget.exe for windows installs --- utils/scripts/eqemu_server.pl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/utils/scripts/eqemu_server.pl b/utils/scripts/eqemu_server.pl index e094e0cce..d3081d580 100755 --- a/utils/scripts/eqemu_server.pl +++ b/utils/scripts/eqemu_server.pl @@ -1371,11 +1371,10 @@ sub get_remote_file $wget = `wget -N --no-cache --cache=no --no-check-certificate --quiet -O $destination_file $request_url`; } elsif ($OS eq "Windows") { - $wget = - `powershell -Command "\$ProgressPreference = 'SilentlyContinue'; Invoke-RestMethod -ContentType \"application/octet-stream\" -Uri $request_url -OutFile $destination_file"` + $wget = `bin\\wget.exe -N --no-cache --cache=no --no-check-certificate --quiet -O $destination_file $request_url`; } print "[Download] Saved [" . $destination_file . "] from [" . $request_url . "]\n" if !$silent_download; - if (($OS eq "Linux" && $wget =~ /unable to resolve/i) || ($OS eq "Windows" && $wget =~ /404/i || $wget =~ /could not be resolved/i)) { + if ($wget =~ /unable to resolve/i) { print "Error, no connection or failed request...\n\n"; #die; } From b585d9b062e4c6569432da75d1cb97b2f502697f Mon Sep 17 00:00:00 2001 From: Akkadius Date: Sat, 23 May 2020 16:29:04 -0500 Subject: [PATCH 02/12] Use wget again for windows [skip ci] --- utils/scripts/eqemu_server.pl | 48 ++++++++++------------------------- 1 file changed, 14 insertions(+), 34 deletions(-) diff --git a/utils/scripts/eqemu_server.pl b/utils/scripts/eqemu_server.pl index d3081d580..86b108ecc 100755 --- a/utils/scripts/eqemu_server.pl +++ b/utils/scripts/eqemu_server.pl @@ -84,6 +84,7 @@ if (-d "bin") { ############################################# # run routines ############################################# +get_windows_wget(); check_xml_to_json_conversion() if $ARGV[0] eq "convert_xml"; do_self_update_check_routine() if !$skip_self_update_check; get_perl_version(); @@ -699,6 +700,16 @@ sub get_perl_version no warnings; } +sub get_windows_wget { + if (!-e "wget.exe" && $OS eq "Windows") { + eval "use LWP::Simple qw(getstore);"; + if (!-d "bin") { + mkdir("bin"); + } + getstore("https://raw.githubusercontent.com/Akkadius/eqemu-install-v2/master/windows/wget.exe", "bin/wget.exe"); + } +} + sub do_self_update_check_routine { @@ -1048,10 +1059,6 @@ sub show_menu_prompt fetch_latest_windows_appveyor(); $dc = 1; } - elsif ($input eq "windows_server_download_bots") { - fetch_latest_windows_binaries_bots(); - $dc = 1; - } elsif ($input eq "windows_server_latest_bots") { fetch_latest_windows_appveyor_bots(); $dc = 1; @@ -1626,13 +1633,13 @@ sub fetch_latest_windows_binaries sub fetch_latest_windows_appveyor_bots { print "[Update] Fetching Latest Windows Binaries with Bots (unstable) from Appveyor... \n"; - get_remote_file("https://ci.appveyor.com/api/projects/KimLS/server/artifacts/eqemu-x86-bots.zip", - "updates_staged/eqemu-x86-bots.zip", + get_remote_file("https://ci.appveyor.com/api/projects/KimLS/server-87crp/artifacts/build_x64.zip", + "updates_staged/eqemu-x64-bots.zip", 1); print "[Update] Fetched Latest Windows Binaries (unstable) from Appveyor... \n"; print "[Update] Extracting... --- \n"; - unzip('updates_staged/eqemu-x86-bots.zip', 'updates_staged/binaries/'); + unzip('updates_staged/eqemu-x64-bots.zip', 'updates_staged/binaries/'); my @files; my $start_dir = "updates_staged/binaries"; find( @@ -1650,33 +1657,6 @@ sub fetch_latest_windows_appveyor_bots rmtree('updates_staged'); } -sub fetch_latest_windows_binaries_bots -{ - print "[Update] Fetching Latest Windows Binaries with Bots...\n"; - get_remote_file($install_repository_request_url . "master_windows_build_bots.zip", - "updates_staged/master_windows_build_bots.zip", - 1); - - print "[Update] Fetched Latest Windows Binaries with Bots...\n"; - print "[Update] Extracting...\n"; - unzip('updates_staged/master_windows_build_bots.zip', 'updates_staged/binaries/'); - my @files; - my $start_dir = "updates_staged/binaries"; - find( - sub {push @files, $File::Find::name unless -d;}, - $start_dir - ); - for my $file (@files) { - $destination_file = $file; - $destination_file =~ s/updates_staged\/binaries\///g; - print "[Install] Installing [" . $bin_dir . $destination_file . "]\n"; - copy_file($file, $bin_dir . $destination_file); - } - print "[Update] Done...\n"; - - rmtree('updates_staged'); -} - sub do_windows_login_server_setup { print "[Install] Pulling down Loginserver database tables...\n"; From 86ef1b12e2c6990c40a52aba8567aeba953e1b3a Mon Sep 17 00:00:00 2001 From: Akkadius Date: Sat, 23 May 2020 16:50:09 -0500 Subject: [PATCH 03/12] Strawberry Perl OOB has issue with getstore so lets use something else [skip ci] --- utils/scripts/eqemu_server.pl | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/utils/scripts/eqemu_server.pl b/utils/scripts/eqemu_server.pl index 86b108ecc..2b9bd4a7a 100755 --- a/utils/scripts/eqemu_server.pl +++ b/utils/scripts/eqemu_server.pl @@ -701,12 +701,11 @@ sub get_perl_version } sub get_windows_wget { - if (!-e "wget.exe" && $OS eq "Windows") { - eval "use LWP::Simple qw(getstore);"; + if (!-e "bin/wget.exe" && $OS eq "Windows") { if (!-d "bin") { mkdir("bin"); } - getstore("https://raw.githubusercontent.com/Akkadius/eqemu-install-v2/master/windows/wget.exe", "bin/wget.exe"); + `powershell -Command "\$ProgressPreference = 'SilentlyContinue'; Invoke-RestMethod -ContentType \"application/octet-stream\" -Uri https://raw.githubusercontent.com/Akkadius/eqemu-install-v2/master/windows/wget.exe -OutFile bin/wget.exe"` } } From 712df6c35abdec342d9bf7ffcd24aeb7408c57ce Mon Sep 17 00:00:00 2001 From: KimLS Date: Sat, 23 May 2020 23:19:54 -0700 Subject: [PATCH 04/12] Fix compile issue for latest vc compiler --- common/util/uuid.cpp | 1 + common/util/uuid.h | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/common/util/uuid.cpp b/common/util/uuid.cpp index 633ffebaf..7acd1517f 100644 --- a/common/util/uuid.cpp +++ b/common/util/uuid.cpp @@ -1,5 +1,6 @@ #include "uuid.h" +#include #include #ifdef _WIN32 diff --git a/common/util/uuid.h b/common/util/uuid.h index 3b37fc2d2..d1e49a0e7 100644 --- a/common/util/uuid.h +++ b/common/util/uuid.h @@ -2,7 +2,7 @@ #include #include -#include +#include namespace EQ { @@ -32,4 +32,4 @@ namespace EQ std::vector m_bytes; }; } -} \ No newline at end of file +} From e8a05ec680c2498a59521456c19f879c5e1a390b Mon Sep 17 00:00:00 2001 From: Chris Miles Date: Sun, 24 May 2020 01:32:50 -0500 Subject: [PATCH 05/12] Fixes instance deletion issue https://github.com/EQEmu/Server/issues/1069 --- common/database_instances.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/common/database_instances.cpp b/common/database_instances.cpp index 617a2baf6..945fca078 100644 --- a/common/database_instances.cpp +++ b/common/database_instances.cpp @@ -514,8 +514,10 @@ void Database::BuryCorpsesInInstance(uint16 instance_id) { void Database::DeleteInstance(uint16 instance_id) { - std::string query; + + query = StringFormat("DELETE FROM instance_list WHERE id=%u", instance_id); + QueryDatabase(query) query = StringFormat("DELETE FROM instance_list_player WHERE id=%u", instance_id); QueryDatabase(query); From 26831d5ad46bf50beee8f7749be0d5e1f5234fdf Mon Sep 17 00:00:00 2001 From: Chris Miles Date: Sun, 24 May 2020 02:56:04 -0500 Subject: [PATCH 06/12] Fix a copy paste error --- common/database_instances.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/common/database_instances.cpp b/common/database_instances.cpp index 945fca078..d7d84c90b 100644 --- a/common/database_instances.cpp +++ b/common/database_instances.cpp @@ -517,7 +517,7 @@ void Database::DeleteInstance(uint16 instance_id) std::string query; query = StringFormat("DELETE FROM instance_list WHERE id=%u", instance_id); - QueryDatabase(query) + QueryDatabase(query); query = StringFormat("DELETE FROM instance_list_player WHERE id=%u", instance_id); QueryDatabase(query); From 0d2d6a2c6be6e73a11e1287f2cff3e366dbaf1ea Mon Sep 17 00:00:00 2001 From: Akkadius Date: Sun, 24 May 2020 04:07:29 -0500 Subject: [PATCH 07/12] More resilient fix to killing instances for now [skip ci] --- common/database_instances.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/common/database_instances.cpp b/common/database_instances.cpp index d7d84c90b..0c917d847 100644 --- a/common/database_instances.cpp +++ b/common/database_instances.cpp @@ -516,9 +516,6 @@ void Database::DeleteInstance(uint16 instance_id) { std::string query; - query = StringFormat("DELETE FROM instance_list WHERE id=%u", instance_id); - QueryDatabase(query); - query = StringFormat("DELETE FROM instance_list_player WHERE id=%u", instance_id); QueryDatabase(query); @@ -606,6 +603,9 @@ void Database::PurgeExpiredInstances() } for (auto row = results.begin(); row != results.end(); ++row) { + query = StringFormat("DELETE FROM instance_list WHERE id=%u", atoi(row[0])); + QueryDatabase(query); + DeleteInstance(atoi(row[0])); } } From db072e767a1e822e70d7b702202dbaa3e59d0dae Mon Sep 17 00:00:00 2001 From: Akkadius Date: Sun, 24 May 2020 04:23:52 -0500 Subject: [PATCH 08/12] Bulk instance deletion instead of tons of individual statements [skip ci] --- common/database_instances.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/common/database_instances.cpp b/common/database_instances.cpp index 0c917d847..4f7c1b8a2 100644 --- a/common/database_instances.cpp +++ b/common/database_instances.cpp @@ -602,12 +602,20 @@ void Database::PurgeExpiredInstances() return; } + std::vector instance_ids; for (auto row = results.begin(); row != results.end(); ++row) { - query = StringFormat("DELETE FROM instance_list WHERE id=%u", atoi(row[0])); - QueryDatabase(query); - - DeleteInstance(atoi(row[0])); + instance_ids.emplace_back(row[0]); } + + std::string imploded_instance_ids = implode(",", instance_ids); + + QueryDatabase(fmt::format("DELETE FROM instance_list WHERE id IN ({})", imploded_instance_ids)); + QueryDatabase(fmt::format("DELETE FROM instance_list_player WHERE id IN ({})", imploded_instance_ids)); + QueryDatabase(fmt::format("DELETE FROM respawn_times WHERE instance_id IN ({})", imploded_instance_ids)); + QueryDatabase(fmt::format("DELETE FROM spawn_condition_values WHERE instance_id IN ({})", imploded_instance_ids)); + QueryDatabase(fmt::format("UPDATE character_corpses SET is_buried = 1, instance_id = 0 WHERE instance_id IN ({})", imploded_instance_ids)); + + } void Database::SetInstanceDuration(uint16 instance_id, uint32 new_duration) From 6896ef650e7feacf4275e8d67f23718877c38965 Mon Sep 17 00:00:00 2001 From: Ali Date: Mon, 25 May 2020 16:18:22 +0300 Subject: [PATCH 09/12] [ci skip] Updated installer to support powershell older than 3.0 --- utils/scripts/eqemu_server.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/scripts/eqemu_server.pl b/utils/scripts/eqemu_server.pl index 2b9bd4a7a..4c510ff9f 100755 --- a/utils/scripts/eqemu_server.pl +++ b/utils/scripts/eqemu_server.pl @@ -705,7 +705,7 @@ sub get_windows_wget { if (!-d "bin") { mkdir("bin"); } - `powershell -Command "\$ProgressPreference = 'SilentlyContinue'; Invoke-RestMethod -ContentType \"application/octet-stream\" -Uri https://raw.githubusercontent.com/Akkadius/eqemu-install-v2/master/windows/wget.exe -OutFile bin/wget.exe"` + `powershell -Command "(New-Object Net.WebClient).DownloadFile('https://raw.githubusercontent.com/Akkadius/eqemu-install-v2/master/windows/wget.exe', 'bin\\wget.exe') "` } } From 5e9bf3b044c535273406dd806e84220a2defa001 Mon Sep 17 00:00:00 2001 From: KimLS Date: Mon, 25 May 2020 20:56:49 -0700 Subject: [PATCH 10/12] Make ChooseRandom more idiomatic, the fact that the code can return a SV of anytype makes it a bit dangerous, good canidate for rewriting as a plugin --- zone/embparser_api.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index 6b4d75719..83839457b 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -1618,11 +1618,12 @@ XS(XS__ChooseRandom) { if (items < 1) Perl_croak(aTHX_ "Usage: quest::ChooseRandom(option1, option2, option3, option4, option5...[no limit])"); + dXSTARG; int index = zone->random.Int(0, items - 1); + SV *RETVAL = ST(index); - SV *tmp = ST(0); - ST(0) = ST(index); - ST(index) = tmp; + XSprePUSH; + PUSHs(RETVAL); XSRETURN(1); //return 1 element from the stack (ST(0)) } From c10a9cb6200fad1b2029991832513d71cb15f782 Mon Sep 17 00:00:00 2001 From: Chris Miles Date: Tue, 26 May 2020 00:32:45 -0500 Subject: [PATCH 11/12] Update README.md --- README.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 1b08d54be..e999b7050 100644 --- a/README.md +++ b/README.md @@ -17,9 +17,13 @@ |:---:|:---:|:---:| |**Install Count**|![Windows Install Count](http://analytics.akkadius.com/?install_count&windows_count)|![Linux Install Count](http://analytics.akkadius.com/?install_count&linux_count)| ### > Windows -* [Install](https://eqemu.gitbook.io/server/categories/how-to-guides/installation/server-installation-windows) + +* [Install Guide](https://eqemu.gitbook.io/server/categories/installation/server-installation-windows) ### > Debian/Ubuntu/CentOS/Fedora + +* [Install Guide](https://eqemu.gitbook.io/server/categories/installation/server-installation-linux) + * You can use curl or wget to kick off the installer (whichever your OS has) > curl -O https://raw.githubusercontent.com/EQEmu/Server/master/utils/scripts/linux_installer/install.sh install.sh && chmod 755 install.sh && ./install.sh From 8a0d4e37bd736b9c34a2ab91c54037e128ab18f5 Mon Sep 17 00:00:00 2001 From: KimLS Date: Tue, 26 May 2020 22:30:19 -0700 Subject: [PATCH 12/12] Remove optimization off of quest::ChooseRandom on msvc to solve a crash on x64 in release mode --- zone/embparser_api.cpp | 39 +++++++++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/zone/embparser_api.cpp b/zone/embparser_api.cpp index 83839457b..f95730eb0 100644 --- a/zone/embparser_api.cpp +++ b/zone/embparser_api.cpp @@ -1523,12 +1523,12 @@ XS(XS__addldonpoints) { if (items != 2) Perl_croak(aTHX_ "Usage: quest::addldonpoints(int points, int theme_id)"); - long points = (long) SvIV(ST(0)); - unsigned long theme_id = (unsigned long) SvUV(ST(1)); +long points = (long)SvIV(ST(0)); +unsigned long theme_id = (unsigned long)SvUV(ST(1)); - quest_manager.addldonpoints(points, theme_id); +quest_manager.addldonpoints(points, theme_id); - XSRETURN_EMPTY; +XSRETURN_EMPTY; } XS(XS__addldonwin); @@ -1537,8 +1537,8 @@ XS(XS__addldonwin) { if (items != 2) Perl_croak(aTHX_ "Usage: quest::addldonwin(int wins, int theme_id)"); - long wins = (long) SvIV(ST(0)); - unsigned long theme_id = (unsigned long) SvUV(ST(1)); + long wins = (long)SvIV(ST(0)); + unsigned long theme_id = (unsigned long)SvUV(ST(1)); quest_manager.addldonwin(wins, theme_id); @@ -1551,8 +1551,8 @@ XS(XS__addldonloss) { if (items != 2) Perl_croak(aTHX_ "Usage: quest::addldonloss(int losses, int theme_id)"); - long losses = (long) SvIV(ST(0)); - unsigned long theme_id = (unsigned long) SvUV(ST(1)); + long losses = (long)SvIV(ST(0)); + unsigned long theme_id = (unsigned long)SvUV(ST(1)); quest_manager.addldonloss(losses, theme_id); @@ -1565,7 +1565,7 @@ XS(XS__setnexthpevent) { if (items != 1) Perl_croak(aTHX_ "Usage: quest::setnexthpevent(int at_mob_percentage)"); - int at = (int) SvIV(ST(0)); + int at = (int)SvIV(ST(0)); quest_manager.setnexthpevent(at); @@ -1578,7 +1578,7 @@ XS(XS__setnextinchpevent) { if (items != 1) Perl_croak(aTHX_ "Usage: quest::setnextinchpevent(int at_mob_percentage)"); - int at = (int) SvIV(ST(0)); + int at = (int)SvIV(ST(0)); quest_manager.setnextinchpevent(at); @@ -1591,7 +1591,7 @@ XS(XS__sethp) { if (items != 1) Perl_croak(aTHX_ "Usage: quest::sethp(int mob_health_percentage [0-100])"); - int hpperc = (int) SvIV(ST(0)); + int hpperc = (int)SvIV(ST(0)); quest_manager.sethp(hpperc); @@ -1604,14 +1604,21 @@ XS(XS__respawn) { if (items != 2) Perl_croak(aTHX_ "Usage: quest::respawn(int npc_type_id, int grid_id)"); - int npc_type_id = (int) SvIV(ST(0)); - int grid_id = (int) SvIV(ST(1)); + int npc_type_id = (int)SvIV(ST(0)); + int grid_id = (int)SvIV(ST(1)); quest_manager.respawn(npc_type_id, grid_id); XSRETURN_EMPTY; } +//64 bit windows seems to optimize something poorly here causing access violations. +//If you don't do anything with index before passing it to perl it gets optimized out +//Disabling optimization right now for msvc on this function is the best solution. +#ifdef _MSC_VER +#pragma optimize( "", off ) +#endif + XS(XS__ChooseRandom); XS(XS__ChooseRandom) { dXSARGS; @@ -1620,7 +1627,7 @@ XS(XS__ChooseRandom) { dXSTARG; int index = zone->random.Int(0, items - 1); - SV *RETVAL = ST(index); + SV* RETVAL = ST(index); XSprePUSH; PUSHs(RETVAL); @@ -1628,6 +1635,10 @@ XS(XS__ChooseRandom) { XSRETURN(1); //return 1 element from the stack (ST(0)) } +#ifdef _MSC_VER +#pragma optimize( "", on ) +#endif + XS(XS__set_proximity); XS(XS__set_proximity) { dXSARGS;