summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/char/char.c10
-rw-r--r--src/map/map.c13
-rw-r--r--src/map/map.h1
-rw-r--r--src/map/script.c14
4 files changed, 27 insertions, 11 deletions
diff --git a/src/char/char.c b/src/char/char.c
index 54f6ca7d1..4ce4c55fe 100644
--- a/src/char/char.c
+++ b/src/char/char.c
@@ -139,6 +139,7 @@ char char_name_letters[1024] = ""; // list of letters/symbols allowed (or not) i
static int char_del_level = 0; ///< From which level you can delete character [Lupus]
static int char_del_delay = 86400;
static bool char_aegis_delete = false; ///< Verify if char is in guild/party or char and reacts as Aegis does (disallow deletion), @see chr->delete2_req.
+static bool char_aegis_rename = false; // whether or not the player can be renamed while in party/guild
static int max_connect_user = -1;
static int gm_allow_group = -1;
@@ -1514,6 +1515,14 @@ static int char_rename_char_sql(struct char_session_data *sd, int char_id)
if( char_dat.rename == 0 )
return 1;
+ if (char_aegis_rename) {
+ if (char_dat.guild_id > 0) {
+ return 5; // MSG_FAILED_RENAME_BELONGS_TO_GUILD
+ } else if (char_dat.party_id > 0) {
+ return 6; // MSG_FAILED_RENAME_BELONGS_TO_PARTY
+ }
+ }
+
SQL->EscapeStringLen(inter->sql_handle, esc_name, sd->new_name, strnlen(sd->new_name, NAME_LENGTH));
// check if the char exist
@@ -5848,6 +5857,7 @@ static bool char_config_read_player_name(const char *filename, const struct conf
libconfig->setting_lookup_mutable_string(setting, "name_letters", char_name_letters, sizeof(char_name_letters));
libconfig->setting_lookup_int(setting, "name_option", &char_name_option);
libconfig->setting_lookup_bool_real(setting, "name_ignoring_case", &name_ignoring_case);
+ libconfig->setting_lookup_bool_real(setting, "use_aegis_rename", &char_aegis_rename);
return true;
}
diff --git a/src/map/map.c b/src/map/map.c
index 343f219b8..a352d34b0 100644
--- a/src/map/map.c
+++ b/src/map/map.c
@@ -635,6 +635,18 @@ static int map_foreachinmap(int (*func)(struct block_list*, va_list), int16 m, i
return returnCount;
}
+static int map_forcountinmap(int (*func)(struct block_list*, va_list), int16 m, int count, int type, ...)
+{
+ int returnCount;
+ va_list ap;
+
+ va_start(ap, type);
+ returnCount = map->vforcountinarea(func, m, 0, 0, map->list[m].bxs, map->list[m].bys, count, type, ap);
+ va_end(ap);
+
+ return returnCount;
+}
+
/**
* Applies func to every block_list object of bl_type type on all maps
* of instance instance_id.
@@ -6901,6 +6913,7 @@ void map_defaults(void)
map->foreachinpath = map_foreachinpath;
map->vforeachinmap = map_vforeachinmap;
map->foreachinmap = map_foreachinmap;
+ map->forcountinmap = map_forcountinmap;
map->vforeachininstance = map_vforeachininstance;
map->foreachininstance = map_foreachininstance;
diff --git a/src/map/map.h b/src/map/map.h
index cb025e9c1..0e38bdb13 100644
--- a/src/map/map.h
+++ b/src/map/map.h
@@ -1293,6 +1293,7 @@ END_ZEROED_BLOCK;
int (*foreachinpath) (int (*func)(struct block_list*,va_list), int16 m, int16 x0, int16 y0, int16 x1, int16 y1, int16 range, int length, int type, ...);
int (*vforeachinmap) (int (*func)(struct block_list*,va_list), int16 m, int type, va_list args);
int (*foreachinmap) (int (*func)(struct block_list*,va_list), int16 m, int type, ...);
+ int (*forcountinmap) (int (*func)(struct block_list*,va_list), int16 m, int count, int type, ...);
int (*vforeachininstance)(int (*func)(struct block_list*,va_list), int16 instance_id, int type, va_list ap);
int (*foreachininstance)(int (*func)(struct block_list*,va_list), int16 instance_id, int type,...);
diff --git a/src/map/script.c b/src/map/script.c
index 348d81a85..fc1ece663 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -11300,7 +11300,7 @@ static int buildin_getunits_sub(struct block_list *bl, va_list ap)
(const void *)h64BPTRSIZE(bl->id), ref);
(*count)++;
- return 0;
+ return 1;
}
static int buildin_getunits_sub_pc(struct map_session_data *sd, va_list ap)
@@ -11372,18 +11372,10 @@ static BUILDIN(getunits)
int16 x2 = script_getnum(st, 8);
int16 y2 = script_getnum(st, 9);
- // FIXME: map_foreachinarea does NOT stop iterating when the callback
- // function returns -1. we still limit the array size, but
- // this doesn't break the loop. We need a foreach function
- // that behaves like map_foreachiddb, but for areas
- map->foreachinarea(buildin_getunits_sub, m, x1, y1, x2, y2, type,
+ map->forcountinarea(buildin_getunits_sub, m, x1, y1, x2, y2, limit, type,
st, sd, id, start, &count, limit, name, ref, type);
} else {
- // FIXME: map_foreachinmap does NOT stop iterating when the callback
- // function returns -1. we still limit the array size, but
- // this doesn't break the loop. We need a foreach function
- // that behaves like map_foreachiddb, but for maps
- map->foreachinmap(buildin_getunits_sub, m, type,
+ map->forcountinmap(buildin_getunits_sub, m, limit, type,
st, sd, id, start, &count, limit, name, ref, type);
}
} else {