Subversion Repositories Games.Carmageddon

Rev

Rev 18 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 18 Rev 20
Line 1... Line 1...
1
#include "opponent.h"
1
#include "opponent.h"
2
#include "brender.h"
2
#include "brender/brender.h"
3
#include "car.h"
3
#include "car.h"
4
#include "controls.h"
4
#include "controls.h"
5
#include "crush.h"
5
#include "crush.h"
6
#include "displays.h"
6
#include "displays.h"
7
#include "errors.h"
7
#include "errors.h"
Line 2779... Line 2779...
2779
    tS16 section_no;
2779
    tS16 section_no;
2780
    int node_index_index;
2780
    int node_index_index;
2781
    LOG_TRACE("(%p, %d)", pOpponent_spec, pSection);
2781
    LOG_TRACE("(%p, %d)", pOpponent_spec, pSection);
2782
 
2782
 
2783
    if (pSection >= 20000 && pSection - 20000 < pOpponent_spec->nnext_sections) {
2783
    if (pSection >= 20000 && pSection - 20000 < pOpponent_spec->nnext_sections) {
2784
        node_index_index = pOpponent_spec->next_sections[pSection - 20000].direction == 0;
2784
      node_index_index = pOpponent_spec->next_sections[pSection - 20000].direction == 0;
2785
        if (pSection - 20000 > pOpponent_spec->nnext_sections) {
2785
      if (pSection - 20000 > pOpponent_spec->nnext_sections) {
2786
            section_no = -1;
2786
          section_no = -1;
2787
        } else {
2787
      } else {
2788
            section_no = gProgram_state.AI_vehicles.path_sections[pOpponent_spec->next_sections[pSection - 20000].section_no].node_indices[node_index_index];
2788
          section_no = gProgram_state.AI_vehicles.path_sections[pOpponent_spec->next_sections[pSection - 20000].section_no].node_indices[node_index_index];
2789
            return section_no;
2789
          return section_no;
2790
        }
2790
      }
2791
    }
2791
    }
2792
    dr_dprintf("BIG ERROR - GetOpponentsSectionStartNode() - section not found in next_section array for opponent %s",
2792
    dr_dprintf("BIG ERROR - GetOpponentsSectionStartNode() - section not found in next_section array for opponent %s",
2793
        pOpponent_spec->car_spec->driver_name);
2793
        pOpponent_spec->car_spec->driver_name);
2794
    PDEnterDebugger("BIG ERROR - GetOpponentsSectionStartNode()");
2794
    PDEnterDebugger("BIG ERROR - GetOpponentsSectionStartNode()");
2795
    return -1;
2795
    return -1;
Line 2799... Line 2799...
2799
tS16 GetOpponentsSectionFinishNode(tOpponent_spec* pOpponent_spec, tS16 pSection) {
2799
tS16 GetOpponentsSectionFinishNode(tOpponent_spec* pOpponent_spec, tS16 pSection) {
2800
    //tS16 section_no; // Pierre-Marie Baty -- unused variable
2800
    //tS16 section_no; // Pierre-Marie Baty -- unused variable
2801
    //int node_index_index; // Pierre-Marie Baty -- unused variable
2801
    //int node_index_index; // Pierre-Marie Baty -- unused variable
2802
    LOG_TRACE("(%p, %d)", pOpponent_spec, pSection);
2802
    LOG_TRACE("(%p, %d)", pOpponent_spec, pSection);
2803
 
2803
 
2804
    if (pSection >= 20000 && pSection - 20000 < pOpponent_spec->nnext_sections) {
2804
   if (pSection >= 20000 && pSection - 20000 < pOpponent_spec->nnext_sections) {
2805
        return gProgram_state.AI_vehicles.path_sections[pOpponent_spec->next_sections[pSection - 20000].section_no].node_indices[pOpponent_spec->next_sections[pSection - 20000].direction];
2805
       return gProgram_state.AI_vehicles.path_sections[pOpponent_spec->next_sections[pSection - 20000].section_no].node_indices[pOpponent_spec->next_sections[pSection - 20000].direction];
2806
    }
2806
   }
2807
    dr_dprintf("BIG ERROR - GetOpponentsSectionFinishNode() - section not found in next_section array for opponent %s",
2807
   dr_dprintf("BIG ERROR - GetOpponentsSectionFinishNode() - section not found in next_section array for opponent %s",
2808
        pOpponent_spec->car_spec->driver_name);
2808
       pOpponent_spec->car_spec->driver_name);
2809
    PDEnterDebugger("BIG ERROR - GetOpponentsSectionFinishNode()");
2809
   PDEnterDebugger("BIG ERROR - GetOpponentsSectionFinishNode()");
2810
    return 0;
2810
   return 0;
2811
}
2811
}
2812
 
2812
 
