Jump to content
  • Advertisement

iam73

Member
  • Content Count

    24
  • Joined

  • Last visited

Community Reputation

105 Neutral

About iam73

  • Rank
    Member
  1. Thank you very much for taking the time to help me today, it was very useful! Cheers! Fred
  2. Serapth, you made my day. I couldn't get this to work with include guards and didn't know about forward declaration... Quick googling led me to loads of information on forward declaration, I fixed my problem within the next 5 minutes by adding this to GUI.h: [source lang="cpp"] typedef struct _fntHeader fntHeader; [/source] Thank you so much for the tip! Now one last question, is it ok to pass the struct as an argument or should I pass a pointer instead? The struct is only read by GUI.cpp, no modifications done. So much to learn (sigh...)
  3. It doesn't, but trying to include reader.h in gui.h gives me redefinition errors, so I tried including include guards but still having the syntax errors on fntHeader...
  4. Being new at programming, I'm really pulling my hairs on this one. Been searching and trying all kind of moves since yesterday morning but I'm at a point where I need directions. The problem I have is at compile time, while trying to pass a struct as a function argument - Visual Studio 2010 Ultimate is giving me a C2061 Syntax Error on my struct identifier in the function prototype. Here's my shortened code: reader.h [source lang="cpp"] typedef struct _fntHeader{ char FontTag[8]; // (5 bytes) Data Identifier 'BBF2' unsigned long misc; // (4 bytes) Future use char desc[50]; // (50 bytes) Artist comments int iFirstASCIIId; // (4 bytes) First ASCII Id int iLastASCIIId; // (4 bytes) Last ASCII Id int iBitDepth; // (4 bytes) BitDepth of Font int iMaxFontWidth; // (4 bytes) Widest font size int iMaxFontHeight; // (4 bytes) Tallest font size int iCharSpacing; // (4 bytes) Extra layout spacing between characters int iCharLineSpacing; // (4 bytes) Extra layout spacing between lines (rows) short wTransColor; // (2 bytes) transparent color (packed) long lCharacterBufferSize; // (4 bytes) Size of font data } fntHeader; [/source] GUI.h (this is where VS complains about a syntax error on fntHeader) [source lang="cpp"] void displayFNTinformation(HWND hwnd, fntHeader fontHeader); [/source] GUI.cpp [source lang="cpp"] #include "reader.h" void displayFNTinformation(HWND hwnd, fntHeader fontHeader) { [...] } [/source] winmain.cpp [source lang="cpp"] [...] #include "reader.h" [...] //fill in the struct fntHeader fontFile = readFNTfile(); //show FNT information on GUI displayFNTinformation(hwnd, fontFile); [...] [/source] Now obviously VS knows about fntHeader - otherwise it'd throw a unknown identifier error instead, but I can't find what the syntax issue is in this case... What do you guys think?
  5. iam73

    Memory reading issue....

    Thanks a lot to both of you guys for clearing that up!
  6. Consider the following binary "file": [font=courier new,courier,monospace]42 42 46 32 00 00 00 00 00 00 00 00 51 75 69 63 6B 20 53 [/font] [font=courier new,courier,monospace]74 61 72 74 20 2D 20 4D 61 69 6E 20 4D 65 6E 75 00 00 00 [/font] [font=courier new,courier,monospace]00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00[/font] [font=courier new,courier,monospace]00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 01 00 00 00 [/font] [font=courier new,courier,monospace]03 00 00 00 05 00 00 00 01 00 00 00 01[/font] And the following file structure that goes with it: [font=courier new,courier,monospace]char fontTag[5] //5 bytes BBF2[/font] [font=courier new,courier,monospace]unsigned long misc //4 bytes 0[/font] [font=courier new,courier,monospace]char desc[50] //50 bytes Quick Start - Main Menu[/font] [font=courier new,courier,monospace]int firstASCII //4 bytes 0[/font] [font=courier new,courier,monospace]int lastASCII //4 bytes 256 [/font] [font=courier new,courier,monospace]int bitDepth //4 bytes 1 [/font] [font=courier new,courier,monospace]int maxWidth //4 bytes 3 [/font] [font=courier new,courier,monospace]int maxHeight //4 bytes 5 [/font] [font=courier new,courier,monospace]int charSpacing //4 bytes 1 [/font] [font=courier new,courier,monospace]int lineSpacing //4 bytes 1 [/font] [font=courier new,courier,monospace]short transColor //2 bytes 1 [/font] In my code I have a struct declared as follow: [source lang="cpp"] typedef struct _fntHeader{ char FontTag[5]; // (5 bytes) Data Identifier 'BBF2' unsigned long misc; // (4 bytes) Unused char desc[50]; // (50 bytes) Font description int iFirstASCIIId; // (4 bytes) First ASCII Id int iLastASCIIId; // (4 bytes) Last ASCII Id int iBitDepth; // (4 bytes) BitDepth of Font int iMaxFontWidth; // (4 bytes) Widest font size int iMaxFontHeight; // (4 bytes) Tallest font size int iCharSpacing; // (4 bytes) Extra layout spacing between characters int iCharLineSpacing; // (4 bytes) Extra layout spacing between lines (rows) short wTransColor; // (2 bytes) transparent color (packed) } fntHeader; [/source] I'm in the process of writing a font editor for an existing game. I have a window displaying the loaded font information - same as what is in the struct. The file above is loaded in memory by the following code: [source lang="cpp"]int loadFNTfile(char *fntFile) { ifstream file (fntFile, ios::in|ios::binary|ios::ate); if (file.is_open()) { fileSize = file.tellg(); memblock = new char [(int)fileSize]; file.seekg(0, ios::beg); file.read(memblock, fileSize); file.close(); return 1; } return 0; }[/source] I fill the structure with the data loaded in memory above (which is basically the font header). Doing it this way works as expected - each member is assigned the right value: [source lang="cpp"] fntHeader *fnt = new fntHeader; fnt = ((fntHeader *)memblock); [/source] The issue is when I'm doing it this way. Apparently my 'walker' doesn't move the right number of bytes in memory for some of the struct members and I'd like to understand why: [source lang="cpp"] walker = (unsigned char *)memblock; fntHeader *fnt = new fntHeader; strcpy(fnt->FontTag, (char*)walker); walker += sizeof(fnt->FontTag); fnt->misc = *(unsigned long *)walker; walker += (unsigned long); strcpy(fnt->desc, (char*)walker); walker += sizeof(fnt->desc); fnt->iFirstASCIIId = *(int *)walker; walker += sizeof(int); fnt->iLastASCIIId = *(int *)walker; walker += sizeof(int); fnt->iBitDepth = *(int *)walker; walker += sizeof(int); fnt->iMaxFontWidth = *(int *)walker; walker += sizeof(int); fnt->iMaxFontHeight = *(int *)walker; walker += sizeof(int); fnt->iCharSpacing = *(int *)walker; walker += sizeof(int); fnt->iCharLineSpacing = *(int *)walker; walker += sizeof(int); fnt->wTransColor = *(unsigned short *)walker; walker += sizeof(unsigned short);[/source] If anyone could shed some lights on this I'd appreciate.
  7. Hi guys, This may be obvious to some of you but I'm still in the game programming learning process. Working on porting an old DX7/1999 game to current platform/hardware. The game works pretty much as expected so far, which is good. The issue I'm facing is with the game window. While in the game, it flashes every few seconds. There is also an intermittent problem where some windows desktop elements appear on top of the game (i.e. the start button). When this happens, as soon as a mouse click is made somewhere in the window, it minimize itself to the windows desktop. While in the game wrapper (menus, options), this doesn't happen. I'd like to able to fix this myself, as part of my learning process! I'd like to get opinions on what could be the problem and what I should be looking for. Pretty much need a lead for my investigation. As said above, this is pretty old game code using DX7 and a mix of D3D and DirectDraw. I found a couple threads here regarding double buffering and locked surface, apparently that may be the cause, any thoughts on this? I'm working on Windows 7 x64, using VS2010. Please let me know if you need any details other than what is posted here. Thanks a lot for your help, iam.
  8. Hi guys, Beginner in network programming here, trying to add networking to my simple flight sim game to export avionics to a network computer. I have read on winsock, tried a few things and faced a wall... I can start my server all right, and can get my client to connect to it and receive data, but my problem is as soon as the server starts listening for incoming connections, the game window freezes and I can't do anything with it, not even close the window, I have to ctrl-alt-del to stop execution. I'm pretty sure I know what's happening (its actually obvious!) I use an infinite loop to listen for incoming connection, then once one come in and is accepted, execution resumes. What I want to do is keep listening for incoming connections without hanging the rest of the execution. Creating the server on a different thread seem to be the answer, but before I dive in multi-threading lessons, I wanted some feedback on what is the best way to do what I want to do. I heard about WSAAsyncSelect, which apparently could be another solution. Can anyone give me some advice? Thanks guys!
  9. I feel extremly dumb right now... I checked and rechecked my values but must have had major brain farts while doing this... the define should be: [color="#880000"]#define PRIMITIVE_ZBUFF_MODE_ENTRY [color="#006666"]0x0000F000 0x0000F000 instead of 0x00F00000 Sorry to made you lose your precious time on this Guess why I'm posting in the Beginners forum!
  10. Hi guys. Have the following defines in my header file: #define PRIMITIVE_DONE 0x00000000 //0 #define PRIMITIVE_DOT 0x00000100 //256 #define PRIMITIVE_LINE 0x00000200 //512 #define PRIMITIVE_TEXTURE 0x00008000 //32768 #define PRIMITIVE_ZBUFF_MODE_ENTRY 0x000F0000 //3840 And the following switch case in my code: int iPrimType = *(int *)walker; //iam: retrieving primitive type value, 4bytes switch (iPrimType) { case PRIMITIVE_DONE: sprintf_s(messBuff," PRIMITIVE_DONE @ 0x%08X\n",walker - sizeof(int)); logFile << messBuff; walker += size_PRIMITIVE_DONE; break; case PRIMITIVE_DOT: sprintf_s(messBuff," Type: %08X @ 0x%08X\n",iPrimType,walker - (sizeof(int))); logFile << messBuff; walker += size_Dot; break; case PRIMITIVE_LINE: sprintf_s(messBuff," Type: %08X @ 0x%08X\n",iPrimType,walker - (sizeof(int))); logFile << messBuff; walker += size_Line; break; case PRIMITIVE_TEXTURE: sprintf_s(messBuff," Type: %08X @ 0x%08X\n",iPrimType,walker - (sizeof(int))); logFile << messBuff; walker += size_Texture; break; case PRIMITIVE_ZBUFF_MODE_ENTRY: sprintf_s(messBuff," Type: %08X @ 0x%08X\n",iPrimType,walker - (sizeof(int))); logFile << messBuff; walker += size_ZBuffMode; break default: sprintf_s(messBuff,"Unknown BSP entry @0x%08X",walker)); logFile << messBuff; return; } When iPrimType reads "00 0F 00 00" from my buffer, case "PRIMITIVE_ZBUFF_MODE_ENTRY" is not entered, it jumps to default. Every other case works as expected. If I use "case 3840:" instead of the define, then it works. Can anyone explain that, am I missing something or not using the right type for iPrimType maybe??? I really don't get it. Thanks guys!
  11. Dan and rip-off, thank you VERY much for the extra information! I'll take that into account and do some more research on what you suggested. Cheers!
  12. Nevermind, sprintf_s() is my new friend! Cheers!
  13. What I've tried is really not relevant as I've been trialing and erroring for hours with delirious concepts, until I did some more googling and finally found a way that is almost doing what I want. By using this code, I can get the data in my message buffer as chars: strcpy_s(messBuff, sizeof(messBuff), (char *)&pheader->cVersion); So this code is "reading" from the right memory location and stores the result as chars allright in my buffer. but I'm facing a different problem now. The "sVersion" struct member (see first post for objHeader struct) is an unsigned short, so I was expecting to read only 2 bytes from the address of pheader->sVersion. Problem is, it reads/stores 4 bytes and I don't understand why. Memory look like this at the address of pheader->sVersion: 01 80 03 00 55 00 00 00 I was expcting to get "80 01" in messBuff, but I actually get "00 03 80 01". So why am I reading 4 bytes eventhough sVersion is delcared as an unsigned short ??? When checking this in the debugger: sizeof((char *)&pheader->sVersion), it gives me 4 bytes. When checking sizeof(&pheader->sVersion), it gives me 2 bytes. I'm confused... Any tips? Thanks guys.
  14. Hi guys, Having a hard time figuring this (probably simple) challenge with logging data read from a binary file to a txt file. First I have this struct: struct objHeader{ float fRadius; float fMountingOffsetX; float fMountingOffsetY; float fMountingOffsetZ; ushort sVersion; ushort sColorFormat; } header; Using this code to get the data: objHeader *pheader; pheader = (objHeader *)walker; I can validate that all my struct members have the right values stored in them. Now I'm unable to put any of the struct member into a char buffer to output in a messagebox or to my txt logfile (using strcpy_s or strcat_s), fails with everything I've tried and can't find infromation on what I'm trying to do... I'm doing trials and errors now and hate that. Any tips? Thanks for helping, Fred
  • 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!