mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 18:52:22 +00:00
[Bug Fix] Allow Songs to be scribed from scrolls (#2460)
* [Bug Fix] Allow Songs to be scribed from scrolls Songs weren't capable of being scribed from scrolls because we didn't check for `Song: ` in the name. Converted old logic to substrings, can probably do it cleaner, but it's better than it was. Removed extraneous `initiator->IsClient()` calls as `initiator` is **always** a client. * Fix substr logic.
This commit is contained in:
+61
-75
@@ -398,7 +398,7 @@ void QuestManager::addloot(int item_id, int charges, bool equipitem, int aug1, i
|
||||
|
||||
void QuestManager::Zone(const char *zone_name) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
if (initiator && initiator->IsClient())
|
||||
if (initiator)
|
||||
{
|
||||
initiator->MoveZone(zone_name);
|
||||
}
|
||||
@@ -406,7 +406,7 @@ void QuestManager::Zone(const char *zone_name) {
|
||||
|
||||
void QuestManager::ZoneGroup(const char *zone_name) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
if (initiator && initiator->IsClient()) {
|
||||
if (initiator) {
|
||||
if (!initiator->GetGroup()) {
|
||||
initiator->MoveZone(zone_name);
|
||||
} else {
|
||||
@@ -423,7 +423,7 @@ void QuestManager::ZoneGroup(const char *zone_name) {
|
||||
|
||||
void QuestManager::ZoneRaid(const char *zone_name) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
if (initiator && initiator->IsClient()) {
|
||||
if (initiator) {
|
||||
if (!initiator->GetRaid()) {
|
||||
initiator->MoveZone(zone_name);
|
||||
} else {
|
||||
@@ -935,96 +935,82 @@ void QuestManager::changedeity(int deity_id) {
|
||||
//Changes the deity.
|
||||
if(initiator)
|
||||
{
|
||||
if(initiator->IsClient())
|
||||
{
|
||||
initiator->SetDeity(deity_id);
|
||||
initiator->Message(Chat::Yellow,"Your Deity has been changed/set to: %i", deity_id);
|
||||
initiator->Save(1);
|
||||
initiator->Kick("Deity change by QuestManager");
|
||||
}
|
||||
else
|
||||
{
|
||||
initiator->Message(Chat::Yellow,"Error changing Deity");
|
||||
}
|
||||
initiator->SetDeity(deity_id);
|
||||
initiator->Message(Chat::Yellow,"Your Deity has been changed/set to: %i", deity_id);
|
||||
initiator->Save(1);
|
||||
initiator->Kick("Deity change by QuestManager");
|
||||
}
|
||||
}
|
||||
|
||||
void QuestManager::exp(int amt) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
if (initiator && initiator->IsClient())
|
||||
if (initiator)
|
||||
initiator->AddEXP(amt);
|
||||
}
|
||||
|
||||
void QuestManager::level(int newlevel) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
if (initiator && initiator->IsClient())
|
||||
if (initiator)
|
||||
initiator->SetLevel(newlevel, true);
|
||||
}
|
||||
|
||||
void QuestManager::traindisc(int discipline_tome_item_id) {
|
||||
void QuestManager::traindisc(uint32 discipline_tome_item_id) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
if (initiator && initiator->IsClient())
|
||||
if (initiator) {
|
||||
initiator->TrainDiscipline(discipline_tome_item_id);
|
||||
}
|
||||
}
|
||||
|
||||
bool QuestManager::isdisctome(int item_id) {
|
||||
const EQ::ItemData *item = database.GetItem(item_id);
|
||||
if(item == nullptr) {
|
||||
return(false);
|
||||
bool QuestManager::isdisctome(uint32 item_id) {
|
||||
const auto &item = database.GetItem(item_id);
|
||||
if (!item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!item->IsClassCommon() || item->ItemType != EQ::item::ItemTypeSpell) {
|
||||
return(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
//Need a way to determine the difference between a spell and a tome
|
||||
//so they cant turn in a spell and get it as a discipline
|
||||
//this is kinda a hack:
|
||||
if(!(
|
||||
item->Name[0] == 'T' &&
|
||||
item->Name[1] == 'o' &&
|
||||
item->Name[2] == 'm' &&
|
||||
item->Name[3] == 'e' &&
|
||||
item->Name[4] == ' '
|
||||
) && !(
|
||||
item->Name[0] == 'S' &&
|
||||
item->Name[1] == 'k' &&
|
||||
item->Name[2] == 'i' &&
|
||||
item->Name[3] == 'l' &&
|
||||
item->Name[4] == 'l' &&
|
||||
item->Name[5] == ':' &&
|
||||
item->Name[6] == ' '
|
||||
)) {
|
||||
return(false);
|
||||
|
||||
const std::string item_name = item->Name;
|
||||
|
||||
if (
|
||||
strcmp(item_name.substr(0, 5).c_str(), "Tome ") &&
|
||||
strcmp(item_name.substr(0, 7).c_str(), "Skill: ")
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//we know for sure none of the int casters get disciplines
|
||||
uint32 cbit = 0;
|
||||
cbit |= 1 << (WIZARD-1);
|
||||
cbit |= 1 << (ENCHANTER-1);
|
||||
cbit |= 1 << (MAGICIAN-1);
|
||||
cbit |= 1 << (NECROMANCER-1);
|
||||
if(item->Classes & cbit) {
|
||||
return(false);
|
||||
uint32 class_bit = 0;
|
||||
class_bit |= 1 << (WIZARD - 1);
|
||||
class_bit |= 1 << (ENCHANTER - 1);
|
||||
class_bit |= 1 << (MAGICIAN - 1);
|
||||
class_bit |= 1 << (NECROMANCER - 1);
|
||||
if (item->Classes & class_bit) {
|
||||
return false;
|
||||
}
|
||||
|
||||
uint32 spell_id = item->Scroll.Effect;
|
||||
if(!IsValidSpell(spell_id)) {
|
||||
return(false);
|
||||
const auto& spell_id = static_cast<uint32>(item->Scroll.Effect);
|
||||
if (!IsValidSpell(spell_id)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//we know for sure none of the int casters get disciplines
|
||||
const SPDat_Spell_Struct &spell = spells[spell_id];
|
||||
const auto& spell = spells[spell_id];
|
||||
if(
|
||||
spell.classes[WIZARD - 1] != 255 &&
|
||||
spell.classes[ENCHANTER - 1] != 255 &&
|
||||
spell.classes[MAGICIAN - 1] != 255 &&
|
||||
spell.classes[NECROMANCER - 1] != 255
|
||||
) {
|
||||
return(false);
|
||||
return false;
|
||||
}
|
||||
|
||||
return(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string QuestManager::getracename(uint16 race_id) {
|
||||
@@ -1066,7 +1052,7 @@ std::string QuestManager::getconsiderlevelname(uint8 consider_level) {
|
||||
|
||||
void QuestManager::safemove() {
|
||||
QuestManagerCurrentQuestVars();
|
||||
if (initiator && initiator->IsClient())
|
||||
if (initiator)
|
||||
initiator->GoToSafeCoords(zone->GetZoneID(), zone->GetInstanceID());
|
||||
}
|
||||
|
||||
@@ -1091,7 +1077,7 @@ void QuestManager::snow(int weather) {
|
||||
|
||||
void QuestManager::rename(std::string name) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
if (initiator && initiator->IsClient()) {
|
||||
if (initiator) {
|
||||
std::string current_name = initiator->GetName();
|
||||
if (initiator->ChangeFirstName(name.c_str(), current_name.c_str())) {
|
||||
initiator->Message(
|
||||
@@ -1117,7 +1103,7 @@ void QuestManager::rename(std::string name) {
|
||||
void QuestManager::surname(std::string last_name) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
//Changes the last name.
|
||||
if (initiator && initiator->IsClient()) {
|
||||
if (initiator) {
|
||||
initiator->ChangeLastName(last_name);
|
||||
initiator->Message(
|
||||
Chat::White,
|
||||
@@ -1208,19 +1194,19 @@ void QuestManager::pvp(const char *mode) {
|
||||
|
||||
void QuestManager::movepc(int zone_id, float x, float y, float z, float heading) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
if (initiator && initiator->IsClient())
|
||||
if (initiator)
|
||||
initiator->MovePC(zone_id, x, y, z, heading);
|
||||
}
|
||||
|
||||
void QuestManager::gmmove(float x, float y, float z) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
if (initiator && initiator->IsClient())
|
||||
if (initiator)
|
||||
initiator->GMMove(x, y, z);
|
||||
}
|
||||
|
||||
void QuestManager::movegrp(int zoneid, float x, float y, float z) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
if (initiator && initiator->IsClient())
|
||||
if (initiator)
|
||||
{
|
||||
Group *g = entity_list.GetGroupByClient(initiator);
|
||||
if (g != nullptr) {
|
||||
@@ -1253,13 +1239,13 @@ void QuestManager::addskill(int skill_id, int value) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
if (skill_id < 0 || skill_id > EQ::skills::HIGHEST_SKILL)
|
||||
return;
|
||||
if (initiator && initiator->IsClient())
|
||||
if (initiator)
|
||||
initiator->AddSkill((EQ::skills::SkillType) skill_id, value);
|
||||
}
|
||||
|
||||
void QuestManager::setlanguage(int skill_id, int value) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
if (initiator && initiator->IsClient())
|
||||
if (initiator)
|
||||
initiator->SetLanguageSkill(skill_id, value);
|
||||
}
|
||||
|
||||
@@ -1267,7 +1253,7 @@ void QuestManager::setskill(int skill_id, int value) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
if (skill_id < 0 || skill_id > EQ::skills::HIGHEST_SKILL)
|
||||
return;
|
||||
if (initiator && initiator->IsClient())
|
||||
if (initiator)
|
||||
initiator->SetSkill((EQ::skills::SkillType) skill_id, value);
|
||||
}
|
||||
|
||||
@@ -1275,7 +1261,7 @@ void QuestManager::setallskill(int value) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
if (!initiator)
|
||||
return;
|
||||
if (initiator && initiator->IsClient()) {
|
||||
if (initiator) {
|
||||
EQ::skills::SkillType sk;
|
||||
for (sk = EQ::skills::Skill1HBlunt; sk <= EQ::skills::HIGHEST_SKILL; sk = (EQ::skills::SkillType)(sk + 1)) {
|
||||
initiator->SetSkill(sk, value);
|
||||
@@ -1329,14 +1315,14 @@ void QuestManager::attacknpctype(int npc_type_id) {
|
||||
|
||||
void QuestManager::save() {
|
||||
QuestManagerCurrentQuestVars();
|
||||
if (initiator && initiator->IsClient())
|
||||
if (initiator)
|
||||
initiator->Save();
|
||||
}
|
||||
|
||||
void QuestManager::faction(int faction_id, int faction_value, int temp) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
running_quest run = quests_running_.top();
|
||||
if(run.owner->IsCharmed() == false && initiator && initiator->IsClient()) {
|
||||
if(run.owner->IsCharmed() == false && initiator) {
|
||||
if(faction_id != 0 && faction_value != 0) {
|
||||
initiator->SetFactionLevel2(
|
||||
initiator->CharacterID(),
|
||||
@@ -1352,7 +1338,7 @@ void QuestManager::faction(int faction_id, int faction_value, int temp) {
|
||||
|
||||
void QuestManager::rewardfaction(int faction_id, int faction_value) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
if (initiator && initiator->IsClient()) {
|
||||
if (initiator) {
|
||||
if (faction_id != 0 && faction_value != 0) {
|
||||
initiator->RewardFaction(faction_id, faction_value);
|
||||
}
|
||||
@@ -1371,7 +1357,7 @@ void QuestManager::setsky(uint8 new_sky) {
|
||||
|
||||
void QuestManager::setguild(uint32 new_guild_id, uint8 new_rank) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
if (initiator && initiator->IsClient()) {
|
||||
if (initiator) {
|
||||
guild_mgr.SetGuild(initiator->CharacterID(), new_guild_id, new_rank);
|
||||
}
|
||||
}
|
||||
@@ -1495,7 +1481,7 @@ void QuestManager::setglobal(const char *varname, const char *newvalue, int opti
|
||||
7 all all all
|
||||
*/
|
||||
|
||||
if (initiator && initiator->IsClient()){ // some events like waypoint and spawn don't have a player involved
|
||||
if (initiator){ // some events like waypoint and spawn don't have a player involved
|
||||
qgCharid=initiator->CharacterID();
|
||||
}
|
||||
else {
|
||||
@@ -1516,7 +1502,7 @@ void QuestManager::setglobal(const char *varname, const char *newvalue, int opti
|
||||
InsertQuestGlobal(qgCharid, qgNpcid, qgZoneid, varname, newvalue, QGVarDuration(duration));
|
||||
|
||||
/* QS: PlayerLogQGlobalUpdate */
|
||||
if (RuleB(QueryServ, PlayerLogQGlobalUpdate) && qgCharid && qgCharid > 0 && initiator && initiator->IsClient()){
|
||||
if (RuleB(QueryServ, PlayerLogQGlobalUpdate) && qgCharid && qgCharid > 0 && initiator){
|
||||
std::string event_desc = StringFormat("Update :: qglobal:%s to qvalue:%s zoneid:%i instid:%i", varname, newvalue, initiator->GetZoneID(), initiator->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_QGlobal_Update, qgCharid, event_desc);
|
||||
}
|
||||
@@ -1601,13 +1587,13 @@ void QuestManager::delglobal(const char *varname) {
|
||||
int qgCharid = 0;
|
||||
int qgNpcid = owner ? owner->GetNPCTypeID() : 0; // encounter scripts don't have an owner
|
||||
|
||||
if (initiator && initiator->IsClient()) // some events like waypoint and spawn don't have a player involved
|
||||
if (initiator) // some events like waypoint and spawn don't have a player involved
|
||||
qgCharid=initiator->CharacterID();
|
||||
else
|
||||
qgCharid=-qgNpcid; // make char id negative npc id as a fudge
|
||||
|
||||
/* QS: PlayerLogQGlobalUpdate */
|
||||
if (RuleB(QueryServ, PlayerLogQGlobalUpdate) && qgCharid && qgCharid > 0 && initiator && initiator->IsClient()){
|
||||
if (RuleB(QueryServ, PlayerLogQGlobalUpdate) && qgCharid && qgCharid > 0 && initiator){
|
||||
std::string event_desc = StringFormat("Deleted :: qglobal:%s zoneid:%i instid:%i", varname, initiator->GetZoneID(), initiator->GetInstanceID());
|
||||
QServ->PlayerLogEvent(Player_Log_QGlobal_Update, qgCharid, event_desc);
|
||||
}
|
||||
@@ -1701,21 +1687,21 @@ int QuestManager::QGVarDuration(const char *fmt)
|
||||
void QuestManager::ding() {
|
||||
QuestManagerCurrentQuestVars();
|
||||
//makes a sound.
|
||||
if (initiator && initiator->IsClient())
|
||||
if (initiator)
|
||||
initiator->SendSound();
|
||||
|
||||
}
|
||||
|
||||
void QuestManager::rebind(int zone_id, const glm::vec3& location) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
if(initiator && initiator->IsClient()) {
|
||||
if(initiator) {
|
||||
initiator->SetBindPoint(0, zone_id, 0, location);
|
||||
}
|
||||
}
|
||||
|
||||
void QuestManager::rebind(int zone_id, const glm::vec4& location) {
|
||||
QuestManagerCurrentQuestVars();
|
||||
if(initiator && initiator->IsClient()) {
|
||||
if(initiator) {
|
||||
initiator->SetBindPoint2(0, zone_id, 0, location);
|
||||
}
|
||||
}
|
||||
@@ -2244,7 +2230,7 @@ bool QuestManager::createBot(const char *name, const char *lastname, uint8 level
|
||||
QuestManagerCurrentQuestVars();
|
||||
uint32 MaxBotCreate = RuleI(Bots, CreationLimit);
|
||||
|
||||
if (initiator && initiator->IsClient())
|
||||
if (initiator)
|
||||
{
|
||||
if(Bot::SpawnedBotCount(initiator->CharacterID()) >= MaxBotCreate)
|
||||
{
|
||||
@@ -2571,7 +2557,7 @@ int QuestManager::getlevel(uint8 type)
|
||||
else
|
||||
return (initiator->GetLevel());
|
||||
}
|
||||
else if(type == 4 && initiator->IsClient())
|
||||
else if(type == 4)
|
||||
{
|
||||
return (initiator->CastToClient()->GetLevel2());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user