Skip to content

Commit 0d21d79

Browse files
committed
Some C# String usage refactoring
1 parent 57007c5 commit 0d21d79

1 file changed

Lines changed: 26 additions & 46 deletions

File tree

Source/KopernicusMods/MapSODemandLarge.cs

Lines changed: 26 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ private void LoadTexture(String path)
4747
{
4848
try
4949
{
50-
if (path.ToLower().EndsWith(".dds"))
50+
if (path.EndsWith(".dds", StringComparison.OrdinalIgnoreCase))
5151
{
5252
// Borrowed from stock KSP 1.0 DDS loader (hi Mike!)
5353
// Also borrowed the extra bits from Sarbian.
@@ -141,7 +141,7 @@ private void LoadTexture(String path)
141141
}
142142
catch (Exception ex)
143143
{
144-
Debug.Log("[Kopernicus]: failed to load " + path + " with exception " + ex.Message);
144+
Debug.Log($"[Kopernicus]: failed to load {path} with exception {ex}");
145145
}
146146
}
147147
else
@@ -174,12 +174,12 @@ public void Load()
174174
eventMap.Path = Path;
175175
Events.OnMapSOLoad.Fire(eventMap);
176176

177-
Debug.Log("[OD] ---> Map " + name + " enabling self. Path = " + Path);
177+
Debug.Log($"[OD] ---> Map {name} enabling self. Path = {Path}");
178178
return;
179179
}
180180

181181
// Return nothing
182-
Debug.Log("[OD] ERROR: Failed to load map " + name + " at path " + Path);
182+
Debug.Log($"[OD] ERROR: Failed to load map {name} at path {Path}");
183183
}
184184

185185
/// <summary>
@@ -209,7 +209,7 @@ public void Unload()
209209
Events.OnMapSOUnload.Fire(eventMap);
210210

211211
// Log
212-
Debug.Log("[OD] <--- Map " + name + " disabling self. Path = " + Path);
212+
Debug.Log($"[OD] <--- Map {name} disabling self. Path = {Path}");
213213
}
214214

