summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-04-27 16:19:30 +0300
committerAndrei Karas <akaras@inbox.ru>2016-06-24 22:23:19 +0300
commit2b366baf187cbcea5d8004e99cba949c83c67433 (patch)
treeeb772b24d0c6209b3dcd9be7a22792413a466500
parenta4f6938c4c4548c433bf2a0f7076f86b5a69c36c (diff)
downloadhercules-2b366baf187cbcea5d8004e99cba949c83c67433.tar.gz
hercules-2b366baf187cbcea5d8004e99cba949c83c67433.tar.bz2
hercules-2b366baf187cbcea5d8004e99cba949c83c67433.tar.xz
hercules-2b366baf187cbcea5d8004e99cba949c83c67433.zip
Add missing checks into party.c
-rw-r--r--src/map/party.c49
1 files changed, 47 insertions, 2 deletions
diff --git a/src/map/party.c b/src/map/party.c
index dbb7b6ae2..c85e23e50 100644
--- a/src/map/party.c
+++ b/src/map/party.c
@@ -58,6 +58,9 @@ struct party_interface *party;
* Used when creating/adding people to a party. [Skotlex]
*------------------------------------------*/
void party_fill_member(struct party_member* member, struct map_session_data* sd, unsigned int leader) {
+ nullpo_retv(member);
+ nullpo_retv(sd);
+
member->account_id = sd->status.account_id;
member->char_id = sd->status.char_id;
safestrncpy(member->name, sd->status.name, NAME_LENGTH);
@@ -162,6 +165,9 @@ int party_create(struct map_session_data *sd, const char *name,int item,int item
struct party_member leader;
char tname[NAME_LENGTH];
+ nullpo_retr(0, sd);
+ nullpo_retr(0, name);
+
safestrncpy(tname, name, NAME_LENGTH);
trim(tname);
@@ -228,6 +234,7 @@ int party_recv_noinfo(int party_id, int char_id) {
void party_check_state(struct party_data *p) {
int i;
+ nullpo_retv(p);
memset(&p->state, 0, sizeof(p->state));
for (i = 0; i < MAX_PARTY; i ++) {
if (!p->party.member[i].online) continue; //Those not online shouldn't apart to skill usage and all that.
@@ -407,6 +414,8 @@ void party_reply_invite(struct map_session_data *sd,int party_id,int flag) {
struct map_session_data* tsd;
struct party_member member;
+ nullpo_retv(sd);
+
if( sd->party_invite != party_id )
{// forged
sd->party_invite = 0;
@@ -436,8 +445,11 @@ void party_reply_invite(struct map_session_data *sd,int party_id,int flag) {
//- Player must be authed/active and belong to a party before calling this method
void party_member_joined(struct map_session_data *sd)
{
- struct party_data* p = party->search(sd->status.party_id);
+ struct party_data* p;
int i;
+
+ nullpo_retv(sd);
+ p = party->search(sd->status.party_id);
if (!p) {
party->request_info(sd->status.party_id, sd->status.char_id);
return;
@@ -536,6 +548,7 @@ int party_removemember(struct map_session_data* sd, int account_id, const char *
if( !p->party.member[i].leader )
return 0; // only party leader may remove members
+ nullpo_retr(0, name);
ARR_FIND( 0, MAX_PARTY, i, p->party.member[i].account_id == account_id && strncmp(p->party.member[i].name,name,NAME_LENGTH) == 0 );
if( i == MAX_PARTY )
return 0; // no such char in party
@@ -550,6 +563,7 @@ int party_leave(struct map_session_data *sd)
struct party_data *p;
int i;
+ nullpo_ret(sd);
p = party->search(sd->status.party_id);
if( p == NULL )
return 0;
@@ -743,6 +757,8 @@ void party_send_movemap(struct map_session_data *sd)
{
struct party_data *p;
+ nullpo_retv(sd);
+
if( sd->status.party_id==0 )
return;
@@ -782,6 +798,8 @@ int party_send_logout(struct map_session_data *sd)
struct party_data *p;
int i;
+ nullpo_ret(sd);
+
if(!sd->status.party_id)
return 0;
@@ -800,9 +818,12 @@ int party_send_logout(struct map_session_data *sd)
int party_send_message(struct map_session_data *sd, const char *mes)
{
- int len = (int)strlen(mes);
+ int len;
nullpo_ret(sd);
+ nullpo_ret(mes);
+
+ len = (int)strlen(mes);
if (sd->status.party_id == 0)
return 0;
@@ -847,6 +868,8 @@ int party_skill_check(struct map_session_data *sd, int party_id, uint16 skill_id
return 0; //Unknown case?
}
+ nullpo_ret(sd);
+
for(i=0;i<MAX_PARTY;i++){
if ((p_sd = p->data[i].sd) == NULL)
continue;
@@ -939,6 +962,7 @@ int party_exp_share(struct party_data* p, struct block_list* src, unsigned int b
#endif
nullpo_ret(p);
+ nullpo_ret(src);
// count the number of players eligible for exp sharing
for (i = c = 0; i < MAX_PARTY; i++) {
@@ -991,8 +1015,12 @@ int party_share_loot(struct party_data* p, struct map_session_data* sd, struct i
{
struct map_session_data *target = NULL;
int i;
+
+ nullpo_ret(item_data);
+
if (p && p->party.item&2 && (first_charid || !(battle_config.party_share_type&1)))
{
+ nullpo_ret(sd);
//item distribution to party members.
if (battle_config.party_share_type&2) {
//Round Robin
@@ -1054,6 +1082,7 @@ int party_share_loot(struct party_data* p, struct map_session_data* sd, struct i
int party_send_dot_remove(struct map_session_data *sd)
{
+ nullpo_ret(sd);
if (sd->status.party_id)
clif->party_xy_remove(sd);
return 0;
@@ -1069,6 +1098,7 @@ int party_sub_count(struct block_list *bl, va_list ap)
nullpo_ret(bl);
Assert_ret(bl->type == BL_PC);
sd = BL_UCCAST(BL_PC, bl);
+ nullpo_ret(sd);
if (sd->state.autotrade)
return 0;
@@ -1181,6 +1211,9 @@ void party_recruit_register(struct map_session_data *sd, short level, const char
#ifdef PARTY_RECRUIT
struct party_booking_ad_info *pb_ad;
+ nullpo_retv(sd);
+ nullpo_retv(notice);
+
pb_ad = (struct party_booking_ad_info*)idb_get(party->booking_db, sd->status.char_id);
if( pb_ad == NULL )
@@ -1211,6 +1244,9 @@ void party_booking_register(struct map_session_data *sd, short level, short mapi
struct party_booking_ad_info *pb_ad;
int i;
+ nullpo_retv(sd);
+ nullpo_retv(job);
+
pb_ad = (struct party_booking_ad_info*)idb_get(party->booking_db, sd->status.char_id);
if( pb_ad == NULL )
{
@@ -1244,6 +1280,7 @@ void party_recruit_update(struct map_session_data *sd, const char *notice) {
#ifdef PARTY_RECRUIT
struct party_booking_ad_info *pb_ad;
+ nullpo_retv(sd);
pb_ad = (struct party_booking_ad_info*)idb_get(party->booking_db, sd->status.char_id);
if( pb_ad == NULL )
@@ -1265,6 +1302,9 @@ void party_booking_update(struct map_session_data *sd, short* job) {
int i;
struct party_booking_ad_info *pb_ad;
+ nullpo_retv(sd);
+ nullpo_retv(job);
+
pb_ad = (struct party_booking_ad_info*)idb_get(party->booking_db, sd->status.char_id);
if( pb_ad == NULL )
@@ -1291,6 +1331,7 @@ void party_recruit_search(struct map_session_data *sd, short level, short mapid,
bool more_result = false;
struct DBIterator *iter = db_iterator(party->booking_db);
+ nullpo_retv(sd);
memset(result_list, 0, sizeof(result_list));
for( pb_ad = dbi_first(iter); dbi_exists(iter); pb_ad = dbi_next(iter) )
@@ -1322,6 +1363,8 @@ void party_booking_search(struct map_session_data *sd, short level, short mapid,
bool more_result = false;
struct DBIterator *iter = db_iterator(party->booking_db);
+ nullpo_retv(sd);
+
memset(result_list, 0, sizeof(result_list));
for( pb_ad = dbi_first(iter); dbi_exists(iter); pb_ad = dbi_next(iter) ) {
@@ -1357,6 +1400,8 @@ bool party_booking_delete(struct map_session_data *sd)
{
struct party_booking_ad_info* pb_ad;
+ nullpo_retr(false, sd);
+
if((pb_ad = (struct party_booking_ad_info*)idb_get(party->booking_db, sd->status.char_id))!=NULL)
{
#ifdef PARTY_RECRUIT