From becc8312ff9a373ba22760ba89cdff6fe5e4895a Mon Sep 17 00:00:00 2001
From: mekolat <mekolat@users.noreply.github.com>
Date: Sat, 23 Apr 2016 14:42:18 -0400
Subject: forbid puppet creation if name already exists

---
 src/map/script-fun.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

(limited to 'src')

diff --git a/src/map/script-fun.cpp b/src/map/script-fun.cpp
index 13a635d..b39a763 100644
--- a/src/map/script-fun.cpp
+++ b/src/map/script-fun.cpp
@@ -1121,6 +1121,13 @@ void builtin_puppet(ScriptState *st)
 {
     int x, y;
 
+    NpcName npc = stringish<NpcName>(ZString(conv_str(st, &AARG(3))));
+    if (npc_name2id(npc) != nullptr)
+    {
+        push_int<ScriptDataInt>(st->stack, 0);
+        return;
+    }
+
     dumb_ptr<block_list> bl = map_id2bl(st->oid);
     dumb_ptr<npc_data_script> parent_nd = bl->is_npc()->is_script();
     dumb_ptr<npc_data_script> nd;
@@ -1137,7 +1144,6 @@ void builtin_puppet(ScriptState *st)
     nd->scr.event_needs_map = false;
 
     // PlayerName::SpellName
-    NpcName npc = stringish<NpcName>(ZString(conv_str(st, &AARG(3))));
     nd->name = npc;
 
     // Dynamically set location
-- 
cgit v1.2.3-70-g09d2