summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-07-06 01:12:58 +0300
committerAndrei Karas <akaras@inbox.ru>2016-07-12 17:20:33 +0300
commitd3167c56ae0bf8d5b20c9c6e57941b7029f0f94e (patch)
tree06c95b2ba42957b601e0b1b1c1c31b0932bf193a
parent85c6962d2f2793de691bc3627e6d5055f3386b1e (diff)
downloadhercules-d3167c56ae0bf8d5b20c9c6e57941b7029f0f94e.tar.gz
hercules-d3167c56ae0bf8d5b20c9c6e57941b7029f0f94e.tar.bz2
hercules-d3167c56ae0bf8d5b20c9c6e57941b7029f0f94e.tar.xz
hercules-d3167c56ae0bf8d5b20c9c6e57941b7029f0f94e.zip
Add missing checks into pet.c
-rw-r--r--src/map/pet.c25
1 files changed, 23 insertions, 2 deletions
diff --git a/src/map/pet.c b/src/map/pet.c
index e2b257e10..a515d2fbb 100644
--- a/src/map/pet.c
+++ b/src/map/pet.c
@@ -91,6 +91,7 @@ void pet_set_intimate(struct pet_data *pd, int value)
int pet_create_egg(struct map_session_data *sd, int item_id)
{
int pet_id = pet->search_petDB_index(item_id, PET_EGG);
+ nullpo_ret(sd);
if (pet_id < 0) return 0; //No pet egg here.
if (!pc->inventoryblank(sd)) return 0; // Inventory full
sd->catch_target_class = pet->db[pet_id].class_;
@@ -117,6 +118,7 @@ int pet_unlocktarget(struct pet_data *pd)
* Pet Attack Skill [Skotlex]
*------------------------------------------*/
int pet_attackskill(struct pet_data *pd, int target_id) {
+ nullpo_ret(pd);
if (!battle_config.pet_status_support || !pd->a_skill ||
(battle_config.pet_equip_required && !pd->pet.equip))
return 0;
@@ -148,6 +150,7 @@ int pet_target_check(struct map_session_data *sd,struct block_list *bl,int type)
struct pet_data *pd;
int rate;
+ nullpo_ret(sd);
pd = sd->pd;
Assert_ret(pd->msd == 0 || pd->msd->pd == pd);
@@ -291,6 +294,7 @@ int pet_performance(struct map_session_data *sd, struct pet_data *pd)
{
int val;
+ nullpo_retr(1, pd);
if (pd->pet.intimate > 900)
val = (pd->petDB->s_perfor > 0)? 4:3;
else if(pd->pet.intimate > 750) //TODO: this is way too high
@@ -309,6 +313,8 @@ int pet_return_egg(struct map_session_data *sd, struct pet_data *pd)
struct item tmp_item;
int flag;
+ nullpo_retr(1, sd);
+ nullpo_retr(1, pd);
pet->lootitem_drop(pd,sd);
memset(&tmp_item,0,sizeof(tmp_item));
tmp_item.nameid = pd->petDB->EggID;
@@ -336,6 +342,7 @@ int pet_data_init(struct map_session_data *sd, struct s_pet *petinfo)
int i=0,interval=0;
nullpo_retr(1, sd);
+ nullpo_retr(1, petinfo);
Assert_retr(1, sd->status.pet_id == 0 || sd->pd == 0 || sd->pd->msd == sd);
if(sd->status.account_id != petinfo->account_id || sd->status.char_id != petinfo->char_id) {
@@ -407,6 +414,7 @@ int pet_data_init(struct map_session_data *sd, struct s_pet *petinfo)
int pet_birth_process(struct map_session_data *sd, struct s_pet *petinfo)
{
nullpo_retr(1, sd);
+ nullpo_retr(1, petinfo);
Assert_retr(1, sd->status.pet_id == 0 || sd->pd == 0 || sd->pd->msd == sd);
if(sd->status.pet_id && petinfo->incubate == 1) {
@@ -443,6 +451,7 @@ int pet_birth_process(struct map_session_data *sd, struct s_pet *petinfo)
int pet_recv_petdata(int account_id,struct s_pet *p,int flag) {
struct map_session_data *sd;
+ nullpo_retr(1, p);
sd = map->id2sd(account_id);
if(sd == NULL)
return 1;
@@ -651,6 +660,7 @@ int pet_change_name(struct map_session_data *sd, const char *name)
int i;
struct pet_data *pd;
nullpo_retr(1, sd);
+ nullpo_retr(1, name);
pd = sd->pd;
if((pd == NULL) || (pd->pet.rename_flag == 1 && !battle_config.pet_rename))
@@ -666,8 +676,12 @@ int pet_change_name(struct map_session_data *sd, const char *name)
int pet_change_name_ack(struct map_session_data *sd, const char *name, int flag)
{
- struct pet_data *pd = sd->pd;
+ struct pet_data *pd;
char *newname = NULL;
+ nullpo_ret(sd);
+ nullpo_ret(name);
+ pd = sd->pd;
+ nullpo_ret(pd);
if (!pd) return 0;
newname = aStrndup(name, NAME_LENGTH-1);
@@ -724,6 +738,8 @@ int pet_unequipitem(struct map_session_data *sd, struct pet_data *pd) {
struct item tmp_item;
int nameid,flag;
+ nullpo_retr(1, sd);
+ nullpo_retr(1, pd);
if(pd->pet.equip == 0)
return 1;
@@ -762,6 +778,7 @@ int pet_unequipitem(struct map_session_data *sd, struct pet_data *pd) {
int pet_food(struct map_session_data *sd, struct pet_data *pd) {
int i, food_id;
+ nullpo_retr(1, pd);
food_id = pd->petDB->FoodID;
i = pc->search_inventory(sd, food_id);
if(i == INDEX_NOT_FOUND) {
@@ -847,6 +864,7 @@ int pet_randomwalk(struct pet_data *pd, int64 tick)
int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, int64 tick) {
struct block_list *target = NULL;
+ nullpo_ret(pd);
if(pd->bl.prev == NULL || sd == NULL || sd->bl.prev == NULL)
return 0;
@@ -959,6 +977,7 @@ int pet_ai_sub_hard(struct pet_data *pd, struct map_session_data *sd, int64 tick
int pet_ai_sub_foreachclient(struct map_session_data *sd,va_list ap) {
int64 tick = va_arg(ap,int64);
+ nullpo_ret(sd);
if(sd->status.pet_id && sd->pd)
pet->ai_sub_hard(sd->pd,sd,tick);
@@ -1114,7 +1133,8 @@ int pet_recovery_timer(int tid, int64 tick, int id, intptr_t data) {
if(sd==NULL || sd->pd == NULL || sd->pd->recovery == NULL)
return 1;
- pd=sd->pd;
+ pd = sd->pd;
+ nullpo_retr(1, pd);
if(pd->recovery->timer != tid) {
ShowError("pet_recovery_timer %d != %d\n",pd->recovery->timer,tid);
@@ -1146,6 +1166,7 @@ int pet_skill_support_timer(int tid, int64 tick, int id, intptr_t data) {
return 1;
pd=sd->pd;
+ nullpo_retr(1, pd);
if(pd->s_skill->timer != tid) {
ShowError("pet_skill_support_timer %d != %d\n",pd->s_skill->timer,tid);