summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3c27cda)
raw | patch | inline | side by side (parent: 3c27cda)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Fri, 22 Apr 2016 14:00:15 +0000 (17:00 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Fri, 22 Apr 2016 14:10:06 +0000 (17:10 +0300) |
12 files changed:
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index 6379821eaf14e92508ab607c4eef8b66c41c02ec..e17175b141cb5c453ab94bef594f1217e47bb4b4 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
w := TWADFile.Create();
w.ReadFile(WAD);
- if not w.GetResource('', 'INTERSCRIPT', p, len) then
+ if not w.GetResource('INTERSCRIPT', p, len) then
begin
w.Free();
Exit;
w := TWADFile.Create();
w.ReadFile(MapsDir + WAD);
- if not w.GetResource('', 'INTERSCRIPT', p, len) then
+ if not w.GetResource('INTERSCRIPT', p, len) then
begin
w.Free();
Exit;
MegaWAD.endpic := cfg.ReadStr('megawad', 'endpic', '');
if MegaWAD.endpic <> '' then
begin
- g_ProcessResourceStr(MegaWAD.endpic, @s, nil, nil);
+ s := g_ExtractWadName(MegaWAD.endpic);
if s = '' then s := MapsDir+WAD else s := GameDir+'/wads/';
g_Texture_CreateWADEx('TEXTURE_endpic', s+MegaWAD.endpic);
end;
MegaWAD.endmus := cfg.ReadStr('megawad', 'endmus', 'Standart.wad:D2DMUS\ÊÎÍÅÖ');
if MegaWAD.endmus <> '' then
begin
- g_ProcessResourceStr(MegaWAD.endmus, @s, nil, nil);
+ s := g_ExtractWadName(MegaWAD.endmus);
if s = '' then s := MapsDir+WAD else s := GameDir+'/wads/';
g_Sound_CreateWADEx('MUSIC_endmus', s+MegaWAD.endmus, True);
end;
procedure EndGame();
var
a: Integer;
- FileName, SectionName, ResName: string;
+ FileName: string;
begin
if g_Game_IsNet and g_Game_IsServer then
MH_SEND_GameEvent(NET_EV_MAPEND, Byte(gMissionFailed));
EXIT_ENDLEVELCUSTOM: // Çàêîí÷èëñÿ óðîâåíü â Ñâîåé èãðå
begin
// Ñòàòèñòèêà Ñâîåé èãðû:
- g_ProcessResourceStr(gMapInfo.Map, FileName, SectionName, ResName);
+ FileName := g_ExtractWadName(gMapInfo.Map);
CustomStat.GameTime := gTime;
- CustomStat.Map := ExtractFileName(FileName)+':'+ResName;
+ CustomStat.Map := ExtractFileName(FileName)+':'+g_ExtractFileName(gMapInfo.Map); //ResName;
CustomStat.MapName := gMapInfo.Name;
CustomStat.GameMode := gGameSettings.GameMode;
if gGameSettings.GameMode in [GM_TDM, GM_CTF] then
e_DrawFillQuad(x, y, x+w-1, y+h-1, 64, 64, 64, 32);
e_DrawQuad(x, y, x+w-1, y+h-1, 255, 127, 0);
- g_ProcessResourceStr(gMapInfo.Map, @wad, nil, @map);
- wad := ExtractFileName(wad);
+ wad := g_ExtractWadNameNoPath(gMapInfo.Map);
+ map := g_ExtractFileName(gMapInfo.Map);
mapstr := wad + ':\' + map + ' - ' + gMapInfo.Name;
case gGameSettings.GameMode of
begin
if g_Game_IsClient then
Exit;
- g_ProcessResourceStr(gMapInfo.Map, nil, nil, @Map);
+ map := g_ExtractFileName(gMapInfo.Map);
MessageTime := 0;
gGameOn := False;
if Pos(':\', Map) > 0 then
begin
- g_ProcessResourceStr(Map, @NewWAD, nil, @ResName);
+ NewWAD := g_ExtractWadName(Map);
+ ResName := g_ExtractFileName(Map);
if g_Game_IsServer then
begin
gWADHash := MD5File(MapsDir + NewWAD);
Exit;
end;
gExit := EXIT_ENDLEVELCUSTOM;
- g_ProcessResourceStr(gMapInfo.Map, nil, nil, @Map);
+ Map := g_ExtractFileName(gMapInfo.Map);
gNextMap := Map;
end;
if MapList = nil then
Exit;
- g_ProcessResourceStr(gMapInfo.Map, nil, nil, @Map);
+ Map := g_ExtractFileName(gMapInfo.Map);
SortSArray(MapList);
MapIndex := -255;
end;
function g_Game_IsTestMap(): Boolean;
-var
- FName, Sect, Res: String;
begin
- g_ProcessResourceStr(gMapInfo.Map, FName, Sect, Res);
- Result := UpperCase(Res) = TEST_MAP_NAME;
+ result := StrEquCI1251(TEST_MAP_NAME, g_ExtractFileName(gMapInfo.Map));
end;
procedure g_Game_DeleteTestMap();
diff --git a/src/game/g_gui.pas b/src/game/g_gui.pas
index 973def68744420d3359986567bba3bc8808ed8cc..9319e45a7b9e29550da578fa07bf4af5ac32dc25 100644 (file)
--- a/src/game/g_gui.pas
+++ b/src/game/g_gui.pas
panels: TPanelsRec1Array;
header: TMapHeaderRec_1;
a: Integer;
- FileName, SectionName, ResName: string;
+ FileName: string;
Data: Pointer;
Len: Integer;
rX, rY: Single;
begin
- g_ProcessResourceStr(Res, FileName, SectionName, ResName);
+ FileName := g_ExtractWadName(Res);
WAD := TWADFile.Create();
if not WAD.ReadFile(FileName) then
Exit;
end;
- if not WAD.GetResource('', ResName, Data, Len) then
+ //k8: ignores path again
+ if not WAD.GetResource(g_ExtractFileName(Res), Data, Len) then
begin
WAD.Free();
Exit;
diff --git a/src/game/g_map.pas b/src/game/g_map.pas
index 8445e7825e307e89348d740d87c6779970f3362c..6c156caf5c973912a371ba6e4c0fc9397dce1467 100644 (file)
--- a/src/game/g_map.pas
+++ b/src/game/g_map.pas
WAD: TWADFile;
TextureData: Pointer;
WADName: String;
- SectionName: String;
- TextureName: String;
a, ResLength: Integer;
begin
Result := -1;
end;
// Çàãðóæàåì ðåñóðñ òåêñòóðû â ïàìÿòü èç WAD'à:
- g_ProcessResourceStr(RecName, WADName, SectionName, TextureName);
+ WADName := g_ExtractWadName(RecName);
WAD := TWADFile.Create();
WAD.ReadFile(WADName);
- if WAD.GetResource(SectionName, TextureName, TextureData, ResLength) then
+ if WAD.GetResource(g_ExtractFilePathName(RecName), TextureData, ResLength) then
begin
SetLength(Textures, Length(Textures)+1);
if not e_CreateTextureMem(TextureData, ResLength, Textures[High(Textures)].TextureID) then
TextureData: Pointer;
cfg: TConfig;
WADName: String;
- SectionName: String;
- TextureName: String;
ResLength: Integer;
TextureResource: String;
_width, _height, _framecount, _speed: Integer;
Result := -1;
// ×èòàåì WAD-ðåñóðñ àíèì.òåêñòóðû èç WAD'à â ïàìÿòü:
- g_ProcessResourceStr(RecName, WADName, SectionName, TextureName);
+ WADName := g_ExtractWadName(RecName);
WAD := TWADFile.Create();
WAD.ReadFile(WADName);
- if not WAD.GetResource(SectionName, TextureName, TextureWAD, ResLength) then
+ if not WAD.GetResource(g_ExtractFilePathName(RecName), TextureWAD, ResLength) then
begin
if log then
begin
end;
// ×èòàåì INI-ðåñóðñ àíèì. òåêñòóðû è çàïîìèíàåì åãî óñòàíîâêè:
- if not WAD.GetResource('TEXT', 'ANIM', TextData, ResLength) then
+ if not WAD.GetResource('TEXT/ANIM', TextData, ResLength) then
begin
FreeMem(TextureWAD);
WAD.Free();
cfg.Free();
// ×èòàåì ðåñóðñ òåêñòóð (êàäðîâ) àíèì. òåêñòóðû â ïàìÿòü:
- if not WAD.GetResource('TEXTURES', TextureResource, TextureData, ResLength) then
+ if not WAD.GetResource('TEXTURES/'+TextureResource, TextureData, ResLength) then
begin
FreeMem(TextureWAD);
FreeMem(TextData);
DoorPanel: Integer;
ShotPanel: Integer;
end;
- FileName, SectionName, ResName,
- FileName2, s, TexName: String;
+ FileName, mapResName, s, TexName: String;
Data: Pointer;
Len: Integer;
ok, isAnim, trigRef: Boolean;
sfsGCDisable(); // temporary disable removing of temporary volumes
try
// Çàãðóçêà WAD:
- g_ProcessResourceStr(Res, FileName, SectionName, ResName);
- e_WriteLog('Loading map WAD: ' + FileName, MSG_NOTIFY);
+ FileName := g_ExtractWadName(Res);
+ e_WriteLog('Loading map WAD: '+FileName, MSG_NOTIFY);
g_Game_SetLoadingText(_lc[I_LOAD_WAD_FILE], 0, False);
WAD := TWADFile.Create();
WAD.Free();
Exit;
end;
- if not WAD.GetResource('', ResName, Data, Len) then
+ //k8: why loader ignores path here?
+ mapResName := g_ExtractFileName(Res);
+ if not WAD.GetResource(mapResName, Data, Len) then
begin
- g_FatalError(Format(_lc[I_GAME_ERROR_MAP_RES], [ResName]));
+ g_FatalError(Format(_lc[I_GAME_ERROR_MAP_RES], [mapResName]));
WAD.Free();
Exit;
end;
WAD.Free();
// Çàãðóçêà êàðòû:
- e_WriteLog('Loading map: ' + ResName, MSG_NOTIFY);
+ e_WriteLog('Loading map: '+mapResName, MSG_NOTIFY);
g_Game_SetLoadingText(_lc[I_LOAD_MAP], 0, False);
MapReader := TMapReader_1.Create();
begin
e_WriteLog(' Loading sky: ' + gMapInfo.SkyName, MSG_NOTIFY);
g_Game_SetLoadingText(_lc[I_LOAD_SKY], 0, False);
- g_ProcessResourceStr(gMapInfo.SkyName, FileName, SectionName, ResName);
+ FileName := g_ExtractWadName(gMapInfo.SkyName);
if FileName <> '' then
FileName := GameDir+'/wads/'+FileName
else
begin
- g_ProcessResourceStr(Res, @FileName2, nil, nil);
- FileName := FileName2;
+ FileName := g_ExtractWadName(Res);
end;
- s := FileName+':'+SectionName+'/'+ResName;
+ s := FileName+':'+g_ExtractFilePathName(gMapInfo.SkyName);
if g_Texture_CreateWAD(BackID, s) then
begin
g_Game_SetupScreenSize();
begin
e_WriteLog(' Loading music: ' + gMapInfo.MusicName, MSG_NOTIFY);
g_Game_SetLoadingText(_lc[I_LOAD_MUSIC], 0, False);
- g_ProcessResourceStr(gMapInfo.MusicName, FileName, SectionName, ResName);
+ FileName := g_ExtractWadName(gMapInfo.MusicName);
if FileName <> '' then
FileName := GameDir+'/wads/'+FileName
else
begin
- g_ProcessResourceStr(Res, @FileName2, nil, nil);
- FileName := FileName2;
+ FileName := g_ExtractWadName(Res);
end;
- s := FileName+':'+SectionName+'/'+ResName;
+ s := FileName+':'+g_ExtractFilePathName(gMapInfo.MusicName);
if g_Sound_CreateWADEx(gMapInfo.MusicName, s, True) then
ok := True
else
WAD: TWADFile;
MapReader: TMapReader_1;
Header: TMapHeaderRec_1;
- FileName, SectionName, ResName: String;
+ FileName: String;
Data: Pointer;
Len: Integer;
begin
FillChar(Result, SizeOf(Result), 0);
- g_ProcessResourceStr(Res, FileName, SectionName, ResName);
+ FileName := g_ExtractWadName(Res);
WAD := TWADFile.Create();
if not WAD.ReadFile(FileName) then
Exit;
end;
- if not WAD.GetResource('', ResName, Data, Len) then
+ //k8: it ignores path again
+ if not WAD.GetResource(g_ExtractFileName(Res), Data, Len) then
begin
WAD.Free();
Exit;
Exit;
end;
- ResList := WAD.GetResourcesList('');
+ ResList := WAD.GetRootResources();
if ResList <> nil then
for a := 0 to High(ResList) do
begin
- if not WAD.GetResource('', ResList[a], Data, Len) then Continue;
+ if not WAD.GetResource(ResList[a], Data, Len) then Continue;
CopyMemory(@Sign[0], Data, 3);
FreeMem(Data);
function g_Map_Exist(Res: string): Boolean;
var
WAD: TWADFile;
- FileName, SectionName, ResName: string;
+ FileName, mnn: string;
ResList: SArray;
a: Integer;
begin
Result := False;
- g_ProcessResourceStr(Res, FileName, SectionName, ResName);
-
- FileName := addWadExtension(FileName);
+ FileName := addWadExtension(g_ExtractWadName(Res));
WAD := TWADFile.Create;
if not WAD.ReadFile(FileName) then
Exit;
end;
- ResList := WAD.GetResourcesList('');
+ ResList := WAD.GetRootResources();
WAD.Free();
+ mnn := g_ExtractFileName(Res);
if ResList <> nil then
- for a := 0 to High(ResList) do if ResList[a] = ResName then
+ for a := 0 to High(ResList) do if StrEquCI1251(ResList[a], mnn) then
begin
Result := True;
Exit;
diff --git a/src/game/g_menu.pas b/src/game/g_menu.pas
index 8b3dc3163d65a40d806a81aacabf4d4a66f34108..eeb6f4a8ee3acb9464709a9b19d7a191973a658d 100644 (file)
--- a/src/game/g_menu.pas
+++ b/src/game/g_menu.pas
if a.pic <> '' then
begin
- g_ProcessResourceStr(a.pic, @fn, nil, nil);
+ fn := g_ExtractWadName(a.pic);
if fn = '' then
TGUIImage(win.GetControl('mpWADImage')).SetImage(wad+a.pic)
else
wad := TWADFile.Create;
if wad.ReadFile(GameWAD) then
- wad.GetResource('FONTS', cfgres, cfgdata, cfglen);
+ wad.GetResource('FONTS/'+cfgres, cfgdata, cfglen);
wad.Free();
if cfglen <> 0 then
wad := TWADFile.Create;
if wad.ReadFile(GameWAD) then
begin
- wad.GetResource('FONTS', txtres, cfgdata, cfglen);
- wad.GetResource('FONTS', fntres, fntdata, fntlen);
+ wad.GetResource('FONTS/'+txtres, cfgdata, cfglen);
+ wad.GetResource('FONTS/'+fntres, fntdata, fntlen);
end;
wad.Free();
index 916f7cdf3fbf9d31524d04bc7e35c9a6f122a114..afc88a72944396474173303e5852c5e486a88afa 100644 (file)
--- a/src/game/g_netmaster.pas
+++ b/src/game/g_netmaster.pas
Wad, Map: string;
Cli: Byte;
begin
- g_ProcessResourceStr(gMapInfo.Map, @Wad, nil, @Map);
- Wad := ExtractFileName(Wad);
+ Wad := g_ExtractWadNameNoPath(gMapInfo.Map);
+ Map := g_ExtractFileName(gMapInfo.Map);
e_Buffer_Write(@NetOut, NetServerName);
diff --git a/src/game/g_netmsg.pas b/src/game/g_netmsg.pas
index 0dab350037a061849ca1d69a9c5552f8a7006a32..9b0614dd1dede069f2297c84a61919fe5fbe3bc0 100644 (file)
--- a/src/game/g_netmsg.pas
+++ b/src/game/g_netmsg.pas
var
Map: string;
begin
- g_ProcessResourceStr(gMapInfo.Map, nil, nil, @Map);
+ Map := g_ExtractFileName(gMapInfo.Map);
e_Buffer_Clear(@NetOut);
index 8345e785c504fa6b621aeb77bb7c979dc19f2bb7..7f939fb44a5c50f3343ea1824b6f36a24608baf4 100644 (file)
Exit;
end;
- if not WAD.GetResource('TEXT', 'MODEL', pData, len) then
+ if not WAD.GetResource('TEXT/MODEL', pData, len) then
begin
WAD.Free();
Exit;
SetLength(Gibs, ReadInt('Gibs', 'count', 0));
if (Gibs <> nil) and
- (WAD.GetResource('TEXTURES', config.ReadStr('Gibs', 'resource', 'GIBS'), pData, lenpd)) and
- (WAD.GetResource('TEXTURES', config.ReadStr('Gibs', 'mask', 'GIBSMASK'), pData2, lenpd2)) then
+ (WAD.GetResource('TEXTURES/'+config.ReadStr('Gibs', 'resource', 'GIBS'), pData, lenpd)) and
+ (WAD.GetResource('TEXTURES/'+config.ReadStr('Gibs', 'mask', 'GIBSMASK'), pData2, lenpd2)) then
begin
for a := 0 to High(Gibs) do
if e_CreateTextureMemEx(pData, lenpd, Gibs[a].ID, a*32, 0, 32, 32) and
index 3a1cecdc6e0782df8ef69912b81b17284c78ba18..3d8c14cd669c6fed75253e9bf1f7916a79d02379 100644 (file)
--- a/src/game/g_saveload.pas
+++ b/src/game/g_saveload.pas
str := gGameSettings.WAD;
bMem.WriteString(str, 128);
// Èìÿ êàðòû:
- g_ProcessResourceStr(gMapInfo.Map, nil, nil, @str);
+ str := g_ExtractFileName(gMapInfo.Map);
bMem.WriteString(str, 32);
// Êîëè÷åñòâî èãðîêîâ:
nPlayers := g_Player_GetCount();
diff --git a/src/game/g_sound.pas b/src/game/g_sound.pas
index 0632efdfe9904859d6accc8222abd3e3e1e28363..5c2882daae9ca8ef2a22e4454bbb6be6ee5870d4 100644 (file)
--- a/src/game/g_sound.pas
+++ b/src/game/g_sound.pas
function g_Sound_CreateWAD(var ID: DWORD; Resource: string; isMusic: Boolean = False): Boolean;
var
WAD: TWADFile;
- FileName,
- SectionName,
- ResourceName: string;
+ FileName: string;
SoundData: Pointer;
ResLength: Integer;
ok: Boolean;
ok := False;
// e_WriteLog('Loading sound: ' + Resource, MSG_NOTIFY);
- g_ProcessResourceStr(Resource, FileName, SectionName, ResourceName);
+ FileName := g_ExtractWadName(Resource);
WAD := TWADFile.Create();
WAD.ReadFile(FileName);
- if WAD.GetResource(SectionName, ResourceName, SoundData, ResLength) then
+ if WAD.GetResource(g_ExtractFilePathName(Resource), SoundData, ResLength) then
begin
if e_LoadSoundMem(SoundData, ResLength, ID, isMusic) then
ok := True
function g_Sound_CreateWADEx(SoundName: ShortString; Resource: string; isMusic: Boolean = False): Boolean;
var
WAD: TWADFile;
- FileName, SectionName, ResourceName: string;
+ FileName: string;
SoundData: Pointer;
ResLength: Integer;
find_id: DWORD;
ok := False;
// e_WriteLog('Loading sound: ' + Resource, MSG_NOTIFY);
- g_ProcessResourceStr(Resource, FileName, SectionName, ResourceName);
+ FileName := g_ExtractWadName(Resource);
find_id := FindSound();
WAD := TWADFile.Create();
WAD.ReadFile(FileName);
- if WAD.GetResource(SectionName, ResourceName, SoundData, ResLength) then
+ if WAD.GetResource(g_ExtractFilePathName(Resource), SoundData, ResLength) then
begin
if e_LoadSoundMem(SoundData, ResLength, SoundArray[find_id].ID, isMusic) then
begin
index bdf6605849405c044781a9cc89723a2a29c50060..4e1cffad133903770bb6900a9e4e8bf699ff2a97 100644 (file)
--- a/src/game/g_textures.pas
+++ b/src/game/g_textures.pas
function g_Texture_CreateWAD(var ID: DWORD; Resource: String): Boolean;
var
WAD: TWADFile;
- FileName,
- SectionName,
- ResourceName: String;
+ FileName: String;
TextureData: Pointer;
ResourceLength: Integer;
begin
Result := False;
- g_ProcessResourceStr(Resource, FileName, SectionName, ResourceName);
+ FileName := g_ExtractWadName(Resource);
WAD := TWADFile.Create;
WAD.ReadFile(FileName);
- if WAD.GetResource(SectionName, ResourceName, TextureData, ResourceLength) then
+ if WAD.GetResource(g_ExtractFilePathName(Resource), TextureData, ResourceLength) then
begin
if e_CreateTextureMem(TextureData, ResourceLength, ID) then
Result := True
function g_Texture_CreateWADEx(TextureName: ShortString; Resource: String): Boolean;
var
WAD: TWADFile;
- FileName,
- SectionName,
- ResourceName: String;
+ FileName: String;
TextureData: Pointer;
find_id: DWORD;
ResourceLength: Integer;
begin
- g_ProcessResourceStr(Resource, FileName, SectionName, ResourceName);
+ FileName := g_ExtractWadName(Resource);
find_id := FindTexture();
WAD := TWADFile.Create;
WAD.ReadFile(FileName);
- if WAD.GetResource(SectionName, ResourceName, TextureData, ResourceLength) then
+ if WAD.GetResource(g_ExtractFilePathName(Resource), TextureData, ResourceLength) then
begin
Result := e_CreateTextureMem(TextureData, ResourceLength, TexturesArray[find_id].ID);
if Result then
FWidth, FHeight, FCount: Word; BackAnimation: Boolean = False): Boolean;
var
WAD: TWADFile;
- FileName,
- SectionName,
- ResourceName: string;
+ FileName: string;
TextureData: Pointer;
ResourceLength: Integer;
begin
Result := False;
- g_ProcessResourceStr(Resource, FileName, SectionName, ResourceName);
+ FileName := g_ExtractWadName(Resource);
WAD := TWADFile.Create();
WAD.ReadFile(FileName);
- if not WAD.GetResource(SectionName, ResourceName, TextureData, ResourceLength) then
+ if not WAD.GetResource(g_ExtractFilePathName(Resource), TextureData, ResourceLength) then
begin
WAD.Free();
e_WriteLog(Format('Error loading texture %s', [Resource]), MSG_WARNING);
index 89adae44b57715f36df45b231cb7fc660ceca8da..609c309e4936e8b0851fe94cd43612a4d28e9577 100644 (file)
--- a/src/game/g_triggers.pas
+++ b/src/game/g_triggers.pas
// Åùå íåò òàêîãî çâóêà:
if not g_Sound_Exists(Trigger.Data.SoundName) then
begin
- g_ProcessResourceStr(Trigger.Data.SoundName, @fn, nil, nil);
+ fn := g_ExtractWadName(Trigger.Data.SoundName);
if fn = '' then
begin // Çâóê â ôàéëå ñ êàðòîé
- g_ProcessResourceStr(gMapInfo.Map, @mapw, nil, nil);
- fn := mapw + Trigger.Data.SoundName;
+ mapw := g_ExtractWadName(gMapInfo.Map);
+ fn := mapw+':'+g_ExtractFilePathName(Trigger.Data.SoundName);
end
else // Çâóê â îòäåëüíîì ôàéëå
fn := GameDir + '/wads/' + Trigger.Data.SoundName;
// Åùå íåò òàêîé ìóçûêè:
if not g_Sound_Exists(Trigger.Data.MusicName) then
begin
- g_ProcessResourceStr(Trigger.Data.MusicName, @fn, nil, nil);
+ fn := g_ExtractWadName(Trigger.Data.MusicName);
if fn = '' then
begin // Ìóçûêà â ôàéëå ñ êàðòîé
- g_ProcessResourceStr(gMapInfo.Map, @mapw, nil, nil);
- fn := mapw + Trigger.Data.MusicName;
+ mapw := g_ExtractWadName(gMapInfo.Map);
+ fn := mapw+':'+g_ExtractFilePathName(Trigger.Data.MusicName);
end
else // Ìóçûêà â ôàéëå ñ êàðòîé
fn := GameDir+'/wads/'+Trigger.Data.MusicName;
index aee12f47e55faea002758b2425fbd0bc5c9a1c1c..ade53adcf7f9343c6ed882a20c7df2b626b0ac7e 100644 (file)
--- a/src/shared/wadreader.pas
+++ b/src/shared/wadreader.pas
function ReadFile (FileName: AnsiString): Boolean;
function ReadMemory (Data: Pointer; Len: LongWord): Boolean;
- function GetResource (Section, Resource: AnsiString; var pData: Pointer; var Len: Integer): Boolean;
- function GetResourcesList (Section: AnsiString): SArray;
+
+ function GetResource (name: AnsiString; var pData: Pointer; var Len: Integer): Boolean;
+ function GetRootResources (): SArray;
property isOpen: Boolean read getIsOpen;
end;
-procedure g_ProcessResourceStr (ResourceStr: AnsiString; var FileName, SectionName, ResourceName: AnsiString); overload;
-procedure g_ProcessResourceStr (ResourceStr: AnsiString; FileName, SectionName, ResourceName: PString); overload;
+function g_ExtractWadName (resourceStr: AnsiString): AnsiString;
+function g_ExtractWadNameNoPath (resourceStr: AnsiString): AnsiString;
+function g_ExtractFilePath (resourceStr: AnsiString): AnsiString;
+function g_ExtractFileName (resourceStr: AnsiString): AnsiString; // without path
+function g_ExtractFilePathName (resourceStr: AnsiString): AnsiString;
// return fixed AnsiString or empty AnsiString
function findDiskWad (fname: AnsiString): AnsiString;
end;
-procedure g_ProcessResourceStr (ResourceStr: AnsiString; var FileName, SectionName, ResourceName: AnsiString);
+function normSlashes (s: AnsiString): AnsiString;
var
- a, i: Integer;
+ f: Integer;
begin
- //e_WriteLog(Format('g_ProcessResourceStr0: [%s]', [ResourceStr]), MSG_NOTIFY);
- for i := Length(ResourceStr) downto 1 do if ResourceStr[i] = ':' then break;
- FileName := Copy(ResourceStr, 1, i-1);
- for a := i+1 to Length(ResourceStr) do if (ResourceStr[a] = '\') or (ResourceStr[a] = '/') then Break;
- ResourceName := Copy(ResourceStr, a+1, Length(ResourceStr)-Abs(a));
- SectionName := Copy(ResourceStr, i+1, Length(ResourceStr)-Length(ResourceName)-Length(FileName)-2);
+ for f := 1 to length(s) do if s[f] = '\' then s[f] := '/';
+ result := s;
end;
+function g_ExtractWadNameNoPath (resourceStr: AnsiString): AnsiString;
+var
+ f, c: Integer;
+begin
+ for f := length(resourceStr) downto 1 do
+ begin
+ if resourceStr[f] = ':' then
+ begin
+ result := normSlashes(Copy(resourceStr, 1, f-1));
+ c := length(result);
+ while (c > 0) and (result[c] <> '/') do Dec(c);
+ if c > 0 then result := Copy(result, c+1, length(result));
+ exit;
+ end;
+ end;
+ result := '';
+end;
-procedure g_ProcessResourceStr (ResourceStr: AnsiString; FileName, SectionName, ResourceName: PAnsiString);
+function g_ExtractWadName (resourceStr: AnsiString): AnsiString;
var
- a, i, l1, l2: Integer;
+ f: Integer;
begin
- //e_WriteLog(Format('g_ProcessResourceStr1: [%s]', [ResourceStr]), MSG_NOTIFY);
- for i := Length(ResourceStr) downto 1 do if ResourceStr[i] = ':' then break;
- if FileName <> nil then
+ for f := length(resourceStr) downto 1 do
begin
- FileName^ := Copy(ResourceStr, 1, i-1);
- l1 := Length(FileName^);
- end
- else
+ if resourceStr[f] = ':' then
+ begin
+ result := normSlashes(Copy(resourceStr, 1, f-1));
+ exit;
+ end;
+ end;
+ result := '';
+end;
+
+function g_ExtractFilePath (resourceStr: AnsiString): AnsiString;
+var
+ f, lastSlash: Integer;
+begin
+ result := '';
+ lastSlash := -1;
+ for f := length(resourceStr) downto 1 do
begin
- l1 := 0;
+ if (lastSlash < 0) and (resourceStr[f] = '\') or (resourceStr[f] = '/') then lastSlash := f;
+ if resourceStr[f] = ':' then
+ begin
+ if lastSlash > 0 then result := normSlashes(Copy(resourceStr, f, lastSlash-f));
+ exit;
+ end;
end;
- for a := i+1 to Length(ResourceStr) do if (ResourceStr[a] = '\') or (ResourceStr[a] = '/') then break;
- if ResourceName <> nil then
+ if lastSlash > 0 then result := normSlashes(Copy(resourceStr, 1, lastSlash-1));
+end;
+
+function g_ExtractFileName (resourceStr: AnsiString): AnsiString; // without path
+var
+ f, lastSlash: Integer;
+begin
+ result := '';
+ lastSlash := -1;
+ for f := length(resourceStr) downto 1 do
begin
- ResourceName^ := Copy(ResourceStr, a+1, Length(ResourceStr)-Abs(a));
- l2 := Length(ResourceName^);
- end
- else
+ if (lastSlash < 0) and (resourceStr[f] = '\') or (resourceStr[f] = '/') then lastSlash := f;
+ if resourceStr[f] = ':' then
+ begin
+ if lastSlash > 0 then result := Copy(resourceStr, lastSlash+1, length(resourceStr));
+ exit;
+ end;
+ end;
+ if lastSlash > 0 then result := Copy(resourceStr, lastSlash+1, length(resourceStr));
+end;
+
+function g_ExtractFilePathName (resourceStr: AnsiString): AnsiString;
+var
+ f: Integer;
+begin
+ result := '';
+ for f := length(resourceStr) downto 1 do
begin
- l2 := 0;
+ if resourceStr[f] = ':' then
+ begin
+ result := normSlashes(Copy(resourceStr, f+1, length(resourceStr)));
+ exit;
+ end;
end;
- if SectionName <> nil then SectionName^ := Copy(ResourceStr, i+1, Length(ResourceStr)-l2-l1-2);
end;
+
{ TWADFile }
constructor TWADFile.Create();
begin
result := s;
end;
-function TWADFile.GetResource (Section, Resource: AnsiString; var pData: Pointer; var Len: Integer): Boolean;
+function TWADFile.GetResource (name: AnsiString; var pData: Pointer; var Len: Integer): Boolean;
var
- f: Integer;
+ f, lastSlash: Integer;
fi: TSFSFileInfo;
fs: TStream;
fpp: Pointer;
+ rpath, rname: AnsiString;
//fn: AnsiString;
begin
Result := False;
if not isOpen or (fIter = nil) then Exit;
- if length(Resource) = 0 then Exit; // just in case
- if (length(Section) <> 0) and (Section[length(Section)] <> '/') then Section := Section+'/';
+ rname := removeExt(name);
+ if length(rname) = 0 then Exit; // just in case
+ lastSlash := -1;
+ for f := 1 to length(rname) do
+ begin
+ if rname[f] = '\' then rname[f] := '/';
+ if rname[f] = '/' then lastSlash := f;
+ end;
+ if lastSlash > 0 then
+ begin
+ rpath := Copy(rname, 1, lastSlash);
+ Delete(rname, 1, lastSlash);
+ end
+ else
+ begin
+ rpath := '';
+ end;
// backwards, due to possible similar names and such
for f := fIter.Count-1 downto 0 do
begin
fi := fIter.Files[f];
if fi = nil then continue;
//e_WriteLog(Format('DFWAD: searching for [%s : %s] in [%s]; current is [%s : %s]', [Section, Resource, fFileName, fi.path, fi.name]), MSG_NOTIFY);
- if StrEquCI1251(fi.path, Section) and StrEquCI1251(removeExt(fi.name), Resource) then
+ if StrEquCI1251(fi.path, rpath) and StrEquCI1251(removeExt(fi.name), rname) then
begin
// i found her!
//fn := fFileName+'::'+fi.path+fi.name;
end;
if fs = nil then
begin
- e_WriteLog(Format('DFWAD: can''t open file [%s%s] in [%s]', [Section, Resource, fFileName]), MSG_WARNING);
+ e_WriteLog(Format('DFWAD: can''t open file [%s] in [%s]', [name, fFileName]), MSG_WARNING);
break;
end;
Len := Integer(fs.size);
result := true;
{$IFDEF SFS_DWFAD_DEBUG}
if gSFSDebug then
- e_WriteLog(Format('DFWAD: file [%s%s] FOUND in [%s]; size is %d bytes', [Section, Resource, fFileName, Len]), MSG_NOTIFY);
+ e_WriteLog(Format('DFWAD: file [%s] FOUND in [%s]; size is %d bytes', [name, fFileName, Len]), MSG_NOTIFY);
{$ENDIF}
exit;
end;
end;
- e_WriteLog(Format('DFWAD: file [%s%s] not found in [%s]', [Section, Resource, fFileName]), MSG_WARNING);
+ e_WriteLog(Format('DFWAD: file [%s] not found in [%s]', [name, fFileName]), MSG_WARNING);
end;
-function TWADFile.GetResourcesList (Section: AnsiString): SArray;
+function TWADFile.GetRootResources (): SArray;
var
f: Integer;
fi: TSFSFileInfo;
begin
Result := nil;
if not isOpen or (fIter = nil) then Exit;
- if (length(Section) <> 0) and (Section[length(Section)] <> '/') then Section := Section+'/';
for f := 0 to fIter.Count-1 do
begin
fi := fIter.Files[f];
if fi = nil then continue;
if length(fi.name) = 0 then continue;
- if StrEquCI1251(fi.path, Section) then
+ if length(fi.path) = 0 then
begin
SetLength(result, Length(result)+1);
result[high(result)] := removeExt(fi.name);