Skip to content
Permalink
Browse files
Optimized Inventory, Cart Inventory, and Storage usage (#1115)
* These storage types now mimic Guild Storage and can be loaded/saved whenever needed.
* Relieves mmo_charstatus from having to send storage types and lets the char-server handle it.
* All storage types now have an increased max amount.
* Implemented Premium Storage System. Thanks to @cydh!
* Fixes #441 - Players will no longer be required to log out to resync cart item data before opening a Vending Store.
* Refactored player weight and cart weight calculations into their own functions.
* Added script commands openstorage2, guildstoragecountitem[2] and guildstoragedelitem[2].
* Refactored several function return types as well as documentation.
Thanks to @lighta and @cydh for their help with it!
  • Loading branch information
aleos89 committed Nov 14, 2016
2 parents b5de7df + 8028789 commit ade1b171ebcb0e9b4e91f97b511fc4b8d0b99bee
Showing with 2,513 additions and 1,557 deletions.
  1. 0 conf/import-tmpl/inter_server.conf
  2. +2 −1 conf/inter_athena.conf
  3. +26 −0 conf/inter_server.conf
  4. +1 −1 conf/msg_conf/map_msg.conf
  5. +1 −1 conf/msg_conf/map_msg_idn.conf
  6. +67 −0 doc/packet_interserv.txt
  7. +59 −12 doc/script_commands.txt
  8. +38 −0 sql-files/upgrades/premium_storage.sql
  9. +133 −291 src/char/char.c
  10. +3 −12 src/char/char.h
  11. +2 −4 src/char/char_clif.c
  12. +11 −14 src/char/int_auction.c
  13. +311 −170 src/char/int_storage.c
  14. +8 −9 src/char/int_storage.h
  15. +105 −6 src/char/inter.c
  16. +11 −0 src/char/inter.h
  17. +40 −14 src/common/mmo.h
  18. +11 −15 src/login/account.c
  19. +61 −51 src/map/atcommand.c
  20. +6 −6 src/map/battle.c
  21. +4 −4 src/map/buyingstore.c
  22. +20 −8 src/map/chrif.c
  23. +156 −136 src/map/clif.c
  24. +2 −3 src/map/clif.h
  25. +24 −18 src/map/guild.c
  26. +291 −42 src/map/intif.c
  27. +6 −2 src/map/intif.h
  28. +1 −1 src/map/itemdb.c
  29. +9 −9 src/map/mail.c
  30. +3 −2 src/map/map.c
  31. +13 −13 src/map/npc.c
  32. +1 −1 src/map/party.c
  33. +182 −191 src/map/pc.c
  34. +17 −3 src/map/pc.h
  35. +5 −8 src/map/pet.c
  36. +246 −155 src/map/script.c
  37. +4 −0 src/map/script_constants.h
  38. +37 −32 src/map/skill.c
  39. +116 −56 src/map/status.c
  40. +2 −0 src/map/status.h
  41. +402 −204 src/map/storage.c
  42. +42 −22 src/map/storage.h
  43. +9 −9 src/map/trade.c
  44. +3 −1 src/map/unit.c
  45. +18 −30 src/map/vending.c
  46. +1 −0 vcproj-10/map-server.vcxproj
  47. +1 −0 vcproj-12/map-server.vcxproj
  48. +1 −0 vcproj-13/map-server.vcxproj
  49. +1 −0 vcproj-14/map-server.vcxproj
Empty file.
@@ -93,7 +93,6 @@ scdata_db: sc_data
cart_db: cart_inventory
inventory_db: inventory
charlog_db: charlog
storage_db: storage
skill_db: skill
interlog_db: interlog
memo_db: memo
@@ -150,4 +149,6 @@ db_roulette_table: db_roulette
// Use SQL item_db, mob_db and mob_skill_db for the map server? (yes/no)
use_sql_db: no

inter_server_conf: conf/inter_server.conf

import: conf/import/inter_conf.txt
@@ -0,0 +1,26 @@
/**
* Config for Storages
*
* To access the premium storage, use script command 'openstorage2'.
* If premium storages are added, copy the structure of the storage table and match the table name in this config.
* The 'max' of premium storages are not adjusted by 'vip_storage_increase' config nor MIN_STORAGE.
*
* Structure:
{
id: <storage_id> // (int) Storage ID will be used for script command 'openstorage2'.
name: "<storage name>" // (string) Storage name will be sent to the client to display on the title bar.
table: "<storage_table>" // (string) Name of table where storage is saved. The table stucture is the same as the default storage table.
max: <max_amount> // (int) *optional* Maximum number of items in storage. MAX_STORAGE will be used if no value is defined.
}, // Use comma to add more storages
**/

storages: (
{
// Default Storage
// DO NOT CHANGE THIS UNLESS YOU KNOW WHAT YOU ARE DOING
id: 0
name: "Storage"
table: "storage"
//max: 600
}
)
@@ -770,7 +770,7 @@

732: Item cannot be opened when your inventory is full.

733: Item '%s' has not yet saved to your cart. Please re-log in order to correctly save your Vending information.
//733 free

// @cloneequip/@clonestat
734: Cannot clone your own %s.
@@ -769,7 +769,7 @@

732: Item tidak dapat dibuka ketika inventory penuh.

733: Item '%s' belum tersimpan di gerobak. Harap masuk kembali untuk dapat menyimpan informasi vending dengan benar.
//733 free

// @cloneequip/@clonestat
734: Tidak dapat mengkloning %s diri sendiri.
@@ -1328,6 +1328,33 @@ Currently the max packet size is 0xFFFF (see 'WFIFOSET()' in 'src/common/socket.
desc:
- Delete pet data

0x308a
Type: ZI
Structure: <cmd>.W <type>.B <account_id>.L <char_id>.L
index: 0,2,3,7
len: 11
parameter:
- cmd : packet identification (0x308a)
- type : 0 - TABLE_INVENTORY, 1 - TABLE_CART, 2 - TABLE_STORAGE
- account_id
- char_id
desc:
- Request inventory/cart/storage data for a player/guild if type = 3

0x308b
Type: ZI
Structure: <size>.W <type>.B <account_id>.L <char_id>.L <entries>.?B
index: 0,2,4,5,9,13
len: 11
parameter:
- cmd : packet identification (0x308a)
- type : 0 - TABLE_INVENTORY, 1 - TABLE_CART, 2 - TABLE_STORAGE
- account_id
- char_id
- entries : Inventory/cart/storage entries that will be saved
desc:
- Request to save inventory/cart/storage entries

0x3090:
Type: ZI
Structure: <cmd>.W <s_homunculus>.W <aid>.L <sh>.?B
@@ -2139,6 +2166,46 @@ Currently the max packet size is 0xFFFF (see 'WFIFOSET()' in 'src/common/socket.
desc:
- Send pet deletion status

0x388a
Type: IZ
Structure: <cmd>.W <size>.W <type>.B <account_id>.L <result>.B <entries>.?B
index: 0,2,4,5,9
len: 9+variable
parameter:
- cmd : packet identification (0x388a)
- size
- type : Storage type, 0 - TABLE_INVENTORY, 1 - TABLE_CART, 2 - TABLE_STORAGE
- account_id
- result : True if data loaded, false if failed
- entries : Inventory/cart/storage entries
desc:
- Process inventory/cart/storage entries for player from inter-server

0x388b
Type: IZ
Structure: <cmd>.W <account_id>.L <result>.B <type>.B
index: 0,2,6,7
len: 11
parameter:
- cmd : packet identification (0x388b)
- account_id
- result : 1 - success, 0 - failed
- type : Storage type, 0 - TABLE_INVENTORY, 1 - TABLE_CART, 2 - TABLE_STORAGE
desc:
- Info about inventory/cart/storage data is saved

0x388c
Type: IZ
Structure: <cmd>.W <len>.W { <storage_table>.? }*?
index: 0,2,6,...
len: 6+variable
parameter:
- cmd : packet identification (0x388c)
- len : Pakcet length
- storage_table : Storage table information
desc:
- Receive storage information

0x3890
Type: IZ
Structure: <cmd>.W <size>.W <account_id>.L <flag>.B <s_homunculus>.?B
@@ -4617,9 +4617,14 @@ database. If the name is not found, nothing will be deleted.
*cartdelitem "<item name>",<amount>{,<account ID>};
*storagedelitem <item id>,<amount>{,<account ID>};
*storagedelitem "<item name>",<amount>{,<account ID>};
*guildstoragedelitem <item id>,<amount>{,<account ID>};
*guildstoragedelitem "<item name>",<amount>{,<account ID>};

This command behaves identically to 'delitem', but deletes items from the player's
cart or storage. If no cart is mounted, 'cartdelitem' will fail.
cart, storage, or guild storage.

If no cart is mounted, 'cartdelitem' will return -1.
If player is not in a guild or storage is open, 'guildstoragedelitem' will return -1.

---------------------------------------

@@ -4635,9 +4640,14 @@ See 'getitem2' for an explanation of the expanded parameters.
*cartdelitem2 "<item name>",<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>};
*storagedelitem2 <item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>};
*storagedelitem2 "<item name>",<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>};
*guildstoragedelitem2 <item id>,<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>};
*guildstoragedelitem2 "<item name>",<amount>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<account ID>};

