Added Guild Storage Expansion Skill (#3244)

* Fixes #499 and part of #1303.
* Implements Guild Storage Expansion Skill which requires client 2013-12-23 or newer (enable by default depending on client date in src/config/packets.hpp).
* Implements guild storage permission which requires client 2014-02-05 or newer.
* Expanded script command guildopenstorage return values.
This commit is contained in:
Aleos
2018-07-03 08:49:34 -04:00
committed by GitHub
parent e4eddc3e61
commit e13ca63cc8
18 changed files with 187 additions and 83 deletions

View File

@@ -19,18 +19,18 @@
/**
* Check if storage ID is valid
* @param id Storage ID
* @return True:Valid, False:Invalid
**/
* @param id: Storage ID
* @return True if success or false on failure
*/
bool inter_premiumStorage_exists(uint8 id) {
return interserv_config.storages.find(id) != interserv_config.storages.end();
}
/**
* Get max storage amount
* @param id Storage ID
* @param id: Storage ID
* @return Max amount
**/
*/
int inter_premiumStorage_getMax(uint8 id) {
if (inter_premiumStorage_exists(id))
return interserv_config.storages[id]->max_num;
@@ -39,9 +39,9 @@ int inter_premiumStorage_getMax(uint8 id) {
/**
* Get table name of storage
* @param id Storage ID
* @param id: Storage ID
* @return Table name
**/
*/
const char *inter_premiumStorage_getTableName(uint8 id) {
if (inter_premiumStorage_exists(id))
return interserv_config.storages[id]->table;
@@ -49,10 +49,10 @@ const char *inter_premiumStorage_getTableName(uint8 id) {
}
/**
* Get printable name of storage
* @param id Storage ID
* @return printable name
**/
* Get printable name of storage
* @param id: Storage ID
* @return printable name
*/
const char *inter_premiumStorage_getPrintableName(uint8 id) {
if (inter_premiumStorage_exists(id))
return interserv_config.storages[id]->name;
@@ -95,7 +95,7 @@ int cart_tosql(uint32 char_id, struct s_storage* p)
/**
* Fetch inventory entries from table
* @param char_id: Character ID to fetch
* @param p: Inventory list to save the entries
* @param p: Inventory entries
* @return True if success, False if failed
*/
bool inventory_fromsql(uint32 char_id, struct s_storage* p)
@@ -106,7 +106,7 @@ bool inventory_fromsql(uint32 char_id, struct s_storage* p)
/**
* Fetch cart entries from table
* @param char_id: Character ID to fetch
* @param p: Cart list to save the entries
* @param p: Cart entries
* @return True if success, False if failed
*/
bool cart_fromsql(uint32 char_id, struct s_storage* p)
@@ -116,8 +116,8 @@ bool cart_fromsql(uint32 char_id, struct s_storage* p)
/**
* Fetch storage entries from table
* @param char_id: Character ID to fetch
* @param p: Storage list to save the entries
* @param account_id: Account ID to fetch
* @param p: Storage entries
* @param stor_id: Storage ID
* @return True if success, False if failed
*/
@@ -128,9 +128,9 @@ bool storage_fromsql(uint32 account_id, struct s_storage* p)
/**
* Save guild_storage data to sql
* @param guild_id: Character ID to save
* @param p: Guild Storage list to save the entries
* @return 0 if success, or error count
* @param guild_id: Guild ID to save
* @param p: Guild Storage entries
* @return True if success, False if failed
*/
bool guild_storage_tosql(int guild_id, struct s_storage* p)
{
@@ -140,8 +140,8 @@ bool guild_storage_tosql(int guild_id, struct s_storage* p)
/**
* Fetch guild_storage entries from table
* @param char_id: Character ID to fetch
* @param p: Storage list to save the entries
* @param guild_id: Guild ID to fetch
* @param p: Guild Storage entries
* @return True if success, False if failed
*/
bool guild_storage_fromsql(int guild_id, struct s_storage* p)
@@ -181,6 +181,14 @@ void inter_storage_sql_final(void)
//---------------------------------------------------------
// packet from map server
/**
* Send guild storage data to the map server
* @param fd: Map server's fd
* @param account_id: Account ID requesting
* @param guild_id: Guild ID requesting
* @param flag: Additional parameters
* @return True on success or false on failure
*/
bool mapif_load_guild_storage(int fd,uint32 account_id,int guild_id, char flag)
{
if( SQL_ERROR == Sql_Query(sql_handle, "SELECT `guild_id` FROM `%s` WHERE `guild_id`='%d'", schema_config.guild_db, guild_id) )
@@ -195,7 +203,7 @@ bool mapif_load_guild_storage(int fd,uint32 account_id,int guild_id, char flag)
WFIFOB(fd,12) = flag; //1 open storage, 0 don't open
guild_storage_fromsql(guild_id, (struct s_storage*)WFIFOP(fd,13));
WFIFOSET(fd, WFIFOW(fd,2));
return false;
return true;
}
// guild does not exist
Sql_FreeResult(sql_handle);
@@ -205,7 +213,7 @@ bool mapif_load_guild_storage(int fd,uint32 account_id,int guild_id, char flag)
WFIFOL(fd,4) = account_id;
WFIFOL(fd,8) = 0;
WFIFOSET(fd, 12);
return true;
return false;
}
void mapif_save_guild_storage_ack(int fd,uint32 account_id,int guild_id,int fail)
@@ -227,6 +235,11 @@ void mapif_parse_LoadGuildStorage(int fd)
mapif_load_guild_storage(fd,RFIFOL(fd,2),RFIFOL(fd,6),1);
}
/**
* Save guild storage data from map server
* @param fd: Map server's fd
* @return True on success or false on failure
*/
bool mapif_parse_SaveGuildStorage(int fd)
{
int guild_id;