From 79eb2d3d4bab15c7fb7d0412841c71baf7fffdf8 Mon Sep 17 00:00:00 2001 From: Uleat Date: Mon, 12 Oct 2015 17:17:07 -0400 Subject: [PATCH] Remote testing and some final updates --- common/version.h | 2 +- utils/scripts/eqemu_update.pl | 21 +++-- utils/sql/git/bots/README | 2 +- .../sql/git/bots/required/2015_09_30_bots.sql | 13 +-- zone/bot.cpp | 83 +++++++++---------- 5 files changed, 63 insertions(+), 58 deletions(-) diff --git a/common/version.h b/common/version.h index e2cda9a31..d8a6b6077 100644 --- a/common/version.h +++ b/common/version.h @@ -32,7 +32,7 @@ #define CURRENT_BINARY_DATABASE_VERSION 9087 #ifdef BOTS - #define CURRENT_BINARY_BOTS_DATABASE_VERSION 0 // temporarily disabled + #define CURRENT_BINARY_BOTS_DATABASE_VERSION 9000 #else #define CURRENT_BINARY_BOTS_DATABASE_VERSION 0 // must be 0 #endif diff --git a/utils/scripts/eqemu_update.pl b/utils/scripts/eqemu_update.pl index 9c1556d21..2026086ce 100644 --- a/utils/scripts/eqemu_update.pl +++ b/utils/scripts/eqemu_update.pl @@ -30,7 +30,8 @@ if($ARGV[0] eq "V"){ print "eqemu_update.pl Automatic Database Upgrade Needs updating...\n"; print " Current version: " . $current_version . "\n"; print " New version: " . $ARGV[1] . "\n"; - get_remote_file("https://raw.githubusercontent.com/EQEmu/Server/master/utils/scripts/eqemu_update.pl", "eqemu_update.pl"); + #get_remote_file("https://raw.githubusercontent.com/EQEmu/Server/master/utils/scripts/eqemu_update.pl", "eqemu_update.pl"); + get_remote_file("https://raw.githubusercontent.com/EQEmu/Server/bots_updater/utils/scripts/eqemu_update.pl", "eqemu_update.pl"); exit; } else{ @@ -205,7 +206,8 @@ else{ } sub do_update_self{ - get_remote_file("https://raw.githubusercontent.com/EQEmu/Server/master/utils/scripts/eqemu_update.pl", "eqemu_update.pl"); + #get_remote_file("https://raw.githubusercontent.com/EQEmu/Server/master/utils/scripts/eqemu_update.pl", "eqemu_update.pl"); + get_remote_file("https://raw.githubusercontent.com/EQEmu/Server/bots_updater/utils/scripts/eqemu_update.pl", "eqemu_update.pl"); die "Rerun eqemu_update.pl"; } @@ -308,7 +310,8 @@ sub check_for_database_dump_script{ } else{ print "db_dumper.pl not found... retrieving...\n\n"; - get_remote_file("https://raw.githubusercontent.com/EQEmu/Server/master/utils/scripts/db_dumper.pl", "db_dumper.pl"); + #get_remote_file("https://raw.githubusercontent.com/EQEmu/Server/master/utils/scripts/db_dumper.pl", "db_dumper.pl"); + get_remote_file("https://raw.githubusercontent.com/EQEmu/Server/bots_updater/utils/scripts/db_dumper.pl", "db_dumper.pl"); } } @@ -897,12 +900,14 @@ sub run_database_check{ #::: Pull down bots database manifest if($bots_db_management == 1){ print "Retrieving latest bots database manifest...\n"; - get_remote_file("https://raw.githubusercontent.com/EQEmu/Server/master/utils/sql/git/bots/bots_db_update_manifest.txt", "db_update/db_update_manifest.txt"); + #get_remote_file("https://raw.githubusercontent.com/EQEmu/Server/master/utils/sql/git/bots/bots_db_update_manifest.txt", "db_update/db_update_manifest.txt"); + get_remote_file("https://raw.githubusercontent.com/EQEmu/Server/bots_updater/utils/sql/git/bots/bots_db_update_manifest.txt", "db_update/db_update_manifest.txt"); } #::: Pull down mainstream database manifest else{ print "Retrieving latest database manifest...\n"; - get_remote_file("https://raw.githubusercontent.com/EQEmu/Server/master/utils/sql/db_update_manifest.txt", "db_update/db_update_manifest.txt"); + #get_remote_file("https://raw.githubusercontent.com/EQEmu/Server/master/utils/sql/db_update_manifest.txt", "db_update/db_update_manifest.txt"); + get_remote_file("https://raw.githubusercontent.com/EQEmu/Server/bots_updater/utils/sql/db_update_manifest.txt", "db_update/db_update_manifest.txt"); } } @@ -1017,10 +1022,12 @@ sub fetch_missing_db_update{ $update_file = $_[1]; if($db_update >= 9000){ if($bots_db_management == 1){ - get_remote_file("https://raw.githubusercontent.com/EQEmu/Server/master/utils/sql/git/bots/required/" . $update_file, "db_update/" . $update_file . ""); + #get_remote_file("https://raw.githubusercontent.com/EQEmu/Server/master/utils/sql/git/bots/required/" . $update_file, "db_update/" . $update_file . ""); + get_remote_file("https://raw.githubusercontent.com/EQEmu/Server/bots_updater/utils/sql/git/bots/required/" . $update_file, "db_update/" . $update_file . ""); } else{ - get_remote_file("https://raw.githubusercontent.com/EQEmu/Server/master/utils/sql/git/required/" . $update_file, "db_update/" . $update_file . ""); + #get_remote_file("https://raw.githubusercontent.com/EQEmu/Server/master/utils/sql/git/required/" . $update_file, "db_update/" . $update_file . ""); + get_remote_file("https://raw.githubusercontent.com/EQEmu/Server/bots_updater/utils/sql/git/required/" . $update_file, "db_update/" . $update_file . ""); } } elsif($db_update >= 5000 && $db_update <= 9000){ diff --git a/utils/sql/git/bots/README b/utils/sql/git/bots/README index f3aaa0c16..844709fb9 100644 --- a/utils/sql/git/bots/README +++ b/utils/sql/git/bots/README @@ -3,4 +3,4 @@ Use the eqemu_update.pl script to source/update bot information into your databa Developers: Please prefix 'bots_' to sql file description (after the date) in order to prevent issues naming conflicts. -Example: 1980_01_01_bots_file_description.sql \ No newline at end of file +Example: 1970_01_01_bots_file_description.sql diff --git a/utils/sql/git/bots/required/2015_09_30_bots.sql b/utils/sql/git/bots/required/2015_09_30_bots.sql index 88a1789d6..2f827c779 100644 --- a/utils/sql/git/bots/required/2015_09_30_bots.sql +++ b/utils/sql/git/bots/required/2015_09_30_bots.sql @@ -124,9 +124,9 @@ BEGIN `class` TINYINT(2) NOT NULL DEFAULT '0', `level` TINYINT(2) UNSIGNED NOT NULL DEFAULT '0', `deity` INT(11) UNSIGNED NOT NULL DEFAULT '0', -- Unused - `creation_day` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, - `last_spawn` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00', - `time_spawned` INT(10) UNSIGNED NOT NULL DEFAULT '0', + `creation_day` INT(11) UNSIGNED NOT NULL DEFAULT UNIX_TIMESTAMP, + `last_spawn` INT(11) UNSIGNED NOT NULL DEFAULT '0', + `time_spawned` INT(11) UNSIGNED NOT NULL DEFAULT '0', `size` FLOAT NOT NULL DEFAULT '0', `face` INT(10) NOT NULL DEFAULT '1', `hair_color` INT(10) NOT NULL DEFAULT '1', @@ -156,6 +156,7 @@ BEGIN `disease` SMALLINT(5) NOT NULL DEFAULT '0', `corruption` SMALLINT(5) NOT NULL DEFAULT '0', `show_helm` INT(11) UNSIGNED NOT NULL DEFAULT '0', -- Unused + `follow_distance` INT(11) UNSIGNED NOT NULL DEFAULT '200', -- Unused PRIMARY KEY (`bot_id`) ) ENGINE=InnoDB; CREATE TABLE `bot_inspect_messages` ( @@ -219,8 +220,8 @@ BEGIN `Race`, `Class`, `BotLevel`, - `BotCreateDate`, - `LastSpawnDate`, + UNIX_TIMESTAMP(`BotCreateDate`), + UNIX_TIMESTAMP(`LastSpawnDate`), `TotalPlayTime`, `Size`, `Face`, @@ -655,7 +656,7 @@ DROP PROCEDURE IF EXISTS `LoadBotsSchema`; -- Functions DELIMITER $$ --- (no code references) +-- (no code references - see `vw_groups` below) CREATE FUNCTION `GetMobType` (mob_name VARCHAR(64)) RETURNS CHAR(1) BEGIN DECLARE Result CHAR(1); diff --git a/zone/bot.cpp b/zone/bot.cpp index d515303e7..3d01f53aa 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -1563,7 +1563,6 @@ bool Bot::Save() " `race`," " `class`," " `level`," - /*creation_day - not needed for bot creation*/ " `last_spawn`," " `time_spawned`," " `size`," @@ -1605,8 +1604,7 @@ bool Bot::Save() " '%i'," /*race*/ " '%i'," /*class*/ " '%u'," /*level*/ - /*creation_day*/ - " NOW()," /*last_spawn*/ + " UNIX_TIMESTAMP(),"/*last_spawn*/ " 0," /*time_spawned*/ " '%f'," /*size*/ " '%i'," /*face*/ @@ -1705,8 +1703,7 @@ bool Bot::Save() " `race` = '%i'," " `class` = '%i'," " `level` = '%u'," - /*creation_day - check to see how client is handled*/ - " `last_spawn` = NOW()," + " `last_spawn` = UNIX_TIMESTAMP()," " `time_spawned` = '%u'," " `size` = '%f'," " `face` = '%i'," @@ -1735,7 +1732,7 @@ bool Bot::Save() " `magic` = '%i'," " `poison` = '%i'," " `disease` = '%i'," - " `corruption` = '%i'," + " `corruption` = '%i'" " WHERE `bot_id` = '%u'", _botOwnerCharacterID, this->GetBotSpellID(), @@ -1746,7 +1743,6 @@ bool Bot::Save() _baseRace, this->GetClass(), this->GetLevel(), - /*creation_day*/ GetTotalPlayTime(), GetSize(), this->GetLuclinFace(), @@ -1892,7 +1888,7 @@ void Bot::LoadBuffs() " `duration_formula`," " `tics_remaining`," " `poison_counters`," - " `disease_counters," + " `disease_counters`," " `curse_counters`," " `corruption_counters`," " `numhits`," @@ -1905,7 +1901,7 @@ void Bot::LoadBuffs() " `caston_z`," " `extra_di_chance`" " FROM `bot_buffs`" - " WHERE `bot_id` = %u", + " WHERE `bot_id` = '%u'", GetBotID() ); auto results = database.QueryDatabase(query); @@ -2091,7 +2087,7 @@ uint32 Bot::SavePetStats(std::string petName, uint32 petMana, uint32 petHitPoint petHitPoints ); auto results = database.QueryDatabase(query); - return 0; + return results.LastInsertedID(); } void Bot::SavePetBuffs(SpellBuff_Struct* petBuffs, uint32 botPetSaveId) @@ -3421,9 +3417,9 @@ void Bot::GetBotItems(std::string* errorMessage, Inventory &inv) " `inst_color`," " `augment_1`," " `augment_2`," - " `augslot_3`," - " `augslot_4`, " - " `augslot_5`," + " `augment_3`," + " `augment_4`, " + " `augment_5`," " `inst_no_drop`" " FROM `bot_inventories`" " WHERE `bot_id` = %i" @@ -3871,38 +3867,39 @@ std::list Bot::ListSpawnedBots(uint32 characterID, std::string* return spawnedBots; } -void Bot::SaveBotGroup(Group* botGroup, std::string botGroupName, std::string* errorMessage) { +void Bot::SaveBotGroup(Group* botGroup, std::string botGroupName, std::string* errorMessage) +{ if(!botGroup || botGroupName.empty()) - return; - - Mob* tempGroupLeader = botGroup->GetLeader(); - if(!tempGroupLeader->IsBot()) - return; - - uint32 botGroupId = 0; - uint32 botGroupLeaderBotId = tempGroupLeader->CastToBot()->GetBotID(); - std::string query = StringFormat("INSERT INTO `bot_groups` (`group_leader_id`, `group_name`) VALUES (%u, '%s')", botGroupLeaderBotId, botGroupName.c_str()); - auto results = database.QueryDatabase(query); - if(!results.Success()) { - *errorMessage = std::string(results.ErrorMessage()); - return; - } - - if(botGroupId == 0) - return; - - for(int groupMemberIndex = 0; groupMemberIndex < botGroup->GroupCount(); groupMemberIndex++) { - Mob* tempBot = botGroup->members[groupMemberIndex]; - if(!tempBot || !tempBot->IsBot()) - continue; - - uint32 botGroupMemberBotId = tempBot->CastToBot()->GetBotID(); - query = StringFormat("INSERT INTO `bot_group_members` (`groups_index`, `bot_id`) VALUES (%u, %u)", botGroupId, botGroupMemberBotId); - results = database.QueryDatabase(query); - if(!results.Success()) - *errorMessage = std::string(results.ErrorMessage()); - } + return; + + Mob* tempGroupLeader = botGroup->GetLeader(); + if(!tempGroupLeader->IsBot()) + return; + + uint32 botGroupId = 0; + uint32 botGroupLeaderBotId = tempGroupLeader->CastToBot()->GetBotID(); + std::string query = StringFormat("INSERT INTO `bot_groups` (`group_leader_id`, `group_name`) VALUES (%u, '%s')", botGroupLeaderBotId, botGroupName.c_str()); + auto results = database.QueryDatabase(query); + if(!results.Success()) { + *errorMessage = std::string(results.ErrorMessage()); + return; + } + botGroupId = results.LastInsertedID(); + if(botGroupId == 0) + return; + + for(int groupMemberIndex = 0; groupMemberIndex < botGroup->GroupCount(); groupMemberIndex++) { + Mob* tempBot = botGroup->members[groupMemberIndex]; + if(!tempBot || !tempBot->IsBot()) + continue; + + uint32 botGroupMemberBotId = tempBot->CastToBot()->GetBotID(); + query = StringFormat("INSERT INTO `bot_group_members` (`groups_index`, `bot_id`) VALUES (%u, %u)", botGroupId, botGroupMemberBotId); + results = database.QueryDatabase(query); + if(!results.Success()) + *errorMessage = std::string(results.ErrorMessage()); + } } void Bot::DeleteBotGroup(std::string botGroupName, std::string* errorMessage) {