L2CharTemplate
Forum rules
READ NOW: L2j Forums Rules of Conduct
READ NOW: L2j Forums Rules of Conduct
-
- Posts: 113
- Joined: Sun Mar 28, 2010 6:17 pm
L2CharTemplate
Hi, i can see that EVERY template extends L2CharTemplate so we have got a looot of references of this class but for static Npc(standing in town and doing nothing) almost every variable in this class is useless. In NpcInfo we are sending some variables but still most of the variables in L2CharTemplate are just useless and take memory, why dont u make new Template for those objects?
- UnAfraid
- L2j Veteran
- Posts: 4199
- Joined: Mon Jul 23, 2007 4:25 pm
- Location: Bulgaria
- Contact:
-
- Posts: 113
- Joined: Sun Mar 28, 2010 6:17 pm
Re: L2CharTemplate
yeah i know, there is 1 template for each Id, so like 10000 templates are created or something like that, still a lot of them are useless
- UnAfraid
- L2j Veteran
- Posts: 4199
- Joined: Mon Jul 23, 2007 4:25 pm
- Location: Bulgaria
- Contact:
Re: L2CharTemplate
Do u have better approach in mind?
I doubt cleaning L2CharTemplate will decrease memory consummation (well at least noticeable).
I doubt cleaning L2CharTemplate will decrease memory consummation (well at least noticeable).
-
- Posts: 113
- Joined: Sun Mar 28, 2010 6:17 pm
Re: L2CharTemplate
I have, for sure its minimal optimalization but it can be done.
The thing is, there isnt much sense to do it if NPCs will be still in sql files. We can create only 1 template(not 3000 or something) for Npc that arent doing actions like taking damage etc(so spd, defense, hp etc can be static variable). If those variables would be static, we could clean most of the variables stored atm in npc.sql coz they wouldnt be needed anymore.
The thing is, there isnt much sense to do it if NPCs will be still in sql files. We can create only 1 template(not 3000 or something) for Npc that arent doing actions like taking damage etc(so spd, defense, hp etc can be static variable). If those variables would be static, we could clean most of the variables stored atm in npc.sql coz they wouldnt be needed anymore.
-
- Posts: 63
- Joined: Tue Jun 26, 2012 11:16 am
Re: L2CharTemplate
or can we simply make a class called L2TXTemplate (abstract or interface) and it would contains the stuffs and L2NpcTemplate would be extends on it and L2CharTemplate would be too.. like
Code: Select all
public interface or abstract class L2XTemplate { public int getFoo(); ...}
Code: Select all
public final class L2NpcTemplate extends L2XTemplate {...
Code: Select all
public final class L2CharTemplate extends L2XTemplate {...
Last edited by powerful0guardian on Thu Aug 16, 2012 8:49 am, edited 1 time in total.
- UnAfraid
- L2j Veteran
- Posts: 4199
- Joined: Mon Jul 23, 2007 4:25 pm
- Location: Bulgaria
- Contact:
-
- L2j Veteran
- Posts: 64
- Joined: Fri Jan 04, 2008 2:13 pm
- Location: USA
Re: L2CharTemplate
I just read this and I agree w/ UnAfraid.UnAfraid wrote:Yes but that is kinda pointless we gain nothing from such rework..
Can you point out the advantages to this? Java is a very object oriented language...
Try a little test if you are thinking about something like this... create some dummy project in eclipse (or w/e your preference), make a "template" class and make the 2 classes that extend it. make each method do something completely retarded and redundant (i.e math equations, for loops, if/else, switch, etc). put some time stamps, memory usage, etc. then try it with the method we use now and if there's a difference i'd be very interested to see the results (If you want me to clear any of this up pm me and we'll walk through it since my explanation is very vauge)
-
- Posts: 113
- Joined: Sun Mar 28, 2010 6:17 pm
Re: L2CharTemplate
i will do that and post the results, thx
-
- Posts: 113
- Joined: Sun Mar 28, 2010 6:17 pm
Re: L2CharTemplate
nah its not worth it, when i was thinking about this, i thought that i would remove template for those npcs but its not possible since i was all the time looking at charTemplate and not at NpcTemplate where those things are stored. So the only advantage of that would be removing few variables from each Template of npc that is doing nothing and i wanted to remove whole object at start thx anyway, i learned something
-
- L2j Veteran
- Posts: 64
- Joined: Fri Jan 04, 2008 2:13 pm
- Location: USA
- Zoey76
- L2j Inner Circle
- Posts: 7005
- Joined: Tue Aug 11, 2009 3:36 am
Re: L2CharTemplate
LOL@something completely retarded and redundant i.e math equationsAhmed wrote:I just read this and I agree w/ UnAfraid.UnAfraid wrote:Yes but that is kinda pointless we gain nothing from such rework..
Can you point out the advantages to this? Java is a very object oriented language...
Try a little test if you are thinking about something like this... create some dummy project in eclipse (or w/e your preference), make a "template" class and make the 2 classes that extend it. make each method do something completely retarded and redundant (i.e math equations, for loops, if/else, switch, etc). put some time stamps, memory usage, etc. then try it with the method we use now and if there's a difference i'd be very interested to see the results (If you want me to clear any of this up pm me and we'll walk through it since my explanation is very vauge)
By the way as vampir already verified, it doesn't increase performance and implementing interfaces is actually slower than extending abstract classes.
Also making some data static (hardcoded) reduce customization and makes updates and future changes harder to implement.
Powered by Eclipse 4.30 | Eclipse Temurin 21 | MariaDB 11.3.2 | L2J Server 2.6.3.0 - High Five
Join our Discord!
Join our Discord!