Register for your free account! | Forgot your password?

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

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

Advertisement



const variables VS enumerators

Discussion on const variables VS enumerators within the CO2 Private Server forum part of the Conquer Online 2 category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: May 2011
Posts: 1,769
Received Thanks: 756
const variables VS enumerators

What is better to use?

It's Conquer Related, because it's for my source.

Currently I have been using enumerators, except for packetids and mapids they are const variables.
BaussHacker is offline  
Old 09/23/2011, 22:00   #2
 
12tails's Avatar
 
elite*gold: 0
Join Date: Apr 2009
Posts: 782
Received Thanks: 458
hmmm i use const variables for some things and enum's for others... i've took the example of EO Source....
it's a good resource project :]

example:
Code:
        const int ITEMSORT_INVALID = -1;
        const int ITEMSORT_EXPEND = 0;
        const int ITEMSORT_HELMET = 1;
        const int ITEMSORT_NECKLACE = 2;
        const int ITEMSORT_ARMOR = 3;
        const int ITEMSORT_WEAPON1 = 4;
        const int ITEMSORT_WEAPON2 = 5;
        const int ITEMSORT_SHIELD = 6;
        const int ITEMSORT_RING = 7;
        const int ITEMSORT_SHOES = 8;
        const int ITEMSORT_OTHER = 9;
12tails is offline  
Thanks
1 User
Old 09/23/2011, 22:02   #3
 
elite*gold: 0
Join Date: May 2011
Posts: 1,769
Received Thanks: 756
Quote:
Originally Posted by 12tails View Post
hmmm i use const variables for some things and enum's for others... i've took the example of EO Source....
it's a good resource project :]
Yeah I mean, where should I use what.
BaussHacker is offline  
Old 09/23/2011, 22:04   #4
 
Mr_PoP's Avatar
 
elite*gold: 0
Join Date: Apr 2008
Posts: 759
Received Thanks: 285
Quote:
Originally Posted by BaussHacker View Post
Yeah I mean, where should I use what.
when you don't need a magic numbers everywhere lol
Mr_PoP is offline  
Old 09/23/2011, 22:05   #5


 
Korvacs's Avatar
 
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
Enums imo, you can do more useful things with enums, a constant is just a constant, not much you can do with it.
Korvacs is offline  
Thanks
1 User
Old 09/23/2011, 22:06   #6
 
elite*gold: 0
Join Date: May 2011
Posts: 1,769
Received Thanks: 756
Quote:
Originally Posted by Mr_PoP View Post
when you don't need a magic numbers everywhere lol
Care to explain?
BaussHacker is offline  
Old 09/23/2011, 22:09   #7
 
12tails's Avatar
 
elite*gold: 0
Join Date: Apr 2009
Posts: 782
Received Thanks: 458
i would say to use an enum when you would struct something like ItemInfo/UserData
and use Get/Set methods to control the variables as you wish... doing this way you would prevent an major error doing a mistake or something like while ur coding...

example:
Code:
class UserData
{
      private uint uiId;
      private string szName;
      public const int MAX_LEVEL = 140;//ex to use a const

      enum EntityVariable { Id, Name }//ex to use a enum

      public uint GetInt(EntityVariable evObject) 
      { 
            switch (evObject)
            {
                  case EntityVariable.Id:
                        return uiId;
            }
      }

      public string GetStr(EntityVariable evObject) 
      { 
            switch (evObject)
            {
                  case EntityVariable.Name:
                        return szName;
            }
      }

      public void SetStr(EntityVariable evObject, string szValue) 
      { 
            switch (evObject)
            {
                  case EntityVariable.Name:
                        szName = szValue;
                        //TODO: Actions after change name here
                        break;
            }
      }
}
12tails is offline  
Thanks
1 User
Old 09/24/2011, 05:38   #8
 
elite*gold: 0
Join Date: Jun 2009
Posts: 787
Received Thanks: 314



each individual ITEM is then an enumerator.
please.
_tao4229_ is offline  
Thanks
1 User
Old 09/24/2011, 11:12   #9
 
elite*gold: 0
Join Date: May 2011
Posts: 1,769
Received Thanks: 756
Quote:
Originally Posted by _tao4229_ View Post



each individual ITEM is then an enumerator.
please.
LOL
BaussHacker is offline  
Reply


Similar Threads Similar Threads
Effects and Variables help
05/03/2011 - SRO Coding Corner - 0 Replies
Hello EPVP I need your help of Srevolution source I would like to know how I declare the variables tied silkroad like quest_complete quest_getreward Also And how am I start do all effects.
S> 130-131 arc/arc Const>Gemini
01/11/2011 - Conquer Online 2 Trading - 0 Replies
Selling Archer 130-131 with sup gears and bow lvl 130+4 2sdg post offers...
Question about variables
10/05/2008 - CO2 Private Server - 2 Replies
ok you know how u got things like blah.blah, example: mychar.level so if you were to make variables for all those example: Clevel = mychar.level what kind of advantages would i gain from this if any? i rem when i learned visual basic was always told to put every thing in variables so was just curious if that would b a good way to go
Rohan Ingame Variables
08/11/2008 - Rohan - 3 Replies
In order to make a good bot, i need to have and control the Rohan Game Variables, if we can get them, such hp/mp if mob is targeted or not, the position i think i can do a nice bot...but the problem remains how to find this data.... Any idea?



All times are GMT +1. The time now is 18:46.


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.