Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Forum » DynamicVectorClass problems
DynamicVectorClass problems [message #453970] Sat, 10 September 2011 13:49 Go to next message
halo2pac is currently offline  halo2pac
Messages: 659
Registered: December 2006
Location: Near Cleveland, Ohio
Karma: 0
Colonel
Hey guys,

So I am trying to make a .. of my custom class 'Gamer'

But the compiler keeps erroring at :

engine_vector.h

	virtual int ID(T const &object)
	{
		for (int index = 0; index < Count(); index++)
		{
------------------>>    if ((*this)[index] == object)
			{
				return(index);
			}
		}
		return -1;
	}


my code:
DynamicVectorClass<Gamer> Gamers;

#include "engine_io.h"

class Gamer
{
public:

	//Gamer();
	Gamer(const char *Nick);

	StringClass PlayerName;
	int Deaths;
	int CurrentKills;
};


Gamer::Gamer(const char *Nick)
{
	PlayerName = Nick;
}


I have no idea why this is not working...
any help is appreciated!


http://img339.imageshack.us/img339/1991/nefobbygenyunoreleasere.jpg
Rene-Buddy | Renegade X
Join the fight against Obsessive-Compulsive Posting Disorder. Cancel is ur friend.
*Renegade X Dev Team Member*

[Updated on: Sat, 10 September 2011 13:50]

Report message to a moderator

Re: DynamicVectorClass problems [message #453971 is a reply to message #453970] Sat, 10 September 2011 13:53 Go to previous messageGo to next message
saberhawk
Messages: 1068
Registered: January 2006
Location: ::1
Karma: 0
General (1 Star)
Add this to the Gamer class definition:

	bool operator==(const Gamer& that)
	{
		return false;
	}


Re: DynamicVectorClass problems [message #453973 is a reply to message #453970] Sat, 10 September 2011 14:36 Go to previous messageGo to next message
halo2pac is currently offline  halo2pac
Messages: 659
Registered: December 2006
Location: Near Cleveland, Ohio
Karma: 0
Colonel
I'm curious as to why I would have to do that in the first place for creating a class :S

also now it s saying the same thing for !=
do I replicate the code?


http://img339.imageshack.us/img339/1991/nefobbygenyunoreleasere.jpg
Rene-Buddy | Renegade X
Join the fight against Obsessive-Compulsive Posting Disorder. Cancel is ur friend.
*Renegade X Dev Team Member*
Re: DynamicVectorClass problems [message #453974 is a reply to message #453973] Sat, 10 September 2011 14:58 Go to previous messageGo to next message
saberhawk
Messages: 1068
Registered: January 2006
Location: ::1
Karma: 0
General (1 Star)
halo2pac wrote on Sat, 10 September 2011 14:36

I'm curious as to why I would have to do that in the first place for creating a class :S

also now it s saying the same thing for !=
do I replicate the code?


Yeah, and replace false with true. DynamicvectorClass tries supplying additional functionality to a vector (like Find), but it requires certain operators to be defined in the class.
Re: DynamicVectorClass problems [message #453975 is a reply to message #453970] Sat, 10 September 2011 15:07 Go to previous messageGo to next message
halo2pac is currently offline  halo2pac
Messages: 659
Registered: December 2006
Location: Near Cleveland, Ohio
Karma: 0
Colonel
ah, I see.

Also it is requiring that I use a default constructor, which I do not want the default constructor because apparently it is setting my integers to integer.max.

Is there a way around this?

I am trying to do a simple class to store player information.. so that if they disconnected and rejoin they don't loose some levels/powerups/ect. Which requires maintaining a custom list of player data.


http://img339.imageshack.us/img339/1991/nefobbygenyunoreleasere.jpg
Rene-Buddy | Renegade X
Join the fight against Obsessive-Compulsive Posting Disorder. Cancel is ur friend.
*Renegade X Dev Team Member*
Re: DynamicVectorClass problems [message #453976 is a reply to message #453975] Sat, 10 September 2011 15:14 Go to previous messageGo to next message
saberhawk
Messages: 1068
Registered: January 2006
Location: ::1
Karma: 0
General (1 Star)
halo2pac wrote on Sat, 10 September 2011 15:07

ah, I see.

Also it is requiring that I use a default constructor, which I do not want the default constructor because apparently it is setting my integers to integer.max.

Is there a way around this?

I am trying to do a simple class to store player information.. so that if they disconnected and rejoin they don't loose some levels/powerups/ect. Which requires maintaining a custom list of player data.



The default constructor isn't setting them to anything. You do need to provide a constructor and have it set the values to whatever you want the defaults to be.
Re: DynamicVectorClass problems [message #453981 is a reply to message #453970] Sat, 10 September 2011 16:09 Go to previous message
halo2pac is currently offline  halo2pac
Messages: 659
Registered: December 2006
Location: Near Cleveland, Ohio
Karma: 0
Colonel
Thanks much Smile

http://img339.imageshack.us/img339/1991/nefobbygenyunoreleasere.jpg
Rene-Buddy | Renegade X
Join the fight against Obsessive-Compulsive Posting Disorder. Cancel is ur friend.
*Renegade X Dev Team Member*
Previous Topic: Post scripts 4.0 code questions here
Next Topic: LOD models
Goto Forum:
  


Current Time: Tue Jul 16 05:48:46 MST 2024

Total time taken to generate the page: 0.00891 seconds