Page 2 of 3

Re: Multi skills bug

Posted: Sat Sep 11, 2010 9:32 am
by Naonah
Works fine (tested).

You forgot to import Thread.... :P

...so here corrected code:

Code: Select all

Index: java/com/l2jserver/gameserver/network/clientpackets/RequestRestart.java===================================================================--- java/com/l2jserver/gameserver/network/clientpackets/RequestRestart.java    (revision 4411)+++ java/com/l2jserver/gameserver/network/clientpackets/RequestRestart.java    (working copy)@@ -20,6 +20,7 @@  import com.l2jserver.Config; import com.l2jserver.gameserver.SevenSignsFestival;+import com.l2jserver.gameserver.ThreadPoolManager; import com.l2jserver.gameserver.model.L2Party; import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; import com.l2jserver.gameserver.network.L2GameClient;@@ -30,7 +31,6 @@ import com.l2jserver.gameserver.network.serverpackets.SystemMessage; import com.l2jserver.gameserver.taskmanager.AttackStanceTaskManager; - /**  * This class ...  *@@ -41,57 +41,57 @@     private static final String _C__46_REQUESTRESTART = "[C] 46 RequestRestart";     private static final Logger _log = Logger.getLogger(RequestRestart.class.getName());     protected static final Logger _logAccounting = Logger.getLogger("accounting");-+         @Override     protected void readImpl()     {         // trigger     }-+         @Override     protected void runImpl()     {         final L2PcInstance player = getClient().getActiveChar();-+                 if (player == null)             return;--        if(player.getActiveEnchantItem() != null || player.getActiveEnchantAttrItem() != null)+        +        if (player.getActiveEnchantItem() != null || player.getActiveEnchantAttrItem() != null)         {             sendPacket(RestartResponse.valueOf(false));             return;         }-+                 if (player.isLocked())         {             _log.warning("Player " + player.getName() + " tried to restart during class change.");             sendPacket(RestartResponse.valueOf(false));             return;         }-+                 if (player.getPrivateStoreType() != 0)         {             player.sendMessage("Cannot restart while trading");             sendPacket(RestartResponse.valueOf(false));             return;         }-+                 if (player.getActiveRequester() != null)         {             player.getActiveRequester().onTradeCancel(player);             player.onTradeCancel(player.getActiveRequester());         }-+                 if (AttackStanceTaskManager.getInstance().getAttackStanceTask(player) && !(player.isGM() && Config.GM_RESTART_FIGHTING))         {             if (Config.DEBUG)                 _log.fine("Player " + player.getName() + " tried to logout while fighting.");-+                         player.sendPacket(new SystemMessage(SystemMessageId.CANT_RESTART_WHILE_FIGHTING));             sendPacket(RestartResponse.valueOf(false));             return;         }-+                 // Prevent player from restarting if they are a festival participant         // and it is in progress, otherwise notify party members that the player         // is not longer a participant.@@ -103,9 +103,9 @@                 sendPacket(RestartResponse.valueOf(false));                 return;             }-+                         final L2Party playerParty = player.getParty();-+                         if (playerParty != null)                 player.getParty().broadcastToPartyMembers(SystemMessage.sendString(player.getName() + " has been removed from the upcoming festival."));         }@@ -113,29 +113,37 @@         player.removeFromBossZone();                  final L2GameClient client = getClient();-+                 LogRecord record = new LogRecord(Level.INFO, "Logged out");-        record.setParameters(new Object[]{client});+        record.setParameters(new Object[] { client });         _logAccounting.log(record);--        // detach the client from the char so that the connection isnt closed in the deleteMe-        player.setClient(null);--        player.logout();         -        getClient().setActiveChar(null);--        // return the client to the authed status-        client.setState(GameClientState.AUTHED);--        sendPacket(RestartResponse.valueOf(true));--        // send char list-        final CharSelectionInfo cl = new CharSelectionInfo(client.getAccountName(), client.getSessionId().playOkID1);-        sendPacket(cl);-        client.setCharSelection(cl.getCharInfo());+        ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()+        {+            +            @Override+            public void run()+            {+                // detach the client from the char so that the connection isnt closed in the deleteMe+                player.setClient(null);+                +                player.logout();+                +                getClient().setActiveChar(null);+                +                // return the client to the authed status+                client.setState(GameClientState.AUTHED);+                +                sendPacket(RestartResponse.valueOf(true));+                +                // send char list+                final CharSelectionInfo cl = new CharSelectionInfo(client.getAccountName(), client.getSessionId().playOkID1);+                sendPacket(cl);+                client.setCharSelection(cl.getCharInfo());+            }+        }, 5000);     }-+         /* (non-Javadoc)      * @see com.l2jserver.gameserver.clientpackets.ClientBasePacket#getType()      */@@ -144,4 +152,4 @@     {         return _C__46_REQUESTRESTART;     }-}\ No newline at end of file+} 
....but problem is not resolved.

