From 38e30977c8a64a89eae680587bcbd05074cdb26c Mon Sep 17 00:00:00 2001 From: terencehill Date: Tue, 23 Jul 2019 14:37:26 +0200 Subject: [PATCH] Reduce code thanks to the addition of a variable --- qcsrc/server/bot/default/waypoints.qc | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/qcsrc/server/bot/default/waypoints.qc b/qcsrc/server/bot/default/waypoints.qc index d8c12d4ee..2399da8ab 100644 --- a/qcsrc/server/bot/default/waypoints.qc +++ b/qcsrc/server/bot/default/waypoints.qc @@ -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; } -- 2.39.2