2813
// IDA: br_vector3* __usercall GetOpponentsSectionStartNodePoint@<EAX>(tOpponent_spec *pOpponent_spec@<EAX>, tS16 pSection@<EDX>)
2813
// IDA: br_vector3* __usercall GetOpponentsSectionStartNodePoint@<EAX>(tOpponent_spec *pOpponent_spec@<EAX>, tS16 pSection@<EDX>)
2814
br_vector3* GetOpponentsSectionStartNodePoint(tOpponent_spec* pOpponent_spec, tS16 pSection) {
2814
br_vector3* GetOpponentsSectionStartNodePoint(tOpponent_spec* pOpponent_spec, tS16 pSection) {
2815
    tS16 section_no;
2815
    tS16 section_no;
Line 3249... Line 3249...
3249
    new_section = ReallocExtraPathSections(1);
3249
    new_section = ReallocExtraPathSections(1);
3250
    gProgram_state.AI_vehicles.path_sections[new_section].node_indices[0] = pInserted_node;
3250
    gProgram_state.AI_vehicles.path_sections[new_section].node_indices[0] = pInserted_node;
3251
    gProgram_state.AI_vehicles.path_sections[new_section].node_indices[1] = section_no_index;
3251
    gProgram_state.AI_vehicles.path_sections[new_section].node_indices[1] = section_no_index;
3252
    gProgram_state.AI_vehicles.path_sections[new_section].min_speed[0] = 0;
3252
    gProgram_state.AI_vehicles.path_sections[new_section].min_speed[0] = 0;
3253
    gProgram_state.AI_vehicles.path_sections[new_section].max_speed[0] = 255;
3253
    gProgram_state.AI_vehicles.path_sections[new_section].max_speed[0] = 255;
-
 
3254
    gProgram_state.AI_vehicles.path_sections[new_section].min_speed[1] =
3254
    gProgram_state.AI_vehicles.path_sections[new_section].min_speed[1] = gProgram_state.AI_vehicles.path_sections[pSection_no].min_speed[1];
3255
        gProgram_state.AI_vehicles.path_sections[pSection_no].min_speed[1];
-
 
3256
    gProgram_state.AI_vehicles.path_sections[new_section].max_speed[1] =
3255
    gProgram_state.AI_vehicles.path_sections[new_section].max_speed[1] = gProgram_state.AI_vehicles.path_sections[pSection_no].max_speed[1];
3257
        gProgram_state.AI_vehicles.path_sections[pSection_no].max_speed[1];
-
 
3258
    gProgram_state.AI_vehicles.path_sections[new_section].width =
3256
    gProgram_state.AI_vehicles.path_sections[new_section].width = gProgram_state.AI_vehicles.path_sections[pSection_no].width;
3259
        gProgram_state.AI_vehicles.path_sections[pSection_no].width;
-
 
3260
    gProgram_state.AI_vehicles.path_sections[new_section].type =
3257
    gProgram_state.AI_vehicles.path_sections[new_section].type = gProgram_state.AI_vehicles.path_sections[pSection_no].type;
3261
        gProgram_state.AI_vehicles.path_sections[pSection_no].type;
-
 
3262
    gProgram_state.AI_vehicles.path_sections[new_section].one_way =
3258
    gProgram_state.AI_vehicles.path_sections[new_section].one_way = gProgram_state.AI_vehicles.path_sections[pSection_no].one_way;
3263
        gProgram_state.AI_vehicles.path_sections[pSection_no].one_way;
3259
    gProgram_state.AI_vehicles.path_sections[pSection_no].node_indices[1] = pInserted_node;
3264
    gProgram_state.AI_vehicles.path_sections[pSection_no].node_indices[1] = pInserted_node;
3260
    gProgram_state.AI_vehicles.path_sections[pSection_no].min_speed[1] = 0;
3265
    gProgram_state.AI_vehicles.path_sections[pSection_no].min_speed[1] = 0;
3261
    gProgram_state.AI_vehicles.path_sections[pSection_no].max_speed[1] = 255;
3266
    gProgram_state.AI_vehicles.path_sections[pSection_no].max_speed[1] = 255;
3262
    BrVector3Copy(&gProgram_state.AI_vehicles.path_nodes[pInserted_node].p, pWhere);
3267
    BrVector3Copy(&gProgram_state.AI_vehicles.path_nodes[pInserted_node].p, pWhere);
3263
    gProgram_state.AI_vehicles.path_nodes[pInserted_node].sections
3268
    gProgram_state.AI_vehicles.path_nodes[pInserted_node].sections
3264
        [gProgram_state.AI_vehicles.path_nodes[pInserted_node].number_of_sections]
3269
        [gProgram_state.AI_vehicles.path_nodes[pInserted_node].number_of_sections] = pSection_no;
3265
        = pSection_no;
3270
    gProgram_state.AI_vehicles.path_nodes[pInserted_node].number_of_sections =
3266
    gProgram_state.AI_vehicles.path_nodes[pInserted_node].number_of_sections = gProgram_state.AI_vehicles.path_nodes[pInserted_node].number_of_sections + 1;
3271
        gProgram_state.AI_vehicles.path_nodes[pInserted_node].number_of_sections + 1;
3267
    gProgram_state.AI_vehicles.path_nodes[pInserted_node].sections
3272
    gProgram_state.AI_vehicles.path_nodes[pInserted_node].sections
3268
        [gProgram_state.AI_vehicles.path_nodes[pInserted_node].number_of_sections]
3273
        [gProgram_state.AI_vehicles.path_nodes[pInserted_node].number_of_sections] = new_section;
3269
        = new_section;
3274
    gProgram_state.AI_vehicles.path_nodes[pInserted_node].number_of_sections =
3270
    gProgram_state.AI_vehicles.path_nodes[pInserted_node].number_of_sections = gProgram_state.AI_vehicles.path_nodes[pInserted_node].number_of_sections + 1;
3275
        gProgram_state.AI_vehicles.path_nodes[pInserted_node].number_of_sections + 1;
3271
    for (node1 = 0; node1 < gProgram_state.AI_vehicles.path_nodes[section_no_index].number_of_sections; node1++) {
3276
    for (node1 = 0; node1 < gProgram_state.AI_vehicles.path_nodes[section_no_index].number_of_sections; node1++) {
3272
        if (gProgram_state.AI_vehicles.path_nodes[section_no_index].sections[node1] == pSection_no) {
3277
        if (gProgram_state.AI_vehicles.path_nodes[section_no_index].sections[node1] == pSection_no) {
3273
            gProgram_state.AI_vehicles.path_nodes[section_no_index].sections[node1] = new_section;
3278
            gProgram_state.AI_vehicles.path_nodes[section_no_index].sections[node1] = new_section;
3274
        }
3279
        }
3275
    }
3280
    }
Line 3648... Line 3653...
3648
                centre_mat_dk = gMat_dk_blu;
3653
                centre_mat_dk = gMat_dk_blu;
3649
            }
3654
            }
