• Content count

  • Joined

  • Last visited

Community Reputation

476 Neutral

About Dom_152

  • Rank
    Advanced Member
  1. You could take a composition approach. Create classes that handle ammo storage, damage/accuracy calculations and whatever else you need for weapons. You then create individual weapon classes that have instances of those basic weapon component classes. This way you can pick and choose which weapon functionality you want for each weapon. It also allows you to easily construct specialisations of any piece of weapon functionality to use in specific weapon classes without having to worry about the effect it has on other weapon classes. 
  2. I'm having an issue using a dialog resource I've created. In the dialog editor it looks like this: [img][/img] And if I set the "Overlapped" style on it, it looks like this when I create it at runtime: [img][/img] But I want this to be a child window so I set the "Child" style on the dialog. However, when I create it at runtime as a child, I get this: [img][/img] As you can see, the button has decided to move itself down and to the right. This also affects other controls as well as buttons. The code I'm using to create it is straight forward: [CODE] HWND window = CreateDialog(RuntimeEnvironment::ModuleInstance, MAKEINTRESOURCE(dialogResource), mMainWindow, WindowHandler::DialogProcedure); ShowWindow(window , SW_SHOW); RECT dialogSize; GetWindowRect(window , &dialogSize); [/CODE] Incidentally, the rectangle I get from the dialog is completely wrong too; it's far too big. Does anyone know of any Windows behaviour that would cause this to occur and if so, how to prevent it?
  3. Object triangle. They all need each other!

    How about having the GamePlay object as an event handler and have the Input object trigger events on the GamePlay object. Then your GamePlay obejct doesn't need to have any knowledge of the Input object at all, it just knows that a method will get invoked when something to do with input happens and that is where it should deal with it. I'm not sure how that fits into the MVC paradigm but I thought I'd share my thoughts. Edit: Another thought: Why must the controller and view be separate? It seems that the Controller would always just be receiving raw input and passing it on; a middleman. In my mind (And it could just be me) it would make more sense for them to be combined so that the "View" is now in charge of taking the raw input, converting it into a form that makes sense to it (i.e. What button has been pressed, is an element being dragged around etc.) and then firing events or generating commands that are then sent to the "Model" which can respond to those events/commands however it wants including modifying the "View" for subsequent use. I understand the value in separating the basic input collection stuff so it can be used for multiple Views but is that really all the "Controller" in this model is supposed to do?
  4. Text Based RPG help

    Why do you have a Monster pointer in game.cpp that you pass into the combatSimulation and rest methods? It's not used anywhere in that game loop and it's value never changes from 0. The new call within the method doesn't change the value of the pointer in game.cpp. When you pass in the Monster pointer it's making a copy of the pointer and putting it on the method's stack and that is what you are manipulating. You might as well just declare it in the combatSimulation method as a local.
  5. I'm not sure but wouldn't you just want to be applying the inverse world matrix to your ray data and not the inverse of a combined world-view matrix? The mesh data shouldn't be in view space at this point as far as I know.
  6. VC++ and the terrible auto completion..

    You could get the express version of VC++ 2010. Oh also if you happen to be a member of the MSDNAA you can get the Ultimate edition of VS2010 for free anyway!
  7. [Win32] ReadFile hangs

    [quote name='Adam_42' timestamp='1297190129' post='4771446'] You might find [url=""]Process Monitor[/url] handy for logging the file related activity in your program. Maybe there's some sort of unexpected error coming back from ReadFile(). That code you posted doesn't seem to have error handling for CreateFile() failing (it will return INVALID_FILE_HANDLE if there's an error). [/quote] Thanks for the tip. I'll look into that Process Monitor.
  8. [Win32] ReadFile hangs

    [quote name='Buckeye' timestamp='1297180194' post='4771379'] [quote]I can try that but would that explain why it would work on some systems and not others?[/quote] Try what, exactly? There are several suggestions. [/quote] Using GetFileType. What would I be checking the high-order DWORD given by GetFileSize for exactly?
  9. [Win32] ReadFile hangs

    [quote name='Buckeye' timestamp='1297178963' post='4771366'] It may not have anything to do with your problem, just good programming practice: you shouldn't mix signed variables with unsigned ( GetFileSize returns DWORD, not int ). Also, you should implement GetFileSize as intended, i.e., provide a second argument rather than using 0, and check the high-order DWORD. Also, you might try checking GetFileType before you get the size or attempt to read, to ensure the remote file type is proper for GetFileSize and ReadFile. [/quote] I don't usually mixed signed and unsigned, I just missed this one! I can try that but would that explain why it would work on some systems and not others?
  10. I have come across a very strange problem when using ReadFile to read in some Bitmap data. [code] HANDLE File = CreateFile(BitmapFileName, FILE_GENERIC_READ, FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); int FileSize = GetFileSize(File, 0); unsigned char *FileData = new unsigned char[FileSize]; int BytesRead; if(!ReadFile(File, FileData, FileSize, reinterpret_cast<LPDWORD>(&BytesRead), 0)) { return false; } [/code] This is the problem code. The problem is that the program will get into ReadFile and then hang such that I am unable to close the program most of the time without restarting the whole machine. The problem only appears to ocurr on the PCs in the labs at my university and only when running it off the local or networked drive. I can run it on these PCs on my flash drive and everything works as it should. It also works fine on my own computer. I have checked error codes and return values and everything is running fine up until the point where it gets stuck. I have also tried setting a timeout period using SetCommTimeouts() but this function is returning an error code of 1 which indicates an "Incorrect Function" (Not sure what that means, really) What is also weird is that [i]sometimes[/i] it will work for, say, the first file I try to load in the program but then fail on subsequent ones. Other times it just fails completley from the off. I'm stumped, anyone have any ideas? Cheers.
  11. I have a problem with the Touch event for actors. I have a pawn with a cylinder component that is positioned in front of it. If I move the player character pawn straight into this trigger zone then Touch is fired. However if I stand still and wait for the other pawn to come to me Touch is not fired despite my player character pawn being very clearly within the other pawn's trigger zone. It seems to me like the collision checks or some physics code is turned off when the player character pawn isn't moving so the intersection with the trigger zone isn't registering. Is this the case or am I way off here? If the former what can be done to solve this issue? [Edited by - Dom_152 on October 20, 2010 11:57:42 AM]
  12. Function pointer mishaps!

    I hadn't thought of that. It's a good idea! Cheers.
  13. Function pointer mishaps!

    I'm trying to see if I can write a function in C++, extract it's machine code at run time and then re-implant said machine code into another executable. The reason being that I had a thought about being able to take a custom script, map each command to a function that implements said command and then outputting a unique executable that is that script in machine code. No real practical reason for this, just an experiment really.
  14. Function pointer mishaps!

    Aha! Well spotted! This makes sense now. This means that I can extract the real address in debug mode by grabbing the JMP instruction stored where FPointer is pointing at. Thanks a lot!
  15. Function pointer mishaps!

    Maybe I am. But I would've thought that the debugger would have made that clear to me. Maybe it's just a feature of function pointers? When I cast "Test" to an integer pointer however I get the same result and I can click the expand icon to see what data is being stored at said address which makes me think that this is not the address of the pointer itself if that makes sense! EDIT: I'll try and illustrate what I'm talking about there: So you see how an integer pointer results in the same pattern and I can see the data that it is pointing to (0x000351e9) as well as where this data is stored (0x00f4100a) EDIT 2: I've also noticed that the address my FPointer is pointing to always seems to end in 100a. Probably coincidence though.