-
Notifications
You must be signed in to change notification settings - Fork 150
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix incorrect format specifier usage in obj_examine_func() #187
Open
dje4321
wants to merge
1
commit into
alexbatalov:main
Choose a base branch
from
dje4321:protinst-snprintf
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -254,6 +254,7 @@ int obj_examine_func(Object* critter, Object* target, void (*fn)(char* string)) | |
|
||
if (description == NULL || *description == '\0') { | ||
MessageListItem messageListItem; | ||
// 493: You see nothing out of the ordinary. | ||
messageListItem.num = 493; | ||
if (!message_search(&proto_main_msg_file, &messageListItem)) { | ||
debug_printf("\nError: Can't find msg num!"); | ||
|
@@ -278,11 +279,12 @@ int obj_examine_func(Object* critter, Object* target, void (*fn)(char* string)) | |
MessageListItem hpMessageListItem; | ||
|
||
if (critter_body_type(target) != BODY_TYPE_BIPED) { | ||
// It has %d/%d hps | ||
// 537: It has %d/%d hps | ||
hpMessageListItem.num = 537; | ||
} else { | ||
// 535: He has %d/%d hps | ||
// 536: She has %d/%d hps | ||
// 537: It has %d/%d hps (GENDER_COUNT) | ||
hpMessageListItem.num = 535 + stat_level(target, STAT_GENDER); | ||
} | ||
|
||
|
@@ -300,9 +302,11 @@ int obj_examine_func(Object* critter, Object* target, void (*fn)(char* string)) | |
MessageListItem weaponMessageListItem; | ||
|
||
if (item_w_caliber(item2) != 0) { | ||
weaponMessageListItem.num = 547; // and is wielding a %s with %d/%d shots of %s. | ||
// 547: and is wielding a %s with %d/%d shots of %s. | ||
weaponMessageListItem.num = 547; | ||
} else { | ||
weaponMessageListItem.num = 546; // and is wielding a %s. | ||
// 546: and is wielding a %s. | ||
weaponMessageListItem.num = 546; | ||
} | ||
|
||
if (!message_search(&proto_main_msg_file, &weaponMessageListItem)) { | ||
|
@@ -343,9 +347,11 @@ int obj_examine_func(Object* critter, Object* target, void (*fn)(char* string)) | |
MessageListItem endingMessageListItem; | ||
|
||
if (critter_is_crippled(target)) { | ||
endingMessageListItem.num = 544; // , | ||
// 544: , (Comma) | ||
endingMessageListItem.num = 544; | ||
} else { | ||
endingMessageListItem.num = 545; // . | ||
// 545: . (Period) | ||
endingMessageListItem.num = 545; | ||
} | ||
|
||
if (!message_search(&proto_main_msg_file, &endingMessageListItem)) { | ||
|
@@ -377,14 +383,19 @@ int obj_examine_func(Object* critter, Object* target, void (*fn)(char* string)) | |
} | ||
|
||
MessageListItem hpMessageListItem; | ||
// 500: Dead | ||
// 501: Almost Dead | ||
// 502: Severely Wounded | ||
// 503: Wounded | ||
// 504: Unhurt | ||
hpMessageListItem.num = 500 + v16; | ||
if (!message_search(&proto_main_msg_file, &hpMessageListItem)) { | ||
debug_printf("\nError: Can't find msg num!"); | ||
exit(1); | ||
} | ||
|
||
if (v16 > 4) { | ||
// Error: lookup_val out of range | ||
// 550: \nError: lookup_val out of range | ||
hpMessageListItem.num = 550; | ||
if (!message_search(&proto_main_msg_file, &hpMessageListItem)) { | ||
debug_printf("\nError: Can't find msg num!"); | ||
|
@@ -397,7 +408,8 @@ int obj_examine_func(Object* critter, Object* target, void (*fn)(char* string)) | |
|
||
MessageListItem v66; | ||
if (target == obj_dude) { | ||
// You look %s | ||
// 520: You look %s. | ||
// 518: You look: %s | ||
v66.num = 520 + v12; | ||
if (!message_search(&proto_main_msg_file, &v66)) { | ||
debug_printf("\nError: Can't find msg num!"); | ||
|
@@ -406,21 +418,17 @@ int obj_examine_func(Object* critter, Object* target, void (*fn)(char* string)) | |
|
||
snprintf(formattedText, sizeof(formattedText), v66.text, hpMessageListItem.text); | ||
} else { | ||
// %s %s | ||
v66.num = 521 + v12; | ||
if (!message_search(&proto_main_msg_file, &v66)) { | ||
debug_printf("\nError: Can't find msg num!"); | ||
exit(1); | ||
} | ||
|
||
MessageListItem v63; | ||
// 522: He looks: %s. | ||
// 523: She looks: %s. | ||
// 524: It looks: %s. | ||
v63.num = 522 + stat_level(target, STAT_GENDER); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can add a check here for |
||
if (!message_search(&proto_main_msg_file, &v63)) { | ||
debug_printf("\nError: Can't find msg num!"); | ||
exit(1); | ||
} | ||
|
||
snprintf(formattedText, sizeof(formattedText), v66.text, v63.text, hpMessageListItem.text); | ||
snprintf(formattedText, sizeof(formattedText), v63.text, hpMessageListItem.text); | ||
} | ||
} | ||
|
||
|
@@ -429,9 +437,13 @@ int obj_examine_func(Object* critter, Object* target, void (*fn)(char* string)) | |
const int currentHitPoints = stat_level(target, STAT_CURRENT_HIT_POINTS); | ||
|
||
MessageListItem v63; | ||
// 530: and has crippled limbs. | ||
// 531: but has crippled limbs. | ||
v63.num = maxiumHitPoints >= currentHitPoints ? 531 : 530; | ||
|
||
if (target == obj_dude) { | ||
// 532: and have crippled limbs. | ||
// 534: but have crippled limbs. | ||
v63.num += 2; | ||
} | ||
|
||
|
@@ -449,6 +461,7 @@ int obj_examine_func(Object* critter, Object* target, void (*fn)(char* string)) | |
if (itemType == ITEM_TYPE_WEAPON) { | ||
if (item_w_caliber(target) != 0) { | ||
MessageListItem weaponMessageListItem; | ||
// 526: It has %d/%d shots of %s. | ||
weaponMessageListItem.num = 526; | ||
|
||
if (!message_search(&proto_main_msg_file, &weaponMessageListItem)) { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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 forHe/She/It looks:
and the second%s
is for examine texthpMessageListItem
, 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.