]> granicus.if.org Git - nethack/commitdiff
move validations before their first use
authorSHIRAKATA Kentaro <argrath@ub32.org>
Tue, 22 Feb 2022 08:21:44 +0000 (17:21 +0900)
committerPatR <rankin@nethack.org>
Sat, 26 Feb 2022 06:41:21 +0000 (22:41 -0800)
src/mkobj.c

index fc27dfbd33b99034758aa1f738844786f8724530..2980ded72f9086f964d16450a1bb1218e2479137 100644 (file)
@@ -2085,7 +2085,7 @@ is_rottable(struct obj *otmp)
 void
 place_object(struct obj *otmp, int x, int y)
 {
-    register struct obj *otmp2 = g.level.objects[x][y];
+    register struct obj *otmp2;
 
     if (!isok(x, y)) { /* validate location */
         void (*func)(const char *, ...) PRINTF_F(1, 2);
@@ -2099,6 +2099,8 @@ place_object(struct obj *otmp, int x, int y)
         panic("place_object: obj \"%s\" [%d] not free",
               safe_typename(otmp->otyp), otmp->where);
 
+    otmp2 = g.level.objects[x][y];
+
     obj_no_longer_held(otmp);
     if (otmp->otyp == BOULDER) {
         if (!otmp2 || otmp2->otyp != BOULDER)