Skip to content

Commit

Permalink
Fix clearing out values on clear. (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
DocMoebiuz authored Feb 11, 2024
1 parent b244a26 commit cb4764a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/PackageDefinitions/mobiflight-event-module.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<AssetPackage Version="1.0.0">
<AssetPackage Version="1.0.1">
<ItemSettings>
<ContentType>MISC</ContentType>
<Title>Event Module</Title>
Expand Down
16 changes: 15 additions & 1 deletion src/Sources/Code/Module.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#include "Module.h"

HANDLE g_hSimConnect;
const char* version = "1.0.0";
const char* version = "1.0.1";

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

// Clear the list of currently tracked SimVars
void ClearSimVars(Client* client) {
// We have to clear out the respective DataAreas
// of the SimVars and StringSimVars
// so that SimConnect sends data next time the
// WASM module is running again.
for (auto& simVar : client->SimVars) {
simVar.Value = 0;
WriteSimVar(simVar, client);
}
client->SimVars.clear();

for (auto& simVar : client->StringSimVars) {
simVar.Value = "";
WriteSimVar(simVar, client);
}
client->StringSimVars.clear();

std::cout << "MobiFlight[" << client->Name.c_str() << "]: Cleared SimVar tracking." << std::endl;
//client->RollingClientDataReadIndex = client->SimVars.begin();
client->RollingClientDataReadIndex = 0;
Expand Down

0 comments on commit cb4764a

Please sign in to comment.