These codes prevent you from restarting only so you can still exit without delay.

As topic owner wrote: this bug exists during exit, not relogging.

Re: Multi skills bug

Posted: Sat Sep 11, 2010 9:45 am
by JIV
dont do this, you could create exploit on your server. Also your revision 4411 is old, latest epilogue is 4413.

Re: Multi skills bug

Posted: Sat Sep 11, 2010 10:04 am
by SolidSnake
Naonah wrote:You forgot to import Thread.... :P
SolidSnake wrote:Add proper imports..
Thx for patch with imports :P

Anyway I made it only for Restart, but now you should just re-made it for Exit, too
Also you could create a new state (like isRestarting or isLeaving) and block any kind of exploitation

EDIT:
JIV wrote:Also your revision 4411 is old, latest epilogue is 4413.
http://trac.l2jserver.com/changeset/4412
http://trac.l2jserver.com/changeset/4413

Re: Multi skills bug

Posted: Sat Sep 11, 2010 10:22 am
by SolidSnake
Sorry for double posts, here a new patch

Code: Select all

Index: java/config/l2jmods.properties===================================================================--- java/config/l2jmods.properties   (revision 4413)+++ java/config/l2jmods.properties   (working copy)@@ -735,1 +735,46 @@# variables: $killer, $targetAnnouncePvpMsg = $killer has defeated $target-+-+# How many time the player must wait to exit server ?+# Default: 0+ExitDelay = 5000++# How many time the player must wait to restart client ?+# Default: 0+RestartDelay = 5000+# ---------------------------------------------------------------------------# Chat ModerationIndex: java/com/l2jserver/gameserver/network/clientpackets/Logout.java===================================================================--- java/com/l2jserver/gameserver/network/clientpackets/Logout.java   (revision 4413)+++ java/com/l2jserver/gameserver/network/clientpackets/Logout.java   (working copy)@@ -22,1 +22,52 @@import java.util.logging.Logger; import com.l2jserver.Config;import com.l2jserver.gameserver.SevenSignsFestival;+import com.l2jserver.gameserver.ThreadPoolManager;import com.l2jserver.gameserver.model.L2Party;import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;@@ -116,3 +116,30 @@        record.setParameters(new Object[]{this.getClient()});        _logAccounting.log(record);--       player.logout();++       int ExitDelay = (Config.EXIT_DELAY);+       ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()+       {+           @Override+           public void run()+           {+               player.logout();+           }+       }, ExitDelay);    }     /* (non-Javadoc)Index: java/com/l2jserver/gameserver/network/clientpackets/RequestRestart.java===================================================================--- java/com/l2jserver/gameserver/network/clientpackets/RequestRestart.java   (revision 4413)+++ java/com/l2jserver/gameserver/network/clientpackets/RequestRestart.java   (working copy)@@ -22,1 +22,52 @@import java.util.logging.Logger; import com.l2jserver.Config;import com.l2jserver.gameserver.SevenSignsFestival;+import com.l2jserver.gameserver.ThreadPoolManager;import com.l2jserver.gameserver.model.L2Party;import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;@@ -120,3 +120,30 @@        record.setParameters(new Object[]{client});        _logAccounting.log(record);-++       int RestartDelay = (Config.RESTART_DELAY);+       ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()+       {+           @Override+           public void run()+           {+               // detach the client from the char so that the connection isnt closed in the deleteMe+               player.setClient(null);++               player.logout();+               +               getClient().setActiveChar(null);++               // return the client to the authed status+               client.setState(GameClientState.AUTHED);++               sendPacket(RestartResponse.valueOf(true));++               // send char list+               final CharSelectionInfo cl = new CharSelectionInfo(client.getAccountName(), client.getSessionId().playOkID1);+               sendPacket(cl);+               client.setCharSelection(cl.getCharInfo());+           }+       }, RestartDelay);-       // detach the client from the char so that the connection isnt closed in the deleteMe-       player.setClient(null);--       player.logout();-       -       getClient().setActiveChar(null);--       // return the client to the authed status-       client.setState(GameClientState.AUTHED);--       sendPacket(RestartResponse.valueOf(true));--       // send char list-       final CharSelectionInfo cl = new CharSelectionInfo(client.getAccountName(), client.getSessionId().playOkID1);-       sendPacket(cl);-       client.setCharSelection(cl.getCharInfo());    }     /* (non-Javadoc)Index: java/com/l2jserver/Config.java===================================================================--- java/com/l2jserver/Config.java   (revision 4413)+++ java/com/l2jserver/Config.java   (working copy)@@ -801,2 +801,40 @@    public static String ANNOUNCE_PK_MSG;    public static String ANNOUNCE_PVP_MSG;+   public static int EXIT_DELAY;+   public static int RESTART_DELAY;    public static boolean L2JMOD_CHAT_ADMIN;    public static boolean L2JMOD_MULTILANG_ENABLE;@@ -2957,6 +2957,102 @@                    ANNOUNCE_PVP_MSG = L2JModSettings.getProperty("AnnouncePvpMsg", "$killer has defeated $target");+                   +                   EXIT_DELAY = Integer.parseInt(L2JModSettings.getProperty("ExitDelay", "0"));+                   RESTART_DELAY = Integer.parseInt(L2JModSettings.getProperty("RestartDelay", "0"));                                        L2JMOD_CHAT_ADMIN = Boolean.parseBoolean(L2JModSettings.getProperty("ChatAdmin", "false"));                    
Imports added! BE WARNED: it isn't tested! Try it leaving server..

