• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
ankhd

Stack overflow help needed

6 posts in this topic

Hello all.

 

Im getting a stack over flow in this line of code or I think it is.

DWORD GetOwnerPlayerID(void)

{

        (OwnerObj == NULL)

                return -1;

       return OwnerObj->GetOwnerPlayerID();

}//no owner

 

if ownerobj is the same object would this be the cause, I think it is

but the codes been running for month and tonight it crashed on that line

I cant believe I did that hehe. and its been running since  29.1.13 is when I created the class lol

 

 

0

Share this post


Link to post
Share on other sites

Apparently DWORD is unsigned, which would mean your return -1; ends up as some huge integer value.

Not sure if that is the problem though, but could be.

1

Share this post


Link to post
Share on other sites

More info would be helpful. If OwnerObj is a member of the same class which implements GetOwnerPlayerID, then try this (simple cycle detection):

DWORD GetOwnerPlayerID(void)

{

 if (OwnerObj == NULL)

                return -1;


       if (OwnerObj == this) {
   printf("ERROR: cycle detected for object %s !", OwnerObj->getName());
}


       return OwnerObj->GetOwnerPlayerID();

}//no owner


Thought there could be non trivial cycles: A->B->C->A...

 

You can also do non-trivial cycle check by having two pointers that you trace:

 

You have Pointer A and Pointer B.  For each step, advance Pointer A once, advance Pointer B twice.

 

If the advances are under same conditions, they will meet sooner or later if there is a cycle.  Of course a bit more involving than the method Ashaman73 proposed, but may be a desperate last resort.

 

Using Ashaman73's example:

A->B->C->A

 

Step 1: Pointer A = A, Pointer B = B

Step 2: Pointer A = B, Pointer B = A

Step 3: Pointer A = C, Pointer B = C = Yes, there is a cycle.

1

Share this post


Link to post
Share on other sites

this object is my explosion object and it has no owner I set it to the explosion object it self  by mistake.

 

Im going to put        if (OwnerObj == this) { printf("ERROR: cycle detected for object %s !", OwnerObj->getName());  in. turns out to be the case

 

one of the projectiles must of polled all cell objects and at the time it picked the explosion object to see if it was a enermy object and called it self over and over.

 

Im going to remove the explosion objects ID I'll return -1;

 

DWORD = -1; = max amount a DWORD can hold I do a bound check on the returned value like this

DWORD error = -1;

if(ID == error)

   do error code; is this not a good Idea the ID will never get to this amount I only need about 8000 IDs thats 8000 units running around 1000 per player

 

I can't believe that it only buged out now after all this time thats been in the code and I ran it many times shooting and all.

 

Im just lucky VC pointed to the code that overflowed.

 

 

the code is like this

cExplosion *explosion = GetFreeExplosionObj();// this is a pool of explosion object pre allocated

 

if(explosion == NULL)

         return false;//error none free

 

 

//see if we can get some particles

 

//add the explotion

UINT error = -1;

UINT CurrentExplosionElement = explosion->GetFreeParticleDataElement();

 

if(CurrentExplosionElement == error)

          return false;//no particles to use maybe next time

 

 

 

 

explosion->InUse = true;//so we dont reuse it

explosion->m_vPos = worldpos;

explosion->OwnerObj = explosion;//bad on my part don't know what I was thinking at the time

 

and when a projectile is fired it checks the cells it travels though for object IDs and if there not allies it explodes and adds a explosion object.

 Thanks everyone for the help.

0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0