Skip to content
This repository has been archived by the owner on Jun 22, 2021. It is now read-only.

Commit

Permalink
Code tidy up and optimisation
Browse files Browse the repository at this point in the history
Changed some accidental assignments to reference rather than copy
Reduced sync rate with TS3 server so only changes are sent or an update
every 3 seconds
Removed unused code
Remove aircraft Position as this calculation will be done in LUA instead
  • Loading branch information
Ciaran Fisher committed Sep 7, 2015
1 parent f249e62 commit 4d321a2
Show file tree
Hide file tree
Showing 14 changed files with 213 additions and 387 deletions.
6 changes: 0 additions & 6 deletions DCS-SimpleRadio.sln
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,8 @@ EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RadioGui", "RadioGui\RadioGui.csproj", "{3FA37CBC-5BE2-4945-802D-9CDD464AC476}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{6919702D-C41C-49AF-8261-F36300694834}"
ProjectSection(SolutionItems) = preProject
Performance1.psess = Performance1.psess
EndProjectSection
EndProject
Global
GlobalSection(Performance) = preSolution
HasPerformanceSessions = true
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Expand Down
70 changes: 53 additions & 17 deletions Plugin/ClientMetaData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ namespace SimpleRadio
, name("init")
, unit("init")
, selected(0)
, position()
, hasRadio(true)
, groundCommander(false)
{
Expand Down Expand Up @@ -47,12 +46,6 @@ namespace SimpleRadio

root["radios"] = array;

Json::Value position;
position["x"] = this->position.x;
position["y"] = this->position.y;

root["pos"] = position;

root["hasRadio"] = this->hasRadio;

root["groundCommander"] = this->groundCommander;
Expand All @@ -74,20 +67,16 @@ namespace SimpleRadio
ClientMetaData data;
Json::Reader reader;
Json::Value root;

bool success = reader.parse(document, root, false);
if (success == true)
{
data.lastUpdate = GetTickCount64();

data.name = root["name"].asString();
data.unit = root["unit"].asString();
//data.unit = "TODO";
data.selected = root["selected"].asInt();

data.position.x = root["pos"]["x"].asFloat();
data.position.y = root["pos"]["y"].asFloat();

for (int i = 0; i < 3; i++)
{
data.radio[i].name = root["radios"][i]["name"].asString();
Expand All @@ -106,18 +95,18 @@ namespace SimpleRadio
data.hasRadio = true;
}


try {

data.groundCommander = root["groundCommander"].asBool();
}
catch (...)
{
//catch older versions
data.groundCommander = false;
}


}
else
{
Expand All @@ -135,4 +124,51 @@ namespace SimpleRadio
return this->lastUpdate > (GetTickCount64() - 5000ULL);
}

bool ClientMetaData::isEqual(ClientMetaData &data)
{

for (int i = 0; i < 3; i++)
{
if (this->radio[i].name.compare(data.radio[i].name) != 0)
{
return false;
}
if (this->radio[i].frequency != data.radio[i].frequency)
{
return false;
}
if (this->radio[i].modulation != data.radio[i].modulation)
{
return false;
}
if (this->radio[i].volume != data.radio[i].volume)
{
return false;
}

}

if (this->groundCommander != data.groundCommander)
{
return false;
}
if (this->hasRadio != data.hasRadio)
{
return false;
}
if (this->name.compare(data.name) != 0)
{
return false;
}
if (this->unit.compare(data.unit) != 0)
{
return false;
}
if (this->selected != data.selected)
{
return false;
}

}

}
12 changes: 2 additions & 10 deletions Plugin/ClientMetaData.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,10 @@
#define SR_CLIENTMETADATA_H

#include <string>
#include "DCSPosition.h"
#include "RadioInformation.h"

namespace SimpleRadio
{
struct RadioInformation
{
std::string name;
double frequency;
int modulation;
float volume;
};

class ClientMetaData
{
public:
Expand All @@ -23,11 +14,12 @@ namespace SimpleRadio
static const ClientMetaData deserialize(const std::string& document, bool fromUDP);
bool isCurrent();

bool isEqual(ClientMetaData &data);

unsigned long long lastUpdate;
std::string name;
std::string unit;
int selected;
DCSPosition position;
RadioInformation radio[3];
bool hasRadio;
bool groundCommander;
Expand Down
133 changes: 0 additions & 133 deletions Plugin/Configuration.cpp

This file was deleted.

42 changes: 0 additions & 42 deletions Plugin/Configuration.h

This file was deleted.

20 changes: 0 additions & 20 deletions Plugin/DCSPosition.cpp

This file was deleted.

16 changes: 0 additions & 16 deletions Plugin/DCSPosition.h

This file was deleted.

Loading

0 comments on commit 4d321a2

Please sign in to comment.