Fix presentation of messages with items (rewards & insurance returns) (#265)

This commit is contained in:
hulkhan22
2025-05-21 23:29:34 +02:00
committed by GitHub
parent e941213e0e
commit aef3a4202f
14 changed files with 50 additions and 50 deletions
@@ -147,7 +147,7 @@ public class DialogueController(
var result = new DialogueInfo
{
Id = dialogueId,
Type = dialogue?.Type ?? MessageType.NPC_TRADER,
Type = dialogue?.Type ?? MessageType.NpcTraderMessage,
Message = _dialogueHelper.GetMessagePreview(dialogue),
New = dialogue?.New,
AttachmentsNew = dialogue?.AttachmentsNew,
@@ -173,7 +173,7 @@ public class DialogueController(
var profile = _saveServer.GetProfile(sessionId);
// User to user messages are special in that they need the player to exist in them, add if they don't
if (messageType == MessageType.USER_MESSAGE &&
if (messageType == MessageType.UserMessage &&
dialog?.Users is not null &&
dialog.Users.All(userDialog => userDialog.Id != profile.CharacterData?.PmcData?.SessionId))
{
@@ -253,7 +253,7 @@ public class DialogueController(
Type = request.Type
};
if (request.Type != MessageType.USER_MESSAGE)
if (request.Type != MessageType.UserMessage)
{
return profile.DialogueRecords[request.DialogId!];
}
@@ -599,7 +599,7 @@ public class InsuranceController(
_mailSendService.SendLocalisedNpcMessageToPlayer(
sessionId,
insurance.TraderId,
insurance.MessageType ?? MessageType.SYSTEM_MESSAGE,
insurance.MessageType ?? MessageType.SystemMessage,
insurance.MessageTemplateId,
insurance.Items,
insurance.MaxStorageTime,
@@ -111,7 +111,7 @@ public class QuestController(
_mailSendService.SendLocalisedNpcMessageToPlayer(
sessionID,
questFromDb.TraderId,
MessageType.QUEST_START,
MessageType.QuestStart,
messageId,
startedQuestRewardItems.ToList(),
_timeUtil.GetHoursAsSeconds((int) _questHelper.GetMailItemRedeemTimeHoursForProfile(pmcData))
@@ -321,7 +321,7 @@ public class TradeController(
_mailSendService.SendLocalisedNpcMessageToPlayer(
sessionId,
trader,
MessageType.MESSAGE_WITH_ITEMS,
MessageType.MessageWithItems,
_randomUtil.GetArrayValue(_databaseService.GetTrader(trader).Dialogue.TryGetValue("soldItems", out var items) ? items : new List<string>()),
curencyReward.SelectMany(x => x).ToList(),
_timeUtil.GetHoursAsSeconds(72)
@@ -736,7 +736,7 @@ public class QuestHelper(
_mailSendService.SendLocalisedNpcMessageToPlayer(
sessionID,
quest?.TraderId ?? matchingRepeatableQuest?.TraderId,
MessageType.QUEST_FAIL,
MessageType.QuestFail,
quest.FailMessageText,
questRewards.ToList(),
_timeUtil.GetHoursAsSeconds((int) GetMailItemRedeemTimeHoursForProfile(pmcData))
@@ -1367,7 +1367,7 @@ public class QuestHelper(
_mailSendService.SendLocalisedNpcMessageToPlayer(
sessionID,
quest.TraderId,
MessageType.QUEST_SUCCESS,
MessageType.QuestSuccess,
quest.SuccessMessageText,
questRewards,
_timeUtil.GetHoursAsSeconds((int) GetMailItemRedeemTimeHoursForProfile(pmcData))
@@ -793,7 +793,7 @@ public class RagfairOfferHelper(
_mailSendService.SendDirectNpcMessageToPlayer(
offerOwnerSessionId,
Traders.RAGMAN,
MessageType.FLEAMARKET_MESSAGE,
MessageType.FleamarketMessage,
GetLocalisedOfferSoldMessage(itemTpl, boughtAmount),
paymentItemsToSendToPlayer,
storagetime,
@@ -130,7 +130,7 @@ public class RagfairServerHelper(
mailSendService.SendLocalisedNpcMessageToPlayer(
sessionID,
Traders.RAGMAN,
MessageType.MESSAGE_WITH_ITEMS,
MessageType.MessageWithItems,
goodsReturnedTemplate,
returnedItems,
timeUtil.GetHoursAsSeconds((int) databaseService.GetGlobals().Configuration.RagFair.YourOfferDidNotSellMaxStorageTimeInHour)
@@ -2,19 +2,19 @@
public enum MessageType
{
USER_MESSAGE = 1,
NPC_TRADER = 2,
AUCTION_MESSAGE = 3,
FLEAMARKET_MESSAGE = 4,
ADMIN_MESSAGE = 5,
GROUP_CHAT_MESSAGE = 6,
SYSTEM_MESSAGE = 7,
INSURANCE_RETURN = 8,
GLOBAL_CHAT = 9,
QUEST_START = 10,
QUEST_FAIL = 11,
QUEST_SUCCESS = 12,
MESSAGE_WITH_ITEMS = 13,
INITIAL_SUPPORT = 14,
BTR_ITEMS_DELIVERY = 15
UserMessage = 1,
NpcTraderMessage = 2,
AuctionMessage = 3,
FleamarketMessage = 4,
AdminMessage = 5,
GroupChatMessage = 6,
SystemMessage = 7,
InsuranceReturn = 8,
GlobalChat = 9,
QuestStart = 10,
QuestFail = 11,
QuestSuccess = 12,
MessageWithItems = 13,
InitialSupport = 14,
BtrItemsDelivery = 15,
}
@@ -524,7 +524,7 @@ public class CreateProfileService(
_mailSendService.SendLocalisedNpcMessageToPlayer(
sessionID,
questFromDb.TraderId,
MessageType.QUEST_START,
MessageType.QuestStart,
messageId,
itemRewards,
_timeUtil.GetHoursAsSeconds(100)
@@ -132,7 +132,7 @@ public class GiftService(
_mailSendService.SendLocalisedNpcMessageToPlayer(
playerId,
giftData.Trader,
MessageType.MESSAGE_WITH_ITEMS,
MessageType.MessageWithItems,
giftData.LocaleTextId,
giftData.Items,
_timeUtil.GetHoursAsSeconds(giftData.CollectionTimeHours ?? 1)
@@ -143,7 +143,7 @@ public class GiftService(
_mailSendService.SendLocalisedNpcMessageToPlayer(
playerId,
giftData.Trader,
MessageType.MESSAGE_WITH_ITEMS,
MessageType.MessageWithItems,
giftData.MessageText,
giftData.Items,
_timeUtil.GetHoursAsSeconds(giftData.CollectionTimeHours ?? 1)
@@ -212,11 +212,11 @@ public class GiftService(
switch (giftData.Sender)
{
case GiftSenderType.System:
return MessageType.SYSTEM_MESSAGE;
return MessageType.SystemMessage;
case GiftSenderType.Trader:
return MessageType.NPC_TRADER;
return MessageType.NpcTraderMessage;
case GiftSenderType.User:
return MessageType.USER_MESSAGE;
return MessageType.UserMessage;
default:
_logger.Error(_localisationService.GetText("gift-unable_to_handle_message_type_command", giftData.Sender));
return null;
@@ -103,7 +103,7 @@ public class InsuranceService(
_mailSendService.SendLocalisedNpcMessageToPlayer(
sessionID,
traderKvP.Key,
MessageType.NPC_TRADER,
MessageType.NpcTraderMessage,
_randomUtil.GetArrayValue(dialogueTemplates["insuranceStart"] ?? ["INSURANCE START MESSAGE MISSING"]),
null,
_timeUtil.GetHoursAsSeconds((int) globals.Configuration?.Insurance?.MaxStorageTimeInHour),
@@ -120,7 +120,7 @@ public class InsuranceService(
TraderId = traderKvP.Key,
MaxStorageTime = (int) GetMaxInsuranceStorageTime(traderBase),
SystemData = systemData,
MessageType = MessageType.INSURANCE_RETURN,
MessageType = MessageType.InsuranceReturn,
MessageTemplateId = _randomUtil.GetArrayValue(dialogueTemplates["insuranceFound"]),
Items = GetInsurance(sessionID)[traderKvP.Key]
}
@@ -516,7 +516,7 @@ public class LocationLifecycleService
_mailSendService.SendLocalisedNpcMessageToPlayer(
sessionId,
Traders.FENCE,
MessageType.MESSAGE_WITH_ITEMS,
MessageType.MessageWithItems,
_randomUtil.GetArrayValue(_traderConfig.Fence.CoopExtractGift.MessageLocaleIds),
mailableLoot,
_timeUtil.GetHoursAsSeconds(_traderConfig.Fence.CoopExtractGift.GiftExpiryHours)
@@ -1134,7 +1134,7 @@ public class LocationLifecycleService
_mailSendService.SendLocalisedNpcMessageToPlayer(
sessionId,
traderId,
MessageType.BTR_ITEMS_DELIVERY,
MessageType.BtrItemsDelivery,
messageId,
items,
messageStoreTime
@@ -29,7 +29,7 @@ public class MailSendService(
)
{
private const string _systemSenderId = "59e7125688a45068a6249071";
protected HashSet<MessageType> _messageTypes = [MessageType.NPC_TRADER, MessageType.FLEAMARKET_MESSAGE];
protected HashSet<MessageType> _messageTypes = [MessageType.NpcTraderMessage, MessageType.FleamarketMessage];
protected HashSet<string> _slotNames = ["hideout", "main"];
/// <summary>
@@ -74,7 +74,7 @@ public class MailSendService(
{
RecipientId = sessionId,
Sender = messageType,
DialogType = MessageType.NPC_TRADER,
DialogType = MessageType.NpcTraderMessage,
Trader = trader,
MessageText = message,
Items = []
@@ -142,7 +142,7 @@ public class MailSendService(
{
RecipientId = sessionId,
Sender = messageType,
DialogType = MessageType.NPC_TRADER,
DialogType = MessageType.NpcTraderMessage,
Trader = trader,
TemplateId = messageLocaleId,
Items = new List<Item>()
@@ -194,7 +194,7 @@ public class MailSendService(
SendMessageDetails details = new()
{
RecipientId = sessionId,
Sender = MessageType.SYSTEM_MESSAGE,
Sender = MessageType.SystemMessage,
MessageText = message,
Items = new List<Item>()
};
@@ -235,7 +235,7 @@ public class MailSendService(
SendMessageDetails details = new()
{
RecipientId = sessionId,
Sender = MessageType.SYSTEM_MESSAGE,
Sender = MessageType.SystemMessage,
TemplateId = messageLocaleId,
Items = new List<Item>()
};
@@ -274,7 +274,7 @@ public class MailSendService(
SendMessageDetails details = new()
{
RecipientId = sessionId,
Sender = MessageType.USER_MESSAGE,
Sender = MessageType.UserMessage,
SenderDetails = senderDetails,
MessageText = message,
Items = new List<Item>()
@@ -329,7 +329,7 @@ public class MailSendService(
// TODO: clean up old code here
// Offer Sold notifications are now separate from the main notification
if (_messageTypes.Contains(senderDialog.Type ?? MessageType.SYSTEM_MESSAGE) &&
if (_messageTypes.Contains(senderDialog.Type ?? MessageType.SystemMessage) &&
messageDetails?.RagfairDetails is not null
)
{
@@ -338,7 +338,7 @@ public class MailSendService(
messageDetails.RagfairDetails
);
_notificationSendHelper.SendMessage(messageDetails.RecipientId, offerSoldMessage);
message.MessageType = MessageType.MESSAGE_WITH_ITEMS; // Should prevent getting the same notification popup twice
message.MessageType = MessageType.MessageWithItems; // Should prevent getting the same notification popup twice
}
// Send message off to player so they get it in client
@@ -369,7 +369,7 @@ public class MailSendService(
DateTime = _timeUtil.GetTimeStamp(),
HasRewards = false,
UserId = playerProfile.CharacterData.PmcData.Id,
MessageType = MessageType.USER_MESSAGE,
MessageType = MessageType.UserMessage,
RewardCollected = false,
Text = message
}
@@ -388,7 +388,7 @@ public class MailSendService(
{
Id = _hashUtil.Generate(),
UserId = dialogId,
MessageType = messageDetails.DialogType,
MessageType = messageDetails.Sender,
DateTime = _timeUtil.GetTimeStamp(),
Text = messageDetails.TemplateId is not null ? "" : messageDetails.MessageText,
TemplateId = messageDetails.TemplateId,
@@ -651,12 +651,12 @@ public class MailSendService(
/// <returns> Gets an id of the individual sending it </returns>
private string? GetMessageSenderIdByType(SendMessageDetails messageDetails)
{
if (messageDetails.Sender == MessageType.SYSTEM_MESSAGE)
if (messageDetails.Sender == MessageType.SystemMessage)
{
return _systemSenderId;
}
if (messageDetails.Sender == MessageType.NPC_TRADER || messageDetails.DialogType == MessageType.NPC_TRADER)
if (messageDetails.Sender == MessageType.NpcTraderMessage || messageDetails.DialogType == MessageType.NpcTraderMessage)
{
if (messageDetails.Trader == null && _logger.IsLogEnabled(LogLevel.Debug))
{
@@ -666,7 +666,7 @@ public class MailSendService(
return messageDetails.Trader;
}
if (messageDetails.Sender == MessageType.USER_MESSAGE)
if (messageDetails.Sender == MessageType.UserMessage)
{
return messageDetails.SenderDetails?.Id;
}
@@ -59,7 +59,7 @@ public class PmcChatResponseService(
sessionId,
victimDetails,
message,
MessageType.USER_MESSAGE
MessageType.UserMessage
);
}
}
@@ -113,7 +113,7 @@ public class PmcChatResponseService(
return;
}
_notificationSendHelper.SendMessageToPlayer(sessionId, killerDetails, message, MessageType.USER_MESSAGE);
_notificationSendHelper.SendMessageToPlayer(sessionId, killerDetails, message, MessageType.UserMessage);
}
/// <summary>