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

Support for the latest build of L2J Server, get help here with installations, upgrades, problems.
Do not post bugs reports here, use viewforum.php?f=77 instead.
There is no support for other server builds than the official provided by l2jserver.com
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
felipipe
Posts: 29
Joined: Fri Apr 11, 2008 4:15 pm

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

Post 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. :-(                                            } 
User avatar
janiii
L2j Veteran
L2j Veteran
Posts: 4269
Joined: Wed May 28, 2008 3:15 pm
Location: Slovakia

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

Post 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..
You do not have the required permissions to view the files attached to this post.
DO NOT EVEN TRY TO MESS WITH ME!
forum flOOder dancing dEVILoper
I don't give private support - PM will be ignored!
toastgodsupreme
Posts: 750
Joined: Sun Dec 07, 2008 7:01 pm
Location: Poland

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

Post 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.
User avatar
Aikimaniac
L2j Inner Circle
L2j Inner Circle
Posts: 3048
Joined: Sun Aug 07, 2005 11:42 pm
Location: Slovakia

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

Post 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..
Image
felipipe
Posts: 29
Joined: Fri Apr 11, 2008 4:15 pm

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

Post 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;  
User avatar
janiii
L2j Veteran
L2j Veteran
Posts: 4269
Joined: Wed May 28, 2008 3:15 pm
Location: Slovakia

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

Post 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..
DO NOT EVEN TRY TO MESS WITH ME!
forum flOOder dancing dEVILoper
I don't give private support - PM will be ignored!
User avatar
janiii
L2j Veteran
L2j Veteran
Posts: 4269
Joined: Wed May 28, 2008 3:15 pm
Location: Slovakia

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

Post 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! :)
DO NOT EVEN TRY TO MESS WITH ME!
forum flOOder dancing dEVILoper
I don't give private support - PM will be ignored!
User avatar
janiii
L2j Veteran
L2j Veteran
Posts: 4269
Joined: Wed May 28, 2008 3:15 pm
Location: Slovakia

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

Post by janiii »

oh, it was already fixed by fordfrog :)
http://www.l2jserver.com/old-forum/thre ... adid=33609
DO NOT EVEN TRY TO MESS WITH ME!
forum flOOder dancing dEVILoper
I don't give private support - PM will be ignored!
felipipe
Posts: 29
Joined: Fri Apr 11, 2008 4:15 pm

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

Post by felipipe »

:!: :!: :D janiii problem solved thanks!
Post Reply