Skip to content

Commit

Permalink
Merge pull request #2221 from carloshenrq/nostorage
Browse files Browse the repository at this point in the history
Mapflag nostorage and nogstorage
  • Loading branch information
MishimaHaruna committed Jun 2, 2019
2 parents bfc31c3 + 582336d commit eb0faf2
Show file tree
Hide file tree
Showing 12 changed files with 83 additions and 3 deletions.
2 changes: 2 additions & 0 deletions db/constants.conf
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,8 @@ constants_db: {
mf_noviewid: 56
mf_pairship_startable: 57
mf_pairship_endable: 58
mf_nostorage: 59
mf_nogstorage: 60

comment__: "Cell Properties"
cell_walkable: 0
Expand Down
2 changes: 2 additions & 0 deletions doc/constants.md
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,8 @@
- `mf_noviewid`: 56
- `mf_pairship_startable`: 57
- `mf_pairship_endable`: 58
- `mf_nostorage`: 59
- `mf_nogstorage`: 60

### Cell Properties

Expand Down
1 change: 1 addition & 0 deletions doc/permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ disable_pickup | Ability to disable the player from picking up any i
disable_exp | Ability to disable the player from gaining any experience point.
disable_store | Ability to disable the player from using/openning npc and player stores.
disable_skill_usage | Ability to disable the player from using any skill.
bypass_nostorage | Ability to bypass the nostorage and nogstorage mapflag.

9 changes: 9 additions & 0 deletions doc/script_commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5803,6 +5803,10 @@ storage window, to avoid any disruption when both windows overlap.
openstorage();
end;

The mapflag 'nostorage' when set to type '2' (or 3), will not open the
account storage. Unless the character group has the permission 'bypass_nostorage'.
In case blocked by mapflag, returns 0.

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

*openmail()
Expand Down Expand Up @@ -5864,6 +5868,10 @@ time.
This will also fail and return 2 if the attached character does not belong
to any guild.

The mapflag 'nogstorage' when set to type '2' (or 3), will not open the
guild storage. Unless the character group has the permission 'bypass_nostorage'.
In case blocked by mapflag, returns 1.

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

*guildchangegm(<guild id>, <new master's name>)
Expand Down Expand Up @@ -8332,6 +8340,7 @@ Valid <permission> are:
PERM_DISABLE_STORE
PERM_DISABLE_EXP
PERM_DISABLE_SKILL_USAGE
PERM_BYPASS_NOSTORAGE

Example:

Expand Down
15 changes: 13 additions & 2 deletions src/map/atcommand.c
Original file line number Diff line number Diff line change
Expand Up @@ -872,6 +872,11 @@ ACMD(storage)
if (sd->npc_id || sd->state.vending || sd->state.prevend || sd->state.buyingstore || sd->state.trading || sd->state.storage_flag)
return false;

if (!pc_has_permission(sd, PC_PERM_BYPASS_NOSTORAGE) && (map->list[sd->bl.m].flag.nostorage & 1)) { // mapflag nostorage already defined? can't open :c
clif->message(fd, msg_fd(fd, 1161)); // You currently cannot open your storage.
return false;
}

if (storage->open(sd) == 1) { //Already open.
clif->message(fd, msg_fd(fd,250)); // You have already opened your storage. Close it first.
return false;
Expand Down Expand Up @@ -905,6 +910,11 @@ ACMD(guildstorage)
return false;
}

if (!pc_has_permission(sd, PC_PERM_BYPASS_NOSTORAGE) && (map->list[sd->bl.m].flag.nogstorage & 1)) { // mapflag nogstorage already defined? can't open :c
clif->message(fd, msg_fd(fd, 1161)); // You currently cannot open your storage. (there is no other messages...)
return false;
}

if( gstorage->open(sd) ) {
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 Expand Up @@ -7757,6 +7767,7 @@ ACMD(mapflag)
CHECKFLAG(nodrop); CHECKFLAG(novending); CHECKFLAG(loadevent);
CHECKFLAG(nochat); CHECKFLAG(partylock); CHECKFLAG(guildlock); CHECKFLAG(src4instance);
CHECKFLAG(notomb); CHECKFLAG(nocashshop); CHECKFLAG(noviewid); CHECKFLAG(town);
CHECKFLAG(nostorage); CHECKFLAG(nogstorage);
clif->message(sd->fd," ");
clif->message(sd->fd,msg_fd(fd,1312)); // Usage: "@mapflag monster_noteleport 1" (0=Off | 1=On)
clif->message(sd->fd,msg_fd(fd,1313)); // Type "@mapflag available" to list the available mapflags.
Expand Down Expand Up @@ -7798,7 +7809,7 @@ ACMD(mapflag)
SETFLAG(nomvploot); SETFLAG(nightenabled); SETFLAG(nodrop); SETFLAG(novending);
SETFLAG(loadevent); SETFLAG(nochat); SETFLAG(partylock); SETFLAG(guildlock);
SETFLAG(src4instance); SETFLAG(notomb); SETFLAG(nocashshop); SETFLAG(noviewid);
SETFLAG(town);
SETFLAG(town); SETFLAG(nostorage); SETFLAG(nogstorage);


clif->message(sd->fd, msg_fd(fd, 1314)); // Invalid flag name or flag.
Expand All @@ -7811,7 +7822,7 @@ ACMD(mapflag)
clif->message(sd->fd, "nozenypenalty, notrade, noskill, nowarp, nowarpto, noicewall, snow, clouds, clouds2,");
clif->message(sd->fd, "fog, fireworks, sakura, leaves, nobaseexp, nojobexp, nomobloot,");
clif->message(sd->fd, "nomvploot, nightenabled, nodrop, novending, loadevent, nochat, partylock,");
clif->message(sd->fd, "guildlock, src4instance, notomb, nocashshop, noviewid");
clif->message(sd->fd, "guildlock, src4instance, notomb, nocashshop, noviewid, nostorage, nogstorage");
#undef CHECKFLAG
#undef SETFLAG

Expand Down
26 changes: 26 additions & 0 deletions src/map/map.c
Original file line number Diff line number Diff line change
Expand Up @@ -5379,6 +5379,32 @@ static bool map_zone_mf_cache(int m, char *flag, char *params)
else if( map->list[m].flag.nocashshop )
map_zone_mf_cache_add(m,"nocashshop");
}
} else if (strcmpi(flag, "nostorage") == 0) {
if (!state) {
if (map->list[m].flag.nostorage != 0) {
sprintf(rflag, "nostorage\t%d", map->list[m].flag.nostorage);
map_zone_mf_cache_add(m, rflag);
}
}
if (sscanf(params, "%d", &state) == 1) {
if (state != map->list[m].flag.nostorage) {
sprintf(rflag, "nostorage\t%d", state);
map_zone_mf_cache_add(m, rflag);
}
}
} else if (strcmpi(flag, "nogstorage") == 0) {
if (!state) {
if (map->list[m].flag.nogstorage != 0) {
sprintf(rflag, "nogstorage\t%d", map->list[m].flag.nogstorage);
map_zone_mf_cache_add(m, rflag);
}
}
if (sscanf(params, "%d", &state) == 1) {
if (state != map->list[m].flag.nogstorage) {
sprintf(rflag, "nogstorage\t%d", state);
map_zone_mf_cache_add(m, rflag);
}
}
}

return false;
Expand Down
2 changes: 2 additions & 0 deletions src/map/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,8 @@ struct map_data {
unsigned noautoloot : 1;
unsigned pairship_startable : 1;
unsigned pairship_endable : 1;
unsigned nostorage : 2;
unsigned nogstorage : 2;
uint32 noviewid; ///< noviewid (bitmask - @see enum equip_pos)
} flag;
struct point save;
Expand Down
4 changes: 4 additions & 0 deletions src/map/npc.c
Original file line number Diff line number Diff line change
Expand Up @@ -4797,6 +4797,10 @@ static const char *npc_parse_mapflag(const char *w1, const char *w2, const char
map->list[m].flag.pairship_startable = (state) ? 1 : 0;
} else if (!strcmpi(w3, "pairship_endable")) {
map->list[m].flag.pairship_endable = (state) ? 1 : 0;
} else if (!strcmpi(w3, "nostorage")) {
map->list[m].flag.nostorage = (state) ? cap_value(atoi(w4), 1, 3) : 0;
} else if (!strcmpi(w3, "nogstorage")) {
map->list[m].flag.nogstorage = (state) ? cap_value(atoi(w4), 1, 3) : 0;
} else {
npc->parse_unknown_mapflag(mapname, w3, w4, start, buffer, filepath, retval);
}
Expand Down
1 change: 1 addition & 0 deletions src/map/pc_groups.c
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,7 @@ static void do_init_pc_groups(void)
{ "disable_store", PC_PERM_DISABLE_STORE },
{ "disable_exp", PC_PERM_DISABLE_EXP },
{ "disable_skill_usage", PC_PERM_DISABLE_SKILL_USAGE },
{ "bypass_nostorage", PC_PERM_BYPASS_NOSTORAGE },
};
unsigned char i, len = ARRAYLENGTH(pc_g_defaults);

