Fixed Guild Creation

Fixed a bug on guild creation process where the leadership would not be
assigned instantly to the guild leader (would need to change channels or
reconnect to take effect).
This commit is contained in:
ronancpl
2017-06-12 14:53:11 -03:00
parent 9ab79f216a
commit 7a8bba98ca
42 changed files with 71 additions and 51 deletions

View File

@@ -182,7 +182,7 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
private int currentPage, currentType = 0, currentTab = 1;
private int chair;
private int itemEffect;
private int guildid, guildrank, allianceRank;
private int guildid, guildRank, allianceRank;
private int messengerposition = 4;
private int slots = 0;
private int energybar;
@@ -1203,11 +1203,11 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
this.closePlayerInteractions();
client.announce(warpPacket);
map.removePlayer(MapleCharacter.this);
map.removePlayer(this);
if (client.getChannelServer().getPlayerStorage().getCharacterById(getId()) != null) {
map = to;
setPosition(pos);
map.addPlayer(MapleCharacter.this);
map.addPlayer(this);
if (party != null) {
mpc.setMapId(to.getId());
silentPartyUpdate();
@@ -1808,7 +1808,7 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
}
public void disbandGuild() {
if (guildid < 1 || guildrank != 1) {
if (guildid < 1 || guildRank != 1) {
return;
}
try {
@@ -2436,7 +2436,7 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
}
public int getGuildRank() {
return guildrank;
return guildRank;
}
public int getHair() {
@@ -3810,7 +3810,7 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
int mountlevel = rs.getInt("mountlevel");
int mounttiredness = rs.getInt("mounttiredness");
ret.guildid = rs.getInt("guildid");
ret.guildrank = rs.getInt("guildrank");
ret.guildRank = rs.getInt("guildrank");
ret.allianceRank = rs.getInt("allianceRank");
ret.familyId = rs.getInt("familyId");
ret.bookCover = rs.getInt("monsterbookcover");
@@ -3820,9 +3820,7 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
ret.dojoPoints = rs.getInt("dojoPoints");
ret.dojoStage = rs.getInt("lastDojoStage");
ret.dataString = rs.getString("dataString");
if (ret.guildid > 0) {
ret.mgc = new MapleGuildCharacter(ret); // oh boy, that's quite funny
}
if (ret.guildid > 0) ret.mgc = new MapleGuildCharacter(ret);
int buddyCapacity = rs.getInt("buddyCapacity");
ret.buddylist = new BuddyList(buddyCapacity);
ret.getInventory(MapleInventoryType.EQUIP).setSlotLimit(rs.getByte("equipslots"));
@@ -4639,7 +4637,7 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
try {
try (PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("UPDATE characters SET guildid = ?, guildrank = ?, allianceRank = ? WHERE id = ?")) {
ps.setInt(1, guildid);
ps.setInt(2, guildrank);
ps.setInt(2, guildRank);
ps.setInt(3, allianceRank);
ps.setInt(4, id);
ps.executeUpdate();
@@ -5087,10 +5085,6 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
}
}
public void setAllianceRank(int rank) {
allianceRank = rank;
}
public void setAllowWarpToId(int id) {
this.warpToId = id;
}
@@ -5205,14 +5199,17 @@ public class MapleCharacter extends AbstractAnimatedMapleMapObject {
}
} else {
mgc = null;
guildRank = 5;
allianceRank = 5;
}
}
public void setGuildRank(int _rank) {
guildrank = _rank;
if (mgc != null) {
mgc.setGuildRank(_rank);
}
guildRank = _rank;
}
public void setAllianceRank(int _rank) {
allianceRank = _rank;
}
public void setHair(int hair) {

View File

@@ -499,11 +499,8 @@ public class Server implements Runnable {
}
if(mc != null) {
MapleGuildCharacter mgc = mc.getMGC();
if (mgc != null) {
g.setOnline(mgc.getId(), true, mgc.getChannel());
mc.setMGC(g.getMGC(mc.getId())); // i really REALLY must make player MGC the same as the guild MGC
}
g.addGuildMember(mc.getMGC()); // i really REALLY must make player MGC the same as the guild MGC
g.setOnline(mc.getId(), true, mc.getClient().getChannel());
}
guilds.put(id, g);

View File

@@ -22,6 +22,7 @@
package net.server.channel.handlers;
import net.server.guild.MapleGuildResponse;
import net.server.guild.MapleGuildCharacter;
import net.server.guild.MapleGuild;
import client.MapleClient;
import net.AbstractMaplePacketHandler;
@@ -30,7 +31,6 @@ import java.util.Iterator;
import tools.MaplePacketCreator;
import client.MapleCharacter;
import net.server.Server;
import net.server.guild.MapleAlliance;
public final class GuildOperationHandler extends AbstractMaplePacketHandler {
private boolean isGuildNameAcceptable(String name) {
@@ -123,16 +123,13 @@ public final class GuildOperationHandler extends AbstractMaplePacketHandler {
return;
}
mc.gainMeso(-MapleGuild.CREATE_GUILD_COST, true, false, true);
mc.setGuildId(gid);
mc.setGuildRank(1);
mc.setAllianceRank(5);
MapleGuild guild = Server.getInstance().getGuild(mc.getGuildId(), c.getWorld(), mc); // initialize guild structure
guild.getMGC(guild.getLeaderId()).setCharacter(mc);
Server.getInstance().getWorld(mc.getWorld()).setGuildAndRank(mc.getId(), gid, 1);
Server.getInstance().setGuildMemberOnline(mc, true, mc.getClient().getChannel());
c.announce(MaplePacketCreator.showGuildInfo(mc));
c.getPlayer().dropMessage(1, "You have successfully created a Guild.");
respawnPlayer(mc);
break;
case 0x05:
if (mc.getGuildId() <= 0 || mc.getGuildRank() > 2) {

View File

@@ -47,7 +47,7 @@ public class MapleGuild {
private enum BCOp {
NONE, DISBAND, EMBLEMCHANGE
}
private List<MapleGuildCharacter> members;
private final List<MapleGuildCharacter> members;
private String rankTitles[] = new String[5]; // 1 = master, 2 = jr, 5 = lowest member
private String name, notice;
private int id, gp, logo, logoColor, leader, capacity, logoBG, logoBGColor, signature, allianceId;

View File

@@ -112,13 +112,23 @@ public class MapleGuildCharacter {
public void setGuildId(int gid) {
guildid = gid;
}
public int getGuildRank() {
return guildrank;
}
public void setGuildRank(int rank) {
guildrank = rank;
if(character != null) character.setGuildRank(rank);
}
public int getGuildRank() {
return guildrank;
public int getAllianceRank() {
return allianceRank;
}
public void setAllianceRank(int rank) {
allianceRank = rank;
if(character != null) character.setAllianceRank(rank);
}
public boolean isOnline() {
@@ -133,15 +143,6 @@ public class MapleGuildCharacter {
return name;
}
public void setAllianceRank(int rank) {
allianceRank = rank;
if(character != null) character.setAllianceRank(rank);
}
public int getAllianceRank() {
return allianceRank;
}
@Override
public boolean equals(Object other) {
if (!(other instanceof MapleGuildCharacter)) {

View File

@@ -266,7 +266,13 @@ public class World {
} else {
bDifferentGuild = guildid != mc.getGuildId();
mc.setGuildId(guildid);
mc.setGuildRank(rank);
MapleGuildCharacter mgc = mc.getMGC();
if(mgc != null) {
mgc.setGuildRank(rank);
if(bDifferentGuild) mgc.setAllianceRank(5);
}
mc.saveGuildStatus();
}
if (bDifferentGuild) {

View File

@@ -117,6 +117,18 @@ public class EventInstanceManager {
return em;
}
public int getEventPlayersJobs() {
//Bits -> 0: BEGINNER 1: WARRIOR 2: MAGICIAN
// 3: BOWMAN 4: THIEF 5: PIRATE
int mask = 0;
for(MapleCharacter chr: getPlayers()) {
mask |= (1 << chr.getJob().getJobNiche());
}
return mask;
}
public void applyEventPlayersItemBuff(int itemId) {
List<MapleCharacter> players = getPlayerList();
MapleStatEffect mse = MapleItemInformationProvider.getInstance().getItemEffect(itemId);

View File

@@ -3730,8 +3730,6 @@ public class MaplePacketCreator {
if (g == null) { //failed to read from DB - don't show a guild
mplew.write(0);
return mplew.getPacket();
} else {
c.setGuildRank(c.getGuildRank());
}
mplew.write(1); //bInGuild
mplew.writeInt(g.getId());