--- a/hedgewars/SDLh.pas Wed Nov 14 00:41:29 2012 +0400
+++ b/hedgewars/SDLh.pas Wed Nov 14 22:45:36 2012 +0400
@@ -1004,7 +1004,7 @@
function TTF_RenderUTF8_Blended(font: PTTF_Font; const text: PChar; fg: TSDL_Color): PSDL_Surface; cdecl; external SDL_TTFLibName;
function TTF_RenderUTF8_Shaded(font: PTTF_Font; const text: PChar; fg, bg: TSDL_Color): PSDL_Surface; cdecl; external SDL_TTFLibName;
-function TTF_OpenFont(const filename: PChar; size: LongInt): PTTF_Font; cdecl; external SDL_TTFLibName;
+function TTF_OpenFontRW(const filename: PChar; freesrc: LongBool; size: LongInt): PTTF_Font; cdecl; external SDL_TTFLibName;
procedure TTF_SetFontStyle(font: PTTF_Font; style: LongInt); cdecl; external SDL_TTFLibName;
(* SDL_mixer *)
--- a/hedgewars/hwengine.pas Wed Nov 14 00:41:29 2012 +0400
+++ b/hedgewars/hwengine.pas Wed Nov 14 22:45:36 2012 +0400
@@ -344,16 +344,6 @@
for i:= 0 to ParamCount do
AddFileLog(inttostr(i) + ': ' + ParamStr(i));
- for p:= Succ(Low(TPathType)) to High(TPathType) do
- if (p <> ptMapCurrent) and (p <> ptData) then
- UserPathz[p]:= UserPathPrefix + '/Data/' + Pathz[p];
-
- UserPathz[ptData]:= UserPathPrefix + '/Data';
-
- for p:= Succ(Low(TPathType)) to High(TPathType) do
- if p <> ptMapCurrent then
- Pathz[p]:= PathPrefix + '/' + Pathz[p];
-
WriteToConsole('Init SDL... ');
SDLTry(SDL_Init(SDL_INIT_VIDEO or SDL_INIT_NOPARACHUTE) >= 0, true);
WriteLnToConsole(msgOK);
@@ -382,18 +372,15 @@
InitKbdKeyTable();
AddProgress();
- LoadLocale(UserPathz[ptLocale] + '/en.txt'); // Do an initial load with english
- LoadLocale(Pathz[ptLocale] + '/en.txt'); // Do an initial load with english
+ LoadLocale(cPathz[ptLocale] + '/en.txt'); // Do an initial load with english
if cLocaleFName <> 'en.txt' then
begin
// Try two letter locale first before trying specific locale overrides
- if (Length(cLocale) > 3) and (Copy(cLocale,1,2) <> 'en') then
+ if (Length(cLocale) > 3) and (Copy(cLocale, 1, 2) <> 'en') then
begin
- LoadLocale(UserPathz[ptLocale] + '/' + Copy(cLocale,1,2)+'.txt');
- LoadLocale(Pathz[ptLocale] + '/' + Copy(cLocale,1,2)+'.txt')
+ LoadLocale(cPathz[ptLocale] + '/' + Copy(cLocale, 1, 2) + '.txt')
end;
- LoadLocale(UserPathz[ptLocale] + '/' + cLocaleFName);
- LoadLocale(Pathz[ptLocale] + '/' + cLocaleFName)
+ LoadLocale(cPathz[ptLocale] + '/' + cLocaleFName)
end
else cLocale := 'en';
--- a/hedgewars/uCommandHandlers.pas Wed Nov 14 00:41:29 2012 +0400
+++ b/hedgewars/uCommandHandlers.pas Wed Nov 14 22:45:36 2012 +0400
@@ -548,15 +548,9 @@
if isDeveloperMode then
begin
if s = '' then
- begin
- UserPathz[ptMapCurrent]:= s;
- Pathz[ptMapCurrent]:= s;
- end
+ cPathz[ptMapCurrent]:= s
else
- begin
- UserPathz[ptMapCurrent]:= UserPathz[ptMaps] + '/' + s;
- Pathz[ptMapCurrent]:= Pathz[ptMaps] + '/' + s;
- end;
+ cPathz[ptMapCurrent]:= cPathz[ptMaps] + '/' + s;
InitStepsFlags:= InitStepsFlags or cifMap
end;
cMapName:= s;
@@ -567,8 +561,7 @@
begin
if isDeveloperMode then
begin
- UserPathz[ptCurrTheme]:= UserPathz[ptThemes] + '/' + s;
- Pathz[ptCurrTheme]:= Pathz[ptThemes] + '/' + s;
+ cPathz[ptCurrTheme]:= cPathz[ptThemes] + '/' + s;
Theme:= s;
InitStepsFlags:= InitStepsFlags or cifTheme
end
--- a/hedgewars/uLand.pas Wed Nov 14 00:41:29 2012 +0400
+++ b/hedgewars/uLand.pas Wed Nov 14 22:45:36 2012 +0400
@@ -426,10 +426,8 @@
var f: textfile;
s: shortstring;
begin
-// unC0Rr - should this be passed from the GUI? I am not sure which layer does what
-s:= UserPathz[ptMapCurrent] + '/map.cfg';
-if not FileExists(s) then
- s:= Pathz[ptMapCurrent] + '/map.cfg';
+s:= cPathz[ptMapCurrent] + '/map.cfg';
+
WriteLnToConsole('Fetching map HH limit');
{$I-}
Assign(f, s);
@@ -437,7 +435,7 @@
Reset(f);
if IOResult <> 0 then
begin
- s:= Pathz[ptMissionMaps] + '/' + ExtractFileName(Pathz[ptMapCurrent]) + '/map.cfg';
+ s:= cPathz[ptMissionMaps] + '/' + ExtractFileName(cPathz[ptMapCurrent]) + '/map.cfg';
Assign(f, s);
Reset(f);
end;
@@ -459,7 +457,7 @@
tmpsurf:= LoadDataImage(ptMapCurrent, 'mask', ifAlpha or ifTransparent or ifIgnoreCaps);
if tmpsurf = nil then
begin
- mapName:= ExtractFileName(Pathz[ptMapCurrent]);
+ mapName:= ExtractFileName(cPathz[ptMapCurrent]);
tmpsurf:= LoadDataImage(ptMissionMaps, mapName + '/mask', ifAlpha or ifTransparent or ifIgnoreCaps);
end;
@@ -533,7 +531,7 @@
tmpsurf:= LoadDataImage(ptMapCurrent, 'map', ifAlpha or ifTransparent or ifIgnoreCaps);
if tmpsurf = nil then
begin
- mapName:= ExtractFileName(Pathz[ptMapCurrent]);
+ mapName:= ExtractFileName(cPathz[ptMapCurrent]);
tmpsurf:= LoadDataImage(ptMissionMaps, mapName + '/map', ifAlpha or ifCritical or ifTransparent or ifIgnoreCaps);
end;
// (bare) Sanity check. Considering possible LongInt comparisons as well as just how much system memoery it would take
@@ -581,7 +579,7 @@
procedure GenMap;
var x, y, w, c: Longword;
- usermap, usermask, map, mask: shortstring;
+ map, mask: shortstring;
maskOnly: boolean;
begin
hasBorder:= false;
@@ -594,14 +592,11 @@
// FillChar(Land,SizeOf(TCollisionArray),0);*)
if (GameFlags and gfForts) = 0 then
- if Pathz[ptMapCurrent] <> '' then
+ if cPathz[ptMapCurrent] <> '' then
begin
- usermap:= UserPathz[ptMapCurrent] + '/map.png';
- usermask:= UserPathz[ptMapCurrent] + '/mask.png';
- map:= Pathz[ptMapCurrent] + '/map.png';
- mask:= Pathz[ptMapCurrent] + '/mask.png';
- if (not(FileExists(usermap)) and FileExists(usermask)) or
- (not(FileExists(map)) and FileExists(mask)) then
+ map:= cPathz[ptMapCurrent] + '/map.png';
+ mask:= cPathz[ptMapCurrent] + '/mask.png';
+ if (not(FileExists(map)) and FileExists(mask)) then
begin
maskOnly:= true;
LoadMask;
@@ -696,7 +691,7 @@
if (GameFlags and gfDisableGirders) <> 0 then
hasGirders:= false;
-if (GameFlags and gfForts = 0) and (maskOnly or (Pathz[ptMapCurrent] = '')) then
+if (GameFlags and gfForts = 0) and (maskOnly or (cPathz[ptMapCurrent] = '')) then
AddObjects
else
--- a/hedgewars/uLandObjects.pas Wed Nov 14 00:41:29 2012 +0400
+++ b/hedgewars/uLandObjects.pas Wed Nov 14 22:45:36 2012 +0400
@@ -429,9 +429,7 @@
end
end;
-s:= UserPathz[ptCurrTheme] + '/' + cThemeCFGFilename;
-if not FileExists(s) then
- s:= Pathz[ptCurrTheme] + '/' + cThemeCFGFilename;
+s:= cPathz[ptCurrTheme] + '/' + cThemeCFGFilename;
WriteLnToConsole('Reading objects info...');
Assign(f, s);
{$I-}
--- a/hedgewars/uPhysFSLayer.pas Wed Nov 14 00:41:29 2012 +0400
+++ b/hedgewars/uPhysFSLayer.pas Wed Nov 14 22:45:36 2012 +0400
@@ -9,23 +9,39 @@
procedure initModule;
procedure freeModule;
-function PHYSFSRWOPS_openRead(fname: PChar): PSDL_RWops; cdecl; external;
-function PHYSFSRWOPS_openWrite(fname: PChar): PSDL_RWops; cdecl; external;
+function rwopsOpenRead(fname: shortstring): PSDL_RWops;
+function rwopsOpenWrite(fname: shortstring): PSDL_RWops;
implementation
uses uUtils, uVariables;
function PHYSFS_init(argv0: PChar) : LongInt; cdecl; external;
function PHYSFS_deinit() : LongInt; cdecl; external;
+function PHYSFSRWOPS_openRead(fname: PChar): PSDL_RWops; cdecl; external;
+function PHYSFSRWOPS_openWrite(fname: PChar): PSDL_RWops; cdecl; external;
function PHYSFS_mount(newDir, mountPoint: PChar; appendToPath: LongBool) : LongInt; cdecl; external;
-procedure initModule;
+function rwopsOpenRead(fname: shortstring): PSDL_RWops;
+begin
+ exit(PHYSFSRWOPS_openRead(Str2PChar(fname)));
+end;
+
+function rwopsOpenWrite(fname: shortstring): PSDL_RWops;
begin
- PHYSFS_init(Str2PChar(ParamStr(0)));
+ exit(PHYSFSRWOPS_openWrite(Str2PChar(fname)));
+end;
- PHYSFS_mount(Str2PChar(PathPrefix), nil, true);
- PHYSFS_mount(Str2PChar(UserPathPrefix), nil, true);
+procedure initModule;
+var i: LongInt;
+begin
+ i:= PHYSFS_init(Str2PChar(ParamStr(0)));
+ AddFileLog('[PhysFS] init: ' + inttostr(i));
+
+ i:= PHYSFS_mount(Str2PChar(PathPrefix), nil, true);
+ AddFileLog('[PhysFS] mount ' + PathPrefix + ': ' + inttostr(i));
+ i:= PHYSFS_mount(Str2PChar(UserPathPrefix), nil, true);
+ AddFileLog('[PhysFS] mount ' + UserPathPrefix + ': ' + inttostr(i));
end;
procedure freeModule;
--- a/hedgewars/uScript.pas Wed Nov 14 00:41:29 2012 +0400
+++ b/hedgewars/uScript.pas Wed Nov 14 22:45:36 2012 +0400
@@ -1592,7 +1592,7 @@
lua_pushnil(L);
end
else
- lua_pushstring(L, str2pchar(Pathz[ptData]));
+ lua_pushstring(L, str2pchar(cPathz[ptData]));
lc_getdatapath:= 1
end;
@@ -1604,7 +1604,7 @@
lua_pushnil(L);
end
else
- lua_pushstring(L, str2pchar(UserPathz[ptData]));
+ lua_pushstring(L, str2pchar(cPathz[ptData]));
lc_getuserdatapath:= 1
end;
@@ -1969,9 +1969,7 @@
var ret : LongInt;
s : shortstring;
begin
-s:= UserPathz[ptData] + '/' + name;
-if not FileExists(s) then
- s:= Pathz[ptData] + '/' + name;
+s:= cPathz[ptData] + '/' + name;
if not FileExists(s) then
exit;
--- a/hedgewars/uSound.pas Wed Nov 14 00:41:29 2012 +0400
+++ b/hedgewars/uSound.pas Wed Nov 14 22:45:36 2012 +0400
@@ -106,7 +106,7 @@
implementation
-uses uVariables, uConsole, uUtils, uCommands, uDebug;
+uses uVariables, uConsole, uUtils, uCommands, uDebug, uPhysFSLayer;
const chanTPU = 32;
var Volume: LongInt;
@@ -131,29 +131,17 @@
if cLocale <> 'en' then
begin
locName:= name+'_'+cLocale;
- path:= UserPathz[ptVoices] + '/' + locName;
+ path:= cPathz[ptVoices] + '/' + locName;
if DirectoryExists(path) then
name:= locName
else
- begin
- path:= Pathz[ptVoices] + '/' + locName;
- if DirectoryExists(path) then
- name:= locName
- else if Length(cLocale) > 3
- then
+ if Length(cLocale) > 3 then
begin
locName:= name+'_'+Copy(cLocale,1,2);
- path:= UserPathz[ptVoices] + '/' + locName;
+ path:= cPathz[ptVoices] + '/' + locName;
if DirectoryExists(path) then
name:= locName
- else
- begin
- path:= Pathz[ptVoices] + '/' + locName;
- if DirectoryExists(path) then
- name:= locName
- end
end
- end
end;
// If that fails, use the unmodified one
@@ -267,13 +255,11 @@
begin
if (voicepack^.chunks[snd] = nil) and (Soundz[snd].Path = ptVoices) and (Soundz[snd].FileName <> '') then
begin
- s:= UserPathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName;
- if not FileExists(s) then
- s:= Pathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName;
+ s:= cPathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName;
if (not FileExists(s)) and (snd in [sndFirePunch2, sndFirePunch3, sndFirePunch4, sndFirePunch5, sndFirePunch6]) then
- s:= Pathz[Soundz[sndFirePunch1].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName;
+ s:= cPathz[Soundz[sndFirePunch1].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName;
WriteToConsole(msgLoading + s + ' ');
- voicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), _P'rb'), 1);
+ voicepack^.chunks[snd]:= Mix_LoadWAV_RW(rwopsOpenRead(s), 1);
if voicepack^.chunks[snd] = nil then
WriteLnToConsole(msgFailed)
else
@@ -285,11 +271,9 @@
begin
if (defVoicepack^.chunks[snd] = nil) and (Soundz[snd].Path <> ptVoices) and (Soundz[snd].FileName <> '') then
begin
- s:= UserPathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName;
- if not FileExists(s) then
- s:= Pathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName;
+ s:= cPathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName;
WriteToConsole(msgLoading + s + ' ');
- defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), _P'rb'), 1);
+ defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(rwopsOpenRead(s), 1);
SDLTry(defVoicepack^.chunks[snd] <> nil, true);
WriteLnToConsole(msgOK);
end;
@@ -369,11 +353,9 @@
begin
if (voicepack^.chunks[snd] = nil) and (Soundz[snd].Path = ptVoices) and (Soundz[snd].FileName <> '') then
begin
- s:= UserPathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName;
- if not FileExists(s) then
- s:= Pathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName;
+ s:= cPathz[Soundz[snd].Path] + '/' + voicepack^.name + '/' + Soundz[snd].FileName;
WriteToConsole(msgLoading + s + ' ');
- voicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), _P'rb'), 1);
+ voicepack^.chunks[snd]:= Mix_LoadWAV_RW(rwopsOpenRead(s), 1);
if voicepack^.chunks[snd] = nil then
WriteLnToConsole(msgFailed)
else
@@ -385,11 +367,9 @@
begin
if (defVoicepack^.chunks[snd] = nil) and (Soundz[snd].Path <> ptVoices) and (Soundz[snd].FileName <> '') then
begin
- s:= UserPathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName;
- if not FileExists(s) then
- s:= Pathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName;
+ s:= cPathz[Soundz[snd].Path] + '/' + Soundz[snd].FileName;
WriteToConsole(msgLoading + s + ' ');
- defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(SDL_RWFromFile(Str2PChar(s), _P'rb'), 1);
+ defVoicepack^.chunks[snd]:= Mix_LoadWAV_RW(rwopsOpenRead(s), 1);
SDLTry(defVoicepack^.chunks[snd] <> nil, true);
WriteLnToConsole(msgOK);
end;
--- a/hedgewars/uStore.pas Wed Nov 14 00:41:29 2012 +0400
+++ b/hedgewars/uStore.pas Wed Nov 14 22:45:36 2012 +0400
@@ -310,11 +310,9 @@
for fi:= Low(THWFont) to High(THWFont) do
with Fontz[fi] do
begin
- s:= UserPathz[ptFonts] + '/' + Name;
- if not FileExists(s) then
- s:= Pathz[ptFonts] + '/' + Name;
+ s:= cPathz[ptFonts] + '/' + Name;
WriteToConsole(msgLoading + s + ' (' + inttostr(Height) + 'pt)... ');
- Handle:= TTF_OpenFont(Str2PChar(s), Height);
+ Handle:= TTF_OpenFontRW(Str2PChar(s), true, Height);
SDLTry(Handle <> nil, true);
TTF_SetFontStyle(Handle, style);
WriteLnToConsole(msgOK)
@@ -566,7 +564,7 @@
WriteToConsole(msgLoading + filename + '.png [flags: ' + inttostr(imageFlags) + '] ');
s:= filename + '.png';
- tmpsurf:= IMG_Load_RW(PHYSFSRWOPS_openRead(Str2PChar(s)), true);
+ tmpsurf:= IMG_Load_RW(rwopsOpenRead(s), true);
if tmpsurf = nil then
begin
--- a/hedgewars/uVariables.pas Wed Nov 14 00:41:29 2012 +0400
+++ b/hedgewars/uVariables.pas Wed Nov 14 22:45:36 2012 +0400
@@ -118,9 +118,6 @@
SDWaterOpacity: byte;
GrayScale: Boolean;
- // originally from uConsts
- Pathz: array[TPathType] of shortstring;
- UserPathz: array[TPathType] of shortstring;
CountTexz: array[0..Pred(AMMO_INFINITE)] of PTexture;
LAND_WIDTH : LongInt;
LAND_HEIGHT : LongInt;
@@ -2586,7 +2583,6 @@
lastVisualGearByUID := nil;
lastGearByUID := nil;
cReadyDelay := 5000;
- Pathz := cPathz;
{* REFERENCE
4096 -> $FFFFF000