fallback to first color in colors array if there is no valid color specified
authorsheepluva
Wed, 18 Mar 2015 21:52:13 +0100
changeset 10863 9d3e1123bd43
parent 10862 4575977d3ce0
child 10864 9cf20f487ee9
fallback to first color in colors array if there is no valid color specified
hedgewars/uChat.pas
--- a/hedgewars/uChat.pas	Wed Mar 18 23:18:52 2015 +0300
+++ b/hedgewars/uChat.pas	Wed Mar 18 21:52:13 2015 +0100
@@ -204,8 +204,15 @@
     end
 else
     begin
-    color:= colors[str[1]];
-    delete(str, 1, 1);
+    if str[1] <= High(colors) then
+        begin
+        color:= colors[str[1]];
+        delete(str, 1, 1);
+        end
+    // fallback if invalid color
+    else
+        color:= colors[Low(colors)];
+
     cl.s:= str;
     end;