]> git.pond.sub.org Git - empserver/commitdiff
Use ef_blank() when extending treaty, loan, comm and trade file
authorMarkus Armbruster <armbru@pond.sub.org>
Sun, 24 Feb 2008 17:47:22 +0000 (18:47 +0100)
committerMarkus Armbruster <armbru@pond.sub.org>
Fri, 14 Mar 2008 19:25:07 +0000 (20:25 +0100)
Only treaty extension initialized ef_type and uid properly.  None of
them zeroed unused members and holes in the struct.  comm and trade
extension called ef_extend(), which had no effect, so remove that.

src/lib/commands/offe.c
src/lib/commands/sell.c
src/lib/commands/set.c

index 2c8c228697d4e4dff4fdce06a388a1a3a4641706..50e283468a86fa269c80288540a1c67ac1f6ddff 100644 (file)
@@ -134,8 +134,7 @@ do_treaty(void)
            break;
        }
     }
-    trty.ef_type = EF_TREATY;
-    trty.trt_uid = nstr.cur;
+    ef_blank(EF_TREATY, nstr.cur, &trty);
     trty.trt_acond = ourcond;
     trty.trt_bcond = theircond;
     trty.trt_status = TS_PROPOSED;
@@ -220,6 +219,7 @@ do_loan(void)
        if (loan.l_status == LS_FREE)
            break;
     }
+    ef_blank(EF_LOAN, nstr.cur, &loan);
     loan.l_loner = player->cnum;
     loan.l_lonee = recipient;
     loan.l_status = LS_PROPOSED;
index 57b3c3bd5969e50867a01545b4d6ae8a489d7407..9f7726d471343d4696c1a7d263a70b19b722d330 100644 (file)
@@ -143,9 +143,8 @@ sell(void)
            if (comm.com_owner == 0)
                break;
        }
-       if (getcomm(ii, &comm) == 0)
-           ef_extend(EF_COMM, 1);
        (void)time(&now);
+       ef_blank(EF_COMM, ii, &comm);
        comm.com_type = ip->i_uid;
        comm.com_owner = player->cnum;
        comm.com_price = price;
index 20f8639907563f5332238b6b8b403423744583b6..5f20a2c3759c18d42874f6d0e7741af71e62718f 100644 (file)
@@ -113,7 +113,7 @@ set(void)
            if (foundslot >= 0) {
                pr("%s #%d (lot #%d) removed from trading\n",
                   trade_nameof(&trade, &item), ni.cur, foundslot);
-               memset(&trade, 0, sizeof(trade));
+               trade.trd_owner = 0;
                puttrade(ni_trade.cur, &trade);
            }
        } else {
@@ -121,10 +121,9 @@ set(void)
                id = foundslot;
            else if (freeslot >= 0)
                id = freeslot;
-           else {
-               ef_extend(EF_TRADE, 1);
+           else
                id = ni_trade.cur;
-           }
+           ef_blank(EF_TRADE, id, &trade);
            trade.trd_x = item.gen.x;
            trade.trd_y = item.gen.y;
            trade.trd_type = type;