Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.78 KB | None | 0 0
  1. // Alliance modification
  2. int mapif_parse_GuildAlliance(int fd,int guild_id1,int guild_id2,int account_id1,int account_id2,int flag)
  3. {
  4. // Could speed up
  5. struct guild *g[2];
  6. int j,i,k;
  7. g[0] = inter_guild_fromsql(guild_id1);
  8. g[1] = inter_guild_fromsql(guild_id2);
  9.  
  10. if(g[0] && g[1]==NULL && (flag & GUILD_ALLIANCE_REMOVE)) //Requested to remove an alliance with a not found guild.
  11. return mapif_parse_GuildDeleteAlliance(g[0], guild_id2, account_id1, account_id2, flag); //Try to do a manual removal of said guild.
  12.  
  13. if(g[0]==NULL || g[1]==NULL)
  14. return 0;
  15.  
  16. if(flag&GUILD_ALLIANCE_REMOVE)
  17. {
  18. // Remove alliance/opposition, in case of alliance, remove on both side
  19. for(i=0;i<2-(flag&GUILD_ALLIANCE_TYPE_MASK);i++)
  20. {
  21. ARR_FIND( 0, MAX_GUILDALLIANCE, j, g[i]->alliance[j].guild_id == g[1-i]->guild_id && g[i]->alliance[j].opposition == (flag&GUILD_ALLIANCE_TYPE_MASK) );
  22. if( j < MAX_GUILDALLIANCE )
  23. g[i]->alliance[j].guild_id = 0;
  24. }
  25. }
  26. else
  27. {
  28. if(g[0]->type==0 && g[1]->type==0){
  29. // Add alliance, in case of alliance, add on both side
  30. for(i=0;i<2-(flag&GUILD_ALLIANCE_TYPE_MASK);i++)
  31. {
  32. // Search an empty slot
  33. ARR_FIND( 0, MAX_GUILDALLIANCE, j, g[i]->alliance[j].guild_id == 0 );
  34. if( j < MAX_GUILDALLIANCE )
  35. {
  36. g[i]->alliance[j].guild_id=g[1-i]->guild_id;
  37. memcpy(g[i]->alliance[j].name,g[1-i]->name,NAME_LENGTH);
  38. // Set alliance type
  39. g[i]->alliance[j].opposition = flag&GUILD_ALLIANCE_TYPE_MASK;
  40. }
  41. }
  42. }else{
  43. k = 1;
  44. }
  45. }
  46. if(k==0){
  47. // Send on all map the new alliance/opposition
  48. mapif_guild_alliance(guild_id1,guild_id2,account_id1,account_id2,flag,g[0]->name,g[1]->name);
  49. }
  50. // Mark the two guild to be saved
  51. g[0]->save_flag |= GS_ALLIANCE;
  52. g[1]->save_flag |= GS_ALLIANCE;
  53. return 0;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement