]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/items/spawning.qh
Convert 5 trivial Item_* functions to macros
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / items / spawning.qh
index b44ec15d088a0bcea6cdba685390f27746abe9b5..7b19292c614a99ccc1a4c75af4e9c5e02f116228 100644 (file)
@@ -8,6 +8,10 @@ bool startitem_failed;
 
 /// \brief lifetime < 0 means permanent (not loot), lifetime > 0 overrides the default
 .float lifetime;
+/// \brief Holds whether item is loot.
+.bool m_isloot;
+/// \brief Holds whether strength, shield or superweapon timers expire while this item is on the ground.
+.bool m_isexpiring;
 
 /// \brief Checks whether the items with the specified definition are allowed to
 /// spawn.
@@ -28,30 +32,30 @@ bool Item_Initialise(entity item);
 /// \brief Returns whether the item is loot.
 /// \param[in] item Item to check.
 /// \return True if the item is loot, false otherwise.
-bool Item_IsLoot(entity item);
+#define ITEM_IS_LOOT(item) (item.m_isloot || item.classname == "droppedweapon")
 
 /// \brief Sets the item loot status.
 /// \param[in,out] item Item to adjust.
 /// \param[in] loot Whether item is loot.
 /// \return No return.
-void Item_SetLoot(entity item, bool loot);
+#define ITEM_SET_LOOT(item, loot) (item.m_isloot = loot)
 
 /// \brief Returns whether item should keep its position or be dropped to the
 /// ground.
 /// \param[in] item Item to check.
 /// \return True if item should keep its position or false if it should be
 /// dropped to the ground.
-bool Item_ShouldKeepPosition(entity item);
+#define ITEM_SHOULD_KEEP_POSITION(item) (item.noalign || item.spawnflags & 1)
 
 /// \brief Returns whether the item is expiring (i.e. its strength, shield and
 /// superweapon timers expire while it is on the ground).
 /// \param[in] item Item to check.
 /// \return True if the item is expiring, false otherwise.
-bool Item_IsExpiring(entity item);
+#define ITEM_IS_EXPIRING(item) (item.m_isexpiring)
 
 /// \brief Sets the item expiring status (i.e. whether its strength, shield
 /// and superweapon timers expire while it is on the ground).
 /// \param[in,out] item Item to adjust.
 /// \param[in] expiring Whether item is expiring.
 /// \return No return.
-void Item_SetExpiring(entity item, bool expiring);
+#define ITEM_SET_EXPIRING(item, expiring) (item.m_isexpiring = expiring)