summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: b53135a)
raw | patch | inline | side by side (parent: b53135a)
author | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sun, 17 Apr 2016 08:49:58 +0000 (11:49 +0300) | ||
committer | Ketmar Dark <ketmar@ketmar.no-ip.org> | |
Sun, 17 Apr 2016 08:51:28 +0000 (11:51 +0300) |
src/game/g_map.pas | patch | blob | history |
diff --git a/src/game/g_map.pas b/src/game/g_map.pas
index 584a88f2b637679b28d719d0def9c9d38cfe6e42..de8bc5baae5f0f60e350bc020db24bc15859eb2e 100644 (file)
--- a/src/game/g_map.pas
+++ b/src/game/g_map.pas
Result := len;
end;
-procedure CreateNullTexture(RecName: String);
+function CreateNullTexture(RecName: String): Integer;
begin
SetLength(Textures, Length(Textures)+1);
+ result := High(Textures);
with Textures[High(Textures)] do
begin
end;
end;
-function CreateTexture(RecName: String; Map: string; log: Boolean): Boolean;
+function CreateTexture(RecName: String; Map: string; log: Boolean): Integer;
var
WAD: TWADEditor_1;
TextureData: Pointer;
TextureName: String;
a, ResLength: Integer;
begin
- Result := False;
+ Result := -1;
if Textures <> nil then
for a := 0 to High(Textures) do
if Textures[a].TextureName = RecName then
begin // Òåêñòóðà ñ òàêèì èìåíåì óæå åñòü
- Result := True;
+ Result := a;
Exit;
end;
Anim := False;
end;
- Result := True;
+ result := High(Textures);
Exit;
end;
Textures[High(Textures)].TextureName := RecName;
Textures[High(Textures)].Anim := False;
- Result := True;
+ result := High(Textures);
end
else // Íåò òàêîãî ðåóñðñà â WAD'å
if log then
WAD.Free();
end;
-function CreateAnimTexture(RecName: String; Map: string; log: Boolean): Boolean;
+function CreateAnimTexture(RecName: String; Map: string; log: Boolean): Integer;
var
WAD: TWADEditor_1;
TextureWAD: Pointer;
_width, _height, _framecount, _speed: Integer;
_backanimation: Boolean;
begin
- Result := False;
+ Result := -1;
// ×èòàåì WAD-ðåñóðñ àíèì.òåêñòóðû èç WAD'à â ïàìÿòü:
g_ProcessResourceStr(RecName, WADName, SectionName, TextureName);
FramesCount := _framecount;
Speed := _speed;
- Result := True;
+ result := High(Textures);
end
else
if log then
MapReader: TMapReader_1;
Header: TMapHeaderRec_1;
_textures: TTexturesRec1Array;
+ _texnummap: array of Integer; // `_textures` -> `Textures`
panels: TPanelsRec1Array;
items: TItemsRec1Array;
monsters: TMonsterRec1Array;
Data: Pointer;
Len: Integer;
ok, isAnim, trigRef: Boolean;
- CurTex: Integer;
+ CurTex, ntn: Integer;
begin
Result := False;
gMapInfo.Map := Res;
// Çàãðóçêà òåêñòóð:
g_Game_SetLoadingText(_lc[I_LOAD_TEXTURES], 0, False);
_textures := MapReader.GetTextures();
+ _texnummap := nil;
// Äîáàâëåíèå òåêñòóð â Textures[]:
if _textures <> nil then
begin
e_WriteLog(' Loading textures:', MSG_NOTIFY);
g_Game_SetLoadingText(_lc[I_LOAD_TEXTURES], High(_textures), False);
+ SetLength(_texnummap, length(_textures));
for a := 0 to High(_textures) do
begin
SetLength(s, b-1);
Break;
end;
- e_WriteLog(' Loading texture: ' + s, MSG_NOTIFY);
+ e_WriteLog(Format(' Loading texture #%d: %s', [a, s]), MSG_NOTIFY);
+ //if g_Map_IsSpecialTexture(s) then e_WriteLog(' SPECIAL!', MSG_NOTIFY);
// Àíèìèðîâàííàÿ òåêñòóðà:
if ByteBool(_textures[a].Anim) then
begin
- if not CreateAnimTexture(_textures[a].Resource, FileName, True) then
+ ntn := CreateAnimTexture(_textures[a].Resource, FileName, True);
+ if ntn < 0 then
begin
g_SimpleError(Format(_lc[I_GAME_ERROR_TEXTURE_ANIM], [s]));
- CreateNullTexture(_textures[a].Resource);
+ ntn := CreateNullTexture(_textures[a].Resource);
end;
end
else // Îáû÷íàÿ òåêñòóðà:
- if not CreateTexture(_textures[a].Resource, FileName, True) then
+ ntn := CreateTexture(_textures[a].Resource, FileName, True);
+ if ntn < 0 then
begin
g_SimpleError(Format(_lc[I_GAME_ERROR_TEXTURE_SIMPLE], [s]));
- CreateNullTexture(_textures[a].Resource);
+ ntn := CreateNullTexture(_textures[a].Resource);
end;
+ _texnummap[a] := ntn; // fix texture number
g_Game_StepLoading();
end;
end;
g_Game_SetLoadingText(_lc[I_LOAD_PANELS], 0, False);
panels := MapReader.GetPanels();
+ // check texture numbers for panels
+ for a := 0 to High(panels) do
+ begin
+ if panels[a].TextureNum > High(_textures) then
+ begin
+ e_WriteLog('error loading map: invalid texture index for panel', MSG_FATALERROR);
+ result := false;
+ exit;
+ end;
+ panels[a].TextureNum := _texnummap[panels[a].TextureNum];
+ end;
+
// Ñîçäàíèå òàáëèöû òðèããåðîâ (ñîîòâåòñòâèå ïàíåëåé òðèããåðàì):
if triggers <> nil then
begin
if ByteBool(texture.Anim) then
begin // Íà÷àëüíàÿ - àíèìèðîâàííàÿ, èùåì àíèìèðîâàííóþ
isAnim := True;
- ok := CreateAnimTexture(TexName, FileName, False);
+ ok := CreateAnimTexture(TexName, FileName, False) >= 0;
if not ok then
begin // Íåò àíèìèðîâàííîé, èùåì îáû÷íóþ
isAnim := False;
- ok := CreateTexture(TexName, FileName, False);
+ ok := CreateTexture(TexName, FileName, False) >= 0;
end;
end
else
begin // Íà÷àëüíàÿ - îáû÷íàÿ, èùåì îáû÷íóþ
isAnim := False;
- ok := CreateTexture(TexName, FileName, False);
+ ok := CreateTexture(TexName, FileName, False) >= 0;
if not ok then
begin // Íåò îáû÷íîé, èùåì àíèìèðîâàííóþ
isAnim := True;
- ok := CreateAnimTexture(TexName, FileName, False);
+ ok := CreateAnimTexture(TexName, FileName, False) >= 0;
end;
end;
CurTex := 0;
end;
+ //e_WriteLog(Format('panel #%d: TextureNum=%d; ht=%d; ht1=%d; atl=%d', [a, panels[a].TextureNum, High(_textures), High(Textures), High(AddTextures)]), MSG_NOTIFY);
+
// Ñîçäàåì ïàíåëü è çàïîìèíàåì åå íîìåð:
PanelID := CreatePanel(panels[a], AddTextures, CurTex, trigRef);