L2CharTemplate

This is not a Support area! Discuss about the Server here. Non-Server related discussion goes in Off-Topic Discussion.
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
vampir
Posts: 113
Joined: Sun Mar 28, 2010 6:17 pm

L2CharTemplate

Post 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?
User avatar
UnAfraid
L2j Veteran
L2j Veteran
Posts: 4199
Joined: Mon Jul 23, 2007 4:25 pm
Location: Bulgaria
Contact:

Re: L2CharTemplate

Post by UnAfraid »

They are sharing just a reference of this object not a copy for each npc :)
Image
vampir
Posts: 113
Joined: Sun Mar 28, 2010 6:17 pm

Re: L2CharTemplate

Post 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
User avatar
UnAfraid
L2j Veteran
L2j Veteran
Posts: 4199
Joined: Mon Jul 23, 2007 4:25 pm
Location: Bulgaria
Contact:

Re: L2CharTemplate

Post by UnAfraid »

Do u have better approach in mind?
I doubt cleaning L2CharTemplate will decrease memory consummation (well at least noticeable).
Image
vampir
Posts: 113
Joined: Sun Mar 28, 2010 6:17 pm

Re: L2CharTemplate

Post 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.
powerful0guardian
Posts: 63
Joined: Tue Jun 26, 2012 11:16 am

Re: L2CharTemplate

Post 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 {... 
Last edited by powerful0guardian on Thu Aug 16, 2012 8:49 am, edited 1 time in total.
User avatar
UnAfraid
L2j Veteran
L2j Veteran
Posts: 4199
Joined: Mon Jul 23, 2007 4:25 pm
Location: Bulgaria
Contact:

Re: L2CharTemplate

Post by UnAfraid »

Yes but that is kinda pointless we gain nothing from such rework..
Image
Ahmed
L2j Veteran
L2j Veteran
Posts: 64
Joined: Fri Jan 04, 2008 2:13 pm
Location: USA

Re: L2CharTemplate

Post 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)
Image
vampir
Posts: 113
Joined: Sun Mar 28, 2010 6:17 pm

Re: L2CharTemplate

Post by vampir »

i will do that and post the results, thx :)
vampir
Posts: 113
Joined: Sun Mar 28, 2010 6:17 pm

Re: L2CharTemplate

Post 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
Ahmed
L2j Veteran
L2j Veteran
Posts: 64
Joined: Fri Jan 04, 2008 2:13 pm
Location: USA

Re: L2CharTemplate

Post by Ahmed »

vampir wrote: i learned something :P
And that's the most important thing :)!
Image
User avatar
Zoey76
L2j Inner Circle
L2j Inner Circle
Posts: 7005
Joined: Tue Aug 11, 2009 3:36 am

Re: L2CharTemplate

Post 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.
Powered by Eclipse 4.30 🌌 | Eclipse Temurin 21 ☕ | MariaDB 11.3.2 🗃️ | L2J Server 2.6.3.0 - High Five 🚀

🔗 Join our Discord! 🎮💬
Post Reply