Skip to content
Permalink
Browse files

Merge pull request #2221 from carloshenrq/nostorage

Mapflag nostorage and nogstorage
  • Loading branch information...
MishimaHaruna committed Jun 2, 2019
2 parents bfc31c3 + 582336d commit eb0faf2b3ecc294d8247ce9afb81198730d516d2
Showing with 83 additions and 3 deletions.
  1. +2 −0 db/constants.conf
  2. +2 −0 doc/constants.md
  3. +1 −0 doc/permissions.md
  4. +9 −0 doc/script_commands.txt
  5. +13 −2 src/map/atcommand.c
  6. +26 −0 src/map/map.c
  7. +2 −0 src/map/map.h
  8. +4 −0 src/map/npc.c
  9. +1 −0 src/map/pc_groups.c
  10. +1 −0 src/map/pc_groups.h
  11. +19 −0 src/map/script.c
  12. +3 −1 src/map/script.h
@@ -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
@@ -362,6 +362,8 @@
- `mf_noviewid`: 56
- `mf_pairship_startable`: 57
- `mf_pairship_endable`: 58
- `mf_nostorage`: 59
- `mf_nogstorage`: 60

### Cell Properties

@@ -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.

@@ -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()
@@ -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>)
@@ -8332,6 +8340,7 @@ Valid <permission> are:
PERM_DISABLE_STORE
PERM_DISABLE_EXP
PERM_DISABLE_SKILL_USAGE
PERM_BYPASS_NOSTORAGE

Example:

@@ -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;
@@ -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;
@@ -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.
@@ -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.
@@ -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

@@ -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;
@@ -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;
@@ -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);
}
@@ -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);

@@ -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
@@ -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.
@@ -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;
@@ -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;
}
}

@@ -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;
}
}

@@ -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;
}
}

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);
@@ -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 {

0 comments on commit eb0faf2

Please sign in to comment.
You can’t perform that action at this time.