| 313 | } |
| 314 | |
| 315 | void ScriptHandler::DeregisterScriptAction(void *, calldata_t *data) |
| 316 | { |
| 317 | const char *actionName; |
| 318 | if (!calldata_get_string(data, nameParam.data(), &actionName) || |
| 319 | strlen(actionName) == 0) { |
| 320 | blog(LOG_WARNING, "[%s] failed! \"%s\" parameter missing!", |
| 321 | deregisterActionFuncName.data(), nameParam.data()); |
| 322 | RETURN_FAILURE(); |
| 323 | } |
| 324 | |
| 325 | const std::string id = nameToScriptID(actionName); |
| 326 | std::lock_guard<std::mutex> lock(_mutex); |
| 327 | |
| 328 | if (_actions.count(id) == 0) { |
| 329 | blog(LOG_WARNING, |
| 330 | "[%s] failed! Action \"%s\" was never registered!", |
| 331 | deregisterActionFuncName.data(), id.c_str()); |
| 332 | RETURN_FAILURE(); |
| 333 | } |
| 334 | |
| 335 | if (!MacroActionFactory::Deregister(id)) { |
| 336 | blog(LOG_WARNING, |
| 337 | "[%s] failed! Action id \"%s\" does not exist!", |
| 338 | deregisterActionFuncName.data(), id.c_str()); |
| 339 | RETURN_FAILURE(); |
| 340 | } |
| 341 | |
| 342 | auto it = _actions.find(id); |
| 343 | if (it != _actions.end()) { |
| 344 | _actions.erase(it); |
| 345 | } |
| 346 | |
| 347 | RETURN_SUCCESS(); |
| 348 | } |
| 349 | |
| 350 | void ScriptHandler::RegisterScriptCondition(void *, calldata_t *data) |
| 351 | { |