Explorar o código

Fix compilation issue

Follow up dae81222 (AEGIS class system) fix out of bound issue for
array.
(didn't check the x_ALL option system yet)
Follow up 7a9aa7fb Fix possible mapcrash due to offline player
Follow up 12007fef Fix some invalide string check and remove the
reverted sqlfiles
lighta %!s(int64=11) %!d(string=hai) anos
pai
achega
b695ab3f41

+ 0 - 50
sql-files/upgrades/upgrade_20131229.sql

@@ -1,50 +0,0 @@
-ALTER TABLE  `item_db2` CHANGE  `type`  `type` VARCHAR( 2 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db2` CHANGE  `price_buy`  `price_buy` VARCHAR( 11 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db2` CHANGE  `price_sell`  `price_sell` VARCHAR( 11 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db2` CHANGE  `weight`  `weight` VARCHAR( 5 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db2` CHANGE  `attack`  `attack` VARCHAR( 11 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db2` CHANGE  `defence`  `defence` VARCHAR( 5 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db2` CHANGE  `range`  `range` VARCHAR( 2 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db2` CHANGE  `slots`  `slots` VARCHAR( 2 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db2` CHANGE  `equip_jobs`  `equip_jobs` VARCHAR( 11 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db2` CHANGE  `equip_upper`  `equip_upper` VARCHAR( 2 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db2` CHANGE  `equip_genders`  `equip_genders` CHAR( 1 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db2` CHANGE  `equip_locations`  `equip_locations` VARCHAR( 8 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db2` CHANGE  `weapon_level`  `weapon_level` CHAR( 1 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db2` CHANGE  `equip_level`  `equip_level` VARCHAR( 4 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db2` CHANGE  `refineable`  `refineable` CHAR( 1 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db2` CHANGE  `view`  `view` VARCHAR( 5 ) NOT NULL DEFAULT  '0';
-
-ALTER TABLE  `item_db` CHANGE  `type`  `type` VARCHAR( 2 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db` CHANGE  `price_buy`  `price_buy` VARCHAR( 11 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db` CHANGE  `price_sell`  `price_sell` VARCHAR( 11 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db` CHANGE  `weight`  `weight` VARCHAR( 5 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db` CHANGE  `attack`  `attack` VARCHAR( 11 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db` CHANGE  `defence`  `defence` VARCHAR( 5 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db` CHANGE  `range`  `range` VARCHAR( 2 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db` CHANGE  `slots`  `slots` VARCHAR( 2 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db` CHANGE  `equip_jobs`  `equip_jobs` VARCHAR( 11 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db` CHANGE  `equip_upper`  `equip_upper` VARCHAR( 2 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db` CHANGE  `equip_genders`  `equip_genders` CHAR( 1 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db` CHANGE  `equip_locations`  `equip_locations` VARCHAR( 8 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db` CHANGE  `weapon_level`  `weapon_level` CHAR( 1 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db` CHANGE  `equip_level`  `equip_level` VARCHAR( 4 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db` CHANGE  `refineable`  `refineable` CHAR( 1 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db` CHANGE  `view`  `view` VARCHAR( 5 ) NOT NULL DEFAULT  '0';
-
-ALTER TABLE  `item_db_re` CHANGE  `type`  `type` VARCHAR( 2 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db_re` CHANGE  `price_buy`  `price_buy` VARCHAR( 11 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db_re` CHANGE  `price_sell`  `price_sell` VARCHAR( 11 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db_re` CHANGE  `weight`  `weight` VARCHAR( 5 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db_re` CHANGE  `atk:matk`  `atk:matk` VARCHAR( 11 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db_re` CHANGE  `defence`  `defence` VARCHAR( 5 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db_re` CHANGE  `range`  `range` VARCHAR( 2 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db_re` CHANGE  `slots`  `slots` VARCHAR( 2 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db_re` CHANGE  `equip_jobs`  `equip_jobs` VARCHAR( 11 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db_re` CHANGE  `equip_upper`  `equip_upper` VARCHAR( 2 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db_re` CHANGE  `equip_genders`  `equip_genders` CHAR( 1 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db_re` CHANGE  `equip_locations`  `equip_locations` VARCHAR( 8 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db_re` CHANGE  `weapon_level`  `weapon_level` CHAR( 1 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db_re` CHANGE  `equip_level`  `equip_level` VARCHAR( 4 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db_re` CHANGE  `refineable`  `refineable` CHAR( 1 ) NOT NULL DEFAULT  '0';
-ALTER TABLE  `item_db_re` CHANGE  `view`  `view` VARCHAR( 5 ) NOT NULL DEFAULT  '0';

+ 3 - 1
src/char/char.c

@@ -4137,7 +4137,9 @@ static void char_delete2_accept(int fd, struct char_session_data* sd)
 		return;
 	}
 
-	if( ( char_del_level > 0 && base_level >= (unsigned int)char_del_level ) || ( char_del_level < 0 && base_level <= (unsigned int)(-char_del_level) ) || !char_del_option&2 )
+	if( ( char_del_level > 0 && base_level >= (unsigned int)char_del_level ) 
+			|| ( char_del_level < 0 && base_level <= (unsigned int)(-char_del_level) ) 
+			|| !(char_del_option&2) )
 	{// character level config restriction
 		char_delete2_accept_ack(fd, char_id, 2);
 		return;

+ 1 - 1
src/map/atcommand.c

@@ -14,6 +14,7 @@
 #include "../common/utils.h"
 #include "../common/conf.h"
 
+#include "map.h"
 #include "atcommand.h"
 #include "battle.h"
 #include "chat.h"
@@ -25,7 +26,6 @@
 #include "intif.h"
 #include "itemdb.h"
 #include "log.h"
-#include "map.h"
 #include "pc.h"
 #include "pc_groups.h" // groupid2name
 #include "status.h"

+ 7 - 11
src/map/battle.c

@@ -35,7 +35,7 @@
 #include <string.h>
 #include <math.h>
 
-int attr_fix_table[4][ELE_ALL][ELE_ALL];
+int attr_fix_table[4][ELE_NONE][ELE_NONE];
 
 struct Battle_Config battle_config;
 static struct eri *delay_damage_ers; //For battle delay damage structures.
@@ -292,15 +292,11 @@ int battle_delay_damage (unsigned int tick, int amotion, struct block_list *src,
 
 	return 0;
 }
-int battle_attr_ratio(int atk_elem,int def_type, int def_lv)
-{
-
-	if (atk_elem < 0 || atk_elem >= ELE_ALL)
+int battle_attr_ratio(int atk_elem,int def_type, int def_lv){
+	if (atk_elem < ELE_NEUTRAL || atk_elem >= ELE_ALL)
 		return 100;
-
-	if (def_type < 0 || def_type > ELE_ALL || def_lv < 1 || def_lv > 4)
+	if (def_type < ELE_NEUTRAL || def_type > ELE_ALL || def_lv < 1 || def_lv > 4)
 		return 100;
-
 	return attr_fix_table[def_lv-1][atk_elem][def_type];
 }
 
@@ -317,10 +313,10 @@ int64 battle_attr_fix(struct block_list *src, struct block_list *target, int64 d
 	if (src) sc = status_get_sc(src);
 	if (target) tsc = status_get_sc(target);
 
-	if (atk_elem < 0 || atk_elem >= ELE_ALL)
+	if (atk_elem < ELE_NEUTRAL || atk_elem >= ELE_ALL)
 		atk_elem = rnd()%ELE_ALL;
 
-	if (def_type < 0 || def_type > ELE_ALL ||
+	if (def_type < ELE_NEUTRAL || def_type > ELE_ALL ||
 		def_lv < 1 || def_lv > 4) {
 		ShowError("battle_attr_fix: unknown attr type: atk=%d def_type=%d def_lv=%d\n",atk_elem,def_type,def_lv);
 		return damage;
@@ -5974,7 +5970,7 @@ void battle_drain(TBL_PC *sd, struct block_list *tbl, int64 rdamage, int64 ldama
 {
 	struct weapon_data *wd;
 	int64 *damage;
-	int thp = 0, tsp = 0, rhp = 0, rsp = 0, hp, sp, i;
+	int thp = 0, tsp = 0, rhp = 0, rsp = 0, hp=0, sp=0, i;
 	for (i = 0; i < 4; i++) {
 		//First two iterations: Right hand
 		if (i < 2) { wd = &sd->right_weapon; damage = &rdamage; }

+ 2 - 1
src/map/battle.h

@@ -6,6 +6,7 @@
 
 #include "../common/mmo.h"
 #include "../config/core.h"
+#include "map.h" //ELE_MAX
 
 // state of a single attack attempt; used in flee/def penalty calculations when mobbed
 typedef enum damage_lv {
@@ -59,7 +60,7 @@ struct Damage {
 };
 
 //(Used in read pc.c,) attribute table (battle_attr_fix)
-extern int attr_fix_table[4][10][10];
+extern int attr_fix_table[4][ELE_NONE][ELE_NONE];
 
 struct map_session_data;
 struct mob_data;

+ 1 - 1
src/map/chat.c

@@ -7,10 +7,10 @@
 #include "../common/showmsg.h"
 #include "../common/strlib.h"
 #include "../common/mmo.h"
+#include "map.h"
 #include "atcommand.h" // msg_txt()
 #include "battle.h" // struct battle_config
 #include "clif.h"
-#include "map.h"
 #include "npc.h" // npc_event_do()
 #include "pc.h"
 #include "skill.h" // ext_skill_unit_onplace()

+ 1 - 1
src/map/chrif.c

@@ -1859,7 +1859,7 @@ int chrif_load_bsdata(int fd) {
 		struct script_code *script;
 		struct bonus_script_data *bs = (struct bonus_script_data*)RFIFOP(fd,10 + i*sizeof(struct bonus_script_data));
 
-		if (bs->script == '\0' || !(script = parse_script(bs->script,"chrif_load_bsdata",1,1)))
+		if (bs->script[0] == '\0' || !(script = parse_script(bs->script,"chrif_load_bsdata",1,1)))
 			continue;
 
 		memcpy(sd->bonus_script[i].script_str,bs->script,strlen(bs->script));

+ 1 - 1
src/map/itemdb.c

@@ -1481,7 +1481,7 @@ static int itemdb_read_sqldb(void) {
 * 2 set new value bypassing anything
 * 3/other return last value
 *------------------------------------------*/
-static uint64 itemdb_unique_id(int8 flag, int64 value) {
+uint64 itemdb_unique_id(int8 flag, int64 value) {
 	static uint64 item_uid = 0;
 
 	if(flag)

+ 1 - 1
src/map/itemdb.h

@@ -428,7 +428,7 @@ struct item_data* itemdb_exists(int nameid);
 #define itemdb_iscashfood(id) ( (id) >= ITEMID_STR_DISH10_ && (id) <= ITEMID_VIT_DISH10_ )
 #define itemdb_is_GNbomb(n) (n >= ITEMID_APPLE_BOMB && n <= ITEMID_VERY_HARD_LUMP)
 #define itemdb_is_GNthrowable(n) (n >= ITEMID_MYSTERIOUS_POWDER && n <= ITEMID_BLACK_THING_TO_THROW)
-const char* itemdb_typename(int type);
+const char* itemdb_typename(enum item_types type);
 
 int itemdb_group_bonus(struct map_session_data* sd, int itemid);
 unsigned short itemdb_searchrandomid(int group_id, uint8 sub_group);

+ 1 - 1
src/map/log.c

@@ -6,10 +6,10 @@
 #include "../common/strlib.h"
 #include "../common/nullpo.h"
 #include "../common/showmsg.h"
+#include "map.h"
 #include "battle.h"
 #include "itemdb.h"
 #include "log.h"
-#include "map.h"
 #include "mob.h"
 #include "pc.h"
 

+ 8 - 6
src/map/map.h

@@ -280,7 +280,7 @@ enum bl_type {
 
 enum npc_subtype { WARP, SHOP, SCRIPT, CASHSHOP, ITEMSHOP, POINTSHOP, TOMB };
 
-enum {
+enum e_race {
 	RC_FORMLESS=0,
 	RC_UNDEAD,
 	RC_BRUTE,
@@ -291,17 +291,19 @@ enum {
 	RC_DEMIHUMAN,
 	RC_ANGEL,
 	RC_DRAGON,
-	RC_ALL
+	RC_ALL,
+	RC_MAX //auto upd enum for array size
 };
 
-enum {
+enum e_classAE {
 	CLASS_NORMAL = 0,
 	CLASS_BOSS,
 	CLASS_GUARDIAN,
-	CLASS_ALL
+	CLASS_ALL,
+	CLASS_MAX //auto upd enum for array len
 };
 
-enum {
+enum e_race2 {
 	RC2_NONE = 0,
 	RC2_GOBLIN,
 	RC2_KOBOLD,
@@ -312,7 +314,7 @@ enum {
 	RC2_MAX
 };
 
-enum {
+enum e_elemen {
 	ELE_NEUTRAL=0,
 	ELE_WATER,
 	ELE_EARTH,

+ 1 - 0
src/map/mob.h

@@ -68,6 +68,7 @@ enum size {
 	SZ_MEDIUM,
 	SZ_BIG,
 	SZ_ALL,
+	SZ_MAX
 };
 
 struct mob_skill {

+ 23 - 24
src/map/pc.c

@@ -14,6 +14,7 @@
 #include "../common/mmo.h" //NAME_LENGTH
 
 #include "atcommand.h" // get_atcommand_level()
+#include "map.h"
 #include "battle.h" // battle_config
 #include "battleground.h"
 #include "channel.h"
@@ -26,7 +27,6 @@
 #include "itemdb.h"
 #include "log.h"
 #include "mail.h"
-#include "map.h"
 #include "path.h"
 #include "homunculus.h"
 #include "instance.h"
@@ -56,7 +56,7 @@ int pc_split_atoui(char* str, unsigned int* val, char sep, int max);
 
 static unsigned int statp[MAX_LEVEL+1];
 #if defined(RENEWAL_DROP) || defined(RENEWAL_EXP)
-static unsigned int level_penalty[3][CLASS_ALL][MAX_LEVEL*2+1];
+static unsigned int level_penalty[3][CLASS_MAX][MAX_LEVEL*2+1];
 #endif
 
 // h-files are for declarations, not for implementations... [Shinomori]
@@ -9314,36 +9314,35 @@ bool pc_divorce(struct map_session_data *sd)
 	return true;
 }
 
-/*==========================================
- * Get sd partner charid. (Married partner)
- *------------------------------------------*/
-struct map_session_data *pc_get_partner(struct map_session_data *sd)
-{
+/**
+ * Get the partner map_session_data of a player
+ * @param sd : the husband|wife session
+ * @return partner session or NULL
+ */
+struct map_session_data *pc_get_partner(struct map_session_data *sd){
 	if (!sd || !pc_ismarried(sd))
-		// charid2sd returns NULL if not found
 		return NULL;
 	return map_charid2sd(sd->status.partner_id);
 }
 
-/*==========================================
- * Get sd father charid. (Need to be baby)
- *------------------------------------------*/
-struct map_session_data *pc_get_father (struct map_session_data *sd)
-{
-	if (!sd || !sd->class_&JOBL_BABY || !sd->status.father)
-		// charid2sd returns NULL if not found
+/**
+ * Get the father map_session_data of a player
+ * @param sd : the baby session
+ * @return father session or NULL
+ */
+struct map_session_data *pc_get_father (struct map_session_data *sd){
+	if (!sd || !(sd->class_&JOBL_BABY) || !sd->status.father)
 		return NULL;
-
 	return map_charid2sd(sd->status.father);
 }
 
-/*==========================================
- * Get sd mother charid. (Need to be baby)
- *------------------------------------------*/
-struct map_session_data *pc_get_mother (struct map_session_data *sd)
-{
-	if (!sd || sd->class_&JOBL_BABY || !sd->status.mother)
-		// charid2sd returns NULL if not found
+/**
+ * Get the mother map_session_data of a player
+ * @param sd : the baby session
+ * @return mother session or NULL
+ */
+struct map_session_data *pc_get_mother (struct map_session_data *sd){
+	if (!sd || !(sd->class_&JOBL_BABY) || !sd->status.mother)
 		return NULL;
 	return map_charid2sd(sd->status.mother);
 }
@@ -10500,7 +10499,7 @@ void pc_bonus_script_remove(struct map_session_data *sd, uint8 i) {
 
 	script_free_code(sd->bonus_script[i].script);
 	memset(&sd->bonus_script[i].script,0,sizeof(sd->bonus_script[i].script));
-	*sd->bonus_script[i].script_str = '\0';
+	sd->bonus_script[i].script_str[0] = '\0';
 	sd->bonus_script[i].tick = 0;
 	sd->bonus_script[i].tid = 0;
 	sd->bonus_script[i].flag = 0;

+ 30 - 30
src/map/pc.h

@@ -6,11 +6,11 @@
 
 #include "../common/mmo.h" // JOB_*, MAX_FAME_LIST, struct fame_list, struct mmo_charstatus
 #include "../common/timer.h" // INVALID_TIMER
+#include "map.h" // RC_ALL
 #include "atcommand.h" // AtCommandType
 #include "battle.h" // battle_config
 #include "buyingstore.h"  // struct s_buyingstore
 #include "itemdb.h" // MAX_ITEMGROUP
-#include "map.h" // RC_ALL
 #include "script.h" // struct script_reg, struct script_regstr
 #include "searchstore.h"  // struct s_search_store_info
 #include "status.h" // OPTION_*, struct weapon_atk
@@ -72,11 +72,11 @@ struct weapon_data {
 	int def_ratio_atk_ele;
 	int def_ratio_atk_race;
 	int def_ratio_atk_class;
-	int addele[ELE_ALL];
-	int addrace[RC_ALL];
-	int addclass[CLASS_ALL];
+	int addele[ELE_NONE];
+	int addrace[RC_MAX];
+	int addclass[CLASS_MAX];
 	int addrace2[RC2_MAX];
-	int addsize[3];
+	int addsize[SZ_MAX];
 
 	struct drain_data {
 		short rate;
@@ -289,36 +289,36 @@ struct map_session_data {
 
 	// here start arrays to be globally zeroed at the beginning of status_calc_pc()
 	int param_bonus[6],param_equip[6]; //Stores card/equipment bonuses.
-	int subele[ELE_ALL];
-	int subrace[RC_ALL];
-	int subclass[CLASS_ALL];
+	int subele[ELE_NONE];
+	int subrace[RC_MAX];
+	int subclass[CLASS_MAX];
 	int subrace2[RC2_MAX];
-	int subsize[3];
+	int subsize[SZ_MAX];
 	int reseff[SC_COMMON_MAX-SC_COMMON_MIN+1];
-	int weapon_coma_ele[ELE_ALL];
-	int weapon_coma_race[RC_ALL];
-	int weapon_coma_class[CLASS_ALL];
+	int weapon_coma_ele[ELE_NONE];
+	int weapon_coma_race[RC_MAX];
+	int weapon_coma_class[CLASS_MAX];
 	int weapon_atk[16];
 	int weapon_atk_rate[16];
-	int arrow_addele[ELE_ALL];
-	int arrow_addrace[RC_ALL];
-	int arrow_addclass[CLASS_ALL];
-	int arrow_addsize[3];
-	int magic_addele[ELE_ALL];
-	int magic_addrace[RC_ALL];
-	int magic_addclass[CLASS_ALL];
-	int magic_addsize[3];
-	int magic_atk_ele[ELE_ALL];
-	int critaddrace[RC_ALL];
-	int expaddrace[RC_ALL];
+	int arrow_addele[ELE_NONE];
+	int arrow_addrace[RC_MAX];
+	int arrow_addclass[CLASS_MAX];
+	int arrow_addsize[SZ_MAX];
+	int magic_addele[ELE_NONE];
+	int magic_addrace[RC_MAX];
+	int magic_addclass[CLASS_MAX];
+	int magic_addsize[SZ_MAX];
+	int magic_atk_ele[ELE_NONE];
+	int critaddrace[RC_MAX];
+	int expaddrace[RC_MAX];
 	int ignore_mdef;
-	int ignore_mdef_by_race[RC_ALL];
-	int ignore_mdef_by_class[CLASS_ALL];
-	int ignore_def_by_race[RC_ALL];
+	int ignore_mdef_by_race[RC_MAX];
+	int ignore_mdef_by_class[CLASS_MAX];
+	int ignore_def_by_race[RC_MAX];
 	int itemgrouphealrate[MAX_ITEMGROUP];
-	short sp_gain_race[RC_ALL];
-	short sp_gain_race_attack[RC_ALL];
-	short hp_gain_race_attack[RC_ALL];
+	short sp_gain_race[RC_MAX];
+	short sp_gain_race_attack[RC_MAX];
+	short hp_gain_race_attack[RC_MAX];
 	// zeroed arrays end here.
 	// zeroed structures start here
 	struct s_autospell autospell[15], autospell2[15], autospell3[15];
@@ -349,7 +349,7 @@ struct map_session_data {
 	struct {
 		short value;
 		int rate, tick;
-	} def_set_race[RC_ALL], mdef_set_race[RC_ALL];
+	} def_set_race[RC_MAX], mdef_set_race[RC_MAX];
 	// zeroed structures end here
 	// manually zeroed structures start here.
 	struct s_autobonus autobonus[MAX_PC_BONUS], autobonus2[MAX_PC_BONUS], autobonus3[MAX_PC_BONUS]; //Auto script on attack, when attacked, on skill usage

+ 2 - 1
src/map/script.c

@@ -18228,6 +18228,7 @@ BUILDIN_FUNC(montransform) {
  * @param "script code"
  * @param duration
  * @param flag
+ * @param icon
  * @param char_id
  **/
 BUILDIN_FUNC(bonus_script) {
@@ -18236,7 +18237,7 @@ BUILDIN_FUNC(bonus_script) {
 	uint32 dur;
 	char type = 0;
 	TBL_PC* sd;
-	const char *script_str = '\0';
+	const char *script_str = NULL;
 	struct script_code *script = NULL;
 
 	if (script_hasdata(st,7))

+ 9 - 4
src/map/skill.c

@@ -7275,8 +7275,14 @@ int skill_castend_nodamage_id (struct block_list *src, struct block_list *bl, ui
 			struct block_list *b_bl = map_id2bl(sd->bl.id);
 			struct block_list *f_bl = map_id2bl(f_sd->bl.id);
 			struct block_list *m_bl = map_id2bl(m_sd->bl.id);
-			// if neither was found
-			if( (!f_sd && !m_sd) || (sd->status.party_id != 0 && sd->status.party_id != f_sd->status.party_id && sd->status.party_id != m_sd->status.party_id) || (!check_distance_bl(b_bl, f_bl, AREA_SIZE) && !check_distance_bl(b_bl, m_bl, AREA_SIZE)) ) {
+			if( (!f_sd && !m_sd) // if neither was found
+				|| (sd->status.party_id != 0 && //not in same party
+					((!f_sd || sd->status.party_id != f_sd->status.party_id) 
+					&& (!m_sd || sd->status.party_id != m_sd->status.party_id) //if both are online they should all be in same team
+					))
+				|| ((!f_sd || !check_distance_bl(b_bl, f_bl, AREA_SIZE)) //not in same screen
+					&& (!m_bl && !check_distance_bl(b_bl, m_bl, AREA_SIZE)))
+			) {
 				clif_skill_fail(sd,skill_id,USESKILL_FAIL_LEVEL,0);
 				map_freeblock_unlock();
 				return 0;
@@ -9920,8 +9926,7 @@ int skill_castend_id(int tid, unsigned int tick, int id, intptr_t data)
 				if(sd) {
 					struct map_session_data *f_sd = pc_get_father(sd);
 					struct map_session_data *m_sd = pc_get_mother(sd);
-
-					if( f_sd->state.autotrade || m_sd->state.autotrade )
+					if( (f_sd && f_sd->state.autotrade) || (m_sd && m_sd->state.autotrade ))
 						break;
 				}
 			case WE_CALLBABY: