Changeset View
Standalone View
binaries/data/mods/public/gui/session/messages.js
/** | /** | ||||
* All tutorial messages received so far. | * All tutorial messages received so far. | ||||
*/ | */ | ||||
var g_TutorialMessages = []; | var g_TutorialMessages = []; | ||||
/** | /** | ||||
* GUI tags applied to the most recent tutorial message. | * GUI tags applied to the most recent tutorial message. | ||||
*/ | */ | ||||
var g_TutorialNewMessageTags = { "color": "255 226 149" }; | var g_TutorialNewMessageTags = { "color": "255 226 149" }; | ||||
/** | /** | ||||
* The number of seconds we observe for rate limiting flares. | |||||
*/ | |||||
var g_FlareRateLimitScope = 10; | |||||
/** | |||||
* The maximum allowed number of flares within g_FlareRateLimitScope seconds. | |||||
* This should be a bit larger than the number of flares that can be sent in theory by using the GUI. | |||||
*/ | |||||
var g_FlareRateLimitMaximumFlares = 16; | |||||
/** | |||||
* Contains the arrival timestamps the flares of the last g_FlareRateLimitScope seconds. | |||||
*/ | |||||
var g_FlareRateLimitLastTimes = []; | |||||
/** | |||||
* These handlers are called everytime a client joins or disconnects. | * These handlers are called everytime a client joins or disconnects. | ||||
*/ | */ | ||||
var g_PlayerAssignmentsChangeHandlers = new Set(); | var g_PlayerAssignmentsChangeHandlers = new Set(); | ||||
/** | /** | ||||
* These handlers are called when the ceasefire time has run out. | * These handlers are called when the ceasefire time has run out. | ||||
*/ | */ | ||||
var g_CeasefireEndedHandlers = new Set(); | var g_CeasefireEndedHandlers = new Set(); | ||||
▲ Show 20 Lines • Show All 242 Lines • ▼ Show 20 Lines | var g_NotificationsTypes = | ||||
{ | { | ||||
if (notification.lock) | if (notification.lock) | ||||
{ | { | ||||
global.music.storeTracks(notification.tracks.map(track => ({ "Type": "custom", "File": track }))); | global.music.storeTracks(notification.tracks.map(track => ({ "Type": "custom", "File": track }))); | ||||
global.music.setState(global.music.states.CUSTOM); | global.music.setState(global.music.states.CUSTOM); | ||||
} | } | ||||
global.music.setLocked(notification.lock); | global.music.setLocked(notification.lock); | ||||
}, | |||||
"map-flare": function(notification, player) | |||||
{ | |||||
// Don't display for the player that did the flare because they will see it immediately | |||||
elexis: (Should be taken care of that this can't cause any OOS, or asynchronicities without hash… | |||||
Done Inline ActionsThat's all purely gui, so no simulation involved. (Besides the action marker) So I don't see a OOS posssibility. Imarok: That's all purely gui, so no simulation involved. (Besides the action marker) So I don't see a… | |||||
Done Inline ActionsOOS could happen if displayMapPing changes serialized data, depends on how it will be implemented.
Imagine if the game is paused and a player tries communicating via the markers and assumes that his allies see these commands immediately, because he himself sees these immediately. This could be solved by displaying one actor when the command was started and the other when the marker was finished. I guess that can be neglected, since one currently is not supposed to be able to send commands during pauses. But that might actually change again in the future. Anyhow, not so important edge case and the affected player might just learn that he can't use these to communicate during pauses. elexis: OOS could happen if `displayMapPing` changes serialized data, depends on how it will be… | |||||
Done Inline ActionsWhat's about possible OOS? Also it's the code duplication. Is it possible to remove the displayFlare call before the network command posting and remove the condition below? vladislavbelov: What's about possible OOS?
Also it's the code duplication. Is it possible to remove the… | |||||
Done Inline ActionsOOS: This command does not alter any simulation data → no OOS. duplication: With your proposal the player doing the ping gets the feedback delayed by the sim and network delay. This means it feels way less responsive Imarok: OOS: This command does not alter any simulation data → no OOS.
duplication: With your proposal… | |||||
if (player != Engine.GetPlayerID() && g_Players[player].isMutualAlly[Engine.GetPlayerID()]) | |||||
{ | |||||
let now = Date.now(); | |||||
if (g_FlareRateLimitLastTimes.length) | |||||
{ | |||||
g_FlareRateLimitLastTimes = g_FlareRateLimitLastTimes.filter(t => now - t < g_FlareRateLimitScope * 1000); | |||||
Not Done Inline ActionsReally sucks this function doesn't take a SoundGroup. Hardcoding ogg files is wrong and might lead to oversights Stan: Really sucks this function doesn't take a SoundGroup. Hardcoding ogg files is wrong and might… | |||||
if (g_FlareRateLimitLastTimes.length >= g_FlareRateLimitMaximumFlares) | |||||
{ | |||||
warn("Received too many flares. Dropping a flare request by '" + g_Players[player].name + "'."); | |||||
return; | |||||
} | |||||
} | |||||
g_FlareRateLimitLastTimes.push(now); | |||||
displayFlare(notification.target, player); | |||||
Engine.PlayUISound(g_FlareSound, false); | |||||
} | |||||
} | } | ||||
}; | }; | ||||
function registerPlayerAssignmentsChangeHandler(handler) | function registerPlayerAssignmentsChangeHandler(handler) | ||||
{ | { | ||||
g_PlayerAssignmentsChangeHandlers.add(handler); | g_PlayerAssignmentsChangeHandlers.add(handler); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 281 Lines • Show Last 20 Lines |
(Should be taken care of that this can't cause any OOS, or asynchronicities without hash-mismatch. For example if the game is paused or lagging the local player might see it already but the other clients wouldn't. Likely not a problem as the commands aren't delayed anyhow.)