summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/common/db.c2
-rw-r--r--src/map/atcommand.c66
-rw-r--r--src/map/chat.c4
-rw-r--r--src/map/clif.c4
-rw-r--r--src/map/irc-bot.c2
-rw-r--r--src/map/mob.c2
-rw-r--r--src/map/npc.c13
-rw-r--r--src/map/party.c2
-rw-r--r--src/map/pc.c5
-rw-r--r--src/map/pet.c17
-rw-r--r--src/map/script.c15
-rw-r--r--src/map/skill.c16
-rw-r--r--src/map/status.c84
13 files changed, 126 insertions, 106 deletions
diff --git a/src/common/db.c b/src/common/db.c
index c3ca7e0a4..ba3fef97b 100644
--- a/src/common/db.c
+++ b/src/common/db.c
@@ -1696,7 +1696,7 @@ static DBData* db_obj_vensure(DBMap* self, DBKey key, DBCreateData create, va_li
if (db->options&DB_OPT_DUP_KEY) {
node->key = db_dup_key(db, key);
if (db->options&DB_OPT_RELEASE_KEY)
- db->release(key, *data, DB_RELEASE_KEY);
+ db->release(key, node->data, DB_RELEASE_KEY);
} else {
node->key = key;
}
diff --git a/src/map/atcommand.c b/src/map/atcommand.c
index da89f0008..9d01b2b37 100644
--- a/src/map/atcommand.c
+++ b/src/map/atcommand.c
@@ -900,50 +900,52 @@ ACMD(hide) {
/*==========================================
* Changes a character's class
*------------------------------------------*/
-ACMD(jobchange)
-{
+ACMD(jobchange) {
int job = 0, upper = 0;
const char* text;
- if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
- int i;
- bool found = false;
-
+ if (!message || !*message || sscanf(message, "%d %d", &job, &upper) < 1) {
upper = 0;
-
- // Normal Jobs
- for( i = JOB_NOVICE; i < JOB_MAX_BASIC && !found; i++ ){
- if (strncmpi(message, pc->job_name(i), 16) == 0) {
- job = i;
- found = true;
+
+ if( message ) {
+ int i;
+ bool found = false;
+
+ // Normal Jobs
+ for( i = JOB_NOVICE; i < JOB_MAX_BASIC && !found; i++ ) {
+ if (strncmpi(message, pc->job_name(i), 16) == 0) {
+ job = i;
+ found = true;
+ }
}
- }
-
- // High Jobs, Babys and Third
- for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ){
- if (strncmpi(message, pc->job_name(i), 16) == 0) {
- job = i;
- found = true;
+
+ // High Jobs, Babys and Third
+ for( i = JOB_NOVICE_HIGH; i < JOB_MAX && !found; i++ ){
+ if (strncmpi(message, pc->job_name(i), 16) == 0) {
+ job = i;
+ found = true;
+ }
+ }
+
+ if (!found) {
+ text = atcommand_help_string(info);
+ if (text)
+ clif->messageln(fd, text);
+ return false;
}
- }
-
- if (!found) {
- text = atcommand_help_string(info);
- if (text)
- clif->messageln(fd, text);
- return false;
}
}
-
+ /* WHY DO WE LIST THEM THEN? */
+ // Deny direct transformation into dummy jobs
if (job == JOB_KNIGHT2 || job == JOB_CRUSADER2 || job == JOB_WEDDING || job == JOB_XMAS || job == JOB_SUMMER
|| job == JOB_LORD_KNIGHT2 || job == JOB_PALADIN2 || job == JOB_BABY_KNIGHT2 || job == JOB_BABY_CRUSADER2 || job == JOB_STAR_GLADIATOR2
|| (job >= JOB_RUNE_KNIGHT2 && job <= JOB_MECHANIC_T2) || (job >= JOB_BABY_RUNE2 && job <= JOB_BABY_MECHANIC2)
- ) // Deny direct transformation into dummy jobs
- {clif->message(fd, msg_txt(923)); //"You can not change to this job by command."
- return true;}
+ ) {
+ clif->message(fd, msg_txt(923)); //"You can not change to this job by command."
+ return true;
+ }
- if (pcdb_checkid(job))
- {
+ if (pcdb_checkid(job)) {
if (pc->jobchange(sd, job, upper) == 0)
clif->message(fd, msg_txt(12)); // Your job has been changed.
else {
diff --git a/src/map/chat.c b/src/map/chat.c
index 187d40337..858878430 100644
--- a/src/map/chat.c
+++ b/src/map/chat.c
@@ -54,11 +54,11 @@ struct chat_data* chat_createchat(struct block_list* bl, const char* title, cons
if( cd->bl.id == 0 ) {
aFree(cd);
- cd = NULL;
+ return NULL;
}
map->addiddb(&cd->bl);
-
+
if( bl->type != BL_NPC )
cd->kick_list = idb_alloc(DB_OPT_BASE);
diff --git a/src/map/clif.c b/src/map/clif.c
index 4e10e2eea..41ba732fe 100644
--- a/src/map/clif.c
+++ b/src/map/clif.c
@@ -11088,8 +11088,10 @@ void clif_parse_RemoveOption(int fd,struct map_session_data *sd)
void clif_parse_ChangeCart(int fd,struct map_session_data *sd)
{// TODO: State tracking?
int type;
+
+ nullpo_retv(sd);
- if( sd && pc->checkskill(sd, MC_CHANGECART) < 1 )
+ if( pc->checkskill(sd, MC_CHANGECART) < 1 )
return;
#ifdef RENEWAL
diff --git a/src/map/irc-bot.c b/src/map/irc-bot.c
index 0f487d8f7..2b6dcfccd 100644
--- a/src/map/irc-bot.c
+++ b/src/map/irc-bot.c
@@ -289,7 +289,7 @@ void irc_privmsg(int fd, char *cmd, char *source, char *target, char *msg) {
} else if( strcmpi(target,hChSys.irc_nick) == 0 ) {
ShowDebug("irc_privmsg: Received message from %s: '%s'\n", source ? source : "(null)", msg);
#endif // IRCBOT_DEBUG
- } else if( strcmpi(target,hChSys.irc_channel) == 0 ) {
+ } else if( msg && strcmpi(target,hChSys.irc_channel) == 0 ) {
char source_nick[IRC_NICK_LENGTH], source_ident[IRC_IDENT_LENGTH], source_host[IRC_HOST_LENGTH];
source_nick[0] = source_ident[0] = source_host[0] = '\0';
diff --git a/src/map/mob.c b/src/map/mob.c
index 8bb0ebe65..8c02503aa 100644
--- a/src/map/mob.c
+++ b/src/map/mob.c
@@ -602,7 +602,7 @@ int mob_spawn_guardian_sub(int tid, int64 tick, int id, intptr_t data) {
guild->castledatasave(md->guardian_data->castle->castle_id, 1, 0);
}
} else {
- if (md->guardian_data->number >= 0 && md->guardian_data->number < MAX_GUARDIANS && md->guardian_data->castle->guardian[md->guardian_data->number].visible)
+ if (md->guardian_data && md->guardian_data->number >= 0 && md->guardian_data->number < MAX_GUARDIANS && md->guardian_data->castle->guardian[md->guardian_data->number].visible)
guild->castledatasave(md->guardian_data->castle->castle_id, 10+md->guardian_data->number,0);
unit->free(&md->bl,CLR_OUTSIGHT); //Remove guardian.
}
diff --git a/src/map/npc.c b/src/map/npc.c
index 5f890c65b..b57627495 100644
--- a/src/map/npc.c
+++ b/src/map/npc.c
@@ -3148,7 +3148,7 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char
int savex, savey;
if (state == 0)
; //Map flag disabled.
- else if (!strcmpi(w4, "SavePoint")) {
+ else if (w4 && !strcmpi(w4, "SavePoint")) {
map->list[m].save.map = 0;
map->list[m].save.x = -1;
map->list[m].save.y = -1;
@@ -3370,10 +3370,11 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char
else if (!strcmpi(w3,"adjust_unit_duration")) {
int skill_id, k;
char skill_name[MAP_ZONE_MAPFLAG_LENGTH], modifier[MAP_ZONE_MAPFLAG_LENGTH];
- int len = strlen(w4);
+ int len = w4 ? strlen(w4) : 0;
modifier[0] = '\0';
- memcpy(skill_name, w4, MAP_ZONE_MAPFLAG_LENGTH);
+ if( w4 )
+ memcpy(skill_name, w4, MAP_ZONE_MAPFLAG_LENGTH);
for(k = 0; k < len; k++) {
if( skill_name[k] == '\t' ) {
@@ -3424,10 +3425,12 @@ const char* npc_parse_mapflag(char* w1, char* w2, char* w3, char* w4, const char
} else if (!strcmpi(w3,"adjust_skill_damage")) {
int skill_id, k;
char skill_name[MAP_ZONE_MAPFLAG_LENGTH], modifier[MAP_ZONE_MAPFLAG_LENGTH];
- int len = strlen(w4);
+ int len = w4 ? strlen(w4) : 0;
modifier[0] = '\0';
- memcpy(skill_name, w4, MAP_ZONE_MAPFLAG_LENGTH);
+
+ if( w4 )
+ memcpy(skill_name, w4, MAP_ZONE_MAPFLAG_LENGTH);
for(k = 0; k < len; k++) {
if( skill_name[k] == '\t' ) {
diff --git a/src/map/party.c b/src/map/party.c
index 8e3ac3dcf..cab12548b 100644
--- a/src/map/party.c
+++ b/src/map/party.c
@@ -553,7 +553,7 @@ int party_member_withdraw(int party_id, int account_id, int char_id)
sd->status.party_id = 0;
clif->charnameupdate(sd); //Update name display [Skotlex]
//TODO: hp bars should be cleared too
- if( p->instances )
+ if( p && p->instances )
instance->check_kick(sd);
}
if (sd && sd->sc.data[SC_DANCING]) {
diff --git a/src/map/pc.c b/src/map/pc.c
index aa6073be8..7c3df2262 100644
--- a/src/map/pc.c
+++ b/src/map/pc.c
@@ -1790,9 +1790,8 @@ int pc_disguise(struct map_session_data *sd, int class_) {
}
if (sd->chatID) {
struct chat_data* cd;
- nullpo_retr(1, sd);
- cd = (struct chat_data*)map->id2bl(sd->chatID);
- if( cd != NULL || (struct block_list*)sd == cd->owner )
+
+ if( (cd = (struct chat_data*)map->id2bl(sd->chatID)) )
clif->dispchat(cd,0);
}
}
diff --git a/src/map/pet.c b/src/map/pet.c
index a2695d3b0..8cdc78e16 100644
--- a/src/map/pet.c
+++ b/src/map/pet.c
@@ -364,15 +364,20 @@ int pet_data_init(struct map_session_data *sd, struct s_pet *petinfo)
pd->last_thinktime = timer->gettick();
pd->state.skillbonus = 0;
+
if( battle_config.pet_status_support )
script->run(pet->db[i].pet_script,0,sd->bl.id,0);
- if( pd->petDB && pd->petDB->equip_script )
- status_calc_pc(sd,SCO_NONE);
+
+ if( pd->petDB ) {
+ if( pd->petDB->equip_script )
+ status_calc_pc(sd,SCO_NONE);
- if( battle_config.pet_hungry_delay_rate != 100 )
- interval = (pd->petDB->hungry_delay*battle_config.pet_hungry_delay_rate)/100;
- else
- interval = pd->petDB->hungry_delay;
+ if( battle_config.pet_hungry_delay_rate != 100 )
+ interval = (pd->petDB->hungry_delay*battle_config.pet_hungry_delay_rate)/100;
+ else
+ interval = pd->petDB->hungry_delay;
+ }
+
if( interval <= 0 )
interval = 1;
pd->pet_hungry_timer = timer->add(timer->gettick() + interval, pet->hungry, sd->bl.id, 0);
diff --git a/src/map/script.c b/src/map/script.c
index 764ae743a..1da6fb1c2 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -10669,13 +10669,14 @@ BUILDIN(setmapflag) {
case MF_NORETURN: map->list[m].flag.noreturn = 1; break;
case MF_NOWARPTO: map->list[m].flag.nowarpto = 1; break;
case MF_NIGHTMAREDROP: map->list[m].flag.pvp_nightmaredrop = 1; break;
- case MF_ZONE: {
- char zone[6] = "zone\0";
- char empty[1] = "\0";
- char params[MAP_ZONE_MAPFLAG_LENGTH];
- memcpy(params, val2, MAP_ZONE_MAPFLAG_LENGTH);
- npc->parse_mapflag(map->list[m].name, empty, zone, params, empty, empty, empty);
- }
+ case MF_ZONE:
+ if( val2 ) {
+ char zone[6] = "zone\0";
+ char empty[1] = "\0";
+ char params[MAP_ZONE_MAPFLAG_LENGTH];
+ memcpy(params, val2, MAP_ZONE_MAPFLAG_LENGTH);
+ npc->parse_mapflag(map->list[m].name, empty, zone, params, empty, empty, empty);
+ }
break;
case MF_NOCOMMAND: map->list[m].nocommand = (val <= 0) ? 100 : val; break;
case MF_NODROP: map->list[m].flag.nodrop = 1; break;
diff --git a/src/map/skill.c b/src/map/skill.c
index 1f9a8c15b..e8538d286 100644
--- a/src/map/skill.c
+++ b/src/map/skill.c
@@ -9266,14 +9266,16 @@ int skill_castend_nodamage_id(struct block_list *src, struct block_list *bl, uin
break;
case MH_GRANITIC_ARMOR:
case MH_PYROCLASTIC:
- {
- struct block_list *s_bl = battle->get_master(src);
- if(s_bl)
- sc_start2(s_bl, type, 100, skill_lv, hd->homunculus.level, skill->get_time(skill_id, skill_lv)); //start on master
- sc_start2(bl, type, 100, skill_lv, hd->homunculus.level, skill->get_time(skill_id, skill_lv));
- if (hd)
+ if( hd ){
+ struct block_list *s_bl = battle->get_master(src);
+
+ if(s_bl)
+ sc_start2(s_bl, type, 100, skill_lv, hd->homunculus.level, skill->get_time(skill_id, skill_lv)); //start on master
+
+ sc_start2(bl, type, 100, skill_lv, hd->homunculus.level, skill->get_time(skill_id, skill_lv));
+
skill->blockhomun_start(hd, skill_id, skill->get_cooldown(skill_id, skill_lv));
- }
+ }
break;
case MH_LIGHT_OF_REGENE:
diff --git a/src/map/status.c b/src/map/status.c
index 4367f6243..7e16faeeb 100644
--- a/src/map/status.c
+++ b/src/map/status.c
@@ -1752,14 +1752,16 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin
bool is_detect = ((st->mode&MD_DETECTOR)?true:false);//god-knows-why gcc doesn't shut up until this happens
if (pc_isinvisible(sd))
return 0;
- if (tsc->option&hide_flag && !is_boss &&
- ((sd->special_state.perfect_hiding || !is_detect) ||
- (tsc->data[SC_CLOAKINGEXCEED] && is_detect)))
- return 0;
- if( tsc->data[SC_CAMOUFLAGE] && !(is_boss || is_detect) && !skill_id )
- return 0;
- if( tsc->data[SC_STEALTHFIELD] && !is_boss )
- return 0;
+ if( tsc ) {
+ if (tsc->option&hide_flag && !is_boss &&
+ ((sd->special_state.perfect_hiding || !is_detect) ||
+ (tsc->data[SC_CLOAKINGEXCEED] && is_detect)))
+ return 0;
+ if( tsc->data[SC_CAMOUFLAGE] && !(is_boss || is_detect) && !skill_id )
+ return 0;
+ if( tsc->data[SC_STEALTHFIELD] && !is_boss )
+ return 0;
+ }
}
break;
case BL_ITEM: //Allow targetting of items to pick'em up (or in the case of mobs, to loot them).
@@ -1792,38 +1794,41 @@ int status_check_skilluse(struct block_list *src, struct block_list *target, uin
//Checks whether the source can see and chase target.
int status_check_visibility(struct block_list *src, struct block_list *target) {
int view_range;
- struct status_data *st = status->get_status_data(src);
- struct status_change *tsc = status->get_sc(target);
+ struct status_change *tsc = NULL;
+
switch (src->type) {
- case BL_MOB:
- view_range = ((TBL_MOB*)src)->min_chase;
- break;
- case BL_PET:
- view_range = ((TBL_PET*)src)->db->range2;
- break;
- default:
- view_range = AREA_SIZE;
+ case BL_MOB:
+ view_range = ((TBL_MOB*)src)->min_chase;
+ break;
+ case BL_PET:
+ view_range = ((TBL_PET*)src)->db->range2;
+ break;
+ default:
+ view_range = AREA_SIZE;
}
if (src->m != target->m || !check_distance_bl(src, target, view_range))
return 0;
- if( tsc && tsc->data[SC_STEALTHFIELD] )
- return 0;
-
- switch (target->type)
- { //Check for chase-walk/hiding/cloaking opponents.
- case BL_PC:
- if ( tsc->data[SC_CLOAKINGEXCEED] && !(st->mode&MD_BOSS) )
- return 0;
- if( (tsc->option&(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK) || tsc->data[SC__INVISIBILITY] || tsc->data[SC_CAMOUFLAGE]) && !(st->mode&MD_BOSS) &&
- ( ((TBL_PC*)target)->special_state.perfect_hiding || !(st->mode&MD_DETECTOR) ) )
- return 0;
- break;
- default:
- if( tsc && (tsc->option&(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK) || tsc->data[SC__INVISIBILITY] || tsc->data[SC_CAMOUFLAGE]) && !(st->mode&(MD_BOSS|MD_DETECTOR)) )
+ if( ( tsc = status->get_sc(target) ) ) {
+ struct status_data *st = status->get_status_data(src);
+
+ if( tsc->data[SC_STEALTHFIELD] )
return 0;
+ switch (target->type) { //Check for chase-walk/hiding/cloaking opponents.
+ case BL_PC:
+ if ( tsc->data[SC_CLOAKINGEXCEED] && !(st->mode&MD_BOSS) )
+ return 0;
+ if( (tsc->option&(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK) || tsc->data[SC__INVISIBILITY] || tsc->data[SC_CAMOUFLAGE]) && !(st->mode&MD_BOSS) &&
+ ( ((TBL_PC*)target)->special_state.perfect_hiding || !(st->mode&MD_DETECTOR) ) )
+ return 0;
+ break;
+ default:
+ if( (tsc->option&(OPTION_HIDE|OPTION_CLOAK|OPTION_CHASEWALK) || tsc->data[SC__INVISIBILITY] || tsc->data[SC_CAMOUFLAGE]) && !(st->mode&(MD_BOSS|MD_DETECTOR)) )
+ return 0;
+
+ }
}
return 1;
@@ -2054,12 +2059,13 @@ int status_calc_mob_(struct mob_data* md, enum e_status_calc_opt opt) {
mbl = map->id2bl(md->master_id);
if (flag&8 && mbl) {
- struct status_data *mstatus = status->get_base_status(mbl);
- if (mstatus &&
- battle_config.slaves_inherit_speed&(mstatus->mode&MD_CANMOVE?1:2))
- mstatus->speed = mstatus->speed;
- if( mstatus->speed < 2 ) /* minimum for the unit to function properly */
- mstatus->speed = 2;
+ struct status_data *mstatus;
+ if ( (mstatus = status->get_base_status(mbl)) ) {
+ if( battle_config.slaves_inherit_speed&(mstatus->mode&MD_CANMOVE?1:2) )
+ mstatus->speed = mstatus->speed;
+ if( mstatus->speed < 2 ) /* minimum for the unit to function properly */
+ mstatus->speed = 2;
+ }
}
if (flag&16 && mbl) {
@@ -9932,7 +9938,7 @@ int status_change_end_(struct block_list* bl, enum sc_type type, int tid, const
else if(opt_flag) {
clif->changeoption(bl);
if( sd && opt_flag&0x4 ) {
- clif->changelook(bl,LOOK_BASE,vd->class_);
+ clif->changelook(bl,LOOK_BASE,sd->vd.class_);
clif->get_weapon_view(sd, &sd->vd.weapon, &sd->vd.shield);
clif->changelook(bl,LOOK_WEAPON,sd->vd.weapon);
clif->changelook(bl,LOOK_SHIELD,sd->vd.shield);