215215
protected override void ConstructBilinearCoords(double x, double y)
@@ -241,7 +241,7 @@ public override Byte GetPixelByte(Int32 x, Int32 y)
241241
{
242242
if (OnDemandStorage.OnDemandLogOnMissing)
243243
{
244-
Debug.Log("[OD] ERROR: getting pixelbyte with unloaded map " + name + " of path " + Path + ", autoload = " + AutoLoad);
244+
Debug.Log($"[OD] ERROR: getting pixelbyte with unloaded map {name} of path {Path}, autoload = {AutoLoad}");
245245
}
246246

247247
if (AutoLoad)
@@ -284,8 +284,7 @@ public override Color GetPixelColor(Double x, Double y)
284284

285285
if (OnDemandStorage.OnDemandLogOnMissing)
286286
{
287-
Debug.Log("[OD] ERROR: getting pixelColD with unloaded map " + name + " of path " + Path +
288-
", autoload = " + AutoLoad);
287+
Debug.Log($"[OD] ERROR: getting pixelColD with unloaded map {name} of path {Path}, autoload = {AutoLoad}");
289288
}
290289

291290
if (AutoLoad)
@@ -310,8 +309,7 @@ public override Color GetPixelColor(Single x, Single y)
310309

311310
if (OnDemandStorage.OnDemandLogOnMissing)
312311
{
313-
Debug.Log("[OD] ERROR: getting pixelColF with unloaded map " + name + " of path " + Path +
314-
", autoload = " + AutoLoad);
312+
Debug.Log($"[OD] ERROR: getting pixelColF with unloaded map {name} of path {Path}, autoload = {AutoLoad}");
315313
}
316314

317315
if (AutoLoad)
@@ -333,8 +331,7 @@ public override Color GetPixelColor(Int32 x, Int32 y)
333331
{
334332
if (OnDemandStorage.OnDemandLogOnMissing)
335333
{
336-
Debug.Log("[OD] ERROR: getting pixelColI with unloaded map " + name + " of path " + Path +
337-
", autoload = " + AutoLoad);
334+
Debug.Log($"[OD] ERROR: getting pixelColI with unloaded map {name} of path {Path}, autoload = {AutoLoad}");
338335
}
339336

340337
if (AutoLoad)
@@ -383,8 +380,7 @@ public override Color GetPixelColor32(Double x, Double y)
383380

384381
if (OnDemandStorage.OnDemandLogOnMissing)
385382
{
386-
Debug.Log("[OD] ERROR: getting pixelCol32D with unloaded map " + name + " of path " + Path +
387-
", autoload = " + AutoLoad);
383+
Debug.Log($"[OD] ERROR: getting pixelCol32D with unloaded map {name} of path {Path}, autoload = {AutoLoad}");
388384
}
389385

390386
if (AutoLoad)
@@ -409,8 +405,7 @@ public override Color GetPixelColor32(Single x, Single y)
409405

410406
if (OnDemandStorage.OnDemandLogOnMissing)
411407
{
412-
Debug.Log("[OD] ERROR: getting pixelCol32F with unloaded map " + name + " of path " + Path +
413-
", autoload = " + AutoLoad);
408+
Debug.Log($"[OD] ERROR: getting pixelCol32F with unloaded map {name} of path {Path}, autoload = {AutoLoad}");
414409
}
415410

416411
if (AutoLoad)
@@ -432,8 +427,7 @@ public override Color32 GetPixelColor32(Int32 x, Int32 y)
432427
{
433428
if (OnDemandStorage.OnDemandLogOnMissing)
434429
{
435-
Debug.Log("[OD] ERROR: getting pixelCol32I with unloaded map " + name + " of path " + Path +
436-
", autoload = " + AutoLoad);
430+
Debug.Log($"[OD] ERROR: getting pixelCol32I with unloaded map {name} of path {Path}, autoload = {AutoLoad}");
437431
}
438432

439433
if (AutoLoad)
@@ -480,8 +474,7 @@ public override Single GetPixelFloat(Double x, Double y)
480474

481475
if (OnDemandStorage.OnDemandLogOnMissing)
482476
{
483-
Debug.Log("[OD] ERROR: getting pixelFloatD with unloaded map " + name + " of path " + Path +
484-
", autoload = " + AutoLoad);
477+
Debug.Log($"[OD] ERROR: getting pixelFloatD with unloaded map {name} of path {Path}, autoload = {AutoLoad}");
485478
}
486479

487480
if (AutoLoad)
@@ -506,8 +499,7 @@ public override Single GetPixelFloat(Single x, Single y)
506499

507500
if (OnDemandStorage.OnDemandLogOnMissing)
508501
{
509-
Debug.Log("[OD] ERROR: getting pixelFloatF with unloaded map " + name + " of path " + Path +
510-
", autoload = " + AutoLoad);
502+
Debug.Log($"[OD] ERROR: getting pixelFloatF with unloaded map {name} of path {Path}, autoload = {AutoLoad}");
511503
}
512504

513505
if (AutoLoad)
@@ -529,8 +521,7 @@ public override Single GetPixelFloat(Int32 x, Int32 y)
529521
{
530522
if (OnDemandStorage.OnDemandLogOnMissing)
531523
{
532-
Debug.Log("[OD] ERROR: getting pixelFloatI with unloaded map " + name + " of path " + Path +
533-
", autoload = " + AutoLoad);
524+
Debug.Log($"[OD] ERROR: getting pixelFloatI with unloaded map {name} of path {Path}, autoload = {AutoLoad}");
534525
}
535526

536527
if (AutoLoad)
@@ -570,8 +561,7 @@ public override HeightAlpha GetPixelHeightAlpha(Double x, Double y)
570561

571562
if (OnDemandStorage.OnDemandLogOnMissing)
572563
{
573-
Debug.Log("[OD] ERROR: getting pixelHeightAlphaD with unloaded map " + name + " of path " + Path +
574-
", autoload = " + AutoLoad);
564+
Debug.Log($"[OD] ERROR: getting pixelHeightAlphaD with unloaded map {name} of path {Path}, autoload = {AutoLoad}");
575565
}
576566

577567
if (AutoLoad)
@@ -593,8 +583,7 @@ public override HeightAlpha GetPixelHeightAlpha(Single x, Single y)
593583
{
594584
if (OnDemandStorage.OnDemandLogOnMissing)
595585
{
596-
Debug.Log("[OD] ERROR: getting pixelHeightAlphaF with unloaded map " + name + " of path " + Path +
597-
", autoload = " + AutoLoad);
586+
Debug.Log($"[OD] ERROR: getting pixelHeightAlphaF with unloaded map {name} of path {Path}, autoload = {AutoLoad}");
598587
}
599588

600589
if (AutoLoad)
@@ -617,8 +606,7 @@ public override HeightAlpha GetPixelHeightAlpha(Int32 x, Int32 y)
617606
{
618607
if (OnDemandStorage.OnDemandLogOnMissing)
619608
{
620-
Debug.Log("[OD] ERROR: getting pixelHeightAlphaI with unloaded map " + name + " of path " +
621-
Path + ", autoload = " + AutoLoad);
609+
Debug.Log($"[OD] ERROR: getting pixelHeightAlphaI with unloaded map {name} of path {Path}, autoload = {AutoLoad}");
622610
}
623611

624612
if (AutoLoad)
@@ -658,8 +646,7 @@ public override Byte GreyByte(Int32 x, Int32 y)
658646
{
659647
if (OnDemandStorage.OnDemandLogOnMissing)
660648
{
661-
Debug.Log("[OD] ERROR: getting GreyByteI with unloaded map " + name + " of path " + Path +
662-
", autoload = " + AutoLoad);
649+
Debug.Log($"[OD] ERROR: getting GreyByteI with unloaded map {name} of path {Path}, autoload = {AutoLoad}");
663650
}
664651

665652
if (AutoLoad)
@@ -687,8 +674,7 @@ public override Single GreyFloat(Int32 x, Int32 y)
687674
{
688675
if (OnDemandStorage.OnDemandLogOnMissing)
689676
{
690-
Debug.Log("[OD] ERROR: getting GreyFloat with unloaded map " + name + " of path " + Path +
691-
", autoload = " + AutoLoad);
677+
Debug.Log($"[OD] ERROR: getting GreyFloat with unloaded map {name} of path {Path}, autoload = {AutoLoad}");
692678
}
693679

694680
if (AutoLoad)
@@ -716,8 +702,7 @@ public override Byte[] PixelByte(Int32 x, Int32 y)
716702
{
717703
if (OnDemandStorage.OnDemandLogOnMissing)
718704
{
719-
Debug.Log("[OD] ERROR: getting pixelByte with unloaded map " + name + " of path " + Path +
720-
", autoload = " + AutoLoad);
705+
Debug.Log($"[OD] ERROR: getting pixelByte with unloaded map {name} of path {Path}, autoload = {AutoLoad}");
721706
}
722707

723708
if (AutoLoad)
@@ -752,8 +737,7 @@ public override Texture2D CompileToTexture(Byte filter)
752737
{
753738
if (OnDemandStorage.OnDemandLogOnMissing)
754739
{
755-
Debug.Log("[OD] ERROR: compiling with unloaded map " + name + " of path " + Path + ", autoload = " +
756-
AutoLoad);
740+
Debug.Log($"[OD] ERROR: compiling with unloaded map {name} of path {Path}, autoload = {AutoLoad}");
757741
}
758742

759743
if (AutoLoad)
@@ -790,8 +774,7 @@ public override Texture2D CompileGreyscale()
790774
{
791775
if (OnDemandStorage.OnDemandLogOnMissing)
792776
{
793-
Debug.Log("[OD] ERROR: compiling with unloaded map " + name + " of path " + Path + ", autoload = " +
794-
AutoLoad);
777+
Debug.Log($"[OD] ERROR: compiling with unloaded map {name} of path {Path}, autoload = {AutoLoad}");
795778
}
796779

797780
if (AutoLoad)
@@ -828,8 +811,7 @@ public override Texture2D CompileHeightAlpha()
828811
{
829812
if (OnDemandStorage.OnDemandLogOnMissing)
830813
{
831-
Debug.Log("[OD] ERROR: compiling with unloaded map " + name + " of path " + Path + ", autoload = " +
832-
AutoLoad);
814+
Debug.Log($"[OD] ERROR: compiling with unloaded map {name} of path {Path}, autoload = {AutoLoad}");
833815
}
834816

835817
if (AutoLoad)
@@ -866,8 +848,7 @@ public override Texture2D CompileRGB()
866848
{
867849
if (OnDemandStorage.OnDemandLogOnMissing)
868850
{
869-
Debug.Log("[OD] ERROR: compiling with unloaded map " + name + " of path " + Path + ", autoload = " +
870-
AutoLoad);
851+
Debug.Log($"[OD] ERROR: compiling with unloaded map {name} of path {Path}, autoload = {AutoLoad}");
871852
}
872853

873854
if (AutoLoad)
@@ -903,8 +884,7 @@ public override Texture2D CompileRGBA()
903884
{
904885
if (OnDemandStorage.OnDemandLogOnMissing)
905886
{
906-
Debug.Log("[OD] ERROR: compiling with unloaded map " + name + " of path " + Path + ", autoload = " +
907-
AutoLoad);
887+
Debug.Log($"[OD] ERROR: compiling with unloaded map {name} of path {Path}, autoload = {AutoLoad}");
908888
}
909889

910890
if (AutoLoad)

0 commit comments

Comments
 (0)