|
2 | 2 |
|
3 | 3 | bool foundIWAD = false;
|
4 | 4 | bool wipeDone = true;
|
| 5 | +int last_automap_input[4] = { 0 }; |
| 6 | + |
| 7 | +void send_input(struct PackedPlayerInput *inputs, int playerId) |
| 8 | +{ |
| 9 | + local_cmds[playerId].forwardmove = inputs->RunSpeed; |
| 10 | + local_cmds[playerId].sidemove = inputs->StrafingSpeed; |
| 11 | + local_cmds[playerId].angleturn = (shorttics || !longtics) ? inputs->TurningSpeed << 8 : inputs->TurningSpeed; |
| 12 | + |
| 13 | + if (inputs->Fire == 1) local_cmds[playerId].buttons |= 0b00000001; |
| 14 | + if (inputs->Action == 1) local_cmds[playerId].buttons |= 0b00000010; |
| 15 | + |
| 16 | + if (inputs->WeaponSelect != 0) |
| 17 | + { |
| 18 | + local_cmds[playerId].buttons |= BT_CHANGE; |
| 19 | + local_cmds[playerId].buttons |= (inputs->WeaponSelect - 1)<<BT_WEAPONSHIFT; |
| 20 | + } |
| 21 | + |
| 22 | + local_cmds[playerId].lookfly = inputs->FlyLook; |
| 23 | + local_cmds[playerId].arti = inputs->ArtifactUse; |
| 24 | + |
| 25 | + if (inputs->EndPlayer == 1) local_cmds[playerId].arti |= 0b01000000; |
| 26 | + if (inputs->Jump == 1) local_cmds[playerId].arti |= 0b10000000; |
| 27 | + |
| 28 | + if (inputs->Automap && !last_automap_input[playerId]) |
| 29 | + { |
| 30 | + if (automap_input) |
| 31 | + AM_Stop(true); |
| 32 | + else |
| 33 | + AM_Start(true); |
| 34 | + } |
| 35 | + last_automap_input[playerId] = inputs->Automap; |
| 36 | + |
| 37 | + // printf("ForwardSpeed: %d - sideMove: %d - angleTurn: %d - buttons: %u\n", forwardSpeed, strafingSpeed, turningSpeed, local_cmds[playerId].buttons); |
| 38 | +} |
5 | 39 |
|
6 | 40 | ECL_EXPORT void dsda_get_audio(int *n, void **buffer)
|
7 | 41 | {
|
@@ -43,73 +77,11 @@ ECL_EXPORT bool dsda_frame_advance(struct PackedPlayerInput *player1Inputs, stru
|
43 | 77 | // Setting inputs
|
44 | 78 | headlessClearTickCommand();
|
45 | 79 |
|
46 |
| - // Setting Player 1 inputs |
47 |
| - headlessSetTickCommand |
48 |
| - ( |
49 |
| - 0, |
50 |
| - player1Inputs->RunSpeed, |
51 |
| - player1Inputs->StrafingSpeed, |
52 |
| - player1Inputs->TurningSpeed, |
53 |
| - player1Inputs->Fire, |
54 |
| - player1Inputs->Action, |
55 |
| - player1Inputs->WeaponSelect, |
56 |
| - player1Inputs->Automap, |
57 |
| - player1Inputs->FlyLook, |
58 |
| - player1Inputs->ArtifactUse, |
59 |
| - player1Inputs->Jump, |
60 |
| - player1Inputs->EndPlayer |
61 |
| - ); |
62 |
| - |
63 |
| - // Setting Player 2 inputs |
64 |
| - headlessSetTickCommand |
65 |
| - ( |
66 |
| - 1, |
67 |
| - player2Inputs->RunSpeed, |
68 |
| - player2Inputs->StrafingSpeed, |
69 |
| - player2Inputs->TurningSpeed, |
70 |
| - player2Inputs->Fire, |
71 |
| - player2Inputs->Action, |
72 |
| - player2Inputs->WeaponSelect, |
73 |
| - player2Inputs->Automap, |
74 |
| - player2Inputs->FlyLook, |
75 |
| - player2Inputs->ArtifactUse, |
76 |
| - player2Inputs->Jump, |
77 |
| - player2Inputs->EndPlayer |
78 |
| - ); |
79 |
| - |
80 |
| - // Setting Player 3 inputs |
81 |
| - headlessSetTickCommand |
82 |
| - ( |
83 |
| - 2, |
84 |
| - player3Inputs->RunSpeed, |
85 |
| - player3Inputs->StrafingSpeed, |
86 |
| - player3Inputs->TurningSpeed, |
87 |
| - player3Inputs->Fire, |
88 |
| - player3Inputs->Action, |
89 |
| - player3Inputs->WeaponSelect, |
90 |
| - player3Inputs->Automap, |
91 |
| - player3Inputs->FlyLook, |
92 |
| - player3Inputs->ArtifactUse, |
93 |
| - player3Inputs->Jump, |
94 |
| - player3Inputs->EndPlayer |
95 |
| - ); |
96 |
| - |
97 |
| - // Setting Player 4 inputs |
98 |
| - headlessSetTickCommand |
99 |
| - ( |
100 |
| - 3, |
101 |
| - player4Inputs->RunSpeed, |
102 |
| - player4Inputs->StrafingSpeed, |
103 |
| - player4Inputs->TurningSpeed, |
104 |
| - player4Inputs->Fire, |
105 |
| - player4Inputs->Action, |
106 |
| - player4Inputs->WeaponSelect, |
107 |
| - player4Inputs->Automap, |
108 |
| - player4Inputs->FlyLook, |
109 |
| - player4Inputs->ArtifactUse, |
110 |
| - player4Inputs->Jump, |
111 |
| - player4Inputs->EndPlayer |
112 |
| - ); |
| 80 | + // Setting Players inputs |
| 81 | + send_input(player1Inputs, 0); |
| 82 | + send_input(player2Inputs, 1); |
| 83 | + send_input(player3Inputs, 2); |
| 84 | + send_input(player4Inputs, 3); |
113 | 85 |
|
114 | 86 | // Enabling/Disabling rendering, as required
|
115 | 87 | if (!renderInfo->RenderVideo) headlessDisableVideoRendering();
|
|
0 commit comments