From: Lyberta Date: Sat, 30 Sep 2017 09:39:56 +0000 (+0300) Subject: Random items: Polish. X-Git-Tag: xonotic-v0.8.5~2426^2~47 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=3020ecdb80e5324264dcf47399aef5030cb3af68;p=xonotic%2Fxonotic-data.pk3dir.git Random items: Polish. --- diff --git a/qcsrc/common/mutators/mutator/random_items/sv_random_items.qc b/qcsrc/common/mutators/mutator/random_items/sv_random_items.qc index 22e0c77c4..10bbadd68 100644 --- a/qcsrc/common/mutators/mutator/random_items/sv_random_items.qc +++ b/qcsrc/common/mutators/mutator/random_items/sv_random_items.qc @@ -989,16 +989,8 @@ entity RandomItems_ReplaceMapItem(entity item) return NULL; } random_items_is_spawning = true; - entity new_item = spawn(); - new_item.classname = strzone(new_classname); - new_item.spawnfunc_checked = true; - Item_Initialize(new_item, new_classname); + entity new_item = Item_Create(strzone(new_classname), item.origin); random_items_is_spawning = false; - if (wasfreed(new_item)) - { - return NULL; - } - setorigin(new_item, item.origin); return new_item; } diff --git a/qcsrc/server/items.qc b/qcsrc/server/items.qc index 0f5735d9e..0b20af1c4 100644 --- a/qcsrc/server/items.qc +++ b/qcsrc/server/items.qc @@ -10,6 +10,20 @@ .bool m_isloot; ///< Holds whether item is loot. +entity Item_Create(string class_name, vector position) +{ + entity item = spawn(); + item.classname = class_name; + item.spawnfunc_checked = true; + Item_Initialize(item, class_name); + if (wasfreed(item)) + { + return NULL; + } + setorigin(item, position); + return item; +} + void Item_Initialize(entity item, string class_name) { switch (class_name) diff --git a/qcsrc/server/items.qh b/qcsrc/server/items.qh index bb2af40fb..37b7d10c6 100644 --- a/qcsrc/server/items.qh +++ b/qcsrc/server/items.qh @@ -4,10 +4,18 @@ #pragma once +/// \brief Creates a new item. +/// \param[in] class_name Class name of the item. +/// \param[in] position Position of the item. +/// \return Item on success, NULL otherwise. +entity Item_Create(string class_name, vector position); + /// \brief Initializes the item according to classname. /// \param[in,out] item Item to initialize. /// \param[in] class_name Class name to use. /// \return No return. +/// \nore This function is useful if you want to set some item properties before +/// initialization. void Item_Initialize(entity item, string class_name); /// \brief Creates a loot item.