Original Post
Alright, doing a map editor here using C++ and MFC.
The following code is causing me a problem. BTW I am still pretty new to C++.
void CNZViewMapProperties::SetActiveMap(MAP* mapptr)
{
if(mapptr != NULL)
pMap = mapptr;
if(mapptr->GetMapName() == NULL)
::MessageBox(NULL, "I get it", "Error", MB_OK);
::MessageBox(NULL, mapptr->GetMapName(), "Map Name", MB_OK);
}
The above code doesnt do much. It prints out a stupid message if GetMapName is NULL otherwise prints out the map name. Its a test.
What surprises me is that the following code doesn''t error out.
void CNZViewMapProperties::SetActiveMap(MAP* mapptr)
{
if(mapptr != NULL)
pMap = mapptr;
if(mapptr->GetMapName() == NULL)
::MessageBox(NULL, "I get it", "Error", MB_OK);
/*
::MessageBox(NULL, mapptr->GetMapName(), "Map Name", MB_OK);
*/
}
And Finally, here is the runtime error I am getting.
Unhandled exception at 0x77d5d231 in NZEdit.exe: 0xC0000005: Access violation reading location 0xfdfdfd00.
Sounds like a memory access violation to me, but I cannot figgure out why. The pointer that is passed to the function SetActiveMap is passed from and used in a CDocument class which manages the map. The GetMapName() function also works as predicted in teh CDocument class.
Will Reynard