-
Notifications
You must be signed in to change notification settings - Fork 0
/
telemetry.cpp
1881 lines (1569 loc) · 69.3 KB
/
telemetry.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/**
* @brief Simple logger.
*
* Writes the output into file inside the current directory.
*/
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <stdarg.h>
#include <string.h>
#include <string>
#include <iostream>
#include <cstring>
#include <sstream>
#include <thread>
#include <netinet/in.h>
#include <unistd.h>
// SDK
#include "./include/scssdk_telemetry.h"
#include "./include/eurotrucks2/scssdk_eut2.h"
#include "./include/eurotrucks2/scssdk_telemetry_eut2.h"
#include "./include/amtrucks/scssdk_ats.h"
#include "./include/amtrucks/scssdk_telemetry_ats.h"
#define UNUSED(x)
#define speedMultiplicatorToKmh 3.571428571
/**
* @brief Function writting message to the game internal log.
*/
scs_log_t game_log = NULL;
/**
* @brief Tracking of paused state of the game.
*/
bool output_paused = true;
struct Game {
bool connected;
bool paused;
std::string time;
int timeScale;
std::string nextRestStopTime;
std::string version;
std::string telemetryPluginVersion;
};
struct Placement {
double x;
double y;
double z;
double heading;
double pitch;
double roll;
};
struct Acceleration {
double x;
double y;
double z;
};
struct Head {
double x;
double y;
double z;
};
struct Cabin {
double x;
double y;
double z;
};
struct Hook {
double x;
double y;
double z;
};
struct Truck {
std::string id;
std::string make;
std::string model;
double speed;
double cruiseControlSpeed;
bool cruiseControlOn;
double odometer;
int gear;
int displayedGear;
int forwardGears;
int reverseGears;
std::string shifterType;
double engineRpm;
double engineRpmMax;
double fuel;
double fuelCapacity;
double fuelAverageConsumption;
double fuelWarningFactor;
bool fuelWarningOn;
double wearEngine;
double wearTransmission;
double wearCabin;
double wearChassis;
double wearWheels;
double userSteer;
double userThrottle;
double userBrake;
double userClutch;
double gameSteer;
double gameThrottle;
double gameBrake;
double gameClutch;
int shifterSlot;
bool engineOn;
bool electricOn;
bool wipersOn;
double retarderBrake;
int retarderStepCount;
bool parkBrakeOn;
bool motorBrakeOn;
double brakeTemperature;
double adblue;
double adblueCapacity;
double adblueAverageConsumpton;
bool adblueWarningOn;
double airPressure;
bool airPressureWarningOn;
double airPressureWarningValue;
bool airPressureEmergencyOn;
double airPressureEmergencyValue;
double oilTemperature;
double oilPressure;
bool oilPressureWarningOn;
double oilPressureWarningValue;
double waterTemperature;
bool waterTemperatureWarningOn;
double waterTemperatureWarningValue;
double batteryVoltage;
bool batteryVoltageWarningOn;
double batteryVoltageWarningValue;
int lightsDashboardValue;
bool lightsDashboardOn;
bool blinkerLeftActive;
bool blinkerRightActive;
bool blinkerLeftOn;
bool blinkerRightOn;
bool lightsParkingOn;
bool lightsBeamLowOn;
bool lightsBeamHighOn;
bool lightsAuxFrontOn;
bool lightsAuxRoofOn;
bool lightsBeaconOn;
bool lightsBrakeOn;
bool lightsReverseOn;
Placement placement;
Acceleration acceleration;
Head head;
Cabin cabin;
Hook hook;
};
struct Trailer {
bool attached;
std::string id;
std::string name;
double mass;
double wear;
Placement placement;
};
struct Job {
int income;
std::string deadlineTime;
std::string remainingTime;
std::string sourceCity;
std::string sourceCompany;
std::string destinationCity;
std::string destinationCompany;
};
struct Navigation {
std::string estimatedTime;
int estimatedDistance;
int speedLimit;
};
struct GameState {
Game game;
Truck truck;
Trailer trailer;
Job job;
Navigation navigation;
} game_state_s;
struct GameState *game_state = &game_state_s;
std::string convertToJson(const GameState& gameState) {
std::ostringstream oss;
oss << "{";
oss << "\"game\":{";
oss << "\"connected\":" << (gameState.game.connected ? "true" : "false") << ",";
oss << "\"paused\":" << (gameState.game.paused ? "true" : "false") << ",";
oss << "\"time\":\"" << gameState.game.time << "\",";
oss << "\"timeScale\":" << gameState.game.timeScale << ",";
oss << "\"nextRestStopTime\":\"" << gameState.game.nextRestStopTime << "\",";
oss << "\"version\":\"" << gameState.game.version << "\",";
oss << "\"telemetryPluginVersion\":\"" << gameState.game.telemetryPluginVersion << "\"";
oss << "},";
oss << "\"truck\":{";
oss << "\"id\":\"" << gameState.truck.id << "\",";
oss << "\"make\":\"" << gameState.truck.make << "\",";
oss << "\"model\":\"" << gameState.truck.model << "\",";
oss << "\"speed\":" << gameState.truck.speed << ",";
oss << "\"cruiseControlSpeed\":" << gameState.truck.cruiseControlSpeed*(speedMultiplicatorToKmh) << ",";
oss << "\"cruiseControlOn\":" << (gameState.truck.cruiseControlSpeed > 0 ? "true" : "false") << ",";
oss << "\"odometer\":" << gameState.truck.odometer << ",";
oss << "\"gear\":" << gameState.truck.gear << ",";
oss << "\"displayedGear\":" << gameState.truck.displayedGear << ",";
oss << "\"forwardGears\":" << gameState.truck.forwardGears << ",";
oss << "\"reverseGears\":" << gameState.truck.reverseGears << ",";
oss << "\"shifterType\":\"" << gameState.truck.shifterType << "\",";
oss << "\"engineRpm\":" << gameState.truck.engineRpm << ",";
oss << "\"engineRpmMax\":" << gameState.truck.engineRpmMax << ",";
oss << "\"fuel\":" << gameState.truck.fuel << ",";
oss << "\"fuelCapacity\":" << gameState.truck.fuelCapacity << ",";
oss << "\"fuelAverageConsumption\":" << gameState.truck.fuelAverageConsumption << ",";
oss << "\"fuelWarningFactor\":" << gameState.truck.fuelWarningFactor << ",";
oss << "\"fuelWarningOn\":" << (gameState.truck.fuelWarningOn ? "true" : "false") << ",";
oss << "\"wearEngine\":" << gameState.truck.wearEngine << ",";
oss << "\"wearTransmission\":" << gameState.truck.wearTransmission << ",";
oss << "\"wearCabin\":" << gameState.truck.wearCabin << ",";
oss << "\"wearChassis\":" << gameState.truck.wearChassis << ",";
oss << "\"wearWheels\":" << gameState.truck.wearWheels << ",";
oss << "\"userSteer\":" << gameState.truck.userSteer << ",";
oss << "\"userThrottle\":" << gameState.truck.userThrottle << ",";
oss << "\"userBrake\":" << gameState.truck.userBrake << ",";
oss << "\"userClutch\":" << gameState.truck.userClutch << ",";
oss << "\"gameSteer\":" << gameState.truck.gameSteer << ",";
oss << "\"gameThrottle\":" << gameState.truck.gameThrottle << ",";
oss << "\"gameBrake\":" << gameState.truck.gameBrake << ",";
oss << "\"gameClutch\":" << gameState.truck.gameClutch << ",";
oss << "\"shifterSlot\":" << gameState.truck.shifterSlot << ",";
oss << "\"engineOn\":" << (gameState.truck.engineOn ? "true" : "false") << ",";
oss << "\"electricOn\":" << (gameState.truck.electricOn ? "true" : "false") << ",";
oss << "\"wipersOn\":" << (gameState.truck.wipersOn ? "true" : "false") << ",";
oss << "\"retarderBrake\":" << gameState.truck.retarderBrake << ",";
oss << "\"retarderStepCount\":" << gameState.truck.retarderStepCount << ",";
oss << "\"parkBrakeOn\":" << (gameState.truck.parkBrakeOn ? "true" : "false") << ",";
oss << "\"motorBrakeOn\":" << (gameState.truck.motorBrakeOn ? "true" : "false") << ",";
oss << "\"brakeTemperature\":" << gameState.truck.brakeTemperature << ",";
oss << "\"adblue\":" << gameState.truck.adblue << ",";
oss << "\"adblueCapacity\":" << gameState.truck.adblueCapacity << ",";
oss << "\"adblueAverageConsumpton\":" << gameState.truck.adblueAverageConsumpton << ",";
oss << "\"adblueWarningOn\":" << (gameState.truck.adblueWarningOn ? "true" : "false") << ",";
oss << "\"airPressure\":" << gameState.truck.airPressure << ",";
oss << "\"airPressureWarningOn\":" << (gameState.truck.airPressureWarningOn ? "true" : "false") << ",";
oss << "\"airPressureWarningValue\":" << gameState.truck.airPressureWarningValue << ",";
oss << "\"airPressureEmergencyOn\":" << (gameState.truck.airPressureEmergencyOn ? "true" : "false") << ",";
oss << "\"airPressureEmergencyValue\":" << gameState.truck.airPressureEmergencyValue << ",";
oss << "\"oilTemperature\":" << gameState.truck.oilTemperature << ",";
oss << "\"oilPressure\":" << gameState.truck.oilPressure << ",";
oss << "\"oilPressureWarningOn\":" << (gameState.truck.oilPressureWarningOn ? "true" : "false") << ",";
oss << "\"oilPressureWarningValue\":" << gameState.truck.oilPressureWarningValue << ",";
oss << "\"waterTemperature\":" << gameState.truck.waterTemperature << ",";
oss << "\"waterTemperatureWarningOn\":" << (gameState.truck.waterTemperatureWarningOn ? "true" : "false") << ",";
oss << "\"waterTemperatureWarningValue\":" << gameState.truck.waterTemperatureWarningValue << ",";
oss << "\"batteryVoltage\":" << gameState.truck.batteryVoltage << ",";
oss << "\"batteryVoltageWarningOn\":" << (gameState.truck.batteryVoltageWarningOn ? "true" : "false") << ",";
oss << "\"batteryVoltageWarningValue\":" << gameState.truck.batteryVoltageWarningValue << ",";
oss << "\"lightsDashboardValue\":" << gameState.truck.lightsDashboardValue << ",";
oss << "\"lightsDashboardOn\":" << (gameState.truck.lightsDashboardOn ? "true" : "false") << ",";
oss << "\"blinkerLeftActive\":" << (gameState.truck.blinkerLeftActive ? "true" : "false") << ",";
oss << "\"blinkerRightActive\":" << (gameState.truck.blinkerRightActive ? "true" : "false") << ",";
oss << "\"blinkerLeftOn\":" << (gameState.truck.blinkerLeftOn ? "true" : "false") << ",";
oss << "\"blinkerRightOn\":" << (gameState.truck.blinkerRightOn ? "true" : "false") << ",";
oss << "\"lightsParkingOn\":" << (gameState.truck.lightsParkingOn ? "true" : "false") << ",";
oss << "\"lightsBeamLowOn\":" << (gameState.truck.lightsBeamLowOn ? "true" : "false") << ",";
oss << "\"lightsBeamHighOn\":" << (gameState.truck.lightsBeamHighOn ? "true" : "false") << ",";
oss << "\"lightsAuxFrontOn\":" << (gameState.truck.lightsAuxFrontOn ? "true" : "false") << ",";
oss << "\"lightsAuxRoofOn\":" << (gameState.truck.lightsAuxRoofOn ? "true" : "false") << ",";
oss << "\"lightsBeaconOn\":" << (gameState.truck.lightsBeaconOn ? "true" : "false") << ",";
oss << "\"lightsBrakeOn\":" << (gameState.truck.lightsBrakeOn ? "true" : "false") << ",";
oss << "\"lightsReverseOn\":" << (gameState.truck.lightsReverseOn ? "true" : "false") << ",";
oss << "\"placement\":{";
oss << "\"x\":" << gameState.truck.placement.x << ",";
oss << "\"y\":" << gameState.truck.placement.y << ",";
oss << "\"z\":" << gameState.truck.placement.z << ",";
oss << "\"heading\":" << gameState.truck.placement.heading << ",";
oss << "\"pitch\":" << gameState.truck.placement.pitch << ",";
oss << "\"roll\":" << gameState.truck.placement.roll;
oss << "},";
oss << "\"acceleration\":{";
oss << "\"x\":" << gameState.truck.acceleration.x << ",";
oss << "\"y\":" << gameState.truck.acceleration.y << ",";
oss << "\"z\":" << gameState.truck.acceleration.z;
oss << "},";
oss << "\"head\":{";
oss << "\"x\":" << gameState.truck.head.x << ",";
oss << "\"y\":" << gameState.truck.head.y << ",";
oss << "\"z\":" << gameState.truck.head.z;
oss << "},";
oss << "\"cabin\":{";
oss << "\"x\":" << gameState.truck.cabin.x << ",";
oss << "\"y\":" << gameState.truck.cabin.y << ",";
oss << "\"z\":" << gameState.truck.cabin.z;
oss << "},";
oss << "\"hook\":{";
oss << "\"x\":" << gameState.truck.hook.x << ",";
oss << "\"y\":" << gameState.truck.hook.y << ",";
oss << "\"z\":" << gameState.truck.hook.z;
oss << "}";
oss << "},";
oss << "\"trailer\":{";
oss << "\"attached\":" << (gameState.trailer.attached ? "true" : "false") << ",";
oss << "\"id\":\"" << gameState.trailer.id << "\",";
oss << "\"name\":\"" << gameState.trailer.name << "\",";
oss << "\"mass\":" << gameState.trailer.mass << ",";
oss << "\"wear\":" << gameState.trailer.wear << ",";
oss << "\"placement\":{";
oss << "\"x\":" << gameState.trailer.placement.x << ",";
oss << "\"y\":" << gameState.trailer.placement.y << ",";
oss << "\"z\":" << gameState.trailer.placement.z << ",";
oss << "\"heading\":" << gameState.trailer.placement.heading << ",";
oss << "\"pitch\":" << gameState.trailer.placement.pitch << ",";
oss << "\"roll\":" << gameState.trailer.placement.roll;
oss << "}";
oss << "},";
oss << "\"job\":{";
oss << "\"income\":" << gameState.job.income << ",";
oss << "\"deadlineTime\":\"" << gameState.job.deadlineTime << "\",";
oss << "\"remainingTime\":\"" << gameState.job.remainingTime << "\",";
oss << "\"sourceCity\":\"" << gameState.job.sourceCity << "\",";
oss << "\"sourceCompany\":\"" << gameState.job.sourceCompany << "\",";
oss << "\"destinationCity\":\"" << gameState.job.destinationCity << "\",";
oss << "\"destinationCompany\":\"" << gameState.job.destinationCompany << "\"";
oss << "},";
oss << "\"navigation\":{";
oss << "\"estimatedTime\":\"" << gameState.navigation.estimatedTime << "\",";
oss << "\"estimatedDistance\":" << gameState.navigation.estimatedDistance << ",";
oss << "\"speedLimit\":" << gameState.navigation.speedLimit;
oss << "}";
oss << "}";
return oss.str();
}
// Function to handle the GET request
void handleGETRequest(int clientSocket) {
// Simulate fetching data from a database or external source
std::string responseData = convertToJson(*game_state);
// Construct the HTTP response
std::ostringstream responseStream;
responseStream << "HTTP/1.1 200 OK\r\n";
responseStream << "Content-Type: application/json\r\n";
responseStream << "Content-Length: " << responseData.length() << "\r\n";
responseStream << "\r\n";
responseStream << responseData;
// Send the response
std::string httpResponse = responseStream.str();
send(clientSocket, httpResponse.c_str(), httpResponse.length(), 0);
}
void runRESTServer() {
int serverSocket, clientSocket;
struct sockaddr_in serverAddr, clientAddr;
socklen_t sinSize = sizeof(struct sockaddr_in);
// Socket erstellen
serverSocket = socket(AF_INET, SOCK_STREAM, 0);
// Serveradresse konfigurieren
serverAddr.sin_family = AF_INET;
serverAddr.sin_port = htons(8000);
serverAddr.sin_addr.s_addr = htonl(INADDR_LOOPBACK);
// Socket an Adresse und Port binden
bind(serverSocket, (struct sockaddr *)&serverAddr, sizeof(serverAddr));
// Auf eingehende Verbindungen hören
listen(serverSocket, 5);
std::cout << "Server is running on localhost:8000\n";
while (true) {
// Eingehende Verbindung akzeptieren
clientSocket = accept(serverSocket, (struct sockaddr *)&clientAddr, &sinSize);
// GET-Anfrage in einem separaten Thread behandeln
std::thread requestThread(handleGETRequest, clientSocket);
requestThread.detach(); // Thread abkoppeln, um ihn unabhängig auszuführen
}
// Server-Socket schließen (nicht im Beispiel erreicht)
close(serverSocket);
}
void log(std::string message){
//Concat message with [JANNIK]
std::string newMessage = "[JANNIK] " + message;
game_log(SCS_LOG_TYPE_message, newMessage.c_str());
}
int oldMemorySize = 0;
//2MegaBytes
int memorySize = 2048*100;
std::string keys = "JANNIK";
SCSAPI_VOID telemetry_pause(const scs_event_t UNUSED(event), const void *const UNUSED(event_info), const scs_context_t UNUSED(context))
{
output_paused = !output_paused;
}
SCSAPI_VOID telemetry_frame_start(const scs_event_t UNUSED(event), const void *const UNUSED(event_info), const scs_context_t UNUSED(context)){
if(output_paused){
return;
}
}
SCSAPI_VOID telemetry_frame_end(const scs_event_t UNUSED(event), const void *const UNUSED(event_info), const scs_context_t UNUSED(context)){
if(output_paused){
return;
}
std::string data = convertToJson(*game_state);
}
SCSAPI_VOID telemetry_store_speed(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_float){
return;
}
game_state->truck.speed = (value->value_float.value)*(speedMultiplicatorToKmh);
if(game_state->truck.speed < 0){
game_state->truck.speed = -1 * game_state->truck.speed;
}
}
SCSAPI_VOID telemetry_store_rpm(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_float){
log("Not a float");
return;
}
game_state->truck.engineRpm = value->value_float.value;
}
SCSAPI_VOID telemetry_store_electric_enabled(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_bool){
return;
}
game_state->truck.electricOn = value->value_bool.value;
}
SCSAPI_VOID telemetry_store_engine_enabled(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_bool){
return;
}
game_state->truck.engineOn = value->value_bool.value;
}
SCSAPI_VOID telemetry_store_wipers(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_bool){
return;
}
game_state->truck.wipersOn = value->value_bool.value;
}
SCSAPI_VOID telemetry_store_retarder_brake(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_float){
return;
}
game_state->truck.retarderBrake = value->value_float.value;
}
SCSAPI_VOID telemetry_store_park_brake(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_bool){
return;
}
game_state->truck.parkBrakeOn = value->value_bool.value;
}
SCSAPI_VOID telemetry_store_motor_brake(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_bool){
return;
}
game_state->truck.motorBrakeOn = value->value_bool.value;
}
SCSAPI_VOID telemetry_store_brake_air_pressure(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_float){
return;
}
game_state->truck.airPressure = value->value_float.value;
}
SCSAPI_VOID telemetry_store_adblue(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_float){
return;
}
game_state->truck.adblue = value->value_float.value;
}
SCSAPI_VOID telemetry_store_fuel(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_float){
return;
}
game_state->truck.fuel = value->value_float.value;
}
SCSAPI_VOID telemetry_store_oil_pressure(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_float){
return;
}
game_state->truck.oilPressure = value->value_float.value;
}
SCSAPI_VOID telemetry_store_oil_temperature(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_float){
return;
}
game_state->truck.oilTemperature = value->value_float.value;
}
SCSAPI_VOID telemetry_store_water_temperature(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_float){
return;
}
game_state->truck.waterTemperature = value->value_float.value;
}
SCSAPI_VOID telemetry_store_battery_voltage(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_float){
return;
}
game_state->truck.batteryVoltage = value->value_float.value;
}
SCSAPI_VOID telemetry_store_lights_dashboard(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_u32){
return;
}
game_state->truck.lightsDashboardValue = value->value_u32.value;
}
SCSAPI_VOID telemetry_store_lights_dashboard_on(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_bool){
return;
}
game_state->truck.lightsDashboardOn = value->value_bool.value;
}
SCSAPI_VOID telemetry_store_blinker_left_active(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_bool){
return;
}
game_state->truck.blinkerLeftActive = value->value_bool.value;
}
SCSAPI_VOID telemetry_store_blinker_right_active(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_bool){
return;
}
game_state->truck.blinkerRightActive = value->value_bool.value;
}
SCSAPI_VOID telemetry_store_blinker_left_on(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_bool){
return;
}
game_state->truck.blinkerLeftOn = value->value_bool.value;
}
SCSAPI_VOID telemetry_store_blinker_right_on(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_bool){
return;
}
game_state->truck.blinkerRightOn = value->value_bool.value;
}
SCSAPI_VOID telemetry_store_lights_parking(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_bool){
return;
}
game_state->truck.lightsParkingOn = value->value_bool.value;
}
SCSAPI_VOID telemetry_store_lights_beam_low(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_bool){
return;
}
game_state->truck.lightsBeamLowOn = value->value_bool.value;
}
SCSAPI_VOID telemetry_store_lights_beam_high(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_bool){
return;
}
game_state->truck.lightsBeamHighOn = value->value_bool.value;
}
SCSAPI_VOID telemetry_store_lights_aux_front(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_bool){
return;
}
game_state->truck.lightsAuxFrontOn = value->value_bool.value;
}
SCSAPI_VOID telemetry_store_lights_aux_roof(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_bool){
return;
}
game_state->truck.lightsAuxRoofOn = value->value_bool.value;
}
SCSAPI_VOID telemetry_store_lights_beacon(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_bool){
return;
}
game_state->truck.lightsBeaconOn = value->value_bool.value;
}
SCSAPI_VOID telemetry_store_lights_brake_on(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_bool){
return;
}
game_state->truck.lightsBrakeOn = value->value_bool.value;
}
SCSAPI_VOID telemetry_store_lights_reverse(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_bool){
return;
}
game_state->truck.lightsReverseOn = value->value_bool.value;
}
SCSAPI_VOID telemetry_store_world_placement(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_dplacement){
return;
}
game_state->truck.placement.x = value->value_dplacement.position.x;
game_state->truck.placement.y = value->value_dplacement.position.y;
game_state->truck.placement.z = value->value_dplacement.position.z;
game_state->truck.placement.heading = value->value_dplacement.orientation.heading;
game_state->truck.placement.pitch = value->value_dplacement.orientation.pitch;
game_state->truck.placement.roll = value->value_dplacement.orientation.roll;
}
SCSAPI_VOID telemetry_store_local_linear_velocity(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_fvector){
return;
}
game_state->truck.acceleration.x = value->value_fvector.x;
game_state->truck.acceleration.y = value->value_fvector.y;
game_state->truck.acceleration.z = value->value_fvector.z;
}
SCSAPI_VOID telemetry_store_local_angular_velocity(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_fvector){
return;
}
game_state->truck.acceleration.x = value->value_fvector.x;
game_state->truck.acceleration.y = value->value_fvector.y;
game_state->truck.acceleration.z = value->value_fvector.z;
}
SCSAPI_VOID telemetry_store_head(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_fvector){
return;
}
game_state->truck.head.x = value->value_fvector.x;
game_state->truck.head.y = value->value_fvector.y;
game_state->truck.head.z = value->value_fvector.z;
}
SCSAPI_VOID telemetry_store_cabin(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_fvector){
return;
}
game_state->truck.cabin.x = value->value_fvector.x;
game_state->truck.cabin.y = value->value_fvector.y;
game_state->truck.cabin.z = value->value_fvector.z;
}
SCSAPI_VOID telemetry_store_hook(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_fvector){
return;
}
game_state->truck.hook.x = value->value_fvector.x;
game_state->truck.hook.y = value->value_fvector.y;
game_state->truck.hook.z = value->value_fvector.z;
}
SCSAPI_VOID telemetry_store_job_income(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_u32){
return;
}
game_state->job.income = value->value_u32.value;
}
SCSAPI_VOID telemetry_store_job_deadline_time(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_string){
return;
}
game_state->job.deadlineTime = value->value_string.value;
}
SCSAPI_VOID telemetry_store_job_remaining_time(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_string){
return;
}
game_state->job.remainingTime = value->value_string.value;
}
SCSAPI_VOID telemetry_store_job_source_city(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_string){
return;
}
game_state->job.sourceCity = value->value_string.value;
}
SCSAPI_VOID telemetry_store_job_source_company(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_string){
return;
}
game_state->job.sourceCompany = value->value_string.value;
}
SCSAPI_VOID telemetry_store_job_destination_city(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_string){
return;
}
game_state->job.destinationCity = value->value_string.value;
}
SCSAPI_VOID telemetry_store_job_destination_company(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_string){
return;
}
game_state->job.destinationCompany = value->value_string.value;
}
SCSAPI_VOID telemetry_store_navigation_estimated_time(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_string){
return;
}
game_state->navigation.estimatedTime = value->value_string.value;
}
SCSAPI_VOID telemetry_store_navigation_estimated_distance(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_float){
return;
}
game_state->navigation.estimatedDistance = value->value_float.value;
}
SCSAPI_VOID telemetry_store_trailer_attached(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_bool){
return;
}
game_state->trailer.attached = value->value_bool.value;
}
SCSAPI_VOID telemetry_store_trailer_id(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_string){
return;
}
game_state->trailer.id = value->value_string.value;
}
SCSAPI_VOID telemetry_store_trailer_name(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_string){
return;
}
game_state->trailer.name = value->value_string.value;
}
SCSAPI_VOID telemetry_store_trailer_mass(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_float){
return;
}
game_state->trailer.mass = value->value_float.value;
}
SCSAPI_VOID telemetry_store_trailer_wear(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_float){
return;
}
game_state->trailer.wear = value->value_float.value;
}
SCSAPI_VOID telemetry_store_trailer_placement(scs_string_t name, scs_u32_t index, const scs_value_t *value, scs_context_t context){
if(output_paused){
return;
}
if(value->type != SCS_VALUE_TYPE_dplacement){
return;
}
game_state->trailer.placement.x = value->value_dplacement.position.x;
game_state->trailer.placement.y = value->value_dplacement.position.y;
game_state->trailer.placement.z = value->value_dplacement.position.z;
game_state->trailer.placement.heading = value->value_dplacement.orientation.heading;
game_state->trailer.placement.pitch = value->value_dplacement.orientation.pitch;
game_state->trailer.placement.roll = value->value_dplacement.orientation.roll;
}