{"id":331336,"date":"2022-03-31T15:01:03","date_gmt":"2022-03-31T15:01:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=331336"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=331336","title":{"rendered":"<span>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 Barotrauma \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u043e\u043c PVS-Studio<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>Barotrauma \u2013 \u0438\u0433\u0440\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u0434\u043b\u043e\u0434\u043a\u043e\u0439, \u043f\u043e\u043f\u0440\u044f\u0442\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u043c\u043e\u043d\u0441\u0442\u0440\u043e\u0432 \u0438 \u0434\u0430\u0436\u0435 \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c \u043d\u0430 \u0430\u043a\u043a\u043e\u0440\u0434\u0435\u043e\u043d\u0435 \u0432 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u043d\u0435 \u043f\u043e\u0439\u0442\u0438 \u043a\u043e \u0434\u043d\u0443. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043f\u0440\u043e\u0435\u043a\u0442, \u043d\u0430\u0447\u0430\u0442\u044b\u0439 \u0438\u043d\u0434\u0438-\u0441\u0442\u0443\u0434\u0438\u0435\u0439 Undertow Games \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u043d\u044b\u0439 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0441 FakeFish, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0438\u0437\u043d\u0443\u0442\u0440\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u0441\u043b\u0435\u0434\u0443\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434, \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 C#, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 PVS-Studio.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/129\/cfd\/5f6\/129cfd5f6b6d50f1afff5d341b6fad30.png\" width=\"780\" height=\"440\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/129\/cfd\/5f6\/129cfd5f6b6d50f1afff5d341b6fad30.png\"\/><figcaption><\/figcaption><\/figure>\n<h3>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h3>\n<p>Barotrauma \u2013 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043a\u043e\u0441\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 2D-\u0441\u0438\u043c\u0443\u043b\u044f\u0442\u043e\u0440 \u043f\u043e\u0434\u043b\u043e\u0434\u043a\u0438 \u0432 \u0436\u0430\u043d\u0440\u0435 survival horror. \u0418\u0433\u0440\u043e\u043a\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u043e\u0438\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u0434\u043b\u043e\u0434\u043a\u043e\u0439, \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043a\u0430\u0437\u044b, \u0443\u0441\u0442\u0440\u0430\u043d\u044f\u0442\u044c \u043f\u0440\u043e\u0442\u0435\u0447\u043a\u0438 \u0438 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044f\u043c.<\/p>\n<p>Barotrauma \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f Open Source \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c \u0432 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0438. \u0420\u0430\u043d\u043d\u044f\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0438\u0433\u0440\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e, \u0442\u0435\u043a\u0443\u0449\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0432 <a href=\"https:\/\/store.steampowered.com\/app\/602960\/Barotrauma\/\">Steam<\/a>. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043b\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 <a href=\"https:\/\/github.com\/Regalis11\/Barotrauma\">GitHub<\/a> \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e \u0438\u0433\u0440\u043e\u043a\u043e\u0432 \u043c\u043e\u0433\u043b\u043e \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u044b\u0435 \u043c\u043e\u0434\u044b \u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438.<\/p>\n<h3>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438<\/h3>\n<h4>\u041e\u0448\u0438\u0431\u043a\u0438 \u0432 if<\/h4>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3001\/\">V3001<\/a> There are identical sub-expressions &#8216;string.IsNullOrEmpty(EndPoint)&#8217; to the left and to the right of the &#8216;||&#8217; operator. BanList.cs 41<\/p>\n<pre><code class=\"cs\">public bool CompareTo(string endpointCompare) {   if (string.IsNullOrEmpty(EndPoint) || string.IsNullOrEmpty(EndPoint))    { return false; }   .... } <\/code><\/pre>\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>EndPoint<\/em> \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0434\u0432\u0430\u0436\u0434\u044b. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0437\u0430\u0431\u044b\u043b \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <em>EndPoint<\/em> \u043d\u0430 <em>endpointCompare<\/em> \u043f\u0440\u0438 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 <em>string.IsNullOrEmpty<\/em>. \u0412\u043e\u043e\u0431\u0449\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b \u043e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e \u043e\u0448\u0438\u0431\u0430\u044e\u0442\u0441\u044f \u0432 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f. \u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/cpp\/0509\/\">\u0441\u0442\u0430\u0442\u044c\u044e<\/a> \u043a\u043e\u043b\u043b\u0435\u0433\u0438 \u043e\u0431 \u044d\u0442\u043e\u043c.<\/p>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3004\/\">V3004<\/a> The &#8216;then&#8217; statement is equivalent to the &#8216;else&#8217; statement. ServerEntityEventManager.cs 314<\/p>\n<pre><code class=\"cs\">public void Write(Client client, IWriteMessage msg,                    out List&lt;NetEntityEvent> sentEvents) {   List&lt;NetEntityEvent> eventsToSync = null;   if (client.NeedsMidRoundSync)   {     eventsToSync = GetEventsToSync(client);   }   else   {     eventsToSync = GetEventsToSync(client);   }   .... } <\/code><\/pre>\n<p>\u0412\u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <em>client.NeedsMidRoundSync<\/em> \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0443\u0431\u0440\u0430\u0442\u044c <em>else<\/em>-\u0432\u0435\u0442\u0432\u044c \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0435\u0451 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430 \u0432\u044b\u0437\u0432\u0430\u043b \u0434\u0432\u0430 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3021\/\">V3021<\/a> There are two &#8216;if&#8217; statements with identical conditional expressions. The first &#8216;if&#8217; statement contains method return. This means that the second &#8216;if&#8217; statement is senseless DebugConsole.cs 2177<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3022\/\">V3022<\/a> Expression &#8216;args.Length &lt; 2&#8217; is always false. DebugConsole.cs 2183<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cs\">private static void InitProjectSpecific() {   ....   AssignOnClientRequestExecute(     \"setclientcharacter\",     (Client senderClient, Vector2 cursorWorldPos, string[] args) =>     {       if (args.Length &lt; 2)       {         GameMain.Server.SendConsoleMessage(\"....\", senderClient);         return;       }        if (args.Length &lt; 2)       {         ThrowError(\"....\");         return;       }     );   .... } <\/code><\/pre>\n<p>\u0414\u0432\u0435 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e <em>if<\/em> \u043c\u0435\u0442\u043e\u0434 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442 \u0440\u0430\u0431\u043e\u0442\u0443, \u0438\u043d\u0430\u0447\u0435 \u0436\u0435 \u043e\u0431\u0435 <em>then<\/em>-\u0432\u0435\u0442\u0432\u0438 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u044b.<\/p>\n<p>\u041f\u0440\u0438 \u0442\u0430\u043a\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f, \u043d\u043e \u0437\u0430\u043f\u0438\u0441\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u043c <em>ThrowError<\/em> \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442. \u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0434\u0432\u0430 \u0442\u0435\u043b\u0430 <em>if<\/em> \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0432\u0442\u043e\u0440\u043e\u0433\u043e.<\/p>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3022\/\">V3022<\/a> Expression &#8216;newPrice > 0&#8217; is always true. DebugConsole.cs 3310<\/p>\n<pre><code class=\"cs\">private static void PrintItemCosts(....) {   if (newPrice &lt; 1)   {     NewMessage(depth + materialPrefab.Name +      \" cannot be adjusted to this price, because it would become less than 1.\");     return;   }    ....    if (newPrice > 0)   {     newPrices.TryAdd(materialPrefab, newPrice);   }   .... } <\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 <em>newPrice<\/em> \u043c\u0435\u043d\u044c\u0448\u0435 \u0438\u043b\u0438 \u0440\u0430\u0432\u0435\u043d 0, \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0442\u0435\u043b\u0430 \u043f\u0435\u0440\u0432\u043e\u0433\u043e <em>if<\/em>. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f. \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0432\u0442\u043e\u0440\u043e\u0433\u043e <em>if<\/em> \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u0442\u0438\u043d\u043d\u043e. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u0435\u043b\u043e \u0432\u0442\u043e\u0440\u043e\u0433\u043e *if *\u0432 <em>else<\/em>-\u0432\u0435\u0442\u0432\u044c \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0438\u043b\u0438 \u0436\u0435 \u0432\u043e\u0432\u0441\u0435 \u0435\u0433\u043e \u0443\u0431\u0440\u0430\u0442\u044c.<\/p>\n<h4>\u041e\u043f\u0435\u0447\u0430\u0442\u043a\u0438<\/h4>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3005\/\">V3005<\/a> The &#8216;arrowIcon.PressedColor&#8217; variable is assigned to itself. ChatBox.cs 164<\/p>\n<pre><code class=\"cs\">public ChatBox(GUIComponent parent, bool isSinglePlayer) {   ....   arrowIcon = new GUIImage(....)   {     Color = new Color(51, 59, 46)   };   arrowIcon.HoverColor = arrowIcon.PressedColor =    arrowIcon.PressedColor = arrowIcon.Color;   ....   } <\/code><\/pre>\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 *arrowIcon.PressedColor *\u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u043e\u0439 \u0441\u0435\u0431\u0435. \u0412 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 *GUIIMage *\u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <em>SelectedColor<\/em>. \u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0445\u043e\u0442\u0435\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e, \u043d\u043e \u043e\u043f\u0435\u0447\u0430\u0442\u0430\u043b\u0441\u044f.<\/p>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3005\/\">V3005<\/a> The &#8216;Penetration&#8217; variable is assigned to itself. Attack.cs 324<\/p>\n<pre><code class=\"cs\">public Attack(float damage,                float bleedingDamage,                float burnDamage,                float structureDamage,               float itemDamage,                float range = 0.0f,                float penetration = 0f) {    ....    Range = range;    DamageRange = range;    StructureDamage = LevelWallDamage = structureDamage;    ItemDamage = itemDamage;         Penetration = Penetration;                \/\/ &lt;= } <\/code><\/pre>\n<p>\u0415\u0449\u0451 \u043e\u0434\u043d\u0430 \u043f\u043e\u0434\u043e\u0431\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u0445\u043e\u0442\u0435\u043b \u043f\u0440\u043e\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043d\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <em>penetration<\/em> \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u043b \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 <em>Penetration<\/em> \u0441\u0432\u043e\u0451 \u0436\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3025\/\">V3025<\/a> Incorrect format. A different number of format items is expected while calling &#8216;Format&#8217; function. Arguments not used: t.Character.Name. DebugConsole.cs 1123<\/p>\n<pre><code class=\"cs\">private static void InitProjectSpecific() {   AssignOnClientRequestExecute(\"traitorlist\",        (Client client, Vector2 cursorPos, string[] args) =>   {     ....     GameMain.Server.SendTraitorMessage(      client,       string.Format(\"- Traitor {0} has no current objective.\",            \/\/ &lt;=                    \"\",                                                   \/\/ &lt;=                    t.Character.Name),                                    \/\/ &lt;=      \"\",      TraitorMessageType.Console);      }); } <\/code><\/pre>\n<p>\u0418\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u0441\u043c\u044b\u0441\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <em>GameMain.Server.SendTraitorMessage<\/em> \u0444\u0440\u0430\u0437\u044b, \u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0432\u0432\u043e\u0434\u0430 <em>{0}<\/em> \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u043b \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c <em>t.Character.Name<\/em>. \u041e\u0434\u043d\u0430\u043a\u043e \u0436\u0435 \u0442\u0430\u043c \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043f\u0443\u0441\u0442\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430.<\/p>\n<p>\u041e\u0448\u0438\u0431\u043a\u0430, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435\u043c \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e\u0433\u043e copy-paste \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430 <em>GameMain.Server.SendTraitorMessage<\/em>:<\/p>\n<pre><code class=\"cs\">GameMain.Server.SendTraitorMessage(client,  \"There are no traitors at the moment.\", \"\", TraitorMessageType.Console); <\/code><\/pre>\n<h4>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0435 NullReferenceException<\/h4>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3153\/\">V3153<\/a> Enumerating the result of null-conditional access operator can lead to NullReferenceException. Voting.cs 181<\/p>\n<pre><code class=\"cs\">public void ClientRead(IReadMessage inc) {   ....   foreach (GUIComponent item in            GameMain.NetLobbyScreen?.SubList?.Content?.Children)    \/\/ &lt;=   {     if (item.UserData != null &amp;&amp; item.UserData is SubmarineInfo)      {       serversubs.Add(item.UserData as SubmarineInfo);      }   }   .... } <\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u0438\u043d \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0438\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 <em>GameMain.NetLobbyScreen?.SubList?.Content?.Children<\/em> \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u0435\u043d <em>null<\/em>, \u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u0441\u0435\u0433\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0442\u043e\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u0435\u043d <em>null<\/em>. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 *NullReferenceException *\u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u0430 \u0432 <em>foreach<\/em>.<\/p>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043f\u0440\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <em>?<\/em>. \u0432 <em>foreach<\/em> \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 <a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/csharp\/0832\/\">\u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a>.<\/p>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3027\/\">V3027<\/a> The variable &#8216;spawnPosition&#8217; was utilized in the logical expression before it was verified against null in the same logical expression. LevelObjectManager.cs 274<\/p>\n<pre><code class=\"cs\">private void PlaceObject(LevelObjectPrefab prefab,                           SpawnPosition spawnPosition,                           Level level, Level.Cave parentCave = null) {   float rotation = 0.0f;   if (   prefab.AlignWithSurface        &amp;&amp; spawnPosition.Normal.LengthSquared() > 0.001f          \/\/ &lt;=       &amp;&amp; spawnPosition != null)                                 \/\/ &lt;=   {     rotation = MathUtils.VectorToAngle(new Vector2(spawnPosition.Normal.Y,                                                     spawnPosition.Normal.X));   }   .... } <\/code><\/pre>\n<p>\u0418\u0437 \u043a\u043e\u0434\u0430 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0434\u0451\u0442 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 <em>LengthSquared<\/em> \u0443 \u043f\u043e\u043b\u044f <em>Normal<\/em> \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <em>spawnPosition<\/em> \u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0435\u0433\u043e \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043d\u0430 <em>null<\/em>.  \u0415\u0441\u043b\u0438 <em>spawnPosition<\/em> \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u0430 <em>null<\/em>, \u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 <em>NullReferenceException<\/em>.<\/p>\n<p>\u041f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043d\u0430 <em>null<\/em> \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044f.<\/p>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3095\/\">V3095<\/a> The &#8216;level&#8217; object was used before it was verified against null. Check lines: 107, 115. BeaconMission.cs 107<\/p>\n<pre><code class=\"cs\">public override void End() {   completed = level.CheckBeaconActive();                        \/\/ &lt;=   if (completed)   {     if (Prefab.LocationTypeChangeOnCompleted != null)     {       ChangeLocationType(Prefab.LocationTypeChangeOnCompleted);     }     GiveReward();     if (level?.LevelData != null)                               \/\/ &lt;=     {       level.LevelData.IsBeaconActive = true;     }   } } <\/code><\/pre>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>level.CheckBeaconActive<\/em> \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0430 \u0437\u0430\u0442\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <em>?.<\/em> \u0432 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0438 <em>level?.LevelData<\/em>. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 <em>level<\/em> \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u0435\u043d <em>null<\/em> \u2014 \u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 <em>NullReferenceException<\/em> \u043b\u0438\u0431\u043e <em>level<\/em> \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 <em>null \u2014<\/em> \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u0430.<\/p>\n<h4>\u0412\u044b\u0445\u043e\u0434 \u0437\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u044b<\/h4>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3106\/\">V3106<\/a> Possibly index is out of bound. The &#8216;0&#8217; index is pointing beyond &#8216;Sprites&#8217; bound. ParticlePrefab.cs 303<\/p>\n<pre><code class=\"cs\">public ParticlePrefab(XElement element, ContentFile file) {   ....   if (CollisionRadius &lt;= 0.0f)      CollisionRadius = Sprites.Count > 0 ? 1 :                                            Sprites[0].SourceRect.Width \/ 2.0f; } <\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0442\u0435\u0440\u043d\u0430\u0440\u043d\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <em>CollisionRadius<\/em> \u0441\u0442\u0430\u043d\u0435\u0442 \u0440\u0430\u0432\u043d\u043e 1. \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>Sprites.Count<\/em> \u0440\u0430\u0432\u043d\u043e 0, \u0438 \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 <em>IndexOutOfRangeException<\/em>.<\/p>\n<p>\u0420\u0430\u043d\u0435\u0435 \u043f\u043e \u043a\u043e\u0434\u0443 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430: \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u043f\u0443\u0441\u0442\u043e\u0439.<\/p>\n<pre><code class=\"cs\">if (Sprites.Count == 0) {   DebugConsole.ThrowError($\"Particle prefab \\\"{Name}\\\" in the file \\\"{file}\\\"                             has no sprites defined!\"); } <\/code><\/pre>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430 \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0442\u0435\u0440\u043d\u0430\u0440\u043d\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430.<\/p>\n<h4>\u041b\u0438\u0448\u043d\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f<\/h4>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3107\/\">V3107<\/a> Identical expression &#8216;power&#8217; to the left and to the right of compound assignment. RelayComponent.cs 150<\/p>\n<pre><code class=\"cs\">public override void ReceivePowerProbeSignal(Connection connection,                                               Item source, float power) {   ....   if (power &lt; 0.0f)   {     ....   }   else   {     if (connection.IsOutput || powerOut == null) { return; }      if (currPowerConsumption - power &lt; -MaxPower)     {       power += MaxPower + (currPowerConsumption - power);     }   } } <\/code><\/pre>\n<p>\u041f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u043f\u044b\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u0431\u0430\u0432\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <em>power<\/em> \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e <em>MaxPower<\/em> \u0438 \u0440\u0430\u0437\u043d\u0438\u0446\u0443 \u043c\u0435\u0436\u0434\u0443 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u043c\u0438 <em>currPowerConsumption<\/em> \u0438 <em>power<\/em>. \u0412 \u0440\u0430\u0437\u043b\u043e\u0436\u0435\u043d\u043d\u043e\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0435 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0432\u0438\u0434:<\/p>\n<pre><code class=\"cs\">power = power + MaxPower + (currPowerConsumption - power); <\/code><\/pre>\n<p>\u0412\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f <em>power<\/em> \u0432\u044b\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u0430 \u0438\u0437 \u0441\u0435\u0431\u044f. \u0423\u043f\u0440\u043e\u0449\u0451\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cs\">power = MaxPower + currPowerConsumption; <\/code><\/pre>\n<h4>\u0412\u0441\u0435\u0433\u0434\u0430 false<\/h4>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3009\/\">V3009<\/a> It&#8217;s odd that this method always returns one and the same value of &#8216;false&#8217;. FileSelection.cs 395<\/p>\n<pre><code class=\"cs\">public static bool MoveToParentDirectory(GUIButton button, object userdata) {   string dir = CurrentDirectory;   if (dir.EndsWith(\"\/\")) { dir = dir.Substring(0, dir.Length - 1); }   int index = dir.LastIndexOf(\"\/\");   if (index &lt; 0) { return false; }   CurrentDirectory = CurrentDirectory.Substring(0, index+1);    return false; } <\/code><\/pre>\n<p>\u0421\u0442\u0440\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434, \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0449\u0438\u0439 <em>false<\/em>. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u0437\u0434\u0435\u0441\u044c \u043d\u0435\u0442 \u043e\u0448\u0438\u0431\u043a\u0438 \u0438 \u0442\u0430\u043a \u0437\u0430\u0434\u0443\u043c\u0430\u043d\u043e, \u043b\u0438\u0431\u043e \u043e\u0434\u0438\u043d \u0438\u0437 <em>return<\/em> \u0434\u043e\u043b\u0436\u0435\u043d \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0442\u044c <em>true<\/em>.<\/p>\n<h4>\u0423\u0442\u0440\u0430\u0447\u0435\u043d\u043d\u043e\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435<\/h4>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3010\/\">V3010<\/a> The return value of function &#8216;Trim&#8217; is required to be utilized. GameServer.cs 1589<\/p>\n<pre><code class=\"cs\">private void ClientWriteInitial(Client c, IWriteMessage outmsg) {   ....    if (gameStarted)   {     ....      if (ownedSubmarineIndexes.Length > 0)     {       ownedSubmarineIndexes.Trim(';');     }     outmsg.Write(ownedSubmarineIndexes);   } } <\/code><\/pre>\n<p>\u041c\u0435\u0442\u043e\u0434 <em>Trim<\/em> \u043d\u0435 \u043c\u0435\u043d\u044f\u0435\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>ownedSubmarineIndexes<\/em>, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u0442 \u0441\u043c\u044b\u0441\u043b\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u0435\u0433\u043e, \u043d\u0435 \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442. \u041f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442:<\/p>\n<pre><code class=\"cs\">ownedSubmarineIndexes = ownedSubmarineIndexes.Trim(';'); <\/code><\/pre>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>PVS-Studio \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u043b \u0440\u044f\u0434 \u043e\u0448\u0438\u0431\u043e\u043a, \u043e\u043f\u0435\u0447\u0430\u0442\u043e\u043a \u0438 \u043d\u0435\u0434\u043e\u0447\u0451\u0442\u043e\u0432 \u0432 \u0438\u0441\u0445\u043e\u0434\u043d\u043e\u043c \u043a\u043e\u0434\u0435 Baratrauma. \u041c\u043d\u043e\u0433\u0438\u0435 \u0438\u0437 \u043d\u0438\u0445 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043b\u0435\u0433\u043a\u043e \u0434\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0438 \u043e\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u0437\u0430\u043c\u0435\u0447\u0435\u043d\u043d\u044b\u043c\u0438 \u043d\u0430 code-review.<\/p>\n<p>\u0421\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u0430\u043d\u0430\u043b\u0438\u0437 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043c\u043e\u0447\u044c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430\u043c \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043e\u043d\u0438 \u0431\u044b \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u043b\u0438 \u043d\u0430 \u043f\u043e\u0438\u0441\u043a \u0438 \u0438\u0441\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0431\u0430\u0433\u043e\u0432, \u0438 \u0443\u0434\u0435\u043b\u0438\u0442\u044c \u0435\u0433\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043d\u043e\u0432\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430. \u041e\u0434\u043d\u0430\u043a\u043e \u043c\u0430\u043b\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043a\u043e\u0434 \u043e\u0434\u0438\u043d \u0440\u0430\u0437. \u041c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u0430\u044f \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0441\u0442\u044c \u0434\u043e\u0441\u0442\u0438\u0433\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430.<\/p>\n<p>\u041e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 PVS-Studio \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0435\u0441\u0442\u044c \u0432 \u043d\u0430\u0448\u0435\u043c <a href=\"https:\/\/pvs-studio.com\/ru\/blog\/\">\u0431\u043b\u043e\u0433\u0435<\/a>.<\/p>\n<p>\u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u0442\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435\u0439 \u0441 \u0430\u043d\u0433\u043b\u043e\u044f\u0437\u044b\u0447\u043d\u043e\u0439 \u0430\u0443\u0434\u0438\u0442\u043e\u0440\u0438\u0435\u0439, \u0442\u043e \u043f\u0440\u043e\u0448\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043f\u0435\u0440\u0435\u0432\u043e\u0434: Mikhail Evtihevich. <a href=\"https:\/\/pvs-studio.com\/en\/blog\/posts\/csharp\/0930\/\">Checking Barotrauma with the PVS-Studio static analyzer<\/a>.<\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/pvs-studio\/blog\/658361\/\"> https:\/\/habr.com\/ru\/company\/pvs-studio\/blog\/658361\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>Barotrauma \u2013 \u0438\u0433\u0440\u0430, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u0434\u043b\u043e\u0434\u043a\u043e\u0439, \u043f\u043e\u043f\u0440\u044f\u0442\u0430\u0442\u044c\u0441\u044f \u043e\u0442 \u043c\u043e\u043d\u0441\u0442\u0440\u043e\u0432 \u0438 \u0434\u0430\u0436\u0435 \u043f\u043e\u0438\u0433\u0440\u0430\u0442\u044c \u043d\u0430 \u0430\u043a\u043a\u043e\u0440\u0434\u0435\u043e\u043d\u0435 \u0432 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u043d\u0435 \u043f\u043e\u0439\u0442\u0438 \u043a\u043e \u0434\u043d\u0443. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u043f\u0440\u043e\u0435\u043a\u0442, \u043d\u0430\u0447\u0430\u0442\u044b\u0439 \u0438\u043d\u0434\u0438-\u0441\u0442\u0443\u0434\u0438\u0435\u0439 Undertow Games \u0438 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0435\u043d\u043d\u044b\u0439 \u0441\u043e\u0432\u043c\u0435\u0441\u0442\u043d\u043e \u0441 FakeFish, \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0438\u0437\u043d\u0443\u0442\u0440\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u0441\u043b\u0435\u0434\u0443\u0435\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434, \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 \u044f\u0437\u044b\u043a\u0435 C#, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0430\u043d\u0430\u043b\u0438\u0437\u0430\u0442\u043e\u0440\u0430 PVS-Studio.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<h3>\u0412\u0432\u0435\u0434\u0435\u043d\u0438\u0435<\/h3>\n<p>Barotrauma \u2013 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043a\u043e\u0441\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 2D-\u0441\u0438\u043c\u0443\u043b\u044f\u0442\u043e\u0440 \u043f\u043e\u0434\u043b\u043e\u0434\u043a\u0438 \u0432 \u0436\u0430\u043d\u0440\u0435 survival horror. \u0418\u0433\u0440\u043e\u043a\u0443 \u043f\u0440\u0435\u0434\u0441\u0442\u043e\u0438\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043f\u043e\u0434\u043b\u043e\u0434\u043a\u043e\u0439, \u043e\u0442\u0434\u0430\u0432\u0430\u0442\u044c \u043f\u0440\u0438\u043a\u0430\u0437\u044b, \u0443\u0441\u0442\u0440\u0430\u043d\u044f\u0442\u044c \u043f\u0440\u043e\u0442\u0435\u0447\u043a\u0438 \u0438 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u0441\u0442\u043e\u044f\u0442\u044c \u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044f\u043c.<\/p>\n<p>Barotrauma \u043d\u0435 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f Open Source \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c \u0432 \u043e\u0431\u044b\u0447\u043d\u043e\u043c \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0438. \u0420\u0430\u043d\u043d\u044f\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0438\u0433\u0440\u044b \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u043e, \u0442\u0435\u043a\u0443\u0449\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u0432 <a href=\"https:\/\/store.steampowered.com\/app\/602960\/Barotrauma\/\">Steam<\/a>. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0438 \u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u043b\u0438 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0439 \u043a\u043e\u0434 \u043d\u0430 <a href=\"https:\/\/github.com\/Regalis11\/Barotrauma\">GitHub<\/a> \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e \u0438\u0433\u0440\u043e\u043a\u043e\u0432 \u043c\u043e\u0433\u043b\u043e \u0441\u0432\u043e\u0431\u043e\u0434\u043d\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043a\u043e\u043c\u043f\u043b\u0435\u043a\u0441\u043d\u044b\u0435 \u043c\u043e\u0434\u044b \u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438.<\/p>\n<h3>\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438<\/h3>\n<h4>\u041e\u0448\u0438\u0431\u043a\u0438 \u0432 if<\/h4>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3001\/\">V3001<\/a> There are identical sub-expressions &#8216;string.IsNullOrEmpty(EndPoint)&#8217; to the left and to the right of the &#8216;||&#8217; operator. BanList.cs 41<\/p>\n<pre><code class=\"cs\">public bool CompareTo(string endpointCompare) {   if (string.IsNullOrEmpty(EndPoint) || string.IsNullOrEmpty(EndPoint))    { return false; }   .... } <\/code><\/pre>\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>EndPoint<\/em> \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0434\u0432\u0430\u0436\u0434\u044b. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0437\u0430\u0431\u044b\u043b \u043f\u043e\u043c\u0435\u043d\u044f\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <em>EndPoint<\/em> \u043d\u0430 <em>endpointCompare<\/em> \u043f\u0440\u0438 \u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 <em>string.IsNullOrEmpty<\/em>. \u0412\u043e\u043e\u0431\u0449\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u044b \u043e\u0447\u0435\u043d\u044c \u0447\u0430\u0441\u0442\u043e \u043e\u0448\u0438\u0431\u0430\u044e\u0442\u0441\u044f \u0432 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f. \u0420\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043f\u043e\u0447\u0438\u0442\u0430\u0442\u044c <a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/cpp\/0509\/\">\u0441\u0442\u0430\u0442\u044c\u044e<\/a> \u043a\u043e\u043b\u043b\u0435\u0433\u0438 \u043e\u0431 \u044d\u0442\u043e\u043c.<\/p>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3004\/\">V3004<\/a> The &#8216;then&#8217; statement is equivalent to the &#8216;else&#8217; statement. ServerEntityEventManager.cs 314<\/p>\n<pre><code class=\"cs\">public void Write(Client client, IWriteMessage msg,                    out List&lt;NetEntityEvent> sentEvents) {   List&lt;NetEntityEvent> eventsToSync = null;   if (client.NeedsMidRoundSync)   {     eventsToSync = GetEventsToSync(client);   }   else   {     eventsToSync = GetEventsToSync(client);   }   .... } <\/code><\/pre>\n<p>\u0412\u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f <em>client.NeedsMidRoundSync<\/em> \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u043e\u0434\u043d\u043e \u0438 \u0442\u043e \u0436\u0435. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0443\u0431\u0440\u0430\u0442\u044c <em>else<\/em>-\u0432\u0435\u0442\u0432\u044c \u0438\u043b\u0438 \u043f\u0435\u0440\u0435\u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0435\u0451 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435.<\/p>\n<p>\u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0444\u0440\u0430\u0433\u043c\u0435\u043d\u0442 \u043a\u043e\u0434\u0430 \u0432\u044b\u0437\u0432\u0430\u043b \u0434\u0432\u0430 \u043f\u0440\u0435\u0434\u0443\u043f\u0440\u0435\u0436\u0434\u0435\u043d\u0438\u044f:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3021\/\">V3021<\/a> There are two &#8216;if&#8217; statements with identical conditional expressions. The first &#8216;if&#8217; statement contains method return. This means that the second &#8216;if&#8217; statement is senseless DebugConsole.cs 2177<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3022\/\">V3022<\/a> Expression &#8216;args.Length &lt; 2&#8217; is always false. DebugConsole.cs 2183<\/p>\n<\/li>\n<\/ul>\n<pre><code class=\"cs\">private static void InitProjectSpecific() {   ....   AssignOnClientRequestExecute(     \"setclientcharacter\",     (Client senderClient, Vector2 cursorWorldPos, string[] args) =>     {       if (args.Length &lt; 2)       {         GameMain.Server.SendConsoleMessage(\"....\", senderClient);         return;       }        if (args.Length &lt; 2)       {         ThrowError(\"....\");         return;       }     );   .... } <\/code><\/pre>\n<p>\u0414\u0432\u0435 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438. \u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e <em>if<\/em> \u043c\u0435\u0442\u043e\u0434 \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u0442 \u0440\u0430\u0431\u043e\u0442\u0443, \u0438\u043d\u0430\u0447\u0435 \u0436\u0435 \u043e\u0431\u0435 <em>then<\/em>-\u0432\u0435\u0442\u0432\u0438 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u044b.<\/p>\n<p>\u041f\u0440\u0438 \u0442\u0430\u043a\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c\u0441\u044f, \u043d\u043e \u0437\u0430\u043f\u0438\u0441\u044c \u043e\u0448\u0438\u0431\u043a\u0438 \u043c\u0435\u0442\u043e\u0434\u043e\u043c <em>ThrowError<\/em> \u043d\u0435 \u043f\u0440\u043e\u0438\u0437\u043e\u0439\u0434\u0451\u0442. \u0421\u043b\u0435\u0434\u0443\u0435\u0442 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0434\u0432\u0430 \u0442\u0435\u043b\u0430 <em>if<\/em> \u0438\u043b\u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0432\u0442\u043e\u0440\u043e\u0433\u043e.<\/p>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3022\/\">V3022<\/a> Expression &#8216;newPrice > 0&#8217; is always true. DebugConsole.cs 3310<\/p>\n<pre><code class=\"cs\">private static void PrintItemCosts(....) {   if (newPrice &lt; 1)   {     NewMessage(depth + materialPrefab.Name +      \" cannot be adjusted to this price, because it would become less than 1.\");     return;   }    ....    if (newPrice > 0)   {     newPrices.TryAdd(materialPrefab, newPrice);   }   .... } <\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 <em>newPrice<\/em> \u043c\u0435\u043d\u044c\u0448\u0435 \u0438\u043b\u0438 \u0440\u0430\u0432\u0435\u043d 0, \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u0442\u0435\u043b\u0430 \u043f\u0435\u0440\u0432\u043e\u0433\u043e <em>if<\/em>. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044f. \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0432\u0442\u043e\u0440\u043e\u0433\u043e <em>if<\/em> \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u0442\u0438\u043d\u043d\u043e. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0442\u0435\u043b\u043e \u0432\u0442\u043e\u0440\u043e\u0433\u043e *if *\u0432 <em>else<\/em>-\u0432\u0435\u0442\u0432\u044c \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0438\u043b\u0438 \u0436\u0435 \u0432\u043e\u0432\u0441\u0435 \u0435\u0433\u043e \u0443\u0431\u0440\u0430\u0442\u044c.<\/p>\n<h4>\u041e\u043f\u0435\u0447\u0430\u0442\u043a\u0438<\/h4>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3005\/\">V3005<\/a> The &#8216;arrowIcon.PressedColor&#8217; variable is assigned to itself. ChatBox.cs 164<\/p>\n<pre><code class=\"cs\">public ChatBox(GUIComponent parent, bool isSinglePlayer) {   ....   arrowIcon = new GUIImage(....)   {     Color = new Color(51, 59, 46)   };   arrowIcon.HoverColor = arrowIcon.PressedColor =    arrowIcon.PressedColor = arrowIcon.Color;   ....   } <\/code><\/pre>\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 *arrowIcon.PressedColor *\u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u043e\u0439 \u0441\u0435\u0431\u0435. \u0412 \u0442\u043e \u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u0432\u043d\u0443\u0442\u0440\u0438 \u043a\u043b\u0430\u0441\u0441\u0430 *GUIIMage *\u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <em>SelectedColor<\/em>. \u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0445\u043e\u0442\u0435\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e, \u043d\u043e \u043e\u043f\u0435\u0447\u0430\u0442\u0430\u043b\u0441\u044f.<\/p>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3005\/\">V3005<\/a> The &#8216;Penetration&#8217; variable is assigned to itself. Attack.cs 324<\/p>\n<pre><code class=\"cs\">public Attack(float damage,                float bleedingDamage,                float burnDamage,                float structureDamage,               float itemDamage,                float range = 0.0f,                float penetration = 0f) {    ....    Range = range;    DamageRange = range;    StructureDamage = LevelWallDamage = structureDamage;    ItemDamage = itemDamage;         Penetration = Penetration;                \/\/ &lt;= } <\/code><\/pre>\n<p>\u0415\u0449\u0451 \u043e\u0434\u043d\u0430 \u043f\u043e\u0434\u043e\u0431\u043d\u0430\u044f \u043e\u0448\u0438\u0431\u043a\u0430. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442 \u0445\u043e\u0442\u0435\u043b \u043f\u0440\u043e\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u0430, \u043d\u043e \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 <em>penetration<\/em> \u043f\u0440\u0438\u0441\u0432\u043e\u0438\u043b \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0443 <em>Penetration<\/em> \u0441\u0432\u043e\u0451 \u0436\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435.<\/p>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3025\/\">V3025<\/a> Incorrect format. A different number of format items is expected while calling &#8216;Format&#8217; function. Arguments not used: t.Character.Name. DebugConsole.cs 1123<\/p>\n<pre><code class=\"cs\">private static void InitProjectSpecific() {   AssignOnClientRequestExecute(\"traitorlist\",        (Client client, Vector2 cursorPos, string[] args) =>   {     ....     GameMain.Server.SendTraitorMessage(      client,       string.Format(\"- Traitor {0} has no current objective.\",            \/\/ &lt;=                    \"\",                                                   \/\/ &lt;=                    t.Character.Name),                                    \/\/ &lt;=      \"\",      TraitorMessageType.Console);      }); } <\/code><\/pre>\n<p>\u0418\u0441\u0445\u043e\u0434\u044f \u0438\u0437 \u0441\u043c\u044b\u0441\u043b\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <em>GameMain.Server.SendTraitorMessage<\/em> \u0444\u0440\u0430\u0437\u044b, \u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c, \u0447\u0442\u043e \u0441\u043f\u0435\u0446\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0432\u0432\u043e\u0434\u0430 <em>{0}<\/em> \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u043b \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c <em>t.Character.Name<\/em>. \u041e\u0434\u043d\u0430\u043a\u043e \u0436\u0435 \u0442\u0430\u043c \u043e\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043f\u0443\u0441\u0442\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430.<\/p>\n<p>\u041e\u0448\u0438\u0431\u043a\u0430, \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0441\u0442\u0432\u0438\u0435\u043c \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e\u0433\u043e copy-paste \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043c\u0435\u0442\u043e\u0434\u0430 <em>GameMain.Server.SendTraitorMessage<\/em>:<\/p>\n<pre><code class=\"cs\">GameMain.Server.SendTraitorMessage(client,  \"There are no traitors at the moment.\", \"\", TraitorMessageType.Console); <\/code><\/pre>\n<h4>\u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0435 NullReferenceException<\/h4>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3153\/\">V3153<\/a> Enumerating the result of null-conditional access operator can lead to NullReferenceException. Voting.cs 181<\/p>\n<pre><code class=\"cs\">public void ClientRead(IReadMessage inc) {   ....   foreach (GUIComponent item in            GameMain.NetLobbyScreen?.SubList?.Content?.Children)    \/\/ &lt;=   {     if (item.UserData != null &amp;&amp; item.UserData is SubmarineInfo)      {       serversubs.Add(item.UserData as SubmarineInfo);      }   }   .... } <\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0445\u043e\u0442\u044f \u0431\u044b \u043e\u0434\u0438\u043d \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0438\u0437 \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 <em>GameMain.NetLobbyScreen?.SubList?.Content?.Children<\/em> \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u0435\u043d <em>null<\/em>, \u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u0432\u0441\u0435\u0433\u043e \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u0442\u043e\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u0435\u043d <em>null<\/em>. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 *NullReferenceException *\u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u043f\u0435\u0440\u0435\u0431\u043e\u0440\u0430 \u0432 <em>foreach<\/em>.<\/p>\n<p>\u041f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043f\u0440\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 <em>?<\/em>. \u0432 <em>foreach<\/em> \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 <a href=\"https:\/\/pvs-studio.com\/ru\/blog\/posts\/csharp\/0832\/\">\u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435<\/a>.<\/p>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3027\/\">V3027<\/a> The variable &#8216;spawnPosition&#8217; was utilized in the logical expression before it was verified against null in the same logical expression. LevelObjectManager.cs 274<\/p>\n<pre><code class=\"cs\">private void PlaceObject(LevelObjectPrefab prefab,                           SpawnPosition spawnPosition,                           Level level, Level.Cave parentCave = null) {   float rotation = 0.0f;   if (   prefab.AlignWithSurface        &amp;&amp; spawnPosition.Normal.LengthSquared() > 0.001f          \/\/ &lt;=       &amp;&amp; spawnPosition != null)                                 \/\/ &lt;=   {     rotation = MathUtils.VectorToAngle(new Vector2(spawnPosition.Normal.Y,                                                     spawnPosition.Normal.X));   }   .... } <\/code><\/pre>\n<p>\u0418\u0437 \u043a\u043e\u0434\u0430 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0438\u0434\u0451\u0442 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 <em>LengthSquared<\/em> \u0443 \u043f\u043e\u043b\u044f <em>Normal<\/em> \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <em>spawnPosition<\/em> \u0438 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u0435\u0433\u043e \u0441 \u0437\u0430\u0434\u0430\u043d\u043d\u044b\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u043d\u0430 <em>null<\/em>.  \u0415\u0441\u043b\u0438 <em>spawnPosition<\/em> \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u043d\u0430 <em>null<\/em>, \u0442\u043e \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 <em>NullReferenceException<\/em>.<\/p>\n<p>\u041f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443 \u043d\u0430 <em>null<\/em> \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044f.<\/p>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3095\/\">V3095<\/a> The &#8216;level&#8217; object was used before it was verified against null. Check lines: 107, 115. BeaconMission.cs 107<\/p>\n<pre><code class=\"cs\">public override void End() {   completed = level.CheckBeaconActive();                        \/\/ &lt;=   if (completed)   {     if (Prefab.LocationTypeChangeOnCompleted != null)     {       ChangeLocationType(Prefab.LocationTypeChangeOnCompleted);     }     GiveReward();     if (level?.LevelData != null)                               \/\/ &lt;=     {       level.LevelData.IsBeaconActive = true;     }   } } <\/code><\/pre>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>level.CheckBeaconActive<\/em> \u043f\u0440\u0438\u0441\u0432\u0430\u0438\u0432\u0430\u0435\u0442\u0441\u044f, \u0430 \u0437\u0430\u0442\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <em>?.<\/em> \u0432 \u0432\u044b\u0440\u0430\u0436\u0435\u043d\u0438\u0438 <em>level?.LevelData<\/em>. \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u0438, \u043a\u043e\u0433\u0434\u0430 <em>level<\/em> \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0432\u0435\u043d <em>null<\/em> \u2014 \u0438 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0431\u0440\u043e\u0448\u0435\u043d\u043e \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 <em>NullReferenceException<\/em> \u043b\u0438\u0431\u043e <em>level<\/em> \u043d\u0438\u043a\u043e\u0433\u0434\u0430 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 <em>null \u2014<\/em> \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0438\u0437\u0431\u044b\u0442\u043e\u0447\u043d\u0430.<\/p>\n<h4>\u0412\u044b\u0445\u043e\u0434 \u0437\u0430 \u0433\u0440\u0430\u043d\u0438\u0446\u044b<\/h4>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3106\/\">V3106<\/a> Possibly index is out of bound. The &#8216;0&#8217; index is pointing beyond &#8216;Sprites&#8217; bound. ParticlePrefab.cs 303<\/p>\n<pre><code class=\"cs\">public ParticlePrefab(XElement element, ContentFile file) {   ....   if (CollisionRadius &lt;= 0.0f)      CollisionRadius = Sprites.Count > 0 ? 1 :                                            Sprites[0].SourceRect.Width \/ 2.0f; } <\/code><\/pre>\n<p>\u041f\u0440\u0438 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0438 \u0443\u0441\u043b\u043e\u0432\u0438\u044f \u0442\u0435\u0440\u043d\u0430\u0440\u043d\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 <em>CollisionRadius<\/em> \u0441\u0442\u0430\u043d\u0435\u0442 \u0440\u0430\u0432\u043d\u043e 1. \u0412 \u043f\u0440\u043e\u0442\u0438\u0432\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 <em>Sprites.Count<\/em> \u0440\u0430\u0432\u043d\u043e 0, \u0438 \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0443 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u0435\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 <em>IndexOutOfRangeException<\/em>.<\/p>\n<p>\u0420\u0430\u043d\u0435\u0435 \u043f\u043e \u043a\u043e\u0434\u0443 \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430: \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043b\u0438 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u043f\u0443\u0441\u0442\u043e\u0439.<\/p>\n<pre><code class=\"cs\">if (Sprites.Count == 0) {   DebugConsole.ThrowError($\"Particle prefab \\\"{Name}\\\" in the file \\\"{file}\\\"                             has no sprites defined!\"); } <\/code><\/pre>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u0433\u043e \u043a\u043e\u0434\u0430 \u043d\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442. \u0420\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0443 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0435\u0440\u0435\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u0438\u0435 \u0442\u0435\u0440\u043d\u0430\u0440\u043d\u043e\u0433\u043e \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430.<\/p>\n<h4>\u041b\u0438\u0448\u043d\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f<\/h4>\n<p><a href=\"https:\/\/pvs-studio.com\/ru\/docs\/warnings\/v3107\/\">V3107<\/a> Identical expression &#8216;power&#8217; to the left and to the right of compound assignment. RelayComponent.cs 150<\/p>\n<pre><code class=\"cs\">public override void ReceivePowerProbeSignal(Connection connection,                                               Item source, float power) {   ....   if (power &lt; 0.0f)   {     ....   }   else   {     if (connection.IsOutput || powerOut == null) {<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-331336","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/331336","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=331336"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/331336\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=331336"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=331336"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=331336"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}