# HG changeset patch # User nemo # Date 1291613619 18000 # Node ID b08c7ebcadb25682ce8e33094c4ccf425aedc16b # Parent 0758b19bc99b6071e0f4fd1578aaa55ae86e5d78 string length checks diff -r 0758b19bc99b -r b08c7ebcadb2 hedgewars/uGears.pas --- a/hedgewars/uGears.pas Sun Dec 05 23:58:15 2010 -0500 +++ b/hedgewars/uGears.pas Mon Dec 06 00:33:39 2010 -0500 @@ -1751,9 +1751,13 @@ begin hh:= nil; i:= 0; + t:= 0; x:= byte(s[1]); // speech type - t:= byte(s[2]); // team - h:= byte(s[3]); // target hog + if x < 4 then + begin + t:= byte(s[2]); // team + if Length(s) > 2 then h:= byte(s[3]) // target hog + end; // allow targetting a hog by specifying a number as the first portion of the text if (x < 4) and (h > byte('0')) and (h < byte('9')) then i:= h - 48; if i <> 0 then text:= copy(s, 4, Length(s) - 1)