merge
authornemo
Fri, 02 Jul 2010 21:20:38 -0400
changeset 3614 5806f8f614b7
parent 3609 bc63ed514b70 (current diff)
parent 3613 cfd3c6536a09 (diff)
child 3615 b78d7959540a
merge
--- a/hedgewars/CCHandlers.inc	Fri Jul 02 21:19:22 2010 -0400
+++ b/hedgewars/CCHandlers.inc	Fri Jul 02 21:20:38 2010 -0400
@@ -695,11 +695,7 @@
     flags:= SDL_OPENGL;// or SDL_RESIZABLE;
 
     if cFullScreen then
-    begin
         flags:= flags or SDL_FULLSCREEN;
-        cScreenWidth:= cInitWidth;
-        cScreenHeight:= cInitHeight
-    end;
 
 {$IFDEF SDL_IMAGE_NEWER}
     WriteToConsole('Init SDL_image... ');
--- a/hedgewars/VGSHandlers.inc	Fri Jul 02 21:19:22 2010 -0400
+++ b/hedgewars/VGSHandlers.inc	Fri Jul 02 21:20:38 2010 -0400
@@ -18,6 +18,8 @@
 procedure doStepFlake(Gear: PVisualGear; Steps: Longword);
 var sign: float;
 begin
+if ((cReducedQuality and rqkillFlakes) <> 0) then exit;
+
 sign:= 1;
 with Gear^ do
     begin
--- a/hedgewars/hwengine.pas	Fri Jul 02 21:19:22 2010 -0400
+++ b/hedgewars/hwengine.pas	Fri Jul 02 21:20:38 2010 -0400
@@ -73,7 +73,7 @@
 var isTerminated: boolean = false;
     alsoShutdownFrontend: boolean = false;
 {$IFDEF HWLIBRARY}
-type arrayofpchar = array[0..8] of PChar;
+type arrayofpchar = array[0..9] of PChar;
 
 procedure initEverything(complete:boolean);
 procedure freeEverything(complete:boolean);
@@ -81,6 +81,7 @@
 implementation
 {$ELSE}
 procedure OnDestroy; forward;
+procedure initEverything(complete:boolean); forward;
 procedure freeEverything(complete:boolean); forward;
 {$ENDIF}
 
@@ -245,16 +246,16 @@
 {$ENDIF}
 var p: TPathType;
     s: shortstring;
+{$IFDEF DEBUGFILE}
+    i: LongInt;
+{$ENDIF}
 begin
 {$IFDEF HWLIBRARY}
-    initEverything(true);
-
     cBits:= 32;
     cFullScreen:= false;
     cVSyncInUse:= true;
     cTimerInterval:= 8;
     PathPrefix:= 'Data';
-    cReducedQuality:= rqBlurryLand;                //FIXME
     cShowFPS:= true;
     cInitVolume:= 100;
 
@@ -266,9 +267,23 @@
     cAltDamage:= gameArgs[5] = '1';
     val(gameArgs[6], cScreenHeight);
     val(gameArgs[7], cScreenWidth);
-    cInitHeight:= cScreenHeight;
-    cInitWidth:= cScreenWidth;
     recordFileName:= gameArgs[8];
+    
+    if (gameArgs[9] = '2') then
+        cReducedQuality:= rqLowRes or rqBlurryLand
+    else 
+        if (gameArgs[9] = '1') then
+            cReducedQuality:= rqBlurryLand
+        else
+            cReducedQuality:= rqNone;
+
+{$ENDIF}
+    initEverything(true);
+    WriteLnToConsole('Hedgewars ' + cVersionString + ' engine (network protocol: ' + inttostr(cNetProtoVersion) + ')');
+{$IFDEF DEBUGFILE}
+    AddFileLog('Prefix: "' + PathPrefix +'"');
+    for i:= 0 to ParamCount do
+        AddFileLog(inttostr(i) + ': ' + ParamStr(i));
 {$ENDIF}
 
     for p:= Succ(Low(TPathType)) to High(TPathType) do
@@ -335,7 +350,7 @@
 
     MainLoop();
     OnDestroy();
-{$IFDEF HWLIBRARY}freeEverything(true);{$ENDIF}
+    freeEverything(true);
     if alsoShutdownFrontend then halt;
 end;
 
@@ -366,7 +381,7 @@
         //uLandGraphics does not need initialization
         //uLandObjects does not need initialization
         //uLandTemplates does not need initialization
-        //uLandTexture does not need initialization
+        uLandTexture.initModule;
         //uLocale does not need initialization
         uRandom.initModule; 
         //uSHA is initialized internally
@@ -395,7 +410,7 @@
         uRandom.freeModule;         //stub
         //uLocale does not need to be freed
         //uLandTemplates does not need to be freed
-        //uLandTexture does not need to be freed
+        uLandTexture.freeModule;
         //uLandObjects does not need to be freed
         //uLandGraphics does not need to be freed
         uKeys.freeModule;           //stub
@@ -420,11 +435,11 @@
 end;
 
 /////////////////////////
-procedure GenLandPreview{$IFDEF IPHONEOS}(port: LongInt){$ENDIF}; {$IFDEF HWLIBRARY}cdecl; export;{$ENDIF}
+procedure GenLandPreview{$IFDEF HWLIBRARY}(port: LongInt); cdecl; export{$ENDIF};
 var Preview: TPreview;
 begin
-{$IFDEF IPHONEOS}
     initEverything(false);
