Create an object holding the handling of all netmessage types.
Display private messages sent by moderators.
Details:
Switch back the second and third argument of CreateSimpleMessage, so it
relates again to the switch/object.
Reduce the dimension/nesting of the object/switch from three to two.
Hence remove the useless "standard" and "internal" value send in the
text field.
Rename CreateSimpleMessage to CreateGUIMessage
Use the property "level" instead of "text" for "connect" and
"disconnect".
Remove the handling of the "connect" event in lobby.js, since it is
never called.
Translate the disconnect event.
Add comments and explicit checks to handleMessage and handleMUCMessage
to make obvious where they differ.
Remove the "message" property from those GUI messages, since it should
just use "text".
Move the login-fail handling to JS.
Remove useless sprintf calls from warning messages.
Inline some variables.
Add missing semicolons.
This was SVN commit r17581.
Rename ratio to rate.
Simplify translation.
Round in GUI, not simulation.
Check for div/0.
Fix wrong variable name in test_GuiInterface.js.
This was SVN commit r17580.
It can only be built while ashoka is alive.
Previously the structure was selectable from the panel but not placable
while he was absent.
This was SVN commit r17577.
Transform switch-statements into objects.
Make them more consistent, in particular the kick/ban and
ready-messages.
Also colorizes the playername in disconnect messages.
Fix a wrong comment in the network code and remove a duplicate check
(AIs).
This was SVN commit r17568.
Transform trivial switch-statements to objects.
Move removeOldChatMessage right below addChatMessage, since it is only
used there.
This was SVN commit r17566.
Unify switch-statement using objects.
Do not parse recursively, but do a linear 2-step process. Remove msg.me
property and move "/me" parsing out of that function.
Early return instead of using msg.hide.
Add observer-checks for private messages to impede abuse and fix#3270.
Remove the "/all" command, since it doesn't add functionality but
complexity.
Remove a TODO as displaying multiple contexts ("/team /allies text"?) is
not useful currently and made the previous code error-prone.
This was SVN commit r17565.
Move formating of resource-amounts to new function
translateResourceAmounts.
Rename player/player1 to sourcePlayer/targetPlayer.
Inline colorizedPlayername.
This was SVN commit r17556.
Move new objects to globals, which makes the code easier to read,
changable for mods and saves performance.
Move cheat functions below variable declarations.
Remove old function formatClientList, which for any reason didn't make
it into last commit.
This was SVN commit r17555.
Add two missing semicolons and remove an unnecessary one.
Eliminate formatClientList, message, formattedUsername and
formattedUsernamePrefix.
Move four hardcoded colors to globals.
This was SVN commit r17554.
Move the code to update the idle-traders text to two new simplified
functions.
Eliminate all if-statements (including quadruple-nested ones).
This was SVN commit r17553.
Replace for-each with for-of.
Remove duplicate code from updateMenuPosition.
Eliminate three unneeded globals.
Rename savedGameData to g_SavedGameData.
Remove unneeded braces.
This was SVN commit r17549.
Rename globals to g_Foo.
Remove unused variable playerID from updateTimeNotifications which
became obsolete in fe9eeedd66.
Use let instead of var.
Add some missing semicolons.
Fix whitespace, quote object keys.
This was SVN commit r17548.
Transform switch-statement in handleNetMessage to object of fat-arrow
functions.
Also add missing check to colorizePlayernameByGUID.
This was SVN commit r17547.
Move code from switch-statement to handlePlayerAssignmentsMessage.
Inline updatePlayerDataAdd and updatePlayerDataRemove as they are tiny
and only used here.
Remove comments, early return, eliminate for-each.
This was SVN commit r17546.
Remove duplicate code by transforming getUsernameAndColor to
colorizePlayername.
Notice the previous function getUsernameAndColorByGUID didn't work with
unassigned players.
This was SVN commit r17544.
Remove g_PlayerAssignments from calls to findGuidForPlayerID, since the
argument was removed in ae92736b02.
Simplify formatChatMessage by moving playercolor-detection to
formatDefeatMessage and formatChatCommand.
This was SVN commit r17541.
Use .property instead of ["property"].
Use if (object.property) instead of if ("property" in object).
Use array- and fat-arrow functions.
This was SVN commit r17537.
Remove duplicate call to parseChatCommands.
Rename msg.action to msg.me, as it only applies to the "/me" chat
command.
Remove some duplicate checks.
Remove unused variable userTag.
Also fix a wrong space in the loading screen.
This was SVN commit r17528.
Remove the "Seed" attribute as it is a relict of Atlas and not used
anywhere.
Also remove the author-tag of Forest Battle (4) as it's the only map
that has it.
This was SVN commit r17522.
Simplify GetAverageRangeForBuildings and GetFormationInfoFromTemplate.
Use let instead of var.
Quote object keys.
Remove unneeded braces and variables.
Remove unused variable cmpMirage in L414 and numCleared in L1096.
Add missing semicolon in L637.
Use fat-arrow function.
This was SVN commit r17516.
Use let instead of var.
Quote object keys.
Prefix globals with g_.
Remove some unneeded variables.
Use ternary operator and fat arrow functions.
This was SVN commit r17515.
Use let instead of var.
Do not redeclare timeToTarget and cmpTimer.
Remove unused variable graphicalPosition.
Fix some whitespace issues.
This was SVN commit r17507.
Remove all remaining variables referencing GUI objects in
updateGUIObjects.
Do more simple checks and insert new calls at more coherent places.
This was SVN commit r17488.
Move GUI updates from loadPersistMatchSettings to updateGUIObjects.
Simplify updateGUIObjects and use setGUIBoolean.
Move SetRankedGame from updateGUIObjects to handleGamesetupMessage.
Early return in handleGamesetupMessage.
This was SVN commit r17485.
Remove duplicate GUI updates which are done in initMapNameList and
updateGUIObjects.
Remove the g_IsInGuiUpdate line as the variable will be overwritten with
the next statement.
This was SVN commit r17484.
Don't copy the label from the dropdownlist, but create it from
g_MapFilters.
Move placeholder items to g_RandomMap and g_RandomCiv.
This was SVN commit r17483.
Remove 4 duplicate GUI updates in updateGUIObjects.
mapSelectionBox is updated in initMapNameList, the other three are done
80 lines below.
Inline finding of the selected map.
This was SVN commit r17482.
Abort in case a client tries to update the gamesettings.
Rename onGameAttributesChange to updateGUIObjects.
Move a check to sendRegisterGameStanza().
This was SVN commit r17481.
Deobfuscate mapfilter code. Remove unneeded, peculiar functions.
Construct g_MapFilters in-place and mark as const.
In initMapNameList, load "all" maps if no mapfilter is specified.
This was SVN commit r17480.
The caption of mapSelectionText (mapname-label visible to clients)
showed "random" instead of a translated "Random".
Move hardcoded "orange" color to a global const.
Simplify loadMapData.
Rename saveGameAttributes() to savePersistMatchSettings().
This was SVN commit r17475.
Use hideControl for playerdropdowns.
Remove some superfluous checks and comments.
Simplify using logical or, math and ternary operator.
This was SVN commit r17472.
Use let in function scope too.
Though spider monkey doesn't support let fully yet, it might be able to
detect some more reference errors in the code with later versions.
For example if a let variable is referenced before being defined
(temporal dead zone).
Besides, it is an easier rule to follow (let in functions, var for
globals) and makes the code more coherent.
This was SVN commit r17471.
The usual suspects:
Move all constants to the top.
Rename all globals to g_Foo.
Use let for all local variables (except in the for-each parts which will
be updated later).
Quote object keys.
Ternary operator.
Fat-arrow functions.
Whitespace issues.
This was SVN commit r17468.
Move some shared color-code to color.js.
Remove shuffleArray() as it's unused since bbc325fb5a.
Add JSdoc comments and use let.
This was SVN commit r17466.
Moves cropping of the mappreview image to a common function
setMapPreviewImage.
Also avoids magic numbers by using the actual formula.
This was SVN commit r17459.
"color" can make use of the sprite's alpha texture, and the "add_color"
effect will now take the original image's alpha into account.
Remove the no longer needed "unaffordableMask" images on a variety of
panels.
Somewhat based on a patch by BoeseRaupe. Fixes#2421 and #3688.
This was SVN commit r17456.
Rename panelsData and teamMiscHelperData to g_Foo.
Use let instead of var everywhere except for globals.
Quote object keys, add some spaces.
This was SVN commit r17455.
Upgraded aleppo pines.
New Oaks and dead oaks variations.
New generic dead trees.
Upgraded grapes texture by Stanislas69. Thanks Stan!
This was SVN commit r17452.
Introduce a GUI function to set checkboxes and their label-counterpart
in one line.
Replace code that is duplicated for every maptype.
Fix a typo "ExporeMap" from e05c8263c5.
This was SVN commit r17450.
Make a hidden function globally available and use it everywhere to
simplify the hiding/showing of GUI elements.
Use strings instead of the references to the actual GUI objects, so that
the code doesn't rely on variables anymore.
Use a default argument so we can reuse it with regards to other
conditions like scenario maps or multiplayer.
Notice the JS variables have the same name as the GUIObjects, so the
replacement is simple.
This was SVN commit r17447.
The previous code failed at it as it looped over g_PlayerAssignments
instead of all slots.
Based on patch by Pilzschaf, fixes#3602.
This was SVN commit r17444.
Split handleNetMessage into five smaller functions.
Besides improving the readability a bit, it allows adding new variables
without declaring them in the scope of other messagetypes.
This was SVN commit r17442.
Split the 280-line function initGUIObjects (former initMain) into
sixteen short functions.
Do not correct indentation in this commit in order to have the smallest
changeset possible, highlighting the actual changes
[the only logic change being mapTypes.selected and mapFilters.selected
being set one function (initMoreOptions) earlier].
This was SVN commit r17435.
Rename initMain to initGUIObjects to clarify what the function does.
While init() sets globals without touching the GUI, initGUIObjects
updates all GUI controls after the first tick.
Rename loadGameAttributes to loadPersistMatchSettings as that's more
specific as to where the attributes are loaded from.
Add some JSDoc comments and a TODO for an annoying old bug.
Simplifiy to-boolean conversions by negating twice (!!)
This was SVN commit r17433.
Don't define variables inside switch-statements.
Move chat-font to global.
Rename host and an i to guid, newPlayer to newGUID to be more coherent.
Do early continues when finding joinings/leavings and swapping players.
This was SVN commit r17432.
Doing so follows the principle of least exposure and means those
variables will be destroyed when leaving the block (i.e. memory being
freed up earlier).
The blocks affected by this commit are short (mostly 3-5 lines).
The variables are not referenced before or after the block, nor in their
temporal dead zones.
This was SVN commit r17424.
No effort was done to prevent players from accessing it since it's
impossible to prevent them from doing so anyway.
Fixes#3387 .
This was SVN commit r17423.
Do not focus the maplist when entering the singleplayer gamesetup as
that actually doesn't have an effect (you can't scroll the maplist with
arrow-keys).
This was SVN commit r17422.
This autodetection has a higer priority than default.cfg, but lower
priority than local changes.
Note that after enabling these features some get disabled later on on
some drivers (Intel, software renderers).
Also note that mesa drivers only expose core profile OpenGL, and 0 A.D.
reads compatibility profile, so that on mesa drivers OpenGL4 is never
detected and these features are never enabled by default.
This was SVN commit r17412.
Actually define these variables and revert to sorting by state for
gamelists by default (despite not having a column to sort for that).
This was SVN commit r17387.
The previous selection is saved globally so that we don't lose it in
case of no element being selected.
Also remove an unused variable.
This was SVN commit r17383.
Don't even load non-playable civs in the gamesetup and add sanity checks
to sanitizePlayerData() and loadCivData() so that we can remove later
checks.
Remove some blatantly wrong code from launchGame().
Move hardcoded romanNumbers to a global.
This was SVN commit r17381.
Notice that initMapSizes() confusingly mapped from "LongName" to "names"
and from "Name" to "shortnames".
Now it's identical in both parts.
Also fixes a bug in the summary screen where it would show "Scenario"
for a skirmish map.
This was SVN commit r17373.
Remove wrong attempt to display private-messages in the lobby.
Move hardcoded font to g_SenderFont global.
Replace some variables with references.
Correct indentation in ircFormat().
This was SVN commit r17370.
Removes a broken translation in displayProfile().
Removes many unused functions, variables and comments.
Moves filter initialization to new function.
Moves hardcoded system color to g_SystemColor.
Simplifies a lot without changing the logic otherwise.
This was SVN commit r17369.
Hides the summary-button in the replaymenu in case the summary wasn't
saved.
Corrects the timestamp for incompatible replays.
Remove unused UNUSED from header files.
Use string8() instead of OsString().
Mention a reported compiler warning.
Use const& instead of a copy in StartVisualReplay().
This was SVN commit r17356.
Fix llvmpipe (mesa) detection.
Add softpipe (mesa) detection.
Add GDI Generic (Windows) detection.
Consolidate software renderers detection in a function.
Disable s3tc on software renderers, it halves performance and make
textures weird.
Add a warning when on software renderer, to inform the player something
is bad.
This was SVN commit r17339.
This doesn't override any user setting, it just changes the default when
no preferglsl setting is specified.
Fixes#3641.
Refs #145.
This was SVN commit r17338.