Skip to content

Refactor player-set-target SEXP#7393

Open
LuytenFS wants to merge 1 commit intoscp-fs2open:masterfrom
LuytenFS:refactor-player-target-sexp
Open

Refactor player-set-target SEXP#7393
LuytenFS wants to merge 1 commit intoscp-fs2open:masterfrom
LuytenFS:refactor-player-target-sexp

Conversation

@LuytenFS
Copy link
Copy Markdown
Contributor

Based on prior feedback from @Goober5000, I've revisited this feature to address the following:

  1. the sexp implementation uses ship_name_lookup, but eval_ship would take advantage of the ship registry (faster lookup that comes with handling of non-present states) and would also cache the ship in the sexp node
  2. last_targeted_subobject shouldn't be used; the sexp implementation should explicitly set the subsystem (as it does in the clearing sexp) without using hacks

However I should address the line:

    // set_target_objnum will call hud_restore_subsystem_target which reads last_targeted_subobject
    shipp->last_targeted_subobject[Player_num] = new_subsys;

HUD code still reads ship::last_targeted_subobject instead of Player_ai->targeted_subsys I think am not sure, so SEXPs have to write it as a hack. Needs HUD‑side fix so hud_restore_subsystem_target uses targeted_subsys; then last_targeted_subobject can be removed from SEXP logic. I'd have to say that this is an assumption.

@wookieejedi wookieejedi added cleanup A modification or rewrite of code to make it more understandable or easier to maintain. sexps A feature or issue related to SEXPs labels Apr 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cleanup A modification or rewrite of code to make it more understandable or easier to maintain. sexps A feature or issue related to SEXPs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants