Jump to content

  • Log In with Google      Sign In   
  • Create Account

kseh's blog



RPG Project - Post 6

Posted by , 22 March 2013 - - - - - - · 852 views

Added some collision detection style logic to help better plan tree placement. Went from randomly planting around 57k trees to create an impassible forest to using only 39k trees for the same effect. Also found some settings that will be good for thinner forests when I start looking into adding more variety in the terrain.

Added in some serialization code so that I can save and load the world. So far the file size in total to recreate the world is a bit under 10Mb.

A few weeks ago, the host that I've been using for my website was having some issues with the data center they've been using. The center just up and vanished. Thankfully, anything I had up there I do have backups of. But rather than just put what I had back up I figured I'd try something a little more modern and went with the Wordpress package that's available. I think it generally looks alright but I still need to get a project details page and some sort of page for downloads going.

In the mean time, I imported the 'detailed developer notes' for this RPG project from day 1 to the site. I don't think I'll be uploading notes everyday but more likely to do batch loads every so often.

Current development is on the stuff that I was working on just before I got distracted with the memory leak. I'm trying to get things going such that when you press space a sort of 'swoosh' appears like you're swinging something. If that swoosh hits a tree then I think you should see a sort of 'strike' effect that'd be like a little star or something, and the tree will be chopped down providing you with wood to work with. What I have going so far doesn't look right, I think, because I'm not detecting the collision between the swoosh and the tree quite right. Probably has something to do with the code being an over all mess which is something else I need to work on before it gets completely out of control.

So, not really anything new to show off but I thought I'd include a screenshot anyways and with the excuse interesting new detail to show being that I changed the look of the winter trees slightly. I'm hoping that when I start adding in critters my programmer art skills will manage something that fits with the style.

Attached Image

I believe I've found a way to deal with the flicker issue. It needs a little fine tuning yet but I like what I've come up with and it means that ultimately what you see in the screenshot will be what you get. Essentially, I'm dealing with it by not dealing with it. Assuming that I'm able to get this tree chopping thing all sorted out, I'll include a video in my next post.


RPG Project - Post 5

Posted by , in RPG Project 08 March 2013 - - - - - - · 713 views

Memory leaks have pretty much been at the center of my focus for this project for the past few weeks. There really isn't a lot that's interesting to post about while trying to hunt these things down. And up until about two days ago, the only posts I would've been making would've been appeals for help and possibly questioning the help offered. I had thoughts of just living with the leaks and hoping they don't cause problems down the road or abandoning the project entirely. But now, I'm glad I stuck to it and found the bugger that was giving me issues.

Don't know if anyone will find any of this interesting but I figure I might as well take the opportunity to vent about the non-sense my own code inflicted upon myself.

The line where the error would occur was

CSwooshEffect * pItemTemp = new CSwooshEffect;

From this line I experienced weeks of being confronted with "Windows has triggered a breakpoint in [program].exe". Google searches that all pretty much say the same thing when other people ask about it, "You're probably writing to memory that's already been freed." I figured I'd get about the same response if I posted a question here or anywhere so I began painstakingly started going through code to try to find such a situation. I plugged in Paul Nettle's MMGR code into my project which helped find the source of a bunch of leaks. But after fixing them, that damn message still came up even though the leak report came back "No memory leaks found!" Clearly I didn't really have them all. But I just couldn't understand it. All I was doing was instantiating a new object, how could that be writing to memory that's been freed?

Trying to battle that one message resulted in me rewriting my animation class that I've been using for almost a decade now, it resulted in finding 2 other locations causing leaks, revealed that I forgot to change some code for a few objects so they're created using new() instead of being members of another class, it resulted in the realization that some sorts I'm doing on my object lists weren't sorting correctly. I found a variety of things I was doing wrong and yet despite all that the message wouldn't go away.

As fascinating as I'm sure all this is, I'll skip ahead now to where the problem finally was. (my dev notes have the details of how I came to this point, I can post them if anyone's interested but I'll skip ahead).

I keep a few lists that are used to track instances of objects. I was investigating a tile's list of objects and comparing it to a main list of objects. Checking that an object was being created and being properly set to the tile's list of objects. I wanted to make sure that everything was the same when that object's pointer later got removed from the tile's list and the object deleted. The object itself was indeed the same however completely by chance I noticed that the tile that I thought was working with wasn't actually the one I was working with. It all went a little something like this:

- From my main list I'd determine which object required deletion.
- Using the object's world co-ordinates I'd calculate what tile that object was associated with.
- This calculation was producing a rounding error causing me to look at the wrong tile's object list.
- The wrong list of objects isn't actually affected.
- The object is removed from the main list.
- The object is finally deleted from memory.
- The tile with the list that should have been examined now has a pointer in it pointing to freed memory.

That memory gets accessed later on in my paint routine. Undefined behavior due to accessing invalid memory sounds like an appropriate description of the trouble I've been having.

I dealt with the problem by adding the tile co-ordinates that the object is on to that object. Not terribly creative but it got the job done.

This annoying issue has taken so much attention I don't know what's next now.





March 2013 »

S M T W T F S
     12
3456789
10111213141516
17181920212223
24252627282930
31      

Recent Entries

Recent Comments

Latest Visitors



PARTNERS