diff options
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/atcommand.c | 4 | ||||
-rw-r--r-- | src/map/channel.c | 17 | ||||
-rw-r--r-- | src/map/channel.h | 1 | ||||
-rw-r--r-- | src/map/map.c | 24 | ||||
-rw-r--r-- | src/map/map.h | 1 | ||||
-rw-r--r-- | src/map/npc.c | 2 | ||||
-rw-r--r-- | src/map/script.c | 33 |
7 files changed, 55 insertions, 27 deletions
diff --git a/src/map/atcommand.c b/src/map/atcommand.c index 809a740d7..236975b32 100644 --- a/src/map/atcommand.c +++ b/src/map/atcommand.c @@ -9387,8 +9387,8 @@ ACMD(channel) } else { int v = atoi(sub3); if (k == HCS_OPT_MSG_DELAY) { - if (v < 0 || v > 10) { - safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd,1451), v, opt_str[k]);// value '%d' for option '%s' is out of range (limit is 0-10) + if (v < 0 || v > channel->config->channel_opt_msg_delay) { + safesnprintf(atcmd_output, sizeof(atcmd_output), msg_fd(fd, 1451), v, opt_str[k], channel->config->channel_opt_msg_delay);// value '%d' for option '%s' is out of range (limit is 0-%d) clif->message(fd, atcmd_output); return false; } diff --git a/src/map/channel.c b/src/map/channel.c index f1946385d..3ba56b100 100644 --- a/src/map/channel.c +++ b/src/map/channel.c @@ -276,7 +276,9 @@ static void channel_send(struct channel_data *chan, struct map_session_data *sd, if (sd && chan->msg_delay != 0 && DIFF_TICK(sd->hchsysch_tick + chan->msg_delay*1000, timer->gettick()) > 0 && !pc_has_permission(sd, PC_PERM_HCHSYS_ADMIN)) { - clif->messagecolor_self(sd->fd, COLOR_RED, msg_sd(sd,1455)); + char output[CHAT_SIZE_MAX]; + sprintf(output, msg_sd(sd, 1455), DIFF_TICK(sd->hchsysch_tick + chan->msg_delay * 1000, timer->gettick()) / 1000); // "You cannot send a message to this channel for another %d seconds." + clif->messagecolor_self(sd->fd, COLOR_RED, output); return; } else if (sd) { int i; @@ -622,7 +624,8 @@ static void read_channels_config(void) irc_autojoin = 0, irc_flood_protection_rate = 0, irc_flood_protection_burst = 0, - irc_flood_protection_enabled = 0; + irc_flood_protection_enabled = 0, + channel_opt_msg_delay = 10; if( !libconfig->setting_lookup_string(settings, "map_local_channel_name", &local_name) ) local_name = "map"; @@ -818,6 +821,16 @@ static void read_channels_config(void) } } + libconfig->setting_lookup_int(settings, "channel_opt_msg_delay", &channel_opt_msg_delay); + if (channel_opt_msg_delay < 0) { + ShowWarning("channels.conf: channel_opt_msg_delay value '%d' must be from 0-255. Defaulting to 0...\n", channel_opt_msg_delay); + channel_opt_msg_delay = 0; + } else if (channel_opt_msg_delay > 255) { + ShowWarning("channels.conf: channel_opt_msg_delay value '%d' must be from 0-255. Defaulting to 255...\n", channel_opt_msg_delay); + channel_opt_msg_delay = 255; + } + channel->config->channel_opt_msg_delay = channel_opt_msg_delay; + ShowStatus("Done reading '"CL_WHITE"%u"CL_RESET"' channels in '"CL_WHITE"%s"CL_RESET"'.\n", db_size(channel->db), config_filename); } libconfig->destroy(&channels_conf); diff --git a/src/map/channel.h b/src/map/channel.h index 4ac3c6037..c56227c66 100644 --- a/src/map/channel.h +++ b/src/map/channel.h @@ -75,6 +75,7 @@ struct Channel_Config { char irc_server[40], irc_channel[50], irc_nick[40], irc_nick_pw[30]; unsigned short irc_server_port; bool irc_use_ghost; + int channel_opt_msg_delay; }; struct channel_ban_entry { diff --git a/src/map/map.c b/src/map/map.c index a352d34b0..d4d6e3323 100644 --- a/src/map/map.c +++ b/src/map/map.c @@ -3707,7 +3707,7 @@ static void map_zonedb_reload(void) { // first, reset maps to their initial zones: for (int i = 0; i < map->count; i++) { - map->zone_remove(i); + map->zone_remove_all(i); if (battle_config.pk_mode) { map->list[i].flag.pvp = 1; @@ -4688,6 +4688,27 @@ static void map_zone_remove(int m) map->list[m].zone_mf = NULL; map->list[m].zone_mf_count = 0; } +// this one removes every flag, even if they were previously turned on before +// the current zone was applied +static void map_zone_remove_all(int m) +{ + Assert_retv(m >= 0 && m < map->count); + + for (unsigned short k = 0; k < map->list[m].zone_mf_count; k++) { + char flag[MAP_ZONE_MAPFLAG_LENGTH]; + + memcpy(flag, map->list[m].zone_mf[k], MAP_ZONE_MAPFLAG_LENGTH); + strtok(flag, "\t"); + + npc->parse_mapflag(map->list[m].name, "", flag, "off", "", "", "", NULL); + aFree(map->list[m].zone_mf[k]); + map->list[m].zone_mf[k] = NULL; + } + + aFree(map->list[m].zone_mf); + map->list[m].zone_mf = NULL; + map->list[m].zone_mf_count = 0; +} static inline void map_zone_mf_cache_add(int m, char *rflag) { Assert_retv(m >= 0 && m < map->count); @@ -6840,6 +6861,7 @@ void map_defaults(void) /* funcs */ map->zone_init = map_zone_init; map->zone_remove = map_zone_remove; + map->zone_remove_all = map_zone_remove_all; map->zone_apply = map_zone_apply; map->zone_change = map_zone_change; map->zone_change2 = map_zone_change2; diff --git a/src/map/map.h b/src/map/map.h index 0e38bdb13..4267c2c88 100644 --- a/src/map/map.h +++ b/src/map/map.h @@ -1220,6 +1220,7 @@ END_ZEROED_BLOCK; /* funcs */ void (*zone_init) (void); void (*zone_remove) (int m); + void (*zone_remove_all) (int m); void (*zone_apply) (int m, struct map_zone_data *zone, const char* start, const char* buffer, const char* filepath); void (*zone_change) (int m, struct map_zone_data *zone, const char* start, const char* buffer, const char* filepath); void (*zone_change2) (int m, struct map_zone_data *zone); diff --git a/src/map/npc.c b/src/map/npc.c index a8bf7d371..7f57a9c50 100644 --- a/src/map/npc.c +++ b/src/map/npc.c @@ -4971,6 +4971,7 @@ static int npc_reload(void) npc->npc_mob = npc->npc_cache_mob = npc->npc_delay_mob = 0; // reset mapflags + map->zone_reload(); map->flags_init(); // Reprocess npc files and reload constants @@ -4980,7 +4981,6 @@ static int npc_reload(void) instance->reload(); - map->zone_reload(); map->zone_init(); npc->motd = npc->name2id("HerculesMOTD"); /* [Ind/Hercules] */ diff --git a/src/map/script.c b/src/map/script.c index fc1ece663..8c09bb8d8 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -8698,32 +8698,23 @@ static BUILDIN(getcharid) return true; } + /*========================================== * returns the GID of an NPC *------------------------------------------*/ static BUILDIN(getnpcid) { - int num = script_getnum(st,2); - struct npc_data* nd = NULL; - - if( script_hasdata(st,3) ) - {// unique npc name - if( ( nd = npc->name2id(script_getstr(st,3)) ) == NULL ) - { - ShowError("buildin_getnpcid: No such NPC '%s'.\n", script_getstr(st,3)); - script_pushint(st,0); - return false; + if (script_hasdata(st, 2)) { + if (script_isinttype(st, 2)) { + // Deprecate old form - getnpcid(<type>{, <"npc name">}) + ShowWarning("buildin_getnpcid: Use of type is deprecated. Format - getnpcid({<\"npc name\">})\n"); + script_pushint(st, 0); + } else { + struct npc_data *nd = npc->name2id(script_getstr(st, 2)); + script_pushint(st, (nd != NULL) ? nd->bl.id : 0); } - } - - switch (num) { - case 0: - script_pushint(st,nd ? nd->bl.id : st->oid); - break; - default: - ShowError("buildin_getnpcid: invalid parameter (%d).\n", num); - script_pushint(st,0); - return false; + } else { + script_pushint(st, st->oid); } return true; @@ -25016,7 +25007,7 @@ static void script_parse_builtin(void) BUILDIN_DEF(readparam,"i?"), BUILDIN_DEF(setparam,"ii?"), BUILDIN_DEF(getcharid,"i?"), - BUILDIN_DEF(getnpcid,"i?"), + BUILDIN_DEF(getnpcid, "?"), BUILDIN_DEF(getpartyname,"i"), BUILDIN_DEF(getpartymember,"i?"), BUILDIN_DEF(getpartyleader,"i?"), |