Jump to content
  • Advertisement
Sign in to follow this  
Vanderry

[C++] Tree View & Byte Arrays

This topic is 3206 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

Hello GameDevs ! I have a probably very weird problem this time. In a game engine of mine I was planning to sort the static game assets by array-like indices that correspond to a folder path. 1. Flora ---1. Trees ------1. Pine ------2. Oak ---2. Flowers ------1. Daisy 2. Structures ---1. Wall ---2. House (1, 1, 2, 0) would represent the oak asset (zeros signify end of index). The reason for all this being that I can store orientational data (within the game world) for a series of instanced game objects in a binary file that won't occupy unnecessarily much memory. Now to the actual problem, within the game world editor I'm using a Win32 Tree View to access the game assets. The way I have understood it, I can store a label string and an LPARAM (a LONG_PTR of 4 bytes) in each of its TVITEM elements. So I figured I might just as well store the index into the LPARAM in the form of a 4 char array (4 x 1 byte). My question is: can and should I push the 4 chars into the LPARAM somehow? I tried to use memcpy with no great success.
LONG_PTR lParam = 0;
UCHAR index[4] = { 1, 1, 2, 0 };
memcpy( &lParam, &index, sizeof( LONG_PTR ) );

for( int i = 0; i < sizeof( LONG_PTR ); i++ )
{
	cout << (UCHAR)(&lParam ) << endl; // The printout is wrong at least
}




If anyone might shed a little light on my situation I'd be ever grateful. - Dave

Share this post


Link to post
Share on other sites
Advertisement
I realized this was a better cast for the printout example:


LPARAM lParam = 0;
UCHAR index[4] = { 1, 1, 2, 0 };
lParam = (LPARAM)index;

for( int i = 0; i < sizeof( LPARAM ); i++ )
{
cout << (int)((UCHAR*)lParam) << endl;
}




Stupid mistake, the result is correct now but I am still unsure about the actual implementation.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!