Advertisement
Guest User

Untitled

a guest
Jul 24th, 2012
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.47 KB | None | 0 0
  1. Index: src/char/int_party.c
  2. ===================================================================
  3. --- src/char/int_party.c (revisão 16496)
  4. +++ src/char/int_party.c (cópia de trabalho)
  5. @@ -106,7 +106,7 @@
  6.  
  7. if (p->party.exp && !party_check_exp_share(p)) {
  8. p->party.exp = 0; //Set off even share.
  9. - mapif_party_optionchanged(0, &p->party, 0, 0);
  10. + mapif_party_optionchanged(0, &p->party, 0, 0);// FIXME notifications should be handled outside since this can be called on parties that aren't available yet [flaviojs]
  11. }
  12. return;
  13. }
  14. @@ -326,26 +326,18 @@
  15. //-------------------------------------------------------------------
  16. // map server‚ւ̒ʐM
  17.  
  18. -// ƒp[ƒeƒBì¬‰Â”Û
  19. -int mapif_party_created(int fd,int account_id,int char_id,struct party *p)
  20. +/// Party creation notification.
  21. +/// @param result 0 on success, 1 on failure
  22. +static void mapif_party_created(int fd, int account_id, int char_id, int result, int party_id, const char* name)
  23. {
  24. WFIFOHEAD(fd, 39);
  25. - WFIFOW(fd,0)=0x3820;
  26. - WFIFOL(fd,2)=account_id;
  27. - WFIFOL(fd,6)=char_id;
  28. - if(p!=NULL){
  29. - WFIFOB(fd,10)=0;
  30. - WFIFOL(fd,11)=p->party_id;
  31. - memcpy(WFIFOP(fd,15),p->name,NAME_LENGTH);
  32. - ShowInfo("int_party: Party created (%d - %s)\n",p->party_id,p->name);
  33. - }else{
  34. - WFIFOB(fd,10)=1;
  35. - WFIFOL(fd,11)=0;
  36. - memset(WFIFOP(fd,15),0,NAME_LENGTH);
  37. - }
  38. + WFIFOW(fd,0) = 0x3820;
  39. + WFIFOL(fd,2) = account_id;
  40. + WFIFOL(fd,6) = char_id;
  41. + WFIFOB(fd,10) = result;
  42. + WFIFOL(fd,11) = party_id;
  43. + safestrncpy((char*)WFIFOP(fd,15), name, NAME_LENGTH);
  44. WFIFOSET(fd,39);
  45. -
  46. - return 0;
  47. }
  48.  
  49. // ƒp[ƒeƒBî•ñŒ©‚‚©‚炸
  50. @@ -459,27 +451,27 @@
  51. // map server‚©‚ç‚̒ʐM
  52.  
  53.  
  54. -// Create Party
  55. -int mapif_parse_CreateParty(int fd, char *name, int item, int item2, struct party_member *leader)
  56. +/// Create a party.
  57. +static void mapif_parse_CreateParty(int fd, char* name, int item, int item2, struct party_member* leader)
  58. {
  59. struct party_data *p;
  60. int i;
  61. if( (p=search_partyname(name))!=NULL){
  62. - mapif_party_created(fd,leader->account_id,leader->char_id,NULL);
  63. - return 0;
  64. + mapif_party_created(fd, leader->account_id, leader->char_id, 1, 0, "");
  65. + return;
  66. }
  67. // Check Authorised letters/symbols in the name of the character
  68. if (char_name_option == 1) { // only letters/symbols in char_name_letters are authorised
  69. for (i = 0; i < NAME_LENGTH && name[i]; i++)
  70. if (strchr(char_name_letters, name[i]) == NULL) {
  71. - mapif_party_created(fd,leader->account_id,leader->char_id,NULL);
  72. - return 0;
  73. + mapif_party_created(fd, leader->account_id, leader->char_id, 1, 0, "");
  74. + return;
  75. }
  76. } else if (char_name_option == 2) { // letters/symbols in char_name_letters are forbidden
  77. for (i = 0; i < NAME_LENGTH && name[i]; i++)
  78. if (strchr(char_name_letters, name[i]) != NULL) {
  79. - mapif_party_created(fd,leader->account_id,leader->char_id,NULL);
  80. - return 0;
  81. + mapif_party_created(fd, leader->account_id, leader->char_id, 1, 0, "");
  82. + return;
  83. }
  84. }
  85.  
  86. @@ -499,13 +491,11 @@
  87. int_party_calc_state(p);
  88. idb_put(party_db_, p->party.party_id, p);
  89. mapif_party_info(fd, &p->party, 0);
  90. - mapif_party_created(fd,leader->account_id,leader->char_id,&p->party);
  91. + mapif_party_created(fd, leader->account_id, leader->char_id, 0, p->party.party_id, p->party.name);
  92. } else { //Failed to create party.
  93. aFree(p);
  94. - mapif_party_created(fd,leader->account_id,leader->char_id,NULL);
  95. + mapif_party_created(fd, leader->account_id, leader->char_id, 1, 0, "");
  96. }
  97. -
  98. - return 0;
  99. }
  100. // ƒp[ƒeƒBî•ñ—v‹
  101. static void mapif_parse_PartyInfo(int fd, int party_id, int char_id)
  102. Index: src/map/clif.c
  103. ===================================================================
  104. --- src/map/clif.c (revisão 16496)
  105. +++ src/map/clif.c (cópia de trabalho)
  106. @@ -6196,6 +6196,10 @@
  107.  
  108.  
  109. /// Adds new member to a party.
  110. +/// Other behaviours:
  111. +/// updates item share options without a message
  112. +/// replaces member if the charname matches
  113. +/// ignores position fields // TODO check on different clients [flaviojs]
  114. /// 0104 <account id>.L <role>.L <x>.W <y>.W <state>.B <party name>.24B <char name>.24B <map name>.16B (ZC_ADD_MEMBER_TO_GROUP)
  115. /// 01e9 <account id>.L <role>.L <x>.W <y>.W <state>.B <party name>.24B <char name>.24B <map name>.16B <item pickup rule>.B <item share rule>.B (ZC_ADD_MEMBER_TO_GROUP2)
  116. /// role:
  117. @@ -6204,31 +6208,35 @@
  118. /// state:
  119. /// 0 = connected
  120. /// 1 = disconnected
  121. -void clif_party_member_info(struct party_data *p, struct map_session_data *sd)
  122. +void clif_party_member_info(struct party_data *p, int member_id, send_target type)
  123. {
  124. unsigned char buf[81];
  125. - int i;
  126. + struct map_session_data* sd;
  127. + struct party_member* m;
  128.  
  129. - if (!sd) { //Pick any party member (this call is used when changing item share rules)
  130. - ARR_FIND( 0, MAX_PARTY, i, p->data[i].sd != 0 );
  131. - } else {
  132. - ARR_FIND( 0, MAX_PARTY, i, p->data[i].sd == sd );
  133. - }
  134. - if (i >= MAX_PARTY) return; //Should never happen...
  135. - sd = p->data[i].sd;
  136. + nullpo_retv(p);
  137.  
  138. + if( member_id < 0 || member_id >= MAX_PARTY )
  139. + return;// out of range
  140. + m = &p->party.member[member_id];
  141. + sd = p->data[member_id].sd;
  142. + if( sd == NULL && type != SELF )
  143. + sd = party_getavailablesd(p);// can use any party member
  144. + if( sd == NULL )
  145. + return;// not online
  146. +
  147. WBUFW(buf, 0) = 0x1e9;
  148. - WBUFL(buf, 2) = sd->status.account_id;
  149. - WBUFL(buf, 6) = (p->party.member[i].leader)?0:1;
  150. - WBUFW(buf,10) = sd->bl.x;
  151. - WBUFW(buf,12) = sd->bl.y;
  152. - WBUFB(buf,14) = (p->party.member[i].online)?0:1;
  153. + WBUFL(buf, 2) = m->account_id;
  154. + WBUFL(buf, 6) = ( m->leader ) ? 0 : 1;// role: 0-leader 1-member
  155. + WBUFW(buf,10) = p->data[member_id].x;
  156. + WBUFW(buf,12) = p->data[member_id].y;
  157. + WBUFB(buf,14) = ( m->online ) ? 0 : 1;// state: 0-online 1-offline
  158. memcpy(WBUFP(buf,15), p->party.name, NAME_LENGTH);
  159. - memcpy(WBUFP(buf,39), sd->status.name, NAME_LENGTH);
  160. - mapindex_getmapname_ext(map[sd->bl.m].name, (char*)WBUFP(buf,63));
  161. + memcpy(WBUFP(buf,39), m->name, NAME_LENGTH);
  162. + mapindex_getmapname_ext(map[m->map].name, (char*)WBUFP(buf,63));
  163. WBUFB(buf,79) = (p->party.item&1)?1:0;
  164. WBUFB(buf,80) = (p->party.item&2)?1:0;
  165. - clif_send(buf,packet_len(0x1e9),&sd->bl,PARTY);
  166. + clif_send(buf,packet_len(0x1e9),&sd->bl,type);
  167. }
  168.  
  169.  
  170. @@ -6363,18 +6371,17 @@
  171.  
  172.  
  173. /// Updates party settings.
  174. +/// Other behaviour:
  175. +/// notifies the user about the current options
  176. /// 0101 <exp option>.L (ZC_GROUPINFO_CHANGE)
  177. /// 07d8 <exp option>.L <item pick rule>.B <item share rule>.B (ZC_REQ_GROUPINFO_CHANGE_V2)
  178. /// exp option:
  179. /// 0 = exp sharing disabled
  180. /// 1 = exp sharing enabled
  181. /// 2 = cannot change exp sharing
  182. -///
  183. -/// flag:
  184. -/// 0 = send to party
  185. -/// 1 = send to sd
  186. -void clif_party_option(struct party_data *p,struct map_session_data *sd,int flag)
  187. +void clif_party_option(struct party_data* p, int member_id, send_target type)
  188. {
  189. + struct map_session_data* sd;
  190. unsigned char buf[16];
  191. #if PACKETVER < 20090603
  192. const int cmd = 0x101;
  193. @@ -6384,26 +6391,47 @@
  194.  
  195. nullpo_retv(p);
  196.  
  197. - if(!sd && flag==0){
  198. - int i;
  199. - for(i=0;i<MAX_PARTY && !p->data[i].sd;i++);
  200. - if (i < MAX_PARTY)
  201. - sd = p->data[i].sd;
  202. - }
  203. - if(!sd) return;
  204. + if( member_id < 0 || member_id >= MAX_PARTY )
  205. + return;// out of range
  206. + sd = p->data[member_id].sd;
  207. + if( sd == NULL && type != SELF )
  208. + sd = party_getavailablesd(p);// can use any party member
  209. + if( sd == NULL )
  210. + return;// not online
  211. +
  212. WBUFW(buf,0)=cmd;
  213. - WBUFL(buf,2)=((flag&0x01)?2:p->party.exp);
  214. + WBUFL(buf,2)=p->party.exp;
  215. #if PACKETVER >= 20090603
  216. WBUFB(buf,6)=(p->party.item&1)?1:0;
  217. WBUFB(buf,7)=(p->party.item&2)?1:0;
  218. +#else
  219. + // item changes are not notified in older clients
  220. + clif_party_member_info(p, member_id, type);
  221. #endif
  222. - if(flag==0)
  223. - clif_send(buf,packet_len(cmd),&sd->bl,PARTY);
  224. - else
  225. - clif_send(buf,packet_len(cmd),&sd->bl,SELF);
  226. + clif_send(buf,packet_len(cmd),&sd->bl,type);
  227. }
  228.  
  229.  
  230. +/// Notify the user that it cannot change exp sharing.
  231. +/// 0101 <exp option>.L (ZC_GROUPINFO_CHANGE)
  232. +/// exp option:
  233. +/// 0 = exp sharing disabled
  234. +/// 1 = exp sharing enabled
  235. +/// 2 = cannot change exp sharing
  236. +void clif_party_option_failexp(struct map_session_data* sd)
  237. +{
  238. + unsigned char buf[16];
  239. +
  240. + if( sd == NULL )
  241. + return;
  242. +
  243. + WBUFW(buf,0) = 0x101;
  244. + WBUFL(buf,2) = 2;// cannot change exp sharing
  245. +
  246. + clif_send(buf,packet_len(0x101),&sd->bl,SELF);
  247. +}
  248. +
  249. +
  250. /// 0105 <account id>.L <char name>.24B <result>.B (ZC_DELETE_MEMBER_FROM_GROUP).
  251. /// result:
  252. /// 0 = leave
  253. Index: src/map/clif.h
  254. ===================================================================
  255. --- src/map/clif.h (revisão 16496)
  256. +++ src/map/clif.h (cópia de trabalho)
  257. @@ -494,11 +494,12 @@
  258.  
  259. // party
  260. void clif_party_created(struct map_session_data *sd,int result);
  261. -void clif_party_member_info(struct party_data *p, struct map_session_data *sd);
  262. +void clif_party_member_info(struct party_data *p, int member_id, send_target type);
  263. void clif_party_info(struct party_data* p, struct map_session_data *sd);
  264. void clif_party_invite(struct map_session_data *sd,struct map_session_data *tsd);
  265. void clif_party_inviteack(struct map_session_data* sd, const char* nick, int result);
  266. -void clif_party_option(struct party_data *p,struct map_session_data *sd,int flag);
  267. +void clif_party_option(struct party_data* p, int member_id, send_target type);
  268. +void clif_party_option_failexp(struct map_session_data* sd);
  269. void clif_party_withdraw(struct party_data* p, struct map_session_data* sd, int account_id, const char* name, int flag);
  270. void clif_party_message(struct party_data* p, int account_id, const char* mes, int len);
  271. void clif_party_xy(struct map_session_data *sd);
  272. Index: src/map/intif.c
  273. ===================================================================
  274. --- src/map/intif.c (revisão 16496)
  275. +++ src/map/intif.c (cópia de trabalho)
  276. @@ -52,7 +52,9 @@
  277. //-----------------------------------------------------------------
  278. // inter server‚Ö‚Ì‘—M
  279.  
  280. -int CheckForCharServer(void)
  281. +
  282. +/// Returns true if not connected to the char-server.
  283. +bool CheckForCharServer(void)
  284. {
  285. return ((char_fd <= 0) || session[char_fd] == NULL || session[char_fd]->wdata == NULL);
  286. }
  287. @@ -386,22 +388,23 @@
  288. return 0;
  289. }
  290.  
  291. -// ƒp[ƒeƒBì¬—v‹
  292. -int intif_create_party(struct party_member *member,char *name,int item,int item2)
  293. +/// Create a party.
  294. +/// Returns true if the request is sent.
  295. +bool intif_create_party(struct party_member* member, const char* name, int item, int item2)
  296. {
  297. if (CheckForCharServer())
  298. - return 0;
  299. - nullpo_ret(member);
  300. + return false;
  301. + nullpo_retr(false, member);
  302.  
  303. WFIFOHEAD(inter_fd,64);
  304. WFIFOW(inter_fd,0) = 0x3020;
  305. WFIFOW(inter_fd,2) = 30+sizeof(struct party_member);
  306. memcpy(WFIFOP(inter_fd,4),name, NAME_LENGTH);
  307. - WFIFOB(inter_fd,28)= item;
  308. - WFIFOB(inter_fd,29)= item2;
  309. + WFIFOB(inter_fd,28) = item;
  310. + WFIFOB(inter_fd,29) = item2;
  311. memcpy(WFIFOP(inter_fd,30), member, sizeof(struct party_member));
  312. WFIFOSET(inter_fd,WFIFOW(inter_fd, 2));
  313. - return 0;
  314. + return true;
  315. }
  316. // ƒp[ƒeƒBî•ñ—v‹
  317. int intif_request_partyinfo(int party_id, int char_id)
  318. @@ -1023,12 +1026,12 @@
  319. return 0;
  320. }
  321.  
  322. -// ƒp[ƒeƒBì¬‰Â”Û
  323. +/// Party creation notification.
  324. int intif_parse_PartyCreated(int fd)
  325. {
  326. if(battle_config.etc_log)
  327. ShowInfo("intif: party created by account %d\n\n", RFIFOL(fd,2));
  328. - party_created(RFIFOL(fd,2), RFIFOL(fd,6),RFIFOB(fd,10),RFIFOL(fd,11), (char *)RFIFOP(fd,15));
  329. + party_created(RFIFOL(fd,2), RFIFOL(fd,6), RFIFOB(fd,10), RFIFOL(fd,11), (const char *)RFIFOP(fd,15));
  330. return 0;
  331. }
  332. // ƒp[ƒeƒBî•ñ
  333. Index: src/map/intif.h
  334. ===================================================================
  335. --- src/map/intif.h (revisão 16496)
  336. +++ src/map/intif.h (cópia de trabalho)
  337. @@ -31,7 +31,7 @@
  338. int intif_send_guild_storage(int account_id, struct guild_storage *gstor);
  339.  
  340.  
  341. -int intif_create_party(struct party_member *member,char *name,int item,int item2);
  342. +bool intif_create_party(struct party_member* member, const char* name, int item, int item2);
  343. int intif_request_partyinfo(int party_id, int char_id);
  344.  
  345. int intif_party_addmember(int party_id,struct party_member *member);
  346. @@ -107,6 +107,6 @@
  347. /* @accinfo */
  348. void intif_request_accinfo( int u_fd, int aid, int group_id, char* query );
  349.  
  350. -int CheckForCharServer(void);
  351. +bool CheckForCharServer(void);
  352.  
  353. #endif /* _INTIF_H_ */
  354. Index: src/map/party.c
  355. ===================================================================
  356. --- src/map/party.c (revisão 16496)
  357. +++ src/map/party.c (cópia de trabalho)
  358. @@ -143,7 +143,9 @@
  359. return p;
  360. }
  361.  
  362. -int party_create(struct map_session_data *sd,char *name,int item,int item2)
  363. +/// Request the creation of a party.
  364. +/// Returns true if the request was sent.
  365. +bool party_create(struct map_session_data* sd, const char* name, int item, int item2)
  366. {
  367. struct party_member leader;
  368. char tname[NAME_LENGTH];
  369. @@ -153,25 +155,24 @@
  370.  
  371. if( !tname[0] )
  372. {// empty name
  373. - return 0;
  374. + return false;
  375. }
  376.  
  377. if( sd->status.party_id > 0 || sd->party_joining || sd->party_creating )
  378. {// already associated with a party
  379. clif_party_created(sd,2);
  380. - return 0;
  381. + return false;
  382. }
  383.  
  384. - sd->party_creating = true;
  385. -
  386. party_fill_member(&leader, sd, 1);
  387.  
  388. - intif_create_party(&leader,name,item,item2);
  389. - return 0;
  390. + sd->party_creating = intif_create_party(&leader,name,item,item2);
  391. + return sd->party_creating;
  392. }
  393.  
  394.  
  395. -void party_created(int account_id,int char_id,int fail,int party_id,char *name)
  396. +/// Party creation notification.
  397. +void party_created(int account_id, int char_id, int fail, int party_id, const char* name)
  398. {
  399. struct map_session_data *sd;
  400. sd=map_id2sd(account_id);
  401. @@ -316,8 +317,8 @@
  402. if( sd == NULL )
  403. continue;// not online
  404. clif_charnameupdate(sd); //Update other people's display. [Skotlex]
  405. - clif_party_member_info(p,sd);
  406. - clif_party_option(p,sd,0x100);
  407. + clif_party_member_info(p, member_id, PARTY);
  408. + clif_party_option(p, member_id, SELF);
  409. clif_party_info(p,NULL);
  410. if( p->instance_id != 0 )
  411. clif_instance_join(sd->fd, p->instance_id);
  412. @@ -480,8 +481,8 @@
  413.  
  414. sd->status.party_id = party_id;
  415.  
  416. - clif_party_member_info(p,sd);
  417. - clif_party_option(p,sd,0x100);
  418. + clif_party_member_info(p, party_getmemberid(p,sd), PARTY);
  419. + clif_party_option(p, party_getmemberid(p,sd), SELF);
  420. clif_party_info(p,sd);
  421.  
  422. if( sd2 != NULL )
  423. @@ -607,6 +608,7 @@
  424. return 0;
  425. }
  426.  
  427. +/// Request the charserver to change party options.
  428. int party_changeoption(struct map_session_data *sd,int exp,int item)
  429. {
  430. nullpo_ret(sd);
  431. @@ -617,22 +619,26 @@
  432. return 0;
  433. }
  434.  
  435. -int party_optionchanged(int party_id,int account_id,int exp,int item,int flag)
  436. +/// Reply from charserver about changed party options.
  437. +/// flag bitfield:
  438. +/// &0x01 - exp change denied
  439. +/// &0x10 - item change denied
  440. +void party_optionchanged(int party_id, int account_id, int exp, int item, int flag)
  441. {
  442. struct party_data *p;
  443. struct map_session_data *sd=map_id2sd(account_id);
  444. if( (p=party_search(party_id))==NULL)
  445. - return 0;
  446. + return;
  447.  
  448. //Flag&1: Exp change denied. Flag&2: Item change denied.
  449. if(!(flag&0x01) && p->party.exp != exp)
  450. p->party.exp=exp;
  451. - if(!(flag&0x10) && p->party.item != item) {
  452. + if(!(flag&0x10) && p->party.item != item)
  453. p->party.item=item;
  454. - }
  455.  
  456. - clif_party_option(p,sd,flag);
  457. - return 0;
  458. + if( (flag&0x01) )
  459. + clif_party_option_failexp(sd);
  460. + clif_party_option(p, party_getmemberid(p,sd), PARTY);
  461. }
  462.  
  463. bool party_changeleader(struct map_session_data *sd, struct map_session_data *tsd)
  464. @@ -733,9 +739,9 @@
  465.  
  466. if(sd->state.connect_new) {
  467. //Note that this works because this function is invoked before connect_new is cleared.
  468. - clif_party_option(p,sd,0x100);
  469. + clif_party_option(p, party_getmemberid(p,sd), SELF);
  470. clif_party_info(p,sd);
  471. - clif_party_member_info(p,sd);
  472. + clif_party_member_info(p, party_getmemberid(p,sd), PARTY);
  473. }
  474.  
  475. if (sd->fd) { // synchronize minimap positions with the rest of the party
  476. Index: src/map/party.h
  477. ===================================================================
  478. --- src/map/party.h (revisão 16496)
  479. +++ src/map/party.h (cópia de trabalho)
  480. @@ -54,8 +54,8 @@
  481. int party_getmemberid(struct party_data* p, struct map_session_data* sd);
  482. struct map_session_data* party_getavailablesd(struct party_data *p);
  483.  
  484. -int party_create(struct map_session_data *sd,char *name, int item, int item2);
  485. -void party_created(int account_id,int char_id,int fail,int party_id,char *name);
  486. +bool party_create(struct map_session_data* sd, const char* name, int item, int item2);
  487. +void party_created(int account_id, int char_id, int fail, int party_id, const char* name);
  488. int party_request_info(int party_id, int char_id);
  489. int party_invite(struct map_session_data *sd,struct map_session_data *tsd);
  490. void party_member_joined(struct map_session_data *sd);
  491. @@ -68,7 +68,7 @@
  492. int party_recv_info(struct party* sp, int char_id);
  493. int party_recv_movemap(int party_id,int account_id,int char_id, unsigned short map,int online,int lv);
  494. int party_broken(int party_id);
  495. -int party_optionchanged(int party_id,int account_id,int exp,int item,int flag);
  496. +void party_optionchanged(int party_id, int account_id, int exp, int item, int flag);
  497. int party_changeoption(struct map_session_data *sd,int exp,int item);
  498. bool party_changeleader(struct map_session_data *sd, struct map_session_data *t_sd);
  499. void party_send_movemap(struct map_session_data *sd);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement