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 "display_monitor.h"
#include "game.h"
#include "game_dialog.h"
#include "game_sound.h"
#include "geometry.h"
#include "interface.h"
@ -499,6 +500,12 @@ int _obj_examine_func(Object* critter, Object* target, void (*fn)(char* string))
fn(formattedText);
}
} 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;
ammoMessageListItem.num = 510;
@ -510,7 +517,11 @@ int _obj_examine_func(Object* critter, Object* target, void (*fn)(char* string))
sprintf(formattedText,
ammoMessageListItem.text,
ammoGetArmorClassModifier(target));
if (fn == gameDialogRenderSupplementaryMessage) {
strcat(ammoFormattedText, formattedText);
} else {
fn(formattedText);
}
ammoMessageListItem.num++;
if (!messageListGetItem(&gProtoMessageList, &ammoMessageListItem)) {
@ -521,7 +532,12 @@ int _obj_examine_func(Object* critter, Object* target, void (*fn)(char* string))
sprintf(formattedText,
ammoMessageListItem.text,
ammoGetDamageResistanceModifier(target));
if (fn == gameDialogRenderSupplementaryMessage) {
strcat(ammoFormattedText, ", ");
strcat(ammoFormattedText, formattedText);
} else {
fn(formattedText);
}
ammoMessageListItem.num++;
if (!messageListGetItem(&gProtoMessageList, &ammoMessageListItem)) {
@ -533,9 +549,16 @@ int _obj_examine_func(Object* critter, Object* target, void (*fn)(char* string))
ammoMessageListItem.text,
ammoGetDamageMultiplier(target),
ammoGetDamageDivisor(target));
if (fn == gameDialogRenderSupplementaryMessage) {
strcat(ammoFormattedText, ", ");
strcat(ammoFormattedText, formattedText);
strcat(ammoFormattedText, ".");
fn(ammoFormattedText);
} else {
fn(formattedText);
}
}
}
return 0;
}