summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 93f620d)
raw | patch | inline | side by side (parent: 93f620d)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sun, 20 Oct 2019 23:40:49 +0000 (02:40 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sun, 20 Oct 2019 23:41:32 +0000 (02:41 +0300) |
diff --git a/src/engine/e_res.pas b/src/engine/e_res.pas
index e2f888955076063cf022a58d1c3bda40b2be01ce..a4f9da50bd829c9fc28605d850bd0b60df8e12f7 100644 (file)
--- a/src/engine/e_res.pas
+++ b/src/engine/e_res.pas
function e_FindResource (dirs: SSArray; var name: AnsiString; nameIsDir: Boolean = false): Boolean;
function e_FindWad (dirs: SSArray; name: AnsiString): AnsiString;
+ {--- returns relative wad name; never empty string ---}
+ function e_FindWadRel (dirs: SSArray; name: AnsiString): AnsiString;
+
{--- append dirs to 'path.wad:\file'. if disk is void, append defWad ---}
function e_GetResourcePath (dirs: SSArray; path: AnsiString; defWad: AnsiString): AnsiString;
end
end;
+ function e_FindWadRel (dirs: SSArray; name: AnsiString): AnsiString;
+ var
+ s: AnsiString;
+ maxpfx: AnsiString = '';
+ pfx: AnsiString;
+ begin
+ result := name;
+ if not findFileCI(name) then exit;
+ for s in dirs do
+ begin
+ if (length(s) = 0) then continue;
+ if (length(name) <= length(s)) then continue;
+ if (length(s) < length(maxpfx)) then continue;
+ pfx := s;
+ if not findFileCI(pfx, true) then continue;
+ if (pfx[length(pfx)] <> '/') and (pfx[length(pfx)] <> '\') then pfx := pfx+'/';
+ if (length(pfx)+1 > length(name)) then continue;
+ if (strEquCI1251(copy(name, 1, length(pfx)), pfx)) then maxpfx := pfx;
+ end;
+ if (length(maxpfx) > 0) then
+ begin
+ result := name;
+ Delete(result, 1, length(maxpfx));
+ end;
+ end;
+
function e_GetResourcePath (dirs: SSArray; path: AnsiString; defWad: AnsiString): AnsiString;
var diskName, fileName: AnsiString;
begin
diff --git a/src/game/g_game.pas b/src/game/g_game.pas
index 6564a23464337389d03aa98db59c0c0ee65623c8..ec7f8f29831e03151a1da5bf2f1227a134d51964 100644 (file)
--- a/src/game/g_game.pas
+++ b/src/game/g_game.pas
procedure g_Game_RestartRound(NoMapRestart: Boolean = False);
function g_Game_ClientWAD (NewWAD: String; const WHash: TMD5Digest): AnsiString;
procedure g_Game_SaveOptions();
-function g_Game_StartMap(Map: String; Force: Boolean = False; const oldMapPath: AnsiString=''): Boolean;
+function g_Game_StartMap(asMegawad: Boolean; Map: String; Force: Boolean = False; const oldMapPath: AnsiString=''): Boolean;
procedure g_Game_ChangeMap(const MapPath: String);
procedure g_Game_ExitLevel(const Map: AnsiString);
function g_Game_GetFirstMap(WAD: String): String;
end;
// Çàãðóçêà è çàïóñê êàðòû:
- if not g_Game_StartMap(MAP, True) then
+ if not g_Game_StartMap(false{asMegawad}, MAP, True) then
begin
if (Pos(':\', Map) > 0) or (Pos(':/', Map) > 0) then tmps := Map else tmps := gGameSettings.WAD + ':\' + MAP;
g_FatalError(Format(_lc[I_GAME_ERROR_MAP_LOAD], [tmps]));
end;
// Çàãðóçêà è çàïóñê êàðòû:
- if not g_Game_StartMap(Map, True) then
+ if not g_Game_StartMap(true{asMegawad}, Map, True) then
begin
g_FatalError(Format(_lc[I_GAME_ERROR_MAP_LOAD], [Map]));
Exit;
g_Net_Slist_ServerStarted();
// Çàãðóçêà è çàïóñê êàðòû:
- if not g_Game_StartMap(Map, True) then
+ if not g_Game_StartMap(false{asMegawad}, Map, True) then
begin
g_Net_Slist_ServerClosed();
g_FatalError(Format(_lc[I_GAME_ERROR_MAP_LOAD], [Map]));
gPlayer1.UID := NetPlrUID1;
gPlayer1.Reset(True);
- if not g_Game_StartMap(newResPath + ':\' + Map, True) then
+ if not g_Game_StartMap(false{asMegawad}, newResPath + ':\' + Map, True) then
begin
g_FatalError(Format(_lc[I_GAME_ERROR_MAP_LOAD], [WadName + ':\' + Map]));
e_LogWritefln('unable to find or create directory for configs', []);
end;
+var
+ lastAsMegaWad: Boolean = false;
+
procedure g_Game_ChangeMap(const MapPath: String);
var
Force: Boolean;
Force := False;
gExitByTrigger := False;
end;
- if not g_Game_StartMap(MapPath, Force) then
+ if not g_Game_StartMap(lastAsMegaWad, MapPath, Force) then
g_FatalError(Format(_lc[I_GAME_ERROR_MAP_LOAD], [MapPath]));
end;
MessageTime := 0;
gGameOn := False;
g_Game_ClearLoading();
- g_Game_StartMap(Map, True, gCurrentMapFileName);
+ g_Game_StartMap(lastAsMegaWad, Map, True, gCurrentMapFileName);
end;
-function g_Game_StartMap(Map: String; Force: Boolean = False; const oldMapPath: AnsiString=''): Boolean;
+function g_Game_StartMap (asMegawad: Boolean; Map: String; Force: Boolean = False; const oldMapPath: AnsiString=''): Boolean;
var
NewWAD, ResName: String;
I: Integer;
g_Player_ResetTeams();
+ lastAsMegaWad := asMegawad;
if isWadPath(Map) then
begin
NewWAD := g_ExtractWadName(Map);
begin
nws := findDiskWad(NewWAD);
//writeln('000: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
- if (length(nws) = 0) then nws := e_FindWad(MapDirs, NewWAD);
+ if (asMegawad) then
+ begin
+ if (length(nws) = 0) then nws := e_FindWad(MegawadDirs, NewWAD);
+ if (length(nws) = 0) then nws := e_FindWad(MapDirs, NewWAD);
+ end
+ else
+ begin
+ if (length(nws) = 0) then nws := e_FindWad(MapDirs, NewWAD);
+ if (length(nws) = 0) then nws := e_FindWad(MegawadDirs, NewWAD);
+ end;
+ //if (length(nws) = 0) then nws := e_FindWad(MapDownloadDirs, NewWAD);
//writeln('001: Map=[', Map, ']; nws=[', nws, ']; NewWAD=[', NewWAD, ']');
//nws := NewWAD;
if (length(nws) = 0) then
diff --git a/src/game/g_menu.pas b/src/game/g_menu.pas
index d808bf3bdc446bef705d698b86ea094b74892a6d..72a5c8ceeb16317cfbaf60d737cd667dcb8726d1 100644 (file)
--- a/src/game/g_menu.pas
+++ b/src/game/g_menu.pas
WAD := TGUIFileListBox(GetControl('lsWAD')).SelectedItem();
TwoPlayers := TGUISwitch(GetControl('swPlayers')).ItemIndex = 1;
end;
+ WAD := e_FindWadRel(MegawadDirs, WAD);
if TwoPlayers then
n := 2
if (wad = '') or (map = '') then
Exit;
+ wad := e_FindWadRel(MapDirs, WAD);
+
res := wad+':\'+map;
TGUILabel(TGUIMenu(g_GUI_GetWindow('CustomGameMenu').GetControl('mCustomGameMenu')).GetControl('lbMap')).Text := res;
diff --git a/src/game/g_netmsg.pas b/src/game/g_netmsg.pas
index aec47c7ff524d3c16de2bc4da6f2e9ea350f2172..484f8bb2d0641fd8e131b552a50f92bf6df82eda 100644 (file)
--- a/src/game/g_netmsg.pas
+++ b/src/game/g_netmsg.pas
gGameSettings.GameMode := gSwitchGameMode;
gWADHash := EvHash;
- if not g_Game_StartMap(EvStr, True) then
+ if not g_Game_StartMap(false{asMegawad}, EvStr, True) then
begin
if not isWadPath(EvStr) then
g_FatalError(Format(_lc[I_GAME_ERROR_MAP_LOAD], [gGameSettings.WAD + ':\' + EvStr]))
index 4e5697465bfc8b8c42ede7cc174ebc3e2dc07742..09f5076c9b919fc95d9f96a09f672f20193bc24b 100644 (file)
--- a/src/game/g_saveload.pas
+++ b/src/game/g_saveload.pas
g_Game_SetupScreenSize();
// Çàãðóçêà è çàïóñê êàðòû
- if not g_Game_StartMap(WAD_Path+':\'+Map_Name, True, curmapfile) then
+ //FIXME: save/load `asMegawad`
+ if not g_Game_StartMap(false{asMegawad}, WAD_Path+':\'+Map_Name, True, curmapfile) then
begin
g_FatalError(Format(_lc[I_GAME_ERROR_MAP_LOAD], [WAD_Path + ':\' + Map_Name]));
exit;