Fix for daily timers. Minor family fixes. Server code to change guild leader. (#513)
This commit is contained in:
@@ -7577,7 +7577,7 @@ public class MapleCharacter extends AbstractMapleCharacterObject {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (possesed > 0) {
|
||||
if (possesed > 0 && !GameConstants.isDojo(getMapId())) {
|
||||
message("You have used a safety charm, so your EXP points have not been decreased.");
|
||||
MapleInventoryManipulator.removeById(client, ItemConstants.getInventoryType(charmID[i]), charmID[i], 1, true, false);
|
||||
} else if (getJob() != MapleJob.BEGINNER) { //Hmm...
|
||||
|
||||
@@ -203,9 +203,11 @@ public class MapleFamily {
|
||||
jobID = rs.getInt("job");
|
||||
} else {
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, "Could not load character information of " + cid + " in loadAllFamilies(). (RECORD DOES NOT EXIST)");
|
||||
continue;
|
||||
}
|
||||
} catch(SQLException e) {
|
||||
FilePrinter.printError(FilePrinter.FAMILY_ERROR, e, "Could not load character information of " + cid + " in loadAllFamilies(). (SQL ERROR)");
|
||||
continue;
|
||||
}
|
||||
int familyid = rsEntries.getInt("familyid");
|
||||
int seniorid = rsEntries.getInt("seniorid");
|
||||
|
||||
@@ -535,7 +535,7 @@ public class Server {
|
||||
public static long getTimeLeftForNextDay() {
|
||||
Calendar nextDay = Calendar.getInstance();
|
||||
nextDay.add(Calendar.DAY_OF_MONTH, 1);
|
||||
nextDay.set(Calendar.HOUR, 0);
|
||||
nextDay.set(Calendar.HOUR_OF_DAY, 0);
|
||||
nextDay.set(Calendar.MINUTE, 0);
|
||||
nextDay.set(Calendar.SECOND, 0);
|
||||
|
||||
|
||||
@@ -46,6 +46,8 @@ public final class FamilyAddHandler extends AbstractMaplePacketHandler {
|
||||
MapleCharacter chr = c.getPlayer();
|
||||
if(addChr == null) {
|
||||
c.announce(MaplePacketCreator.sendFamilyMessage(65, 0));
|
||||
} else if(addChr == chr) { //only possible through packet editing/client editing i think?
|
||||
c.announce(MaplePacketCreator.enableActions());
|
||||
} else if(addChr.getMap() != chr.getMap() || (addChr.isHidden()) && chr.gmLevel() < addChr.gmLevel()) {
|
||||
c.announce(MaplePacketCreator.sendFamilyMessage(69, 0));
|
||||
} else if(addChr.getLevel() <= 10) {
|
||||
|
||||
@@ -30,6 +30,7 @@ import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@@ -307,6 +308,18 @@ public class MapleGuild {
|
||||
}
|
||||
}
|
||||
|
||||
public void broadcastInfoChanged() {
|
||||
PlayerStorage ps = Server.getInstance().getWorld(world).getPlayerStorage();
|
||||
|
||||
for (MapleGuildCharacter mgc : getMembers()) {
|
||||
MapleCharacter chr = ps.getCharacterById(mgc.getId());
|
||||
if (chr == null || !chr.isLoggedinWorld()) continue;
|
||||
|
||||
byte[] packet = MaplePacketCreator.showGuildInfo(chr);
|
||||
chr.announce(packet);
|
||||
}
|
||||
}
|
||||
|
||||
public void broadcast(final byte[] packet) {
|
||||
broadcast(packet, -1, BCOp.NONE);
|
||||
}
|
||||
@@ -567,6 +580,14 @@ public class MapleGuild {
|
||||
}
|
||||
|
||||
membersLock.lock();
|
||||
members.sort(new Comparator<MapleGuildCharacter>() {
|
||||
@Override
|
||||
public int compare(MapleGuildCharacter t, MapleGuildCharacter o) {
|
||||
if(t.getGuildRank() <= 1 && o.getGuildRank() > 1) return -1;
|
||||
else if(t.getGuildRank() > 1 && o.getGuildRank() <= 1) return 1;
|
||||
else return 0;
|
||||
}
|
||||
});
|
||||
try {
|
||||
this.broadcast(MaplePacketCreator.changeRank(mgc));
|
||||
} finally {
|
||||
|
||||
@@ -21,8 +21,16 @@
|
||||
*/
|
||||
package net.server.handlers.login;
|
||||
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
|
||||
import client.MapleClient;
|
||||
import client.MapleFamily;
|
||||
import net.AbstractMaplePacketHandler;
|
||||
import net.server.Server;
|
||||
import tools.DatabaseConnection;
|
||||
import tools.FilePrinter;
|
||||
import tools.MaplePacketCreator;
|
||||
import tools.data.input.SeekableLittleEndianAccessor;
|
||||
@@ -34,11 +42,45 @@ public final class DeleteCharHandler extends AbstractMaplePacketHandler {
|
||||
String pic = slea.readMapleAsciiString();
|
||||
int cid = slea.readInt();
|
||||
if (c.checkPic(pic)) {
|
||||
//check for family, guild leader, pending marriage, world transfer
|
||||
try (Connection con = DatabaseConnection.getConnection();
|
||||
PreparedStatement ps = con.prepareStatement("SELECT `world`, `guildid`, `guildrank`, `familyId` FROM characters WHERE id = ?");
|
||||
PreparedStatement ps2 = con.prepareStatement("SELECT COUNT(*) as rowcount FROM worldtransfers WHERE `characterid` = ? AND completionTime IS NULL")) {
|
||||
ps.setInt(1, cid);
|
||||
ResultSet rs = ps.executeQuery();
|
||||
if(!rs.next()) throw new SQLException("Character record does not exist.");
|
||||
int world = rs.getInt("world");
|
||||
int guildId = rs.getInt("guildid");
|
||||
int guildRank = rs.getInt("guildrank");
|
||||
int familyId = rs.getInt("familyId");
|
||||
if(guildId != 0 && guildRank <= 1) {
|
||||
c.announce(MaplePacketCreator.deleteCharResponse(cid, 0x16));
|
||||
return;
|
||||
} else if(familyId != -1) {
|
||||
MapleFamily family = Server.getInstance().getWorld(world).getFamily(familyId);
|
||||
if(family != null && family.getTotalMembers() > 1) {
|
||||
c.announce(MaplePacketCreator.deleteCharResponse(cid, 0x1D));
|
||||
return;
|
||||
}
|
||||
}
|
||||
rs.close();
|
||||
ps2.setInt(1, cid);
|
||||
rs = ps2.executeQuery();
|
||||
rs.next();
|
||||
if(rs.getInt("rowcount") > 0) {
|
||||
c.announce(MaplePacketCreator.deleteCharResponse(cid, 0x1A));
|
||||
return;
|
||||
}
|
||||
} catch(SQLException e) {
|
||||
e.printStackTrace();
|
||||
c.announce(MaplePacketCreator.deleteCharResponse(cid, 0x09));
|
||||
return;
|
||||
}
|
||||
if(c.deleteCharacter(cid, c.getAccID())) {
|
||||
FilePrinter.print(FilePrinter.DELETED_CHAR + c.getAccountName() + ".txt", c.getAccountName() + " deleted CID: " + cid);
|
||||
c.announce(MaplePacketCreator.deleteCharResponse(cid, 0));
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.deleteCharResponse(cid, 0x14));
|
||||
c.announce(MaplePacketCreator.deleteCharResponse(cid, 0x09));
|
||||
}
|
||||
} else {
|
||||
c.announce(MaplePacketCreator.deleteCharResponse(cid, 0x14));
|
||||
|
||||
@@ -29,7 +29,7 @@ public class FamilyDailyResetWorker implements Runnable {
|
||||
public static void resetEntitlementUsage(World world) {
|
||||
Calendar resetTime = Calendar.getInstance();
|
||||
resetTime.add(Calendar.MINUTE, 1); // to make sure that we're in the "next day", since this is called at midnight
|
||||
resetTime.set(Calendar.HOUR, 0);
|
||||
resetTime.set(Calendar.HOUR_OF_DAY, 0);
|
||||
resetTime.set(Calendar.MINUTE, 0);
|
||||
resetTime.set(Calendar.SECOND, 0);
|
||||
resetTime.set(Calendar.MILLISECOND, 0);
|
||||
|
||||
@@ -2721,7 +2721,17 @@ public class MaplePacketCreator {
|
||||
}
|
||||
|
||||
/**
|
||||
* state 0 = del ok state 12 = invalid bday state 14 = incorrect pic
|
||||
* State :
|
||||
* 0x00 = success
|
||||
* 0x06 = Trouble logging into the game?
|
||||
* 0x09 = Unknown error
|
||||
* 0x0A = Could not be processed due to too many connection requests to the server.
|
||||
* 0x12 = invalid bday
|
||||
* 0x14 = incorrect pic
|
||||
* 0x16 = Cannot delete a guild master.
|
||||
* 0x18 = Cannot delete a character with a pending wedding.
|
||||
* 0x1A = Cannot delete a character with a pending world transfer.
|
||||
* 0x1D = Cannot delete a character that has a family.
|
||||
*
|
||||
* @param cid
|
||||
* @param state
|
||||
|
||||
Reference in New Issue
Block a user