This command behaves identically to 'delitem2', but deletes items from the player's
cart or storage. If no cart is mounted, 'cartdelitem2' will fail.
cart, storage, or guild storage.

If no cart is mounted, 'cartdelitem2' will return -1.
If player is not in a guild or storage is open, 'guildstoragedelitem2' will return -1.

---------------------------------------

@@ -4663,13 +4673,18 @@ adding up strings:

---------------------------------------

*cartcountitem(<item id>)
*cartcountitem("<item name>")
*storagecountitem(<item id>)
*storagecountitem("<item name>")
*cartcountitem(<item id>{,<accountID>})
*cartcountitem("<item name>"{,<accountID>})
*storagecountitem(<item id>{,<accountID>})
*storagecountitem("<item name>"{,<accountID>})
*guildstoragecountitem(<nameID>{,<accountID>})
*guildstoragecountitem("<item name>"{,<accountID>})

This command behaves identically to 'countitem', but counts items from the player's
cart or storage. If no cart is mounted, 'cartcountitem' will return -1.
cart, storage, or guild storage.

If no cart is mounted, 'cartcountitem' will return -1.
If player is not in a guild or storage is open, 'guildstoragecountitem' will return -1.

---------------------------------------

@@ -4684,13 +4699,18 @@ See 'getitem2' for an explanation of the expanded parameters.