+{$IFDEF HWLIBRARY}
     WriteLnToConsole('Preview connecting on port ' + inttostr(port));
     ipcPort:= port;
 {$ENDIF}
@@ -438,23 +453,10 @@
     SendIPCRaw(@MaxHedgehogs, sizeof(byte));
     WriteLnToConsole('Preview sent, disconnect');
     CloseIPC();
-{$IFDEF IPHONEOS}
     freeEverything(false);
-{$ENDIF}
 end;
 
 {$IFNDEF HWLIBRARY}
-////////////////////////////////
-(*procedure Resize(w, h: LongInt);
-begin
-    cScreenWidth:= w;
-    cScreenHeight:= h;
-    if cFullScreen then
-        ParseCommand('/fullscr 1', true)
-    else
-        ParseCommand('/fullscr 0', true);
-end;*)
-
 /////////////////////
 procedure DisplayUsage;
 var i: LongInt;
@@ -479,17 +481,11 @@
 
 ////////////////////
 procedure GetParams;
-{$IFDEF DEBUGFILE}
-var i: LongInt;
-{$ENDIF}
 begin
-
     case ParamCount of
         18: begin
             val(ParamStr(2), cScreenWidth);
             val(ParamStr(3), cScreenHeight);
-            cInitWidth:= cScreenWidth;
-            cInitHeight:= cScreenHeight;
             cBitsStr:= ParamStr(4);
             val(cBitsStr, cBits);
             val(ParamStr(5), ipcPort);
@@ -507,7 +503,7 @@
             isMusicEnabled:= ParamStr(17) = '1';
 
             if (ParamStr(18) = '1') then        //HACK
-                cReducedQuality:= $FFFFFFFF
+                cReducedQuality:= $FFFFFFFF xor rqLowRes
             else
                 val(ParamStr(18), cReducedQuality);
         end;
@@ -529,8 +525,6 @@
             begin
                 val(ParamStr(4), cScreenWidth);
                 val(ParamStr(5), cScreenHeight);
-                cInitWidth:= cScreenWidth;
-                cInitHeight:= cScreenHeight;
                 cBitsStr:= ParamStr(6);
                 val(cBitsStr, cBits);
             end
@@ -562,8 +556,6 @@
             begin
                 val(ParamStr(4), cScreenWidth);
                 val(ParamStr(5), cScreenHeight);
-                cInitWidth:= cScreenWidth;
-                cInitHeight:= cScreenHeight;
                 cBitsStr:= ParamStr(6);
                 val(cBitsStr, cBits);
                 val(ParamStr(7), cInitVolume);
@@ -581,8 +573,6 @@
             begin
                 val(ParamStr(4), cScreenWidth);
                 val(ParamStr(5), cScreenHeight);
-                cInitWidth:= cScreenWidth;
-                cInitHeight:= cScreenHeight;
                 cBitsStr:= ParamStr(6);
                 val(cBitsStr, cBits);
                 val(ParamStr(7), cInitVolume);
@@ -594,7 +584,7 @@
                 cShowFPS:= ParamStr(13) = '1';
                 val(ParamStr(14), cTimerInterval);
                 if (ParamStr(15) = '1') then        //HACK
-                    cReducedQuality:= $FFFFFFFF
+                    cReducedQuality:= $FFFFFFFF xor rqLowRes
                 else
                     val(ParamStr(15), cReducedQuality);
             end
@@ -602,28 +592,18 @@
         end;
         else GameType:= gmtSyntax;
     end;
-
-{$IFDEF DEBUGFILE}
-    AddFileLog('Prefix: "' + PathPrefix +'"');
-    for i:= 0 to ParamCount do
-        AddFileLog(inttostr(i) + ': ' + ParamStr(i));
-{$ENDIF}
 end;
 
 ////////////////////////////////////////////////////////////////////////////////
 /////////////////////////////// m a i n ////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////////
 begin
-    initEverything(true);
-    WriteLnToConsole('Hedgewars ' + cVersionString + ' engine (network protocol: ' + inttostr(cNetProtoVersion) + ')');
-    
     GetParams();
 
     if GameType = gmtLandPreview then GenLandPreview()
     else if GameType = gmtSyntax then DisplayUsage()
     else Game();
     
-    freeEverything(true);
     if GameType = gmtSyntax then
         ExitCode:= 1
     else
--- a/hedgewars/options.inc	Fri Jul 02 21:19:22 2010 -0400
+++ b/hedgewars/options.inc	Fri Jul 02 21:20:38 2010 -0400
@@ -33,7 +33,6 @@
   {$DEFINE SDL_IMAGE_NEWER}
   {$DEFINE HWLIBRARY}
   {$DEFINE GLunit:=gles11}
-  {$DEFINE DOWNSCALE}
 {$ENDIF}
 
 {$IFNDEF DARWIN}
--- a/hedgewars/uConsts.pas	Fri Jul 02 21:19:22 2010 -0400
+++ b/hedgewars/uConsts.pas	Fri Jul 02 21:20:38 2010 -0400
@@ -183,7 +183,6 @@
     TScreenFade = (sfNone, sfInit, sfToBlack, sfFromBlack, sfToWhite, sfFromWhite);
 const sfMax = 1000;
 
-const
     // message constants
     errmsgCreateSurface   = 'Error creating SDL surface';
     errmsgTransparentSet  = 'Error setting transparent color';
