Skip to content

Commit cb4764a

Browse files
authored
Fix clearing out values on clear. (#25)
1 parent b244a26 commit cb4764a

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/PackageDefinitions/mobiflight-event-module.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<AssetPackage Version="1.0.0">
2+
<AssetPackage Version="1.0.1">
33
<ItemSettings>
44
<ContentType>MISC</ContentType>
55
<Title>Event Module</Title>

src/Sources/Code/Module.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include "Module.h"
1212

1313
HANDLE g_hSimConnect;
14-
const char* version = "1.0.0";
14+
const char* version = "1.0.1";
1515

1616
const char* ClientName = "MobiFlightWasmModule";
1717
const char* MobiFlightEventPrefix = "MobiFlight.";
@@ -376,8 +376,22 @@ void RegisterStringSimVar(const std::string code, Client* client) {
376376

377377
// Clear the list of currently tracked SimVars
378378
void ClearSimVars(Client* client) {
379+
// We have to clear out the respective DataAreas
380+
// of the SimVars and StringSimVars
381+
// so that SimConnect sends data next time the
382+
// WASM module is running again.
383+
for (auto& simVar : client->SimVars) {
384+
simVar.Value = 0;
385+
WriteSimVar(simVar, client);
386+
}
379387
client->SimVars.clear();
388+
389+
for (auto& simVar : client->StringSimVars) {
390+
simVar.Value = "";
391+
WriteSimVar(simVar, client);
392+
}
380393
client->StringSimVars.clear();
394+
381395
std::cout << "MobiFlight[" << client->Name.c_str() << "]: Cleared SimVar tracking." << std::endl;
382396
//client->RollingClientDataReadIndex = client->SimVars.begin();
383397
client->RollingClientDataReadIndex = 0;

0 commit comments

Comments
 (0)