Jump to content

Rick

Members
  • Posts

    7,936
  • Joined

  • Last visited

Everything posted by Rick

  1. This probably better shows what I'm wanting. Actor is created in main and passed to Projectile. It's then destroyed in main, but we need a way to tell projectile that it's destroyed and to not use it. By using a pointer to a pointer and checking what it's pointing to is NULL (because I set 'a' to NULL after deleting what it was pointing to) allows me to do this. If I just passed the original pointer I would have no way of knowing the actor was deleted and so I shouldn't call any members of it. The reason I need to do this is because I can have 5 projectiles all moving towards this actor. When one of them hit it, it'll kill the actor which will then be deleted invalidating all the other targets for the remaining 4 projectiles. I want the actor to die and be deleted instantly, so this raised a problem because the other 4 projectiles no don't have a valid target. I get around this by setting a pivot to the target's location AS LONG AS the target is valid. However just checking a regular pointer wasn't working because the pointer in projectile to the actor wasn't NULL, it was still pointing to the same memory location which now has garbage in it. class Actor { private: int i; public: Actor() { i = 50; } void Increase() { i++; } }; class Projectile { private: Actor** _actor; public: Projectile(Actor** actor) { _actor = actor; } void Update() { if((*_actor)) (*_actor)->Increase(); } }; int _tmain(int argc, _TCHAR* argv[]) { Actor* a = new Actor(); Projectile p(&a);; delete a; a = NULL; p.Update(); return 0; } In this example it gives me what I want. Trying to translate it to my game doesn't seem to give me what I want yet. hmmm
  2. This example is to confusing because of variables used (2 a's) and all done in main. Writing another one up that will be easier to talk about
  3. But that's what I want right. I want the pointers memory location (hence pointer to a pointer) so that when that gets set to NULL after I deleted what it was pointing to, I can then check the pointers memory location against NULL to tell me what it's pointing to has been deleted. This example doesn't show 100% why I want that because it's checking the NULL in the main function and I could just check 'a' for null there, BUT let's say I was checking for NULL inside the projectile class. The NULL check would always pass even if I deleted a in the main function (if I didn't use a pointer to a pointer). So from other classes the fact that the pointer to the pointer is NULL is telling me that what it was pointing to was deleted and I should not call anything with it.
  4. Nice pic mumbles! Yeah what you have there is exactly what's happening. I'm going to use a pointer to a pointer and check against NULL with that. Tested it out in a smaller app and that seems to work. I don't want a smart pointer because sounds like as long as there are references to it it'll stay alive, but I need my actor dead the moment I call delete on it even if other classes have it. With pointer to pointers I can check against that original pointer memory itself for NULL instead of what it was pointing to. class Actor { public: Actor() { i = 50; } int i; }; class Projectile { public: Actor** a; }; int _tmain(int argc, _TCHAR* argv[]) { Actor* a = new Actor(); Projectile p; p.a = &a; delete a; a = NULL; // it won't get inside this check because it's NULL which is what I'm looking for if((*p.a)) { int test; test = (*p.a)->i; } return 0; }
  5. Maybe I need to look into shared_ptr's or a pointer to a pointer when passing these around.
  6. I'm looking at some old tower defense code I had and ran into a problem and was hoping someone could maybe help me out. I have an Actor class which has a model entity in it. I also have a Projectile class that stores a pointer to an Actor as it's target. The Update() method of the Projectile class gets the actors position via it's model and moves towards it. What can happen though is that the actor object can be killed while the projectile is moving towards it. I only delete actors in 1 spot in where I use: delete actor; actor = NULL; In my projectile Update() method I do NULL checks against the target actor but it seems to pass these checks and go into an LE function where the model is a <bad ptr> and bomb out. I'm deleting these actors and setting them to NULL (and in the destructor I free the model and set it to NULL) so not sure if I'm missing something. When the error happens and it breaks in the code I notice the target pointer address is still 0x0c917030. All the variables in the class are filled with garbage (not the actual values they were filled with) so it's like it's sort of deleting the class but doesn't fully set the pointer of the class to NULL and so it passes the if(_target) check. I can tell all of this when I mouse over it in VS. If it's truly NULL I would think it would just say NULL and not give all the details about the variables in the class so it leads me to believe it's not truly getting deleted, but besides calling the delete statement on it and setting to NULL I'm not sure what else to do. The code is long and complex, but any general tips around deleting objects and why they might not get "fully" deleted?
  7. Nevermind I found it. Had a list for debugging of these actors and deleted the object in one place but it was still in this list so looping over it and calling it's method's wasn't failing which is odd, but all better now.
  8. Never had this error before but getting: It happens, not always, after I'm deleting an enemy unit from a tower defense game so I must be messing something up. However finding this bad boy is proving to be annoying. Anyone have any tips on how to find such a bug? Maybe some diagnostics tool to help? It shows me a break or continue button and it does actually allow me to continue but I usually get it again and again but each time it allows me to continue.
  9. Rick

    1.#QNAN error

    OK now I'm not getting it. hmmm. Will keep checking.
  10. Rick

    1.#QNAN error

    The only ScaleEntity() command in the entire project is on the weapon model in first person. The very first frame the values are correct, then after that is when I get the 1.#QNAN so that's interesting.
  11. Rick

    1.#QNAN error

    TVec3 rick = EntityPosition(camera); cout << "camera pos " << rick.X << "," << rick.Y << "," << rick.Z << endl; In debug mode I get valid numbers. In release mode I'm seeing 1.#QNAN. Any ideas why that would be happening?
  12. I agree it's unplayable right now. I've been away from the project for a month or so preparing and then having our second child so I've missed some of the later development of the game. I'm working on the errors that were found but my time is still limited. I've found the crash on exit bug, the first one I looked at, and will find the others. We will keep the thread updated. Thanks for your patience.
  13. Trying to compile, and can't find batHit01.ogg - batHit03.ogg. I assume these were never added to SVN? I agree with Shadmar, everything on SVN is the ideal way to go.
  14. From what I can tell most people use C++ or BMax around here. Lua is becoming more popular but (I think) because of LE2's poor Lua IDE/debugger, larger Lua projects are harder to manage. I have a few fairly large Lua projects I was working on and it can get hard to follow fast. One little typo error could mean hours of finding out what's wrong because LE2 doesn't give you any real meaningful error message. Without the nice features of IDE's like Visual Studio (proper debugging being a big one) large Lua projects in LE2 are just too painful. LE3 looks to really help Lua with LE development though, so really excited for that! Again, a lot of this is all about preference though.
  15. Shadmar how familiar are you with OOP? If you don't really know it, then it'll seem complicated. Especially when you get into virtual functions and if you don't know how they work. The idea with most of the games with C++ is that you load your scene and any object/model that needs functionality is assigned to a class object and then most everything is done via that class objects. All variables and methods for that object can be done by that class. I think MidnightSalsa got a little more complicated when we started mixing Lua and C++ myself. Now you have to look in 2 places to see the functionality instead of just 1 even for the same object possibly. I think this happened because of what the people we had were more comfortable with. When we first started the coders were more comfortable with C++. Later some of the programmers we got were more comfortable with Lua so things started to shift. We were in a situation where beggars couldn't be choosers though so we took what we could to keep things moving forward.
  16. That looks really nice. Are we by chance able to mouse over a variable to see it's value?
  17. Not sure if it's the same but I had a similar issue when I had a group of controllers chasing an object. When they would start to bunch together once they reached their goal the fps would just die. Josh seemed to acknowledge the issue and said he thought he knew what it was but then he went silent. http://www.leadwerks..._hl__controller
  18. Rick

    shadow distance

    Thanks Athos. SetShadowDistance() is probably the command but when I use it in C++ it doesn't work, but I set it from the editor and it's working now. Clearly doing something wrong on the C++ side, but it works from the editor so all good. Thanks!
  19. I have a FOV of 15. My terrain is at the default level. I have 1 directional light. My camera is at (1, 75, -57). The models on my terrain aren't casting any shadows and I would like them to do so. After I load my scene I loop through each entity in the scene and set the shadow range to a large number but it doesn't seem to show them still. How can I get the shadows to show in my above situation? childCount = CountChildren(scene); for(i = 1; i <= childCount; i++) { entity = GetChild(scene, i); EntityShadowRange(entity, 50000); }
  20. Hey Roland is there some doc around how to create a template? I love LEBuilder and would love to make my own template that is more object oriented and more of a game template with classes like Actor, Animation, etc to share. Would that be possible with your LEBuilder program to do? I feel like some people might enjoy having a game template setup for them.
  21. There really isn't anything LE specific about classes. LE 2 isn't object oriented so it's not as if you are deriving from anything. The person would just have member variables that are LE types that they would want to put into the class. That could be done a million different ways. I don't think this will help much but: class Actor { private: TModel _model; string _name; int _hp; public: virtual void Update()=0; }; I don't have the ctor there, but trying to show you that the class itself isn't related to LE at all. The members inside of it can be LE data types but how you do it is completely up to the individual.
  22. I could give you an example but if you are at the point of wondering how to setup a skeleton class you might want to follow some C++ class tutorials. You'll probably get more from them.
  23. Win 7 32 bit here. For about 2 mins I saw The Village.exe process at 50% cpu with the memory jumping around. Right now it's at 0 CPU and I see nothing. No window of the game has came up. I right clicked the process and did properties, then I saw the window come up but it was all white. Shortly after I got the "Program has stopped working" error. I moved the exe from the downloads folder to my desktop.
  24. HANDLE hFind; WIN32_FIND_DATA data; hFind = FindFirstFile("c:\\*.*", &data); if (hFind != INVALID_HANDLE_VALUE) { do { printf("%s\n", data.cFileName); } while (FindNextFile(hFind, &data)); FindClose(hFind); } Found from http://stackoverflow...-directory-in-c
×
×
  • Create New...