Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualKnolanCross

Posted 13 November 2012 - 11:40 AM

Well, as I said, comparing by name is a bad idea, it is slow and prone to error. If you using char* of char[], they won't compare as you may want. For instance:
[source lang="cpp"] char* a = "hello world"; char b[] = "hello world"; if (a == b){ printf("Ok"); } else{ printf("Nope."); }[/source]
Will print "Nope.", which is not intuitive at all (it has to do with memory areas used by a and b).

Using find is also not needed as you know which item you need to check, even if you get it working (I believe that if you use Strings, aItem is a struct and they are the first element declared in the struct it will work as intended), you will be tossing away processing (as you need to find the element in the array).

I keep my opinion of adding an itemType, each type is an ID that represents the item type (armor, potion, quest item and so on). So you just check if the item at that point have the potion id. The main advantage of a vector over a list is that you can directly accesss an item... take advantage of it =D

#1KnolanCross

Posted 13 November 2012 - 11:39 AM

Well, as I said, comparing by name is a bad idea, it is slow and prone to error. If you using char* of char[], they won't compare as you may want. For instance:
[source lang="cpp"] char* a = "hello world"; char b[] = "hello world"; if (a == b){ printf("Ok"); } else{ printf("Nope."); }[/source]
Will print "Nope.", which is not intuitive at all (it has to do with memory areas used by a and b).

Using find is also not needed as you know which item you need to check, even if you get it working (I believe that if you use Strings, aItem is a struct and they are the first element declared in the struct it will work as intended), you will be tossing away processing (as you need to find the element in the array).

I keep my opinion of adding an itemType, each type is an ID that represents the item type (armor, potion, quest item and so on). So you just check if the item at that point have the potion id.

PARTNERS