Page 1 of 1

The castles do not get adena by Tax's concept.

Posted: Tue Apr 28, 2009 4:48 pm
by felipipe
If you want to receive support we need this info to help you properly.
» Find Revision
L2J Revision Number:2939
L2JDP Revision Number:5986

Problem bases: The castles do not get adena by Tax's concept.

Problem in MerchantPriceConfigTable.java

When it loads the instance, it does not solve the object castle

Code: Select all

 node = n.getAttributes().getNamedItem("castleId");            if (node != null)            {                castleId = Integer.parseInt(node.getNodeValue());                castle = CastleManager.getInstance().getCastleById(castleId);                                //*****Castle is null All the time. :-(                                            } 

Re: The castles do not get adena by Tax's concept.

Posted: Tue Apr 28, 2009 9:19 pm
by janiii
there is problem when loading all the managers, they call each other also when not all data is loaded..

following scenario is now:
- start initialize MerchantPriceConfigTable (create instance when loaded data)
- start initialize CastleManager (create instance and then load data)
- CastleManager creates an static instance
- CastleManager starts to load data => when calling get instance on CastleManager, the instance is already existent, but the data is not loaded yet!!
- when loading the data (creating castle objects), other managers are called..
- start initializing FortManager
- L2CastleZone.getCastle calls getInstance on CastleManager (castle data still in progress of loading!! we are in the contructor of the castle object which is then stored in CastleManager!)
- MerchantPriceConfigTable.parseMerchantPriceConfig calls getInstance on CastleManager (getting null object from the castle map, as we are creating the first castle object now!)
- L2CastleZone.getCastle calling getInstance on CastleManager..
- start initialize MerchantPriceConfigTable (calling this again, as we are still in the constructor of it and the instance isn't existent yet!! so loading the data when loading it already)
- end initialize MerchantPriceConfigTable
- ...end initializing FortManager
- L2CastleZone.getCastle calling getInstance on CastleManager..
- ...end initializing CastleManager
- MerchantPriceConfigTable.parseMerchantPriceConfig calling again as he is also not finished yet with loading the data (was called before CastleManager initialization)


so.. it's really chaotic. other code calling the instances before the data is even loaded and making own data on this empty manager instances..

giving the loading of data into the constructors (avoiding that instance is created but data not loaded) creates deadlocks.. they are way too many dependencies between the managers and the data which is loaded and object that created. manager loads data, creates objects, the objects call other managers which create other objects calling the same manager they came originaly from..


//attachment with log, where the start and end of some managers is logged and also the calling of getInstance of CastleManager and MerchantPriceConfigTable
//end of the initialization would mean, that the data is fully loaded. when there is a call to instance before data is loaded, that is bad..

Re: The castles do not get adena by Tax's concept.

Posted: Wed Apr 29, 2009 1:31 am
by toastgodsupreme
since we're on the topic of castles and taxes, we should look at l2jfree's implementation where items purchased by GMs do not give the tax to the castle owner. just one more thing we're missing.

Re: The castles do not get adena by Tax's concept.

Posted: Wed Apr 29, 2009 5:59 am
by Aikimaniac
i think the primary issue is that castle owners dont get adenas from taxes...when you have taxes 0 or 15..price in shops is the same..

Re: The castles do not get adena by Tax's concept.

Posted: Wed Apr 29, 2009 7:12 am
by felipipe
The problem this one that when the instance MerchantPriceConfigTable loads when the server up, does not load the objects "castle" (is null), since the instance CastleManager even has not taken the values of the database. This provokes that the variable: castleTaxRate always it is 0.0 in RequestBuyItem.java.

Code: Select all

 double castleTaxRate = 0;        double baseTaxRate = 0;        if (merchant != null)         {            castleTaxRate = merchant.getMpc().getCastleTaxRate(); // **** all the time value 0.0 ****            baseTaxRate = merchant.getMpc().getBaseTaxRate(); // value ok        }        long subTotal = 0;        int castleTax = 0;        int baseTax = 0;  

Re: The castles do not get adena by Tax's concept.

Posted: Wed Apr 29, 2009 8:07 am
by janiii
merchantpricetable is loaded more than once. the first time, castle data is not yet loaded, so the mpc property contains null castle info.
when the merchantpricedatatable is loaded second time, the list of mpc gets new mpc objects, so if in the mean time the L2MerchantInstance got mpc from it, it has the old reference to the null castle mpc and not to the secondly loaded. mpc property is loaded when a L2MerchantInstance is spawned in the onSpawn method.
so if there would be no spawns of merchant before the CastleManager loaded the castles and after that the MerchantPriceDatatable reinitialized its castle info, and ONLY AFTER THAT the L2MerchantInstance would be spawned (already with correct castle and mpc data), than it would be fine.

FortManager is creating new Fort object which then are initializing npcs calling SpawnTable instance which creates npc and spawns them (e.g. L2ChamberlainInstance) and they are got spawned... before all other data is even loaded..

Re: The castles do not get adena by Tax's concept.

Posted: Wed Apr 29, 2009 2:59 pm
by janiii
i am not sure, if i have the correct test scenario, so pls correct me:
1. e.g. trying revision 2876/5890
2. created clan, assigned me as CL, given Giran castle to my clan
3. go to giran grocery, see how much Spirit Ore and Gemstone D is worth
4. go to Giran Castle Chamberlain NPC, changed tax to 15%
5. go to giran grocery, see how much spirit ore and gemstone d is worth now with 15%

-> my conslusion from revision 2876/5890 with this scenario is, that both prices are equal.. this would mean that already on that revision the tax problem was existing, or? if my test scenario is right..

i don't have now time to test different revision, i will come back in 1 week.. :( GL guys! :)

Re: The castles do not get adena by Tax's concept.

Posted: Wed Apr 29, 2009 7:08 pm
by janiii
oh, it was already fixed by fordfrog :)
http://www.l2jserver.com/old-forum/thre ... adid=33609

Re: The castles do not get adena by Tax's concept.

Posted: Wed Apr 29, 2009 9:32 pm
by felipipe
:!: :!: :D janiii problem solved thanks!