Skip to content

Fix incorrect format specifier usage in obj_examine_func() - #187

Open
dje4321 wants to merge 1 commit into
alexbatalov:mainfrom
dje4321:protinst-snprintf
Open

Fix incorrect format specifier usage in obj_examine_func()#187
dje4321 wants to merge 1 commit into
alexbatalov:mainfrom
dje4321:protinst-snprintf

Conversation

@dje4321

@dje4321 dje4321 commented May 21, 2024

Copy link
Copy Markdown

Fixes #162

obj_examine_func():408-424 has a redundant format specifier. v66 provides a "%s %s" format specifier for objects v63 && hpMessageListItem, however v63 already provides a format specifier in the form of "GENDER looks: %s" for use by hpMessageListItem. Technically the most correct fix is to use v63 to create a secondary format specifier like how src/game/protinst.cc:314 does it, However it is my belief that this will cause a regression if the target is not crippled because MSG_ID 521 is "%s %s." which will append a secondary period onto the end of the string.

Modifed obj_examine_func() comments for added clarity

obj_examine_func():408-424 has a redundant format specifier. v66 provides a "%s %s" format specifier for objects v63 && hpMessageListItem,
however v63 already provides a format specifier in the form of "GENDER looks: %s" for use by hpMessageListItem. Technically the most correct
fix is to use v63 to create a secondary format specifier like how src/game/protinst.cc:314 does it, However it is my belief that this will
cause a regression if the target is not crippled because MSG_ID 521 is "%s %s." which will append a secondary period onto the end of the string.

Modifed obj_examine_func() comments for added clarity
@dje4321 dje4321 changed the title Fixes issue #162 Fix incorrect format specifier usage in obj_examine_func() May 21, 2024
Comment thread src/game/protinst.cc
// 522: He looks: %s.
// 523: She looks: %s.
// 524: It looks: %s.
v63.num = 522 + stat_level(target, STAT_GENDER);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

you can add a check here for critter_body_type(target) != BODY_TYPE_BIPED and then set num to 524 - "It looks: %s." See example above at line 280 of unmodified file.

Comment thread src/game/protinst.cc
snprintf(formattedText, sizeof(formattedText), v66.text, hpMessageListItem.text);
} else {
// %s %s
v66.num = 521 + v12;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I've found no correct way to use messages 521 - %s %s. and 519 - %s %s .
Seems like the first %s is for He/She/It looks: and the second %s is for examine text hpMessageListItem, but the messages file doesn't have separate messages for the first one - only with format parameter and a dot.
So, I think, without changing messages file it is not possible to correctly format the text taking into account if the critter is crippled or not.

The version of Fallout that is delivered through Xbox app has the same functionality as your fix.

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.

[linux] Combat messages show %s character

2 participants