# HG changeset patch # User koda # Date 1258752125 0 # Node ID 079ef82eac7561fc8f6392af3b46912b2ffe28f5 # Parent be70fd3458c04c6f93410ebed7d4630aa5427640 revamped file access and debug display diff -r be70fd3458c0 -r 079ef82eac75 hedgewars/SDLh.pas --- a/hedgewars/SDLh.pas Fri Nov 20 14:56:43 2009 +0000 +++ b/hedgewars/SDLh.pas Fri Nov 20 21:22:05 2009 +0000 @@ -16,16 +16,17 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA *) +{$INCLUDE "options.inc"} + unit SDLh; interface -{$INCLUDE "options.inc"} {$IFDEF LINUX} -{$DEFINE UNIX} + {$DEFINE UNIX} {$ENDIF} {$IFDEF FREEBSD} -{$DEFINE UNIX} + {$DEFINE UNIX} {$ENDIF} {$IFDEF UNIX} @@ -42,18 +43,19 @@ {$ENDIF} {$IFDEF DARWIN} - {$PASCALMAINNAME SDL_main} -{$IFNDEF IPHONEOS} - {$linkframework Cocoa} - {$linkframework SDL} - {$linkframework SDL_net} - {$linkframework SDL_image} - {$linkframework SDL_ttf} - {$linkframework SDL_mixer} - {$linklib SDLmain} - {$linklib gcc} + {$PASCALMAINNAME SDL_main} + {$IFNDEF IPHONEOS} + {$linkframework Cocoa} + {$linkframework SDL} + {$linkframework SDL_net} + {$linkframework SDL_image} + {$linkframework SDL_ttf} + {$linkframework SDL_mixer} + {$linklib SDLmain} + {$linklib gcc} + {$ENDIF} {$ENDIF} -{$ENDIF} + (* SDL *) const @@ -482,7 +484,7 @@ {$ELSE} SDL_GL_SWAP_CONTROL {$ENDIF} -); + ); {$IFDEF SDL13} TSDL_ArrayByteOrder = ( // array component order, low byte -> high byte @@ -711,6 +713,11 @@ procedure SDLNet_FreeSocketSet(_set: PSDLNet_SocketSet); cdecl; external SDL_NetLibName; function SDLNet_AddSocket(_set: PSDLNet_SocketSet; sock: PTCPSocket): LongInt; cdecl; external SDL_NetLibName; function SDLNet_CheckSockets(_set: PSDLNet_SocketSet; timeout: LongInt): LongInt; cdecl; external SDL_NetLibName; + +{$IFDEF IPHONEOS} +function get_documents_path: PChar; cdecl; external 'hwutils'; +{$ENDIF} + {$ELSE}{$ENDIF} procedure SDLNet_Write16(value: Word; buf: pointer); diff -r be70fd3458c0 -r 079ef82eac75 hedgewars/getdocumentpath.m --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hedgewars/getdocumentpath.m Fri Nov 20 21:22:05 2009 +0000 @@ -0,0 +1,8 @@ +#import + +const char* get_documents_path() { + NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); + NSString *documentsDirectory = [paths objectAtIndex: 0]; + const char* path = [documentsDirectory UTF8String]; + return path; +} diff -r be70fd3458c0 -r 079ef82eac75 hedgewars/hwengine.pas --- a/hedgewars/hwengine.pas Fri Nov 20 14:56:43 2009 +0000 +++ b/hedgewars/hwengine.pas Fri Nov 20 21:22:05 2009 +0000 @@ -16,15 +16,10 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA *) -{$IFNDEF FPC} -{$ERROR Only Free Pascal supported!} -{$ENDIF} - {$INCLUDE "options.inc"} program hwengine; -uses - SDLh in 'SDLh.pas', +uses SDLh in 'SDLh.pas', {$IFDEF GLES11} gles11, {$ELSE} @@ -314,14 +309,14 @@ end; {$ENDIF} {$IFDEF IPHONEOS} - SDL_JOYAXISMOTION: begin +(* SDL_JOYAXISMOTION: begin {* axis 0 = left and right; axis 1 = up and down; axis 2 = back and forth; *} WriteLnToConsole('********************************************* accelerometer'); - tiltValue:= SDL_JoystickGetAxis(uKeys.theJoystick, 0); + tiltValue:= SDL_JoystickGetAxis(uKeys.theJoystick,≤ 0); if (CurrentTeam <> nil) then begin @@ -343,7 +338,7 @@ else if (tiltValue > -1500) and (tiltValue <= 1500) and (movedbybuttons = false) then uKeys.isWalking:= false; end; - end; + end;*) {$ELSE} SDL_MOUSEBUTTONDOWN: if event.button.button = SDL_BUTTON_WHEELDOWN then uKeys.wheelDown:= true; SDL_MOUSEBUTTONUP: if event.button.button = SDL_BUTTON_WHEELDUP then uKeys.wheelUp:= true; @@ -392,11 +387,6 @@ {$ENDIF} p: TPathType; begin -{$IFDEF DEBUGFILE} -AddFileLog('Prefix: "' + PathPrefix +'"'); -for i:= 0 to ParamCount do - AddFileLog(inttostr(i) + ': ' + ParamStr(i)); -{$ENDIF} case ParamCount of 17: begin @@ -425,25 +415,25 @@ {$IFDEF IPHONEOS} 0: begin PathPrefix:= 'hedgewars/Data'; - recordFileName:= 'hedgewars/save.hws'; - val('320', cScreenWidth); - val('480', cScreenHeight); - cInitWidth:= cScreenWidth; - cInitHeight:= cScreenHeight; - cBitsStr:= '32'; - val(cBitsStr, cBits); - val('100', cInitVolume); - isMusicEnabled:= false; - isSoundEnabled:= false; - cLocaleFName:= 'en.txt'; - cFullScreen:= true; //T or F is is the same here - cAltDamage:= false; - cShowFPS:= true; - val('8', cTimerInterval); - cReducedQuality:= false; + recordFileName:= 'hedgewars/save.hws'; + val('320', cScreenWidth); + val('480', cScreenHeight); + cInitWidth:= cScreenWidth; + cInitHeight:= cScreenHeight; + cBitsStr:= '32'; + val(cBitsStr, cBits); + val('100', cInitVolume); + isMusicEnabled:= false; + isSoundEnabled:= false; + cLocaleFName:= 'en.txt'; + cFullScreen:= true; //T or F is is the same here + cAltDamage:= false; + cShowFPS:= true; + val('8', cTimerInterval); + cReducedQuality:= false; for p:= Succ(Low(TPathType)) to High(TPathType) do - if p <> ptMapCurrent then Pathz[p]:= PathPrefix + '/' + Pathz[p] + if p <> ptMapCurrent then Pathz[p]:= PathPrefix + '/' + Pathz[p] end; {$ENDIF} 3: begin @@ -457,7 +447,7 @@ for p:= Succ(Low(TPathType)) to High(TPathType) do if p <> ptMapCurrent then Pathz[p]:= PathPrefix + '/' + Pathz[p] - end; + end; 6: begin PathPrefix:= ParamStr(1); recordFileName:= ParamStr(2); @@ -545,6 +535,15 @@ end; else DisplayUsage; end; + +{$IFDEF DEBUGFILE} +AddFileLog('Prefix: "' + PathPrefix +'"'); +for i:= 0 to ParamCount do + AddFileLog(inttostr(i) + ': ' + ParamStr(i)); +{$IFDEF IPHONEOS} +WriteLnToConsole('Saving debug file at: ' + get_documents_path()); +{$ENDIF} +{$ENDIF} end; ///////////////////////// diff -r be70fd3458c0 -r 079ef82eac75 hedgewars/options.inc --- a/hedgewars/options.inc Fri Nov 20 14:56:43 2009 +0000 +++ b/hedgewars/options.inc Fri Nov 20 21:22:05 2009 +0000 @@ -18,19 +18,22 @@ {$IFDEF FPC} {$J+} -{$ENDIF} - -{$DEFINE DEBUGFILE} - -{$IFDEF DEBUGFILE} - {$DEFINE DUMP} - {$DEFINE TRACEAIACTIONS} +{$ELSE} + {$ERROR Only Free Pascal supported!} {$ENDIF} {$IFDEF IPHONEOS} {$DEFINE SDL13} {$DEFINE GLES11} {$DEFINE TOUCHINPUT} + {$DEFINE LOWRES} +{$ENDIF} + +{$IFNDEF DARWIN} + {$DEFINE DEBUGFILE} + { $DEFINE DUMP} + { $DEFINE TRACEAIACTIONS} + { $DEFINE COUNTTICKS} {$ENDIF} {$IFDEF TOUCHINPUT} diff -r be70fd3458c0 -r 079ef82eac75 hedgewars/uAI.pas --- a/hedgewars/uAI.pas Fri Nov 20 14:56:43 2009 +0000 +++ b/hedgewars/uAI.pas Fri Nov 20 21:22:05 2009 +0000 @@ -16,10 +16,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA *) +{$INCLUDE "options.inc"} + unit uAI; interface uses uFloat; -{$INCLUDE "options.inc"} + procedure ProcessBot; procedure FreeActionsList; diff -r be70fd3458c0 -r 079ef82eac75 hedgewars/uAIActions.pas --- a/hedgewars/uAIActions.pas Fri Nov 20 14:56:43 2009 +0000 +++ b/hedgewars/uAIActions.pas Fri Nov 20 21:22:05 2009 +0000 @@ -16,10 +16,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA *) +{$INCLUDE "options.inc"} + unit uAIActions; interface uses uGears, uFloat; -{$INCLUDE "options.inc"} + const MAXACTIONS = 96; aia_none = 0; aia_Left = 1; diff -r be70fd3458c0 -r 079ef82eac75 hedgewars/uAIAmmoTests.pas --- a/hedgewars/uAIAmmoTests.pas Fri Nov 20 14:56:43 2009 +0000 +++ b/hedgewars/uAIAmmoTests.pas Fri Nov 20 21:22:05 2009 +0000 @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA *) +{$INCLUDE "options.inc"} + unit uAIAmmoTests; interface uses SDLh, uGears, uConsts, uFloat; diff -r be70fd3458c0 -r 079ef82eac75 hedgewars/uAmmos.pas --- a/hedgewars/uAmmos.pas Fri Nov 20 14:56:43 2009 +0000 +++ b/hedgewars/uAmmos.pas Fri Nov 20 21:22:05 2009 +0000 @@ -16,10 +16,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA *) +{$INCLUDE "options.inc"} + unit uAmmos; interface uses uConsts, uTeams; -{$INCLUDE "options.inc"} procedure AddAmmoStore(s: shortstring); procedure AssignStores; diff -r be70fd3458c0 -r 079ef82eac75 hedgewars/uChat.pas --- a/hedgewars/uChat.pas Fri Nov 20 14:56:43 2009 +0000 +++ b/hedgewars/uChat.pas Fri Nov 20 21:22:05 2009 +0000 @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA *) +{$INCLUDE "options.inc"} + unit uChat; interface diff -r be70fd3458c0 -r 079ef82eac75 hedgewars/uCollisions.pas --- a/hedgewars/uCollisions.pas Fri Nov 20 14:56:43 2009 +0000 +++ b/hedgewars/uCollisions.pas Fri Nov 20 21:22:05 2009 +0000 @@ -16,10 +16,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA *) +{$INCLUDE "options.inc"} + unit uCollisions; interface uses uGears, uFloat; -{$INCLUDE "options.inc"} + const cMaxGearArrayInd = 255; type PGearArray = ^TGearArray; diff -r be70fd3458c0 -r 079ef82eac75 hedgewars/uConsole.pas --- a/hedgewars/uConsole.pas Fri Nov 20 14:56:43 2009 +0000 +++ b/hedgewars/uConsole.pas Fri Nov 20 21:22:05 2009 +0000 @@ -16,10 +16,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA *) +{$INCLUDE "options.inc"} + unit uConsole; interface uses uFloat; -{$INCLUDE "options.inc"} + const isDeveloperMode: boolean = true; type TVariableType = (vtCommand, vtLongInt, vthwFloat, vtBoolean); TCommandHandler = procedure (var params: shortstring); diff -r be70fd3458c0 -r 079ef82eac75 hedgewars/uConsts.pas --- a/hedgewars/uConsts.pas Fri Nov 20 14:56:43 2009 +0000 +++ b/hedgewars/uConsts.pas Fri Nov 20 21:22:05 2009 +0000 @@ -186,32 +186,26 @@ 1024 -> $FFFFFC00 512 -> $FFFFFE00 *} -{$IFDEF IPHONEOS} - LAND_WIDTH = 2048; - LAND_HEIGHT = 1024; - LAND_WIDTH_MASK = $FFFFF800; - LAND_HEIGHT_MASK = $FFFFFC00; +{$IFDEF LOWRES} + // default for iphone pre 3gs + LAND_WIDTH = 2048; + LAND_HEIGHT = 1024; + LAND_WIDTH_MASK = $FFFFF800; + LAND_HEIGHT_MASK = $FFFFFC00; {$ELSE} -{$IFDEF LOWRES} - 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} + LAND_WIDTH = 4096; + LAND_HEIGHT = 2048; + LAND_WIDTH_MASK = $FFFFF000; + LAND_HEIGHT_MASK = $FFFFF800; {$ENDIF} - COLOR_LAND = $FFFF; // white - COLOR_INDESTRUCTIBLE = $88FF; // red + COLOR_LAND = $FFFF; // white + COLOR_INDESTRUCTIBLE = $88FF; // red - //some opengl headers do not have these macros - GL_BGR = $80E0; - GL_BGRA = $80E1; - GL_CLAMP_TO_EDGE = $812F; + // some opengl headers do not have these macros + GL_BGR = $80E0; + GL_BGRA = $80E1; + GL_CLAMP_TO_EDGE = $812F; cifRandomize = $00000001; @@ -246,6 +240,9 @@ cSendEmptyPacketTime = 1000; + // from uTriggers + trigTurns = $80000001; + // Training Flags tfNone = $00000000; tfTimeTrial = $00000001; @@ -341,18 +338,18 @@ htTransparent = $80; cTagsMasks : array[0..7] of byte = ( - htTeamName or htName or htHealth, - htName or htHealth, - htHealth, - htNone, - htTeamName or htName or htHealth or htTransparent, - htName or htHealth or htTransparent, - htHealth or htTransparent, - htNone - ); + htTeamName or htName or htHealth, + htName or htHealth, + htHealth, + htNone, + htTeamName or htName or htHealth or htTransparent, + htName or htHealth or htTransparent, + htHealth or htTransparent, + htNone + ); - cHHFileName = 'Hedgehog'; - cCHFileName = 'Crosshair'; + cHHFileName = 'Hedgehog'; + cCHFileName = 'Crosshair'; cThemeCFGFilename = 'theme.cfg'; Fontz: array[THWFont] of THHFont = ( @@ -635,7 +632,6 @@ Width: 64; Height: 64; imageWidth: 0; imageHeight: 0; saveSurf: false), // sprJetpack (FileName: 'Health'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; Width: 16; Height: 16; imageWidth: 0; imageHeight: 0; saveSurf: false), // sprHealth - (FileName: 'amMolotov'; Path: ptHedgehog; AltPath: ptNone; Texture: nil; Surface: nil; Width: 32; Height: 32; imageWidth: 0; imageHeight: 0; saveSurf: false), //sprHandMolotov (FileName: 'Molotov'; Path: ptGraphics; AltPath: ptNone; Texture: nil; Surface: nil; diff -r be70fd3458c0 -r 079ef82eac75 hedgewars/uFloat.pas --- a/hedgewars/uFloat.pas Fri Nov 20 14:56:43 2009 +0000 +++ b/hedgewars/uFloat.pas Fri Nov 20 21:22:05 2009 +0000 @@ -16,11 +16,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA *) +{$INCLUDE "options.inc"} + unit uFloat; interface -{$INCLUDE "options.inc"} - {$IFDEF FPC} {$IFDEF ENDIAN_LITTLE} type hwFloat = record diff -r be70fd3458c0 -r 079ef82eac75 hedgewars/uGame.pas --- a/hedgewars/uGame.pas Fri Nov 20 14:56:43 2009 +0000 +++ b/hedgewars/uGame.pas Fri Nov 20 21:22:05 2009 +0000 @@ -16,10 +16,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA *) +{$INCLUDE "options.inc"} + unit uGame; interface uses uFloat; -{$INCLUDE "options.inc"} procedure DoGameTick(Lag: LongInt); diff -r be70fd3458c0 -r 079ef82eac75 hedgewars/uIO.pas --- a/hedgewars/uIO.pas Fri Nov 20 14:56:43 2009 +0000 +++ b/hedgewars/uIO.pas Fri Nov 20 21:22:05 2009 +0000 @@ -16,10 +16,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA *) +{$INCLUDE "options.inc"} + unit uIO; interface uses SDLh; -{$INCLUDE "options.inc"} const ipcPort: Word = 0; @@ -173,9 +174,9 @@ buf: array[0..255] of byte; s: shortstring absolute buf; begin -{$IFDEF IPHONEOS} -filemode := 0; -{$ENDIF} + +// set RDNLY on file open +filemode:= 0; assign(f, fileName); reset(f, 1); diff -r be70fd3458c0 -r 079ef82eac75 hedgewars/uKeys.pas --- a/hedgewars/uKeys.pas Fri Nov 20 14:56:43 2009 +0000 +++ b/hedgewars/uKeys.pas Fri Nov 20 21:22:05 2009 +0000 @@ -16,10 +16,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA *) +{$INCLUDE "options.inc"} + unit uKeys; interface uses uConsts, SDLh; -{$INCLUDE "options.inc"} type TBinds = array[0..cKeyMaxIndex] of shortstring; type TKeyboardState = array[0..cKeyMaxIndex] of Byte; diff -r be70fd3458c0 -r 079ef82eac75 hedgewars/uLandGraphics.pas --- a/hedgewars/uLandGraphics.pas Fri Nov 20 14:56:43 2009 +0000 +++ b/hedgewars/uLandGraphics.pas Fri Nov 20 21:22:05 2009 +0000 @@ -16,10 +16,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA *) +{$INCLUDE "options.inc"} + unit uLandGraphics; interface uses uFloat, uConsts; -{$INCLUDE "options.inc"} type PRangeArray = ^TRangeArray; TRangeArray = array[0..31] of record diff -r be70fd3458c0 -r 079ef82eac75 hedgewars/uLandObjects.pas --- a/hedgewars/uLandObjects.pas Fri Nov 20 14:56:43 2009 +0000 +++ b/hedgewars/uLandObjects.pas Fri Nov 20 21:22:05 2009 +0000 @@ -16,10 +16,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA *) +{$INCLUDE "options.inc"} + unit uLandObjects; interface uses SDLh; -{$INCLUDE "options.inc"} procedure AddObjects(); procedure LoadThemeConfig; diff -r be70fd3458c0 -r 079ef82eac75 hedgewars/uLandTemplates.pas --- a/hedgewars/uLandTemplates.pas Fri Nov 20 14:56:43 2009 +0000 +++ b/hedgewars/uLandTemplates.pas Fri Nov 20 21:22:05 2009 +0000 @@ -16,10 +16,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA *) +{$INCLUDE "options.inc"} + unit uLandTemplates; interface uses SDLh; -{$INCLUDE "options.inc"} const NTPX = Low(TSDL_Rect.x); diff -r be70fd3458c0 -r 079ef82eac75 hedgewars/uLocale.pas --- a/hedgewars/uLocale.pas Fri Nov 20 14:56:43 2009 +0000 +++ b/hedgewars/uLocale.pas Fri Nov 20 21:22:05 2009 +0000 @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA *) +{$INCLUDE "options.inc"} + unit uLocale; interface type TAmmoStrId = (sidNothing, sidGrenade, sidClusterBomb, sidBazooka, sidUFO, sidShotgun, diff -r be70fd3458c0 -r 079ef82eac75 hedgewars/uMisc.pas --- a/hedgewars/uMisc.pas Fri Nov 20 14:56:43 2009 +0000 +++ b/hedgewars/uMisc.pas Fri Nov 20 21:22:05 2009 +0000 @@ -16,9 +16,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA *) +{$INCLUDE "options.inc"} + unit uMisc; interface -{$INCLUDE "options.inc"} + uses uConsts, SDLh, {$IFDEF GLES11} gles11, @@ -130,6 +132,8 @@ AttackBar: LongInt = 0; // 0 - none, 1 - just bar at the right-down corner, 2 - like in WWP +var i: LongInt; + type HwColor4f = record r, g, b, a: byte end; @@ -559,6 +563,7 @@ else doSurfaceConversion:= tmpsurf; end; + initialization cDrownSpeed.QWordValue:= 257698038;// 0.06 cMaxWindSpeed.QWordValue:= 2147484;// 0.0005 @@ -571,17 +576,25 @@ {$IFDEF DEBUGFILE} {$I-} -f:= stderr; -rewrite(f); -{$IFNDEF IPHONEOS} -if ParamCount <> 0 then - for i:= 0 to 7 do - begin - assign(f, ParamStr(1) + '/debug' + inttostr(i) + '.txt'); - rewrite(f); - if IOResult = 0 then break - end; +for i:= 0 to 7 do +begin + assign(f, +{$IFDEF IPHONEOS} + string(get_documents_path()) +{$ELSE} + ParamStr(1) {$ENDIF} + + '/debug' + inttostr(i) + '.txt'); + rewrite(f); + if IOResult = 5 then + begin + // prevent writing on a directory you do not have permissions on + // should be safe to assume the current directory is writable + assign(f, './debug' + inttostr(i) + '.txt'); + rewrite(f); + end; + if IOResult = 0 then break +end; {$I+} finalization diff -r be70fd3458c0 -r 079ef82eac75 hedgewars/uRandom.pas --- a/hedgewars/uRandom.pas Fri Nov 20 14:56:43 2009 +0000 +++ b/hedgewars/uRandom.pas Fri Nov 20 21:22:05 2009 +0000 @@ -16,10 +16,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA *) +{$INCLUDE "options.inc"} + unit uRandom; interface uses uFloat; -{$INCLUDE "options.inc"} {$INCLUDE "proto.inc"} procedure SetRandomSeed(Seed: shortstring); diff -r be70fd3458c0 -r 079ef82eac75 hedgewars/uSHA.pas --- a/hedgewars/uSHA.pas Fri Nov 20 14:56:43 2009 +0000 +++ b/hedgewars/uSHA.pas Fri Nov 20 21:22:05 2009 +0000 @@ -15,6 +15,8 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA *) + +{$INCLUDE "options.inc"} unit uSHA; interface diff -r be70fd3458c0 -r 079ef82eac75 hedgewars/uSound.pas --- a/hedgewars/uSound.pas Fri Nov 20 14:56:43 2009 +0000 +++ b/hedgewars/uSound.pas Fri Nov 20 21:22:05 2009 +0000 @@ -16,10 +16,11 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA *) +{$INCLUDE "options.inc"} + unit uSound; interface uses SDLh, uConsts; -{$INCLUDE "options.inc"} type PVoicepack = ^TVoicepack; TVoicepack = record diff -r be70fd3458c0 -r 079ef82eac75 hedgewars/uStats.pas --- a/hedgewars/uStats.pas Fri Nov 20 14:56:43 2009 +0000 +++ b/hedgewars/uStats.pas Fri Nov 20 21:22:05 2009 +0000 @@ -16,6 +16,8 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA *) +{$INCLUDE "options.inc"} + unit uStats; interface uses uGears, uConsts; diff -r be70fd3458c0 -r 079ef82eac75 hedgewars/uStore.pas --- a/hedgewars/uStore.pas Fri Nov 20 14:56:43 2009 +0000 +++ b/hedgewars/uStore.pas Fri Nov 20 21:22:05 2009 +0000 @@ -265,10 +265,6 @@ ai: TAmmoType; tmpsurf: PSDL_Surface; i: LongInt; -{$IFDEF IPHONEOS} -tmpP: PLongWordArray; -tmpA, tmpR, tmpG, tmpB: LongWord; -{$ENDIF} begin for fi:= Low(THWFont) to High(THWFont) do @@ -304,45 +300,7 @@ end; if tmpsurf <> nil then - begin -{$IFDEF IPHONEOS} -{* http://bugzilla.libsdl.org/show_bug.cgi?id=868 but patched library doesn't work on ipod, so implementing workaround here *} - if (ifAlpha or ifTransparent) > 0 then - begin - tmpP := tmpsurf^.pixels; - for i:= 0 to (tmpsurf^.pitch shr 2) * tmpsurf^.h - 1 do - begin -{$IFDEF ENDIAN_LITTLE} - tmpA:= tmpP^[i] shr 24 and $FF; - tmpR:= tmpP^[i] shr 16 and $FF; - tmpG:= tmpP^[i] shr 8 and $FF; - tmpB:= tmpP^[i] and $FF; -{$ELSE} - tmpA:= tmpP^[i] and $FF; - tmpR:= tmpP^[i] shr 8 and $FF; - tmpG:= tmpP^[i] shr 16 and $FF; - tmpB:= tmpP^[i] shr 24 and $FF; -{$ENDIF} - if tmpA <> 0 then - begin - tmpR:= round(tmpR * 255 / tmpA); - tmpG:= round(tmpG * 255 / tmpA); - tmpB:= round(tmpB * 255 / tmpA); - end; - - if tmpR > 255 then tmpR:= 255; - if tmpG > 255 then tmpG:= 255; - if tmpB > 255 then tmpB:= 255; - -{$IFDEF ENDIAN_LITTLE} - tmpP^[i]:= (tmpA shl 24) or (tmpR shl 16) or (tmpG shl 8) or tmpB; -{$ELSE} - tmpP^[i]:= (tmpA) or (tmpR shl 8) or (tmpG shl 16) or (tmpB shl 24); -{$ENDIF} - end; - end; -{$ENDIF} - + begin if imageWidth = 0 then imageWidth:= tmpsurf^.w; if imageHeight = 0 then imageHeight:= tmpsurf^.h; if Width = 0 then Width:= tmpsurf^.w; @@ -353,22 +311,10 @@ begin Texture:= Surface2Tex(tmpsurf, false); if (ii = sprWater) and not cReducedQuality then // HACK: We should include some sprite attribute to define the texture wrap directions - begin - (* REMOVE ME WHEN BUG ABOVE IS FIXED - tmpP := tmpsurf^.pixels; - for i:= 0 to (tmpsurf^.pitch shr 2) * tmpsurf^.h - 1 do - begin - tmpA:= tmpP^[i] shr 24 and $FF; - tmpR:= tmpP^[i] shr 16 and $FF; - tmpG:= tmpP^[i] shr 8 and $FF; - tmpB:= tmpP^[i] and $FF; - - writeln(stdout, inttostr(tmpA) + ' | ' + inttostr(tmpR) + ' | ' + inttostr(tmpG)+ ' | ' + inttostr(tmpB)); - end; - *) + begin glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - end; end; + end; if saveSurf then Surface:= tmpsurf else SDL_FreeSurface(tmpsurf) end else @@ -1030,13 +976,18 @@ function LoadImage(const filename: string; imageFlags: Integer): PSDL_Surface; var tmpsurf: PSDL_Surface; s: shortstring; +{$IFDEF IPHONEOS} + tmpP: PLongWordArray; + tmpA, tmpR, tmpG, tmpB: LongWord; + i: LongInt; +{$ENDIF} begin -WriteToConsole(msgLoading + filename + '... '); + WriteToConsole(msgLoading + filename + '... '); -s:= filename + '.png'; -tmpsurf:= IMG_Load(Str2PChar(s)); + s:= filename + '.png'; + tmpsurf:= IMG_Load(Str2PChar(s)); -if ((imageFlags and ifLowRes) <> 0) then + if (imageFlags and ifLowRes) <> 0 then begin s:= filename + '-lowres.png'; if (tmpsurf <> nil) then @@ -1044,39 +995,90 @@ if ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then begin SDL_FreeSurface(tmpsurf); - WriteLnToConsole('Image too big, trying to load lowres version: ' + s); + {$IFDEF DEBUGFILE} + AddFileLog('...image too big, trying to load lowres version: ' + s + '...'); + {$ENDIF} tmpsurf:= IMG_Load(Str2PChar(s)) end; end else begin - WriteLnToConsole('Image not found, trying to load lowres version: ' + s); + {$IFDEF DEBUGFILE} + AddFileLog('...image not found, trying to load lowres version: ' + s + '...'); + {$ENDIF} tmpsurf:= IMG_Load(Str2PChar(s)) end; end; -if tmpsurf = nil then + if tmpsurf = nil then begin - OutError(msgFailed, (imageFlags and ifCritical) <> 0); - exit(nil) + OutError(msgFailed, (imageFlags and ifCritical) <> 0); + exit(nil) end; -if ((imageFlags and ifIgnoreCaps) = 0) and ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then + if ((imageFlags and ifIgnoreCaps) = 0) and ((tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize)) then begin SDL_FreeSurface(tmpsurf); OutError(msgFailedSize, (imageFlags and ifCritical) <> 0); - //dummy surface to replace non-critical textures that failed to load due to their size + // dummy surface to replace non-critical textures that failed to load due to their size exit(SDL_CreateRGBSurface(SDL_SWSURFACE, 32, 32, 32, RMask, GMask, BMask, AMask)); end; -tmpsurf:= doSurfaceConversion(tmpsurf); + tmpsurf:= doSurfaceConversion(tmpsurf); + +{$IFDEF IPHONEOS} +{* http://bugzilla.libsdl.org/show_bug.cgi?id=868 but patched library doesn't work on ipod, so implementing workaround here *} + if imageFlags and (ifAlpha or ifTransparent) > 0 then + begin + tmpP := tmpsurf^.pixels; + for i:= 0 to (tmpsurf^.pitch shr 2) * tmpsurf^.h - 1 do + begin +{$IFDEF ENDIAN_LITTLE} + tmpA:= tmpP^[i] shr 24 and $FF; + tmpR:= tmpP^[i] shr 16 and $FF; + tmpG:= tmpP^[i] shr 8 and $FF; + tmpB:= tmpP^[i] and $FF; +{$ELSE} + tmpA:= tmpP^[i] and $FF; + tmpR:= tmpP^[i] shr 8 and $FF; + tmpG:= tmpP^[i] shr 16 and $FF; + tmpB:= tmpP^[i] shr 24 and $FF; +{$ENDIF} + if tmpA <> 0 then + begin + tmpR:= round(tmpR * 255 / tmpA); + tmpG:= round(tmpG * 255 / tmpA); + tmpB:= round(tmpB * 255 / tmpA); + end; -if (imageFlags and ifTransparent) <> 0 then TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); -//if (imageFlags and ifAlpha) <> 0 then Result:= SDL_DisplayFormatAlpha(tmpsurf) else Result:= SDL_DisplayFormat(tmpsurf); -WriteLnToConsole('(' + inttostr(tmpsurf^.w) + ',' + inttostr(tmpsurf^.h) + ') '); -WriteLnToConsole(msgOK); + if tmpR > 255 then tmpR:= 255; + if tmpG > 255 then tmpG:= 255; + if tmpB > 255 then tmpB:= 255; -LoadImage:= tmpsurf //Result +{$IFDEF ENDIAN_LITTLE} + tmpP^[i]:= (tmpA shl 24) or (tmpR shl 16) or (tmpG shl 8) or tmpB; +{$ELSE} + tmpP^[i]:= (tmpA) or (tmpR shl 8) or (tmpG shl 16) or (tmpB shl 24); +{$ENDIF} + end; +(* for i:= 0 to (tmpsurf^.pitch shr 2) * tmpsurf^.h - 1 do + begin + tmpA:= tmpP^[i] shr 24 and $FF; + tmpR:= tmpP^[i] shr 16 and $FF; + tmpG:= tmpP^[i] shr 8 and $FF; + tmpB:= tmpP^[i] and $FF; + writeln(stdout, inttostr(tmpA) + ' | ' + inttostr(tmpR) + ' | ' + inttostr(tmpG)+ ' | ' + inttostr(tmpB)); + end; *) + end; +{$ENDIF} + + if (imageFlags and ifTransparent) <> 0 then + TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); + + WriteLnToConsole('(' + inttostr(tmpsurf^.w) + ',' + inttostr(tmpsurf^.h) + ') '); + WriteLnToConsole(msgOK); + + LoadImage:= tmpsurf //Result end; function glLoadExtension(extension : string) : boolean; @@ -1099,14 +1101,14 @@ begin glGetIntegerv(GL_MAX_TEXTURE_SIZE, @MaxTextureSize); +WriteLnToConsole('OpenGL - Renderer: ' + string(pchar(glGetString(GL_RENDERER)))); {$IFDEF DEBUGFILE} -AddFileLog('OpenGL - Renderer: ' + string(pchar(glGetString(GL_RENDERER)))); AddFileLog('OpenGL - Vendor: ' + string(pchar(glGetString(GL_VENDOR)))); AddFileLog('OpenGL - Version: ' + string(pchar(glGetString(GL_VERSION)))); -AddFileLog('OpenGL - GL_MAX_TEXTURE_SIZE: ' + inttostr(MaxTextureSize)); {$ENDIF} +WriteLnToConsole('OpenGL - GL_MAX_TEXTURE_SIZE: ' + inttostr(MaxTextureSize)); -if MaxTextureSize = 0 then + if MaxTextureSize = 0 then begin MaxTextureSize:= 1024; {$IFDEF DEBUGFILE} diff -r be70fd3458c0 -r 079ef82eac75 hedgewars/uTriggers.pas --- a/hedgewars/uTriggers.pas Fri Nov 20 14:56:43 2009 +0000 +++ b/hedgewars/uTriggers.pas Fri Nov 20 21:22:05 2009 +0000 @@ -16,12 +16,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA *) +{$INCLUDE "options.inc"} + unit uTriggers; interface uses SDLh, uConsts; -{$INCLUDE "options.inc"} -const trigTurns = $80000001; type TTrigAction = (taSpawnGear, taSuccessFinish, taFailFinish); diff -r be70fd3458c0 -r 079ef82eac75 hedgewars/uWorld.pas --- a/hedgewars/uWorld.pas Fri Nov 20 14:56:43 2009 +0000 +++ b/hedgewars/uWorld.pas Fri Nov 20 21:22:05 2009 +0000 @@ -16,10 +16,12 @@ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA *) +{$INCLUDE "options.inc"} + unit uWorld; interface uses SDLh, uGears, uConsts, uFloat; -{$INCLUDE "options.inc"} + const WorldDx: LongInt = -512; WorldDy: LongInt = -256;