Skip to content

Commit 772ff5e

Browse files
committed
Changes to mapif and merge fixes
1 parent 7d7fe0a commit 772ff5e

5 files changed

Lines changed: 27 additions & 22 deletions

File tree

src/char/mapif.c

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1816,29 +1816,30 @@ static int mapif_save_guild_storage_ack(int fd, int account_id, int guild_id, in
18161816

18171817
/**
18181818
* Loads the account storage and send to the map server.
1819-
* @packet 0x3805 [out] <account_id>.L <struct item[]>.P
1819+
* @packet 0x3805 [out] <packet_len>.W <account_id>.L <storage_id>.W <struct item[]>.P
18201820
* @param fd [in] file/socket descriptor.
18211821
* @param account_id [in] account id of the session.
18221822
* @return 1 on success, 0 on failure.
18231823
*/
1824-
static int mapif_account_storage_load(int fd, int account_id)
1824+
static int mapif_account_storage_load(int fd, int account_id, int storage_id, int storage_size)
18251825
{
18261826
struct storage_data stor = { 0 };
18271827
int count = 0, i = 0, len = 0;
18281828

18291829
Assert_ret(account_id > 0);
18301830

18311831
VECTOR_INIT(stor.item);
1832-
count = inter_storage->fromsql(account_id, &stor);
1832+
count = inter_storage->fromsql(account_id, storage_id, &stor, storage_size);
18331833

1834-
len = 8 + count * sizeof(struct item);
1834+
len = 10 + count * sizeof(struct item);
18351835

18361836
WFIFOHEAD(fd, len);
18371837
WFIFOW(fd, 0) = 0x3805;
18381838
WFIFOW(fd, 2) = (uint16) len;
18391839
WFIFOL(fd, 4) = account_id;
1840+
WFIFOW(fd, 8) = storage_id;
18401841
for (i = 0; i < count; i++)
1841-
memcpy(WFIFOP(fd, 8 + i * sizeof(struct item)), &VECTOR_INDEX(stor.item, i), sizeof(struct item));
1842+
memcpy(WFIFOP(fd, 10 + i * sizeof(struct item)), &VECTOR_INDEX(stor.item, i), sizeof(struct item));
18421843
WFIFOSET(fd, len);
18431844

18441845
VECTOR_CLEAR(stor.item);
@@ -1848,31 +1849,36 @@ static int mapif_account_storage_load(int fd, int account_id)
18481849

18491850
/**
18501851
* Parses account storage load request from map server.
1851-
* @packet 0x3010 [in] <account_id>.L
1852+
* @packet 0x3010 [in] <account_id>.L <storage_id>.W <storage_size>.W
18521853
* @param fd [in] file/socket descriptor
18531854
* @return 1 on success, 0 on failure.
18541855
*/
18551856
static int mapif_parse_AccountStorageLoad(int fd)
18561857
{
1857-
int account_id = RFIFOL(fd, 2);
1858+
int account_id = RFIFOL(fd, 2), storage_id = RFIFOW(fd, 6);
1859+
int storage_size = RFIFOW(fd, 8);
18581860

18591861
Assert_ret(fd > 0);
18601862
Assert_ret(account_id > 0);
1863+
Assert_ret(storage_id >= 0);
1864+
Assert_ret(storage_size > 0);
18611865

1862-
mapif->account_storage_load(fd, account_id);
1866+
mapif->account_storage_load(fd, account_id, storage_id, storage_size);
18631867

18641868
return 1;
18651869
}
18661870

18671871
/**
18681872
* Parses an account storage save request from the map server.
1869-
* @packet 0x3011 [in] <packet_len>.W <account_id>.L <struct item[]>.P
1873+
* @packet 0x3011 [in] <packet_len>.W <account_id>.L <storage_id>.L <struct item[]>.P
18701874
* @param fd [in] file/socket descriptor.
18711875
* @return 1 on success, 0 on failure.
18721876
*/
18731877
static int mapif_parse_AccountStorageSave(int fd)
18741878
{
1875-
int payload_size = RFIFOW(fd, 2) - 8, account_id = RFIFOL(fd, 4);
1879+
int payload_size = RFIFOW(fd, 2) - 10, account_id = RFIFOL(fd, 4);
1880+
short storage_id = RFIFOW(fd, 8);
1881+
18761882
int i = 0, count = 0;
18771883
struct storage_data p_stor = { 0 };
18781884

@@ -1887,38 +1893,39 @@ static int mapif_parse_AccountStorageSave(int fd)
18871893
VECTOR_ENSURE(p_stor.item, count, 1);
18881894

18891895
for (i = 0; i < count; i++) {
1890-
const struct item *it = RFIFOP(fd, 8 + i * sizeof(struct item));
1896+
const struct item *it = RFIFOP(fd, 10 + i * sizeof(struct item));
18911897

18921898
VECTOR_PUSH(p_stor.item, *it);
18931899
}
18941900

18951901
p_stor.aggregate = count;
18961902
}
18971903

1898-
inter_storage->tosql(account_id, &p_stor);
1904+
inter_storage->tosql(account_id, storage_id, &p_stor);
18991905

19001906
VECTOR_CLEAR(p_stor.item);
19011907

1902-
mapif->sAccountStorageSaveAck(fd, account_id, true);
1908+
mapif->sAccountStorageSaveAck(fd, account_id, storage_id, true);
19031909

19041910
return 1;
19051911
}
19061912

19071913
/**
19081914
* Sends an acknowledgement for the save
19091915
* status of the account storage.
1910-
* @packet 0x3808 [out] <account_id>.L <save_flag>.B
1916+
* @packet 0x3808 [out] <account_id>.L <storage_id>.W <save_flag>.B
19111917
* @param fd [in] File/Socket Descriptor.
19121918
* @param account_id [in] Account ID of the storage in question.
19131919
* @param flag [in] Save flag, true for success and false for failure.
19141920
*/
1915-
static void mapif_send_AccountStorageSaveAck(int fd, int account_id, bool flag)
1921+
static void mapif_send_AccountStorageSaveAck(int fd, int account_id, int storage_id, bool flag)
19161922
{
1917-
WFIFOHEAD(fd, 7);
1923+
WFIFOHEAD(fd, 9);
19181924
WFIFOW(fd, 0) = 0x3808;
19191925
WFIFOL(fd, 2) = account_id;
1920-
WFIFOB(fd, 6) = flag ? 1 : 0;
1921-
WFIFOSET(fd, 7);
1926+
WFIFOW(fd, 6) = storage_id;
1927+
WFIFOB(fd, 8) = flag ? 1 : 0;
1928+
WFIFOSET(fd, 9);
19221929
}
19231930

19241931
static int mapif_parse_LoadGuildStorage(int fd)

src/map/atcommand.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5506,7 +5506,6 @@ ACMD(dropall)
55065506
*------------------------------------------*/
55075507
ACMD(storeall)
55085508
{
5509-
int i = 0;
55105509
char storage_name[NAME_LENGTH] = "";
55115510
int storage_id = 0, intval = 0;
55125511
struct storage_data *stor = NULL;

src/map/intif.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ static void intif_send_account_storage(struct map_session_data *sd, int storage_
408408

409409
WFIFOSET(inter_fd, len);
410410

411-
sd->storage.save = false; // Save request has been sent
411+
stor->save = false; // Save request has been sent
412412
}
413413

414414
/**

src/map/pc.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1282,7 +1282,6 @@ static bool pc_authok(struct map_session_data *sd, int login_id2, time_t expirat
12821282
VECTOR_INIT(sd->channels);
12831283
VECTOR_INIT(sd->script_queues);
12841284
VECTOR_INIT(sd->achievement); // Achievements [Smokexyz/Hercules]
1285-
VECTOR_INIT(sd->storage.item); // initialize storage item vector.
12861285
VECTOR_INIT(sd->hatEffectId);
12871286

12881287
// Storage

src/map/storage.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,8 +190,8 @@ static int storage_storageopen(struct map_session_data *sd, struct storage_data
190190
/* Send item list to client if available. */
191191
if (stor->aggregate > 0) {
192192
storage->sortitem(VECTOR_DATA(stor->item), VECTOR_LENGTH(stor->item));
193-
clif->storagelist(sd, VECTOR_DATA(stor->item), VECTOR_LENGTH(stor->item));
194193
}
194+
clif->storageList(sd, VECTOR_DATA(stor->item), VECTOR_LENGTH(stor->item));
195195

196196
/* Send storage total items and max amount update. */
197197
clif->updatestorageamount(sd, stor->aggregate, stst->capacity);

0 commit comments

Comments
 (0)