Expand Down
1 change: 1 addition & 0 deletions src/map/pc_groups.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ enum e_pc_permission {
PC_PERM_DISABLE_STORE = 0x1000000,
PC_PERM_DISABLE_EXP = 0x2000000,
PC_PERM_DISABLE_SKILL_USAGE = 0x4000000,
PC_PERM_BYPASS_NOSTORAGE = 0x8000000,
};

// Cached config settings for quick lookup
Expand Down
19 changes: 19 additions & 0 deletions src/map/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -10766,6 +10766,12 @@ static BUILDIN(openstorage)
return false;
}

// Mapflag preventing from openstorage here
if (!pc_has_permission(sd, PC_PERM_BYPASS_NOSTORAGE) && (map->list[sd->bl.m].flag.nostorage & 2)) {
script_pushint(st, 0);
return true;
}

storage->open(sd);

script_pushint(st, 1); // success flag.
Expand All @@ -10779,6 +10785,12 @@ static BUILDIN(guildopenstorage)
if (sd == NULL)
return true;

// Mapflag preventing from openstorage here
if (!pc_has_permission(sd, PC_PERM_BYPASS_NOSTORAGE) && (map->list[sd->bl.m].flag.nogstorage & 2)) {
script_pushint(st, 1);
return true;
}

ret = gstorage->open(sd);
script_pushint(st,ret);
return true;
Expand Down Expand Up @@ -13306,6 +13318,8 @@ static BUILDIN(getmapflag)
case MF_NOVIEWID: script_pushint(st, map->list[m].flag.noviewid); break;
case MF_PAIRSHIP_STARTABLE: script_pushint(st, map->list[m].flag.pairship_startable); break;
case MF_PAIRSHIP_ENDABLE: script_pushint(st, map->list[m].flag.pairship_endable); break;
case MF_NOSTORAGE: script_pushint(st, map->list[m].flag.nostorage); break;
case MF_NOGSTORAGE: script_pushint(st, map->list[m].flag.nogstorage); break;
}
}

