Skip to content

Commit

Permalink
Fixed minor radio message bugs.
Browse files Browse the repository at this point in the history
- not sending "clear" radio message when new enemies have arrived since it had been scheduled
- not sending radio messages while the spacecraft is jumping out
  • Loading branch information
nkrisztian89 committed Dec 29, 2024
1 parent aa50bcd commit 391f236
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ module.exports = function (grunt) {
["locked", "is"],
["alive", "is"],
["away", "is"],
["jumping", "is", "isJumping"],
["readyToUse", "is"],
["playing", "is"],
["measuredFromCenter", "is"],
Expand Down Expand Up @@ -285,7 +286,8 @@ module.exports = function (grunt) {
["revealState"],
["piloted"],
["objectIntensity"],
["radioSilence"]
["radioSilence"],
["jumping", "set", "isJumping"]
].map(
function (replacement) {
// create the replacements for each simple setter
Expand Down
2 changes: 1 addition & 1 deletion src/config/config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.5.5-dev:1246 (2024.12.29.)",
"version": "0.5.5-dev:1247 (2024.12.29.)",
"debugVersion": false,
"logVerbosity": 1,
"platform": "web",
Expand Down
4 changes: 2 additions & 2 deletions src/js/armada/logic/ai.js
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ define([
*/
SpacecraftAI.prototype._sendRadio = function (messageType, delay, priority) {
var now = performance.now(), elapsed = now - this._lastRadioTime;
if (!this._radioSilence && (this._radioData.voice >= 0) && (this._spacecraft && this._spacecraft.isAlive() && !this._spacecraft.isAway()) && (
if (!this._radioSilence && (this._radioData.voice >= 0) && (this._spacecraft && this._spacecraft.isAlive() && !this._spacecraft.isAway() && (!this._spacecraft.isJumping() || (messageType === _radioMessageLeaving))) && (
(messageType !== this._lastRadioType) && (elapsed >= _differentRadioMessageDelay) ||
(elapsed > _sameRadioMessageDelay) ||
(delay > 0) ||
Expand Down Expand Up @@ -799,7 +799,7 @@ define([
SpacecraftAI.prototype._handleDelayedRadio = function (dt) {
if (this._radioTimeLeft > 0) {
this._radioTimeLeft -= dt;
if (this._radioTimeLeft <= 0) {
if ((this._radioTimeLeft <= 0) && ((this._radioData.messageType !== _radioMessageClear) || !this._target)) {
this._sendRadio(this._radioData.messageType, 0, 1);
}
}
Expand Down
7 changes: 7 additions & 0 deletions src/js/armada/logic/spacecraft.js
Original file line number Diff line number Diff line change
Expand Up @@ -2868,6 +2868,13 @@ define([
Spacecraft.prototype.setJumping = function (value) {
this._isJumping = value;
};
/**
* Whether the jump sequence is currently underway.
* @returns {Boolean}
*/
Spacecraft.prototype.isJumping = function () {
return this._isJumping;
};
/**
* Engages jump engines to leave the scene of the mission
* @param {Boolean} toggle If true, calling the method while the jump out sequence is under way will cancel the jump
Expand Down

0 comments on commit 391f236

Please sign in to comment.