Skip to content

Commit

Permalink
Don't read IWAD's TEXTURE lump unless specified
Browse files Browse the repository at this point in the history
  • Loading branch information
Voros2 authored Jul 29, 2017
1 parent 89ef343 commit 80ba7ee
Showing 1 changed file with 22 additions and 16 deletions.
38 changes: 22 additions & 16 deletions src/compose.c
Original file line number Diff line number Diff line change
Expand Up @@ -272,17 +272,19 @@ void CMPOmakePWAD(const char *doomwad, WADTYPE type, const char *PWADname,
** read texture1
*/
if (select & BTEXTUR) {
FoundOne = false;
if (TXTseekSection(TXT, "TEXTURE1")) {
Phase("CM50", "Making TEXTURE1");
TXUinit();
entry = WADRfindEntry(&iwad, "TEXTURE1");
if (entry >= 0) {
EntryP = WADRreadEntry(&iwad, entry, &EntrySz);
TXUreadTEXTURE("TEXTURE1", EntryP, EntrySz, NULL, 0, true);
free(EntryP);
} else
Warning("CM51", "Can't find TEXTURE1 in main WAD");
FoundOne = false;
if (Type == IWAD) {
entry = WADRfindEntry(&iwad, "TEXTURE1");
if (entry >= 0) {
EntryP = WADRreadEntry(&iwad, entry, &EntrySz);
TXUreadTEXTURE("TEXTURE1", EntryP, EntrySz, NULL, 0, true);
free(EntryP);
} else
Warning("CM51", "Can't find TEXTURE1 in main WAD");
} else {
/*read TEXTURES composing TEXTURE1 */
while (TXTentryParse
(name, filenam, &X, &Y, &Repeat, TXT, false) == true) {
Expand Down Expand Up @@ -310,6 +312,7 @@ void CMPOmakePWAD(const char *doomwad, WADTYPE type, const char *PWADname,
WADRclose(&pwad);
} else
ProgError("CM54", "Can't find texture list %s", file);
}
}
/*write texture */
if (FoundOne == true) {
Expand All @@ -325,17 +328,19 @@ void CMPOmakePWAD(const char *doomwad, WADTYPE type, const char *PWADname,
** read texture2
*/
if (select & BTEXTUR) {
FoundOne = false;
if (TXTseekSection(TXT, "TEXTURE2")) {
Phase("CM55", "Making TEXTURE2");
TXUinit();
entry = WADRfindEntry(&iwad, "TEXTURE2");
if (entry >= 0) {
EntryP = WADRreadEntry(&iwad, entry, &EntrySz);
TXUreadTEXTURE("TEXTURE2", EntryP, EntrySz, NULL, 0, true);
free(EntryP);
} else
Warning("CM56", "Can't find TEXTURE2 in main WAD");
FoundOne = false;
if (Type == IWAD) {
entry = WADRfindEntry(&iwad, "TEXTURE2");
if (entry >= 0) {
EntryP = WADRreadEntry(&iwad, entry, &EntrySz);
TXUreadTEXTURE("TEXTURE2", EntryP, EntrySz, NULL, 0, true);
free(EntryP);
} else
Warning("CM56", "Can't find TEXTURE2 in main WAD");
} else {
/*read TEXTURES composing TEXTURE2 */
while (TXTentryParse
(name, filenam, &X, &Y, &Repeat, TXT, false) == true) {
Expand Down Expand Up @@ -363,6 +368,7 @@ void CMPOmakePWAD(const char *doomwad, WADTYPE type, const char *PWADname,
WADRclose(&pwad);
} else
ProgError("CM59", "Can't find texture list %s", file);
}
}
/*write texture */
if (FoundOne == true) {
Expand Down

4 comments on commit 80ba7ee

@fragglet
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic here looks backwards to me. The point is that when an IWAD is being built, any TEXTURE* lumps from an existing IWAD ought to be ignored.

But I also question whether this is the right approach. As @chungy comments in Doom-Utils#7, ideally deutex shouldn't require an existing IWAD at all when building an IWAD. If that part can be fixed, perhaps the "importing textures from IWAD" part of the problem resolves itself naturally.

@Voros2
Copy link
Owner Author

@Voros2 Voros2 commented on 80ba7ee Jul 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In line 557 of deutex.c, -iwad sets Type to IWAD instead of the default PWAD. So essentially, checking if Type == IWAD is basically the same as checking if -iwad is true. Or maybe I'm missing something?

@fragglet
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IWAD textures should only be inspected when a PWAD is being built, not when an IWAD is being built.

@Voros2
Copy link
Owner Author

@Voros2 Voros2 commented on 80ba7ee Jul 30, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:P I mistakenly wrote IWAD instead of PWAD. For some reason I assumed I was using != instead of == (9f7c847) should make sense.

Please sign in to comment.