Jump to content

Recommended Posts

Posted (edited)

Nice idea!

 

BUT the implementation is not that nice..

Why didn't u wrote that as a DP sided script..

Also u're using thread-safe classes where u don't need to, and not thread-safe where u had to..

Using public variables to access from outside and methods to access inner vars is not so nice either.

Btw we use to add '_' (underscore) prefix to global variables not to local ones so you don't have to use explicit 'this.var = var'

Also we stopped using e.printStackTrace() because in windows it doesn't gets logged on log files, we use Logger for that (Same goes for System.out.println())

(new Thread(new RankPvpSystemPvpTask(player, target))).start();

 Why don't u simply use that instead.

ThreadPoolManager.getInstance().executeTask(new RankPvpSystemPvpTask(player, target));

It also executes the task in another thread without having to create new thread because there is already created a pool of threads used by the whole server.

 

Actually the code is really messed up (That's what we call spaghetti  code) that's why u have 20 pages of typo reports, i think u should start writing a bit more cleaner & safe.

Here i attach similar script i started some time ago, it doesn't supports most of the things u did but count it as an example of how i write things.

Note: This is an alpha version, totally not ready for use version, it may work but it still needs work to be done to consider it as a final version.

PvP.zip

Edited by UnAfraid
Posted (edited)

Thanks for this post UnAfraid, but like i sad some time ago i still learn java. I will try apply your clues in my system ;)

 

 

Why didn't u wrote that as a DP sided script

It is better for debug for me if it is in Core packages.

 

 

Also u're using thread-safe classes where u don't need to, and not thread-safe where u had to..

So where i should use thread-safe?

 

 

Using public variables to access from outside and methods to access inner vars is not so nice either.

I use that public variable only in L2PcInstance, reason: I don't want change original code too much (adding getter and setter will add too much code)

 

I use inner methods for obtain inner fields, because i think it's look better, and cleaner :)



_killersList.add(killer);
// or
getKillerList().add(killer);

...but now i think the first line looks better than third line.

 

 

 

ThreadPoolManager.getInstance().executeTask(new RankPvpSystemPvpTask(player, target));

It is applied right now.

 

About _ (underscore), yes i know this rule ;) but some code is auto-generated in eclipse, so mostly i don't look into this methods.

 

About e.printStackTrace(), it will be changed for Logger.

 

 

 

that's why u have 20 pages of typo reports,

Can you explain what do you mean?

 

 

i think u should start writing a bit more cleaner & safe

What mean safe?

 

 

Finally, thanks for check my work. I am really glad :)

Edited by matthewmaster04
Posted (edited)

Every time u need some Map/List which will be used only once to add and then only to read doesn't have to be FastMap/FastList (Javolution) they are thread-safe use HashMap (When order is not important LinkedHashMap when u need insert order) and ArrayList.

 

In case you have to use a Map/List to add/remove entries during run-time then u have to use thread-safe Map/List i'd rather use ConcurrentHashMap/CopyOnWriteArrayList (In case when insert order matters only then FastMap)

 

If you like to leave little fingerprints over the source i'd implement some event listeners.

With that you can create some interface bridge between your engine and every other l2j based server.

 

Debugging is easy within Core or DP it doesn't really matters eclipse's debugger works well on both sides equally.

Edited by UnAfraid
Posted (edited)

So in this case, standard Map/List will be correct and i can remove FastMap from this pack, i think.

 

ConcurrentHashMap & CopyOnWriteArrayList can be useful but now i am little confused what will be better for me (i need more knowledge).

 

Anyway thanks for help ;)

Edited by matthewmaster04
Posted (edited)

Codding safer means you should make sure your code is not going to cause any problems like exceptions (Mostly nulls), exploits..  as you write it.

Edited by UnAfraid
Posted (edited)

U also could do that 

for (Entry<Integer, KillerPvpStats> entry = getKillerPvpTable().entrySet())

instead of 

for (FastMap.Entry<Integer, KillerPvpStats> e = getKillerPvpTable().head(), end = getKillerPvpTable().tail(); (e = e.getNext()) != end;)

It looks way more cleaner and understandable also when u change the underlying implementation you'll not have to worry about rewriting all the loops u did in that way.

 

