Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Alliance modification
- int mapif_parse_GuildAlliance(int fd,int guild_id1,int guild_id2,int account_id1,int account_id2,int flag)
- {
- // Could speed up
- struct guild *g[2];
- int j,i,k;
- g[0] = inter_guild_fromsql(guild_id1);
- g[1] = inter_guild_fromsql(guild_id2);
- if(g[0] && g[1]==NULL && (flag & GUILD_ALLIANCE_REMOVE)) //Requested to remove an alliance with a not found guild.
- return mapif_parse_GuildDeleteAlliance(g[0], guild_id2, account_id1, account_id2, flag); //Try to do a manual removal of said guild.
- if(g[0]==NULL || g[1]==NULL)
- return 0;
- if(flag&GUILD_ALLIANCE_REMOVE)
- {
- // Remove alliance/opposition, in case of alliance, remove on both side
- for(i=0;i<2-(flag&GUILD_ALLIANCE_TYPE_MASK);i++)
- {
- 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) );
- if( j < MAX_GUILDALLIANCE )
- g[i]->alliance[j].guild_id = 0;
- }
- }
- else
- {
- if(g[0]->type==0 && g[1]->type==0){
- // Add alliance, in case of alliance, add on both side
- for(i=0;i<2-(flag&GUILD_ALLIANCE_TYPE_MASK);i++)
- {
- // Search an empty slot
- ARR_FIND( 0, MAX_GUILDALLIANCE, j, g[i]->alliance[j].guild_id == 0 );
- if( j < MAX_GUILDALLIANCE )
- {
- g[i]->alliance[j].guild_id=g[1-i]->guild_id;
- memcpy(g[i]->alliance[j].name,g[1-i]->name,NAME_LENGTH);
- // Set alliance type
- g[i]->alliance[j].opposition = flag&GUILD_ALLIANCE_TYPE_MASK;
- }
- }
- }else{
- k = 1;
- }
- }
- if(k==0){
- // Send on all map the new alliance/opposition
- mapif_guild_alliance(guild_id1,guild_id2,account_id1,account_id2,flag,g[0]->name,g[1]->name);
- }
- // Mark the two guild to be saved
- g[0]->save_flag |= GS_ALLIANCE;
- g[1]->save_flag |= GS_ALLIANCE;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement