Page 1 of 1

L2CharTemplate

Posted: Mon Aug 13, 2012 5:59 pm
by vampir
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?

Re: L2CharTemplate

Posted: Tue Aug 14, 2012 5:51 pm
by UnAfraid
They are sharing just a reference of this object not a copy for each npc :)

Re: L2CharTemplate

Posted: Tue Aug 14, 2012 8:32 pm
by vampir
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 :P

Re: L2CharTemplate

Posted: Tue Aug 14, 2012 9:50 pm
by UnAfraid
Do u have better approach in mind?
I doubt cleaning L2CharTemplate will decrease memory consummation (well at least noticeable).

Re: L2CharTemplate

Posted: Wed Aug 15, 2012 3:41 pm
by vampir
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.

Re: L2CharTemplate

Posted: Wed Aug 15, 2012 7:14 pm
by powerful0guardian
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 {... 

Re: L2CharTemplate

Posted: Wed Aug 15, 2012 11:45 pm
by UnAfraid
Yes but that is kinda pointless we gain nothing from such rework..

Re: L2CharTemplate

Posted: Fri Aug 17, 2012 5:36 am
by Ahmed
UnAfraid wrote:Yes but that is kinda pointless we gain nothing from such rework..
I just read this and I agree w/ UnAfraid.

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)

Re: L2CharTemplate

Posted: Fri Aug 17, 2012 10:52 am
by vampir
i will do that and post the results, thx :)

Re: L2CharTemplate

Posted: Fri Aug 17, 2012 2:11 pm
by vampir
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 :P

Re: L2CharTemplate

Posted: Fri Aug 17, 2012 4:40 pm
by Ahmed
vampir wrote: i learned something :P
And that's the most important thing :)!

Re: L2CharTemplate

Posted: Fri Aug 17, 2012 6:03 pm
by Zoey76
Ahmed wrote:
UnAfraid wrote:Yes but that is kinda pointless we gain nothing from such rework..
I just read this and I agree w/ UnAfraid.

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)
LOL@something completely retarded and redundant i.e math equations :lol:

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.