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