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'm having trouble getting dbReadByte to read character bytes from a file (newbie question)

Author
Message
Garfield rules
19
Years of Service
User Offline
Joined: 12th Jun 2005
Location:
Posted: 27th Apr 2008 02:14 Edited at: 27th Apr 2008 02:17
Hi... Using DarkBASIC I created a custom file format for myself. It's by no means the most sophisticated file format out there, but it suits my needs... Anyway, now that I've gotten Dark GDK I would like to try and use that same format. However, I'm having trouble loading the custom files I created using DarkBASIC. Here's the code of the function, with an explanation below the snippet:



The first step for loading this file is reading the five-byte signature at the top of the file. So, before I proceed with programming the actual loading of most of the data, I just want to test once the bytes are read whether they equal the signature--that's why the function is boolean for the moment. However, dbReadByte doesn't like those bytes for some reason, or I've gotten something mixed up in my code (the latter being the most likely). Here is the output I get when I try to compile:

>Compiling...
1>Main.cpp
1>c:\users\*name omitted*\documents\visual studio 2008\projects\dark gdk - game1\dark gdk - game1\cmap.h(40) : error C2665: 'dbReadByte' : none of the 2 overloads could convert all the argument types
1> c:\program files\the game creators\dark gdk\include\darksdkfile.h(99): could be 'unsigned char dbReadByte(int,unsigned char *)'
1> while trying to match the argument list '(int, char)'


It would appear that the problem resides with how I'm using the dbReadByte command, as everything else compiles correctly. But, what do I know? Could someone please advise me on what my mistake is and what the solution is?
jinzai
18
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 27th Apr 2008 03:23 Edited at: 27th Apr 2008 03:24
The way to call dbReadByte is with a pointer. You are not passing a pointer; that is trying to pass what is already in your read buffer, which you should initialize with zeros so that you start with a known buffer. Use memset for that, like this:
memset(&FileSig[0], 0, 5);
Call dbReadByte like this:
dbReadByte(1, &FileSig[bytecounter]);
Garfield rules
19
Years of Service
User Offline
Joined: 12th Jun 2005
Location:
Posted: 27th Apr 2008 07:47
Thank you so much!

Login to post a reply

Server time is: 2024-11-20 09:12:11
Your offset time is: 2024-11-20 09:12:11