From f109f3886d6fc44860feaea98b4ac90df11ee924 Mon Sep 17 00:00:00 2001 From: renmu123 <1101022351@qq.com> Date: Sat, 13 Jul 2024 00:06:03 +0800 Subject: [PATCH 1/7] =?UTF-8?q?=E5=8F=AA=E5=AF=B9=E5=BD=95=E6=92=AD?= =?UTF-8?q?=E5=A7=AC=E7=9A=84gift=E7=9A=84raw=E8=BF=9B=E8=A1=8C=E8=A7=A3?= =?UTF-8?q?=E6=9E=90=E6=9D=A5=E5=8A=A0=E5=BF=AB=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- XmlFile.c | 97 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 53 insertions(+), 44 deletions(-) diff --git a/XmlFile.c b/XmlFile.c index 4eb05f0..76b5db5 100644 --- a/XmlFile.c +++ b/XmlFile.c @@ -116,7 +116,7 @@ int readXml(const char *const ipFile, DANMAKU **head, const char *mode, const fl BOOL isDanmaku; BOOL hasUserInfo; BOOL hasGiftInfo; - + while (!feof(ipF)) { type = 0; @@ -284,62 +284,71 @@ int readXml(const char *const ipFile, DANMAKU **head, const char *mode, const fl // BililiveRecorder else if (strcmp(key, "raw") == 0) { - strGetLeftPart(NULL, &labelPtr, '\"', LABEL_LEN); - strGetLeftPart(raw, &labelPtr, '\"', LABEL_LEN); + if(hasGiftInfo == TRUE) + { + strGetLeftPart(NULL, &labelPtr, '\"', LABEL_LEN); + strGetLeftPart(raw, &labelPtr, '\"', LABEL_LEN); - /* 解析raw部分 */ - char rawKey[KEY_LEN]; - char rawValue[VALUE_LEN]; - char *rawPtr = raw; + /* 解析raw部分 */ + char rawKey[KEY_LEN]; + char rawValue[VALUE_LEN]; + char *rawPtr = raw; - char coinTypeValue[VALUE_LEN] = {0}; + char coinTypeValue[VALUE_LEN] = {0}; + clock_t start2 = clock(); - xmlUnescape(raw); - strGetLeftPart(NULL, &rawPtr, '{', LABEL_LEN); + xmlUnescape(raw); + clock_t end2 = clock(); + duration2 += (double)(end2 - start2) / CLOCKS_PER_SEC; + strGetLeftPart(NULL, &rawPtr, '{', LABEL_LEN); - while (*rawPtr != '\0') - { - strGetLeftPart(rawKey, &rawPtr, ':', KEY_LEN); - strGetLeftPart(rawValue, &rawPtr, ',', VALUE_LEN); - deQuotMarks(rawKey); - deQuotMarks(rawValue); - if (strcmp(rawKey, "gift_name") == 0) - { - strSafeCopy(gift.name, rawValue, GIFT_NAME_LEN); - } - else if (strcmp(rawKey, "coin_type") == 0) - { - strSafeCopy(coinTypeValue, rawValue, GIFT_NAME_LEN); - } - else if (strcmp(rawKey, "uid") == 0) + + while (*rawPtr != '\0') { - if (user.uid == 0) { - user.uid = strtoull(rawValue, NULL, 10); + strGetLeftPart(rawKey, &rawPtr, ':', KEY_LEN); + strGetLeftPart(rawValue, &rawPtr, ',', VALUE_LEN); + deQuotMarks(rawKey); + deQuotMarks(rawValue); + if (strcmp(rawKey, "gift_name") == 0) + { + strSafeCopy(gift.name, rawValue, GIFT_NAME_LEN); } - } - else if (strcmp(rawKey, "price") == 0) - { - if (FLOAT_IS_EQUAL(gift.price, -1.00)) + else if (strcmp(rawKey, "coin_type") == 0) + { + strSafeCopy(coinTypeValue, rawValue, GIFT_NAME_LEN); + } + else if (strcmp(rawKey, "uid") == 0) { - gift.price = atof(rawValue); + if (user.uid == 0) { + user.uid = strtoull(rawValue, NULL, 10); + } + } + else if (strcmp(rawKey, "price") == 0) + { + if (FLOAT_IS_EQUAL(gift.price, -1.00)) + { + gift.price = atof(rawValue); + } + } + else if (strcmp(rawKey, "combo_stay_time") == 0) + { + if (gift.duration == 0) { + gift.duration = GET_MS_FLT(atof(rawValue)); + } } } - else if (strcmp(rawKey, "combo_stay_time") == 0) + + if (strcmp(coinTypeValue, "silver") == 0) { - if (gift.duration == 0) { - gift.duration = GET_MS_FLT(atof(rawValue)); - } + giftPriceUnit = 0.0; + } + else if (messageType != MSG_SUPER_CHAT) + { + giftPriceUnit = 1e-3; } + } - if (strcmp(coinTypeValue, "silver") == 0) - { - giftPriceUnit = 0.0; - } - else if (messageType != MSG_SUPER_CHAT) - { - giftPriceUnit = 1e-3; - } } // blrec else if (strcmp(key, "cointype") == 0) { From 89c74028c3888529421f42310b84f19061cc5868 Mon Sep 17 00:00:00 2001 From: muse Date: Sat, 13 Jul 2024 00:26:24 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- XmlFile.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/XmlFile.c b/XmlFile.c index 76b5db5..2e7d022 100644 --- a/XmlFile.c +++ b/XmlFile.c @@ -295,14 +295,9 @@ int readXml(const char *const ipFile, DANMAKU **head, const char *mode, const fl char *rawPtr = raw; char coinTypeValue[VALUE_LEN] = {0}; - clock_t start2 = clock(); - xmlUnescape(raw); - clock_t end2 = clock(); - duration2 += (double)(end2 - start2) / CLOCKS_PER_SEC; strGetLeftPart(NULL, &rawPtr, '{', LABEL_LEN); - while (*rawPtr != '\0') { strGetLeftPart(rawKey, &rawPtr, ':', KEY_LEN); From de1dac03a279d0ab9d332863e6a229e5c43c4608 Mon Sep 17 00:00:00 2001 From: muse Date: Wed, 17 Jul 2024 00:14:07 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E4=BC=98=E5=8C=96xmlUnescape=E5=87=BD?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- XmlFile.c | 97 +++++++++++++++++++------------------------------------ 1 file changed, 34 insertions(+), 63 deletions(-) diff --git a/XmlFile.c b/XmlFile.c index 2e7d022..a82f7b4 100644 --- a/XmlFile.c +++ b/XmlFile.c @@ -732,88 +732,59 @@ int writeXml(char const *const fileName, DANMAKU *danmakuHead, STATUS *const sta */ static char *xmlUnescape(char *const str) { - /* 非法检查 */ if (str == NULL) { return NULL; } - char *leftPtr, *rightPtr, *reWritePtr; - leftPtr = str; - while (*leftPtr != '\0') + char *srcPtr = str; // 源字符串指针 + char *dstPtr = str; // 目标字符串指针,也用于就地修改字符串 + + while (*srcPtr != '\0') { - if (*leftPtr == '&') + if (*srcPtr == '&') { - if (strstr(leftPtr, "&") == leftPtr) + if (strncmp(srcPtr, "&", 5) == 0) { - *leftPtr = '&'; - reWritePtr = leftPtr + 1; - rightPtr = leftPtr + 5; - while (*rightPtr != '\0') - { - *reWritePtr = *rightPtr; - reWritePtr++; - rightPtr++; - } - *reWritePtr = '\0'; + *dstPtr++ = '&'; + srcPtr += 5; } - else if (strstr(leftPtr, "'") == leftPtr) + else if (strncmp(srcPtr, "'", 6) == 0) { - *leftPtr = '\''; - reWritePtr = leftPtr + 1; - rightPtr = leftPtr + 6; - while (*rightPtr != '\0') - { - *reWritePtr = *rightPtr; - reWritePtr++; - rightPtr++; - } - *reWritePtr = '\0'; + *dstPtr++ = '\''; + srcPtr += 6; } - else if (strstr(leftPtr, ">") == leftPtr) + else if (strncmp(srcPtr, ">", 4) == 0) { - *leftPtr = '>'; - reWritePtr = leftPtr + 1; - rightPtr = leftPtr + 4; - while (*rightPtr != '\0') - { - *reWritePtr = *rightPtr; - reWritePtr++; - rightPtr++; - } - *reWritePtr = '\0'; + *dstPtr++ = '>'; + srcPtr += 4; } - else if (strstr(leftPtr, "<") == leftPtr) + else if (strncmp(srcPtr, "<", 4) == 0) { - *leftPtr = '<'; - reWritePtr = leftPtr + 1; - rightPtr = leftPtr + 4; - while (*rightPtr != '\0') - { - *reWritePtr = *rightPtr; - reWritePtr++; - rightPtr++; - } - *reWritePtr = '\0'; + *dstPtr++ = '<'; + srcPtr += 4; } - else if (strstr(leftPtr, """) == leftPtr) + else if (strncmp(srcPtr, """, 6) == 0) { - *leftPtr = '\"'; - reWritePtr = leftPtr + 1; - rightPtr = leftPtr + 6; - while (*rightPtr != '\0') - { - *reWritePtr = *rightPtr; - reWritePtr++; - rightPtr++; - } - *reWritePtr = '\0'; + *dstPtr++ = '\"'; + srcPtr += 6; + } + else + { + // 如果不是已知的转义序列,就原样复制 + *dstPtr++ = *srcPtr++; } } - - leftPtr++; + else + { + // 如果当前字符不是 '&',就原样复制 + *dstPtr++ = *srcPtr++; + } } - + + // 字符串结束 + *dstPtr = '\0'; + return str; } From 05a0014a2dd2ea941631d6b89400207689ff75ee Mon Sep 17 00:00:00 2001 From: Shawn Sun Date: Tue, 23 Jul 2024 14:35:26 +0800 Subject: [PATCH 4/7] refactor(xml): better code structure --- XmlFile.c | 63 +++++++++++++++++++++++++++---------------------------- 1 file changed, 31 insertions(+), 32 deletions(-) diff --git a/XmlFile.c b/XmlFile.c index a82f7b4..0632422 100644 --- a/XmlFile.c +++ b/XmlFile.c @@ -742,42 +742,41 @@ static char *xmlUnescape(char *const str) while (*srcPtr != '\0') { - if (*srcPtr == '&') + if (*srcPtr != '&') { - if (strncmp(srcPtr, "&", 5) == 0) - { - *dstPtr++ = '&'; - srcPtr += 5; - } - else if (strncmp(srcPtr, "'", 6) == 0) - { - *dstPtr++ = '\''; - srcPtr += 6; - } - else if (strncmp(srcPtr, ">", 4) == 0) - { - *dstPtr++ = '>'; - srcPtr += 4; - } - else if (strncmp(srcPtr, "<", 4) == 0) - { - *dstPtr++ = '<'; - srcPtr += 4; - } - else if (strncmp(srcPtr, """, 6) == 0) - { - *dstPtr++ = '\"'; - srcPtr += 6; - } - else - { - // 如果不是已知的转义序列,就原样复制 - *dstPtr++ = *srcPtr++; - } + // 如果当前字符不是 '&',就原样复制 + *dstPtr++ = *srcPtr++; + continue; + } + + if (strncmp(srcPtr, "&", 5) == 0) + { + *dstPtr++ = '&'; + srcPtr += 5; + } + else if (strncmp(srcPtr, "'", 6) == 0) + { + *dstPtr++ = '\''; + srcPtr += 6; + } + else if (strncmp(srcPtr, ">", 4) == 0) + { + *dstPtr++ = '>'; + srcPtr += 4; + } + else if (strncmp(srcPtr, "<", 4) == 0) + { + *dstPtr++ = '<'; + srcPtr += 4; + } + else if (strncmp(srcPtr, """, 6) == 0) + { + *dstPtr++ = '\"'; + srcPtr += 6; } else { - // 如果当前字符不是 '&',就原样复制 + // 如果不是已知的转义序列,就原样复制 *dstPtr++ = *srcPtr++; } } From f4080db39d021b9dc1487e3e06c14253a2eca565 Mon Sep 17 00:00:00 2001 From: muse Date: Thu, 25 Jul 2024 00:15:05 +0800 Subject: [PATCH 5/7] =?UTF-8?q?blrec=E7=9A=84=E7=A4=BC=E7=89=A9=E4=BB=B7?= =?UTF-8?q?=E6=A0=BC=E4=BF=AE=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- XmlFile.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/XmlFile.c b/XmlFile.c index 2605530..ca0d3b2 100644 --- a/XmlFile.c +++ b/XmlFile.c @@ -345,10 +345,11 @@ int readXml(const char *const ipFile, DANMAKU **head, const char *mode, const fl } } - // blrec + // blrec的礼物,不包含sc和guard else if (strcmp(key, "cointype") == 0) { 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; } From dcf208161431607190439eb46ce490d986c22cc5 Mon Sep 17 00:00:00 2001 From: muse Date: Thu, 25 Jul 2024 10:59:26 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dblrec=E8=88=B0=E9=95=BF?= =?UTF-8?q?=E4=BB=B7=E6=A0=BC=E4=BB=A5=E5=8F=8A=E6=9C=AA=E8=AE=B0=E5=BD=95?= =?UTF-8?q?raw=E7=9A=84=E5=BD=95=E6=92=AD=E5=A7=AC=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- XmlFile.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/XmlFile.c b/XmlFile.c index ca0d3b2..6b2168f 100644 --- a/XmlFile.c +++ b/XmlFile.c @@ -261,27 +261,32 @@ 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; break; case 2: // 提督 gift.duration = 1998000; + gift.price = 1998; break; case 3: // 舰长 gift.duration = 198000; + gift.price = 198; break; default: // 未知 gift.duration = 18000; + gift.price = 0; break; } } - // BililiveRecorder + // BililiveRecorder,开启记录raw else if (strcmp(key, "raw") == 0) { if(hasGiftInfo == TRUE) From 68ab42c442f1ddf66d6aa581709837ba560a7de6 Mon Sep 17 00:00:00 2001 From: Shawn Sun Date: Fri, 26 Jul 2024 02:01:05 +0800 Subject: [PATCH 7/7] =?UTF-8?q?fix(super=20chat):=20=E4=BF=AE=E5=A4=8D=20b?= =?UTF-8?q?lrec=20=E4=B8=8E=20=E5=BD=95=E6=92=AD=E5=A7=AC=20=E7=9A=84=20SC?= =?UTF-8?q?=20=E9=87=91=E9=A2=9D=E9=A2=9C=E8=89=B2=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将礼物金额读取单位由“元”改为“厘”,内部存储类型由单精度浮点数统一转换为整型。 BREAKING CHANGE: 由于现在统一以“厘”为单位读入礼物金额,如果在以前单独处理 blrec 的 xml 时将 `price` 统一除以 1000 的话,会在这次更新后使读入金额缩小 1000 倍出现计算错误。 re #53 --- AssFile/AssFile.c | 19 +++++++++--------- Config/Config.h | 2 +- Define/DanmakuDef.h | 2 +- XmlFile.c | 47 ++++++++++++++++----------------------------- 4 files changed, 29 insertions(+), 41 deletions(-) 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; }