summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-05-16 07:28:46 +0000
committerultramage <ultramage@54d463be-8e91-2dee-dedb-b68131a5f0ec>2008-05-16 07:28:46 +0000
commit11f60b00d19a194ee4a0cdb4b889aed9ebe96140 (patch)
tree65ff473efb3f1eb6a0e331d479206d715b297a03
parent6caf74f06f019e4edf78e86c435c5a36c0178566 (diff)
downloadhercules-11f60b00d19a194ee4a0cdb4b889aed9ebe96140.tar.gz
hercules-11f60b00d19a194ee4a0cdb4b889aed9ebe96140.tar.bz2
hercules-11f60b00d19a194ee4a0cdb4b889aed9ebe96140.tar.xz
hercules-11f60b00d19a194ee4a0cdb4b889aed9ebe96140.zip
Added changes missing from the previous update (followup to r12710).
Corrected party invite failure not informing the inviting player. Cleaned up some foreach() code int_party.c. git-svn-id: https://rathena.svn.sourceforge.net/svnroot/rathena/trunk@12711 54d463be-8e91-2dee-dedb-b68131a5f0ec
-rw-r--r--src/char/int_party.c75
-rw-r--r--src/map/party.c19
-rw-r--r--src/map/pc.h4
3 files changed, 48 insertions, 50 deletions
diff --git a/src/char/int_party.c b/src/char/int_party.c
index f0668a820..e7f5fa501 100644
--- a/src/char/int_party.c
+++ b/src/char/int_party.c
@@ -243,24 +243,25 @@ int inter_party_save() {
return 0;
}
-// パ?ティ名?索用
-int search_partyname_sub(DBKey key,void *data,va_list ap) {
- struct party_data *p = (struct party_data *)data,**dst;
- char *str;
-
- str = va_arg(ap, char *);
- dst = va_arg(ap, struct party_data **);
- if (strncmpi(p->party.name, str, NAME_LENGTH) == 0)
- *dst = p;
+// Search for the party according to its name
+struct party_data* search_partyname(char *str)
+{
+ struct DBIterator* iter;
+ struct party_data* p;
+ struct party_data* result = NULL;
- return 0;
-}
+ iter = party_db->iterator(party_db);
+ for( p = (struct party_data*)iter->first(iter,NULL); iter->exists(iter); p = (struct party_data*)iter->next(iter,NULL) )
+ {
+ if( strncmpi(p->party.name, str, NAME_LENGTH) == 0 )
+ {
+ result = p;
+ break;
+ }
+ }
+ iter->destroy(iter);
-// パ?ティ名?索
-struct party_data* search_partyname(char *str) {
- struct party_data *p = NULL;
- party_db->foreach(party_db, search_partyname_sub, str, &p);
- return p;
+ return result;
}
// Returns whether this party can keep having exp share or not.
@@ -283,41 +284,37 @@ int party_check_empty(struct party *p) {
return 1;
}
-// キャラの競合がないかチェック用
-int party_check_conflict_sub(DBKey key, void *data, va_list ap) {
- struct party_data *p = (struct party_data *)data;
- int party_id, account_id, char_id, i;
+// キャラの競合がないかチェック
+int party_check_conflict(int party_id, int account_id, int char_id)
+{
+ DBIterator* iter;
+ struct party_data* p;
+ int i;
- party_id=va_arg(ap, int);
- account_id=va_arg(ap, int);
- char_id=va_arg(ap, int);
-
- if (p->party.party_id == party_id) //No conflict to check
- return 0;
+ iter = party_db->iterator(party_db);
+ for( p = (struct party_data*)iter->first(iter,NULL); iter->exists(iter); p = (struct party_data*)iter->next(iter,NULL) )
+ {
+ if (p->party.party_id == party_id) //No conflict to check
+ continue;
- for(i = 0; i < MAX_PARTY; i++) {
- if(p->party.member[i].account_id == account_id &&
- p->party.member[i].char_id == char_id)
- {
+ ARR_FIND( 0, MAX_PARTY, i, p->party.member[i].account_id == account_id && p->party.member[i].char_id == char_id );
+ if( i < MAX_PARTY )
+ {
ShowWarning("int_party: party conflict! %d %d %d\n", account_id, party_id, p->party.party_id);
mapif_parse_PartyLeave(-1, p->party.party_id, account_id, char_id);
}
}
+ iter->destroy(iter);
return 0;
}
-// キャラの競合がないかチェック
-int party_check_conflict(int party_id, int account_id, int char_id) {
- party_db->foreach(party_db, party_check_conflict_sub, party_id, account_id, char_id);
- return 0;
-}
-
//-------------------------------------------------------------------
// map serverへの通信
// パ?ティ作成可否
-int mapif_party_created(int fd,int account_id, int char_id, struct party *p) {
+int mapif_party_created(int fd,int account_id, int char_id, struct party *p)
+{
WFIFOHEAD(fd, 39);
WFIFOW(fd,0) = 0x3820;
WFIFOL(fd,2) = account_id;
@@ -450,10 +447,12 @@ int mapif_party_message(int party_id, int account_id, char *mes, int len, int sf
// パ?ティ
-int mapif_parse_CreateParty(int fd, char *name, int item, int item2, struct party_member *leader) {
+int mapif_parse_CreateParty(int fd, char *name, int item, int item2, struct party_member *leader)
+{
struct party_data *p;
int i;
+ //FIXME: this should be removed once the savefiles can handle all symbols
for(i = 0; i < NAME_LENGTH && name[i]; i++) {
if (!(name[i] & 0xe0) || name[i] == 0x7f) {
ShowInfo("int_party: illegal party name [%s]\n", name);
diff --git a/src/map/party.c b/src/map/party.c
index 5f2ca4e33..4a53d5038 100644
--- a/src/map/party.c
+++ b/src/map/party.c
@@ -408,7 +408,12 @@ int party_member_added(int party_id,int account_id,int char_id, int flag)
return 0;
}
- if( flag ) return 0;
+ if( flag )
+ {// failed
+ if( sd2 != NULL )
+ clif_party_inviteack(sd2,sd->status.name,3);
+ return 0;
+ }
sd->status.party_id = party_id;
@@ -420,13 +425,13 @@ int party_member_added(int party_id,int account_id,int char_id, int flag)
p->data[i].sd = sd;
}
- party_check_conflict(sd);
+ party_check_conflict(sd); //FIXME: is this neccessary?
clif_party_member_info(p,sd);
clif_party_option(p,sd,0x100);
clif_party_info(p,sd);
if( sd2 != NULL )
- clif_party_inviteack(sd2,sd->status.name,flag?3:2);
+ clif_party_inviteack(sd2,sd->status.name,2);
for( i = 0; i < ARRAYLENGTH(p->data); ++i )
{// hp of the other party members
@@ -751,14 +756,6 @@ int party_send_xy_timer(int tid, unsigned int tick, int id, intptr data)
{
struct map_session_data* sd = p->data[i].sd;
if( !sd ) continue;
- if( !malloc_verify(sd) )
- {
- ShowError("party_send_xy_timer: party member zombie reference '0x%8.8x'!\n", (uint32)sd);
- ShowDebug("party info: id='%d', name='%s', member count='%d'\n", p->party.party_id, p->party.name, p->party.count);
- ShowDebug("member info: charid='%d', name='%s', member no.='%d', online='%d', coords='%s,%d,%d'\n", p->party.member[i].char_id, p->party.member[i].name, i, p->party.member[i].online, mapindex_id2name(p->party.member[i].map), p->data[i].x, p->data[i].y);
- p->data[i].sd = NULL;
- continue;
- }
if( p->data[i].x != sd->bl.x || p->data[i].y != sd->bl.y )
{// perform position update
diff --git a/src/map/pc.h b/src/map/pc.h
index 42a28c78c..bd2baea96 100644
--- a/src/map/pc.h
+++ b/src/map/pc.h
@@ -295,7 +295,9 @@ struct map_session_data {
int zeny, weight;
} deal;
- int party_invite,party_invite_account;
+ bool party_creating; // whether the char is requesting party creation
+ bool party_joining; // whether the char is accepting party invitation
+ int party_invite, party_invite_account; // for handling party invitation (holds party id and account id)
int adopt_invite; // Adoption
int guild_invite,guild_invite_account;