Corrected some map property issues (#3435)
* Resolves PvP timers and effects not displaying properly. * Resolves any GvG effects not displaying properly. * If PvP or GvG is disabled, stop players from attacking. * Moved PvP timer and attack functions to appropriate locations. * Removed redundancy from atcommands.
This commit is contained in:
@@ -4404,12 +4404,12 @@ void map_skill_damage_add(struct map_data *m, uint16 skill_id, int rate[SKILLDMG
|
||||
}
|
||||
|
||||
/**
|
||||
* PvP timer handling
|
||||
* PvP timer handling (starting)
|
||||
* @param bl: Player block object
|
||||
* @param ap: func* with va_list values
|
||||
* @return 0
|
||||
*/
|
||||
static int map_mapflag_pvp_sub(struct block_list *bl, va_list ap)
|
||||
static int map_mapflag_pvp_start_sub(struct block_list *bl, va_list ap)
|
||||
{
|
||||
struct map_session_data *sd = map_id2sd(bl->id);
|
||||
|
||||
@@ -4428,6 +4428,26 @@ static int map_mapflag_pvp_sub(struct block_list *bl, va_list ap)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* PvP timer handling (stopping)
|
||||
* @param bl: Player block object
|
||||
* @param ap: func* with va_list values
|
||||
* @return 0
|
||||
*/
|
||||
static int map_mapflag_pvp_stop_sub(struct block_list *bl, va_list ap)
|
||||
{
|
||||
struct map_session_data* sd = map_id2sd(bl->id);
|
||||
|
||||
clif_pvpset(sd, 0, 0, 2);
|
||||
|
||||
if (sd->pvp_timer != INVALID_TIMER) {
|
||||
delete_timer(sd->pvp_timer, pc_calc_pvprank_timer);
|
||||
sd->pvp_timer = INVALID_TIMER;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the mapflag enum from the given name.
|
||||
* @param name: Mapflag name
|
||||
@@ -4481,7 +4501,7 @@ bool map_getmapflag_name( enum e_mapflag mapflag, char* output ){
|
||||
*/
|
||||
int map_getmapflag_sub(int16 m, enum e_mapflag mapflag, union u_mapflag_args *args)
|
||||
{
|
||||
if (m < 0) {
|
||||
if (m < 0 || m >= MAX_MAP_PER_SERVER) {
|
||||
ShowWarning("map_getmapflag: Invalid map ID %d.\n", m);
|
||||
return -1;
|
||||
}
|
||||
@@ -4531,7 +4551,7 @@ int map_getmapflag_sub(int16 m, enum e_mapflag mapflag, union u_mapflag_args *ar
|
||||
*/
|
||||
bool map_setmapflag_sub(int16 m, enum e_mapflag mapflag, bool status, union u_mapflag_args *args)
|
||||
{
|
||||
if (m < 0) {
|
||||
if (m < 0 || m >= MAX_MAP_PER_SERVER) {
|
||||
ShowWarning("map_setmapflag: Invalid map ID %d.\n", m);
|
||||
return false;
|
||||
}
|
||||
@@ -4555,11 +4575,16 @@ bool map_setmapflag_sub(int16 m, enum e_mapflag mapflag, bool status, union u_ma
|
||||
mapdata->flag[mapflag] = status;
|
||||
break;
|
||||
case MF_PVP:
|
||||
if (!status)
|
||||
mapdata->flag[mapflag] = status; // Must come first to properly set map property
|
||||
if (!status) {
|
||||
clif_map_property_mapall(m, MAPPROPERTY_NOTHING);
|
||||
else {
|
||||
if (!battle_config.pk_mode)
|
||||
map_foreachinmap(map_mapflag_pvp_sub, m, BL_PC);
|
||||
map_foreachinmap(map_mapflag_pvp_stop_sub, m, BL_PC);
|
||||
map_foreachinmap(unit_stopattack, m, BL_CHAR, 0);
|
||||
} else {
|
||||
if (!battle_config.pk_mode) {
|
||||
clif_map_property_mapall(m, MAPPROPERTY_FREEPVPZONE);
|
||||
map_foreachinmap(map_mapflag_pvp_start_sub, m, BL_PC);
|
||||
}
|
||||
if (mapdata->flag[MF_GVG]) {
|
||||
mapdata->flag[MF_GVG] = false;
|
||||
ShowWarning("map_setmapflag: Unable to set GvG and PvP flags for the same map! Removing GvG flag from %s.\n", mapdata->name);
|
||||
@@ -4585,13 +4610,14 @@ bool map_setmapflag_sub(int16 m, enum e_mapflag mapflag, bool status, union u_ma
|
||||
ShowWarning("map_setmapflag: Unable to set Battleground and PvP flags for the same map! Removing Battleground flag from %s.\n", mapdata->name);
|
||||
}
|
||||
}
|
||||
mapdata->flag[mapflag] = status;
|
||||
break;
|
||||
case MF_GVG:
|
||||
case MF_GVG_TE:
|
||||
if (!status)
|
||||
mapdata->flag[mapflag] = status; // Must come first to properly set map property
|
||||
if (!status) {
|
||||
clif_map_property_mapall(m, MAPPROPERTY_NOTHING);
|
||||
else {
|
||||
map_foreachinmap(unit_stopattack, m, BL_CHAR, 0);
|
||||
} else {
|
||||
clif_map_property_mapall(m, MAPPROPERTY_AGITZONE);
|
||||
if (mapdata->flag[MF_PVP]) {
|
||||
mapdata->flag[MF_PVP] = false;
|
||||
@@ -4603,7 +4629,6 @@ bool map_setmapflag_sub(int16 m, enum e_mapflag mapflag, bool status, union u_ma
|
||||
ShowWarning("map_setmapflag: Unable to set Battleground and GvG flags for the same map! Removing Battleground flag from %s.\n", mapdata->name);
|
||||
}
|
||||
}
|
||||
mapdata->flag[mapflag] = status;
|
||||
break;
|
||||
case MF_GVG_CASTLE:
|
||||
case MF_GVG_TE_CASTLE:
|
||||
|
||||
Reference in New Issue
Block a user