From d69fddf8b4e4a4fd105abcf79a815be20293bb2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Valentin=20Gr=C3=BCnbacher?= Date: Sun, 10 May 2015 23:45:01 +0200 Subject: [PATCH] Engine/Core: Move precache_event() to core --- amxmodx/amxmodx.cpp | 8 ++++++++ modules/engine/engine.cpp | 9 --------- plugins/include/amxmodx.inc | 19 +++++++++++++++++++ plugins/include/engine.inc | 19 ------------------- 4 files changed, 27 insertions(+), 28 deletions(-) diff --git a/amxmodx/amxmodx.cpp b/amxmodx/amxmodx.cpp index 2aa0efaf..90398e30 100755 --- a/amxmodx/amxmodx.cpp +++ b/amxmodx/amxmodx.cpp @@ -2806,6 +2806,14 @@ static cell AMX_NATIVE_CALL precache_generic(AMX *amx, cell *params) return PRECACHE_GENERIC((char*)STRING(ALLOC_STRING(sptemp))); } +static cell AMX_NATIVE_CALL precache_event(AMX *amx, cell *params) +{ + int len; + char *sptemp = format_amxstring(amx, params, 2, len); + + return PRECACHE_EVENT(params[1], (char*)STRING(ALLOC_STRING(sptemp))); +} + static cell AMX_NATIVE_CALL random_float(AMX *amx, cell *params) /* 2 param */ { float one = amx_ctof(params[1]); diff --git a/modules/engine/engine.cpp b/modules/engine/engine.cpp index a635fd4b..f996f8ef 100644 --- a/modules/engine/engine.cpp +++ b/modules/engine/engine.cpp @@ -366,14 +366,6 @@ static cell AMX_NATIVE_CALL get_decal_index(AMX *amx, cell *params) return DECAL_INDEX(szDecal); } -static cell AMX_NATIVE_CALL precache_event(AMX *amx, cell *params) -{ - int len; - char *szEvent = MF_FormatAmxString(amx, params, 2, &len); - return PRECACHE_EVENT(params[1], (char *)STRING(ALLOC_STRING(szEvent))); - -} - static cell AMX_NATIVE_CALL get_info_keybuffer(AMX *amx, cell *params) { int iEnt = params[1]; @@ -1032,7 +1024,6 @@ AMX_NATIVE_INFO engine_Natives[] = { {"set_speak", set_speak}, {"get_speak", get_speak}, - {"precache_event", precache_event}, {"playback_event", playback_event}, {"set_view", set_view}, diff --git a/plugins/include/amxmodx.inc b/plugins/include/amxmodx.inc index b58239de..46ae4431 100755 --- a/plugins/include/amxmodx.inc +++ b/plugins/include/amxmodx.inc @@ -248,6 +248,25 @@ native precache_sound(const name[]); */ native precache_generic(const szFile[]); +/** + * Precaches an event file. + * + * @note The event type should always be 1. + * @note Contrary to the other precache_* natives, this can be used outside of + * the plugin_precache() forward, e.g. in plugin_init() or plugin_cfg(). + * A bug in some clients makes this necessary, as plugin_precache() is + * called before the mod has precached its own, default event files. This + * can cause the event table to be misaligned on the client, leading to + * visual and audio bugs that are hard to diagnose. + * + * @param type Event type + * @param Name Formatting rules, path to the event file + * @param ... Variable number of formatting parameters + * + * @return Unique cache id of the event + */ +native precache_event(type, const Name[], any:...); + /** * Changes the map. * diff --git a/plugins/include/engine.inc b/plugins/include/engine.inc index 9d9bcdbd..ae3bd98a 100755 --- a/plugins/include/engine.inc +++ b/plugins/include/engine.inc @@ -151,25 +151,6 @@ native unregister_touch(registerid); */ native unregister_think(registerid); -/** - * Precaches an event file. - * - * @note The event type should always be 1. - * @note Contrary to the other precache_* natives, this can be used outside of - * the plugin_precache() forward, e.g. in plugin_init() or plugin_cfg(). - * A bug in some clients makes this necessary, as plugin_precache() is - * called before the mod has precached its own, default event files. This - * can cause the event table to be misaligned on the client, leading to - * visual and audio bugs that are hard to diagnose. - * - * @param type Event type - * @param Name Formatting rules, path to the event file - * @param ... Variable number of formatting parameters - * - * @return Unique cache id of the event - */ -native precache_event(type, const Name[], any:...); - /** * Sets the engine module speak flags on a client. *