mirror of
https://github.com/ErikasKontenis/SabrehavenServer.git
synced 2025-12-20 08:27:11 +01:00
introduce changes from streamside fork
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
/**
|
||||
* Tibia GIMUD Server - a free and open-source MMORPG server emulator
|
||||
* Copyright (C) 2017 Alejandro Mujica <alejandrodemujica@gmail.com>
|
||||
* Copyright (C) 2019 Sabrehaven and Mark Samman <mark.samman@gmail.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@@ -36,9 +36,6 @@ TalkActions::~TalkActions()
|
||||
|
||||
void TalkActions::clear()
|
||||
{
|
||||
for (TalkAction* talkAction : talkActions) {
|
||||
delete talkAction;
|
||||
}
|
||||
talkActions.clear();
|
||||
|
||||
scriptInterface.reInitState();
|
||||
@@ -64,15 +61,17 @@ Event* TalkActions::getEvent(const std::string& nodeName)
|
||||
|
||||
bool TalkActions::registerEvent(Event* event, const pugi::xml_node&)
|
||||
{
|
||||
talkActions.push_front(static_cast<TalkAction*>(event)); // event is guaranteed to be a TalkAction
|
||||
auto talkAction = std::unique_ptr<TalkAction>(static_cast<TalkAction*>(event)); // event is guaranteed to be a TalkAction
|
||||
talkActions.push_front(std::move(*talkAction));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
TalkActionResult_t TalkActions::playerSaySpell(Player* player, SpeakClasses type, const std::string& words) const
|
||||
{
|
||||
size_t wordsLength = words.length();
|
||||
for (TalkAction* talkAction : talkActions) {
|
||||
const std::string& talkactionWords = talkAction->getWords();
|
||||
for (const TalkAction& talkAction : talkActions) {
|
||||
const std::string& talkactionWords = talkAction.getWords();
|
||||
size_t talkactionLength = talkactionWords.length();
|
||||
if (wordsLength < talkactionLength || strncasecmp(words.c_str(), talkactionWords.c_str(), talkactionLength) != 0) {
|
||||
continue;
|
||||
@@ -86,7 +85,7 @@ TalkActionResult_t TalkActions::playerSaySpell(Player* player, SpeakClasses type
|
||||
}
|
||||
trim_left(param, ' ');
|
||||
|
||||
char separator = talkAction->getSeparator();
|
||||
char separator = talkAction.getSeparator();
|
||||
if (separator != ' ') {
|
||||
if (!param.empty()) {
|
||||
if (param.front() != separator) {
|
||||
@@ -98,7 +97,7 @@ TalkActionResult_t TalkActions::playerSaySpell(Player* player, SpeakClasses type
|
||||
}
|
||||
}
|
||||
|
||||
if (talkAction->executeSay(player, param, type)) {
|
||||
if (talkAction.executeSay(player, param, type)) {
|
||||
return TALKACTION_CONTINUE;
|
||||
} else {
|
||||
return TALKACTION_BREAK;
|
||||
|
||||
Reference in New Issue
Block a user