]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Random items: Polish.
authorLyberta <lyberta@lyberta.net>
Sat, 30 Sep 2017 09:39:56 +0000 (12:39 +0300)
committerLyberta <lyberta@lyberta.net>
Sat, 30 Sep 2017 09:39:56 +0000 (12:39 +0300)
qcsrc/common/mutators/mutator/random_items/sv_random_items.qc
qcsrc/server/items.qc
qcsrc/server/items.qh

index 22e0c77c456ff4506092eee8988b881c43df7563..10bbadd68a8518f20922f9541fb2d863afa6711d 100644 (file)
@@ -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;
 }
 
index 0f5735d9ee705b354950984009001715937b798b..0b20af1c4fa2e85d9d9b9a12038204fb266f01cc 100644 (file)
 
 .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)
index bb2af40fbbe446444bb6289c42232e9276c88e06..37b7d10c6fed2eb8fa6ca97457cbdd5bd3a31d7c 100644 (file)
@@ -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.