Expand Down Expand Up @@ -13436,6 +13450,8 @@ static BUILDIN(setmapflag)
case MF_NOVIEWID: map->list[m].flag.noviewid = (val <= 0) ? EQP_NONE : val; break;
case MF_PAIRSHIP_STARTABLE: map->list[m].flag.pairship_startable = 1; break;
case MF_PAIRSHIP_ENDABLE: map->list[m].flag.pairship_endable = 1; break;
case MF_NOSTORAGE: map->list[m].flag.nostorage = cap_value(val, 0, 3); break;
case MF_NOGSTORAGE: map->list[m].flag.nogstorage = cap_value(val, 0, 3); break;
}
}

Expand Down Expand Up @@ -13527,6 +13543,8 @@ static BUILDIN(removemapflag)
case MF_NOCASHSHOP: map->list[m].flag.nocashshop = 0; break;
case MF_NOAUTOLOOT: map->list[m].flag.noautoloot = 0; break;
case MF_NOVIEWID: map->list[m].flag.noviewid = EQP_NONE; break;
case MF_NOSTORAGE: map->list[m].flag.nostorage = 0; break;
case MF_NOGSTORAGE: map->list[m].flag.nogstorage = 0; break;
}
}

Expand Down Expand Up @@ -26444,6 +26462,7 @@ static void script_hardcoded_constants(void)
script->set_constant("PERM_DISABLE_STORE", PC_PERM_DISABLE_STORE, false, false);
script->set_constant("PERM_DISABLE_EXP", PC_PERM_DISABLE_EXP, false, false);
script->set_constant("PERM_DISABLE_SKILL_USAGE", PC_PERM_DISABLE_SKILL_USAGE, false, false);
script->set_constant("PERM_BYPASS_NOSTORAGE", PC_PERM_BYPASS_NOSTORAGE, false, false);

script->constdb_comment("Data types");
script->set_constant("DATATYPE_NIL", DATATYPE_NIL, false, false);
Expand Down
4 changes: 3 additions & 1 deletion src/map/script.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,9 @@ enum {
MF_NOAUTOLOOT,
MF_NOVIEWID,
MF_PAIRSHIP_STARTABLE,
MF_PAIRSHIP_ENDABLE
MF_PAIRSHIP_ENDABLE,
MF_NOSTORAGE,
MF_NOGSTORAGE
};

enum navigation_service {
Expand Down

0 comments on commit eb0faf2

Please sign in to comment.