Jump to content
  • Advertisement
Sign in to follow this  
Mizipzor

Errorcheck in GetTileData

This topic is 4820 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a struct which defines a tile, evert tile got an id number so I can store them in the map file and in the mapvector as ints. Then I need a function that returns the tile represented by a certain tile id. I wrote this:
Tile* GetTileData(int TileID) {
	if( TileData.find(TileID) == TileData.end() ) {	// if the TileID doesnt exist...
		return &TileData[0];	// return the black one
	} 

	return &TileData[TileID];	// otherwise return the specified tile
}
But I get errors:
d:\Documents\CPP\Visual Studio Projects\TileSystem\AsciiMap.cpp(39) : error C2065: 'TileData' : undeclared identifier
d:\Documents\CPP\Visual Studio Projects\TileSystem\AsciiMap.cpp(39) : error C2228: left of '.find' must have class/struct/union type
        type is ''unknown-type''
d:\Documents\CPP\Visual Studio Projects\TileSystem\AsciiMap.cpp(39) : error C2228: left of '.end' must have class/struct/union type
        type is ''unknown-type''
d:\Documents\CPP\Visual Studio Projects\TileSystem\AsciiMap.cpp(39) : error C3861: 'TileData': identifier not found, even with argument-dependent lookup
d:\Documents\CPP\Visual Studio Projects\TileSystem\AsciiMap.cpp(40) : error C3861: 'TileData': identifier not found, even with argument-dependent lookup
d:\Documents\CPP\Visual Studio Projects\TileSystem\AsciiMap.cpp(43) : error C3861: 'TileData': identifier not found, even with argument-dependent lookup

The tiledata is a std::map, std::map <int, Tile> TileData; // holds the information for all the tiles, the data is accessed by the tile ID number I thought ( TileData.find(TileID) == TileData.end() ) was the way to test if an element didnt exist in a std::map. Whats the right way?

Share this post


Link to post
Share on other sites
Advertisement
It looks like that's not your problem, the problem is that your function can't see the TileData declaration. Possible reasons for this include that you forget to include a header, are writing a class member function and didn't put the ClassName:: in front of the function name, or accidently declared something static when it wasn't meant to be. Without seeing more code, it's hard to say what the exact problem is.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!