Skip to content

Commit 8f3ef45

Browse files
author
Goober5000
committed
don't remove invisible beam sections
1 parent 762997f commit 8f3ef45

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

code/weapon/weapons.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2337,12 +2337,8 @@ int parse_weapon(int subtype, bool replace, const char *filename)
23372337
if ( optional_string("+Texture:") ) {
23382338
stuff_string(fname, F_NAME, NAME_LENGTH);
23392339

2340-
// invisible textures are okay
2341-
if (!stricmp(fname, "invisible")) {
2342-
generic_anim_init(&bsip->texture);
2343-
} else {
2344-
generic_anim_init(&bsip->texture, fname);
2345-
}
2340+
// invisible textures are okay - see weapon_clean_entries()
2341+
generic_anim_init(&bsip->texture, fname);
23462342
}
23472343

23482344
// The E -- Dummied out due to not being used anywhere
@@ -3081,7 +3077,15 @@ void weapon_clean_entries()
30813077
int removed = 0;
30823078

30833079
for (int s_idx = 0; s_idx < wip->b_info.beam_num_sections; s_idx++) {
3084-
if ( !strlen(wip->b_info.sections[s_idx].texture.filename) ) {
3080+
beam_weapon_section_info *bsip = &wip->b_info.sections[s_idx];
3081+
3082+
// If this is an invisible beam section, we want to keep it. Originally invisible sections were initialized as they were parsed,
3083+
// but then they were inadvertently cleaned up in this function. So let's properly set the filename here while not removing the section.
3084+
if ( !stricmp(bsip->texture.filename, "invisible") ) {
3085+
memset(bsip->texture.filename, 0, MAX_FILENAME_LEN);
3086+
}
3087+
// Now remove empty beam sections as before
3088+
else if ( !strlen(bsip->texture.filename) ) {
30853089
int new_idx = s_idx + 1;
30863090

30873091
while (new_idx < MAX_BEAM_SECTIONS) {
@@ -3097,6 +3101,10 @@ void weapon_clean_entries()
30973101
mprintf(("NOTE: weapon-cleanup is removing %i stale beam sections, out of %i original, from '%s'.\n", removed, wip->b_info.beam_num_sections, wip->name));
30983102
wip->b_info.beam_num_sections -= removed;
30993103
}
3104+
3105+
if (wip->b_info.beam_num_sections == 0) {
3106+
Warning(LOCATION, "The beam '%s' has 0 usable sections!", wip->name);
3107+
}
31003108
}
31013109
}
31023110
}

0 commit comments

Comments
 (0)