@@ -225,6 +224,7 @@
     rqKillFlakes  = $00000040;  // no flakes
     rqSlowMenu    = $00000080;  // ammomenu appears with no animation
     rqPlainSplash = $00000100;  // no droplets
+    rqClampLess   = $00000200;  // don't clamp textures
 
     // image flags (for LoadImage())
     ifNone        = $00000000;  // nothing special
@@ -240,25 +240,6 @@
     tpHigh        = 0.75;
     tpHighest     = 1.00;
 
-    {*  REFERENCE
-      4096 -> $FFFFF000
-      2048 -> $FFFFF800
-      1024 -> $FFFFFC00
-       512 -> $FFFFFE00  *}
-
-{$IFDEF LOWRES}
-    // default for iphone pre 3gs
-    LAND_WIDTH  = 2048;
-    LAND_HEIGHT = 1024;
-    LAND_WIDTH_MASK  = $FFFFF800;
-    LAND_HEIGHT_MASK = $FFFFFC00;
-{$ELSE}
-    LAND_WIDTH  = 4096;
-    LAND_HEIGHT = 2048;
-    LAND_WIDTH_MASK  = $FFFFF000;
-    LAND_HEIGHT_MASK = $FFFFF800;
-{$ENDIF}
-
 // To allow these to layer, going to treat them as masks. The bottom byte is reserved for objects
 // TODO - set lfBasic for all solid land, ensure all uses of the flags can handle multiple flag bits
     lfBasic          = $8000;  // white
@@ -442,9 +423,35 @@
     cThemeCFGFilename = 'theme.cfg';
     
     FontBorder = 2;
-var PathPrefix: shortstring;
+    cPathz: array[TPathType] of shortstring = (
+        '',                              // ptNone
+        '',                              // ptData
+        'Graphics',                      // ptGraphics
+        'Themes',                        // ptThemes
+        'Themes/avematan',               // ptCurrTheme
+        'Teams',                         // ptTeams
+        'Maps',                          // ptMaps
+        '',                              // ptMapCurrent
+        'Demos',                         // ptDemos
+        'Sounds',                        // ptSounds
+        'Graphics/Graves',               // ptGraves
+        'Fonts',                         // ptFonts
+        'Forts',                         // ptForts
+        'Locale',                        // ptLocale
+        'Graphics/AmmoMenu',             // ptAmmoMenu
+        'Graphics/Hedgehog',             // ptHedgehog
+        'Sounds/voices',                 // ptVoices
+        'Graphics/Hats',                 // ptHats
+        'Graphics/Flags'                 // ptFlags
+    );
+    
+var PathPrefix: shortstring = './';
     Pathz: array[TPathType] of shortstring;
     CountTexz: array[1..Pred(AMMO_INFINITE)] of PTexture;
+    LAND_WIDTH  :longint;
+    LAND_HEIGHT :longint;
+    LAND_WIDTH_MASK  :longWord;
+    LAND_HEIGHT_MASK :longWord;
 
 const
     cTagsMasks : array[0..15] of byte = (7, 0, 0, 0, 15, 6, 4, 5, 0, 0, 0, 0, 0, 14, 12, 13);
@@ -2158,43 +2165,40 @@
         colorkey: 0;
         alpha : 255
     );
-            
-
+    
 procedure initModule;
 procedure freeModule;
 
 implementation
+uses uMisc;
 
 procedure initModule;
-var cPathz: array[TPathType] of shortstring = (
-        '',                              // ptNone
-        '',                              // ptData
-        'Graphics',                      // ptGraphics
-        'Themes',                        // ptThemes
-        'Themes/avematan',               // ptCurrTheme
-        'Teams',                         // ptTeams
-        'Maps',                          // ptMaps
-        '',                              // ptMapCurrent
-        'Demos',                         // ptDemos
-        'Sounds',                        // ptSounds
-        'Graphics/Graves',               // ptGraves
-        'Fonts',                         // ptFonts
-        'Forts',                         // ptForts
-        'Locale',                        // ptLocale
-        'Graphics/AmmoMenu',             // ptAmmoMenu
-        'Graphics/Hedgehog',             // ptHedgehog
-        'Sounds/voices',                 // ptVoices
-        'Graphics/Hats',                 // ptHats
-        'Graphics/Flags'                 // ptFlags
-    );
 begin
-    PathPrefix := './';
     Pathz:= cPathz;
+        {*  REFERENCE
+      4096 -> $FFFFF000
+      2048 -> $FFFFF800
+      1024 -> $FFFFFC00
+       512 -> $FFFFFE00  *}
+    if (cReducedQuality and rqLowRes) <> 0 then
+    begin
+        LAND_WIDTH:= 2048;
+        LAND_HEIGHT:= 1024;
+        LAND_WIDTH_MASK:= $FFFFF800;
+        LAND_HEIGHT_MASK:= $FFFFFC00;
+    end
+    else
+    begin
+        LAND_WIDTH:= 4096;
+        LAND_HEIGHT:= 2048;
+        LAND_WIDTH_MASK:= $FFFFF000;
+        LAND_HEIGHT_MASK:= $FFFFF800
+    end;
 end;
 
 procedure freeModule;
 begin
-
+    PathPrefix := './';
 end;
 
 end.
--- a/hedgewars/uIO.pas	Fri Jul 02 21:19:22 2010 -0400
+++ b/hedgewars/uIO.pas	Fri Jul 02 21:20:38 2010 -0400
@@ -22,7 +22,7 @@
 interface
 uses SDLh;
 
-var ipcPort: Word;
+var ipcPort: Word = 0;
     hiTicks: Word;
 
 procedure initModule;
@@ -361,11 +361,11 @@
 
     hiTicks:= 0;
     SendEmptyPacketTicks:= 0;
-    ipcPort:= 0;
 end;
 
 procedure freeModule;
 begin
+    ipcPort:= 0;
 
 end;
 
--- a/hedgewars/uLand.pas	Fri Jul 02 21:19:22 2010 -0400
+++ b/hedgewars/uLand.pas	Fri Jul 02 21:20:38 2010 -0400
@@ -23,15 +23,10 @@
 uses SDLh, uLandTemplates, uFloat, uConsts, GLunit;
 
 type
-{$IFDEF DOWNSCALE}
-    TLandArray = packed array[0 .. LAND_HEIGHT div 2 - 1, 0 .. LAND_WIDTH div 2 - 1] of LongWord;
-{$ELSE}
-    TLandArray = packed array[0 .. LAND_HEIGHT - 1, 0 .. LAND_WIDTH - 1] of LongWord;
-{$ENDIF}
- 
-    TCollisionArray = packed array[0 .. LAND_HEIGHT - 1, 0 .. LAND_WIDTH - 1] of Word;
+    TLandArray = packed array of array of LongWord; 
+    TCollisionArray = packed array of array of Word;
     TPreview  = packed array[0..127, 0..31] of byte;
-    TDirtyTag = packed array[0 .. LAND_HEIGHT div 32 - 1, 0 .. LAND_WIDTH div 32 - 1] of byte;
+    TDirtyTag = packed array of array of byte;
 
 var Land: TCollisionArray;
     LandPixels: TLandArray;
@@ -607,27 +602,19 @@
 
 function SelectTemplate: LongInt;
 begin
-case cTemplateFilter of
-     0: begin
-     SelectTemplate:= getrandom(Succ(High(EdgeTemplates)));
-     end;
-     1: begin
-     SelectTemplate:= SmallTemplates[getrandom(Succ(High(SmallTemplates)))];
-     end;
-     2: begin
-     SelectTemplate:= MediumTemplates[getrandom(Succ(High(MediumTemplates)))];
-     end;
-     3: begin
-     SelectTemplate:= LargeTemplates[getrandom(Succ(High(LargeTemplates)))];
-     end;
-     4: begin
-     SelectTemplate:= CavernTemplates[getrandom(Succ(High(CavernTemplates)))];
-     end;
-     5: begin
-     SelectTemplate:= WackyTemplates[getrandom(Succ(High(WackyTemplates)))];
-     end;
-end;
-WriteLnToConsole('Selected template #'+inttostr(SelectTemplate)+' using filter #'+inttostr(cTemplateFilter));
+    if (cReducedQuality and rqLowRes) <> 0 then
+        SelectTemplate:= SmallTemplates[getrandom(Succ(High(SmallTemplates)))]
+    else
+        case cTemplateFilter of
+        0: SelectTemplate:= getrandom(Succ(High(EdgeTemplates)));
+        1: SelectTemplate:= SmallTemplates[getrandom(Succ(High(SmallTemplates)))];
+        2: SelectTemplate:= MediumTemplates[getrandom(Succ(High(MediumTemplates)))];
+        3: SelectTemplate:= LargeTemplates[getrandom(Succ(High(LargeTemplates)))];
+        4: SelectTemplate:= CavernTemplates[getrandom(Succ(High(CavernTemplates)))];
+        5: SelectTemplate:= WackyTemplates[getrandom(Succ(High(WackyTemplates)))];
+    end;
+
+    WriteLnToConsole('Selected template #'+inttostr(SelectTemplate)+' using filter #'+inttostr(cTemplateFilter));
 end;
 
 procedure LandSurface2LandPixels(Surface: PSDL_Surface);
@@ -1344,12 +1331,21 @@
 begin
     LandBackSurface:= nil;
     digest:= '';
-    FillChar(LandPixels, sizeof(TLandArray), 0);
+
+    if (cReducedQuality and rqBlurryLand) = 0 then
+        SetLength(LandPixels, LAND_HEIGHT, LAND_WIDTH)
+    else
+        SetLength(LandPixels, LAND_HEIGHT div 2, LAND_WIDTH div 2);
+
+    SetLength(Land, LAND_HEIGHT, LAND_WIDTH);
+    SetLength(LandDirty, (LAND_HEIGHT div 32), (LAND_WIDTH div 32));
 end;
 
 procedure freeModule;
 begin
-
+    Land:= nil;
+    LandPixels:= nil;
+    LandDirty:= nil;
 end;
 
 end.
--- a/hedgewars/uLandTexture.pas	Fri Jul 02 21:19:22 2010 -0400
+++ b/hedgewars/uLandTexture.pas	Fri Jul 02 21:20:38 2010 -0400
@@ -22,6 +22,8 @@
 interface
 uses SDLh;
 
+procedure initModule;
+procedure freeModule;
 procedure UpdateLandTexture(X, Width, Y, Height: LongInt);
 procedure DrawLand(dX, dY: LongInt);
 procedure FreeLand;
@@ -31,23 +33,15 @@
 
 
 const TEXSIZE = 256;
-{$IFDEF DOWNSCALE}
-    LANDTEXARW = (LAND_WIDTH div TEXSIZE) div 2;
-    LANDTEXARH = (LAND_HEIGHT div TEXSIZE) div 2;
-{$ELSE}
-    LANDTEXARW = LAND_WIDTH div TEXSIZE;
-    LANDTEXARH = LAND_HEIGHT div TEXSIZE;
-{$ENDIF}
 
-var
-    LandTextures: array[0..LANDTEXARW - 1, 0..LANDTEXARH - 1] of
-            record
+type TLandRecord = record
             shouldUpdate: boolean;
             tex: PTexture;
             end;
-
+var LandTextures: array of array of TLandRecord;
     tmpPixels: array [0..TEXSIZE - 1, 0..TEXSIZE - 1] of LongWord;
-
+LANDTEXARW: LongWord;
+    LANDTEXARH: LongWord;
 function Pixels(x, y: Longword): Pointer;
 var ty: Longword;
 begin
@@ -135,10 +129,29 @@
                 FreeTexture(tex);
                 tex:= nil;
             end;
-
     if LandBackSurface <> nil then
         SDL_FreeSurface(LandBackSurface);
     LandBackSurface:= nil;
 end;
 
+procedure initModule;
+begin
+    if (cReducedQuality and rqBlurryLand) = 0 then
+    begin
+        LANDTEXARW:= LAND_WIDTH div TEXSIZE;
+        LANDTEXARH:= LAND_HEIGHT div TEXSIZE;
+    end
+    else
+    begin
+        LANDTEXARW:= (LAND_WIDTH div TEXSIZE) div 2;
+        LANDTEXARH:= (LAND_HEIGHT div TEXSIZE) div 2;
+    end;
+    
+    SetLength(LandTextures, LANDTEXARW, LANDTEXARH);
+end;
+    
+procedure freeModule;
+begin
+    LandTextures:= nil;
+end;
 end.
--- a/hedgewars/uMisc.pas	Fri Jul 02 21:19:22 2010 -0400
+++ b/hedgewars/uMisc.pas	Fri Jul 02 21:20:38 2010 -0400
@@ -29,8 +29,7 @@
     isTerminated    : boolean;
     isInLag         : boolean;
     isPaused        : boolean;
-    isSoundEnabled  : boolean;
-    isMusicEnabled  : boolean;
+
     isSEBackup      : boolean;
     isInMultiShoot  : boolean;
     isSpeed         : boolean;
@@ -38,9 +37,9 @@
 
     fastUntilLag    : boolean;
 
-    GameState   : TGameState;
-    GameType    : TGameType;
-    GameFlags   : Longword;
+    GameState       : TGameState;
+    GameType        : TGameType;
+    GameFlags       : Longword;
     TrainingFlags   : Longword;
     TurnTimeLeft    : Longword;
     cSuddenDTurns   : LongInt;
@@ -55,20 +54,13 @@
     cMaxAIThinkTime  : Longword;
 
     cCloudsNumber    : LongInt;
-    cScreenWidth     : LongInt;
-    cScreenHeight    : LongInt;
-    cInitWidth       : LongInt;
-    cInitHeight      : LongInt;
-    cVSyncInUse      : boolean;
-    cBits            : LongInt;
-    cBitsStr         : string[2];
+
     cTagsMask        : byte;
     zoom             : GLfloat;
     ZoomValue        : GLfloat;
 
     cWaterLine       : LongInt;
     cGearScrEdgesDist: LongInt;
-    cAltDamage       : boolean;
 
     GameTicks   : LongWord;
     TrainingTimeInc : Longword;
@@ -79,20 +71,35 @@
     TimeTrialStartTime: Longword;
     TimeTrialStopTime : Longword;
     
-    recordFileName  : shortstring;
-    cShowFPS    : boolean;
-    cCaseFactor : Longword;
+    // init flags
+    cScreenWidth    : LongInt = 1024;
+    cScreenHeight   : LongInt = 768;
+    cBits           : LongInt = 32;
+    cBitsStr        : string[2] = '32';
+    //ipcPort is in uIO
+    cFullScreen     : boolean = false;
+    isSoundEnabled  : boolean = true;
+    isMusicEnabled  : boolean = false;
+    cVSyncInUse     : boolean = true;    
+    cWeaponTooltips : boolean = true;
+    cLocaleFName    : shortstring = 'en.txt';
+    cInitVolume     : LongInt = 50;
+    cTimerInterval  : LongInt = 8;
+    //pathPrefix is in uConsts
+    cShowFPS        : boolean = false;
+    cAltDamage      : boolean = true;
+    cReducedQuality : LongInt = rqNone;
+
+    recordFileName  : shortstring = '';
+    
+    cCaseFactor     : Longword;
     cLandAdditions  : Longword;
-    cExplosives : Longword;
-    cFullScreen : boolean;
-    cReducedQuality : LongInt;
-    cLocaleFName    : shortstring;
-    cSeed       : shortstring;
-    cInitVolume : LongInt;
+    cExplosives     : Longword;
+
+    cSeed           : shortstring;
     cVolumeDelta    : LongInt;
-    cTimerInterval  : Longword;
-    cHasFocus   : boolean;
-    cInactDelay : Longword;
+    cHasFocus       : boolean;
+    cInactDelay     : Longword;
 
     bBetweenTurns   : boolean;
     cHealthDecrease : LongWord;
@@ -101,48 +108,47 @@
     ShowCrosshair   : boolean;
     CursorMovementX : LongInt;
     CursorMovementY : LongInt;
-    cDrownSpeed : hwFloat;
-    cDrownSpeedf : float;
+    cDrownSpeed     : hwFloat;
+    cDrownSpeedf    : float;
     cMaxWindSpeed   : hwFloat;
-    cWindSpeed  : hwFloat;
-    cWindSpeedf  : float;
-    cGravity    : hwFloat;
-    cGravityf    : float;
+    cWindSpeed      : hwFloat;
+    cWindSpeedf     : float;
+    cGravity        : hwFloat;
+    cGravityf       : float;
     cDamageModifier : hwFloat;
     cLaserSighting  : boolean;
-    cVampiric   : boolean;
-    cArtillery  : boolean;
+    cVampiric       : boolean;
+    cArtillery      : boolean;
     WeaponTooltipTex : PTexture;
-    cWeaponTooltips: boolean;
 
     flagMakeCapture : boolean;
 
     InitStepsFlags  : Longword;
-    RealTicks   : Longword;
-    AttackBar   : LongInt;
+    RealTicks       : Longword;
+    AttackBar       : LongInt;
 
     WaterColorArray : array[0..3] of HwColor4f;
 
-    CursorPoint : TPoint;
-    TargetPoint : TPoint;
+    CursorPoint     : TPoint;
+    TargetPoint     : TPoint;
 
-    TextureList : PTexture;
+    TextureList     : PTexture;
 
-    ScreenFade : TScreenFade;
+    ScreenFade      : TScreenFade;
     ScreenFadeValue : LongInt;
     ScreenFadeSpeed : LongInt;
 
 {$IFDEF SDL13}
-    SDLwindow: PSDL_Window;
+    SDLwindow       : PSDL_Window;
 {$ENDIF}
 
 procedure initModule;
 procedure freeModule;
 procedure SplitBySpace(var a, b: shortstring);
 procedure SplitByChar(var a, b: ansistring; c: char);
-function EnumToStr(const en : TGearType) : shortstring; overload;
-function EnumToStr(const en : TSound) : shortstring; overload;
-function EnumToStr(const en : TAmmoType) : shortstring; overload;
+function  EnumToStr(const en : TGearType) : shortstring; overload;
+function  EnumToStr(const en : TSound) : shortstring; overload;
+function  EnumToStr(const en : TAmmoType) : shortstring; overload;
 procedure movecursor(dx, dy: LongInt);
 function  hwSign(r: hwFloat): LongInt;
 function  Min(a, b: LongInt): LongInt;
@@ -291,8 +297,7 @@
 
 procedure SetTextureParameters(enableClamp: Boolean);
 begin
-    //if enableClamp and not cReducedQuality then
-    if enableClamp and ((cReducedQuality and rqNoBackground) = 0) then
+    if enableClamp and ((cReducedQuality and rqClampLess) = 0) then
     begin
         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)
@@ -718,32 +723,25 @@
     cTemplateFilter     := 0;
     cMapGen             := 0;//MAPGEN_REGULAR
     cMazeSize           := 0;
-
     cHedgehogTurnTime   := 45000;
     cMinesTime          := 3000;
     cMaxAIThinkTime     := 9000;
+    cCloudsNumber       := 9;
 
-    cCloudsNumber       := 9;
-    cScreenWidth        := 1024;
-    cScreenHeight       := 768;
-    cInitWidth      := cScreenWidth;
-    cInitHeight     := cScreenHeight;
-    cBits           := 32;
     cTagsMask       := 0;
     KBnum           := 0;
     InitStepsFlags  := 0;
     RealTicks       := 0;
     AttackBar       := 0; // 0 - none, 1 - just bar at the right-down corner, 2 - like in WWP
-    
-    // tgametype and glfloat and string
+    cCaseFactor     := 5;  {0..9}
+    cLandAdditions  := 4;
+    cExplosives     := 2;
+        
     GameState       := Low(TGameState);
     GameType        := gmtLocal;
     zoom            := 2.0;
     ZoomValue       := 2.0;
-    cBitsStr        := '32';
     WeaponTooltipTex:= nil;
-
-    // booleans
     cLaserSighting  := false;
     cVampiric       := false;
     cArtillery      := false;
@@ -754,31 +752,15 @@
     isTerminated    := false;
     isInLag         := false;
     isPaused        := false;
-    isMusicEnabled  := false;
     isInMultiShoot  := false;
     isSpeed         := false;
     fastUntilLag    := false;
     isFirstFrame    := true;
-    cVSyncInUse     := true;    
-    isSoundEnabled  := true;
     isSEBackup      := true;
-    
-    // init flags
-    recordFileName  := '';
-    cShowFPS        := false;
-    cCaseFactor     := 5;  {0..9}
-    cLandAdditions  := 4;
-    cExplosives     := 2;
-    cFullScreen     := false;
-    cReducedQuality := 0;
-    cLocaleFName    := 'en.txt';
     cSeed           := '';
-    cInitVolume     := 50;
     cVolumeDelta    := 0;
-    cTimerInterval  := 8;
     cHasFocus       := true;
     cInactDelay     := 1250;
-    cAltDamage      := true;
 
     ScreenFade      := sfNone;
     
--- a/hedgewars/uStore.pas	Fri Jul 02 21:19:22 2010 -0400
+++ b/hedgewars/uStore.pas	Fri Jul 02 21:20:38 2010 -0400
@@ -424,7 +424,7 @@
                 else
                     begin
                     Texture:= Surface2Tex(tmpsurf, false);
