[planetblupi] 05/15: Move code for testing if an object can burn in a dedicated func

Didier Raboud odyx at moszumanska.debian.org
Thu Mar 15 07:59:40 UTC 2018


This is an automated email from the git hooks/post-receive script.

odyx pushed a commit to branch debian/master
in repository planetblupi.

commit d2046a93894c6c4884c67c8601efc9f53cfc61cc
Author: Mathieu Schroeter <mathieu at schroetersa.ch>
Date:   Sun Feb 18 23:24:06 2018 +0100

    Move code for testing if an object can burn in a dedicated func
---
 src/decmove.cxx | 67 +++++++++++++++++++++++++++++++++------------------------
 src/decor.h     |  1 +
 2 files changed, 40 insertions(+), 28 deletions(-)

diff --git a/src/decmove.cxx b/src/decmove.cxx
index 228f7fd..5decaad 100644
--- a/src/decmove.cxx
+++ b/src/decmove.cxx
@@ -1012,53 +1012,64 @@ CDecor::MoveAddIcons (Point cel, Sint32 rankIcons, bool bContinue)
 }
 
 /**
- * \brief Start the fire on a cell.
+ * \brief Test if something can burn at a specified cell.
  *
  * \param[in] cel - Position.
  * \returns true if possible.
  */
 bool
-CDecor::MoveStartFire (Point cel)
+CDecor::CanBurn (Point cel)
 {
   Sint32 channel, icon;
+  bool   canBurn = false;
 
   cel.x = (cel.x / 2) * 2;
   cel.y = (cel.y / 2) * 2;
 
-  channel = m_decor[cel.x / 2][cel.y / 2].objectChannel;
-  icon    = m_decor[cel.x / 2][cel.y / 2].objectIcon;
-
-  if (
-    channel == CHOBJECT && ((icon >= 6 && icon <= 11)     // trees ?
-                            || (icon >= 65 && icon <= 71) // palissade ?
-                            || icon == 61                 // cabane ?
-                            || icon == 36                 // planches ?
-                            || icon == 60                 // tomatoes ?
-                            || icon == 63                 // eggs ?
-                            || icon == 113                // house ?
-                            || icon == 121                // mine de fer ?
-                            || icon == 122                // mine de fer ?
-                            ))
-  {
-    if (!MoveCreate (cel, -1, false, CHOBJECT, -1, -1, -1, 9999, 1, 0, true))
-      return false;
-
-    MoveAddIcons (cel, 1, true); // small fire
-    m_decor[cel.x / 2][cel.y / 2].fire = 2;
+  const auto cell = m_decor[cel.x / 2][cel.y / 2];
+
+  channel = cell.objectChannel;
+  icon    = cell.objectIcon;
+
+  canBurn = channel == CHOBJECT && ((icon >= 6 && icon <= 11)     // trees ?
+                                    || (icon >= 65 && icon <= 71) // palissade ?
+                                    || icon == 61                 // cabane ?
+                                    || icon == 36                 // planches ?
+                                    || icon == 60                 // tomatoes ?
+                                    || icon == 63                 // eggs ?
+                                    || icon == 113                // house ?
+                                    || icon == 121 // mine de fer ?
+                                    || icon == 122 // mine de fer ?
+                                   );
+  if (canBurn)
     return true;
-  }
 
   // If there is an other object, then no fire.
   if (channel >= 0)
     return false;
 
-  channel = m_decor[cel.x / 2][cel.y / 2].floorChannel;
-  icon    = m_decor[cel.x / 2][cel.y / 2].floorIcon;
+  channel = cell.floorChannel;
+  icon    = cell.floorIcon;
 
-  if (
-    channel == CHFLOOR && (icon == 20 ||                // herbe foncée ?
-                           (icon >= 59 && icon <= 64))) // bridge ?
+  canBurn = channel == CHFLOOR && (icon == 20 || // herbe foncée ?
+                                   (icon >= 59 && icon <= 64));
+  return canBurn;
+}
+
+/**
+ * \brief Start the fire on a cell.
+ *
+ * \param[in] cel - Position.
+ * \returns true if possible.
+ */
+bool
+CDecor::MoveStartFire (Point cel)
+{
+  if (this->CanBurn (cel))
   {
+    cel.x = (cel.x / 2) * 2;
+    cel.y = (cel.y / 2) * 2;
+
     if (!MoveCreate (cel, -1, false, CHOBJECT, -1, -1, -1, 9999, 1, 0, true))
       return false;
 
diff --git a/src/decor.h b/src/decor.h
index ddcc376..70ea98b 100644
--- a/src/decor.h
+++ b/src/decor.h
@@ -322,6 +322,7 @@ public:
   Term * GetTerminated ();
 
   // DecMove.cpp
+  bool   CanBurn (Point cel);
   void   MoveFlush ();
   Sint32 MoveMaxFire ();
   void   MoveFixInit ();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/planetblupi.git



More information about the Pkg-games-commits mailing list