summaryrefslogtreecommitdiff
path: root/src/map/party.c
diff options
context:
space:
mode:
authorskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-02-21 00:13:56 +0000
committerskotlex <skotlex@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-02-21 00:13:56 +0000
commitfd665092bbcd4be32f9d8319ffbb4aad30b40d08 (patch)
tree96fbf399d2704c89a5254a91994dd07a40fdfe39 /src/map/party.c
parent5870b45487fde3bc3fef54062aab5fcce4ce39ca (diff)
downloadhercules-fd665092bbcd4be32f9d8319ffbb4aad30b40d08.tar.gz
hercules-fd665092bbcd4be32f9d8319ffbb4aad30b40d08.tar.bz2
hercules-fd665092bbcd4be32f9d8319ffbb4aad30b40d08.tar.xz
hercules-fd665092bbcd4be32f9d8319ffbb4aad30b40d08.zip
- Fixed new guilds displaying online-connect member count at 0 rather than 1, and the guild master not knowing it is one (eg: it cannot edit the guild notice of a newly created guild until relogging).
- Fixed acc_reg2 parsing screwing up the char_id and subtracting 2 from it rather than passing it as it is. - Extended the auth_node/auth_db system in chrif.c to handle log in/out and mapserver-change procedures. This way players are not in the main dbs when they are not "active", which blocks potential invalid accesses to them. - Replaced states auth, waiting_disconnect and finalsave with active. - Cleaned some the party/guild login and creation procedures, removed the party_sent/guild_sent states. - Removed a redundant guild_check_member call which is beyond not-needed and into the realm of wasting resources. - clif_parse will no longer process packets from !sd->state.active players, this also makes checking for finalsave uneccessary (since players re already removed from the maps and dbs by this point, so you can't access them in any other way) - Separated the roles of unit_free and map_quit, the former will handle cleaning structures from the player so it can be free'd safely, while the latter performs additional routines which are unique to characters logging out normally (map-server changes will invoke unit_free and bypass map_quit). - Removed pc_isplaying, quit_db, map_knowsaccount, MAPIT_PCISPLAYING among other functions/defines which are no longer needed due to the new login scheme. - Cleand up a bit some code in the clif_send(_sub) functions. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12223 54d463be-8e91-2dee-dedb-b68131a5f0ec
Diffstat (limited to 'src/map/party.c')
-rw-r--r--src/map/party.c75
1 files changed, 44 insertions, 31 deletions
diff --git a/src/map/party.c b/src/map/party.c
index 7928a3ad3..b8cd03811 100644
--- a/src/map/party.c
+++ b/src/map/party.c
@@ -54,7 +54,7 @@ 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))
+ if (!(sd && sd->status.char_id == char_id))
return NULL;
if (sd->status.party_id != party_id)
@@ -125,7 +125,6 @@ int party_create(struct map_session_data *sd,char *name,int item,int item2)
int party_created(int account_id,int char_id,int fail,int party_id,char *name)
{
struct map_session_data *sd;
- struct party_data *p;
sd=map_id2sd(account_id);
if (!sd || sd->status.char_id != char_id)
@@ -140,16 +139,8 @@ int party_created(int account_id,int char_id,int fail,int party_id,char *name)
return 0; // "party name already exists"
}
sd->status.party_id=party_id;
- if(idb_get(party_db,party_id)!=NULL){
- ShowFatalError("party: id already exists!\n");
- exit(EXIT_FAILURE);
- }
- p=(struct party_data *)aCalloc(1,sizeof(struct party_data));
- p->party.party_id=party_id;
- memcpy(p->party.name, name, NAME_LENGTH);
- idb_put(party_db,party_id,p);
clif_party_created(sd,0); //Success message
- clif_charnameupdate(sd); //Update other people's display. [Skotlex]
+ //We don't do any further work here because the char-server sends a party info packet right after creating the party.
return 1;
}
@@ -239,15 +230,18 @@ static void party_check_state(struct party_data *p)
int party_recv_info(struct party *sp)
{
- struct map_session_data *sd;
struct party_data *p;
int i;
+ bool party_new = false;
nullpo_retr(0, sp);
p= idb_ensure(party_db, sp->party_id, create_party);
if (!p->party.party_id) //party just received.
+ {
+ party_new = true;
party_check_member(sp);
+ }
memcpy(&p->party,sp,sizeof(struct party));
memset(&p->state, 0, sizeof(p->state));
memset(&p->data, 0, sizeof(p->data));
@@ -257,14 +251,17 @@ int party_recv_info(struct party *sp)
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++){
- sd = p->data[i].sd;
- if(!sd || sd->state.party_sent)
- continue;
- clif_party_member_info(p,sd);
- clif_party_option(p,sd,0x100);
- clif_party_info(p,NULL);
- sd->state.party_sent=1;
+ if (party_new) {
+ //Send party data to all players.
+ struct map_session_data *sd;
+ for(i=0;i<MAX_PARTY;i++){
+ sd = p->data[i].sd;
+ if(!sd) continue;
+ clif_charnameupdate(sd); //Update other people's display. [Skotlex]
+ clif_party_member_info(p,sd);
+ clif_party_option(p,sd,0x100);
+ clif_party_info(p,NULL);
+ }
}
return 0;
@@ -349,6 +346,26 @@ int party_reply_invite(struct map_session_data *sd,int account_id,int flag)
return 1;
}
+//Invoked when a player joins:
+//- Loads up party data if not in server
+//- Sets up the pointer to him
+//- 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);
+ int i;
+ if (!p)
+ {
+ party_request_info(sd->status.party_id);
+ return;
+ }
+ ARR_FIND( 0, MAX_PARTY, i, p->party.member[i].account_id == sd->status.account_id && p->party.member[i].char_id == sd->status.char_id );
+ if (i < MAX_PARTY)
+ p->data[i].sd = sd;
+ else
+ sd->status.party_id = 0; //He does not belongs to the party really?
+}
+
/// Invoked (from char-server) when a new member is added to the party.
int party_member_added(int party_id,int account_id,int char_id, int flag)
{
@@ -371,9 +388,10 @@ int party_member_added(int party_id,int account_id,int char_id, int flag)
}
if(!flag) {
- sd->state.party_sent=0;
sd->status.party_id=party_id;
party_check_conflict(sd);
+ clif_party_option(p,sd,0x100);
+ clif_party_info(p,sd);
clif_party_member_info(p,sd);
for( i = 0; i < ARRAYLENGTH(p->data); ++i )
{// hp of the other party members
@@ -458,7 +476,6 @@ int party_member_leaved(int party_id, int account_id, int char_id)
if( sd && sd->status.party_id == party_id && sd->status.char_id == char_id )
{
sd->status.party_id = 0;
- sd->state.party_sent = 0;
clif_charnameupdate(sd); //Update name display [Skotlex]
//TODO: hp bars should be cleared too
}
@@ -479,7 +496,6 @@ int party_broken(int party_id)
if(p->data[i].sd!=NULL){
clif_party_leaved(p,p->data[i].sd,p->party.member[i].account_id,p->party.member[i].name,0x10);
p->data[i].sd->status.party_id=0;
- p->data[i].sd->state.party_sent=0;
}
}
idb_remove(party_db,party_id);
@@ -561,14 +577,11 @@ void party_send_movemap(struct map_session_data *sd)
p=party_search(sd->status.party_id);
if (!p) return;
- if(!sd->state.party_sent) {
- party_check_member(&p->party);
- if(sd->status.party_id==p->party.party_id){
- clif_party_option(p,sd,0x100);
- clif_party_info(p,sd);
- clif_party_member_info(p,sd);
- sd->state.party_sent=1;
- }
+ if(sd->state.connect_new) {
+ //Note that this works because this function is invoked before connect_new is cleared.
+ clif_party_option(p,sd,0x100);
+ clif_party_info(p,sd);
+ clif_party_member_info(p,sd);
}
if (sd->fd) { // synchronize minimap positions with the rest of the party