Skip to content

Commit

Permalink
Added storage permissions to the enum guild_permission
Browse files Browse the repository at this point in the history
- Available in PACKETVER >= 20140205

Signed-off-by: Haru <[email protected]>
  • Loading branch information
panikon authored and MishimaHaruna committed Jun 26, 2016
1 parent 4dd44a7 commit 59802a9
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 17 deletions.
3 changes: 2 additions & 1 deletion conf/messages.conf
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,8 @@
334: Total Domination

335: Your guild doesn't have storage!
//336-342 FREE
336: You're not authorized to open your guild storage!
//337-342 FREE

// Templates for @who output
343: Name: %s
Expand Down
1 change: 1 addition & 0 deletions doc/script_commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5423,6 +5423,7 @@ Expected return values:
1 Storage is already open
2 Player has no guild / guild information hasn't arrived yet
3 Player's guild doesn't have GD_GUILD_STORAGE (only if OFFICIAL_GUILD_STORAGE is enabled - automatically enabled on PACKETVER >= 20131223)
4 Player doesn't have permission to use storage (only on PACKETVER >= 20140205)

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

Expand Down
2 changes: 1 addition & 1 deletion src/char/int_guild.c
Original file line number Diff line number Diff line change
Expand Up @@ -1230,7 +1230,7 @@ int mapif_parse_CreateGuild(int fd, int account_id, const char *name, const stru
g->member[0].modified = GS_MEMBER_MODIFIED;

// Set default positions
g->position[0].mode = GPERM_ALL;
g->position[0].mode = GPERM_DEFAULT;
strcpy(g->position[0].name,"GuildMaster");
strcpy(g->position[MAX_GUILDPOSITION-1].name,"Newbie");
g->position[0].modified = g->position[MAX_GUILDPOSITION-1].modified = GS_POSITION_MODIFIED;
Expand Down
14 changes: 10 additions & 4 deletions src/common/mmo.h
Original file line number Diff line number Diff line change
Expand Up @@ -766,10 +766,16 @@ enum { //Change Member Infos
};

enum guild_permission { // Guild permissions
GPERM_INVITE = 0x01,
GPERM_EXPEL = 0x10,
GPERM_ALL = GPERM_INVITE|GPERM_EXPEL,
GPERM_MASK = GPERM_ALL,
GPERM_INVITE = 0x001,
GPERM_EXPEL = 0x010,
#if PACKETVER >= 20140205
GPERM_STORAGE = 0x100,
GPERM_ALL = GPERM_INVITE|GPERM_EXPEL|GPERM_STORAGE,
#else
GPERM_ALL = GPERM_INVITE|GPERM_EXPEL,
#endif
GPERM_MASK = GPERM_ALL,
GPERM_DEFAULT = GPERM_ALL,
};

enum {
Expand Down
2 changes: 2 additions & 0 deletions src/map/atcommand.c
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,8 @@ ACMD(guildstorage)
clif->message(fd, msg_fd(fd,252)); // You are not in a guild
else if (retval == 3)
clif->message(fd, msg_fd(fd,335)); // Your guild doesn't have storage!
else if (retval == 4)
clif->message(fd, msg_fd(fd,336)); // You're not authorized to open your guild storage!
else // retval == 1 or unknown results
clif->message(fd, msg_fd(fd,1201)); // Your guild's storage has already been opened by another member, try again later.
return false;
Expand Down
20 changes: 14 additions & 6 deletions src/map/guild.c
Original file line number Diff line number Diff line change
Expand Up @@ -1114,16 +1114,24 @@ int guild_memberposition_changed(struct guild *g,int idx,int pos)
return 0;
}

/*====================================================
* Change guild title or member
*---------------------------------------------------*/
int guild_change_position(int guild_id,int idx,int mode,int exp_mode,const char *name)
{
/**
* Changes guild title or permission information of member with pos idx
*
* @param idx - Position id
* @param mode @see0x001 - Can invite
* @param mode 0x010 - Can expel
* @param mode 0x100 - Can use guild storage (PACKETVER >= 20140205)
* @param exp_mode - Exp tax (%)
* @param name - Title
*
* @retval true success
**/
bool guild_change_position(int guild_id,int idx,int mode,int exp_mode,const char *name) {
struct guild_position p;
nullpo_ret(name);

exp_mode = cap_value(exp_mode, 0, battle_config.guild_exp_limit);
p.mode=mode&GPERM_MASK;
p.mode = mode&GPERM_MASK;
p.exp_mode=exp_mode;
safestrncpy(p.name,name,NAME_LENGTH);
return intif->guild_position(guild_id,idx,&p);
Expand Down
2 changes: 1 addition & 1 deletion src/map/guild.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ struct guild_interface {
int (*recv_memberinfoshort) (int guild_id,int account_id,int char_id,int online,int lv,int class_);
int (*change_memberposition) (int guild_id,int account_id,int char_id,short idx);
int (*memberposition_changed) (struct guild *g,int idx,int pos);
int (*change_position) (int guild_id,int idx,int mode,int exp_mode,const char *name);
bool (*change_position) (int guild_id, int idx, int mode, int exp_mode, const char *name);
int (*position_changed) (int guild_id, int idx, const struct guild_position *p);
int (*change_notice) (struct map_session_data *sd,int guild_id,const char *mes1,const char *mes2);
int (*notice_changed) (int guild_id,const char *mes1,const char *mes2);
Expand Down
7 changes: 4 additions & 3 deletions src/map/intif.c
Original file line number Diff line number Diff line change
Expand Up @@ -804,19 +804,20 @@ int intif_guild_change_memberinfo(int guild_id,int account_id,int char_id,
}

// Request a change of Guild title
int intif_guild_position(int guild_id,int idx,struct guild_position *p)
bool intif_guild_position(int guild_id,int idx,struct guild_position *p)
{
if (intif->CheckForCharServer())
return 0;
return false;
nullpo_ret(p);

WFIFOHEAD(inter_fd, sizeof(struct guild_position)+12);
WFIFOW(inter_fd,0)=0x303b;
WFIFOW(inter_fd,2)=sizeof(struct guild_position)+12;
WFIFOL(inter_fd,4)=guild_id;
WFIFOL(inter_fd,8)=idx;
memcpy(WFIFOP(inter_fd,12),p,sizeof(struct guild_position));
WFIFOSET(inter_fd,WFIFOW(inter_fd,2));
return 0;
return true;
}

// Request an update of Guildskill skill_id
Expand Down
2 changes: 1 addition & 1 deletion src/map/intif.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ struct intif_interface {
int (*guild_change_gm) (int guild_id, const char *name, int len);
int (*guild_change_basicinfo) (int guild_id, int type, const void *data, int len);
int (*guild_change_memberinfo) (int guild_id, int account_id, int char_id, int type, const void *data, int len);
int (*guild_position) (int guild_id, int idx, struct guild_position *p);
bool (*guild_position) (int guild_id, int idx, struct guild_position *p);
int (*guild_skillup) (int guild_id, uint16 skill_id, int account_id, int max);
int (*guild_alliance) (int guild_id1, int guild_id2, int account_id1, int account_id2, int flag);
int (*guild_notice) (int guild_id, const char *mes1, const char *mes2);
Expand Down
9 changes: 9 additions & 0 deletions src/map/storage.c
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,7 @@ void guild_storage_delete(int guild_id)
* @retval 1 storage is already open (storage_flag).
* @retval 2 sd has no guild / guild information hasn't arrived yet.
* @retval 3 sd's guild doesn't have GD_GUILD_STORAGE (msg_txt(335)) (if OFFICIAL_GUILD_STORAGE / PACKETVER >= 20131223)
* @retval 4 sd doesn't have permission to use storage (msg_txt(336)) (PACKETVER >= 20140205)
*/
int storage_guild_storageopen(struct map_session_data *sd)
{
Expand All @@ -434,6 +435,14 @@ int storage_guild_storageopen(struct map_session_data *sd)
return 3; // Can't open storage if guild has none
#endif // OFFICIAL_GUILD_STORAGE

#if PACKETVER >= 20140205
{
int pos;
if( (pos = guild->getposition(sd->guild, sd)) < 0 || !(sd->guild->position[pos].mode&GPERM_STORAGE) )
return 4; // Doesn't have permission
}
#endif // PACKETVER >= 20140205

if (!pc_can_give_items(sd)) { // check if this GM level can open guild storage and store items [Lupus]
clif->message(sd->fd, msg_sd(sd,246));
return 1;
Expand Down

0 comments on commit 59802a9

Please sign in to comment.