@@ -36,7 +36,7 @@ static SimpleRadio::Plugin plugin;
3636namespace SimpleRadio
3737{
3838 const char * Plugin::NAME = " DCS-SimpleRadio" ;
39- const char * Plugin::VERSION = " 1.1.6 " ;
39+ const char * Plugin::VERSION = " 1.1.7 " ;
4040 const char * Plugin::AUTHOR = " Ciribob - GitHub.com/ciribob" ;
4141 const char * Plugin::DESCRIPTION = " DCS-SimpleRadio " ;
4242 const char * Plugin::COMMAND_KEYWORD = " sr" ;
@@ -62,6 +62,8 @@ namespace SimpleRadio
6262 // Delete other things?!
6363 delete[] this ->pluginId ;
6464 }
65+
66+
6567 }
6668
6769 void Plugin::start ()
@@ -299,35 +301,44 @@ namespace SimpleRadio
299301 return data;
300302 }
301303
304+ void Plugin::toggleMuteOnNonUsers ()
305+ {
306+ this ->allowNonPlayers = !this ->allowNonPlayers ;
307+
308+ if (this ->allowNonPlayers )
309+ {
310+ this ->teamspeak .printMessageToCurrentTab (" Un-muting clients NOT in an aircraft" );
311+ }
312+ else
313+ {
314+ this ->teamspeak .printMessageToCurrentTab (" Muting clients NOT in an aircraft" );
315+ }
316+ }
317+
318+ void Plugin::toggleForceON () {
319+ this ->forceOn = !this ->forceOn ;
320+
321+ if (this ->forceOn )
322+ {
323+ this ->teamspeak .printMessageToCurrentTab (" Forcing ON in Ground Mode" );
324+ }
325+ else
326+ {
327+ this ->teamspeak .printMessageToCurrentTab (" Forcing OFF in Ground Mode" );
328+ }
329+ }
330+
302331 void Plugin::onHotKeyEvent (const char * hotkeyCommand) {
303332
304333 if (strcmp (" DCS-SR-TOGGLE-MUTE" , hotkeyCommand) == 0 )
305334 {
306- this ->allowNonPlayers = !this ->allowNonPlayers ;
307-
308- if (this ->allowNonPlayers )
309- {
310- this ->teamspeak .printMessageToCurrentTab (" Un-muting clients NOT in an aircraft" );
311- }
312- else
313- {
314- this ->teamspeak .printMessageToCurrentTab (" Muting clients NOT in an aircraft" );
315- }
335+ this ->toggleMuteOnNonUsers ();
316336 return ;
317337
318338 }
319339 else if (strcmp (" DCS-SR-TOGGLE-FORCE-ON" , hotkeyCommand) == 0 )
320340 {
321- this ->forceOn = !this ->forceOn ;
322-
323- if (this ->forceOn )
324- {
325- this ->teamspeak .printMessageToCurrentTab (" Forcing ON in Ground Mode" );
326- }
327- else
328- {
329- this ->teamspeak .printMessageToCurrentTab (" Forcing OFF in Ground Mode" );
330- }
341+ this ->toggleForceON ();
331342 return ;
332343
333344 }
@@ -476,6 +487,7 @@ namespace SimpleRadio
476487 update.selected = this ->myClientData .selected ;
477488 update.hasRadio = this ->myClientData .hasRadio ;
478489 update.allowNonPlayers = this ->allowNonPlayers ;
490+ update.caMode = this ->forceOn ;
479491
480492 for (int i = 0 ; i < 3 ; i++)
481493 {
@@ -505,7 +517,7 @@ namespace SimpleRadio
505517 int len = sizeof (SOCKADDR_IN);
506518
507519 // JSON Encode
508- sprintf (sbuf, " %s\r\n " , update.serialize (false ).c_str ());
520+ sprintf (sbuf, " %s\r\n " , update.serialize ().c_str ());
509521
510522 // teamspeak.printMessageToCurrentTab(update.serialize(false).c_str());
511523
@@ -554,7 +566,7 @@ namespace SimpleRadio
554566
555567 void Plugin::onClientUpdated (uint64 serverConnectionHandlerId, anyID clientId, anyID invokerId)
556568 {
557-
569+ // Called every time and update happens on a client
558570 char * bufferForMetaData;
559571 DWORD error;
560572
@@ -563,7 +575,7 @@ namespace SimpleRadio
563575
564576 anyID myID;
565577 if (this ->teamspeak .getClientID (serverConnectionHandlerId, &myID) != ERROR_ok) {
566-
578+ return ;
567579 }
568580 else
569581 {
@@ -586,46 +598,36 @@ namespace SimpleRadio
586598 catch (...)
587599 {
588600 this ->teamspeak .logMessage (" Failed to parse my metadata" , LogLevel_ERROR, Plugin::NAME, 0 );
589-
590601 }
591602 }
592603
593604 this ->teamspeak .freeMemory (bufferForMetaData);
594605
595606 return ;
596607 }
597- }
598-
599- // Called every time and update happens on a client
600-
601-
602- if ((error = this ->teamspeak .getClientVariableAsString (serverConnectionHandlerId, clientId, CLIENT_META_DATA, &bufferForMetaData)) != ERROR_ok) {
603-
604- }
605- else
606- {
607-
608- try {
609-
610- ClientMetaData metadata = ClientMetaData::deserialize (bufferForMetaData, false );
608+ else
609+ {
610+ if ((error = this ->teamspeak .getClientVariableAsString (serverConnectionHandlerId, clientId, CLIENT_META_DATA, &bufferForMetaData)) != ERROR_ok) {
611+ return ;
612+ }
613+ else
614+ {
615+ try {
611616
612- auto ret = this -> connectedClient . insert (std::pair<anyID, ClientMetaData>(clientId, metadata) );
617+ ClientMetaData metadata = ClientMetaData::deserialize (bufferForMetaData, false );
613618
614- if (!ret.second )
615- {
616- this ->connectedClient [clientId] = metadata;
619+ this ->connectedClient [clientId] = metadata;
620+ }
621+ catch (...)
622+ {
623+ this ->teamspeak .logMessage (" Failed to parse client metadata" , LogLevel_ERROR, Plugin::NAME, 0 );
617624
625+ }
626+ this ->teamspeak .freeMemory (bufferForMetaData);
627+ return ;
618628 }
619629 }
620- catch (...)
621- {
622- this ->teamspeak .logMessage (" Failed to parse client metadata" , LogLevel_ERROR, Plugin::NAME, 0 );
623-
624- }
625630 }
626-
627-
628- this ->teamspeak .freeMemory (bufferForMetaData);
629631 }
630632
631633 void Plugin::onEditPlaybackVoiceDataEvent (uint64 serverConnectionHandlerId, anyID clientId, short * samples, int sampleCount, int channels)
@@ -1167,17 +1169,20 @@ namespace SimpleRadio
11671169 {
11681170 ReceiveBuf[ByteReceived - 1 ] = 0 ; // add terminator
11691171
1172+ RadioUpdateCommand updateCommand = RadioUpdateCommand::deserialize (ReceiveBuf);
1173+
11701174 // only allow on FC3 aircraft
1171- if (this ->myClientData .hasRadio == false )
1175+ if (this ->myClientData .hasRadio == false || updateCommand. cmdType >= 4 )
11721176 {
1173- RadioUpdateCommand updateCommand = RadioUpdateCommand::deserialize (ReceiveBuf);
11741177
11751178 if (updateCommand.radio >= 0 )
11761179 {
11771180 /*
1178- FREQUENCY=1,
1181+ FREQUENCY=1,
11791182 VOLUME=2,
11801183 SELECT=3,
1184+ TOGGLE_MUTE_NON_RADIO = 4,
1185+ TOGGLE_FORCE_RADIO_ON = 5
11811186 */
11821187 switch (updateCommand.cmdType ) {
11831188 case 1 :
@@ -1189,6 +1194,15 @@ namespace SimpleRadio
11891194 case 3 :
11901195 this ->teamSpeakControlledClientData .selected = updateCommand.radio ;
11911196 break ;
1197+ case 4 :
1198+ this ->toggleMuteOnNonUsers ();
1199+ this ->sendUpdateToGUI ();
1200+ break ;
1201+ case 5 :
1202+ this ->toggleForceON ();
1203+ this ->sendUpdateToGUI ();
1204+ break ;
1205+
11921206 default :
11931207 break ;
11941208
@@ -1271,6 +1285,7 @@ void ts3plugin_setFunctionPointers(const struct TS3Functions funcs)
12711285*/
12721286int ts3plugin_init ()
12731287{
1288+ // _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
12741289 try
12751290 {
12761291
0 commit comments