3650
            if (gProgram_state.AI_vehicles.path_sections[i].one_way) {
3655
            if (gProgram_state.AI_vehicles.path_sections[i].one_way) {
3651
                centre_mat_lt = gMat_lt_yel;
3656
                centre_mat_lt = gMat_lt_yel;
3652
            }
3657
            }
-
 
3658
            if ((gProgram_state.AI_vehicles.path_sections[i].min_speed[0] != 0) ||
3653
            if ((gProgram_state.AI_vehicles.path_sections[i].min_speed[0] != 0) || (gProgram_state.AI_vehicles.path_sections[i].max_speed[0] != 255)) {
3659
                (gProgram_state.AI_vehicles.path_sections[i].max_speed[0] != 255)) {
3654
                edge_mat_start_lt = gMat_lt_turq;
3660
                edge_mat_start_lt = gMat_lt_turq;
3655
                edge_mat_start_dk = gMat_dk_turq;
3661
                edge_mat_start_dk = gMat_dk_turq;
3656
            }
3662
            }
-
 
3663
            if ((gProgram_state.AI_vehicles.path_sections[i].min_speed[1] != 0) ||
3657
            if ((gProgram_state.AI_vehicles.path_sections[i].min_speed[1] != 0) || (gProgram_state.AI_vehicles.path_sections[i].max_speed[1] != 255)) {
3664
                (gProgram_state.AI_vehicles.path_sections[i].max_speed[1] != 255)) {
3658
                edge_mat_finish_lt = gMat_lt_turq;
3665
                edge_mat_finish_lt = gMat_lt_turq;
3659
                edge_mat_finish_dk = gMat_dk_turq;
3666
                edge_mat_finish_dk = gMat_dk_turq;
3660
            }
3667
            }
3661
            if (gAlready_elasticating && gMobile_section == i) {
3668
            if (gAlready_elasticating && gMobile_section == i) {
3662
                BrVector3Copy(&gProgram_state.AI_vehicles.path_nodes[gProgram_state.AI_vehicles.path_sections[i].node_indices[1]].p,
3669
                BrVector3Copy(&gProgram_state.AI_vehicles.path_nodes[gProgram_state.AI_vehicles.path_sections[i].node_indices[1]].p,
Line 3664... Line 3671...
3664
            }
3671
            }
3665
            MakeSection(18 * i, 12 * i,
3672
            MakeSection(18 * i, 12 * i,
3666
                &gProgram_state.AI_vehicles.path_nodes[gProgram_state.AI_vehicles.path_sections[i].node_indices[0]].p,
3673
                &gProgram_state.AI_vehicles.path_nodes[gProgram_state.AI_vehicles.path_sections[i].node_indices[0]].p,
3667
                &gProgram_state.AI_vehicles.path_nodes[gProgram_state.AI_vehicles.path_sections[i].node_indices[1]].p,
3674
                &gProgram_state.AI_vehicles.path_nodes[gProgram_state.AI_vehicles.path_sections[i].node_indices[1]].p,
3668
                gProgram_state.AI_vehicles.path_sections[i].width,
3675
                gProgram_state.AI_vehicles.path_sections[i].width,
3669
                centre_mat_lt, centre_mat_dk,
3676
                centre_mat_lt,centre_mat_dk,
3670
                edge_mat_start_lt, edge_mat_start_dk,
3677
                edge_mat_start_lt,edge_mat_start_dk,
3671
                edge_mat_finish_lt, edge_mat_finish_dk);
3678
                edge_mat_finish_lt,edge_mat_finish_dk);
3672
        }
3679
        }
