MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / read_controls

Method read_controls

Descent3/pilot_class.cpp:1399–1484  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1397}
1398
1399void pilot::read_controls(CFILE *file, bool skip) {
1400 float temp_f;
1401 uint8_t temp_b;
1402 int i;
1403
1404 // Controller data
1405 temp_b = cf_ReadByte(file);
1406
1407 // alway read this?
1408 read_controller = temp_b;
1409
1410 temp_b = cf_ReadByte(file);
1411
1412 for (i = 0; i < temp_b; i++) {
1413 int id, y;
1414 ct_type type[2];
1415 ct_config_data value;
1416
1417 id = cf_ReadInt(file);
1418 type[0] = (ct_type)cf_ReadInt(file);
1419 type[1] = (ct_type)cf_ReadInt(file);
1420 value = (ct_config_data)cf_ReadInt(file);
1421
1422 for (y = 0; y < temp_b; y++) {
1423 if (Controller_needs[y].id == id) {
1424 if (type[0] == ctNone) // do this if there are new functions that don't have ctNone.
1425 type[0] = Controller_needs[y].ctype[0];
1426 if (type[1] == ctNone) // do this if there are new functions that don't have ctNone.
1427 type[1] = Controller_needs[y].ctype[1];
1428 break;
1429 }
1430 }
1431
1432 controls[y].id = id;
1433 controls[y].type[0] = type[0];
1434 controls[y].type[1] = type[1];
1435 controls[y].value = value;
1436 controls[y].flags[0] = (uint8_t)cf_ReadByte(file);
1437 controls[y].flags[1] = (uint8_t)cf_ReadByte(file);
1438
1439 if (!skip)
1440 Controller->set_controller_function(controls[y].id, controls[y].type, controls[y].value, controls[y].flags);
1441 }
1442
1443 // fill in remainder of pilot controls array.
1444 for (; i < NUM_CONTROLLER_FUNCTIONS; i++) {
1445 Controller->get_controller_function(Controller_needs[i].id, controls[i].type, &controls[i].value,
1446 controls[i].flags);
1447 }
1448
1449 // Set controller enabled masks
1450 if (!skip && Controller) {
1451 Controller->mask_controllers((read_controller & READF_JOY) ? true : false,
1452 (read_controller & READF_MOUSE) ? true : false);
1453 }
1454
1455 // mouse sensitivity
1456 temp_b = cf_ReadByte(file);

Callers

nothing calls this directly

Calls 6

cf_ReadByteFunction · 0.85
cf_ReadIntFunction · 0.85
cf_ReadFloatFunction · 0.85
mask_controllersMethod · 0.45

Tested by

no test coverage detected