]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Reduce code thanks to the addition of a variable
authorterencehill <piuntn@gmail.com>
Tue, 23 Jul 2019 12:37:26 +0000 (14:37 +0200)
committerterencehill <piuntn@gmail.com>
Tue, 23 Jul 2019 12:37:26 +0000 (14:37 +0200)
qcsrc/server/bot/default/waypoints.qc

index d8c12d4ee2319d2d45c34815519ae13e5ba50484..2399da8ab38a5b0ce34fecf5b5438c63b4b55ae8 100644 (file)
@@ -592,27 +592,17 @@ void waypoint_spawn_fromeditor(entity pl, bool at_crosshair, bool is_jump_wp, bo
                if (!pl.wp_locked)
                        pl.wp_locked = e;
        }
-       else if (is_jump_wp)
-       {
-               entity wp_found = waypoint_get(org, org);
-               if (wp_found && !(wp_found.wpflags & WAYPOINTFLAG_JUMP))
-               {
-                       LOG_INFO("Error: can't spawn a jump waypoint over an existent waypoint of a different type\n");
-                       return;
-               }
-               e = waypoint_spawn(org, org, WAYPOINTFLAG_JUMP | WAYPOINTFLAG_NORELINK);
-               if (!pl.wp_locked)
-                       pl.wp_locked = e;
-       }
-       else if (is_support_wp)
+       else if (is_jump_wp || is_support_wp)
        {
+               int type_flag = (is_jump_wp) ? WAYPOINTFLAG_JUMP : WAYPOINTFLAG_SUPPORT;
+
                entity wp_found = waypoint_get(org, org);
-               if (wp_found && !(wp_found.wpflags & WAYPOINTFLAG_SUPPORT))
+               if (wp_found && !(wp_found.wpflags & type_flag))
                {
-                       LOG_INFO("Error: can't spawn a support waypoint over an existent waypoint of a different type\n");
+                       LOG_INFOF("Error: can't spawn a %s waypoint over an existent waypoint of a different type\n", (is_jump_wp) ? "Jump" : "Support");
                        return;
                }
-               e = waypoint_spawn(org, org, WAYPOINTFLAG_SUPPORT | WAYPOINTFLAG_NORELINK);
+               e = waypoint_spawn(org, org, type_flag | WAYPOINTFLAG_NORELINK);
                if (!pl.wp_locked)
                        pl.wp_locked = e;
        }