summaryrefslogtreecommitdiff
path: root/src/map/party.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-02-11 14:11:41 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-02-11 14:11:41 +0000
commitc31be7e56e5c1d4345df7c5baf6fb4f4c412d7aa (patch)
tree2bff098281f7588f09c3c4d12b1390c67ce7a150 /src/map/party.c
parentea4d8114ce4aa030d224acdd00af66d0ee1a979d (diff)
downloadhercules-c31be7e56e5c1d4345df7c5baf6fb4f4c412d7aa.tar.gz
hercules-c31be7e56e5c1d4345df7c5baf6fb4f4c412d7aa.tar.bz2
hercules-c31be7e56e5c1d4345df7c5baf6fb4f4c412d7aa.tar.xz
hercules-c31be7e56e5c1d4345df7c5baf6fb4f4c412d7aa.zip
- Applied some cleanups to party.c/guild.c to ensure that direct pointers to sd are only done for valid sd states.
git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12194 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/party.c')
-rw-r--r--src/map/party.c34
1 files changed, 23 insertions, 11 deletions
diff --git a/src/map/party.c b/src/map/party.c
index 47648b889..fedd5ce1e 100644
--- a/src/map/party.c
+++ b/src/map/party.c
@@ -47,6 +47,26 @@ static void party_fill_member(struct party_member *member, struct map_session_da
}
/*==========================================
+ * Retrieves and validates the sd pointer for this party member [Skotlex]
+ *------------------------------------------*/
+
+static TBL_PC* party_sd_check(int party_id, int account_id, int char_id)
+{
+ TBL_PC* sd = map_id2sd(account_id);
+
+ if (!(sd && sd->status.char_id == char_id && sd->state.auth && !sd->state.waitingdisconnect))
+ return NULL;
+
+ if (sd->status.party_id != party_id)
+ { //If player belongs to a different party, kick him out.
+ intif_party_leave(party_id,account_id,char_id);
+ return NULL;
+ }
+
+ return sd;
+}
+
+/*==========================================
* I—¹
*------------------------------------------*/
void do_final_party(void)
@@ -233,11 +253,7 @@ int party_recv_info(struct party *sp)
for(i=0;i<MAX_PARTY;i++){
if (!p->party.member[i].account_id)
continue;
- sd = map_id2sd(p->party.member[i].account_id);
- if (sd && sd->status.party_id==p->party.party_id
- && sd->status.char_id == p->party.member[i].char_id
- && sd->state.auth && !sd->state.waitingdisconnect)
- p->data[i].sd = sd;
+ p->data[i].sd = party_sd_check(p->party.party_id, p->party.member[i].account_id, p->party.member[i].char_id);
}
party_check_state(p);
for(i=0;i<MAX_PARTY;i++){
@@ -340,10 +356,8 @@ int party_member_added(int party_id,int account_id,int char_id, int flag)
int i;
if(sd == NULL || sd->status.char_id != char_id){
- if (flag == 0) {
- ShowError("party: member added error %d is not online\n",account_id);
+ if (!flag) //Char logged off before being accepted into party.
intif_party_leave(party_id,account_id,char_id);
- }
return 0;
}
sd->party_invite=0;
@@ -507,7 +521,6 @@ int party_optionchanged(int party_id,int account_id,int exp,int item,int flag)
/// - gains a level (disabled)
int party_recv_movemap(int party_id,int account_id,int char_id, unsigned short map,int online,int lv)
{
- struct map_session_data* sd;
struct party_member* m;
struct party_data* p;
int i;
@@ -528,8 +541,7 @@ int party_recv_movemap(int party_id,int account_id,int char_id, unsigned short m
m->online = online;
m->lv = lv;
//Check if they still exist on this map server
- sd = map_id2sd(m->account_id);
- p->data[i].sd = (sd!=NULL && sd->status.party_id==p->party.party_id && sd->status.char_id == m->char_id && !sd->state.waitingdisconnect)?sd:NULL;
+ p->data[i].sd = party_sd_check(party_id, account_id, char_id);
clif_party_info(p,NULL);
return 0;