Also i'd use a bit more java 7 features like the ARM (Auto resource management), mostly for database queries look at current l2j sources to see how we handled them

Edited by UnAfraid
Posted (edited)

Thanks again, i will apply it in next rev. ;)

 

It should be like:

for (Map.Entry<Integer, Rank> e : rankList.entrySet())

And btw, is exist a Map what allows you add value on selected position?

Example:



_map.insert(position, key, value);
Edited by matthewmaster04
Posted

 

Thanks again, i will apply it in next rev. ;)

 

It should be like:

for (Map.Entry<Integer, Rank> e : rankList.entrySet())

And btw, is exist a Map what allows you add value on selected position?

Example:



_map.insert(position, key, value);

No, you must use comparator.

  • 2 weeks later...
Posted

i suggest you create one more file to show diffs in eclipse so ppl dont have to remove and re-add patches ;) ofc if you have time for that is just a suggestion ;) btw is one of the best features here!

Posted

i have a problem  

 

Buildfile: C:\workspace\L2J_Server\build.xml
checkRequirements:
getChangelogDateVersion:
     [exec] Result: 1
     [exec] Result: 1
init:
   [delete] Deleting directory C:\workspace\L2J_Server\build\bin
    [mkdir] Created dir: C:\workspace\L2J_Server\build\bin
dist:
     [sync] Removed 2 dangling files from C:\workspace\L2J_Server\build\dist
compile:
    [javac] Compiling 1692 source files to C:\workspace\L2J_Server\build\bin
    [javac] C:\workspace\L2J_Server\java\com\l2jserver\gameserver\handler\UserCommandHandler.java:24: error: cannot find symbol
    [javac] import com.l2jserver.gameserver.masteriopack.rankpvpsystem.IUserCommandHandlerPvpInfo;
    [javac]                                                           ^
    [javac]   symbol:   class IUserCommandHandlerPvpInfo
    [javac]   location: package com.l2jserver.gameserver.masteriopack.rankpvpsystem
    [javac] C:\workspace\L2J_Server\java\com\l2jserver\gameserver\handler\VoicedCommandHandler.java:24: error: cannot find symbol
    [javac] import com.l2jserver.gameserver.masteriopack.rankpvpsystem.IVoicedCommandHandlerPvpInfo;
    [javac]                                                           ^
    [javac]   symbol:   class IVoicedCommandHandlerPvpInfo
    [javac]   location: package com.l2jserver.gameserver.masteriopack.rankpvpsystem
    [javac] C:\workspace\L2J_Server\java\com\l2jserver\gameserver\GameServer.java:317: error: load() has private access in ServerSideImage
    [javac] ServerSideImage.getInstance().load();
    [javac]                             ^
    [javac] C:\workspace\L2J_Server\java\com\l2jserver\gameserver\handler\UserCommandHandler.java:41: error: cannot find symbol
    [javac] registerHandler(new IUserCommandHandlerPvpInfo());
    [javac]                    ^
    [javac]   symbol:   class IUserCommandHandlerPvpInfo
    [javac]   location: class UserCommandHandler
    [javac] C:\workspace\L2J_Server\java\com\l2jserver\gameserver\handler\VoicedCommandHandler.java:41: error: cannot find symbol
    [javac] registerHandler(new IVoicedCommandHandlerPvpInfo());
    [javac]                    ^
    [javac]   symbol:   class IVoicedCommandHandlerPvpInfo
    [javac]   location: class VoicedCommandHandler
    [javac] 5 errors
 
BUILD FAILED
C:\workspace\L2J_Server\build.xml:64: Compile failed; see the compiler error output for details.
 
Total time: 7 seconds
Posted (edited)

marik20001

Probably you try add this diff files into lower chronicle than H5 or other l2jserver.

 

You should check methods names and parameters what are overrided in command handlers.

 

IUserCommandHandlerPvpInfo should be correctly implemented from IUserCommandHandler interface.

 

valanths1990

You can restore the oryginal class from repo and then apply my patch. THat way is faster i think. (BTW I am too lazy ... ;))

Edited by >Masterio<
Posted (edited)

I will apply concurrent hashmap. do not download 3.7.5, new revision today.

 

PS. I will fit this code when I will finish H5 version. (soon)

Edited by >Masterio<
Guest
This topic is now closed to further replies.



×
×
  • Create New...