• 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
Mozly

Invalid Block type

5 posts in this topic

So I added a new class to my program that has many pointers.

There is nothing wrong until the last line.
I debugged until the point
[code]
return 0;
[/code]
at the end of my main function and I get this error

[img]https://lh4.googleusercontent.com/-lIcLkqX4kGA/TW2Hv85PZKI/AAAAAAAAAB8/ZiS5GtXv1b0/s1600/error.png[/img]


I dont know why it gives me this. Can someone help me solve it.
Thanks.
0

Share this post


Link to post
Share on other sites
Someone else may be able to figure out what's wrong with this information but I can't. Could you maybe post the class declaration/definition?
0

Share this post


Link to post
Share on other sites
[code]
class Button
{
protected:
//add mult brac buttons
SDL_Rect buttons[3];
SDL_Surface* button_image[6];

// plugin button
SDL_Rect Plug_in_button;
SDL_Surface* Plug_in_image[2];

//plugin process
bool Plug_in_process;
SDL_Rect Plug_in_box;

SDL_Rect* Plug_in_variables;
SDL_Surface** variable;
std::string* varstr;

//to cancel the plugin
SDL_Rect cancel;
std::string cancelstr;
SDL_Surface* cancelsur;

//plugin part 2
bool Plug_in_2;
//std::stringstream inputnum;
StringInput inputstr;

//plugin partt3
bool Plug_in_3;


public:
Button();
~Button()
{
for(int q=0; q<6;q++)
{
SDL_FreeSurface(button_image[q]);
}
SDL_FreeSurface(cancelsur);
delete cancelsur;
delete varstr;
delete variable;
delete button_image;
delete Plug_in_variables;
}
std::vector<Digit*> handle_events(std::vector<Digit*> elEquation);

void handle_display();
bool return_plug_in_bool(){return Plug_in_process;}
bool return_plug_in_bool2(){return Plug_in_2;}
bool return_plug_in_bool3(){return Plug_in_3;}

void plug_in_false(){Plug_in_process=false;}
void plug_in_false2(){Plug_in_2 = false; inputstr.reset_input();}
void plug_in_false3(){Plug_in_3 = false;}

//handles the buttons for plgin
void handle_plug_in_display();
void handle_plug_in_buttons();

void handle_plug_in_display2();
void handle_plug_in_buttons2();

void Plug_into(int variable_number)
{
plug_in_false();
Plug_in_2 = true;

//use the first values to hold stuff
varstr[0] = varstr[variable_number];
varstr[0] += "=";
variable[0] = TTF_RenderText_Solid(font,varstr[0].c_str(),fontcolor);
Plug_in_variables[0].w = variable[0]->w;

//center the box
Plug_in_variables[0].x = Plug_in_box.x + (int)((Plug_in_box.w/2)-(Plug_in_variables[0].w/2));



}

void Plug_in_func(std::vector<Digit*> delEquation)
{
//we are now in the process of pluggin in
Plug_in_process = true;

//make some boxes with variables
Plug_in_variables = new SDL_Rect[numofvar];




//as many surfaces as variables
variable = new SDL_Surface*[numofvar];
int *color_positions = new int[numofvar];


//sets the number of strings to number of variables
varstr = new std::string[numofvar];
for(int q=0; q<numofvar; q++)
{
varstr[q] = "";
variable[q] = NULL;
color_positions[q]=0;
}

//compaes to see if we have enough strings
int var_comparator = 0;

//get all the variables
for(int q=0; q< delEquation.size(); q++)
{
if(delEquation.at(q)->returnid()==2) //if its a variable check if it has come up
{
int matches = 0;
for(int w=0; w<numofvar;w++)//check all the initialized strings to see if this one matches a prevoius one
{
if(varstr[w] == delEquation.at(q)->return_svalue())
matches++;
}
if(matches ==0)//if there are no matches it is a new var
{
varstr[var_comparator] = delEquation.at(q)->return_svalue();
color_positions[numofvar]=q;
var_comparator++;
}
}

if(var_comparator == numofvar)//if you have enough variables then break the loop
break;
}

//make some surfaces in the name of the variable
for(int q =0; q<numofvar; q++)
{
variable[q] = TTF_RenderText_Solid(font,varstr[q].c_str(),delEquation.at(color_positions[q])->return_color());
Plug_in_variables[q].h=variable[q]->h;
Plug_in_variables[q].w=variable[q]->w;

}

//set the position of the little boxes
for(int q=0; q<numofvar; q++)
{
Plug_in_variables[q].x = Plug_in_box.x + (int)((2*q+1) * (Plug_in_box.w / (2 * numofvar))-(Plug_in_variables[q].w/2));
Plug_in_variables[q].y = Plug_in_box.y + (int)(Plug_in_box.h / 4);
}

cancelstr = "cancel";
cancelsur = TTF_RenderText_Solid(font,cancelstr.c_str(),fontcolor);
cancel.w = cancelsur->w;
cancel.h = cancelsur->h;
cancel.x = Plug_in_box.x + (int)((Plug_in_box.w/2)-(cancel.w/2));
cancel.y = Plug_in_box.y + (int)(2 * Plug_in_box.h/3);


}

std::vector<Digit*> Plug_in_func2(std::vector<Digit*> delEquation)
{
//finish part 3
plug_in_false3();
plug_in_false2();

//get string input in the format x=
return delEquation;
}
};
[/code]
0

Share this post


Link to post
Share on other sites
I looked into the assertion that was failing and since you said the problem occurs at the end of main that means you are likely double deleting some memory when a global gets destructed. So look into your global variables and try to find out what might be shared between them that is getting deleted 2+ times.
1

Share this post


Link to post
Share on other sites
Thanks, You are right.

It stopped showing the error after I got rid of the all the calls to delete in my destructor.
0

Share this post


Link to post
Share on other sites
[quote name='Mozly' timestamp='1299036712' post='4780819']
Thanks, You are right.

It stopped showing the error after I got rid of the all the calls to delete in my destructor.
[/quote]
That probably happened because you didn't do one of 2 things.
1) drop pointers, and use something like boost::smart_ptr.
2) If you are going to go about it the way you have already, you need to implement operator= and the copy constructor so that you can manually manage the ownership of the pointers.
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