3673
        for (i = 0; i < gProgram_state.AI_vehicles.number_of_cops; i++) {
3680
        for (i = 0; i < gProgram_state.AI_vehicles.number_of_cops; i++) {
3674
            MakeCube(18 * gProgram_state.AI_vehicles.number_of_path_sections + 8 * i,
3681
            MakeCube(18 * gProgram_state.AI_vehicles.number_of_path_sections + 8 * i,
3675
                12 * gProgram_state.AI_vehicles.number_of_path_sections + 12 * i,
3682
                12 * gProgram_state.AI_vehicles.number_of_path_sections + 12 * i,
3676
                gProgram_state.AI_vehicles.cop_start_points + i,
3683
                gProgram_state.AI_vehicles.cop_start_points + i,
Line 3882... Line 3889...
3882
#ifdef DETHRACE_FIX_BUGS
3889
#ifdef DETHRACE_FIX_BUGS
3883
    f = fopen(gOppo_path_filename, "w");
3890
    f = fopen(gOppo_path_filename, "w");
3884
#else
3891
#else
3885
    f = DRfopen(gOppo_path_filename, "wt");
3892
    f = DRfopen(gOppo_path_filename, "wt");
3886
#endif
3893
#endif
3887
    if (f == NULL) {
-
 
3888
        printf("f is NULL, errno=%d, msg=\"%s\"\n", errno, strerror(errno));
3894
    if (f == NULL) { printf("f is NULL, errno=%d, msg=\"%s\"\n", errno, strerror(errno));}
3889
    }
-
 
3890
    fprintf(f, "%s\n", "START OF OPPONENT PATHS");
3895
    fprintf(f, "%s\n", "START OF OPPONENT PATHS");
3891
    fprintf(f, "\n%-3d                             // Number of path nodes\n",
3896
    fprintf(f, "\n%-3d                             // Number of path nodes\n",
3892
        gProgram_state.AI_vehicles.number_of_path_nodes);
3897
        gProgram_state.AI_vehicles.number_of_path_nodes);
3893
    for (i = 0; i < gProgram_state.AI_vehicles.number_of_path_nodes; i++) {
3898
    for (i = 0; i < gProgram_state.AI_vehicles.number_of_path_nodes; i++) {
3894
        fprintf(f, "%9.3f,%9.3f,%9.3f   // Node #%d\n",
3899
        fprintf(f, "%9.3f,%9.3f,%9.3f   // Node #%d\n",
Line 3988... Line 3993...
3988
            return;
3993
            return;
3989
        }
3994
        }
3990
        original_type = 0;
3995
        original_type = 0;
3991
        if (gProgram_state.AI_vehicles.path_nodes[old_node].number_of_sections != 0) {
3996
        if (gProgram_state.AI_vehicles.path_nodes[old_node].number_of_sections != 0) {
3992
            for (section_no_index = 1; section_no_index < gProgram_state.AI_vehicles.path_nodes[old_node].number_of_sections; section_no_index++) {
3997
            for (section_no_index = 1; section_no_index < gProgram_state.AI_vehicles.path_nodes[old_node].number_of_sections; section_no_index++) {
3993
                if (gProgram_state.AI_vehicles.path_sections[gProgram_state.AI_vehicles.path_nodes[old_node].sections[section_no_index]].type != gProgram_state.AI_vehicles.path_sections[gProgram_state.AI_vehicles.path_nodes[old_node].sections[0]].type) {
3998
                if (gProgram_state.AI_vehicles.path_sections[gProgram_state.AI_vehicles.path_nodes[old_node].sections[section_no_index]].type !=
-
 
3999
                        gProgram_state.AI_vehicles.path_sections[gProgram_state.AI_vehicles.path_nodes[old_node].sections[0]].type) {
3994
                    all_the_same_type = 0;
4000
                    all_the_same_type = 0;
3995
                }
4001
                }
3996
            }
4002
            }
3997
            if (all_the_same_type) {
4003
            if (all_the_same_type) {
3998
                original_type = gProgram_state.AI_vehicles.path_sections[gProgram_state.AI_vehicles.path_nodes[old_node].sections[0]].type;
4004
                original_type = gProgram_state.AI_vehicles.path_sections [gProgram_state.AI_vehicles.path_nodes[old_node].sections[0]].type;
3999
            }
4005
            }
4000
        }
4006
        }
4001
        gAlready_elasticating = 1;
4007
        gAlready_elasticating = 1;
4002
        new_node = ReallocExtraPathNodes(1);
4008
        new_node = ReallocExtraPathNodes(1);
4003
        gMobile_section = ReallocExtraPathSections(1);
4009
        gMobile_section = ReallocExtraPathSections(1);
Line 4012... Line 4018...
4012
    gProgram_state.AI_vehicles.path_sections[gMobile_section].type = original_type;
4018
    gProgram_state.AI_vehicles.path_sections[gMobile_section].type = original_type;
4013
    gProgram_state.AI_vehicles.path_sections[gMobile_section].one_way = one_wayness;
4019
    gProgram_state.AI_vehicles.path_sections[gMobile_section].one_way = one_wayness;
4014
    if (gProgram_state.AI_vehicles.path_nodes[old_node].number_of_sections == 0) {
4020
    if (gProgram_state.AI_vehicles.path_nodes[old_node].number_of_sections == 0) {
4015
        gProgram_state.AI_vehicles.path_sections[gMobile_section].width = 1.f;
4021
        gProgram_state.AI_vehicles.path_sections[gMobile_section].width = 1.f;
4016
    } else {
4022
    } else {
-
 
4023
        gProgram_state.AI_vehicles.path_sections[gMobile_section].width =
4017
        gProgram_state.AI_vehicles.path_sections[gMobile_section].width = gProgram_state.AI_vehicles.path_sections[gProgram_state.AI_vehicles.path_nodes[old_node].sections[0]].width;
4024
            gProgram_state.AI_vehicles.path_sections[gProgram_state.AI_vehicles.path_nodes[old_node].sections[0]].width;
4018
    }
4025
    }
4019
    gProgram_state.AI_vehicles.path_nodes[new_node].number_of_sections = 0;
4026
    gProgram_state.AI_vehicles.path_nodes[new_node].number_of_sections = 0;
4020
    gProgram_state.AI_vehicles.path_nodes[new_node].sections[gProgram_state.AI_vehicles.path_nodes[new_node].number_of_sections] = gMobile_section;
4027
    gProgram_state.AI_vehicles.path_nodes[new_node].sections[gProgram_state.AI_vehicles.path_nodes[new_node].number_of_sections] = gMobile_section;
4021
    gProgram_state.AI_vehicles.path_nodes[new_node].number_of_sections += 1;
4028
    gProgram_state.AI_vehicles.path_nodes[new_node].number_of_sections += 1;
4022
    gProgram_state.AI_vehicles.path_nodes[old_node].sections[gProgram_state.AI_vehicles.path_nodes[old_node].number_of_sections] = gMobile_section;
4029
    gProgram_state.AI_vehicles.path_nodes[old_node].sections[gProgram_state.AI_vehicles.path_nodes[old_node].number_of_sections] = gMobile_section;
Line 4190... Line 4197...
4190
 
4197
 
4191
// IDA: void __cdecl WidenOppoPathSection()
4198
// IDA: void __cdecl WidenOppoPathSection()
4192
void WidenOppoPathSection(void) {
4199
void WidenOppoPathSection(void) {
4193
    LOG_TRACE("()");
4200
    LOG_TRACE("()");
4194
 
4201
 
-
 
4202
 
4195
    if (gOppo_paths_shown) {
4203
   if (gOppo_paths_shown) {
4196
        RecalcNearestPathSectionWidth(.05f);
4204
       RecalcNearestPathSectionWidth(.05f);
4197
    }
4205
   }
4198
}
4206
}
4199
 
4207
 
4200
// IDA: void __cdecl NarrowOppoPathSection()
4208
// IDA: void __cdecl NarrowOppoPathSection()
4201
void NarrowOppoPathSection(void) {
4209
void NarrowOppoPathSection(void) {
4202
    LOG_TRACE("()");
4210
    LOG_TRACE("()");
Line 4226... Line 4234...
4226
 
4234
 
4227
// IDA: void __cdecl IncreaseSectionMaxSpeed()
4235
// IDA: void __cdecl IncreaseSectionMaxSpeed()
4228
void IncreaseSectionMaxSpeed(void) {
4236
void IncreaseSectionMaxSpeed(void) {
4229
    LOG_TRACE("()");
4237
    LOG_TRACE("()");
4230
 
4238
 
4231
    if (gOppo_paths_shown) {
4239
   if (gOppo_paths_shown) {
4232
        RecalcNearestPathSectionSpeed(1, 1);
4240
       RecalcNearestPathSectionSpeed(1, 1);
4233
    }
4241
   }
4234
}
4242
}
4235
 
4243
 
4236
// IDA: void __cdecl DecreaseSectionMaxSpeed()
4244
// IDA: void __cdecl DecreaseSectionMaxSpeed()
4237
void DecreaseSectionMaxSpeed(void) {
4245
void DecreaseSectionMaxSpeed(void) {
4238
    LOG_TRACE("()");
4246
    LOG_TRACE("()");
Line 4298... Line 4306...
4298
    br_vector3 direction_v;
4306
    br_vector3 direction_v;
4299
    br_vector3 intersect;
4307
    br_vector3 intersect;
4300
    LOG_TRACE("()");
4308
    LOG_TRACE("()");
4301
 
4309
 
4302
    if (!gOppo_paths_shown) {
4310
    if (!gOppo_paths_shown) {
4303
        NewTextHeadupSlot(4, 0, 2000, -1, "Show paths first (F5)");
4311
      NewTextHeadupSlot(4, 0, 2000, -1, "Show paths first (F5)");
4304
    } else if (gAlready_elasticating) {
4312
    } else if (gAlready_elasticating) {
4305
        sprintf(str, "This section will be #%d attached to nodes #%d and #%d",
4313
        sprintf(str, "This section will be #%d attached to nodes #%d and #%d",
4306
            gMobile_section,
4314
            gMobile_section,
4307
            gProgram_state.AI_vehicles.path_sections[gMobile_section].node_indices[0],
4315
            gProgram_state.AI_vehicles.path_sections[gMobile_section].node_indices[0],
4308
            gProgram_state.AI_vehicles.path_sections[gMobile_section].node_indices[1]);
4316
            gProgram_state.AI_vehicles.path_sections[gMobile_section].node_indices[1]);
Line 4385... Line 4393...
4385
    tS16 node_no;
4393
    tS16 node_no;
4386
    LOG_TRACE("()");
4394
    LOG_TRACE("()");
4387
 
4395
 
4388
    if (!gOppo_paths_shown) {
4396
    if (!gOppo_paths_shown) {
4389
        NewTextHeadupSlot(4, 0, 2000, -1, "Show paths first (F5)");
4397
        NewTextHeadupSlot(4, 0, 2000, -1, "Show paths first (F5)");
-
 
4398
    }
4390
    } else if (gAlready_elasticating) {
4399
    else if (gAlready_elasticating) {
4391
        NewTextHeadupSlot(4, 0, 2000, -1, "Not while you're creating a new section");
4400
        NewTextHeadupSlot(4, 0, 2000, -1, "Not while you're creating a new section");
4392
    } else {
4401
    } else {
4393
        node_no = FindNearestPathNode(&gSelf->t.t.translate.t, &distance);
4402
        node_no = FindNearestPathNode(&gSelf->t.t.translate.t, &distance);
4394
        if (distance > 10.f) {
4403
        if (distance > 10.f) {
4395
            NewTextHeadupSlot(4, 0, 2000, -1, "Can't find any nodes close enough");
4404
            NewTextHeadupSlot(4, 0, 2000, -1, "Can't find any nodes close enough");
Line 4417... Line 4426...
4417
        if (distance > 10.f) {
4426
        if (distance > 10.f) {
4418
            NewTextHeadupSlot(4, 0, 2000, -1, "Can't find any nodes close enough");
4427
            NewTextHeadupSlot(4, 0, 2000, -1, "Can't find any nodes close enough");
4419
        } else if (gProgram_state.AI_vehicles.path_nodes[node_no].number_of_sections != 2) {
4428
        } else if (gProgram_state.AI_vehicles.path_nodes[node_no].number_of_sections != 2) {
4420
            NewTextHeadupSlot(4, 0, 2000, -1, "Node must have exactly 2 sections attached");
4429
            NewTextHeadupSlot(4, 0, 2000, -1, "Node must have exactly 2 sections attached");
4421
        } else if ((gProgram_state.AI_vehicles.path_sections[gProgram_state.AI_vehicles.path_nodes[node_no].sections[0]].node_indices[0] == node_no
4430
        } else if ((gProgram_state.AI_vehicles.path_sections[gProgram_state.AI_vehicles.path_nodes[node_no].sections[0]].node_indices[0] == node_no
4422
                       && gProgram_state.AI_vehicles.path_sections[gProgram_state.AI_vehicles.path_nodes[node_no].sections[1]].node_indices[1] == node_no)
4431
                    && gProgram_state.AI_vehicles.path_sections[gProgram_state.AI_vehicles.path_nodes[node_no].sections[1]].node_indices[1] == node_no) ||
4423
            || (gProgram_state.AI_vehicles.path_sections[gProgram_state.AI_vehicles.path_nodes[node_no].sections[1]].node_indices[0] == node_no
4432
                (gProgram_state.AI_vehicles.path_sections[gProgram_state.AI_vehicles.path_nodes[node_no].sections[1]].node_indices[0] == node_no
4424
                && gProgram_state.AI_vehicles.path_sections[gProgram_state.AI_vehicles.path_nodes[node_no].sections[0]].node_indices[1] == node_no)) {
4433
                    && gProgram_state.AI_vehicles.path_sections[gProgram_state.AI_vehicles.path_nodes[node_no].sections[0]].node_indices[1] == node_no)) {
4425
            ConsistencyCheck();
4434
            ConsistencyCheck();
4426
            DeleteNode(node_no, 0);
4435
            DeleteNode(node_no,0);
4427
            ConsistencyCheck();
4436
            ConsistencyCheck();
4428
            DeleteOrphanNodes();
4437
            DeleteOrphanNodes();
4429
            ConsistencyCheck();
4438
            ConsistencyCheck();
4430
            ShowOppoPaths();
4439
            ShowOppoPaths();
4431
            NewTextHeadupSlot(4, 0, 2000, -1, "Blam!");
4440
            NewTextHeadupSlot(4, 0, 2000, -1, "Blam!");
-
 
4441
        }
4432
        } else {
4442
        else {
4433
            NewTextHeadupSlot(4, 0, 2000, -1, "Sections must point in same direction");
4443
            NewTextHeadupSlot(4, 0, 2000, -1, "Sections must point in same direction");
4434
        }
4444
        }
4435
    }
4445
    }
4436
}
4446
}
4437
 
4447
 
Line 4448... Line 4458...
4448
    if (!gOppo_paths_shown) {
4458
    if (!gOppo_paths_shown) {
4449
        NewTextHeadupSlot(4, 0, 2000, -1, "Show paths first (F5)");
4459
        NewTextHeadupSlot(4, 0, 2000, -1, "Show paths first (F5)");
4450
    } else if (gAlready_elasticating) {
4460
    } else if (gAlready_elasticating) {
4451
        NewTextHeadupSlot(4, 0, 2000, -1, "Not while you're creating a new section");
4461
        NewTextHeadupSlot(4, 0, 2000, -1, "Not while you're creating a new section");
4452
    } else {
4462
    } else {
4453
        section_no = FindNearestPathSection(&gSelf->t.t.translate.t, &direction_v, &intersect, &distance);
4463
        section_no = FindNearestPathSection(&gSelf->t.t.translate.t,  &direction_v, &intersect, &distance);
4454
        if (distance > 10.f) {
4464
        if (distance > 10.f) {
4455
            NewTextHeadupSlot(4, 0, 2000, -1, "Can't find any sections close enough");
4465
            NewTextHeadupSlot(4, 0, 2000, -1, "Can't find any sections close enough");
4456
        } else {
4466
        } else {
4457
            temp = gProgram_state.AI_vehicles.path_sections[section_no].node_indices[0];
4467
            temp = gProgram_state.AI_vehicles.path_sections[section_no].node_indices[0];
-
 
4468
            gProgram_state.AI_vehicles.path_sections[section_no].node_indices[0] =
4458
            gProgram_state.AI_vehicles.path_sections[section_no].node_indices[0] = gProgram_state.AI_vehicles.path_sections[section_no].node_indices[1];
4469
                gProgram_state.AI_vehicles.path_sections[section_no].node_indices[1];
4459
            gProgram_state.AI_vehicles.path_sections[section_no].node_indices[1] = temp;
4470
            gProgram_state.AI_vehicles.path_sections[section_no].node_indices[1] = temp;
4460
 
4471
 
4461
            speed_temp = gProgram_state.AI_vehicles.path_sections[section_no].min_speed[0];
4472
            speed_temp = gProgram_state.AI_vehicles.path_sections[section_no].min_speed[0];
-
 
4473
            gProgram_state.AI_vehicles.path_sections[section_no].min_speed[0] =
4462
            gProgram_state.AI_vehicles.path_sections[section_no].min_speed[0] = gProgram_state.AI_vehicles.path_sections[section_no].min_speed[1];
4474
                gProgram_state.AI_vehicles.path_sections[section_no].min_speed[1];
4463
            gProgram_state.AI_vehicles.path_sections[section_no].min_speed[1] = speed_temp;
4475
            gProgram_state.AI_vehicles.path_sections[section_no].min_speed[1] = speed_temp;
4464
 
4476
 
4465
            speed_temp = gProgram_state.AI_vehicles.path_sections[section_no].max_speed[0];
4477
            speed_temp = gProgram_state.AI_vehicles.path_sections[section_no].max_speed[0];
-
 
4478
            gProgram_state.AI_vehicles.path_sections[section_no].max_speed[0] =
4466
            gProgram_state.AI_vehicles.path_sections[section_no].max_speed[0] = gProgram_state.AI_vehicles.path_sections[section_no].max_speed[1];
4479
                gProgram_state.AI_vehicles.path_sections[section_no].max_speed[1];
4467
            gProgram_state.AI_vehicles.path_sections[section_no].max_speed[1] = speed_temp;
4480
            gProgram_state.AI_vehicles.path_sections[section_no].max_speed[1] = speed_temp;
4468
 
4481
 
4469
            ShowOppoPaths();
4482
            ShowOppoPaths();
4470
        }
4483
        }
4471
    }
4484
    }
Line 4487... Line 4500...
4487
    } else {
4500
    } else {
4488
        section_no = FindNearestPathSection(&gSelf->t.t.translate.t, &direction_v, &intersect, &distance);
4501
        section_no = FindNearestPathSection(&gSelf->t.t.translate.t, &direction_v, &intersect, &distance);
4489
        if (distance > 10.f) {
4502
        if (distance > 10.f) {
4490
            NewTextHeadupSlot(4, 0, 2000, -1, "Can't find any sections close enough");
4503
            NewTextHeadupSlot(4, 0, 2000, -1, "Can't find any sections close enough");
4491
        } else {
4504
        } else {
-
 
4505
            gProgram_state.AI_vehicles.path_sections[section_no].type =
4492
            gProgram_state.AI_vehicles.path_sections[section_no].type = (gProgram_state.AI_vehicles.path_sections[section_no].type + 1) % 3;
4506
                (gProgram_state.AI_vehicles.path_sections[section_no].type + 1) % 3;
4493
            sprintf(str, "%s section", gPath_section_type_names[gProgram_state.AI_vehicles.path_sections[section_no].type]);
4507
            sprintf(str, "%s section",  gPath_section_type_names[gProgram_state.AI_vehicles.path_sections[section_no].type]);
4494
            ShowOppoPaths();
4508
            ShowOppoPaths();
4495
            NewTextHeadupSlot(4, 0, 2000, -1, str);
4509
            NewTextHeadupSlot(4, 0, 2000, -1, str);
4496
        }
4510
        }
4497
    }
4511
    }
4498
}
4512
}
Line 4514... Line 4528...
4514
        if (distance > 10.f) {
4528
        if (distance > 10.f) {
4515
            NewTextHeadupSlot(4, 0, 2000, -1, "Can't find any sections close enough");
4529
            NewTextHeadupSlot(4, 0, 2000, -1, "Can't find any sections close enough");
4516
        } else {
4530
        } else {
4517
            if (gProgram_state.AI_vehicles.path_sections[section_no].one_way) {
4531
            if (gProgram_state.AI_vehicles.path_sections[section_no].one_way) {
4518
                gProgram_state.AI_vehicles.path_sections[section_no].one_way = 0;
4532
                gProgram_state.AI_vehicles.path_sections[section_no].one_way = 0;
-
 
4533
            }
4519
            } else {
4534
            else {
4520
                gProgram_state.AI_vehicles.path_sections[section_no].one_way = 1;
4535
                gProgram_state.AI_vehicles.path_sections[section_no].one_way = 1;
4521
            }
4536
            }
4522
            ShowOppoPaths();
4537
            ShowOppoPaths();
4523
            if (gProgram_state.AI_vehicles.path_sections[section_no].one_way) {
4538
            if (gProgram_state.AI_vehicles.path_sections[section_no].one_way) {
4524
                NewTextHeadupSlot(4, 0, 2000, -1, "ONE-WAY");
4539
                NewTextHeadupSlot(4, 0, 2000, -1, "ONE-WAY");
Line 4540... Line 4555...
4540
    LOG_TRACE("()");
4555
    LOG_TRACE("()");
4541
 
4556
 
4542
    closest = -1;
4557
    closest = -1;
4543
    closest_distance = FLT_MAX;
4558
    closest_distance = FLT_MAX;
4544
    if (!gOppo_paths_shown) {
4559
    if (!gOppo_paths_shown) {
4545
        NewTextHeadupSlot(4, 0, 2000, -1, "Show paths first (F5)");
4560
      NewTextHeadupSlot(4, 0, 2000, -1, "Show paths first (F5)");
4546
    } else {
4561
    } else {
4547
        for (i = 0; i < gProgram_state.AI_vehicles.number_of_cops; i++) {
4562
        for (i = 0; i < gProgram_state.AI_vehicles.number_of_cops; i++) {
4548
            BrVector3Sub(&car_to_point, &gSelf->t.t.translate.t, &gProgram_state.AI_vehicles.cop_start_points[i]);
4563
            BrVector3Sub(&car_to_point, &gSelf->t.t.translate.t, &gProgram_state.AI_vehicles.cop_start_points[i]);
4549
            distance = BrVector3LengthSquared(&car_to_point);
4564
            distance = BrVector3LengthSquared(&car_to_point);
4550
            if (distance < closest_distance) {
4565
            if (distance < closest_distance) {
Line 4625... Line 4640...
4625
}
4640
}
4626
 
4641
 
4627
// IDA: void __cdecl CycleCopStartPointType()
4642
// IDA: void __cdecl CycleCopStartPointType()
4628
void CycleCopStartPointType(void) {
4643
void CycleCopStartPointType(void) {
4629
    LOG_TRACE("()");
4644
    LOG_TRACE("()");
-
 
4645
 
4630
}
4646
}