client.java search "destroy" under that method add that player savingshit.
|
I encountered this bug while dupe-testing on my server. If you do an action that gives another player an item, for example dropping an item, and then disconnect your router and put it back in, your account will load on the last time it was saved.
The issue is, how would I prevent rollbacks as a whole? I was thinking creating a separate thread and saving all accounts in that one, but that would eat up my memory.
I also tried using this:
Code:@Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { Player player = session.getPlayer(); if (player != null) SerializeSave.savePlayer(player); }Is what is used to add the player to the list of online players, and remove them.Code:@Override public void run() { Thread.currentThread().setName("NodeWorker"); Node n = null; while (true) { try { while (!AWAITING_ADDING.isEmpty()) { n = AWAITING_ADDING.poll(); if (n instanceof Player) { try { Player player = PLAYER_LOADER.load(PLAYER_LOADER.checkLogin(n)); if (player != null) { if (player.getIOSession().isInLobby()) { LOBBY_PLAYERS.add(player); PLAYER_NAME_MAP.put("+lobby>" + player.getCredentials().getUsername(), player); } else { LOBBY_PLAYERS.remove(player); PLAYER_NAME_MAP.remove("+lobby>" + player.getCredentials().getUsername()); if (getPlayer(player.getCredentials().getUsername()) == null) { PLAYERS.add(player); PLAYER_NAME_MAP.put(player.getCredentials().getUsername(), player); } else { player.getIOSession().getChannel().disconnect(); continue; } } player.init(); System.out.println("Player " + player.getCredentials().getUsername() + " connected: [" + player.getIndex() + ", " + PLAYERS.size() + "]."); } } catch (Throwable t) { t.printStackTrace(); } } else if (n instanceof NPC) { NPC npc = NPC_LOADER.load(NPC_LOADER.checkLogin(n)); if (npc != null) { npc.init(); NPCS.add(npc); } } else if (n instanceof GameObject) { OBJECT_LOADER.load(OBJECT_LOADER.checkLogin(n)); } else { throw new IllegalStateException("Unsupported node - " + n.getClass().getSimpleName()); } } while (!AWAITING_REMOVAL.isEmpty()) { n = AWAITING_REMOVAL.poll(); if (n instanceof Player) { DISCONNECTED_PLAYERS.add((Player) n); } else if (n instanceof NPC) { NPC npc = NPC_LOADER.save(n).clear(); if (npc != null) { NPCS.remove(npc); } } else if (n instanceof GameObject) { OBJECT_LOADER.save(n); } } for (Iterator<Player> it = DISCONNECTED_PLAYERS.iterator(); it.hasNext();) { Player p = it.next(); boolean isLobby = LOBBY_PLAYERS.get(p.getIndex()) == p; if (!isLobby && PLAYERS.get(p.getIndex()) != p) { PLAYER_NAME_MAP.remove("+lobby>" + p.getCredentials().getUsername()); PLAYER_NAME_MAP.remove(p.getCredentials().getUsername()); it.remove(); //Prevent random resets. continue; } Player player = PLAYER_LOADER.save(p); if (player == null) { //If the player isn't ready to be removed yet. continue; } if (isLobby) { LOBBY_PLAYERS.remove(player.clearLobby()); PLAYER_NAME_MAP.remove("+lobby>" + player.getCredentials().getUsername()); } if (PLAYERS.get(player.getIndex()) == player) { PLAYERS.remove(player.clear()); PLAYER_NAME_MAP.remove(player.getCredentials().getUsername()); System.out.println("Player " + player.getCredentials().getUsername() + " disconnected: [" + player.getIndex() + ", " + PLAYERS.size() + "]."); } it.remove(); } } catch (Throwable t) { t.printStackTrace(); } try { Thread.sleep(600); } catch (InterruptedException e) { e.printStackTrace(); } } }
However, it was ineffective . What should I do?
Your post is a little vague, you might want to add a few more details on the problem if you want someone to give you some accurate help
Not using Project Insanity, nor Hyperion or Apollo/anything released.
What info should I add? This is what I do for the dupe to happen:
Spawn 11694, save so my character file has it. Drop 11694, then log back in, plug out my router and plug it back in. In my inventory, I will have 11694, and the ground item manager also shows 11694 in a few ticks.
Is what is used to add the player to the list of online players, and remove them.Code:@Override public void run() { Thread.currentThread().setName("NodeWorker"); Node n = null; while (true) { try { while (!AWAITING_ADDING.isEmpty()) { n = AWAITING_ADDING.poll(); if (n instanceof Player) { try { Player player = PLAYER_LOADER.load(PLAYER_LOADER.checkLogin(n)); if (player != null) { if (player.getIOSession().isInLobby()) { LOBBY_PLAYERS.add(player); PLAYER_NAME_MAP.put("+lobby>" + player.getCredentials().getUsername(), player); } else { LOBBY_PLAYERS.remove(player); PLAYER_NAME_MAP.remove("+lobby>" + player.getCredentials().getUsername()); if (getPlayer(player.getCredentials().getUsername()) == null) { PLAYERS.add(player); PLAYER_NAME_MAP.put(player.getCredentials().getUsername(), player); } else { player.getIOSession().getChannel().disconnect(); continue; } } player.init(); System.out.println("Player " + player.getCredentials().getUsername() + " connected: [" + player.getIndex() + ", " + PLAYERS.size() + "]."); } } catch (Throwable t) { t.printStackTrace(); } } else if (n instanceof NPC) { NPC npc = NPC_LOADER.load(NPC_LOADER.checkLogin(n)); if (npc != null) { npc.init(); NPCS.add(npc); } } else if (n instanceof GameObject) { OBJECT_LOADER.load(OBJECT_LOADER.checkLogin(n)); } else { throw new IllegalStateException("Unsupported node - " + n.getClass().getSimpleName()); } } while (!AWAITING_REMOVAL.isEmpty()) { n = AWAITING_REMOVAL.poll(); if (n instanceof Player) { DISCONNECTED_PLAYERS.add((Player) n); } else if (n instanceof NPC) { NPC npc = NPC_LOADER.save(n).clear(); if (npc != null) { NPCS.remove(npc); } } else if (n instanceof GameObject) { OBJECT_LOADER.save(n); } } for (Iterator<Player> it = DISCONNECTED_PLAYERS.iterator(); it.hasNext();) { Player p = it.next(); boolean isLobby = LOBBY_PLAYERS.get(p.getIndex()) == p; if (!isLobby && PLAYERS.get(p.getIndex()) != p) { PLAYER_NAME_MAP.remove("+lobby>" + p.getCredentials().getUsername()); PLAYER_NAME_MAP.remove(p.getCredentials().getUsername()); it.remove(); //Prevent random resets. continue; } Player player = PLAYER_LOADER.save(p); if (player == null) { //If the player isn't ready to be removed yet. continue; } if (isLobby) { LOBBY_PLAYERS.remove(player.clearLobby()); PLAYER_NAME_MAP.remove("+lobby>" + player.getCredentials().getUsername()); } if (PLAYERS.get(player.getIndex()) == player) { PLAYERS.remove(player.clear()); PLAYER_NAME_MAP.remove(player.getCredentials().getUsername()); System.out.println("Player " + player.getCredentials().getUsername() + " disconnected: [" + player.getIndex() + ", " + PLAYERS.size() + "]."); } it.remove(); } } catch (Throwable t) { t.printStackTrace(); } try { Thread.sleep(600); } catch (InterruptedException e) { e.printStackTrace(); } } }
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |