Reduce number of warnings in pas2c-generated code
authorunc0rr
Sun, 16 Feb 2014 22:06:55 +0400
changeset 10142 adb804cb2638
parent 10141 3be894730bd6
child 10143 3636106f5b70
Reduce number of warnings in pas2c-generated code
hedgewars/uGearsRender.pas
hedgewars/uIO.pas
hedgewars/uLand.pas
hedgewars/uRenderUtils.pas
project_files/hwc/rtl/pas2c.h
tools/pas2c/Pas2C.hs
tools/pas2c/PascalUnitSyntaxTree.hs
--- a/hedgewars/uGearsRender.pas	Sun Feb 16 16:56:53 2014 +0400
+++ b/hedgewars/uGearsRender.pas	Sun Feb 16 22:06:55 2014 +0400
@@ -275,7 +275,7 @@
     if HH^.Effects[hePoisoned] <> 0 then
         begin
         Tint($00, $FF, $40, $40);
-        DrawTextureRotatedF(SpritesData[sprSmokeWhite].texture, 2, 0, 0, sx, sy, 0, 1, 22, 22, (RealTicks shr 36) mod 360);
+        DrawTextureRotatedF(SpritesData[sprSmokeWhite].texture, 2, 0, 0, sx, sy, 0, 1, 22, 22, (RealTicks shr 4) mod 360);
         untint
         end;
 
@@ -981,7 +981,7 @@
     if HH^.Effects[hePoisoned] <> 0 then
         begin
         Tint($00, $FF, $40, $80);
-        DrawTextureRotatedF(SpritesData[sprSmokeWhite].texture, 1.5, 0, 0, sx, sy, 0, 1, 22, 22, 360 - (RealTicks shr 37) mod 360);
+        DrawTextureRotatedF(SpritesData[sprSmokeWhite].texture, 1.5, 0, 0, sx, sy, 0, 1, 22, 22, 360 - (RealTicks shr 5) mod 360);
         end;
     if HH^.Effects[heResurrected] <> 0 then
         begin
@@ -1262,7 +1262,7 @@
                         Tint(Gear^.Tint and $FFFFFF00 or (5000 - Gear^.Timer) div 8)
                     else
                         Tint(Gear^.Tint);
-                    DrawTextureRotatedF(SpritesData[sprSmokeWhite].texture, 3, 0, 0, x, y, 0, 1, 22, 22, (RealTicks shr 36 + Gear^.UID * 100) mod 360);
+                    DrawTextureRotatedF(SpritesData[sprSmokeWhite].texture, 3, 0, 0, x, y, 0, 1, 22, 22, (RealTicks shr 4 + Gear^.UID * 100) mod 360);
                     untint
                     end;
      gtResurrector: begin
--- a/hedgewars/uIO.pas	Sun Feb 16 16:56:53 2014 +0400
+++ b/hedgewars/uIO.pas	Sun Feb 16 22:06:55 2014 +0400
@@ -223,7 +223,7 @@
     case c of
         '+', '#', 'L', 'l', 'R', 'r', 'U', 'u', 'D', 'd', 'Z', 'z', 'A', 'a', 'S', 'j', 'J', ',', 'c', 'N', 'p', 'P', 'w', 't', '1', '2', '3', '4', '5': isSyncedCommand:= true;
     else
