Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / I need some confirmation...

Author
Message
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 7th Jul 2008 06:32 Edited at: 7th Jul 2008 06:40


That should work, right? Its supposed to return a multidimensional array of all the names of files in the directory.

I tried it, but I kept getting errors with this code, trying to display it:



Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 7th Jul 2008 06:42
Codger?

Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 7th Jul 2008 07:07
1( Error messages would be helpful.

2( I haven't messed with function pointers, but shouldn't this
be this
?

Of course, as I just said, I don't know anything about function-pointers, so I may be wrong.
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 7th Jul 2008 07:09 Edited at: 7th Jul 2008 07:13
I can see a few issues:

'buffer[0] = dbGetFileName();' won't work because 'buffer' is a 2D static array as defined here 'char buffer[512][256];
'
, to access it you have to specify both dimensions.

Even if it did work, you'd merely be writing the address of 'dbGetDir()' to your first array index, I assume you want to copy the string? In which case you'd need to strcpy() it to the address of 'buffer'(which is the same as the first index).

'buffer[i] = dbGetFileName();' Again this copies the address over only, if you want to fill your static array with string data and not just addresses to strings then you need to use strcpy(), I'm not sure if these GDK functions return dynamically allocated string buffers, but if they do you can just create a 1D array for your strings that only stores the addresses to the actual string data.

return *buffer; This also won't work because your 'buffer' array is only valid within the scope of this function, as soon as your function returns you won't be able to access it, you'd need to dynamically allocate it or make the array static for it to be accessible once the function has exit.

Quote: "I tried it, but I kept getting errors with this code, trying to display it:"


I wouldn't be surprised, you're assigning 'test[0]' 'test[1]' and test isn't initialized. 'processFiles("data");' this doesn't even take the same amount of arguments as your above function?

Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 7th Jul 2008 07:09 Edited at: 7th Jul 2008 07:10
I was taught that the position of the * didn't matter.

char * something; would work
char* something; would work
char *something; would work.

Sorry, I took out the second parameter in my own code and didn't change it there.

Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 7th Jul 2008 07:09 Edited at: 7th Jul 2008 07:10
Quote: "I was taught that the position of the * didn't matter."


I believe that's only for variable declarations, not functions.
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 7th Jul 2008 07:12
No, I thought it was for everything.



Dark coder, can you just change it for me? I didn't understand most of that. :/

Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 7th Jul 2008 07:13
I don't recommend having it changed without fully understanding the logic behind it. It's just not a good idea in any situation that isn't a direct learning experience.
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 7th Jul 2008 07:15
I know, but I don't know where to put strcopy() and I'm afraid to screw something up beyond repair.

Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 7th Jul 2008 07:19
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 7th Jul 2008 07:22 Edited at: 7th Jul 2008 07:24
Not tested:



This assumes the GDK string functions return dynamically allocated ones.

Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 7th Jul 2008 07:24
Much better for portability.
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 7th Jul 2008 07:25 Edited at: 7th Jul 2008 07:28
Okay, how do I extract something from that? I don't understand queue.

This?



And then loop through?

Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 7th Jul 2008 07:49
Obviously not, as it produces THIS many errors:





dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 7th Jul 2008 07:50 Edited at: 7th Jul 2008 07:52
Yes, that will get the first string and remove it from the queue, but it depends what you need it for. If you want to keep the file listing and use it many times a vector may be of more use, and remember that you'll have to deallocate the string when you've finished with it, else you'll end up with a memory leak.

[edit] you need to use the . operator, but other than that, it's correct.

Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 7th Jul 2008 07:51
How do I deallocate the string? I know it uses delete, but... how?

dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 7th Jul 2008 07:53
using:



Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 7th Jul 2008 08:00
The function itself (dark coder's) causes all those errors.

dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 7th Jul 2008 08:06
I get no issues, make sure your Project properties/Config properties/General/C++/Code Generation is set to "Multi-threaded (/MT)". If that doesn't work then just look at the billion other threads on this board about this.

Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 7th Jul 2008 08:10
Ok, did that. Now I can't compile, no code errors.



dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 7th Jul 2008 08:14
How did you make your project? You're best off just using one of the GDK wizards, then all you need to do is set it to /MT and it should all work fine.

Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 7th Jul 2008 08:16
GDK projects are /MT by default.
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 7th Jul 2008 08:24
Okay, used the wizard and what you did.

Now there's ANOTHER problem. It should display "x2fighter.dat", but instead just "_".

dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 7th Jul 2008 08:28
Remember that depending on the dir you're searching the first 2 strings will be "." followed by ".."; so check for this. And I'm pretty sure GDK projects are /MTd by default.

Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 7th Jul 2008 08:28
Okay, well... would it be okay to load my images from an FTP?

dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 7th Jul 2008 08:35
Assuming you download them first and don't try to dbLoadImage with a URL then yes.

Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 7th Jul 2008 08:41
They're only /MTd by default under debug. I meant release.
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 7th Jul 2008 08:47
I meant like speed-wise. I'm not loading every frame... so...

dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 7th Jul 2008 09:00
How fast does a car go? It all depends. Try it and see if you have FTP access.

Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 7th Jul 2008 09:07
Nah. Is there any other way to keep my .dat files somewhat safe?

Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 7th Jul 2008 09:16
There is a rule that is almost never broken: if it exist on the harddrive, it can almost assuredly be hacked/modified.
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 7th Jul 2008 09:16
Also, I'm having trouble with Photoshop.

Is there a way to do dbSetImageColorKey with a .png image? It doesn't seem to work...

Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 7th Jul 2008 09:17
Not sure about that. Haven't tried it with png's. They have their own transparency built-in, I believe.
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 7th Jul 2008 09:28
It isn't loading anything...



Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 7th Jul 2008 09:28
That's the problem, Mahoney. I can't GET them to have transparency because my Photoshop is screwed up.

Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 7th Jul 2008 09:32
I meant that they have an alpha channel built in that may be interfering with the dbSetImageColorKey, not that you should use the built-in alpha channel.
Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 7th Jul 2008 09:33
So, what format, then? I am NOT using a .bmp.

Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 7th Jul 2008 09:37 Edited at: 7th Jul 2008 09:40
Um... okay...?

It loaded the .jpg, did SetImageColorKey... and just SOME of it disappeared, thanks to the crappy quality. It seems that .png is the only format that I can use and keep the quality required.

The processFiles thing isnt working still.

Mahoney
16
Years of Service
User Offline
Joined: 14th Apr 2008
Location: The Interwebs
Posted: 7th Jul 2008 09:41
As long as the image is small, bmp should suit you just fine. But, if you really insist on not using it, then you'll have to look up information about the alpha channel in png's.
dark coder
22
Years of Service
User Offline
Joined: 6th Oct 2002
Location: Japan
Posted: 7th Jul 2008 09:47


Your code does this, as I said earlier, the first 2 strings will be "." and "..", so first check that these are valid files, also you never pop the front index from the queue, so you'll just end up with an infinite loop.

Zuka
16
Years of Service
User Offline
Joined: 21st Apr 2008
Location: They locked me in the insane asylum.
Posted: 7th Jul 2008 23:15 Edited at: 8th Jul 2008 01:43
Thank you so much, dark coder. It's working... barely.

It loaded my refit station, but the outer ring is missing... all the black parts are missing, the pink is white. I don't get it.
Never mind. I loaded the wrong image.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-11-20 15:35:19
Your offset time is: 2024-11-20 15:35:19