EDIT: Update 2 -> Added configs
EDIT: Update 3 -> Added ')' at Config.java lines (thx to angkor's report)

Re: Multi skills bug

Posted: Sat Sep 11, 2010 10:42 am
by angkor
thx very match
I try last patch and answer in this topic.

Re: Multi skills bug

Posted: Sat Sep 11, 2010 11:10 am
by SolidSnake
Updated patch with config

I advice you to set restart and exit delay 1000 (1 second), so there aren't too many chances of exploitation

Also you should try to class the character in that second, so if the problem persists, I'll post a new patch with solution :D

Re: Multi skills bug

Posted: Sat Sep 11, 2010 11:32 am
by angkor
I test this patch
work fine

But if you have pressed restart and then any other action before exit game, at next start game you can't move.

Re: Multi skills bug

Posted: Sat Sep 11, 2010 11:40 am
by SolidSnake
Set 1000 (1 second) to limit every action during restart/exit, then when you return in game click on your stats' panel, so try to move your character..

Re: Multi skills bug

Posted: Sat Sep 11, 2010 11:50 am
by angkor
I set logout and restart 1 sec, but i do any action and dont move return in game, i click on my stats panel, bun dont move, i try scroll of escape and i move.

Re: Multi skills bug

Posted: Sat Sep 11, 2010 11:52 am
by Naonah
SolidSnake's patch is very good.

In my opinion it should be commited to l2jserver repo.

@angkor: use arrows on keyboard to move then use a mouse click normaly

Re: Multi skills bug

Posted: Sat Sep 11, 2010 12:03 pm
by SolidSnake
It can be committed with a l2j core developer's revision :P

Re: Multi skills bug

Posted: Sat Sep 11, 2010 1:44 pm
by Naonah
SolidSnake wrote:It can be committed with a l2j core developer's revision :P
sry for off topic but their SVN is not a password protected? :D

Re: Multi skills bug

Posted: Sat Sep 11, 2010 2:12 pm
by SolidSnake
Yes, but I mean that the patch could be committed with a code revision of a developer to make it better :)

Re: Multi skills bug

Posted: Sat Sep 11, 2010 2:54 pm
by Naonah
SolidSnake wrote:Yes, but I mean that the patch could be committed with a code revision of a developer to make it better :)
I meant the same :)

Re: Multi skills bug

Posted: Sat Sep 11, 2010 3:32 pm
by SolidSnake
Naonah wrote:
SolidSnake wrote:It can be committed with a l2j core developer's revision :P
sry for off topic but their SVN is not a password protected? :D
I had understood that you had understood I meant revision (4416), not revised version of the code :mrgreen: