# HG changeset patch # User koda # Date 1374880007 -7200 # Node ID 2be457289e609521418408c3ec679cda0c34a5b0 # Parent 48ab6dea8d2fcf994fdaec36d16265abed812eb5 update physlayer and sdl bindings to the new rwops interface diff -r 48ab6dea8d2f -r 2be457289e60 hedgewars/SDLh.pas --- a/hedgewars/SDLh.pas Fri Jul 26 23:02:25 2013 +0200 +++ b/hedgewars/SDLh.pas Sat Jul 27 01:06:47 2013 +0200 @@ -428,7 +428,12 @@ (* SDL_RWops and friends *) PSDL_RWops = ^TSDL_RWops; +{$IFDEF SDL2} + TSize = function( context: PSDL_RWops): Int64; cdecl; + TSeek = function( context: PSDL_RWops; offset: Int64; whence: LongInt ): Int64; cdecl; +{$ELSE} TSeek = function( context: PSDL_RWops; offset: LongInt; whence: LongInt ): LongInt; cdecl; +{$ENDIF} TRead = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; maxnum : LongInt ): LongInt; cdecl; TWrite = function( context: PSDL_RWops; Ptr: Pointer; size: LongInt; num: LongInt ): LongInt; cdecl; TClose = function( context: PSDL_RWops ): LongInt; cdecl; @@ -473,6 +478,9 @@ {$ENDIF} TSDL_RWops = record +{$IFDEF SDL2} + size: TSize; +{$ENDIF} seek: TSeek; read: TRead; write: TWrite; diff -r 48ab6dea8d2f -r 2be457289e60 hedgewars/uPhysFSLayer.pas --- a/hedgewars/uPhysFSLayer.pas Fri Jul 26 23:02:25 2013 +0200 +++ b/hedgewars/uPhysFSLayer.pas Sat Jul 27 01:06:47 2013 +0200 @@ -133,7 +133,7 @@ begin {$IFDEF HWLIBRARY} //TODO: http://icculus.org/pipermail/physfs/2011-August/001006.html - cPhysfsId:= GetCurrentDir() + {$IFDEF DARWIN}'/Hedgewars.app/Contents/MacOS/' + {$ENDIF} ' hedgewars'; + cPhysfsId:= GetCurrentDir() + {$IFDEF DARWIN}{$IFNDEF IPHONEOS}'/Hedgewars.app/Contents/MacOS/' + {$ENDIF}{$ENDIF} ' hedgewars'; {$ELSE} cPhysfsId:= ParamStr(0); {$ENDIF} diff -r 48ab6dea8d2f -r 2be457289e60 misc/libphyslayer/physfsrwops.c --- a/misc/libphyslayer/physfsrwops.c Fri Jul 26 23:02:25 2013 +0200 +++ b/misc/libphyslayer/physfsrwops.c Sat Jul 27 01:06:47 2013 +0200 @@ -32,6 +32,14 @@ #endif #if TARGET_SDL13 +static SDLCALL Sint64 physfsrwops_size(struct SDL_RWops *rw) +{ + PHYSFS_File *handle = (PHYSFS_File *) rw->hidden.unknown.data1; + return PHYSFS_fileLength(handle); +} +#endif + +#if TARGET_SDL13 static SDLCALL Sint64 physfsrwops_seek(struct SDL_RWops *rw, Sint64 offset, int whence) #else static int physfsrwops_seek(SDL_RWops *rw, int offset, int whence) @@ -42,7 +50,6 @@ if (whence == SEEK_SET) pos = (PHYSFS_sint64) offset; - else if (whence == SEEK_CUR) { const PHYSFS_sint64 current = PHYSFS_tell(handle); @@ -173,6 +180,9 @@ retval = SDL_AllocRW(); if (retval != NULL) { +#if TARGET_SDL13 + retval->size = physfsrwops_size; +#endif retval->seek = physfsrwops_seek; retval->read = physfsrwops_read; retval->write = physfsrwops_write;