From 780a0d771edbe21dcfa3405163ffbdf7f7fa4604 Mon Sep 17 00:00:00 2001 From: Ben Longbons Date: Mon, 13 Oct 2014 13:16:34 -0700 Subject: Convert container lookups to use Option> --- src/char/int_storage.cpp | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src/char/int_storage.cpp') diff --git a/src/char/int_storage.cpp b/src/char/int_storage.cpp index 76eff34..a2b0bc7 100644 --- a/src/char/int_storage.cpp +++ b/src/char/int_storage.cpp @@ -117,14 +117,10 @@ bool extract(XString str, Storage *p) } // アカウントから倉庫データインデックスを得る(新規倉庫追加可能) -Storage *account2storage(AccountId account_id) +Borrowed account2storage(AccountId account_id) { - Storage *s = storage_db.search(account_id); - if (s == nullptr) - { - s = storage_db.init(account_id); - s->account_id = account_id; - } + P s = storage_db.init(account_id); + s->account_id = account_id; return s; } @@ -196,7 +192,7 @@ void inter_storage_delete(AccountId account_id) static void mapif_load_storage(Session *ss, AccountId account_id) { - Storage *st = account2storage(account_id); + P st = account2storage(account_id); Packet_Payload<0x3810> payload_10; payload_10.account_id = account_id; payload_10.storage = *st; @@ -240,11 +236,10 @@ RecvResult mapif_parse_SaveStorage(Session *ss) if (rv != RecvResult::Complete) return rv; - Storage *st; AccountId account_id = payload.account_id; { - st = account2storage(account_id); + P st = account2storage(account_id); *st = payload.storage; mapif_save_storage_ack(ss, account_id); } -- cgit v1.2.3-70-g09d2