OSDN Git Service

[Refactor] #1435 Remove SGN() in h-define.h
authorHourier <grapefox.whitelucifer.0408@gmail.com>
Mon, 30 Aug 2021 12:58:30 +0000 (21:58 +0900)
committerHourier <grapefox.whitelucifer.0408@gmail.com>
Sat, 4 Sep 2021 05:25:07 +0000 (14:25 +0900)
src/floor/floor-leaver.cpp
src/system/h-define.h

index cd34ac1..6ae2fcb 100644 (file)
@@ -306,8 +306,16 @@ static void jump_floors(player_type *creature_ptr)
     else if (creature_ptr->change_floor_mode & CFM_UP)
         move_num = -1;
 
-    if (creature_ptr->change_floor_mode & CFM_SHAFT)
-        move_num += SGN(move_num);
+    if (creature_ptr->change_floor_mode & CFM_SHAFT) {
+        auto direction = 0;
+        if (move_num > 0) {
+            direction = 1;
+        } else if (move_num < 0) {
+            direction = -1;
+        }
+            
+        move_num += direction;
+    }
 
     if (creature_ptr->change_floor_mode & CFM_DOWN) {
         if (!is_in_dungeon(creature_ptr))
index 46b8d17..55f4621 100644 (file)
 #define ABS(a)         (((a) < 0)   ? (-(a)) : (a))
 
 /*
- * Non-typed sign extractor macro
- */
-#undef SGN
-#define SGN(a)         (((a) < 0)   ? (-1) : ((a) != 0))
-
-/*
  * Refer to the member at offset of structure
  */
 #define atoffset(TYPE, STRUCT_PTR, OFFSET) (*(TYPE*)(((char*)STRUCT_PTR) + (OFFSET)))