diff --git a/AssFile/AssFile.c b/AssFile/AssFile.c index d744b6f..baac384 100644 --- a/AssFile/AssFile.c +++ b/AssFile/AssFile.c @@ -1740,6 +1740,7 @@ int writeAssDanmakuPart(FILE *opF, DANMAKU *head, CONFIG config, STATUS *const s COORDIN msgBoxPos = config.msgBoxPos; int msgFontSize = config.msgboxFontsize; const int msgDuration = GET_ASS_MS_FLT(config.msgboxDuration); // 精度为 10 毫秒 + const int giftMinPrice = config.giftMinPrice * 1000.0f; // 单位:厘 const BOOL giftComboSwitch = GET_ASS_MS_FLT(config.giftMergeTolerance) >= 0; /* 刷新status */ @@ -2336,7 +2337,7 @@ int writeAssDanmakuPart(FILE *opF, DANMAKU *head, CONFIG config, STATUS *const s else if (IS_MSG(now) && showMsgBox)/* 消息 */ { /* 按最低价格屏蔽 */ - if (now->gift->price < config.giftMinPrice && now->gift->price > -EPS) + if (now->gift->price < giftMinPrice && now->gift->price >= 0) { goto NEXTNODE; } @@ -3310,13 +3311,13 @@ int printMessage(FILE *filePtr, strcpy(textColor, "\\c&H313131"); - if (message->gift->price + EPS > 2000) + if (message->gift->price >= 2000 * 1000) { /* 2k及以上 */ strcpy(topBoxColor, "\\c&HD8D8FF"); strcpy(btmBoxColor, "\\c&H321AAB"); strcpy(userIDColor, "\\c&H1B0E5E"); } - else if (message->gift->price + EPS > 1000) + else if (message->gift->price >= 1000 * 1000) { /* 1k及以上 */ // strcpy(topBoxColor, "\\c&HE5E5FF"); // strcpy(btmBoxColor, "\\c&H8C8CF7"); @@ -3325,7 +3326,7 @@ int printMessage(FILE *filePtr, strcpy(btmBoxColor, "\\c&H4D4DE5"); strcpy(userIDColor, "\\c&H333398"); } - else if (message->gift->price + EPS > 500) + else if (message->gift->price >= 500 * 1000) { /* 500及以上 */ // strcpy(topBoxColor, "\\c&HD4F6FF"); // strcpy(btmBoxColor, "\\c&H8CCEF7"); @@ -3334,7 +3335,7 @@ int printMessage(FILE *filePtr, strcpy(btmBoxColor, "\\c&H4394E0"); strcpy(userIDColor, "\\c&H2C6193"); } - else if (message->gift->price + EPS > 100) + else if (message->gift->price >= 100 * 1000) { /* 100及以上 */ // strcpy(topBoxColor, "\\c&HCAF9F8"); // strcpy(btmBoxColor, "\\c&H76E8E9"); @@ -3343,7 +3344,7 @@ int printMessage(FILE *filePtr, strcpy(btmBoxColor, "\\c&H2BB5E2"); strcpy(userIDColor, "\\c&H1C7795"); } - else if (message->gift->price + EPS > 50) + else if (message->gift->price >= 50 * 1000) { /* 50及以上 */ strcpy(topBoxColor, "\\c&HFDFFDB"); strcpy(btmBoxColor, "\\c&H9E7D42"); @@ -3413,7 +3414,7 @@ int printMessage(FILE *filePtr, effect, /* 补充特效 */ textColor, /* 颜色 */ (int)(fontSize*(4.0/5.0)), /* 金额文字大小 */ - (int)message->gift->price /* SC金额 */ + message->gift->price / 1000/* SC金额 */ ); /* SC内容 */ @@ -3436,12 +3437,12 @@ int printMessage(FILE *filePtr, char textColor[ASS_COLOR_LEN]; strcpy(textColor, "\\c&H313131"); - if (message->gift->price + EPS > 19800) + if (message->gift->price >= 19998 * 1000) { /* 总督 */ strcpy(boxColor, "\\c&HE5E5FF"); strcpy(userIDColor, "\\c&H0F0F75"); } - else if (message->gift->price + EPS > 1980) + else if (message->gift->price >= 1998 * 1000) { /* 提督 */ strcpy(boxColor, "\\c&HCAF9F8"); strcpy(userIDColor, "\\c&H1A8B87"); diff --git a/Config/Config.h b/Config/Config.h index b7d8654..7996db1 100644 --- a/Config/Config.h +++ b/Config/Config.h @@ -70,7 +70,7 @@ struct Configurations struct Coordinate msgBoxPos; /* 消息框位置 */ int msgboxFontsize; /* 消息框内文字大小 */ float msgboxDuration; /* 消息框持续时长(秒数) */ - float giftMinPrice; /* 消息框礼物最低价格限制 */ + float giftMinPrice; /* 消息框礼物最低价格限制(元) */ float giftMergeTolerance; /* 相同用户相同礼物合并时间窗(秒数) */ int blockmode; /* 屏蔽模式 */ diff --git a/Define/DanmakuDef.h b/Define/DanmakuDef.h index c89ed98..7c85f37 100644 --- a/Define/DanmakuDef.h +++ b/Define/DanmakuDef.h @@ -111,7 +111,7 @@ struct UserPart struct GiftPart { char name[GIFT_NAME_LEN]; - float price; + int price; // 礼物金额(厘) int count; int duration; // 持续时间(毫秒) }; diff --git a/XmlFile.c b/XmlFile.c index 6b2168f..532307a 100644 --- a/XmlFile.c +++ b/XmlFile.c @@ -92,8 +92,8 @@ int readXml(const char *const ipFile, DANMAKU **head, const char *mode, const fl /* 读取xml文件 */ float time; short type; - short fontSize; - int color; + short fontSize = 0; + int color = 0; int messageType; char *text; char tempText[MAX_TEXT_LENGTH]; @@ -126,7 +126,7 @@ int readXml(const char *const ipFile, DANMAKU **head, const char *mode, const fl text = NULL; - gift.price = -1.00; + gift.price = -1; gift.count = -1; gift.name[0] = '\0'; gift.duration = 0; @@ -198,7 +198,6 @@ int readXml(const char *const ipFile, DANMAKU **head, const char *mode, const fl continue; } - double giftPriceUnit = 1.0; while (*labelPtr != '\0') { strGetLeftPart(key, &labelPtr, '=', MAX_TEXT_LENGTH); @@ -245,12 +244,12 @@ int readXml(const char *const ipFile, DANMAKU **head, const char *mode, const fl else if (strcmp(key, "giftcount") == 0 || strcmp(key, "count") == 0) { getNextWord(&labelPtr, tempText, MAX_TEXT_LENGTH, ' ', TRUE); - gift.count = atof(deQuotMarks(tempText)); + gift.count = atoi(deQuotMarks(tempText)); } else if (strcmp(key, "price") == 0) { getNextWord(&labelPtr, tempText, MAX_TEXT_LENGTH, ' ', TRUE); - gift.price = atof(deQuotMarks(tempText)); + gift.price = atoi(deQuotMarks(tempText)); } else if (strcmp(key, "time") == 0) { @@ -261,28 +260,23 @@ int readXml(const char *const ipFile, DANMAKU **head, const char *mode, const fl else if (strcmp(key, "level") == 0) { getNextWord(&labelPtr, tempText, MAX_TEXT_LENGTH, ' ', TRUE); - giftPriceUnit = 1; switch (atoi(deQuotMarks(tempText))) { case 1: // 总督 - gift.duration = 19998000; - gift.price = 19998; + gift.duration = gift.price = 19998000; break; case 2: // 提督 - gift.duration = 1998000; - gift.price = 1998; + gift.duration = gift.price = 1998000; break; case 3: // 舰长 - gift.duration = 198000; - gift.price = 198; + gift.duration = gift.price = 198000; break; default: // 未知 - gift.duration = 18000; - gift.price = 0; + gift.duration = gift.price = 18000; break; } } @@ -325,9 +319,9 @@ int readXml(const char *const ipFile, DANMAKU **head, const char *mode, const fl } else if (strcmp(rawKey, "price") == 0) { - if (FLOAT_IS_EQUAL(gift.price, -1.00)) + if (gift.price == -1) { - gift.price = atof(rawValue); + gift.price = atoi(rawValue); } } else if (strcmp(rawKey, "combo_stay_time") == 0) @@ -340,13 +334,13 @@ int readXml(const char *const ipFile, DANMAKU **head, const char *mode, const fl if (strcmp(coinTypeValue, "silver") == 0) { - giftPriceUnit = 0.0; + gift.price = 0; } - else if (messageType != MSG_SUPER_CHAT) + // 录播姬的 SC 金额特殊处理 + if (messageType == MSG_SUPER_CHAT) { - giftPriceUnit = 1e-3; + gift.price *= 1000; } - } } @@ -355,11 +349,9 @@ int readXml(const char *const ipFile, DANMAKU **head, const char *mode, const fl char coinTypeValue[VALUE_LEN]; getNextWord(&labelPtr, coinTypeValue, GIFT_NAME_LEN, ' ', TRUE); deQuotMarks(coinTypeValue); + // 银瓜子 —— 免费礼物 if (strcmp(coinTypeValue, "\xe9\x93\xb6\xe7\x93\x9c\xe5\xad\x90") == 0) { - giftPriceUnit = 0.0; - } - else if (strcmp(coinTypeValue, "\xe9\x87\x91\xe7\x93\x9c\xe5\xad\x90") == 0) { - giftPriceUnit = 1e-3; + gift.price = 0; } } else @@ -368,11 +360,6 @@ int readXml(const char *const ipFile, DANMAKU **head, const char *mode, const fl } } - if (hasGiftInfo == TRUE && messageType != MSG_SUPER_CHAT) - { - gift.price *= giftPriceUnit; - } - if (messageType == MSG_GIFT && gift.duration == 0) { gift.duration = 5 * 1000; }