bool sampgdk_callback_invoke(AMX *amx, const char *name, int paramcount, cell *retval) { struct _sampgdk_callback_info *callback; struct _sampgdk_callback_info *callback_filter; cell params[_SAMPGDK_CALLBACK_MAX_ARGS + 1]; void **plugins; int num_plugins; int i; assert(amx != NULL); callback = _sampgdk_callback_find(name); callback_filter = sampgdk_array_get(&_sampgdk_callbacks, -1); assert(callback_filter != NULL); if (paramcount > _SAMPGDK_CALLBACK_MAX_ARGS) { sampgdk_log_error("Too many callback arguments (at most %d allowed)", _SAMPGDK_CALLBACK_MAX_ARGS); return true; } params[0] = paramcount * sizeof(cell); memcpy(¶ms[1], sampgdk_param_get_start(amx), params[0]); plugins = sampgdk_plugin_get_plugins(&num_plugins); for (i = 0; i < num_plugins; i++) { void *func; func = sampgdk_plugin_get_symbol(plugins[i], callback_filter->name); if (func != NULL && !((_sampgdk_callback_filter)func)(amx, name, params, retval)) { continue; } if (callback == NULL || callback->handler == NULL) { continue; } func = sampgdk_plugin_get_symbol(plugins[i], callback->name); if (func != NULL && !((sampgdk_callback)callback->handler)(amx, func, retval)) { return false; } } return true; }
static bool call_public_filter(void *plugin, AMX *amx, const char *name) { void *func; cell *params; func = sampgdk_plugin_get_symbol(plugin, "OnPublicCall"); if (func != NULL) { typedef bool (PLUGIN_CALL *public_filter)(AMX *amx, const char *name, cell *params); sampgdk_param_get_all(amx, true, ¶ms); return ((public_filter)func)(amx, name, params); } return true; }
static bool call_public_handler(void *plugin, AMX *amx, const char *name, cell *retval) { void *func; struct sampgdk_callback *callback; func = sampgdk_plugin_get_symbol(plugin, name); if (func != NULL) { callback = sampgdk_callback_find(name); if (callback != NULL) { return callback->handler(amx, func, retval); } } return true; }