-                    if (ii = sprWater) and ((cReducedQuality and rq2DWater) = 0) then // HACK: We should include some sprite attribute to define the texture wrap directions
+                    if (ii = sprWater) and ((cReducedQuality and (rq2DWater or rqClampLess)) = 0) then // HACK: We should include some sprite attribute to define the texture wrap directions
                     begin
                         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
                     end;
--- a/hedgewars/uVisualGears.pas	Fri Jul 02 21:19:22 2010 -0400
+++ b/hedgewars/uVisualGears.pas	Fri Jul 02 21:20:38 2010 -0400
@@ -376,10 +376,11 @@
         begin
         Tint(Gear^.Tint);
         case Gear^.Kind of
-            vgtFlake: if vobVelocity = 0 then
-                        DrawSprite(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
-                    else
-                        DrawRotatedF(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle);
+            vgtFlake: if ((cReducedQuality and rqkillFlakes) <> 0) then
+                        if vobVelocity = 0 then
+                            DrawSprite(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame)
+                        else
+                            DrawRotatedF(sprFlake, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame, 1, Gear^.Angle);
             vgtCloud: DrawSprite(sprCloud, round(Gear^.X) + WorldDx, round(Gear^.Y) + WorldDy + SkyOffset, Gear^.Frame);
             end;
         Gear:= Gear^.NextGear
--- a/hedgewars/uWorld.pas	Fri Jul 02 21:19:22 2010 -0400
+++ b/hedgewars/uWorld.pas	Fri Jul 02 21:20:38 2010 -0400
@@ -553,21 +553,20 @@
             zoom:= zoom + 0.002 * Lag;
             if ZoomValue < zoom then
                 zoom:= ZoomValue
+            end
         end
-    end
-else
-    ZoomValue:= zoom;
+    else
+        ZoomValue:= zoom;
 
-// Sky
-glClear(GL_COLOR_BUFFER_BIT);
-//glPushMatrix;
-//glScalef(1.0, 1.0, 1.0);
+    // Sky
+    glClear(GL_COLOR_BUFFER_BIT);
+    //glPushMatrix;
+    //glScalef(1.0, 1.0, 1.0);
 
     if not isPaused then
         MoveCamera;
 
-{if not cReducedQuality then}
-    if (cReducedQuality and (rqNoBackground or rqKillFlakes or rq2DWater)) = 0 then
+    if (cReducedQuality and rqNoBackground) = 0 then
     begin
         // Offsets relative to camera - spare them to wimpier cpus, no bg or flakes for them anyway
         ScreenBottom:= (WorldDy - trunc(cScreenHeight/cScaleFactor) - (cScreenHeight div 2) + cWaterLine);
@@ -580,9 +579,12 @@
         // background
         DrawRepeated(sprSky, sprSkyL, sprSkyR, (WorldDx + LAND_WIDTH div 2) * 3 div 8, SkyOffset);
         DrawRepeated(sprHorizont, sprHorizontL, sprHorizontR, (WorldDx + LAND_WIDTH div 2) * 3 div 5, HorizontOffset);
+    end;
 
-        DrawVisualGears(0);
-        
+    DrawVisualGears(0);
+    
+    if (cReducedQuality and rq2DWater) = 0 then
+    begin
         // Waves
         DrawWater(255, SkyOffset); 
         DrawWaves( 1,  0 - WorldDx div 32, - cWaveHeight + offsetY div 35, 64);
@@ -593,13 +595,13 @@
     else
         DrawWaves(-1, 100, - (cWaveHeight + (cWaveHeight shr 1)), 0);
 
-DrawLand(WorldDx, WorldDy);
+    DrawLand(WorldDx, WorldDy);
 
-DrawWater(255, 0);
+    DrawWater(255, 0);
 
 // Attack bar
-if CurrentTeam <> nil then
-    case AttackBar of
+    if CurrentTeam <> nil then
+        case AttackBar of
 (*        1: begin
         r:= StuffPoz[sPowerBar];
         {$WARNINGS OFF}
@@ -619,16 +621,16 @@
                 end
         end;
 
-DrawVisualGears(1);
+    DrawVisualGears(1);
 
-DrawGears;
+    DrawGears;
 
-DrawVisualGears(2);
+    DrawVisualGears(2);
 
-DrawWater(cWaterOpacity, 0);
+    DrawWater(cWaterOpacity, 0);
 
-// Waves
-DrawWaves( 1, 25 - WorldDx div 9, - cWaveHeight, 12);
+    // Waves
+    DrawWaves( 1, 25 - WorldDx div 9, - cWaveHeight, 12);
 
     if (cReducedQuality and rq2DWater) = 0 then
     begin
@@ -639,8 +641,8 @@
         DrawWater(cWaterOpacity, - offsetY div 10);
         DrawWaves( -1, 25 + WorldDx div 3, - cWaveHeight - offsetY div 10, 0);
     end
-else
-    DrawWaves(-1, 50, - (cWaveHeight shr 1), 0);
+    else
+        DrawWaves(-1, 50, - (cWaveHeight shr 1), 0);
 
 
 {$WARNINGS OFF}
--- a/project_files/HedgewarsMobile/Classes/GameSetup.m	Fri Jul 02 21:19:22 2010 -0400
+++ b/project_files/HedgewarsMobile/Classes/GameSetup.m	Fri Jul 02 21:20:38 2010 -0400
@@ -364,27 +364,28 @@
     CGRect screenBounds = [[UIScreen mainScreen] bounds];
     NSString *wSize = [[NSString alloc] initWithFormat:@"%d", (int) screenBounds.size.width];
     NSString *hSize = [[NSString alloc] initWithFormat:@"%d", (int) screenBounds.size.height];
-    const char **gameArgs = (const char**) malloc(sizeof(char *) * 9);
+    const char **gameArgs = (const char**) malloc(sizeof(char *) * 10);
 
-    /*
     size_t size;
     // Set 'oldp' parameter to NULL to get the size of the data returned so we can allocate appropriate amount of space
     sysctlbyname("hw.machine", NULL, &size, NULL, 0); 
-    char *name = malloc(size);
+    char *name = (char *)malloc(sizeof(char) * size);
     // Get the platform name
     sysctlbyname("hw.machine", name, &size, NULL, 0);
-    NSString *machine = [[NSString alloc] initWithUTF8String:name];
+    NSString *modelId = [[NSString alloc] initWithUTF8String:name];
     free(name);
-    
-    const char **gameArgs = (const char**) malloc(sizeof(char*) * 9);
 
-    // if the machine is less than iphone 3gs or less than ipod touch 3g use reduced graphics (land array)
-    if ([machine hasPrefix:@"iPhone1"] || ([machine hasPrefix:@"iPod"] && ([machine hasSuffix:@"1,1"] || [machine hasSuffix:@"2,1"])))
-        gameArgs[8] = "1";
-    else
-        gameArgs[8] = "0";
-    [machine release];
-    */
+    if ([modelId hasPrefix:@"iPhone1"] ||                                   // = iPhone or iPhone 3G
+        [modelId hasPrefix:@"iPod1,1"] || [modelId hasPrefix:@"iPod2,1"])   // = iPod Touch or iPod Touch 2G
+        gameArgs[9] = "2";                          // rqLowRes & rqBlurryLand
+    else if ([modelId hasPrefix:@"iPhone2"] ||                              // = iPhone 3GS
+             [modelId hasPrefix:@"iPad1"] ||                                // = iPad
+             [modelId hasPrefix:@"iPod3"])                                  // = iPod Touch 3G
+            gameArgs[9] = "1";                      // rqBlurryLand
+        else                                                                // = everything else
+            gameArgs[9] = "0";                      // full quality
+    [modelId release];
+    
     
     // prevents using an empty nickname
     NSString *username;
--- a/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj	Fri Jul 02 21:19:22 2010 -0400
+++ b/project_files/HedgewarsMobile/Hedgewars.xcodeproj/project.pbxproj	Fri Jul 02 21:20:38 2010 -0400
@@ -246,6 +246,7 @@
 		6132878211D95185006BA39D /* joyButton_forwardjump.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = joyButton_forwardjump.png; path = Resources/joyButton_forwardjump.png; sourceTree = "<group>"; };
 		6132878411D9518B006BA39D /* joyButton_attack.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = joyButton_attack.png; path = Resources/joyButton_attack.png; sourceTree = "<group>"; };
 		61370652117B1D50004EE44A /* Entitlements-Distribution.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Entitlements-Distribution.plist"; sourceTree = "<group>"; };
+		614E333D11DE9A93009DBA4E /* VGSHandlers.inc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.pascal; name = VGSHandlers.inc; path = ../../hedgewars/VGSHandlers.inc; sourceTree = SOURCE_ROOT; };
 		6151347D116C2803001F16D1 /* Icon-iPad.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-iPad.png"; path = "Resources/Icon-iPad.png"; sourceTree = "<group>"; };
 		6163EE7C11CC2600001C0453 /* SingleWeaponViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SingleWeaponViewController.h; sourceTree = "<group>"; };
 		6163EE7D11CC2600001C0453 /* SingleWeaponViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SingleWeaponViewController.m; sourceTree = "<group>"; };
@@ -680,6 +681,7 @@
 				617987E1114AA34C00BA94A9 /* CCHandlers.inc */,
 				617987E4114AA34C00BA94A9 /* GSHandlers.inc */,
 				617987E5114AA34C00BA94A9 /* HHHandlers.inc */,
+				614E333D11DE9A93009DBA4E /* VGSHandlers.inc */,
 				617987F0114AA34C00BA94A9 /* SinTable.inc */,
 			);
 			name = inc;
@@ -1240,6 +1242,7 @@
 				SDKROOT = iphoneos3.2;
 				TARGETED_DEVICE_FAMILY = "1,2";
 				VALIDATE_PRODUCT = NO;
+				VALID_ARCHS = "armv7 armv6";
 			};
 			name = Distribution;
 		};
@@ -1354,6 +1357,7 @@
 				SDKROOT = iphoneos3.2;
 				TARGETED_DEVICE_FAMILY = "1,2";
 				VALIDATE_PRODUCT = NO;
+				VALID_ARCHS = "armv7 armv6";
 			};
 			name = Valgrind;
 		};
@@ -1553,6 +1557,7 @@
 				SDKROOT = iphoneos3.2;
 				TARGETED_DEVICE_FAMILY = "1,2";
 				VALIDATE_PRODUCT = NO;
+				VALID_ARCHS = "armv7 armv6";
 			};
 			name = Debug;
 		};
@@ -1594,6 +1599,7 @@
 				SDKROOT = iphoneos3.2;
 				TARGETED_DEVICE_FAMILY = "1,2";
 				VALIDATE_PRODUCT = NO;
+				VALID_ARCHS = "armv7 armv6";
 			};
 			name = Release;
 		};