Skip to content

Commit d079bac

Browse files
author
Jonas
committed
Added Refuel Amount. Closes #51
This really close 52 but i closed it in the last commit. So know 51 for the last commit.
1 parent 2590edd commit d079bac

File tree

6 files changed

+32
-5
lines changed

6 files changed

+32
-5
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,8 @@ New stuff is marked with the <ins>inserted</ins> Tag.
301301
│ │ ├── Navigation Distance
302302
│ │ ├── Navigation Time
303303
│ │ └── Speed Limit
304+
│ ├── <strong>Refuel</strong>:
305+
│ │ ├── <ins>Amount</ins> (see changelog update 10.4 for some notes to that)
304306
│ ├── <strong>SpecialEvents</strong>:
305307
│ │ ├── On Job
306308
│ │ ├── Job Cancelled (1.14/1.01/1.35) (may not work atm?)

changelog.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@
55
- Update `Readme.md`
66
- Change `update.md` to `changelog.md`
77
- Add `refuel end` event and change `refuel` to `refuel start`
8-
- ADd `refuel payed` event. Instead to fire when you stop refuel like `refuel end` it will fired when you start the engine. Also this is the event for the later coming `refuel amount` value.
8+
- Add `refuel payed` event. Instead to fire when you stop refuel like `refuel end` it will fired when you start the engine. Also this is the event for the later coming `refuel amount` value.
9+
- Add `refuel amount`. After the `refuel payed` event this value contains the amount of fuel that was refueled between the `refuel start` and `refuel payed` event.
10+
- This value could be a bit different to the in-game value, but most of the time it should be really similar. **NOTE:** if you pay in game, but didn't start the engine and start again to refuel the value in-game is the whole refuel amount and this value will only be the new refuel amount
11+
- I tried to calculate the exact value. But there could be a really small difference to that value (maybe up to `+-0.1`, maybe in some special cases more. If you think it is completely wrong create an issue)
12+
- **Shared Memory Changes**:
13+
- > Zone 4 end is modified (floats) -> `gameplas_f.refuelAmount` added, so `job_f.cargoDamage` moved 4 bytes
914
1015
## Rev 10 Update 3 (Game Version 1.36, small Shared Memory changes)
1116

scs-client/C#/SCSSdkClient/Object/SCSTelemetry.GamePlayEvents.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,17 @@ public partial class SCSTelemetry {
77
/// first implementation is that the values will be set, but never deleted
88
/// another change listener for bool values that will be changed will say if there are new values
99
/// </summary>
10+
/// <note>
11+
/// Refuel event is currently not provided by the sdk. It is provided through the fuel value.
12+
/// </note>
1013
public class GamePlayEvents {
1114
public Transport FerryEvent;
1215
public Fined FinedEvent;
1316
public Cancelled JobCancelled;
1417
public Delivered JobDelivered;
1518
public Tollgate TollgateEvent;
1619
public Transport TrainEvent;
20+
public Refuel RefuelEvent;
1721

1822

1923
public GamePlayEvents() {
@@ -23,6 +27,7 @@ public GamePlayEvents() {
2327
TollgateEvent = new Tollgate();
2428
TrainEvent = new Transport();
2529
FerryEvent = new Transport();
30+
RefuelEvent = new Refuel();
2631
}
2732

2833

@@ -58,6 +63,10 @@ public class Transport {
5863
public string TargetId;
5964
public string TargetName;
6065
}
66+
67+
public class Refuel {
68+
public float Amount;
69+
}
6170
}
6271
}
6372
}

scs-client/C#/SCSSdkClient/SCSSdkConvert.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,8 @@ public SCSTelemetry Convert(byte[] structureDataBytes) {
167167
retData.GamePlay.JobDelivered.CargoDamage = GetFloat();
168168
retData.GamePlay.JobDelivered.DistanceKm = GetFloat();
169169

170+
retData.GamePlay.RefuelEvent.Amount = GetFloat();
171+
170172
retData.JobValues.CargoValues.CargoDamage = GetFloat();
171173

172174
NextOffsetArea();

scs-telemetry/inc/scs-telemetry-common.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,12 +306,13 @@ typedef struct scsTelemetryMap_s
306306
struct {
307307
float jobDeliveredCargoDamage;
308308
float jobDeliveredDistanceKm;
309+
float refuelAmount;
309310
}gameplay_f;
310311

311312
struct {
312313
float cargoDamage;
313314
}job_f;
314-
char buffer_f[32];
315+
char buffer_f[28];
315316
//----- END OF FOURTH ZONE AT OFFSET 1499 -----//
316317

317318
//----- START OF FIFTH ZONE AT OFFSET 1500 -----//

scs-telemetry/src/scs_telemetry.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,8 @@ static auto fuel_ticker2 = 0;
374374
static auto last_fuel_value = 0;
375375
static auto current_fuel_value = 0;
376376
static auto refuel = false;
377-
377+
static auto fuel_tmp = 0.0f;
378+
static auto start_fuel = 0.0f;
378379

379380
// Function: telemetry_frame_start
380381
// Register telemetry values
@@ -413,11 +414,17 @@ SCSAPI_VOID telemetry_frame_start(const scs_event_t UNUSED(event), const void* c
413414

414415
// check fuel value
415416
current_fuel_value = telem_ptr->truck_f.fuel;
417+
if(!refuel) {
418+
start_fuel = fuel_tmp;
419+
fuel_tmp = telem_ptr->truck_f.fuel;
420+
}
416421
if (current_fuel_value > last_fuel_value && last_fuel_value >0) {
417422
fuel_ticker2 = 0;
418423
telem_ptr->special_b.refuel = true;
419-
refuel = true;
420-
clear_refuel_payed_ticker = 0;
424+
if(!refuel) {
425+
refuel = true;
426+
clear_refuel_payed_ticker = 0;
427+
}
421428
}
422429
else if (current_fuel_value < last_fuel_value) {
423430
fuel_ticker2 = 0;
@@ -427,6 +434,7 @@ SCSAPI_VOID telemetry_frame_start(const scs_event_t UNUSED(event), const void* c
427434
// refuel is true, but engine is know active? than refuel is finished and payed, fire event
428435
if(refuel && telem_ptr->truck_b.engineEnabled) {
429436
refuel = false;
437+
telem_ptr->gameplay_f.refuelAmount = telem_ptr->truck_f.fuel - start_fuel;
430438
telem_ptr->special_b.refuelPayed = true;
431439
}
432440

0 commit comments

Comments
 (0)