summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2022-05-16 23:39:30 -0300
committerJesusaves <cpntb1@ymail.com>2022-05-16 23:39:30 -0300
commit935cabea8b4570689532932a5c715e1ea9b11fc2 (patch)
treebd65e5e9a7696901b67f2b8bb2a18dda5ff68c48
parent88800edc114b4a25b535cf8240316093ef5af2ec (diff)
downloadserverdata-935cabea8b4570689532932a5c715e1ea9b11fc2.tar.gz
serverdata-935cabea8b4570689532932a5c715e1ea9b11fc2.tar.bz2
serverdata-935cabea8b4570689532932a5c715e1ea9b11fc2.tar.xz
serverdata-935cabea8b4570689532932a5c715e1ea9b11fc2.zip
Encapsule InitMaze in a do{}while loop so it is always valid (I hope)
Fix a typo as well
-rw-r--r--npc/functions/maze.txt33
1 files changed, 16 insertions, 17 deletions
diff --git a/npc/functions/maze.txt b/npc/functions/maze.txt
index 23caede37..27c026c4f 100644
--- a/npc/functions/maze.txt
+++ b/npc/functions/maze.txt
@@ -51,26 +51,25 @@ function script CreateMaze {
if (MAZE_ID == .@r)
continue;
MAZE_ID = .@r;
- break;
- } while (true);
- .@MAZEMP$=sprintf("030-%02d", MAZE_ID);
- MAZE_MAP$=sprintf("mz%02d@"+getcharid(0), MAZE_ID);
+ .@MAZEMP$=sprintf("030-%02d", MAZE_ID);
+ MAZE_MAP$=sprintf("mz%02d@"+getcharid(0), MAZE_ID);
- // Maze is not yet started
- if (.@scope == IOT_CHAR) {
- MAZE_INST = instance_create("Maze "+MAZE_ID+" "+getcharid(0), getcharid(3), IOT_CHAR);
- // Failed
- if (MAZE_INST < 0) {
- consolebug("Instance \"%s\" already exists! (Error %d)", "Maze "+MAZE_ID+" "+getcharid(0), MAZE_INST);
- return 0;
+ // Maze is not yet started
+ if (.@scope == IOT_CHAR) {
+ MAZE_INST = instance_create("Maze "+MAZE_ID+" "+getcharid(0), getcharid(3), IOT_CHAR);
+ // Failed
+ if (MAZE_INST < 0) {
+ consolebug("Instance \"%s\" already exists! (Error %d)", "Maze "+MAZE_ID+" "+getcharid(0), MAZE_INST);
+ continue; // Get a new maze
+ }
+ // Attach map
+ instance_attachmap(.@MAZEMP$, MAZE_INST, false, MAZE_MAP$);
+ } else {
+ consolebug("Scope %d not yet supported by maze system", .@scope);
+ return 0; // Exit early
}
- // Attach map
- instance_attachmap(.@MAZEMP$, .@inst, false, MAZE_MAP$);
- } else {
- consolebug("Scope %d not yet supported by maze system", .@scope);
- return 0;
- }
+ } while (MAZE_INST < 0);
return MAZE_ID;
}