A Project for Chronicle 4 based on L2JServer.


    Error on calculate delay of ClanHall startRentTask

    Share

    Flopix

    Posts : 10
    Join date : 2014-02-28

    Error on calculate delay of ClanHall startRentTask

    Post  Flopix on 3rd December 2015, 12:43

    ClanHall.java
    Code:

        private void startRentTask(boolean forced)
        {
            long currentTime = System.currentTimeMillis();
            if (_paidUntil > currentTime)
                ThreadPoolManager.getInstance().scheduleGeneral(new RentTask(), _paidUntil-currentTime);
            else if (!_paid && !forced)
            {
                if (System.currentTimeMillis()+(1000*60*60*24) <= _paidUntil+_chRate)
                    ThreadPoolManager.getInstance().scheduleGeneral(new RentTask(), System.currentTimeMillis()+(1000*60*60*24));
                else
                    ThreadPoolManager.getInstance().scheduleGeneral(new RentTask(), (_paidUntil+_chRate)-System.currentTimeMillis());
            }
            else
                new RentTask().run();
        }

                   ThreadPoolManager.getInstance().scheduleGeneral(new RentTask(), System.currentTimeMillis()+(1000*60*60*24));

    Delay of 46 years + 1 day? Smile
    avatar
    DnR
    Admin
    Admin

    Posts : 1027
    Join date : 2012-12-03

    Re: Error on calculate delay of ClanHall startRentTask

    Post  DnR on 5th December 2015, 11:15

    Actually, 1000 * 60 * 60 * 24 equals to 86.400.000 milliseconds, which equals to 1 day.
    I don't get the "46 years" part. Perhaps, you have misunderstood the code.
    Thanks. ^^

    Flopix

    Posts : 10
    Join date : 2014-02-28

    Re: Error on calculate delay of ClanHall startRentTask

    Post  Flopix on 5th December 2015, 11:49

    DnR wrote:Actually, 1000 * 60 * 60 * 24 equals to 86.400.000 milliseconds, which equals to 1 day.
    I don't get the "46 years" part. Perhaps, you have misunderstood the code.
    Thanks. ^^


    86.400.000 milliseconds + System.currentTimeMillis() = 86.400.000 + 1.449.308.930.000 milliseconds = ...


    Function scheduleGeneral require delay in ms, not end time.
    avatar
    DnR
    Admin
    Admin

    Posts : 1027
    Join date : 2012-12-03

    Re: Error on calculate delay of ClanHall startRentTask

    Post  DnR on 5th December 2015, 16:24

    You are right. I was careless and hadn't noticed current time in millis was included in thread delay.
    This was an implementation of L2JServer, and as i can see, it took them almost a dozen of years to update the code.
    Thanks for reporting. ^^

    Sponsored content

    Re: Error on calculate delay of ClanHall startRentTask

    Post  Sponsored content


      Current date/time is 22nd November 2017, 05:50