Is this the best way?

07/06/2011 13:47 Yaksha#16
Quote:
Originally Posted by Lateralus View Post
In my proxy, I use class Hero to describe MY character, and class Player to describe other players. Just saying.
Why have 2 classes that do the same thing?
07/06/2011 14:19 Lateralus#17
Quote:
Originally Posted by Yaksha View Post
Why have 2 classes that do the same thing?
They don't do the same thing, not nearly. The packet that initializes your character and other characters are different, plus there are more fields in my character (such as thread controllers), that aren't needed in other players. Remember - this is for a proxy. In a server, yeah, all characters should have the same specifications.
07/06/2011 20:34 -Shunsui-#18
Quote:
Originally Posted by Kiyono View Post
Or people just like using Hero, really you don't have the right to decide what people call things in their source.
owned, and yea i like using Hero, i'm in no way following TQ,
07/06/2011 21:26 Santa#19
I personally use "Whore." I only do this so I can go "Whore.Money -= XX" xD
07/06/2011 21:41 _tao4229_#20
On fucking topic:

No, this is extremely inefficient.
No need to sort the list to get the max battle power (that's a lot more (n/logn times as many comparisons needed)) even if you do it that way.
07/06/2011 21:53 pro4never#21
Personally I just love whoever wrote the class names for CoEmu ISMA.

It has all sorts of handy class names like the "IMMASOCKET" class.


It brings untold joy to my heart looking through that source finding all the fun class names.
07/06/2011 23:02 Lateralus#22
Quote:
Originally Posted by _tao4229_ View Post
On fucking topic:

No, this is extremely inefficient.
No need to sort the list to get the max battle power (that's a lot more (n/logn times as many comparisons needed)) even if you do it that way.
He needs to put a loop with try/catch blocks in its scope, throw the exception inside, and do a bubblesort on the list in the catch block. That's just how I'd do it.

Seriously though, to add on what other people's advice - if you're going to do thread-safe adds in a dictionary and using .NET framework 4.0, may I suggest using the ConcurrentDictionary type?
07/06/2011 23:33 Korvacs#23
Quote:
Originally Posted by Lateralus View Post
He needs to put a loop with try/catch blocks in its scope, throw the exception inside, and do a bubblesort on the list in the catch block. That's just how I'd do it.

Seriously though, to add on what other people's advice - if you're going to do thread-safe adds in a dictionary and using .NET framework 4.0, may I suggest using the ConcurrentDictionary type?
Very much agreed, been using them for a while :D
07/07/2011 00:49 { Angelius }#24
Quote:
Originally Posted by Lateralus View Post
He needs to put a loop with try/catch blocks in its scope, throw the exception inside, and do a bubblesort on the list in the catch block. That's just how I'd do it.

Seriously though, to add on what other people's advice - if you're going to do thread-safe adds in a dictionary and using .NET framework 4.0, may I suggest using the ConcurrentDictionary type?
why do you need a try/catch blocks as long as there is no way the void well throw an exception ?

Quote:
if (Client.Team == null) { return 0;} int bp = 0;
foreach (Character C in ThreadSafeDictionary(Client.Team).values)
if (C.BattlePower > bp) { bp = C.BattlePower; }
return bp;
i know you said thats how (YOU) do it but... i wold like to know how is it gonna return any errors and why does it need a try/catch blocks and how can it be easier than that and why do you need to sort such dictionary that contains less than 6 items ?
07/07/2011 01:32 12tails#25
why not simply do inside the team ...

public ushort BP = 0;

//shall use it when a new mem is added
public void NewMate_CHK(MemberInfo Mem)
{
//check the clan
//if he/she belongs to the same clan then
if(BP < Mem.Info.BP)
BP = Mem.Info.BP * 0.xxxx; //or w/e the calc is

//them send to the team membs the new potency value...
}

//shall use this when a player logout or just leave the team...
public void CHK_WholeLogOut()
{
BP = 0;
foreach(MemberInfo m in members.values)
//check if he/she belongs to clan... if not ... then just pass it with continue;... else
if(BP < Mem.Info.BP)
BP = Mem.Info.BP * 0.xxxx; //or w/e the calc is

//them send to the team membs the new potency value...
}
07/07/2011 01:49 marlyandedsel#26
Quote:
Originally Posted by 12tails View Post
why not simply do inside the team ...

public ushort BP = 0;

//shall use it when a new mem is added
public void NewMate_CHK(MemberInfo Mem)
{
//check the clan
//if he/she belongs to the same clan then
if(BP < Mem.Info.BP)
BP = Mem.Info.BP * 0.xxxx; //or w/e the calc is

//them send to the team membs the new potency value...
}

//shall use this when a player logout or just leave the team...
public void CHK_WholeLogOut()
{
BP = 0;
foreach(MemberInfo m in members.values)
//check if he/she belongs to clan... if not ... then just pass it with continue;... else
if(BP < Mem.Info.BP)
BP = Mem.Info.BP * 0.xxxx; //or w/e the calc is

//them send to the team membs the new potency value...
}
Inside the team? is it inside the team packet?
or when creating the team, team leader BP is the base for sharing to the team.member with appropriate calculation of BP sharing. Or searching the Highest BP within the Team.Leader and Team.Member and make it as the base for sharing BP. is it correct?
07/07/2011 06:07 Lateralus#27
Quote:
Originally Posted by { Angelius } View Post
why do you need a try/catch blocks as long as there is no way the void well throw an exception ?



i know you said thats how (YOU) do it but... i wold like to know how is it gonna return any errors and why does it need a try/catch blocks and how can it be easier than that and why do you need to sort such dictionary that contains less than 6 items ?

I'm just kidding man. That would be ridiculously inefficient. :p
07/07/2011 21:05 -Shunsui-#28
thanks for the help, lol i guess ill just do it how, 12talis said.
07/07/2011 23:18 Lateralus#29
Quote:
Originally Posted by -Shunsui- View Post
thanks for the help, lol i guess ill just do it how, 12talis said.
And use concurrent dictionaries.