Skip to content

WIP mod support#1313

Open
Vagabond wants to merge 40 commits intomasterfrom
adt/mod-support
Open

WIP mod support#1313
Vagabond wants to merge 40 commits intomasterfrom
adt/mod-support

Conversation

@Vagabond
Copy link
Member

@Vagabond Vagabond commented Sep 22, 2025

Things to do:

  • Require a mod manifest in each zip file
  • Either do not load mods in netplay mode, or load only cosmetic changes (would require retaining original sprites for compatible collision detection)
  • Fix all the memory leaks
  • Support for replacing sound samples
  • Support for sprite information like collision coordinates, offsets and index reuse
  • Support for wholly new tournaments
  • Support for wholly new animations
  • Support for wholly new sprites (adding frames to an animation)
  • Support for tournament pilot photos/logos to be higher resolution
  • Switch from file IDs to filenames (eg scene_id 8 -> "ARENA0", har_id 1 -> "FIGHTR1")
  • unify with https://www.omf2097.com/wiki/doku.php?id=openomf:openomf_mod_folder_structure

Depends on #1312 to properly display high-res assets.

@Vagabond
Copy link
Member Author

I'm going to start prepping this for review, I am going to punt all the remaining tasks to future PRs, the only bug remaining I intend to fix is that there's a problem with pilot portrait alignment in tournament matches.

@Vagabond Vagabond marked this pull request as ready for review February 13, 2026 14:29
@katajakasa
Copy link
Member

"Prevent most mod assets loading during netplay" -- most. What is allowed ?

unsigned long long entry_size = zip_entry_uncomp_size(zip);
void *entry_buf = omf_calloc(entry_size, 1);
if(zip_entry_noallocread(zip, entry_buf, entry_size) < 0) {
log_warn("failed to load %s into memory", zip_entry_name(zip));
Copy link
Member

Choose a reason for hiding this comment

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

continue;

?

}

str filename;
str_from_format(&filename, "tournaments/%s/tournament.ini", tournament_name);
Copy link
Member

Choose a reason for hiding this comment

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

str_free() seems to be missing before the next call to str_from_format

// For arenas, check for 'common' for anim_ids 6 (round), 7 (number), 8 (you lose), 9 (you win), 10 (fight),
// 11 (ready), 24 (dust 1), 25 (dust 2), 26 (dust 3), 27 (match counters)

str_from_format(&filename, "scenes/common/%d/animdata.ini", anim_id);
Copy link
Member

Choose a reason for hiding this comment

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

matching str_free() missing


if(!allow_transparency && trans) {
log_error("PNG contained transparent pixels");
return false;
Copy link
Member

Choose a reason for hiding this comment

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

I think this leaks png_ptr and info_ptr

png_destroy_read_struct(&png_ptr, &info_ptr, NULL);


// Convert
af_create(a, &tmp);
af_create(a, &tmp, &fn);
Copy link
Member

Choose a reason for hiding this comment

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

str_free(fn)


// Convert
bk_create(b, &tmp);
bk_create(b, &tmp, &fn);
Copy link
Member

Choose a reason for hiding this comment

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

str_free(fn)

unsigned char *buf;
size_t len;
// check the modmanager here for a music mod
path_stem(&music, &fn);
Copy link
Member

Choose a reason for hiding this comment

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

str_free(fn)

unsigned int count = list_size(l);
log_info("found %d music files for %s", count, name);
if(index >= count) {
log_warn("requested index %s into list of %d members", index, count);
Copy link
Member

Choose a reason for hiding this comment

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

... index %d into list ...

#include <confuse.h>

#define UPDATE_FIELD_INT(field_name, struct_field, new_value) \
if(new_value != 0 && struct_field != new_value) { \
Copy link
Member

Choose a reason for hiding this comment

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

btw, I guess this means that mods cannot set field values intentionally to 0, ever ? Is that okay ?

Copy link
Member

Choose a reason for hiding this comment

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

Same for floats, I suppose

if(!hashmap_get_str(&mod_resources, str_c(&filename), (void **)&obuf, &len)) {
assert(obuf->type == MOD_SPRITE);
log_info("found portrait for pilot %d in %s", pilot_id, trn_name);
// omf_free(pilot_data->photo);
Copy link
Member

Choose a reason for hiding this comment

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

leak ?

@Vagabond
Copy link
Member Author

"Prevent most mod assets loading during netplay" -- most. What is allowed ?

music and arena backgrounds right now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants