ccess violation reading location 0x0000000c When Running Code

I've started creating mods for an open source game titled Liberal Crime Squad and have come across a error that I can not bypass. Every time I debug the program I get "Unhandled exception at 0x773615de in crimesquad.exe: 0xC0000005: Access violation reading location 0x0000000c" from my research I have come to the conclusion that it has something to do with a pointer. The code modifies the interrogation setting to allow the player to release hostages, I've used the Kill code since it's similar to the Free code. I've tried switching the names of the two functions and yet the modified code intended for releasing still works when it is switched to kill but the code meant to kill doesn't work for Freeing. Also the code works fine if the target is freed and the Kill function still works.

Below is the main area of my code. I added the TECHNIQUE_FREE, changed all the parts that say for(int I = 0; I < 7; (originally 6) I++) and bool techniques[6].
Interrogation.cpp (whole):

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121

if(techniques[TECHNIQUE_FREE]) //Free the Hostage
		{
         
		 erase();
         set_color(COLOR_WHITE,COLOR_BLACK,1);
         move(0,0);
         addstr("The Final Education of ", gamelog);
         addstr(cr->name, gamelog);
         addstr(": Day ", gamelog);
         char num[20];
         itoa(cr->joindays,num,10);
         addstr(num, gamelog);
         gamelog.newline();

         a=NULL;

         for(int i=0;i<temppool.size();++i)
         {
            if((int)LCSrandom(50)<temppool[i]->juice||
               LCSrandom(9)+1>=temppool[i]->get_attribute(ATTRIBUTE_HEART,0))
            {
               a=temppool[i];
               break;
            }
         }

         if(a)
         {
            //delete interrogation information
            delete reinterpret_cast<interrogation*>(cr->activity.arg);
            set_color(COLOR_MAGENTA,COLOR_BLACK,0);
            cr->die();
            move(y,0);y++;
            addstr(a->name, gamelog);
            addstr(" releases ", gamelog);
            addstr(cr->name, gamelog);
            addstr(" by ", gamelog);
            switch(LCSrandom(5))
            {
               case 0:addstr("opening the door.", gamelog);break;
               case 1:addstr("kicking it to the curb.", gamelog);break;
               case 2:addstr("setting it into the wild.", gamelog);break;
               case 3:addstr("tossing it into the trash.", gamelog);break;
               case 4:addstr("walking it to a undisclosed location.", gamelog);break;
            }
			refresh();getch();
			if(LCSrandom(a->get_attribute(ATTRIBUTE_WISDOM,false))<LCSrandom(3))
            {
               gamelog.newline();
               set_color(COLOR_GREEN,COLOR_BLACK,1);
               move(y,0);y++;
               addstr(a->name, gamelog);
               addstr(" feels glad it had a peacful resolution and ", gamelog);
               a->adjust_attribute(ATTRIBUTE_HEART,-1);
               move(y,0);y++;
               switch(LCSrandom(4))
               {
                  case 0:addstr("throws a big party.", gamelog);break;
                  case 1:addstr("has a victory toast.", gamelog);break;
                  case 2:addstr("lays down and takes a long nap.", gamelog);break;
                  case 3:addstr("goes out to the clubs.", gamelog);break;
               }
            }
            else if(!LCSrandom(3))
            {
               gamelog.newline();
               set_color(COLOR_CYAN,COLOR_BLACK,1);
               move(y,0);y++;
               addstr(a->name, gamelog);
               addstr(" grows warmer.", gamelog);
               a->adjust_attribute(ATTRIBUTE_HEART,+2);
            }
		 }
			else      
         {
            set_color(COLOR_YELLOW,COLOR_BLACK,0);
            move(y,0);y++;
            addstr("There is no one able to get up the nerve to ", gamelog);
            move(y,0);y++;
            addstr("execute ", gamelog);
            addstr(cr->name, gamelog);
            addstr(" in cold blood.", gamelog);
            gamelog.nextMessage();

            //Interrogation will continue as planned, with
            //these restrictions:
            techniques[TECHNIQUE_TALK]=0; //don't talk to them today
            techniques[TECHNIQUE_BEAT]=0; //don't beat them today
            techniques[TECHNIQUE_DRUGS]=0; //don't administer drugs

            //Food and restraint settings will be applied as normal
			}
         //show_interrogation_sidebar(cr,a);
         refresh();
         getch();
         set_color(COLOR_WHITE,COLOR_BLACK,0);
         move(24,0);
         addstr("Press any key to reflect on this.");
         refresh();
         getch();
		 
		 if(cr->alive==0)
         {
            for(int p=0;p<pool.size();p++)
            {
               if(!pool[p]->alive)continue;
               if(pool[p]->activity.type==ACTIVITY_HOSTAGETENDING)
               {
                  if(pool[p]->activity.arg==cr->id)
                  {
                     pool[p]->activity.type=ACTIVITY_NONE;
                  }
               }
            }
            delete[] _attack;
            return;
		 }
	   }  



includes.h:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
struct interrogation
{
   interrogation() : druguse(0)
   {
      techniques[0]=1;
      techniques[1]=1;
      techniques[2]=0;
      techniques[3]=0;
      techniques[4]=0;
      techniques[5]=0;
      techniques[6]=0; /// Added this one
   };

