Fix ammo details when examining in barter screen

This commit is contained in:
Alexander Batalov 2022-08-14 20:45:26 +03:00
parent b10c580d6f
commit c35ea77c59
1 changed files with 26 additions and 3 deletions

View File

@ -8,6 +8,7 @@
#include "debug.h" #include "debug.h"
#include "display_monitor.h" #include "display_monitor.h"
#include "game.h" #include "game.h"
#include "game_dialog.h"
#include "game_sound.h" #include "game_sound.h"
#include "geometry.h" #include "geometry.h"
#include "interface.h" #include "interface.h"
@ -499,6 +500,12 @@ int _obj_examine_func(Object* critter, Object* target, void (*fn)(char* string))
fn(formattedText); fn(formattedText);
} }
} else if (itemType == ITEM_TYPE_AMMO) { } else if (itemType == ITEM_TYPE_AMMO) {
// SFALL: Fix ammo details when examining in barter screen.
// CE: Underlying `gameDialogRenderSupplementaryMessage` cannot
// accumulate strings like `inventoryRenderItemDescription` does.
char ammoFormattedText[260 * 3];
ammoFormattedText[0] = '\0';
MessageListItem ammoMessageListItem; MessageListItem ammoMessageListItem;
ammoMessageListItem.num = 510; ammoMessageListItem.num = 510;
@ -510,7 +517,11 @@ int _obj_examine_func(Object* critter, Object* target, void (*fn)(char* string))
sprintf(formattedText, sprintf(formattedText,
ammoMessageListItem.text, ammoMessageListItem.text,
ammoGetArmorClassModifier(target)); ammoGetArmorClassModifier(target));
if (fn == gameDialogRenderSupplementaryMessage) {
strcat(ammoFormattedText, formattedText);
} else {
fn(formattedText); fn(formattedText);
}
ammoMessageListItem.num++; ammoMessageListItem.num++;
if (!messageListGetItem(&gProtoMessageList, &ammoMessageListItem)) { if (!messageListGetItem(&gProtoMessageList, &ammoMessageListItem)) {
@ -521,7 +532,12 @@ int _obj_examine_func(Object* critter, Object* target, void (*fn)(char* string))
sprintf(formattedText, sprintf(formattedText,
ammoMessageListItem.text, ammoMessageListItem.text,
ammoGetDamageResistanceModifier(target)); ammoGetDamageResistanceModifier(target));
if (fn == gameDialogRenderSupplementaryMessage) {
strcat(ammoFormattedText, ", ");
strcat(ammoFormattedText, formattedText);
} else {
fn(formattedText); fn(formattedText);
}
ammoMessageListItem.num++; ammoMessageListItem.num++;
if (!messageListGetItem(&gProtoMessageList, &ammoMessageListItem)) { if (!messageListGetItem(&gProtoMessageList, &ammoMessageListItem)) {
@ -533,9 +549,16 @@ int _obj_examine_func(Object* critter, Object* target, void (*fn)(char* string))
ammoMessageListItem.text, ammoMessageListItem.text,
ammoGetDamageMultiplier(target), ammoGetDamageMultiplier(target),
ammoGetDamageDivisor(target)); ammoGetDamageDivisor(target));
if (fn == gameDialogRenderSupplementaryMessage) {
strcat(ammoFormattedText, ", ");
strcat(ammoFormattedText, formattedText);
strcat(ammoFormattedText, ".");
fn(ammoFormattedText);
} else {
fn(formattedText); fn(formattedText);
} }
} }
}
return 0; return 0;
} }