X-Git-Url: http://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fitems.qc;h=b21df78e3f247cb53b809446f95a555c25c86bcb;hb=97090df832317a4b885be09b00f33ff6175823d5;hp=7d248834f72566af97313317a42a3a50c226f637;hpb=b945d959784e5b249c66aea4f3326d8ae048f1cd;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/items.qc b/qcsrc/server/items.qc index 7d248834f..b21df78e3 100644 --- a/qcsrc/server/items.qc +++ b/qcsrc/server/items.qc @@ -5,14 +5,43 @@ /// game items. /// \copyright GNU GPLv2 or any later version. -#include "g_subs.qh" +#include #include +#include .bool m_isloot; ///< Holds whether item is loot. /// \brief Holds whether strength, shield or superweapon timers expire while /// this item is on the ground. .bool m_isexpiring; +entity Item_FindDefinition(string class_name) +{ + FOREACH(Items, it.m_canonical_spawnfunc == class_name, + { + return it; + }); + FOREACH(Weapons, it.m_canonical_spawnfunc == class_name, + { + return it.m_pickup; + }); + return NULL; +} + +bool Item_IsAllowed(string class_name) +{ + entity definition = Item_FindDefinition(class_name); + if (definition == NULL) + { + return false; + } + return Item_IsDefinitionAllowed(definition); +} + +bool Item_IsDefinitionAllowed(entity definition) +{ + return !MUTATOR_CALLHOOK(FilterItemDefinition, definition); +} + entity Item_Create(string class_name, vector position, bool no_align) { entity item = spawn();