-        isSyncedCommand:= ((c >= #128) and (c <= char(128 + cMaxSlotIndex)))
+        isSyncedCommand:= ((byte(c) >= 128) and (byte(c) <= 128 + cMaxSlotIndex))
     end
 end;
 
--- a/hedgewars/uLand.pas	Sun Feb 16 16:56:53 2014 +0400
+++ b/hedgewars/uLand.pas	Sun Feb 16 22:06:55 2014 +0400
@@ -394,7 +394,7 @@
         6: begin
            SelectTemplate:= min(LuaTemplateNumber,High(EdgeTemplates));
            GetRandom(2) // burn 1
-           end;
+           end
         end
     end;
 
--- a/hedgewars/uRenderUtils.pas	Sun Feb 16 16:56:53 2014 +0400
+++ b/hedgewars/uRenderUtils.pas	Sun Feb 16 22:06:55 2014 +0400
@@ -318,21 +318,23 @@
     if cOnlyStats then exit(nil);
 
     case SpeechType of
-        1: begin;
+        1: begin
             edge:= sprSpeechEdge;
             corner:= sprSpeechCorner;
             tail:= sprSpeechTail;
             end;
-        2: begin;
+        2: begin
             edge:= sprThoughtEdge;
             corner:= sprThoughtCorner;
             tail:= sprThoughtTail;
             end;
-        3: begin;
+        3: begin
             edge:= sprShoutEdge;
             corner:= sprShoutCorner;
             tail:= sprShoutTail;
-            end;
+            end
+        else
+            exit(nil)
         end;
     edgeHeight:= SpritesData[edge].Height;
     edgeWidth:= SpritesData[edge].Width;
--- a/project_files/hwc/rtl/pas2c.h	Sun Feb 16 16:56:53 2014 +0400
+++ b/project_files/hwc/rtl/pas2c.h	Sun Feb 16 22:06:55 2014 +0400
@@ -80,5 +80,5 @@
 
 
 #define STRINIT(a) {.len = sizeof(a) - 1, .str = a}
+#define UNUSED(x) (void)(x)
 
-
--- a/tools/pas2c/Pas2C.hs	Sun Feb 16 16:56:53 2014 +0400
+++ b/tools/pas2c/Pas2C.hs	Sun Feb 16 22:06:55 2014 +0400
@@ -809,6 +809,9 @@
     r <- ref2C ref
     t <- gets lastType
     case (t, expr) of
+        (_, Reference r') | ref == r' -> do
+            e <- ref2C r'
+            return $ text "UNUSED" <+> parens e <> semi
         (BTFunction {}, (Reference r')) -> do
             e <- ref2C r'
             return $ r <+> text "=" <+> e <> semi
--- a/tools/pas2c/PascalUnitSyntaxTree.hs	Sun Feb 16 16:56:53 2014 +0400
+++ b/tools/pas2c/PascalUnitSyntaxTree.hs	Sun Feb 16 22:06:55 2014 +0400
@@ -5,20 +5,20 @@
     | Unit Identifier Interface Implementation (Maybe Initialize) (Maybe Finalize)
     | System [TypeVarDeclaration]
     | Redo [TypeVarDeclaration]
-    deriving Show
+    deriving (Show, Eq)
 data Interface = Interface Uses TypesAndVars
-    deriving Show
+    deriving (Show, Eq)
 data Implementation = Implementation Uses TypesAndVars
-    deriving Show
+    deriving (Show, Eq)
 data Identifier = Identifier String BaseType
-    deriving Show
+    deriving (Show, Eq)
 data TypesAndVars = TypesAndVars [TypeVarDeclaration]
-    deriving Show
+    deriving (Show, Eq)
 data TypeVarDeclaration = TypeDeclaration Identifier TypeDecl
     | VarDeclaration Bool Bool ([Identifier], TypeDecl) (Maybe InitExpression)
     | FunctionDeclaration Identifier Bool Bool Bool TypeDecl [TypeVarDeclaration] (Maybe (TypesAndVars, Phrase))
     | OperatorDeclaration String Identifier Bool TypeDecl [TypeVarDeclaration] (Maybe (TypesAndVars, Phrase))
-    deriving Show
+    deriving (Show, Eq)
 data TypeDecl = SimpleType Identifier
     | RangeType Range
     | Sequence [Identifier]
@@ -32,17 +32,17 @@
     | DeriveType InitExpression
     | VoidType
     | VarParamType TypeDecl -- this is a hack
-    deriving Show
+    deriving (Show, Eq)
 data Range = Range Identifier
            | RangeFromTo InitExpression InitExpression
            | RangeInfinite
-    deriving Show
+    deriving (Show, Eq)
 data Initialize = Initialize String
-    deriving Show
+    deriving (Show, Eq)
 data Finalize = Finalize String
-    deriving Show
+    deriving (Show, Eq)
 data Uses = Uses [Identifier]
-    deriving Show
+    deriving (Show, Eq)
 data Phrase = ProcCall Reference [Expression]
         | IfThenElse Expression Phrase (Maybe Phrase)
         | WhileCycle Expression Phrase
@@ -54,7 +54,7 @@
         | Assignment Reference Expression
         | BuiltInFunctionCall [Expression] Reference
         | NOP
-    deriving Show
+    deriving (Show, Eq)
 data Expression = Expression String
     | BuiltInFunCall [Expression] Reference
     | PrefixOp String Expression
@@ -70,7 +70,7 @@
     | Reference Reference
     | SetExpression [Identifier]
     | Null
-    deriving Show
+    deriving (Show, Eq)
 data Reference = ArrayElement [Expression] Reference
     | FunCall [Expression] Reference
     | TypeCast Identifier Expression
@@ -79,7 +79,7 @@
     | RecordField Reference Reference
     | Address Reference
     | RefExpression Expression
-    deriving Show
+    deriving (Show, Eq)
 data InitExpression = InitBinOp String InitExpression InitExpression
     | InitPrefixOp String InitExpression
     | InitReference Identifier
@@ -96,7 +96,7 @@
     | InitNull
     | InitRange Range
     | InitTypeCast Identifier InitExpression
-    deriving Show
+    deriving (Show, Eq)
 
 data BaseType = BTUnknown
     | BTChar
@@ -115,4 +115,4 @@
     | BTVoid
     | BTUnit
     | BTVarParam BaseType
-    deriving Show
+    deriving (Show, Eq)