   bool techniques[6]; //Changed to 7 then 6

   int druguse; //total days of drug use

   //Maps individual characters to the rapport built with them
   map<long,struct float_zero> rapport;
};


Kill Code: (forgot, sorry)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
       
       if (techniques[TECHNIQUE_KILL]) // Kill the Hostage
      {
         erase();
         set_color(COLOR_WHITE,COLOR_BLACK,1);
         move(0,0);
         addstr("The Final Education of ", gamelog);
         addstr(cr->name, gamelog);
         addstr(": Day ", gamelog);
         char num[20];
         itoa(cr->joindays,num,10);
         addstr(num, gamelog);
         gamelog.newline();

         a=NULL;

         for(int i=0;i<temppool.size();++i)
         {
            if((int)LCSrandom(50)<temppool[i]->juice||
               LCSrandom(9)+1>=temppool[i]->get_attribute(ATTRIBUTE_HEART,0))
            {
               a=temppool[i];
               break;
            }
         }

         if(a)
         {
            //delete interrogation information
            delete reinterpret_cast<interrogation*>(cr->activity.arg);
            set_color(COLOR_MAGENTA,COLOR_BLACK,0);
            cr->die();
            stat_kills++;
            move(y,0);y++;
            addstr(a->name, gamelog);
            addstr(" executes ", gamelog);
            addstr(cr->name, gamelog);
            addstr(" by ", gamelog);
            switch(LCSrandom(5))
            {
               case 0:addstr("strangling it to death.", gamelog);break;
               case 1:addstr("beating it to death.", gamelog);break;
               case 2:addstr("burning photos of Reagan in front of it.", gamelog);break;
               case 3:addstr("telling it that taxes have been increased.", gamelog);break;
               case 4:addstr("telling it its parents wanted to abort it.", gamelog);break;
            }
            //show_interrogation_sidebar(cr,a);
            refresh();getch();
            if(LCSrandom(a->get_attribute(ATTRIBUTE_HEART,false))>LCSrandom(3))
            {
               gamelog.newline();
               set_color(COLOR_GREEN,COLOR_BLACK,1);
               move(y,0);y++;
               addstr(a->name, gamelog);
               addstr(" feels sick to the stomach afterward and ", gamelog);
               a->adjust_attribute(ATTRIBUTE_HEART,-1);
               move(y,0);y++;
               switch(LCSrandom(4))
               {
                  case 0:addstr("throws up in a trash can.", gamelog);break;
                  case 1:addstr("gets drunk, eventually falling asleep.", gamelog);break;
                  case 2:addstr("curls up in a ball, crying softly.", gamelog);break;
                  case 3:addstr("shoots up and collapses in a heap on the floor.", gamelog);break;
               }
            }
            else if(!LCSrandom(3))
            {
               gamelog.newline();
               set_color(COLOR_CYAN,COLOR_BLACK,1);
               move(y,0);y++;
               addstr(a->name, gamelog);
               addstr(" grows colder.", gamelog);
               a->adjust_attribute(ATTRIBUTE_WISDOM,+1);
            }
            gamelog.nextMessage();
         }
         else
         {
            set_color(COLOR_YELLOW,COLOR_BLACK,0);
            move(y,0);y++;
            addstr("There is no one able to get up the nerve to ", gamelog);
            move(y,0);y++;
            addstr("execute ", gamelog);
            addstr(cr->name, gamelog);
            addstr(" in cold blood.", gamelog);
            gamelog.nextMessage();

            //Interrogation will continue as planned, with
            //these restrictions:
            techniques[TECHNIQUE_TALK]=0; //don't talk to them today
            techniques[TECHNIQUE_BEAT]=0; //don't beat them today
            techniques[TECHNIQUE_DRUGS]=0; //don't administer drugs

            //Food and restraint settings will be applied as normal
         }
         //show_interrogation_sidebar(cr,a);
         refresh();
         getch();

         set_color(COLOR_WHITE,COLOR_BLACK,0);
         move(24,0);
         addstr("Press any key to reflect on this.");

         refresh();
         getch();

         if(cr->alive==0)
         {
            for(int p=0;p<pool.size();p++)
            {
               if(!pool[p]->alive)continue;
               if(pool[p]->activity.type==ACTIVITY_HOSTAGETENDING)
               {
                  if(pool[p]->activity.arg==cr->id)
                  {
                     pool[p]->activity.type=ACTIVITY_NONE;
                  }
               }
            }
            delete[] _attack;
            return;
         }
	  }
Boy, I sure love to look at walls of code and not knowing what the type or value of anything is or where an error is occurring.
I'm sorry, I really don't know where the error is...
1
2
3
4
5
6
7
8
9
10
11
12
 interrogation() : druguse(0)
   {
      techniques[0]=1;
      techniques[1]=1;
      techniques[2]=0;
      techniques[3]=0;
      techniques[4]=0;
      techniques[5]=0;
      techniques[6]=0; /// Added this one
   };

   bool techniques[6]; //Changed to 7 then 6 


0 1 2 3 4 5 6
1 2 3 4 5 6 7


If you are using 0-6 as indices, how many elements must the array contain?
Well, It was originally 5 so added another to hold the new element, Free
That's what I tried doing but I think your on the right track
Topic archived. No new replies allowed.