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 2... | Line 2... | ||
| 2 | 2 | ||
| 3 | #include "car.h" | 3 | #include "car.h" | 
| 4 | #include " | 4 | #include "brender.h" | 
| 5 | #include "brucetrk.h" | 5 | #include "brucetrk.h" | 
| 6 | #include "car.h" | 6 | #include "car.h" | 
| 7 | #include "constants.h" | 7 | #include "constants.h" | 
| 8 | #include "controls.h" | 8 | #include "controls.h" | 
| 9 | #include "crush.h" | 9 | #include "crush.h" | 
| Line 27... | Line 27... | ||
| 27 | #include "raycast.h" | 27 | #include "raycast.h" | 
| 28 | #include "replay.h" | 28 | #include "replay.h" | 
| 29 | #include "skidmark.h" | 29 | #include "skidmark.h" | 
| 30 | #include "sound.h" | 30 | #include "sound.h" | 
| 31 | #include "spark.h" | 31 | #include "spark.h" | 
| - | 32 | #include "structur.h" | |
| 32 | #include "trig.h" | 33 | #include "trig.h" | 
| 33 | #include "utility.h" | 34 | #include "utility.h" | 
| 34 | #include "world.h" | 35 | #include "world.h" | 
| 35 | #include <math.h> | 36 | #include <math.h> | 
| 36 | #include <stdlib.h> | 37 | #include <stdlib.h> | 
| Line 884... | Line 885... | ||
| 884 | if (fabsf(c->curvature) > c->maxcurve / 2.0f && c->gear < 2 && c->gear && c->traction_control) { | 885 | if (fabsf(c->curvature) > c->maxcurve / 2.0f && c->gear < 2 && c->gear && c->traction_control) { | 
| 885 | ts = 0.7f; | 886 | ts = 0.7f; | 
| 886 | } else if (c->joystick.acc < 0) { | 887 | } else if (c->joystick.acc < 0) { | 
| 887 | ts = (br_scalar) 1.2; // Pierre-Marie Baty -- added type cast | 888 | ts = (br_scalar) 1.2; // Pierre-Marie Baty -- added type cast | 
| 888 | } else { | 889 | } else { | 
| 889 | ts = c->joystick.acc / 54613. | 890 | ts = c->joystick.acc / 54613.0f; | 
| 890 | LOG_PANIC("ooo"); | - | |
| 891 |         } | 891 |         } | 
| 892 | 892 | ||
| 893 | torque = c->engine_power_multiplier * ts * gEngine_powerup_factor[c->power_up_levels[1]]; | 893 | torque = c->engine_power_multiplier * ts * gEngine_powerup_factor[c->power_up_levels[1]]; | 
| 894 | if (c->damage_units[0].damage_level > 10) { | 894 | if (c->damage_units[0].damage_level > 10) { | 
| 895 | torque = (1.0f - (double)(c->damage_units[0].damage_level - 10) / 100.0f) * torque; | 895 | torque = (1.0f - (double)(c->damage_units[0].damage_level - 10) / 100.0f) * torque; | 
| Line 1079... | Line 1079... | ||
| 1079 |     } | 1079 |     } | 
| 1080 | } | 1080 | } | 
| 1081 | 1081 | ||
| 1082 | // IDA: void __usercall GetNetPos(tCar_spec *pCar@<EAX>) | 1082 | // IDA: void __usercall GetNetPos(tCar_spec *pCar@<EAX>) | 
| 1083 | void GetNetPos(tCar_spec* pCar) { | 1083 | void GetNetPos(tCar_spec* pCar) { | 
| 1084 | 
 | 1084 | int j; | 
| 1085 | 
 | 1085 | float amount; | 
| 1086 | 
 | 1086 | br_scalar total_deflection; | 
| 1087 | LOG_TRACE("(%p)", pCar); | 1087 | LOG_TRACE("(%p)", pCar); | 
| - | 1088 | ||
| - | 1089 | if (gNet_mode == eNet_mode_host && pCar->last_car_car_collision > pCar->message.cc_coll_time) { | |
| - | 1090 | pCar->message.type = 0; | |
| - | 1091 | pCar->dt = -1.0f; | |
| - | 1092 | return; | |
| - | 1093 |     } | |
| - | 1094 | if (fabsf(pCar->message.omega.v[0]) > 10000.0 | |
| - | 1095 | || fabsf(pCar->message.omega.v[1]) > 10000.0 | |
| - | 1096 | || fabsf(pCar->message.omega.v[2]) > 10000.0 | |
| - | 1097 | || fabsf(pCar->message.omega.v[0]) > 10000.0 | |
| - | 1098 | || fabsf(pCar->message.omega.v[1]) > 10000.0 | |
| - | 1099 | || fabsf(pCar->message.omega.v[2]) > 10000.0) { | |
| - | 1100 | BrVector3SetFloat(&pCar->message.omega, 0.0, 0.0, 0.0); | |
| - | 1101 | BrVector3SetFloat(&pCar->message.v, 0.0, 0.0, 0.0); | |
| - | 1102 |     } | |
| - | 1103 | GetExpandedMatrix(&pCar->car_master_actor->t.t.mat, &pCar->message.mat); | |
| - | 1104 | if (gNet_mode == eNet_mode_client) { | |
| - | 1105 | BrMatrix34Copy(&pCar->oldmat, &pCar->car_master_actor->t.t.mat); | |
| - | 1106 |     } | |
| - | 1107 | BrVector3Copy(&pCar->v, &pCar->message.v); | |
| - | 1108 | BrVector3Copy(&pCar->omega, &pCar->message.omega); | |
| - | 1109 | ||
| - | 1110 | if (pCar->driver > eDriver_non_car) { | |
| - | 1111 | pCar->curvature = pCar->message.curvature * pCar->maxcurve / 32767.0f; | |
| - | 1112 | ||
| - | 1113 | for (j = 0; j < COUNT_OF(pCar->oldd); j++) { | |
| - | 1114 | pCar->oldd[j] = (pCar->message.d[j] * pCar->susp_height[j >> 1]) / 255.0f; | |
| - | 1115 |         } | |
| - | 1116 | if (pCar->driver == eDriver_oppo || pCar->repair_time >= pCar->message.repair_time) { | |
| - | 1117 | for (j = 0; j < COUNT_OF(pCar->damage_units); j++) { | |
| - | 1118 | pCar->damage_units[j].damage_level = pCar->message.damage[j]; | |
| - | 1119 |             } | |
| - | 1120 | SortOutSmoke(pCar); | |
| - | 1121 | } else { | |
| - | 1122 | if (pCar->message.repair_time - pCar->repair_time < 100000) { | |
| - | 1123 | amount = RepairCar2(pCar, pCar->message.repair_time - pCar->repair_time, &total_deflection); | |
| 1088 | 
 | 1124 | } else { | 
| - | 1125 | TotallyRepairACar(pCar); | |
| - | 1126 | pCar->repair_time = pCar->message.repair_time; | |
| - | 1127 |             } | |
| - | 1128 | for (j = 0; j < COUNT_OF(pCar->damage_units); j++) { | |
| - | 1129 | pCar->damage_units[j].damage_level = pCar->message.damage[j]; | |
| - | 1130 |             } | |
| - | 1131 | SetSmokeLastDamageLevel(pCar); | |
| - | 1132 | StopCarSmoking(pCar); | |
| - | 1133 |         } | |
| - | 1134 | if (pCar->driver == eDriver_net_human) { | |
| - | 1135 | pCar->revs = pCar->message.revs; | |
| - | 1136 |         } | |
| - | 1137 | if (pCar->driver >= eDriver_net_human) { | |
| - | 1138 | pCar->bounds[1].min.v[2] = pCar->message.front; | |
| - | 1139 | pCar->bounds[1].max.v[2] = pCar->message.back; | |
| - | 1140 |         } | |
| - | 1141 | if (pCar->driver != eDriver_local_human) { | |
| - | 1142 | for (j = 0; j < COUNT_OF(pCar->wheel_dam_offset); j++) { | |
| - | 1143 | pCar->wheel_dam_offset[j] = pCar->message.wheel_dam_offset[j]; | |
| - | 1144 |             } | |
| - | 1145 |         } | |
| - | 1146 | GetFacesInBox((tCollision_info*)pCar); | |
| - | 1147 |     } | |
| - | 1148 | ||
| - | 1149 | pCar->message.type = 0; | |
| - | 1150 | pCar->last_car_car_collision = pCar->message.cc_coll_time; | |
| 1089 | } | 1151 | } | 
| 1090 | 1152 | ||
| 1091 | // IDA: void __usercall ApplyPhysicsToCars(tU32 last_frame_time@<EAX>, tU32 pTime_difference@<EDX>) | 1153 | // IDA: void __usercall ApplyPhysicsToCars(tU32 last_frame_time@<EAX>, tU32 pTime_difference@<EDX>) | 
| 1092 | void ApplyPhysicsToCars(tU32 last_frame_time, tU32 pTime_difference) { | 1154 | void ApplyPhysicsToCars(tU32 last_frame_time, tU32 pTime_difference) { | 
| 1093 |     //br_vector3 minus_k; // Pierre-Marie Baty -- unused variable | 1155 |     //br_vector3 minus_k; // Pierre-Marie Baty -- unused variable | 
| Line 1134... | Line 1196... | ||
| 1134 | BrVector3Copy(&gCar_to_view->old_v, &gCar_to_view->v); | 1196 | BrVector3Copy(&gCar_to_view->old_v, &gCar_to_view->v); | 
| 1135 |         } | 1197 |         } | 
| 1136 | for (i = 0; i < gNum_active_cars; i++) { | 1198 | for (i = 0; i < gNum_active_cars; i++) { | 
| 1137 | car = gActive_car_list[i]; | 1199 | car = gActive_car_list[i]; | 
| 1138 | car->dt = -1.f; | 1200 | car->dt = -1.f; | 
| 1139 | if (car->message.type == | 1201 | if (car->message.type == NETMSGID_MECHANICS && car->message.time >= gLast_mechanics_time && car->message.time <= gLast_mechanics_time + harness_game_config.physics_step_time) { | 
| - | 1202 |                 // time between car message and next mechanics | |
| 1140 | car->dt = | 1203 | car->dt = (gLast_mechanics_time + harness_game_config.physics_step_time - car->message.time) / 1000.0f; | 
| - | 1204 |                 // if the time between car message and next mechanics is about equal to timestep | |
| 1141 | if ( | 1205 | if (car->dt >= gDt - 0.0001f) { | 
| 1142 | GetNetPos(car); | 1206 | GetNetPos(car); | 
| 1143 | } else if (gNet_mode == eNet_mode_host) { | 1207 | } else if (gNet_mode == eNet_mode_host) { | 
| 1144 | car->dt = -1.f; | 1208 | car->dt = -1.f; | 
| 1145 | } else { | 1209 | } else { | 
| 1146 | for (dam_index = 0; dam_index < COUNT_OF(car->damage_units); dam_index++) { | 1210 | for (dam_index = 0; dam_index < COUNT_OF(car->damage_units); dam_index++) { | 
| Line 1168... | Line 1232... | ||
| 1168 |         } | 1232 |         } | 
| 1169 | for (i = 0; i < gNum_active_non_cars; i++) { | 1233 | for (i = 0; i < gNum_active_non_cars; i++) { | 
| 1170 | non_car = gActive_non_car_list[i]; | 1234 | non_car = gActive_non_car_list[i]; | 
| 1171 | if (!non_car->collision_info.doing_nothing_flag) { | 1235 | if (!non_car->collision_info.doing_nothing_flag) { | 
| 1172 | non_car->collision_info.dt = -1.f; | 1236 | non_car->collision_info.dt = -1.f; | 
| 1173 | if (non_car->collision_info.message.type == | 1237 | if (non_car->collision_info.message.type == NETMSGID_NONCAR_INFO && non_car->collision_info.message.time >= gLast_mechanics_time && gLast_mechanics_time + harness_game_config.physics_step_time >= non_car->collision_info.message.time) { | 
| 1174 | non_car->collision_info.dt = (gLast_mechanics_time + harness_game_config.physics_step_time - non_car->collision_info.message.time) / 1000.0f; | 1238 | non_car->collision_info.dt = (gLast_mechanics_time + harness_game_config.physics_step_time - non_car->collision_info.message.time) / 1000.0f; | 
| 1175 | GetNetPos((tCar_spec*)non_car); | 1239 | GetNetPos((tCar_spec*)non_car); | 
| 1176 |                 } | 1240 |                 } | 
| 1177 | if (non_car->collision_info.box_face_ref != gFace_num__car | 1241 | if (non_car->collision_info.box_face_ref != gFace_num__car | 
| 1178 | && (non_car->collision_info.box_face_ref != gFace_num__car - 1 | 1242 | && (non_car->collision_info.box_face_ref != gFace_num__car - 1 | 
| Line 1420... | Line 1484... | ||
| 1420 | // IDA: void __cdecl ToggleControls() | 1484 | // IDA: void __cdecl ToggleControls() | 
| 1421 | void ToggleControls(void) { | 1485 | void ToggleControls(void) { | 
| 1422 | LOG_TRACE("()"); | 1486 | LOG_TRACE("()"); | 
| 1423 | 1487 | ||
| 1424 |     gControl__car++; | 1488 |     gControl__car++; | 
| 1425 | if (ControlCar[gControl__car] == | 1489 | if (ControlCar[gControl__car] == NULL) { | 
| 1426 | gControl__car = 0; | 1490 | gControl__car = 0; | 
| 1427 |     } | 1491 |     } | 
| 1428 | switch (gControl__car) { | 1492 | switch (gControl__car) { | 
| 1429 | case 0: | 1493 | case 0: | 
| 1430 | NewTextHeadupSlot(4, 0, 500, -1, "Original Controls"); | 1494 | NewTextHeadupSlot(4, 0, 500, -1, "Original Controls"); | 
| Line 1445... | Line 1509... | ||
| 1445 | } | 1509 | } | 
| 1446 | 1510 | ||
| 1447 | // IDA: void __usercall ControlCar2(tCar_spec *c@<EAX>, br_scalar dt) | 1511 | // IDA: void __usercall ControlCar2(tCar_spec *c@<EAX>, br_scalar dt) | 
| 1448 | void ControlCar2(tCar_spec* c, br_scalar dt) { | 1512 | void ControlCar2(tCar_spec* c, br_scalar dt) { | 
| 1449 | LOG_TRACE("(%p, %f)", c, dt); | 1513 | LOG_TRACE("(%p, %f)", c, dt); | 
| - | 1514 | ||
| 1450 | 
 | 1515 | c->acc_force = 0.f; | 
| - | 1516 | if (c->keys.acc) { | |
| - | 1517 | c->acc_force = 7.f * c->M; | |
| - | 1518 |     } | |
| - | 1519 | if (c->keys.dec) { | |
| - | 1520 | c->acc_force = -7.f * c->M; | |
| - | 1521 |     } | |
| - | 1522 | if (c->keys.left) { | |
| - | 1523 | if (c->turn_speed < 0.f) { | |
| - | 1524 | c->turn_speed = 0.f; | |
| - | 1525 |         } | |
| - | 1526 | if (c->curvature >= 0.f) { | |
| - | 1527 | c->turn_speed += dt / 0.04f * (0.05f / (5.f + BrVector3Length(&c->v)) / 2.f); | |
| - | 1528 | } else { | |
| - | 1529 | c->turn_speed += 0.01f * dt / 0.04f / 2.f; | |
| - | 1530 |         } | |
| - | 1531 |     } | |
| - | 1532 | if (c->keys.right) { | |
| - | 1533 | if (c->turn_speed > 0.f) { | |
| - | 1534 | c->turn_speed = 0.f; | |
| - | 1535 |         } | |
| - | 1536 | if (c->curvature <= 0.f) { | |
| - | 1537 | c->turn_speed -= dt / 0.04f * (0.05f / (5.f + BrVector3Length(&c->v)) / 2.f); | |
| - | 1538 | } else { | |
| - | 1539 | c->turn_speed -= 0.01f * dt / 0.04f / 2.f; | |
| - | 1540 |         } | |
| - | 1541 |     } | |
| - | 1542 | if (!c->keys.left && !c->keys.right) { | |
| - | 1543 | c->turn_speed = 0.f; | |
| - | 1544 |     } | |
| - | 1545 | c->curvature += c->turn_speed; | |
| - | 1546 | if (c->curvature > c->maxcurve) { | |
| - | 1547 | c->curvature = c->maxcurve; | |
| - | 1548 |     } | |
| - | 1549 | if (c->curvature < -c->maxcurve) { | |
| - | 1550 | c->curvature = -c->maxcurve; | |
| - | 1551 |     } | |
| 1451 | } | 1552 | } | 
| 1452 | 1553 | ||
| 1453 | // IDA: void __usercall ControlCar3(tCar_spec *c@<EAX>, br_scalar dt) | 1554 | // IDA: void __usercall ControlCar3(tCar_spec *c@<EAX>, br_scalar dt) | 
| 1454 | void ControlCar3(tCar_spec* c, br_scalar dt) { | 1555 | void ControlCar3(tCar_spec* c, br_scalar dt) { | 
| 1455 | LOG_TRACE("(%p, %f)", c, dt); | 1556 | LOG_TRACE("(%p, %f)", c, dt); | 
| - | 1557 | ||
| 1456 | 
 | 1558 | if (c->keys.left) { | 
| - | 1559 | if (c->turn_speed < 0.f) { | |
| - | 1560 | c->turn_speed = 0.f; | |
| - | 1561 |         } | |
| - | 1562 | if (c->curvature >= 0.f && c->omega.v[1] >= 0.f) { | |
| - | 1563 | c->turn_speed += dt / 0.04f * (0.05f / (5.f + BrVector3Length(&c->v)) / 2.f) * 0.75f; | |
| - | 1564 | } else { | |
| - | 1565 | c->turn_speed += 0.01f * dt / 0.04f / 2.f * 3.f; | |
| - | 1566 |         } | |
| - | 1567 |     } | |
| - | 1568 | ||
| - | 1569 | if (c->keys.right) { | |
| - | 1570 | if (c->turn_speed > 0.f) { | |
| - | 1571 | c->turn_speed = 0.f; | |
| - | 1572 |         } | |
| - | 1573 | if (c->curvature <= 0.f && c->omega.v[1] <= 0.f) { | |
| - | 1574 | c->turn_speed -= dt / 0.04f * (0.05f / (5.f + BrVector3Length(&c->v)) / 2.f) * 0.75f; | |
| - | 1575 | } else { | |
| - | 1576 | c->turn_speed -= 0.01f * dt / 0.04f / 2.f * 3.f; | |
| - | 1577 |         } | |
| - | 1578 |     } | |
| - | 1579 | if (!c->keys.left && !c->keys.right) { | |
| - | 1580 | c->turn_speed = 0.f; | |
| - | 1581 |     } | |
| - | 1582 | c->curvature += c->turn_speed; | |
| - | 1583 | if (c->curvature > c->maxcurve) { | |
| - | 1584 | c->curvature = c->maxcurve; | |
| - | 1585 |     } | |
| - | 1586 | if (c->curvature < -c->maxcurve) { | |
| - | 1587 | c->curvature = -c->maxcurve; | |
| - | 1588 |     } | |
| 1457 | } | 1589 | } | 
| 1458 | 1590 | ||
| 1459 | // IDA: void __usercall ControlCar4(tCar_spec *c@<EAX>, br_scalar dt) | 1591 | // IDA: void __usercall ControlCar4(tCar_spec *c@<EAX>, br_scalar dt) | 
| 1460 | void ControlCar4(tCar_spec* c, br_scalar dt) { | 1592 | void ControlCar4(tCar_spec* c, br_scalar dt) { | 
| 1461 |     //br_scalar ts; // Pierre-Marie Baty -- unused variable | 1593 |     //br_scalar ts; // Pierre-Marie Baty -- unused variable | 
| Line 1511... | Line 1643... | ||
| 1511 | } | 1643 | } | 
| 1512 | 1644 | ||
| 1513 | // IDA: void __usercall ControlCar5(tCar_spec *c@<EAX>, br_scalar dt) | 1645 | // IDA: void __usercall ControlCar5(tCar_spec *c@<EAX>, br_scalar dt) | 
| 1514 | void ControlCar5(tCar_spec* c, br_scalar dt) { | 1646 | void ControlCar5(tCar_spec* c, br_scalar dt) { | 
| 1515 | LOG_TRACE("(%p, %f)", c, dt); | 1647 | LOG_TRACE("(%p, %f)", c, dt); | 
| - | 1648 | ||
| - | 1649 | c->acc_force = 0.f; | |
| - | 1650 | if (c->keys.acc) { | |
| - | 1651 | c->acc_force = 7.f * c->M; | |
| - | 1652 |     } | |
| - | 1653 | if (c->keys.dec) { | |
| - | 1654 | c->acc_force = -7.f * c->M; | |
| - | 1655 |     } | |
| - | 1656 | if (c->keys.left) { | |
| - | 1657 | if (c->turn_speed < 0.f) { | |
| - | 1658 | c->turn_speed = 0.f; | |
| - | 1659 |         } | |
| - | 1660 | if (c->curvature >= 0) { | |
| - | 1661 | c->turn_speed += dt / 0.04f * (0.05f / (5.f + BrVector3Length(&c->v)) / 2.f) * 0.5f; | |
| - | 1662 | } else { | |
| - | 1663 | c->turn_speed += 0.01f * dt / 0.04f / 2.f * .5f; | |
| - | 1664 |         } | |
| - | 1665 |     } | |
| - | 1666 | if (c->keys.right) { | |
| - | 1667 | if (c->turn_speed > 0.f) { | |
| - | 1668 | c->turn_speed = 0.f; | |
| - | 1669 |         } | |
| - | 1670 | if (c->curvature <= 0) { | |
| - | 1671 | c->turn_speed -= dt / 0.04f * (0.05f / (5.f + BrVector3Length(&c->v)) / 2.f) * 0.5f; | |
| - | 1672 | } else { | |
| - | 1673 | c->turn_speed -= 0.01f * dt / 0.04f / 2.f * .5f; | |
| - | 1674 |         } | |
| - | 1675 |     } | |
| - | 1676 | if (!c->keys.left && !c->keys.right) { | |
| - | 1677 | c->turn_speed = 0.f; | |
| - | 1678 | if (c->curvature < 0.f && !c->keys.holdw) { | |
| - | 1679 | c->curvature += dt / 0.04f * 0.05f / (5.f + BrVector3Length(&c->v)) / 2.f * 4.f; | |
| - | 1680 | if (c->curvature > 0.f) { | |
| - | 1681 | c->curvature = 0.f; | |
| - | 1682 |             } | |
| - | 1683 | } else if (c->curvature > 0.f && !c->keys.holdw) { | |
| - | 1684 | c->curvature -= dt / 0.04f * 0.05f / (5.f + BrVector3Length(&c->v)) / 2.f * 4.f; | |
| - | 1685 | if (c->curvature < 0.f) { | |
| - | 1686 | c->curvature = 0.f; | |
| - | 1687 |             } | |
| - | 1688 |         } | |
| - | 1689 |     } | |
| - | 1690 | c->curvature += c->turn_speed; | |
| - | 1691 | if (c->curvature > c->maxcurve) { | |
| - | 1692 | c->curvature = c->maxcurve; | |
| - | 1693 |     } | |
| - | 1694 | if (c->curvature < -c->maxcurve) { | |
| - | 1695 | c->curvature = -c->maxcurve; | |
| - | 1696 |     } | |
| 1516 | 
 | 1697 | c->keys.left = 1; | 
| 1517 | } | 1698 | } | 
| 1518 | 1699 | ||
| 1519 | // IDA: void __usercall ControlCar1(tCar_spec *c@<EAX>, br_scalar dt) | 1700 | // IDA: void __usercall ControlCar1(tCar_spec *c@<EAX>, br_scalar dt) | 
| 1520 | void ControlCar1(tCar_spec* c, br_scalar dt) { | 1701 | void ControlCar1(tCar_spec* c, br_scalar dt) { | 
| 1521 | LOG_TRACE("(%p, %f)", c, dt); | 1702 | LOG_TRACE("(%p, %f)", c, dt); | 
| - | 1703 | ||
| 1522 | 
 | 1704 | c->acc_force = 0.f; | 
| - | 1705 | if (c->keys.acc) { | |
| - | 1706 | c->acc_force = 7.f * c->M; | |
| - | 1707 |     } | |
| - | 1708 | if (c->keys.dec) { | |
| - | 1709 | c->acc_force = -7.f * c->M; | |
| - | 1710 |     } | |
| - | 1711 | if (c->keys.left) { | |
| - | 1712 | if (c->curvature >= 0.f) { | |
| - | 1713 | c->curvature += dt / 0.04f * 0.05f / (5.f + BrVector3Length(&c->v)); | |
| - | 1714 | } else { | |
| - | 1715 | c->curvature += 0.01f * dt / 0.04f; | |
| - | 1716 |         } | |
| - | 1717 |     } | |
| - | 1718 | if (c->keys.right) { | |
| - | 1719 | if (c->curvature <= 0.f) { | |
| - | 1720 | c->curvature -= dt / 0.04f * 0.05f / (5.f + BrVector3Length(&c->v)); | |
| - | 1721 | } else { | |
| - | 1722 | c->curvature -= 0.01f * dt / 0.04f; | |
| - | 1723 |         } | |
| - | 1724 |     } | |
| - | 1725 | if (c->curvature > c->maxcurve) { | |
| - | 1726 | c->curvature = c->maxcurve; | |
| - | 1727 |     } | |
| - | 1728 | if (c->curvature < -c->maxcurve) { | |
| - | 1729 | c->curvature = -c->maxcurve; | |
| - | 1730 |     } | |
| 1523 | } | 1731 | } | 
| 1524 | 1732 | ||
| 1525 | // IDA: void __usercall setrotate(br_vector3 *wdt@<EAX>, br_matrix34 *m@<EDX>) | 1733 | // IDA: void __usercall setrotate(br_vector3 *wdt@<EAX>, br_matrix34 *m@<EDX>) | 
| 1526 | void setrotate(br_vector3* wdt, br_matrix34* m) { | 1734 | void setrotate(br_vector3* wdt, br_matrix34* m) { | 
| 1527 | 
 | 1735 | br_euler e; | 
| 1528 | LOG_TRACE("(%p, %p)", wdt, m); | 1736 | LOG_TRACE("(%p, %p)", wdt, m); | 
| - | 1737 | ||
| - | 1738 | e.a = BR_ANGLE_RAD(wdt->v[0]); | |
| - | 1739 | e.b = BR_ANGLE_RAD(wdt->v[1]); | |
| - | 1740 | e.c = BR_ANGLE_RAD(wdt->v[2]); | |
| - | 1741 | e.order = 0; | |
| 1529 | 
 | 1742 | BrEulerToMatrix34(m, &e); | 
| 1530 | } | 1743 | } | 
| 1531 | 1744 | ||
| 1532 | // IDA: void __usercall RotateCar2(tCollision_info *c@<EAX>, br_scalar dt) | 1745 | // IDA: void __usercall RotateCar2(tCollision_info *c@<EAX>, br_scalar dt) | 
| 1533 | void RotateCar2(tCollision_info* c, br_scalar dt) { | 1746 | void RotateCar2(tCollision_info* c, br_scalar dt) { | 
| 1534 | 
 | 1747 | br_vector3 wdt; | 
| 1535 | 
 | 1748 | br_vector3 wdt2; | 
| 1536 | 
 | 1749 | br_vector3 L; | 
| 1537 | 
 | 1750 | br_vector3 L2; | 
| 1538 | 
 | 1751 | br_matrix34 m; | 
| 1539 | LOG_TRACE("(%p, %f)", c, dt); | 1752 | LOG_TRACE("(%p, %f)", c, dt); | 
| - | 1753 | ||
| - | 1754 | BrVector3Scale(&wdt, &c->omega, dt); | |
| - | 1755 | BrVector3Negate(&wdt2, &wdt); | |
| - | 1756 | BrVector3Mul(&L, &c->I, &c->omega); | |
| - | 1757 | setrotate(&wdt2, &m); | |
| - | 1758 | BrMatrix34ApplyV(&L2, &L, &m); | |
| 1540 | 
 | 1759 | setrotate(&wdt, &m); | 
| - | 1760 | BrMatrix34PreTranslate(&m, -c->cmpos.v[0], -c->cmpos.v[1], -c->cmpos.v[2]); | |
| - | 1761 | BrMatrix34PostTranslate(&m, c->cmpos.v[0], c->cmpos.v[1], c->cmpos.v[2]); | |
| - | 1762 | BrMatrix34Pre(&c->car_master_actor->t.t.mat, &m); | |
| - | 1763 | BrVector3Copy(&c->oldomega, &c->omega); | |
| - | 1764 | Vector3Div(&c->omega, &L2, &c->I); | |
| 1541 | } | 1765 | } | 
| 1542 | 1766 | ||
| 1543 | // IDA: void __usercall RotateCarSecondOrder(tCollision_info *c@<EAX>, br_scalar dt) | 1767 | // IDA: void __usercall RotateCarSecondOrder(tCollision_info *c@<EAX>, br_scalar dt) | 
| 1544 | void RotateCarSecondOrder(tCollision_info* c, br_scalar dt) { | 1768 | void RotateCarSecondOrder(tCollision_info* c, br_scalar dt) { | 
| 1545 |     br_vector3 L; | 1769 |     br_vector3 L; | 
| Line 4326... | Line 4550... | ||
| 4326 | MungeCarGraphics(gFrame_period); | 4550 | MungeCarGraphics(gFrame_period); | 
| 4327 | } | 4551 | } | 
| 4328 | 4552 | ||
| 4329 | // IDA: tCar_spec* __cdecl GetRaceLeader() | 4553 | // IDA: tCar_spec* __cdecl GetRaceLeader() | 
| 4330 | tCar_spec* GetRaceLeader(void) { | 4554 | tCar_spec* GetRaceLeader(void) { | 
| 4331 | 
 | 4555 | int i; | 
| 4332 | 
 | 4556 | int score; | 
| 4333 | 
 | 4557 | tCar_spec* car; | 
| 4334 | LOG_TRACE("()"); | 4558 | LOG_TRACE("()"); | 
| - | 4559 | ||
| - | 4560 | if ((gCurrent_net_game->type == eNet_game_type_foxy || gCurrent_net_game->type == eNet_game_type_tag) && gIt_or_fox >= 0 && gIt_or_fox < gNumber_of_net_players) { | |
| - | 4561 | car = gNet_players[gIt_or_fox].car; | |
| - | 4562 | } else { | |
| - | 4563 | car = gNet_players[0].car; | |
| - | 4564 | score = gNet_players[0].last_score_index; | |
| - | 4565 | for (i = 1; i < gNumber_of_net_players; i++) { | |
| - | 4566 | if (score > gNet_players[i].last_score_index) { | |
| - | 4567 | score = gNet_players[i].last_score_index; | |
| - | 4568 | car = gNet_players[i].car; | |
| - | 4569 |             } | |
| - | 4570 |         } | |
| - | 4571 |     } | |
| 4335 | 
 | 4572 | return car; | 
| 4336 | } | 4573 | } | 
| 4337 | 4574 | ||
| 4338 | // IDA: void __cdecl AmIGettingBoredWatchingCameraSpin() | 4575 | // IDA: void __cdecl AmIGettingBoredWatchingCameraSpin() | 
| 4339 | void AmIGettingBoredWatchingCameraSpin(void) { | 4576 | void AmIGettingBoredWatchingCameraSpin(void) { | 
| 4340 | 
 | 4577 | static tU32 time_of_death; | 
| 4341 | 
 | 4578 | static tU32 headup_timer; | 
| 4342 | 
 | 4579 | tCar_spec* car; | 
| 4343 | 
 | 4580 | char s[256]; | 
| 4344 | LOG_TRACE("()"); | 4581 | LOG_TRACE("()"); | 
| 4345 | 4582 | ||
| - | 4583 | if (gNet_mode == eNet_mode_none | |
| - | 4584 | || (gCurrent_net_game->type != eNet_game_type_sudden_death | |
| - | 4585 | && gCurrent_net_game->type != eNet_game_type_tag | |
| - | 4586 | && gCurrent_net_game->type != eNet_game_type_fight_to_death)) { | |
| - | 4587 | gOpponent_viewing_mode = 0; | |
| - | 4588 | } else if (!gRace_finished) { | |
| - | 4589 | time_of_death = 0; | |
| - | 4590 | gOpponent_viewing_mode = 0; | |
| - | 4591 | } else if (time_of_death == 0) { | |
| - | 4592 | time_of_death = GetRaceTime(); | |
| - | 4593 | } else { | |
| - | 4594 | if (GetRaceTime() >= time_of_death + 10000) { | |
| - | 4595 | if (gOpponent_viewing_mode == 0) { | |
| - | 4596 | gOpponent_viewing_mode = 1; | |
| - | 4597 | gNet_player_to_view_index = -2; | |
| - | 4598 | ViewNetPlayer(); | |
| - | 4599 |             } | |
| - | 4600 | if (gNet_player_to_view_index >= gNumber_of_net_players) { | |
| - | 4601 | gNet_player_to_view_index = -2; | |
| - | 4602 | ViewNetPlayer(); | |
| - | 4603 |             } | |
| - | 4604 | if (gNet_player_to_view_index < 0 && gCar_to_view != GetRaceLeader()) { | |
| - | 4605 | gNet_player_to_view_index = -2; | |
| - | 4606 | ViewNetPlayer(); | |
| - | 4607 |             } | |
| - | 4608 | if ((GetRaceTime() > headup_timer + 1000 || headup_timer > GetRaceTime()) && gRace_over_reason == eRace_not_over_yet) { | |
| - | 4609 | strcpy(s, GetMiscString(kMiscString_WATCHING)); | |
| - | 4610 | strcat(s, " "); | |
| - | 4611 | if (gNet_player_to_view_index >= 0) { | |
| - | 4612 | strcat(s, gNet_players[gNet_player_to_view_index].player_name); | |
| - | 4613 | } else if (gCurrent_net_game->type == eNet_game_type_tag) { | |
| - | 4614 | strcat(s, GetMiscString(kMiscString_QUOTE_IT_QUOTE)); | |
| - | 4615 | } else { | |
| - | 4616 | strcat(s, GetMiscString(kMiscString_RACE_LEADER)); | |
| 4346 | 
 | 4617 |                 } | 
| - | 4618 | headup_timer = GetRaceTime(); | |
| - | 4619 | NewTextHeadupSlot(6, 0, 500, -4, s); | |
| - | 4620 |             } | |
| - | 4621 |         } | |
| - | 4622 |     } | |
| 4347 | } | 4623 | } | 
| 4348 | 4624 | ||
| 4349 | // IDA: void __cdecl ViewNetPlayer() | 4625 | // IDA: void __cdecl ViewNetPlayer() | 
| 4350 | void ViewNetPlayer(void) { | 4626 | void ViewNetPlayer(void) { | 
| 4351 | LOG_TRACE("()"); | 4627 | LOG_TRACE("()"); | 
| Line 4544... | Line 4820... | ||
| 4544 | 4820 | ||
| 4545 | if (gAction_replay_mode && gAction_replay_camera_mode != eAction_replay_standard && gPed_actor != NULL && !gProgram_state.cockpit_on) { | 4821 | if (gAction_replay_mode && gAction_replay_camera_mode != eAction_replay_standard && gPed_actor != NULL && !gProgram_state.cockpit_on) { | 
| 4546 | IncidentCam(c, pTime); | 4822 | IncidentCam(c, pTime); | 
| 4547 |     } | 4823 |     } | 
| 4548 | } | 4824 | } | 
| 4549 | - | ||
| 4550 | // IDA: int __usercall PossibleRemoveNonCarFromWorld@<EAX>(br_actor *pActor@<EAX>) | 4825 | // IDA: int __usercall PossibleRemoveNonCarFromWorld@<EAX>(br_actor *pActor@<EAX>) | 
| 4551 | int PossibleRemoveNonCarFromWorld(br_actor* pActor) { | 4826 | int PossibleRemoveNonCarFromWorld(br_actor* pActor) { | 
| 4552 |     tU8 cx; | 4827 |     tU8 cx; | 
| 4553 |     tU8 cz; | 4828 |     tU8 cz; | 
| 4554 | tTrack_spec* track_spec; | 4829 | tTrack_spec* track_spec; | 
| Line 5406... | Line 5681... | ||
| 5406 | return i; | 5681 | return i; | 
| 5407 | } | 5682 | } | 
| 5408 | 5683 | ||
| 5409 | // IDA: int __usercall BoundsTest@<EAX>(br_bounds *bnds@<EAX>, br_vector3 *p@<EDX>) | 5684 | // IDA: int __usercall BoundsTest@<EAX>(br_bounds *bnds@<EAX>, br_vector3 *p@<EDX>) | 
| 5410 | int BoundsTest(br_bounds* bnds, br_vector3* p) { | 5685 | int BoundsTest(br_bounds* bnds, br_vector3* p) { | 
| 5411 | 
 | 5686 | int j; | 
| 5412 | LOG_TRACE("(%p, %p)", bnds, p); | 5687 | LOG_TRACE("(%p, %p)", bnds, p); | 
| - | 5688 | ||
| - | 5689 | for (j = 0; j < 3; j++) { | |
| - | 5690 | if (p->v[j] > bnds->max.v[j] || p->v[j] < bnds->min.v[j]) { | |
| 5413 | 
 | 5691 | return 0; | 
| - | 5692 |         } | |
| - | 5693 |     } | |
| - | 5694 | return 1; | |
| 5414 | } | 5695 | } | 
| 5415 | 5696 | ||
| 5416 | // IDA: int __usercall CollideCameraWithOtherCars@<EAX>(br_vector3 *car_pos@<EAX>, br_vector3 *cam_pos@<EDX>) | 5697 | // IDA: int __usercall CollideCameraWithOtherCars@<EAX>(br_vector3 *car_pos@<EAX>, br_vector3 *cam_pos@<EDX>) | 
| 5417 | int CollideCameraWithOtherCars(br_vector3* car_pos, br_vector3* cam_pos) { | 5698 | int CollideCameraWithOtherCars(br_vector3* car_pos, br_vector3* cam_pos) { | 
| 5418 | 
 | 5699 | int i; | 
| 5419 | 
 | 5700 | int plane; | 
| 5420 | 
 | 5701 | br_scalar ts; | 
| 5421 | 
 | 5702 | tCar_spec* c; | 
| 5422 | 
 | 5703 | br_vector3 tv; | 
| 5423 | 
 | 5704 | br_vector3 pos_car_space; | 
| 5424 | 
 | 5705 | br_vector3 dir; | 
| 5425 | 
 | 5706 | br_vector3 p; | 
| 5426 | 
 | 5707 | br_vector3 n; | 
| 5427 | 
 | 5708 | br_bounds bnds; | 
| 5428 | LOG_TRACE("(%p, %p)", car_pos, cam_pos); | 5709 | LOG_TRACE("(%p, %p)", car_pos, cam_pos); | 
| 5429 | 5710 | ||
| - | 5711 | for (i = 0; i < gNum_cars_and_non_cars; i++) { | |
| - | 5712 | if (BoundsTest(&gActive_car_list[i]->bounds_world_space, cam_pos)) { | |
| - | 5713 | c = gActive_car_list[i]; | |
| - | 5714 | BrVector3Sub(&tv, cam_pos, &c->car_master_actor->t.t.translate.t); | |
| - | 5715 | BrMatrix34TApplyV(&p, &tv, &c->car_master_actor->t.t.mat); | |
| - | 5716 | if (BoundsTest(&c->bounds[0], &p)) { | |
| - | 5717 | BrVector3Sub(&tv, cam_pos, car_pos); | |
| - | 5718 | BrMatrix34TApplyV(&dir, &tv, &c->car_master_actor->t.t.mat); | |
| - | 5719 | BrVector3Add(&pos_car_space, &p, &dir); | |
| - | 5720 | BrVector3SetFloat(&tv, 0.03f, 0.03f, 0.03f); | |
| - | 5721 | BrVector3Sub(&bnds.min, &c->bounds[0].min, &tv); | |
| - | 5722 | BrVector3Add(&bnds.max, &c->bounds[0].max, &tv); | |
| - | 5723 | plane = LineBoxColl(&pos_car_space, &p, &bnds, &tv); | |
| - | 5724 | BrMatrix34ApplyP(cam_pos, &tv, &c->car_master_actor->t.t.mat); | |
| - | 5725 | return 1; | |
| 5430 | 
 | 5726 |             } | 
| - | 5727 |         } | |
| - | 5728 |     } | |
| 5431 | return 0; | 5729 | return 0; | 
| 5432 | } | 5730 | } | 
| 5433 | 5731 | ||
| 5434 | // IDA: void __cdecl InitialiseExternalCamera() | 5732 | // IDA: void __cdecl InitialiseExternalCamera() | 
| 5435 | void InitialiseExternalCamera(void) { | 5733 | void InitialiseExternalCamera(void) { |