so im making a linked list for my map maker but when i run it none of my other code executes, if i use a break point, then i get an error and it asks me to find the source for "new" but idk what im doing wrong.
map.h
#include <iostream>
using namespace std;
class data
{
public:
int id;
int x;
int y;
int block;
int flag_1;
int flag_2;
int flag_3;
int flag_4;
int flag_5;
};
class node
{
public:
data d;
node *n;
node *l;
};
class map
{
public:
map();
~map();
void setX(int x);
void setY(int y);
void setFlag(int nFlag, int vFlag);
int get_x();
int get_y();
int get_block();
int get_id();
int get_flag(int flag_id);
void next();
void last();
private:
node* root;
node* cond;
int cur_id;
};
//setup list
map::map()
{
//make a root and current node and initialize pointers
root=new node;
root->d.id=0;
root->l=NULL;
root->n=new node;
cond=root->n;
cond->d.id=1;
cond->n=NULL;
cond->l=root;
cur_id=2;
};
map::~map()
{
//prepare to delete all nodes
cond=root->n;
while(cond->n!=NULL)
{
delete root;
root=cond;
cond=cond->n;
}
delete cond;
if(root!=NULL) delete root;
cond=NULL;
root=NULL;
}
//next & last
void map::next()
{
if(cond->n==NULL)
{
cond->n=new node;
cond->n->l=cond;
cond=cond->n;
cond->d.id=cur_id;
cur_id++;
}
else
{
cond=cond->n;
}
};
void map::last()
{
if(cond->l!=root)
{
cond=cond->l;
}
else
{
}
};
//set functions
void map::setX(int x)
{
cond->d.x=x;
};
void map::setY(int y)
{
cond->d.y=y;
};
void map::setFlag(int nFlag, int vFlag)
{
switch(nFlag)
{
case 1:
cond->d.flag_1=vFlag;
break;
case 2:
cond->d.flag_2=vFlag;
break;
case 3:
cond->d.flag_3=vFlag;
break;
case 4:
cond->d.flag_4=vFlag;
break;
case 5:
cond->d.flag_5=vFlag;
break;
default:
break;
}
};
//get functions
int map::get_block()
{
return cond->d.block;
};
int map::get_flag(int flag_id)
{
switch(flag_id)
{
case 1:
return cond->d.flag_1;
break;
case 2:
return cond->d.flag_2;
break;
case 3:
return cond->d.flag_3;
break;
case 4:
return cond->d.flag_4;
break;
case 5:
return cond->d.flag_5;
break;
default:
return -1;
break;
}
};
int map::get_id()
{
return cond->d.id;
};
int map::get_x()
{
return cond->d.x;
};
int map::get_y()
{
return cond->d.y;
};
main.cpp
#include "DarkGDK.h"
#include "text.h"
#include "map.h"
#include <fstream>
using namespace std;
//functions
OPENFILENAME ofn; // common dialog box structure
OPENFILENAME lpofn;
char szFile[260]; // buffer for file name
char ozFile[260];
HWND hwnd; // owner window
HANDLE hf; // file handle
//functions
bool vdSaveFileDialog()
{
// Initialize OPENFILENAME
ZeroMemory(&ofn, sizeof(lpofn));
lpofn.lStructSize = sizeof(lpofn);
lpofn.lpstrFile = szFile;
// Set lpstrFile[0] to '\0' so that GetOpenFileName does not
// use the contents of szFile to initialize itself.
lpofn.lpstrFile[0] = '\0';
lpofn.nMaxFile = sizeof(szFile);
lpofn.lpstrFilter = "Text-File\0*.txt\0";
lpofn.nFilterIndex = 1;
lpofn.lpstrFileTitle = NULL;
lpofn.nMaxFileTitle = 0;
lpofn.lpstrInitialDir = NULL;
lpofn.Flags = NULL;
// Display the Open dialog box.
if (GetSaveFileName(&lpofn)) return true;
return false;
}
bool vdOpenFileDialog()
{
// Initialize OPENFILENAME
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.lpstrFile = ozFile;
// Set lpstrFile[0] to '\0' so that GetOpenFileName does not
// use the contents of szFile to initialize itself.
ofn.lpstrFile[0] = '\0';
ofn.nMaxFile = sizeof(szFile);
ofn.lpstrFilter = "Text-File\0*.txt\0";
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = NULL;
ofn.nMaxFileTitle = 0;
ofn.lpstrInitialDir = NULL;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
// Display the Open dialog box.
if (GetOpenFileName(&ofn)) return true;
return false;
}
char* vdGetOpenFileDialog()
{
return ozFile;
}
char* vdGetSaveFileDialog()
{
return szFile;
}
//create text handler
CText t;
// the main entry point for the application is this function
void DarkGDK ( void )
{
//map data
map m;
// setup screen
dbSyncOn ( );
dbSyncRate ( 60 );
dbSetDisplayMode(604,453,32);
//variables
char buffer[256];
char *filename="None";
bool layer_1=1;
bool layer_2=0;
bool layer_3=0;
//initialize text
CText::InitTextOnce();
t.SetFont("Arial",8,0,0);
t.SetTextColor(255,255,255,255);
//draw background
dbLoadImage("Media/background.PNG",1);
dbLoadImage("Media/empty.PNG",2);
dbLoadImage("Media/block.PNG",3);
dbLoadImage("Media/warp.PNG",4);
int x=1;
//make sprites
while(x<=300)
{
dbSprite(x,1,1,2);
}
dbPasteImage(1,0,0);
// our main loop
while ( LoopGDK ( ) )
{
//reposition grid
// update the screen
dbPasteImage(1,0,0);
//update title screen
dbSetWindowTitle(filename);
//paste text
t.StartText();
sprintf(buffer,"MouseX: %i MouseY: %i ScreenFPS: %i " , dbMouseX(),dbMouseY(),dbScreenFPS());
t.TextOutA(170,430,ALIGN_LEFT,buffer);
//draw menu buttons
sprintf(buffer,"New Save Load");
t.TextOutA(2,2,ALIGN_LEFT,buffer);
if(layer_1==1)
{
t.SetTextColor(255,0,0,255);
t.TextOutA(112,2,ALIGN_LEFT,"Layer 1");
t.SetTextColor(255,255,255,255);
t.TextOutA(160,2,ALIGN_LEFT,"Layer 2");
t.TextOutA(210,2,ALIGN_LEFT,"Layer 3");
}
else
{
if(layer_2==1)
{
t.TextOutA(112,2,ALIGN_LEFT,"Layer 1");
t.SetTextColor(255,0,0,255);
t.TextOutA(160,2,ALIGN_LEFT,"Layer 2");
t.SetTextColor(255,255,255,255);
t.TextOutA(210,2,ALIGN_LEFT,"Layer 3");
}
else
if(layer_3==1)
{
t.TextOutA(112,2,ALIGN_LEFT,"Layer 1");
t.TextOutA(160,2,ALIGN_LEFT,"Layer 2");
t.SetTextColor(255,0,0,255);
t.TextOutA(210,2,ALIGN_LEFT,"Layer 3");
t.SetTextColor(255,255,255,255);
}
else
{
layer_1=1;
t.SetTextColor(255,0,0,255);
t.TextOutA(112,2,ALIGN_LEFT,"Layer 1");
t.SetTextColor(255,255,255,255);
t.TextOutA(160,2,ALIGN_LEFT,"Layer 2");
t.TextOutA(210,2,ALIGN_LEFT,"Layer 3");
}
}
t.EndText();
//now check for clicks for menu buttons
if(dbMouseClick())
{
//check for menu clicks
//new button
if(dbMouseX()>=2 && dbMouseX()<=24 && dbMouseY()>=2 && dbMouseY()<=14)
{
//new button Clicked
}
else
{
if(dbMouseX()>=35 && dbMouseX()<=60 && dbMouseY()>=2 && dbMouseY()<=14)
{
//Save button Clicked
vdSaveFileDialog();
filename=vdGetSaveFileDialog();
}
else
{
if(dbMouseX()>=75 && dbMouseX()<=102 && dbMouseY()>=2 && dbMouseY()<=14)
{
//Load button Clicked
vdOpenFileDialog();
filename=vdGetOpenFileDialog();
}
}
}
//Begin Layer Button Checks
if(dbMouseX()>=112 && dbMouseX()<=148 && dbMouseY()>=2 && dbMouseY()<=14)
{
layer_1=1;
layer_2=0;
layer_3=0;
}
else
{
if(dbMouseX()>=160 && dbMouseX()<=197 && dbMouseY()>=2 && dbMouseY()<=14)
{
layer_1=0;
layer_2=1;
layer_3=0;
}
else
{
if(dbMouseX()>=210 && dbMouseX()<=246 && dbMouseY()>=2 && dbMouseY()<=14)
{
layer_1=0;
layer_2=0;
layer_3=1;
}
}
}
}
//refresh screen
dbSync ( );
}
// return back to windows
return;
}
Show me your combat algorithms(programmers read this NOT in a programming state of mind)