Skip to content

Commit 262d2db

Browse files
committed
fix warnings
1 parent 397c536 commit 262d2db

File tree

12 files changed

+25
-23
lines changed

12 files changed

+25
-23
lines changed

.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ resharper_redundant_explicit_array_creation_highlighting=none
222222
resharper_redundant_name_qualifier_highlighting=none
223223
resharper_redundant_readonly_modifier_highlighting=warning
224224
resharper_redundant_using_directive_highlighting=suggestion
225-
resharper_remove_redundant_braces_highlighting=warning
225+
resharper_remove_redundant_braces_highlighting=hint
226226
resharper_static_member_in_generic_type_highlighting=suggestion
227227
resharper_string_ends_with_is_culture_specific_highlighting=warning
228228
resharper_string_starts_with_is_culture_specific_highlighting=warning

CGSrl.Client/src/Networking/GameClient.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public void SetUi(Text loadingText, string loadingTextFormat, ProgressBar loadin
8989
if(players is null || level is null)
9090
return;
9191
players.Clear();
92-
foreach(PlayerObject player in level.objects.OfType<PlayerObject>())
92+
foreach(PlayerObject player in level.objects.Values.OfType<PlayerObject>())
9393
players.Add(player);
9494
}
9595

@@ -204,7 +204,7 @@ private void ProcessMessages(TimeSpan maxTime) {
204204
return;
205205
}
206206
TimeSpan start = _timer.time;
207-
while(peer.ReadMessage(out NetIncomingMessage msg)) {
207+
while(peer.ReadMessage(out NetIncomingMessage? msg)) {
208208
ProcessMessage(msg);
209209
if(_timer.time - start > maxTime)
210210
break;

CGSrl.Server/src/Networking/GameServer.cs

+10-10
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public void Finish() {
8484

8585
public void ProcessMessages() {
8686
ProcessObjectUpdates();
87-
while(_peer.ReadMessage(out NetIncomingMessage msg)) {
87+
while(_peer.ReadMessage(out NetIncomingMessage? msg)) {
8888
switch(msg.MessageType) {
8989
case NetIncomingMessageType.WarningMessage:
9090
logger.Warn(msg.ReadString);
@@ -142,7 +142,7 @@ private void ProcessObjectUpdates() {
142142
}
143143

144144
private void ProcessConnectionApproval(NetIncomingMessage msg) {
145-
NetConnection connection = msg.SenderConnection;
145+
NetConnection connection = msg.SenderConnection!;
146146
string username = msg.ReadString();
147147
string displayName = msg.ReadString();
148148
if(string.IsNullOrEmpty(username)) {
@@ -171,10 +171,10 @@ private void ProcessConnectionApproval(NetIncomingMessage msg) {
171171
SendChatMessage(null, null, $"\f1{displayName} is joining the game");
172172
}
173173

174-
private void ProcessStatusChanged(NetConnectionStatus status, string reason, NetConnection connection) {
174+
private void ProcessStatusChanged(NetConnectionStatus status, string reason, NetConnection? connection) {
175175
switch(status) {
176176
case NetConnectionStatus.Connected: {
177-
if(connection.Tag is not PlayerObject player) {
177+
if(connection?.Tag is not PlayerObject player) {
178178
logger.Warn("Tag was not player, ignoring connect!");
179179
return;
180180
}
@@ -196,7 +196,7 @@ private void ProcessStatusChanged(NetConnectionStatus status, string reason, Net
196196
break;
197197
}
198198
case NetConnectionStatus.Disconnected: {
199-
if(connection.Tag is not PlayerObject player) {
199+
if(connection?.Tag is not PlayerObject player) {
200200
logger.Warn("Tag was not player, ignoring disconnect!");
201201
return;
202202
}
@@ -208,8 +208,8 @@ private void ProcessStatusChanged(NetConnectionStatus status, string reason, Net
208208
}
209209
}
210210

211-
private static void ProcessConnectionLatencyUpdated(NetConnection connection, float roundTripTime) {
212-
if(connection.Tag is not PlayerObject player) {
211+
private static void ProcessConnectionLatencyUpdated(NetConnection? connection, float roundTripTime) {
212+
if(connection?.Tag is not PlayerObject player) {
213213
logger.Warn("Tag was not player, ignoring ping update!");
214214
return;
215215
}
@@ -270,15 +270,15 @@ private void ProcessRemoveObject(NetBuffer msg) {
270270
}
271271

272272
private static void ProcessPlayerMove(NetIncomingMessage msg) {
273-
if(msg.SenderConnection.Tag is not PlayerObject player) {
273+
if(msg.SenderConnection?.Tag is not PlayerObject player) {
274274
logger.Warn("Tag was not player, ignoring player move!");
275275
return;
276276
}
277277
player.move = msg.ReadVector2Int();
278278
}
279279

280280
private void ProcessPlayerInteract(NetIncomingMessage msg) {
281-
if(msg.SenderConnection.Tag is not PlayerObject player) {
281+
if(msg.SenderConnection?.Tag is not PlayerObject player) {
282282
logger.Warn("Tag was not player, ignoring player interact!");
283283
return;
284284
}
@@ -295,7 +295,7 @@ private void ProcessPlayerInteract(NetIncomingMessage msg) {
295295
}
296296

297297
private void ProcessChatMessage(NetIncomingMessage msg) {
298-
if(msg.SenderConnection.Tag is not PlayerObject player) {
298+
if(msg.SenderConnection?.Tag is not PlayerObject player) {
299299
logger.Warn("Tag was not player, ignoring chat message!");
300300
return;
301301
}

CGSrl.Shared/src/Environment/BoxObject.cs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace CGSrl.Shared.Environment;
66
public class BoxObject : MovableObject {
77
public class Broken : MovableObject {
88
public override int layer => -2;
9-
public override RenderCharacter character { get; } = new('%', Color.transparent, new Color(0.5f, 0.5f, 0f, 1f));
9+
public override RenderCharacter character { get; } = new('%', Color.transparent, new Color(0.5f, 0.5f, 0f));
1010
public override bool blocksLight => false;
1111
protected override bool canPush => true;
1212
protected override float mass => 1f;
@@ -18,6 +18,6 @@ public class Broken : MovableObject {
1818
protected override float strength => 4f;
1919
protected override MovableObject CreateBroken() => new Broken { position = position };
2020
public override int layer => 0;
21-
public override RenderCharacter character { get; } = new('&', Color.transparent, new Color(1f, 1f, 0f, 1f));
21+
public override RenderCharacter character { get; } = new('&', Color.transparent, new Color(1f, 1f, 0f));
2222
public override bool blocksLight => true;
2323
}

CGSrl.Shared/src/Environment/CorruptedObject.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ namespace CGSrl.Shared.Environment;
99
public class CorruptedObject : SyncedLevelObject {
1010
public override int layer => int.MaxValue;
1111
public override RenderCharacter character { get; } = new('\0', Color.white, Color.transparent);
12-
public override IEffect? effect => renderer.formattingEffects["glitch"];
12+
public override IEffect? effect => renderer?.formattingEffects["glitch"];
1313
public override bool blocksLight => false;
1414
}

CGSrl.Shared/src/Environment/FloorObject.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ public void Added() {
2525
if(!level.isClient)
2626
return;
2727
float p = noise.GetNoise(MathF.Abs(position.x), MathF.Abs(position.y)) * PerlinValue;
28-
_character = new RenderCharacter('.', Color.transparent, new Color(0.1f + p, 0.1f + p, 0.1f + p, 1f));
28+
_character = new RenderCharacter('.', Color.transparent, new Color(0.1f + p, 0.1f + p, 0.1f + p));
2929
}
3030
}

CGSrl.Shared/src/Environment/GrassObject.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public class GrassObject : InteractableObject {
1111
public override string prompt => "touch";
1212

1313
public override int layer => -1;
14-
public override RenderCharacter character { get; } = new('"', Color.transparent, new Color(0f, 0.4f, 0f, 1f));
14+
public override RenderCharacter character { get; } = new('"', Color.transparent, new Color(0f, 0.4f, 0f));
1515
public override bool blocksLight => false;
1616

1717
protected override void OnInteract(PlayerObject player) {

CGSrl.Shared/src/Environment/IceObject.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ namespace CGSrl.Shared.Environment;
88
public class IceObject : SyncedLevelObject {
99
public override int layer => -3;
1010
public override RenderCharacter character { get; } =
11-
new('~', Color.transparent, new Color(0f, 0.2f, 0.2f, 1f));
11+
new('~', Color.transparent, new Color(0f, 0.2f, 0.2f));
1212
public override bool blocksLight => false;
1313
}

CGSrl.Shared/src/Environment/PlayerObject.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ namespace CGSrl.Shared.Environment;
1515
public class PlayerObject : MovableObject, IUpdatable, IMovable, ILight {
1616
public override int layer => 0;
1717
public override RenderCharacter character => new('@',
18-
highlighted ? new Color(1f, 1f, 0f, 0.2f) : Color.transparent, new Color(0, 255, 255, 255));
18+
highlighted ? new Color(1f, 1f, 0f, 0.2f) : Color.transparent, new Color(0, 255, 255));
1919
public override bool blocksLight => false;
2020

2121
protected override bool canPush => true;
@@ -86,6 +86,7 @@ public void Update(TimeSpan time) {
8686
}
8787

8888
private void UpdateInteraction() {
89+
RequireClient();
8990
Vector2Int mouse = level.ScreenToLevelPosition(input.mousePosition);
9091
Vector2Int relativeMouse = mouse - position;
9192
float mouseDistSqr = new Vector2(relativeMouse.x, relativeMouse.y).LengthSquared();
@@ -105,6 +106,7 @@ private void UpdateInteraction() {
105106
private void UpdateMovement() {
106107
if(connection is null)
107108
return;
109+
RequireClient();
108110
int moveX = 0;
109111
int moveY = 0;
110112
if(input.KeyPressed(KeyCode.D))

CGSrl.Shared/src/Environment/WallObject.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ public class WallObject : MovableObject {
77
public class Broken : MovableObject {
88
public override int layer => -2;
99
public override RenderCharacter character { get; } =
10-
new('%', Color.transparent, new Color(0.5f, 0.5f, 0.5f, 1f));
10+
new('%', Color.transparent, new Color(0.5f, 0.5f, 0.5f));
1111
public override bool blocksLight => false;
1212
protected override bool canPush => true;
1313
protected override float mass => 8f;

CGSrl.Shared/src/Networking/SyncedGameMode.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22

33
namespace CGSrl.Shared.Networking;
44

5-
public abstract class SyncedGameMode : GameMode<SyncedLevel, SyncedChunk, SyncedLevelObject> { }
5+
public abstract class SyncedGameMode : GameMode<SyncedLevel, SyncedChunk, SyncedLevelObject>;

0 commit comments

Comments
 (0)