Register for your free account! | Forgot your password?

Go Back   elitepvpers > MMORPGs > Conquer Online 2 > CO2 Private Server
You last visited: Today at 19:00

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



Difference and explanation

Discussion on Difference and explanation within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
marlyandedsel's Avatar
 
elite*gold: 0
Join Date: Aug 2010
Posts: 343
Received Thanks: 21
Difference and explanation

code 1

PHP Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace 
System
{
    public class 
SafeDictionary<T1T2>
    {
        private 
Dictionary<T1T2DictBase;

        public 
SafeDictionary(int capacity)
        {
            
DictBase = new Dictionary<T1T2>(capacity);
        }
        public 
SafeDictionary()
        {
            
DictBase = new Dictionary<T1T2>();
        }
        public 
Dictionary<T1T2Base
        
{
            
get
            
{
                return 
DictBase;
            }
        }
        public 
int Count
        
{
            
get
            
{
                return 
DictBase.Count;
            }
        }

        public 
bool Add(T1 keyT2 value)
        {
            if (!
DictBase.ContainsKey(key))
            {
                
DictBase.Add(keyvalue);
                return 
true;
            }
            return 
false;
        }

        public 
void Remove(T1 key)
        {
            
DictBase.Remove(key);
        }

        public 
bool ContainsKey(T1 key)
        {
            return 
DictBase.ContainsKey(key);
        }

        public 
bool ContainsValue(T2 value)
        {
            return 
DictBase.ContainsValue(value);
        }

        public 
void Clear()
        {
            
DictBase.Clear();
        }

        public 
T2 this[T1 key]
        {
            
get
            
{
                if (
ContainsKey(key))
                    return 
DictBase[key];
                else return default(
T2);
            }
        }

        public 
Dictionary<T1T2>.ValueCollection Values
        
{
            
get
            
{
                if (
DictBase == null)
                    
DictBase = new Dictionary<T1T2>();
                return 
DictBase.Values;
            }
        }

        public 
bool TryGetValue(T1 keyout T2 value)
        {
            return 
DictBase.TryGetValue(keyout value);
        }

        
/*internal void Add(ushort p, Conquer_Online_Server.Interfaces.IProf Prof)
        {
           throw new NotImplementedException();
        } */
    
}

I have Argument Null Exception at that code in this portion
PHP Code:
   public bool ContainsKey(T1 key)
        {
            return 
DictBase.ContainsKey(key);
        } 
Code 2
Are they just same function of code 1?
PHP Code:
using System;
using System.Linq;
using System.Collections.Generic;
using System.Runtime.InteropServices;

namespace 
System.Collections.Generic
{
    public class 
ThreadSafeDictionary<T1T2>
    {
        private 
Dictionary<T1T2SafeDictionaryBase;
        public 
T2[] Values = new T2[0];

        public 
ThreadSafeDictionary(int capacity)
        {
            
SafeDictionaryBase = new Dictionary<T1T2>(capacity 10);
        }
        public 
int Count
        
{
            
get
            
{
                return 
SafeDictionaryBase.Count;
            }
        }
        public 
Dictionary<T1T2Base
        
{
            
get
            
{
                return 
SafeDictionaryBase;
            }
        }
        public 
void Add(T1 keyT2 value)
        {
            if (
SafeDictionaryBase.ContainsKey(key) == false)
            {
                
lock (SafeDictionaryBase)
                    
SafeDictionaryBase.Add(keyvalue);
                
safeUpdate();
            }
        }
        public 
void Remove(T1 key)
        {
            
lock (SafeDictionaryBase)
                
SafeDictionaryBase.Remove(key);
            
safeUpdate();
        }

        public 
T2 this[T1 key]
        {
            
get
            
{
                if (
ContainsKey(key))
                    return 
SafeDictionaryBase[key];
                else return default(
T2);
            }
        }

        public 
bool TryGetValue(T1 keyout T2 value)
        {
            return 
SafeDictionaryBase.TryGetValue(keyout value);
        }

        public 
bool ContainsKey(T1 key)
        {
            return 
SafeDictionaryBase.ContainsKey(key);
        }

        public 
bool ContainsValue(T2 value)
        {
            return 
SafeDictionaryBase.ContainsValue(value);
        }

        private 
void safeUpdate()
        {
            if (
Values == null)
            {
                
Values SafeDictionaryBase.Values.ToArray();
            }
            else
            {
                if (
System.Threading.Monitor.TryEnter(Values1))
                {
                    
Values SafeDictionaryBase.Values.ToArray();
                }
            }
        }
    }

these are all from public source but I just need to know if this two is good or not..
marlyandedsel is offline  
Old 06/01/2012, 13:22   #2
 
elite*gold: 0
Join Date: Dec 2011
Posts: 1,537
Received Thanks: 785
They key you specified is null or the dict is null.
I don't have a username is offline  
Old 06/01/2012, 13:52   #3


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
ConcurrentDictionary

That is all.
Korvacs is offline  
Thanks
1 User
Old 06/01/2012, 20:36   #4
 
Zeroxelli's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 1,769
Received Thanks: 1,143
Quote:
Originally Posted by Korvacs View Post
ConcurrentDictionary

That is all.
^ Best advice to follow is right there.
Zeroxelli is offline  
Old 06/01/2012, 23:20   #5
 
elite*gold: 0
Join Date: Dec 2011
Posts: 1,537
Received Thanks: 785
Code:
    public interface ThreadedObject
    {
        string Name { get; set; }
        uint UID { get; set; }
        ThreadedType EntityType { get; set; }
        ushort MapID { get; set; }
    }
    public enum ThreadedType
    {
        Pet,
        Player,
        Mob,
        Guard,
        ReviverGuard,
        Boss,
        SOB
    }
 public class ThreadedCollection : ConcurrentDictionary<uint, ThreadedObject>
    {
        public bool Add(uint Key, ThreadedObject Value)
        {
            return base.TryAdd(Key, Value);
        }
        public bool Remove(uint Key)
        {
            ThreadedObject Value;
            return base.TryRemove(Key, out Value);
        }
        public new ThreadedObject this[uint Key]
        {
            get
            {
                ThreadedObject Value = null;
                base.TryGetValue(Key, out Value);
                return Value;
            }
        }

        public ThreadSafeList<ThreadedObject> Search(ThreadedType ObjectType)
        {
            ThreadSafeList<ThreadedObject> ObjectList = new ThreadSafeList<ThreadedObject>();
            foreach (ThreadedObject Object in base.Values)
                if (Object.EntityType == ObjectType)
                    ObjectList.Add(Object);

            return ObjectList;
        }
        public ThreadSafeList<ThreadedObject> Search(uint UIDStart, uint UIDEnd)
        {
            ThreadSafeList<ThreadedObject> ObjectList = new ThreadSafeList<ThreadedObject>();
            foreach (ThreadedObject Object in base.Values)
                if (Object.UID > UIDStart && Object.UID < UIDEnd)
                    ObjectList.Add(Object);

            return ObjectList;
        }
        public ThreadSafeList<ThreadedObject> Search(ushort MapID)
        {
            ThreadSafeList<ThreadedObject> ObjectList = new ThreadSafeList<ThreadedObject>();
            foreach (ThreadedObject Object in base.Values)
                if (Object.MapID == MapID)
                    ObjectList.Add(Object);

            return ObjectList;
        }
        public ThreadSafeList<ThreadedObject> Search(ThreadedType ObjectType, ushort MapID)
        {
            ThreadSafeList<ThreadedObject> ObjectList = new ThreadSafeList<ThreadedObject>();
            foreach (ThreadedObject Object in base.Values)
                if (Object.EntityType == ObjectType && Object.MapID == MapID)
                    ObjectList.Add(Object);

            return ObjectList;
        }
        public ThreadedObject Search(string Name)
        {
            uint UID = 0;
            foreach (ThreadedObject Object in base.Values)
                if (Object.Name == Name)
                    UID = Object.UID;
            return this[UID];
        }
        public ThreadedObject Search(ThreadedType ObjectType, string Name)
        {
            uint UID = 0;
            foreach (ThreadedObject Object in base.Values)
                if (Object.Name == Name && Object.EntityType == ObjectType)
                    UID = Object.UID;
            return this[UID];
        }
    }
I don't have a username is offline  
Old 06/02/2012, 00:09   #6
 
Zeroxelli's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 1,769
Received Thanks: 1,143
That also works.
Zeroxelli is offline  
Old 06/02/2012, 00:15   #7
 
elite*gold: 0
Join Date: Dec 2011
Posts: 1,537
Received Thanks: 785
Quote:
Originally Posted by Zeroxelli View Post
That also works.
It's a concurrentdictionary o.o
I don't have a username is offline  
Old 06/02/2012, 00:20   #8
 
Zeroxelli's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 1,769
Received Thanks: 1,143
Quote:
Originally Posted by I don't have a username View Post
It's a concurrentdictionary o.o
At the root, yes. But with methods so they can still use the method [names] "Remove" and "Add" instead of the native TryRemove and TryAdd. Less confusing to newbies.
Zeroxelli is offline  
Old 06/02/2012, 00:32   #9
 
elite*gold: 0
Join Date: Dec 2011
Posts: 1,537
Received Thanks: 785
Quote:
Originally Posted by Zeroxelli View Post
At the root, yes. But with methods so they can still use the method [names] "Remove" and "Add" instead of the native TryRemove and TryAdd. Less confusing to newbies.
Yup, but does not make a difference really, I just did it, because of less typing lool.
I don't have a username is offline  
Old 06/02/2012, 00:35   #10
 
Zeroxelli's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 1,769
Received Thanks: 1,143
Quote:
Originally Posted by I don't have a username View Post
Yup, but does not make a difference really, I just did it, because of less typing lool.
You'd be surprised at the amount of people who post on forums asking how to add and remove things from a ConcurrentDictionary. As if IntelliSense didn't tell them as soon as they type the period...
Zeroxelli is offline  
Thanks
1 User
Old 06/02/2012, 01:03   #11
 
nTL3fTy's Avatar
 
elite*gold: 0
Join Date: Jun 2005
Posts: 692
Received Thanks: 353
People still use ushort as a map id? If you went and looked at the latest GameMap.dat (or a patch since they added the arena), you'd quickly notice that its an int.
nTL3fTy is offline  
Old 06/02/2012, 01:10   #12
 
Zeroxelli's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 1,769
Received Thanks: 1,143
Oh, wow. Why would they need map IDs larger than 0xFFFF (65535)? They don't have anywhere near that many maps.
Zeroxelli is offline  
Old 06/02/2012, 01:17   #13
 
elite*gold: 0
Join Date: Dec 2011
Posts: 1,537
Received Thanks: 785
Quote:
Originally Posted by nTL3fTy View Post
People still use ushort as a map id? If you went and looked at the latest GameMap.dat (or a patch since they added the arena), you'd quickly notice that its an int.
I'm running patch 4267.
I don't have a username is offline  
Old 06/02/2012, 01:18   #14
 
Zeroxelli's Avatar
 
elite*gold: 0
Join Date: May 2008
Posts: 1,769
Received Thanks: 1,143
Touche.

No point using the extra two bytes of memory space if you're never going to use it. Two bytes may seem small, but getting into the habit of things like that are how servers end up being inefficient.
Zeroxelli is offline  
Old 06/02/2012, 01:24   #15
 
_DreadNought_'s Avatar
 
elite*gold: 28
Join Date: Jun 2010
Posts: 2,226
Received Thanks: 868
Quote:
Originally Posted by nTL3fTy View Post
People still use ushort as a map id? If you went and looked at the latest GameMap.dat (or a patch since they added the arena), you'd quickly notice that its an int.
I noticed that a long time ago;
_DreadNought_ is offline  
Reply


Similar Threads Similar Threads
[lil explanation]
04/15/2012 - CO2 Programming - 9 Replies
well simply i need someone to explain more about this for me void AccessAll(Control.ControlCollection cc) { foreach (Control c in CC) { if (c is CheckBox) { CheckBox ch = c as CheckBox; ch.Checked = true; }
Need some explanation >.<
08/15/2011 - Silkroad Online - 4 Replies
It's about Ramadan Event..I'm collecting Alibaba seals but the questaion is when does the event finishes? i'm confused coz I went to sro site & it say August 2, 2011 ~ August 16, 2011 (2 weeks)..& some where down it says AliBaba Seal reward: August 23 ~ August 30, 2011 (1 week) :confused:
Need some explanation here..
09/06/2010 - EO PServer Hosting - 9 Replies
Hi all..my server got a few problem now.. and i dont know what is the problem.. Acc server run good..also msg server run good.. and NPC server run good...But after a few minute.Msg server stop working. i have looking at error log..this what i have found.. 14:52:30 ERROR: ¡ïASSERT(!"Error action type!")¡ï in e:\tq_digital\ħÓò\reliable\src\MsgServer\MapGroup Kernel\GameAction.cpp, 1300 14:52:30 ERROR: ¡ïCHECKF(pType)¡ï in...
Need an explanation please^^
02/04/2009 - Kal Online - 13 Replies
Hello people. Long time ago I wrote a little memory scanner. A program like the normal Cheat Engines but its just a console window^^ Well when I wrote it I tried it with Kal and got what I expected: I couldnt access Kals Memory area cause of HS/KOCP or whatever. Well today I tried it again (dont even know why I tried) and well... suddenly it works. I found the max HP adress, the speed adress. And I even can change it with my little noob CE^^ No-Mana G3 speed works perfectly. Well my question,...



All times are GMT +1. The time now is 19:01.


Powered by vBulletin®
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2026 elitepvpers All Rights Reserved.