---------------------------------------

*cartcountitem2(<item id>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>)
*cartcountitem2("<item name>",<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>)
*storagecountitem2(<item id>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>)
*storagecountitem2("<item name>",<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>)
*cartcountitem2(<item id>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<accountID>})
*cartcountitem2("<item name>",<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<accountID>})
*storagecountitem2(<item id>,<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<accountID>})
*storagecountitem2("<item name>",<identify>,<refine>,<attribute>,<card1>,<card2>,<card3>,<card4>{,<accountID>})
*guildstoragecountitem2(<nameID>,<Identified>,<Refine>,<Attribute>,<Card0>,<Card1>,<Card2>,<Card3>{,<accountID>})
*guildstoragecountitem2("<item name>",<Identified>,<Refine>,<Attribute>,<Card0>,<Card1>,<Card2>,<Card3>{,<accountID>})

This command behaves identically to 'countitem2', but counts items from the player's
cart or storage. If no cart is mounted, 'cartcountitem2' will return -1.
cart, storage, or guild storage.

If no cart is mounted, 'cartcountitem2' will return -1.
If player is not in a guild or storage is open, 'guildstoragecountitem2' will return -1.

---------------------------------------

@@ -5054,6 +5074,33 @@ window, to avoid any disruption when both windows overlap.

---------------------------------------

*openstorage2 <storage_id>,<mode>{,<account_id>};

Just like the 'openstorage' command, except this command can open additional storages
by the specified <storage_id>. For <storage_id>, please read the conf/inter_server.conf
for storage groups.

Values for <mode> are:
STOR_MODE_NONE : Player only can read the storage entries.
STOR_MODE_GET : Player can get items from the storage.
STOR_MODE_PUT : Player can put items in the storage.

Example:
if (vip_status(1)) {
mes "I will open your Premium storage.";
mes "Thank you for using our service.";
close2;
openstorage2 1,STOR_MODE_GET|STOR_MODE_PUT;
} else {
mes "Sorry, your Premium status is expired.";
mes "Storage will be opened but you can't put any item into it.";
close2;
openstorage2 1,STOR_MODE_GET;
}
end;

---------------------------------------

*openmail({<char_id>});

This will open a character's Mail window on the client connected to the
@@ -0,0 +1,38 @@
--
-- Table structure for table `storage_1`
--

CREATE TABLE IF NOT EXISTS `storage_1` (
`id` int(11) unsigned NOT NULL auto_increment,
`account_id` int(11) unsigned NOT NULL default '0',
`nameid` smallint(5) unsigned NOT NULL default '0',
`amount` smallint(11) unsigned NOT NULL default '0',
`equip` int(11) unsigned NOT NULL default '0',
`identify` smallint(6) unsigned NOT NULL default '0',
`refine` tinyint(3) unsigned NOT NULL default '0',
`attribute` tinyint(4) unsigned NOT NULL default '0',
`card0` smallint(5) unsigned NOT NULL default '0',
`card1` smallint(5) unsigned NOT NULL default '0',
`card2` smallint(5) unsigned NOT NULL default '0',
`card3` smallint(5) unsigned NOT NULL default '0',
`option_id0` smallint(5) unsigned NOT NULL default '0',
`option_val0` smallint(5) unsigned NOT NULL default '0',
`option_parm0` tinyint(3) unsigned NOT NULL default '0',
`option_id1` smallint(5) unsigned NOT NULL default '0',
`option_val1` smallint(5) unsigned NOT NULL default '0',
`option_parm1` tinyint(3) unsigned NOT NULL default '0',
`option_id2` smallint(5) unsigned NOT NULL default '0',
`option_val2` smallint(5) unsigned NOT NULL default '0',
`option_parm2` tinyint(3) unsigned NOT NULL default '0',
`option_id3` smallint(5) unsigned NOT NULL default '0',
`option_val3` smallint(5) unsigned NOT NULL default '0',
`option_parm3` tinyint(3) unsigned NOT NULL default '0',
`option_id4` smallint(5) unsigned NOT NULL default '0',
`option_val4` smallint(5) unsigned NOT NULL default '0',
`option_parm4` tinyint(3) unsigned NOT NULL default '0',
`expire_time` int(11) unsigned NOT NULL default '0',
`bound` tinyint(3) unsigned NOT NULL default '0',
`unique_id` bigint(20) unsigned NOT NULL default '0',
PRIMARY KEY (`id`),
KEY `account_id` (`account_id`)
) ENGINE=MyISAM;

0 comments on commit ade1b17

Please sign in to comment.