@@ -936,11 +936,13 @@ int DispatchSpawn(edict_t* pent) {
936936}
937937
938938void DispatchThink (edict_t * pent) {
939- if (FStrEq (STRING (pent->v .classname ), " entity_botcam" )) {
939+ // hoist the euser1 null check to the top so the trace and
940+ // MakeVectors below it never deref a null pointer - [APG]RoboCop[CL]
941+ if (FStrEq (STRING (pent->v .classname ), " entity_botcam" ) && pent->v .euser1 != nullptr && !FNullEnt (pent->v .euser1 )) {
940942 TraceResult tr;
941943 int off_f = 16 ;
942944 UTIL_MakeVectors (pent->v .euser1 ->v .v_angle );
943- if (pent->v .euser1 != nullptr && ! FNullEnt (pent-> v . euser1 ) && pent-> v . owner != nullptr && !FNullEnt (pent->v .owner )) {
945+ if (pent->v .owner != nullptr && !FNullEnt (pent->v .owner )) {
944946 bot_t * pBot = UTIL_GetBotPointer (pent->v .euser1 );
945947
946948 UTIL_TraceLine (pent->v .euser1 ->v .origin + pent->v .euser1 ->v .view_ofs + gpGlobals->v_forward * static_cast <float >(off_f), pent->v .euser1 ->v .origin + pent->v .euser1 ->v .view_ofs + gpGlobals->v_forward * 4000 , ignore_monsters, pent->v .euser1 , &tr);
@@ -3239,7 +3241,7 @@ void StartFrame() { // v7 last frame timing
32393241 for (int j = 0 ; j < 12 ; j++) {
32403242 i1++;
32413243 buf = buf + 1 ;
3242- RoleStatus[3 ] = 90 ;
3244+ RoleStatus[2 ] = 90 ; // was RoleStatus[3] - typo, green is team 2 - [APG]RoboCop[CL]
32433245 } // move to end
32443246 } // defend
32453247 else if (std::strncmp (buf, " blue_defend" , 11 ) == 0 ) {
@@ -4396,8 +4398,7 @@ void StartFrame() { // v7 last frame timing
43964398 curr->yellow_av [i2] = -1 ;
43974399 curr->green_av [i2] = -1 ;
43984400 }
4399- snprintf (msg, sizeof (msg), " b_p_%d" , pnt);
4400- std::strcpy (curr->ifs , msg);
4401+ snprintf (curr->ifs , sizeof (curr->ifs ), " b_p_%d" , pnt);
44014402 }
44024403 else if (std::strncmp (buf, " if_red_point" , 12 ) == 0 ) {
44034404 // this can only be in a section
@@ -4429,8 +4430,7 @@ void StartFrame() { // v7 last frame timing
44294430 curr->yellow_av [i2] = -1 ;
44304431 curr->green_av [i2] = -1 ;
44314432 }
4432- snprintf (msg, sizeof (msg), " r_p_%d" , pnt);
4433- std::strcpy (curr->ifs , msg);
4433+ snprintf (curr->ifs , sizeof (curr->ifs ), " r_p_%d" , pnt);
44344434 }
44354435 else if (std::strncmp (buf, " if_green_point" , 14 ) == 0 ) {
44364436 // this can only be in a section
@@ -4462,8 +4462,7 @@ void StartFrame() { // v7 last frame timing
44624462 curr->yellow_av [i2] = -1 ;
44634463 curr->green_av [i2] = -1 ;
44644464 }
4465- snprintf (msg, sizeof (msg), " g_p_%d" , pnt);
4466- std::strcpy (curr->ifs , msg);
4465+ snprintf (curr->ifs , sizeof (curr->ifs ), " g_p_%d" , pnt);
44674466 }
44684467 else if (std::strncmp (buf, " if_yellow_point" , 15 ) == 0 ) {
44694468 // this can only be in a section
@@ -4495,8 +4494,7 @@ void StartFrame() { // v7 last frame timing
44954494 curr->yellow_av [i2] = -1 ;
44964495 curr->green_av [i2] = -1 ;
44974496 }
4498- snprintf (msg, sizeof (msg), " y_p_%d" , pnt);
4499- std::strcpy (curr->ifs , msg);
4497+ snprintf (curr->ifs , sizeof (curr->ifs ), " y_p_%d" , pnt);
45004498 } // is point<n> NOT availabe?
45014499 else if (std::strncmp (buf, " ifn_blue_point" , 14 ) == 0 ) {
45024500 // this can only be in a section
@@ -4529,8 +4527,7 @@ void StartFrame() { // v7 last frame timing
45294527 curr->yellow_av [i2] = -1 ;
45304528 curr->green_av [i2] = -1 ;
45314529 }
4532- snprintf (msg, sizeof (msg), " b_pn_%d" , pnt);
4533- std::strcpy (curr->ifs , msg);
4530+ snprintf (curr->ifs , sizeof (curr->ifs ), " b_pn_%d" , pnt);
45344531 }
45354532 else if (std::strncmp (buf, " ifn_red_point" , 13 ) == 0 ) {
45364533 // this can only be in a section
@@ -4562,8 +4559,7 @@ void StartFrame() { // v7 last frame timing
45624559 curr->yellow_av [i2] = -1 ;
45634560 curr->green_av [i2] = -1 ;
45644561 }
4565- snprintf (msg, sizeof (msg), " r_pn_%d" , pnt);
4566- std::strcpy (curr->ifs , msg);
4562+ snprintf (curr->ifs , sizeof (curr->ifs ), " r_pn_%d" , pnt);
45674563 }
45684564 else if (std::strncmp (buf, " ifn_green_point" , 15 ) == 0 ) {
45694565 // this can only be in a section
@@ -4595,8 +4591,7 @@ void StartFrame() { // v7 last frame timing
45954591 curr->yellow_av [i2] = -1 ;
45964592 curr->green_av [i2] = -1 ;
45974593 }
4598- snprintf (msg, sizeof (msg), " g_pn_%d" , pnt);
4599- std::strcpy (curr->ifs , msg);
4594+ snprintf (curr->ifs , sizeof (curr->ifs ), " g_pn_%d" , pnt);
46004595 }
46014596 else if (std::strncmp (buf, " ifn_yellow_point" , 16 ) == 0 ) {
46024597 // this can only be in a section
@@ -4628,8 +4623,7 @@ void StartFrame() { // v7 last frame timing
46284623 curr->yellow_av [i2] = -1 ;
46294624 curr->green_av [i2] = -1 ;
46304625 }
4631- snprintf (msg, sizeof (msg), " y_pn_%d" , pnt);
4632- std::strcpy (curr->ifs , msg);
4626+ snprintf (curr->ifs , sizeof (curr->ifs ), " y_pn_%d" , pnt);
46334627 }
46344628 // multipoint ifs
46354629 else if (std::strncmp (buf, " if_blue_mpoint" , 14 ) == 0 ) {
@@ -4667,8 +4661,7 @@ void StartFrame() { // v7 last frame timing
46674661 curr->green_av [i2] = -1 ;
46684662 }
46694663 pnts[8 ] = ' \0 ' ;
4670- snprintf (msg, sizeof (msg), " b_mp_%s" , pnts);
4671- std::strcpy (curr->ifs , msg);
4664+ snprintf (curr->ifs , sizeof (curr->ifs ), " b_mp_%s" , pnts);
46724665 }
46734666 else if (std::strncmp (buf, " if_red_mpoint" , 13 ) == 0 ) {
46744667 // this can only be in a section
@@ -4705,8 +4698,7 @@ void StartFrame() { // v7 last frame timing
47054698 curr->green_av [i2] = -1 ;
47064699 }
47074700 pnts[8 ] = ' \0 ' ;
4708- snprintf (msg, sizeof (msg), " r_mp_%s" , pnts);
4709- std::strcpy (curr->ifs , msg);
4701+ snprintf (curr->ifs , sizeof (curr->ifs ), " r_mp_%s" , pnts);
47104702 }
47114703 else if (std::strncmp (buf, " if_green_mpoint" , 15 ) == 0 ) {
47124704 // this can only be in a section
@@ -4743,8 +4735,7 @@ void StartFrame() { // v7 last frame timing
47434735 curr->green_av [i2] = -1 ;
47444736 }
47454737 pnts[8 ] = ' \0 ' ;
4746- snprintf (msg, sizeof (msg), " g_mp_%s" , pnts);
4747- std::strcpy (curr->ifs , msg);
4738+ snprintf (curr->ifs , sizeof (curr->ifs ), " g_mp_%s" , pnts);
47484739 }
47494740 else if (std::strncmp (buf, " if_yellow_mpoint" , 16 ) == 0 ) {
47504741 // this can only be in a section
@@ -4781,8 +4772,7 @@ void StartFrame() { // v7 last frame timing
47814772 curr->green_av [i2] = -1 ;
47824773 }
47834774 pnts[8 ] = ' \0 ' ;
4784- snprintf (msg, sizeof (msg), " y_mp_%s" , pnts);
4785- std::strcpy (curr->ifs , msg);
4775+ snprintf (curr->ifs , sizeof (curr->ifs ), " y_mp_%s" , pnts);
47864776 } // end of multipoint ifs
47874777 else if (buffer[i1] != ' /' && buffer[i1] != ' {' && buffer[i1] != ' }' && buffer[i1] != ' ' && buffer[i1] != ' \n ' && random_shit_error == false ) {
47884778 random_shit_error = true ;
0 commit comments