diff --git a/src/SICore/SICore/Clients/Game/GameLogic.cs b/src/SICore/SICore/Clients/Game/GameLogic.cs index 67b9523a..8830c98b 100644 --- a/src/SICore/SICore/Clients/Game/GameLogic.cs +++ b/src/SICore/SICore/Clients/Game/GameLogic.cs @@ -2800,7 +2800,7 @@ private void PrintPartial() var printingLength = newTextLength - _data.TextLength; // Align to next space position - while (_data.TextLength + printingLength + 1 < text.Length && !char.IsWhiteSpace(text[_data.TextLength + printingLength])) + while (_data.TextLength + printingLength < text.Length && !char.IsWhiteSpace(text[_data.TextLength + printingLength])) { printingLength++; } diff --git a/src/SIQuester/SIQuester/Controls/TextList.cs b/src/SIQuester/SIQuester/Controls/TextList.cs index 3867cc98..7820f766 100644 --- a/src/SIQuester/SIQuester/Controls/TextList.cs +++ b/src/SIQuester/SIQuester/Controls/TextList.cs @@ -210,6 +210,11 @@ private void OnItemsRemoved(NotifyCollectionChangedEventArgs e) Select(start, end - start); _infos.RemoveRange(e.OldStartingIndex, e.OldItems.Count); + + if (_infos.Count != ItemsSource.Count) + { + throw new Exception($"_infos.Count != ItemsSource.Count (_infos.Count: {_infos.Count}, ItemsSource.Count: {ItemsSource.Count}, e.OldItems.Count: {e.OldItems.Count}"); + } } finally { @@ -244,7 +249,7 @@ private void Check() { if (Text != ItemsSource[0].ToString()) { - MessageBox.Show("Ошибка редактирования! Обратитесь к разработчику."); + MessageBox.Show("Editing error. Send message to author"); SetText(); } } @@ -273,6 +278,11 @@ private void OnItemsAdded(NotifyCollectionChangedEventArgs e) _infos.Insert(index++, new ItemInfo(toAdd.Length, isLink ? toAdd.Length : -1, canBeSpecified)); } + if (_infos.Count != ItemsSource.Count) + { + throw new Exception($"_infos.Count != ItemsSource.Count (_infos.Count: {_infos.Count}, ItemsSource.Count: {ItemsSource.Count}, e.NewItems.Count: {e.NewItems.Count}"); + } + if (e.NewStartingIndex == 0 && index < _infos.Count) { text.Append(ItemsSeparator); @@ -411,11 +421,9 @@ protected override void OnTextChanged(TextChangedEventArgs e) return; } - int index = 0; - foreach (var change in e.Changes) { - var offset = ConvertGlobalOffsetToLocalOffset(change.Offset, out index); + var offset = ConvertGlobalOffsetToLocalOffset(change.Offset, out var index); var origin = ItemsSource[index].ToString(); _blockNotificationsFlag = true; diff --git a/test/SIGame/SIGame.Tests/appsettings.json b/test/SIGame/SIGame.Tests/appsettings.json index 8596f265..4b98d232 100644 --- a/test/SIGame/SIGame.Tests/appsettings.json +++ b/test/SIGame/SIGame.Tests/appsettings.json @@ -1,6 +1,6 @@ { "GameServerClient": { - "ServiceUri": "https://vladimirkhil.com/siserver/0/" + "ServiceUri": "https://vladimirkhil.com/sigameserver-0/api/v1/" }, "SIStorageServiceClient": { "ServiceUri": "https://vladimirkhil.com/sistorage/"