diff --git a/AIFormUnit.cpp b/AIFormUnit.cpp index db98839..10664a3 100644 --- a/AIFormUnit.cpp +++ b/AIFormUnit.cpp @@ -234,10 +234,11 @@ void __fastcall TAIForm::WebProcessMessageReceived(TObject* Sender, const _di_IC TJSONObject* opts = new TJSONObject(); TJSONArray* rows = new TJSONArray(); - if( IsCodePolicy(p->kind) ){ //代码策略:data只有code(打注一体另有miniChip) + if( IsCodePolicy(p->kind) ){ //代码策略:data只有code与roadType(打注一体另有miniChip) data->AddPair( "code", new TJSONString( p->code ) ); - if( p->kind==KIND_BET_WCH ) + if( p->kind!=KIND_BET_SPE ) data->AddPair( "miniChip", new TJSONNumber( ((TBetChipPolicy*)p)->miniChip ) ); + data->AddPair( "roadType", new TJSONNumber( p->road ) ); } else if( p->kind == KIND_BET_ASK ){ //庄闲问路(小强路特例,rows留空) opts->AddPair( "适用路单", new TJSONString( "小强路" ) ); @@ -556,6 +557,18 @@ TAIForm::ApplyResult TAIForm::SaveAIPolicy(const String& json) r.message = "解析失败: 缺少 code 字段"; delete obj; return r; } } + //代码打法(特殊打法/打注一体)的data里还需要roadType(本策略适用的路单): + //0=珠盘路 1=大路 2=大眼路 3=小路 4=小强路 + int codeRoad = 0; + if( ptype==TYPE_P_BET && IsCodePolicy(pkind) ){ + TJSONValue* vRoad = dataObj->GetValue("roadType"); + if( !vRoad || !vRoad->InheritsFrom(__classid(TJSONNumber)) ){ + r.message = "解析失败: 缺少 roadType 字段或类型错误"; delete obj; return r; } + codeRoad = (int)((TJSONNumber*)vRoad)->AsInt; + if( codeRoad<0 || codeRoad>4 ){ + r.message = "校验失败: roadType 必须为 0-4 的整数"; delete obj; return r; } + } + //代码策略的data中还需要miniChip(最小非0注码):仅打注一体与特殊注码两类需要, //特殊打法只管下注方向、不输出注码,无miniChip //注意KIND_BET_SPE与KIND_CHIP_SPE同为101,必须配ptype才能区分 @@ -576,23 +589,32 @@ TAIForm::ApplyResult TAIForm::SaveAIPolicy(const String& json) //构造策略对象与行文本 String line; TBasePolicy* pPolicy = NULL; - if( pkind==KIND_BET_WCH ){ - //打注一体:bet+chip代码策略,带miniChip - TBetChipPolicy* pBC = new TBetChipPolicy; - pBC->type = 2; pBC->kind = pkind; pBC->desc = desc; - pBC->code = dataObj->GetValue("code")->Value(); - pBC->miniChip = codeMiniChip; - pPolicy = pBC; - } - else if( pkind==KIND_BET_SPE ){ - //特殊打法:代码策略,无miniChip - TBetPolicy* pBP = new TBetPolicy; - pBP->type = 2; pBP->kind = pkind; pBP->desc = desc; - pBP->code = dataObj->GetValue("code")->Value(); - pPolicy = pBP; + if(IsCodePolicy(pkind)){ + if(pkind==KIND_BET_WCH){ + //打注一体:bet+chip代码策略,带roadType/miniChip + pPolicy = new TBetChipPolicy; + ((TBetChipPolicy*)pPolicy)->road = codeRoad; + ((TBetChipPolicy*)pPolicy)->miniChip = codeMiniChip; + } + else if( pkind==KIND_BET_SPE ){ + //特殊打法:bet代码策略,带roadType + pPolicy = new TBetPolicy; + ((TBetPolicy*)pPolicy)->road = codeRoad; + } + else if( pkind==KIND_CHIP_SPE ){ + //特殊注码:chip代码策略,带miniChip + pPolicy = new TChipPolicy; + ((TChipPolicy*)pPolicy)->miniChip = codeMiniChip; + } + + pPolicy->type = 2; + pPolicy->kind = pkind; + pPolicy->desc = desc; + pPolicy->code = StringReplace(dataObj->GetValue("code")->Value(), "\n", "", TReplaceFlags() << rfReplaceAll); } else if( ptype == TYPE_P_BET ){ TBetPolicy* pBP = new TBetPolicy; + pBP->type = 2; pBP->kind = pkind; pBP->desc = desc; String road = opts ? ((TJSONString*)opts->GetValue("适用路单"))->Value() : String(""); if( road == "大路" ) pBP->road = 1; @@ -615,66 +637,58 @@ TAIForm::ApplyResult TAIForm::SaveAIPolicy(const String& json) } else{ TChipPolicy* pCP = NULL; - if( IsCodePolicy(pkind) ){ - pCP = new TChipPolicy; - pCP->type = 2; pCP->kind = pkind; pCP->desc = desc; - pCP->code = dataObj->GetValue("code")->Value(); - pCP->miniChip = codeMiniChip; - pPolicy = pCP; + + if( pkind == KIND_CHIP_HAN ) pCP = new TTierPolicy; + else if( pkind == KIND_CHIP_LEV || pkind == KIND_CHIP_COM ) pCP = new TLevelPolicy; + else if( pkind == KIND_CHIP_WLD ) pCP = new TWLDiffPolicy; + else pCP = new TChipPolicy; + pCP->type = 2; pCP->kind = pkind; pCP->desc = desc; + if( pkind != KIND_CHIP_RAN && opts ){ + pCP->dead = (int)((TJSONNumber*)opts->GetValue("爆缆方式"))->AsInt; + pCP->deadPause = (int)((TJSONNumber*)opts->GetValue("暂停分钟"))->AsInt; + if( pkind == KIND_CHIP_HAN ){ + TTierPolicy* tp = (TTierPolicy*)pCP; + tp->bTierWinRet = ((TJSONBool*)opts->GetValue("高层赢多回基"))->AsBoolean; + tp->bTierAccChip = ((TJSONBool*)opts->GetValue("净输值累加"))->AsBoolean; + tp->bTierLos0 = ((TJSONBool*)opts->GetValue("输多打0"))->AsBoolean; + } + else if( pkind >= KIND_CHIP_LEV ){ + TLevelPolicy* lp = (TLevelPolicy*)pCP; + lp->bTotalDiff = ((TJSONBool*)opts->GetValue("总体计算"))->AsBoolean; + lp->bInstant = ((TJSONBool*)opts->GetValue("即时升降"))->AsBoolean; + if( pkind == KIND_CHIP_WLD ) ((TWLDiffPolicy*)pCP)->bIndie = ((TJSONBool*)opts->GetValue("升降清零"))->AsBoolean; + } } - else{ - if( pkind == KIND_CHIP_HAN ) pCP = new TTierPolicy; - else if( pkind == KIND_CHIP_LEV || pkind == KIND_CHIP_COM ) pCP = new TLevelPolicy; - else if( pkind == KIND_CHIP_WLD ) pCP = new TWLDiffPolicy; - else pCP = new TChipPolicy; - pCP->type = 2; pCP->kind = pkind; pCP->desc = desc; - if( pkind != KIND_CHIP_RAN && opts ){ - pCP->dead = (int)((TJSONNumber*)opts->GetValue("爆缆方式"))->AsInt; - pCP->deadPause = (int)((TJSONNumber*)opts->GetValue("暂停分钟"))->AsInt; - if( pkind == KIND_CHIP_HAN ){ - TTierPolicy* tp = (TTierPolicy*)pCP; - tp->bTierWinRet = ((TJSONBool*)opts->GetValue("高层赢多回基"))->AsBoolean; - tp->bTierAccChip = ((TJSONBool*)opts->GetValue("净输值累加"))->AsBoolean; - tp->bTierLos0 = ((TJSONBool*)opts->GetValue("输多打0"))->AsBoolean; - } - else if( pkind >= KIND_CHIP_LEV ){ - TLevelPolicy* lp = (TLevelPolicy*)pCP; - lp->bTotalDiff = ((TJSONBool*)opts->GetValue("总体计算"))->AsBoolean; - lp->bInstant = ((TJSONBool*)opts->GetValue("即时升降"))->AsBoolean; - if( pkind == KIND_CHIP_WLD ) ((TWLDiffPolicy*)pCP)->bIndie = ((TJSONBool*)opts->GetValue("升降清零"))->AsBoolean; - } - } - for(int i=0; iCount; i++){ - TJSONObject* rObj = (TJSONObject*)rows->Items[i]; - if( i>0 ) line += ";"; - if( pkind == KIND_CHIP_COM ) - line += ((TJSONString*)rObj->GetValue("常规方案"))->Value() + "," + ((TJSONString*)rObj->GetValue("倍数"))->Value() + "," - + ((TJSONString*)rObj->GetValue("赢利"))->Value() + "," + ((TJSONString*)rObj->GetValue("赢走向"))->Value() + "," - + ((TJSONString*)rObj->GetValue("亏损"))->Value() + "," + ((TJSONString*)rObj->GetValue("输走向"))->Value(); - else if( pkind == KIND_CHIP_HAN ) - line += ((TJSONString*)rObj->GetValue("注码"))->Value() + "," + ((TJSONString*)rObj->GetValue("手数"))->Value() + "," - + ((TJSONString*)rObj->GetValue("赢走向"))->Value() + "," + ((TJSONString*)rObj->GetValue("输走向"))->Value(); - else if( pkind == KIND_CHIP_LEV ) - line += ((TJSONString*)rObj->GetValue("注码"))->Value() + "," + ((TJSONString*)rObj->GetValue("赢利"))->Value() + "," - + ((TJSONString*)rObj->GetValue("赢走向"))->Value() + "," + ((TJSONString*)rObj->GetValue("亏损"))->Value() + "," - + ((TJSONString*)rObj->GetValue("输走向"))->Value(); - else if( pkind == KIND_CHIP_WLD ) - line += ((TJSONString*)rObj->GetValue("注码"))->Value() + "," + ((TJSONString*)rObj->GetValue("大于等于"))->Value() + "," - + ((TJSONString*)rObj->GetValue("赢走向"))->Value() + "," + ((TJSONString*)rObj->GetValue("小于"))->Value() + "," - + ((TJSONString*)rObj->GetValue("输走向"))->Value(); - else - line += ((TJSONString*)rObj->GetValue("注码"))->Value() + "," + ((TJSONString*)rObj->GetValue("赢走向"))->Value() + "," - + ((TJSONString*)rObj->GetValue("输走向"))->Value(); - } - int err = pCP->ParsePolicy(((AnsiString)line).c_str(), TYPE_P_CHIP); - if( err ){ - int row = err >> 16; - int col = err & 0xF; - r.code = 3; r.message = "校验失败: 第 " + IntToStr(row) + " 行第 " + IntToStr(col) + " 列格式有误"; - delete pCP; delete obj; return r; - } - pPolicy = pCP; + for(int i=0; iCount; i++){ + TJSONObject* rObj = (TJSONObject*)rows->Items[i]; + if( i>0 ) line += ";"; + if( pkind == KIND_CHIP_COM ) + line += ((TJSONString*)rObj->GetValue("常规方案"))->Value() + "," + ((TJSONString*)rObj->GetValue("倍数"))->Value() + "," + + ((TJSONString*)rObj->GetValue("赢利"))->Value() + "," + ((TJSONString*)rObj->GetValue("赢走向"))->Value() + "," + + ((TJSONString*)rObj->GetValue("亏损"))->Value() + "," + ((TJSONString*)rObj->GetValue("输走向"))->Value(); + else if( pkind == KIND_CHIP_HAN ) + line += ((TJSONString*)rObj->GetValue("注码"))->Value() + "," + ((TJSONString*)rObj->GetValue("手数"))->Value() + "," + + ((TJSONString*)rObj->GetValue("赢走向"))->Value() + "," + ((TJSONString*)rObj->GetValue("输走向"))->Value(); + else if( pkind == KIND_CHIP_LEV ) + line += ((TJSONString*)rObj->GetValue("注码"))->Value() + "," + ((TJSONString*)rObj->GetValue("赢利"))->Value() + "," + + ((TJSONString*)rObj->GetValue("赢走向"))->Value() + "," + ((TJSONString*)rObj->GetValue("亏损"))->Value() + "," + + ((TJSONString*)rObj->GetValue("输走向"))->Value(); + else if( pkind == KIND_CHIP_WLD ) + line += ((TJSONString*)rObj->GetValue("注码"))->Value() + "," + ((TJSONString*)rObj->GetValue("大于等于"))->Value() + "," + + ((TJSONString*)rObj->GetValue("赢走向"))->Value() + "," + ((TJSONString*)rObj->GetValue("小于"))->Value() + "," + + ((TJSONString*)rObj->GetValue("输走向"))->Value(); + else + line += ((TJSONString*)rObj->GetValue("注码"))->Value() + "," + ((TJSONString*)rObj->GetValue("赢走向"))->Value() + "," + + ((TJSONString*)rObj->GetValue("输走向"))->Value(); } + int err = pCP->ParsePolicy(((AnsiString)line).c_str(), TYPE_P_CHIP); + if( err ){ + int row = err >> 16; + int col = err & 0xF; + r.code = 3; r.message = "校验失败: 第 " + IntToStr(row) + " 行第 " + IntToStr(col) + " 列格式有误"; + delete pCP; delete obj; return r; + } + pPolicy = pCP; } //阶段三:命名 @@ -689,7 +703,7 @@ TAIForm::ApplyResult TAIForm::SaveAIPolicy(const String& json) preName = index>=0 ? ap[index]->name : AutoNewPolicyName(ptype); } - //主窗口置前 + //主窗口置前 // if (Application->MainForm->WindowState == wsMinimized) // Application->MainForm->WindowState = wsNormal; // Application->MainForm->BringToFront(); @@ -709,7 +723,9 @@ TAIForm::ApplyResult TAIForm::SaveAIPolicy(const String& json) int ret = SavePolicy(ptype, pPolicy, tgtIndex); if( ret >= 0 ){ r.ok = true; r.code = 0; r.id = pPolicy->id; r.name = finalName; - PostMessage(Application->MainFormHandle, UM_POLICYCHANGED, 0x10000 | ptype, 0); + + if(tgtIndex<0) //新增:通告主窗追加 + PostMessage(Application->MainFormHandle, UM_POLICYCHANGED, 0x10000 | ptype, 0); pPolicy = NULL; // 所有权已移交给 g_aBetPolicies,禁止释放 diff --git a/Chip02FrameUnit.cpp b/Chip02FrameUnit.cpp index f56478c..8d2851b 100644 --- a/Chip02FrameUnit.cpp +++ b/Chip02FrameUnit.cpp @@ -23,9 +23,9 @@ void __fastcall TChip02Frame::EditChipExit(TObject *Sender) TEdit* pE = (TEdit*)Sender; int num; - if(!TryStrToInt(pE->Text, num) || numg_MaxOnBet ){ - ShowMessage("注码金额不能超过限红"); - pE->Text = pE==m_leMinChip ? "20" : "100"; + if(!TryStrToInt(pE->Text, num) || num<1 || num>g_MaxOnBet ){ + ShowMessage("注码不能小于 1 或大于限红"); + pE->Text = pE==m_leMinChip ? "1" : "5"; pE->SetFocus(); } } diff --git a/CodesFrameUnit.dfm b/CodesFrameUnit.dfm index 1b961db..1ee9bee 100644 --- a/CodesFrameUnit.dfm +++ b/CodesFrameUnit.dfm @@ -25,11 +25,18 @@ object CodesFrame: TCodesFrame object m_lblDesc: TLabel Left = 40 Top = 63 - Width = 169 + Width = 65 Height = 15 - AutoSize = False Caption = #31574#30053#25551#36848#65306 end + object m_lblOption: TLabel + Left = 156 + Top = 63 + Width = 187 + Height = 15 + Alignment = taRightJustify + AutoSize = False + end object m_memDesc: TMemo Left = 40 Top = 87 diff --git a/CodesFrameUnit.h b/CodesFrameUnit.h index 803b812..ea53e46 100644 --- a/CodesFrameUnit.h +++ b/CodesFrameUnit.h @@ -15,6 +15,7 @@ __published: // IDE-managed Components TMemo *m_memDesc; TLabel *m_lblTip; TLabel *m_lblDesc; + TLabel *m_lblOption; private: // User declarations public: // User declarations __fastcall TCodesFrame(TComponent* Owner); diff --git a/GameUnit.cpp b/GameUnit.cpp index 8761f7f..1b4c388 100644 --- a/GameUnit.cpp +++ b/GameUnit.cpp @@ -3,6 +3,7 @@ #include "GameUnit.h" #include "GlobalUnit.h" #include "UtilityUnit.h" +#include "RBmasterMain.h" #pragma hdrstop @@ -493,6 +494,7 @@ void __fastcall TGame::Reset() bRun = bRev = bReset = bBreak = bPause = bReal = bIndPolicy = false; + bPreSPC = bPreBWC = false; nChipMul = iRoad = iBetPolicy = iChipPolicy = -1; } //--------------------------------------------------------------------------- @@ -504,6 +506,8 @@ void __fastcall TGame::ResetBet() iState = iBet = nChip = iBetSeq = iChipSeq = 0; bReal = bReset = false; aBets.clear(); + sCtxSPB = sCtxSPC = sCtxBWC = ""; //新局重置时代码策略context清零 + bPreSPC = bPreBWC = false; if(pRankChip) pRankChip->Reset(); @@ -526,10 +530,56 @@ int __fastcall TGame::Color2Bet(TBetPolicy* pBP, char clr) } //--------------------------------------------------------------------------- +//统一 eval 入口:按 kind 组装 prelude 与 ctx,直接调用 MainForm::EvalJSCode +//kind→对应 ctx 字段:KIND_BET_SPE→sCtxSPB KIND_CHIP_SPE→sCtxSPC KIND_BET_WCH→sCtxBWC +//失败(通道未就绪/超时/校验失败)⇒ 停台,不得降级;成功时 ctx 回写 +bool __fastcall TGame::EvalCodeJS(int kind, const String& sCode, TJSCodeRet& bs, int iCodeIn) +{ + String* pCtx = kind==KIND_BET_SPE ? &sCtxSPB + : kind==KIND_CHIP_SPE ? &sCtxSPC : &sCtxBWC; + + int iM = nChipMul<0 ? g_nChipMul : nChipMul; + bool bOk; + if(kind==KIND_CHIP_SPE){ //calcChip(result,chipMult,context) + String sPr = "var result=" + IntToStr(iCodeIn) + + "; var chipMult=" + IntToStr(iM) + ";"; + bOk = MainForm && MainForm->EvalJSCode(kind, sCode, sPr, *pCtx, bs); + } + else{ //road 拼装(读 road 历史) + String sRoad = ""; + for(int i=0; iEvalJSCode(kind, sCode, sPr, *pCtx, bs); + } + + if(!bOk){ //执行失败:本台停下,不得降级 + bRun = iBet = nChip = 0; + + String sKind = kind==KIND_BET_SPE ? "SPB" : kind==KIND_CHIP_SPE ? "SPC" : "BWC"; +// TLog::WriteLog("失败,代码策略执行失败," + vid + "," + IntToStr(iGame) + "," + sKind); + DebugPrint("%s 代码策略执行失败 kind=%d", ((AnsiString)vid).c_str(), kind); + if(hTable) + PostMessage(hTable, UM_LOG_UPDATE, ST_FAILED, 100); + } + else + *pCtx = bs.sCtx; //ctx 透传(空对象即重建) + + DebugPrint("JS ret: bet=%d, chip=%d, blast=%d, minutes=%d", bs.iBet, bs.iChip, bs.iBlast, bs.iBlastMinutes); + + return bOk; +} +//--------------------------------------------------------------------------- + + void __fastcall TGame::CalcBet() { - iBet = nChip = 0; //默认不下注 - int iBP = iBetPolicy>=0 ? iBetPolicy : g_iBetPolicy; TBetPolicy* pBP = (TBetPolicy*)g_aBetPolicies[iBP]; @@ -538,8 +588,35 @@ void __fastcall TGame::CalcBet() if(uBP!=pBP->id){ //改用ID判断避免方案删除带来问题 uBP = pBP->id; aBets.clear(); + sCtxSPB = sCtxBWC = ""; //打法策略切换时context清零 + bPreBWC = false; } + //代码策略分支:SPB 每手评估;BWC 由 CalcResult 暂存,仅初发评估一次 + if(pBP->kind==KIND_BET_SPE){ + TJSCodeRet bs; + if(EvalCodeJS(KIND_BET_SPE, pBP->code, bs)) + iBet = bs.iBet; //失败已由 EvalCodeJS 停台 + + iBetSeq = (uBP<<16) + aRes.size()+1; //保证打法方案切换检测有效 + return; //不走既有匹配 + } + if(pBP->kind==KIND_BET_WCH){ + if(!bPreBWC){ //CalcResult已暂存本手注码及方向则原样使用 + iBet = nChip = 0; + TJSCodeRet bs; + if(EvalCodeJS(KIND_BET_WCH, pBP->code, bs)){ + iBet = bs.iBet; + nChip = bs.iChip * (nChipMul<0 ? g_nChipMul : nChipMul); + } + } + + iBetSeq = (uBP<<16) + aRes.size()+1; //保证打法方案切换检测有效 + return; //打注一体由 CalcResult 暂存 + } + + iBet = 0; //默认不下注,nChip 由 CalcChip 各分支赋值 + if(!aBets.empty()){ //连续下注项 if(aBets[0]==0 || aBets[0]==4){ iBet = aBets[0]; @@ -695,18 +772,26 @@ void __fastcall TGame::CalcBet() void __fastcall TGame::CalcChip() { int iCP = iChipPolicy>=0 ? iChipPolicy : g_iChipPolicy; + if(iCP<0) + return; + TChipPolicy* pCP = (TChipPolicy*)g_aChipPolicies[iCP]; + TBetPolicy* pBP = (TBetPolicy*)g_aBetPolicies[iBetPolicy>=0 ? iBetPolicy : g_iBetPolicy]; + bool bGlobalChip = !bIndPolicy && (g_aGames.bFloat || pCP->kind>=KIND_CHIP_LEV && pCP->kind<=KIND_CHIP_WLD && ((TLevelPolicy*)pCP)->bTotalDiff); int& iCS = !bIndPolicy && g_aGames.bFloat ? g_aGames.iChipSeq : iChipSeq; + //方案切换检测(代码策略同样需要,否则切换策略时进度不重置) int uCP = iCS >> 20, uCRnk = (iCS & 0xFF000) >> 12, uCSeq = iCS & 0xFFF; if(uCP!=pCP->id){ //改用ID判断避免方案删除带来问题 uCRnk = uCSeq = 0; iCS = (pCP->id<<20); + sCtxSPC = ""; //注码策略切换时context清零 + bPreSPC = false; if(pCP->kind>=KIND_CHIP_HAN && pCP->kind<=KIND_CHIP_WLD){ TRankChip* pRC = bGlobalChip ? g_aGames.GetRankChip(pCP->kind) @@ -721,6 +806,19 @@ void __fastcall TGame::CalcChip() } } + //代码策略:SPC 在 CalcResult 暂存(初发在此评估一次),BWC 直接穿过 + if(pCP->kind==KIND_CHIP_SPE){ + if(!bPreSPC){ //CalcResult未暂存时评估:初发/新注码策略传0,无结算手(iBet=0/tie/op>=2后)传3 + nChip = 0; + TJSCodeRet bs; + if(EvalCodeJS(KIND_CHIP_SPE, pCP->code, bs, sCtxSPC.IsEmpty() ? 0 : 3)) + nChip = bs.iChip * (bIndPolicy ? nChipMul : g_nChipMul); + } + return; //暂存的 nChip 原样使用 + } + + nChip = 0; //非代码策略:由下方各分支赋值 + if(pCP->kind>=KIND_CHIP_HAN && pCP->kind<=KIND_CHIP_WLD){ TRankChip* pRC = bGlobalChip ? g_aGames.GetRankChip(pCP->kind) : GetRankChip(pCP->kind); @@ -752,7 +850,7 @@ int __fastcall TGame::CalcResult(int op) int uBP = iBetSeq >> 16, uBSeq = iBetSeq & 0xFFFF; - if(!iBet || !uBSeq)// || uBSeq>aRes.size() && op!=2)// || !nChip) 允许注码为0 + if(!iBet || !uBSeq) return 0; int dType = 0; //是否爆缆 @@ -814,71 +912,74 @@ int __fastcall TGame::CalcResult(int op) return ret; } - //处理注码步骤 + //处理注码步骤(打注一体无全局注码,iCP 为 -1,跳过本段) int iCP = iChipPolicy>=0 ? iChipPolicy : g_iChipPolicy; - TChipPolicy* pCP = (TChipPolicy*)g_aChipPolicies[iCP]; - bool bGlobalChip = !bIndPolicy && (g_aGames.bFloat || pCP->kind>=KIND_CHIP_LEV - && pCP->kind<=KIND_CHIP_WLD - && ((TLevelPolicy*)pCP)->bTotalDiff); - int& iCS = !bIndPolicy && g_aGames.bFloat ? g_aGames.iChipSeq : iChipSeq; - int uCP = iCS >> 20, - uCRnk = (iCS & 0xFF000) >> 12, - uCSeq = iCS & 0xFFF; - if(uCP!=pCP->id){ - uCRnk = uCSeq = 0; + TChipPolicy* pCP = iCP>=0 && iCP<(int)g_aChipPolicies.size() ? (TChipPolicy*)g_aChipPolicies[iCP] : NULL; - if(pCP->kind>=KIND_CHIP_HAN && pCP->kind<=KIND_CHIP_WLD){ - TRankChip* pRC = bGlobalChip ? g_aGames.GetRankChip(pCP->kind) - : GetRankChip(pCP->kind); - pRC->SetPolicy(pCP); + if(pCP){ + bool bGlobalChip = !bIndPolicy && (g_aGames.bFloat || pCP->kind>=KIND_CHIP_LEV + && pCP->kind<=KIND_CHIP_WLD + && ((TLevelPolicy*)pCP)->bTotalDiff); + int& iCS = !bIndPolicy && g_aGames.bFloat ? g_aGames.iChipSeq : iChipSeq; + int uCP = iCS >> 20, + uCRnk = (iCS & 0xFF000) >> 12, + uCSeq = iCS & 0xFFF; + if(uCP!=pCP->id){ + uCRnk = uCSeq = 0; + + if(pCP->kind>=KIND_CHIP_HAN && pCP->kind<=KIND_CHIP_WLD){ + TRankChip* pRC = bGlobalChip ? g_aGames.GetRankChip(pCP->kind) + : GetRankChip(pCP->kind); + pRC->SetPolicy(pCP); + } + else{ + if(bGlobalChip && g_aGames.pRankChip) + g_aGames.ClearRankChip(); + else + ClearRankChip(); + } } - else{ - if(bGlobalChip && g_aGames.pRankChip) - g_aGames.ClearRankChip(); - else - ClearRankChip(); + else if(pCP->kind>=KIND_CHIP_HAN && pCP->kind<=KIND_CHIP_WLD){ + TRankChip* pRC = bGlobalChip ? g_aGames.GetRankChip(pCP->kind) : GetRankChip(pCP->kind); + + if(pCP->kind==KIND_CHIP_COM && bGlobalChip && !g_aGames.bFloat && op<2) + uCSeq = ((TComboChip*)pRC)->GetRankSeq(ret, uCRnk, uCSeq); + + int rnk = (g_aGames.bFloat && g_aGames.iFloatGame!=iGame) ? uCRnk + : pRC->HandleResult(ret, wl); + if(rnk!=uCRnk){ + uCRnk = rnk; + uCSeq = 0; + } } - } - else if(pCP->kind>=KIND_CHIP_HAN && pCP->kind<=KIND_CHIP_WLD){ - TRankChip* pRC = bGlobalChip ? g_aGames.GetRankChip(pCP->kind) : GetRankChip(pCP->kind); - - if(pCP->kind==KIND_CHIP_COM && bGlobalChip && !g_aGames.bFloat && op<2) - uCSeq = ((TComboChip*)pRC)->GetRankSeq(ret, uCRnk, uCSeq); - - int rnk = (g_aGames.bFloat && g_aGames.iFloatGame!=iGame) ? uCRnk - : pRC->HandleResult(ret, wl); - if(rnk!=uCRnk){ - uCRnk = rnk; - uCSeq = 0; - } - } - else if(pCP->kind==KIND_CHIP_NOR && (!g_aGames.bFloat || g_aGames.iFloatGame==iGame)){ - TChipRow* pRow = (TChipRow*)pCP->aRows[uCSeq]; - if(ret==1) - uCSeq = pRow->iWin - 1; - else if(ret==2) - uCSeq = pRow->iLos - 1; - } - - if(uCSeq<0 || uCRnk<0){ - dType = pCP->dead + 1; - uCRnk = uCSeq = 0; - - g_aGames.betData.dead++; - - if(!bGlobalChip){ - TBetLog* pLog = NewBetLog(); - pLog->ev = LOGEVT_DEAD; - pLog->op = pCP->dead; - pLog->num = pCP->deadPause; - SendMessage(Application->MainFormHandle, UM_LOG_UPDATE, 0, (long)pLog); + else if(pCP->kind==KIND_CHIP_NOR && (!g_aGames.bFloat || g_aGames.iFloatGame==iGame)){ + TChipRow* pRow = (TChipRow*)pCP->aRows[uCSeq]; + if(ret==1) + uCSeq = pRow->iWin - 1; + else if(ret==2) + uCSeq = pRow->iLos - 1; } - PostMessage(Application->MainFormHandle, UM_STATE_UPDATE, STATE_MISC, 0); - } + if(uCSeq<0 || uCRnk<0){ + dType = pCP->dead + 1; + uCRnk = uCSeq = 0; - if(op<=2) //撤销不更新iCS - iCS = (pCP->id<<20) + (uCRnk<<12) + uCSeq; + g_aGames.betData.dead++; + + if(!bGlobalChip){ + TBetLog* pLog = NewBetLog(); + pLog->ev = LOGEVT_DEAD; + pLog->op = pCP->dead; + pLog->num = pCP->deadPause; + SendMessage(Application->MainFormHandle, UM_LOG_UPDATE, 0, (long)pLog); + } + + PostMessage(Application->MainFormHandle, UM_STATE_UPDATE, STATE_MISC, 0); + } + + if(op<=2) //撤销不更新iCS + iCS = (pCP->id<<20) + (uCRnk<<12) + uCSeq; + } if(wl!=0){ profit += wl; @@ -956,6 +1057,37 @@ int __fastcall TGame::CalcResult(int op) if(wl!=0) PostMessage(Application->MainFormHandle, UM_STATE_UPDATE, STATE_BET_R, ret); + //代码策略爆纤判定(结算侧):注码策略为特殊注码或打法策略为打注一体,每结算评估一次 + TBetPolicy* pBC = (TBetPolicy*)g_aBetPolicies[iBetPolicy>=0 ? iBetPolicy : g_iBetPolicy]; + bool bSPC = pCP && pCP->kind==KIND_CHIP_SPE; //打注一体时 pCP 无效 + + if(op<2 && (bSPC || pBC->kind==KIND_BET_WCH)){ + TJSCodeRet bs; + bool bOk = bSPC + ? EvalCodeJS(KIND_CHIP_SPE, pCP->code, bs, ret) //result 直接取本手结算 + : EvalCodeJS(KIND_BET_WCH, pBC->code, bs); //road 为最新路单 + + if(bOk){ + int iM = nChipMul<0 ? g_nChipMul : nChipMul; + + if(bSPC){ //SPC:暂存本手注码 + nChip = bs.iChip * iM; + bPreSPC = true; + } + else{ //BWC:暂存本手注码及下注方向 + iBet = bs.iBet; + nChip = bs.iChip * iM; + bPreBWC = true; + } + + if(bs.iBlast){ //爆缆直接生效(优先于既有层级注码爆缆) + dType = bs.iBlast; + if(bs.iBlast==3) + ret = (ret & ~0xFF00) | (bs.iBlastMinutes << 8); //暂停分钟进 0xFF00 + } + } + } + if(dType) ret += dType<<16; return ret; } @@ -964,6 +1096,7 @@ int __fastcall TGame::CalcResult(int op) void __fastcall TGame::HandleResult(int op) { timeout = 0; + bPreSPC = bPreBWC = false; //上一手已按结算消费完毕 if(!aManBets.empty()){ //处理手工下注 if(op==0){ //正常结算 @@ -1066,7 +1199,9 @@ void __fastcall TGame::HandleResult(int op) } if(dead && g_bGameOn){ - int pause = dead==3 ? ((TChipPolicy*)g_aChipPolicies[g_iChipPolicy])->deadPause : 0; + int min8 = (ret >> 8) & 0xFF; + int pause = dead==3 && min8 ? min8 + : (g_iChipPolicy>=0 ? ((TChipPolicy*)g_aChipPolicies[g_iChipPolicy])->deadPause : 0); SendMessage(Application->MainFormHandle, UM_FLOAT_DEAD, dead-1, pause); } } @@ -1075,7 +1210,9 @@ void __fastcall TGame::HandleResult(int op) if(dead && (bIndPolicy || !g_aGames.bFloat)){ if(!bIndPolicy && g_aGames.pRankChip){ // DebugPrint("总体阶梯爆缆"); - int pause = dead==3 ? ((TChipPolicy*)g_aChipPolicies[g_iChipPolicy])->deadPause : 0; + int min8 = (ret >> 8) & 0xFF; + int pause = dead==3 && min8 ? min8 + : (g_iChipPolicy>=0 ? ((TChipPolicy*)g_aChipPolicies[g_iChipPolicy])->deadPause : 0); SendMessage(Application->MainFormHandle, UM_GLOBAL_DEAD, dead-1, pause); } else{ @@ -1208,10 +1345,14 @@ void __fastcall TGame::AutoBetOn(bool bR) if(g_settings.bInitBetByGame){ //新局重置打法 iBet = iBetSeq = 0; aBets.clear(); + sCtxSPB = sCtxBWC = ""; //打法类策略context清零 } + bPreBWC = false; //洗牌后首局丢弃上一手暂存,强制 BWC 用新靴路单重评估 if(g_settings.bInitChipByGame){ //新局重置注码 nChip = iChipSeq = 0; + sCtxSPC = ""; //特殊注码context清零 + bPreSPC = false; } if(g_settings.bInitProfitByGame && profit!=0 //新局重置赢利 @@ -1222,8 +1363,8 @@ void __fastcall TGame::AutoBetOn(bool bR) } } - if(aBets.empty()) //连续下注可从新局开始 - return; +// if(aBets.empty()) //连续下注可从新局开始 +// return; } if(bBreak || gmstatus!=1 || !CanBet() || !g_bSimulate && timeout<3){ //非下注状态/暂停中/实打时间太短,放弃 @@ -1258,8 +1399,9 @@ void __fastcall TGame::AutoBetOn(bool bR) } if(iBet==0 || iBet==4){ - if(!aBets.empty()){//连续下注 不打/局停不可取消 - aBets.erase(aBets.begin()); //删除本项 + if(!aBets.empty()){ + if(!aBets.empty()) + aBets.erase(aBets.begin()); //删除本项 iState = ST_NOBET; if(hTable) PostMessage(hTable, UM_LOG_UPDATE, iState, 0); @@ -1303,7 +1445,10 @@ void __fastcall TGame::AutoBetOff(bool bB) if(iState==ST_BETSET || iState==ST_BETTING){ //下注超时或取消 iState = ST_CANCELED; - iBet = nChip = 0; + + //CalcResult暂存的值需保留 + if(!bPreBWC) iBet = 0; + if(!bPreSPC && !bPreBWC) nChip = 0; // iBetSeq &= 0xFFFF0000; // aBets.clear(); @@ -1437,9 +1582,13 @@ void __fastcall TGame::Shuffle() if(g_settings.bInitBetByGame){ //新局重置打法 iBet = iBetSeq = 0; aBets.clear(); + sCtxSPB = sCtxBWC = ""; //打法类策略context清零 } + bPreBWC = false; if(g_settings.bInitChipByGame){ //新局重置注码 nChip = iChipSeq = 0; + sCtxSPC = ""; //特殊注码context清零 + bPreSPC = false; } iState = ST_INIT; @@ -1720,12 +1869,14 @@ void __fastcall TGameArray::GameOn() iChipSeq = iFloatGame = 0; memset(seqCount, 0, sizeof(seqCount)); - TChipPolicy* pCP = (TChipPolicy*)g_aChipPolicies[g_iChipPolicy]; - if(pCP->kind>=KIND_CHIP_HAN && pCP->kind<=KIND_CHIP_WLD){ - GetRankChip(pCP->kind)->SetPolicy(pCP); + if(g_iChipPolicy>=0){ //打注一体时无全局注码 + TChipPolicy* pCP = (TChipPolicy*)g_aChipPolicies[g_iChipPolicy]; + if(pCP->kind>=KIND_CHIP_HAN && pCP->kind<=KIND_CHIP_WLD){ + GetRankChip(pCP->kind)->SetPolicy(pCP); - if(g_settings.bInitBetChipByStart) - pRankChip->Reset(); + if(g_settings.bInitBetChipByStart) + pRankChip->Reset(); + } } } else if(g_settings.bInitBetChipByStart){ diff --git a/GameUnit.h b/GameUnit.h index 9ff0bb4..9d8eeea 100644 --- a/GameUnit.h +++ b/GameUnit.h @@ -228,13 +228,15 @@ public: class TTableFrame; //代码策略(特殊打法/打注一体/特殊注码)求值结果:生产方TMainForm解析JSON,TGame直接按字段使用 -struct TJSCodeRet{ +typedef struct tagJSCodeRet{ int iBet; //下注项:0=不打 1=庄 2=闲 3=和 4=局停,未输出=-1 int iChip; //基码个数:未输出=-1 int iBlast; //爆缆动作:0=无 1=停止 2=新局重开 3=暂停重开 int iBlastMinutes; String sCtx; //下一轮透传的 context 对象串(JS原样序列化,空串=未初始化) -}; + + tagJSCodeRet(){iBet=iChip=iBlast=iBlastMinutes=0;}; +} TJSCodeRet; class TGame { @@ -274,6 +276,8 @@ public: String sCtxSPB, //calcBet(road,context) sCtxSPC, //calcChip(result,chipMult,context) sCtxBWC; //calcBetWithChip(road,chipMult,context) + bool bPreSPC, //CalcResult已为下一手预存 nChip(SPC) + bPreBWC; //CalcResult已为下一手预存 iBet/nChip(BWC) vector aManBets; //手工下注 @@ -321,6 +325,9 @@ public: void __fastcall ClearRankChip(); TRankChip* __fastcall GetRankChip(int type); void __fastcall ResetIP(); + + //代码策略执行辅助(内部统一入口,失败已停台+三写日志;ctx由kind映射读写) + bool __fastcall EvalCodeJS(int kind, const String& sCode, TJSCodeRet& bs, int iCodeIn=0); }; class TGameArray : public vector diff --git a/PolicyCoder.cbproj b/PolicyCoder.cbproj new file mode 100644 index 0000000..6da1e59 --- /dev/null +++ b/PolicyCoder.cbproj @@ -0,0 +1,1182 @@ + + + {071CF3C1-D05C-4751-B8F5-F09C03C6DDEB} + 20.5 + VCL + True + Debug + Win32 + PolicyCoder + 1 + Console + c + + + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Base + true + + + true + Cfg_1 + true + true + + + true + Cfg_1 + true + true + + + true + Base + true + + + true + Cfg_2 + true + true + + + JPHNE + .\$(Platform)\$(Config) + .\$(Platform)\$(Config) + false + true + true + $(BDSLIB)\$(PLATFORM)\release\$(LANGDIR);$(ILINK_TranslatedLibraryPath) + CppConsoleApplication + System;Xml;Data;Datasnap;Web;Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;$(DCC_Namespace) + rtl.lib;vcl.lib + true + ..\Global\;RBmaster\;$(IncludePath) + ..\Global\;RBmaster\;$(ILINK_LibraryPath) + <_TCHARMapping>wchar_t + PolicyCoder + None + 2052 + CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= + + + adortl;bcbie;bcbsmp;bindcomp;bindcompdbx;bindcompfmx;bindcompvcl;bindcompvclsmp;bindcompvclwinx;bindengine;CEF4DelphiFMXRTL;CEF4DelphiVCLRTL;CloudService;CustomIPTransport;DataSnapClient;DataSnapCommon;DataSnapConnectors;DatasnapConnectorsFreePascal;DataSnapFireDAC;DataSnapIndy10ServerTransport;DataSnapNativeClient;DataSnapProviderClient;DataSnapServer;DataSnapServerMidas;dbexpress;dbrtl;dbxcds;DbxClientDriver;DbxCommonDriver;DBXDb2Driver;DBXFirebirdDriver;DBXInformixDriver;DBXInterBaseDriver;DBXMSSQLDriver;DBXMySQLDriver;DBXOdbcDriver;DBXOracleDriver;DBXSqliteDriver;DBXSybaseASADriver;DBXSybaseASEDriver;dsnap;dsnapcon;dsnapxml;emsclient;emsclientfiredac;emsedge;emshosting;emsserverresource;FireDAC;FireDACADSDriver;FireDACASADriver;FireDACCommon;FireDACCommonDriver;FireDACCommonODBC;FireDACDb2Driver;FireDACDBXDriver;FireDACDSDriver;FireDACIBDriver;FireDACInfxDriver;FireDACMongoDBDriver;FireDACMSAccDriver;FireDACMSSQLDriver;FireDACMySQLDriver;FireDACODBCDriver;FireDACOracleDriver;FireDACPgDriver;FireDACSqliteDriver;FireDACTDataDriver;fmx;fmxase;fmxdae;fmxFireDAC;fmxobj;IndyCore;IndyIPClient;IndyIPCommon;IndyIPServer;IndyProtocols;IndySystem;inet;inetdb;inetdbxpress;inetstn;RESTBackendComponents;RESTComponents;rtl;Skia;SmartCoreAI;SmartCoreAIFMX;SmartCoreAIVCL;soapmidas;soaprtl;soapserver;TCapButton;TCKBox;TComboBoxComponent;tethering;TGeneralDialogPanel;TLineEdit;TPNGButton;TRadioBtn;TSkinTrackBar;TTextButton;vcl;vclactnband;vcldb;vcldsnap;vcledge;vclFireDAC;vclie;vclimg;VCLRESTComponents;VclSmp;vcltouch;vclwinx;vclwinxnav;vclx;xmlrtl;$(PackageImports) + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;Bde;$(DCC_Namespace) + Debug + CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= + 1033 + $(BDS)\bin\Artwork\Windows\UWP\cppreg_UwpDefault_44.png + $(BDS)\bin\Artwork\Windows\UWP\cppreg_UwpDefault_150.png + $(BDSINCLUDE)\windows\vcl;$(IncludePath) + + + adortl;bcbie;bcbsmp;bindcomp;bindcompdbx;bindcompfmx;bindcompvcl;bindcompvclsmp;bindcompvclwinx;bindengine;CEF4DelphiFMXRTL;CEF4DelphiVCLRTL;CloudService;CustomIPTransport;DataSnapClient;DataSnapCommon;DataSnapConnectors;DatasnapConnectorsFreePascal;DataSnapFireDAC;DataSnapIndy10ServerTransport;DataSnapNativeClient;DataSnapProviderClient;DataSnapServer;DataSnapServerMidas;dbexpress;dbrtl;dbxcds;DbxClientDriver;DbxCommonDriver;DBXDb2Driver;DBXFirebirdDriver;DBXInformixDriver;DBXInterBaseDriver;DBXMSSQLDriver;DBXMySQLDriver;DBXOdbcDriver;DBXOracleDriver;DBXSqliteDriver;DBXSybaseASADriver;DBXSybaseASEDriver;dsnap;dsnapcon;dsnapxml;emsclient;emsclientfiredac;emsedge;emshosting;emsserverresource;FireDAC;FireDACADSDriver;FireDACASADriver;FireDACCommon;FireDACCommonDriver;FireDACCommonODBC;FireDACDb2Driver;FireDACDBXDriver;FireDACDSDriver;FireDACIBDriver;FireDACInfxDriver;FireDACMongoDBDriver;FireDACMSAccDriver;FireDACMSSQLDriver;FireDACMySQLDriver;FireDACODBCDriver;FireDACOracleDriver;FireDACPgDriver;FireDACSqliteDriver;FireDACTDataDriver;fmx;fmxase;fmxdae;fmxFireDAC;fmxobj;IndyCore;IndyIPClient;IndyIPCommon;IndyIPServer;IndyProtocols;IndySystem;inet;inetdb;inetdbxpress;inetstn;RESTBackendComponents;RESTComponents;rtl;Skia;SmartCoreAI;SmartCoreAIFMX;SmartCoreAIVCL;soapmidas;soaprtl;soapserver;tethering;vcl;vclactnband;vcldb;vcldsnap;vcledge;vclFireDAC;vclie;vclimg;VCLRESTComponents;VclSmp;vcltouch;vclwinx;vclwinxnav;vclx;xmlrtl;$(PackageImports) + $(BDS)\bin\Artwork\Windows\UWP\cppreg_UwpDefault_44.png + $(BDS)\bin\Artwork\Windows\UWP\cppreg_UwpDefault_150.png + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) + Debug + CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= + 1033 + $(BDSINCLUDE)\windows\vcl;$(IncludePath) + + + adortl;bcbsmp;bindcomp;bindcompdbx;bindcompfmx;bindcompvcl;bindcompvclsmp;bindcompvclwinx;bindengine;CloudService;CustomIPTransport;DataSnapClient;DataSnapCommon;DataSnapConnectors;DatasnapConnectorsFreePascal;DataSnapFireDAC;DataSnapIndy10ServerTransport;DataSnapNativeClient;DataSnapProviderClient;DataSnapServer;DataSnapServerMidas;dbexpress;dbrtl;dbxcds;DbxClientDriver;DbxCommonDriver;DBXDb2Driver;DBXFirebirdDriver;DBXInformixDriver;DBXInterBaseDriver;DBXMSSQLDriver;DBXMySQLDriver;DBXOdbcDriver;DBXOracleDriver;DBXSqliteDriver;DBXSybaseASADriver;DBXSybaseASEDriver;dsnap;dsnapcon;dsnapxml;emsclient;emsclientfiredac;emsedge;emshosting;emsserverresource;FireDAC;FireDACADSDriver;FireDACASADriver;FireDACCommon;FireDACCommonDriver;FireDACCommonODBC;FireDACDb2Driver;FireDACDBXDriver;FireDACDSDriver;FireDACIBDriver;FireDACInfxDriver;FireDACMongoDBDriver;FireDACMSAccDriver;FireDACMSSQLDriver;FireDACMySQLDriver;FireDACODBCDriver;FireDACOracleDriver;FireDACPgDriver;FireDACSqliteDriver;FireDACTDataDriver;fmx;fmxase;fmxdae;fmxFireDAC;fmxobj;IndyCore;IndyIPClient;IndyIPCommon;IndyIPServer;IndyProtocols;IndySystem;inet;inetdb;inetdbxpress;inetstn;RESTBackendComponents;RESTComponents;rtl;Skia;SmartCoreAI;SmartCoreAIFMX;SmartCoreAIVCL;soapmidas;soaprtl;soapserver;TCapButton;TCKBox;TComboBoxComponent;tethering;TGeneralDialogPanel;TLineEdit;TRadioBtn;TSkinTrackBar;TTextButton;vcl;vclactnband;vcldb;vcldsnap;vcledge;vclFireDAC;vclie;vclimg;VCLRESTComponents;VclSmp;vcltouch;vclwinx;vclwinxnav;vclx;xmlrtl;$(PackageImports) + $(BDS)\bin\Artwork\Windows\UWP\cppreg_UwpDefault_44.png + $(BDS)\bin\Artwork\Windows\UWP\cppreg_UwpDefault_150.png + Winapi;System.Win;Data.Win;Datasnap.Win;Web.Win;Soap.Win;Xml.Win;$(DCC_Namespace) + Debug + CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments= + 1033 + true + + + false + true + false + true + _DEBUG;$(Defines) + false + None + DEBUG + true + true + true + true + Full + true + true + true + true + true + $(BDSLIB)\$(PLATFORM)\debug;$(ILINK_LibraryPath) + $(BDSLIB)\$(PLATFORM)\debug\$(LANGDIR);$(ILINK_TranslatedLibraryPath) + + + false + $(BDSLIB)\$(PLATFORM)$(CC_SUFFIX)\debug;$(ILINK_LibraryPath) + rtl.lib;vcl.lib + 1033 + import01-大眼.bpf + (None) + none + + + rtl.lib;vcl.lib + 1033 + (None) + none + + + NDEBUG;$(Defines) + None + + + false + + + + ..\Global\GlobalUnit.h + 2 + + + 3 + + + 1 + + + PolicyUnit.h + 1 + + + Base + + + Cfg_1 + Base + + + Cfg_2 + Base + + + + CPlusPlusBuilder.Personality.12 + CppConsoleApplication + + + + False + True + True + False + + + Embarcadero C++Builder Office 2000 Servers Package + Embarcadero C++Builder Office XP Servers Package + Microsoft Office 2000 Sample Automation Server Wrapper Components + Microsoft Office XP Sample Automation Server Wrapper Components + + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + true + + + + + PolicyCoder.exe + true + + + + + PolicyCoder.tds + true + + + + + PolicyCoder.exe + true + + + + + PolicyCoder.pdb + true + + + + + 1 + + + 0 + + + + + res\xml + 1 + + + res\xml + 1 + + + + + library\lib\armeabi + 1 + + + library\lib\armeabi + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + library\lib\mips + 1 + + + library\lib\mips + 1 + + + + + library\lib\armeabi-v7a + 1 + + + library\lib\arm64-v8a + 1 + + + + + library\lib\armeabi-v7a + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable-anydpi-v21 + 1 + + + res\drawable-anydpi-v21 + 1 + + + + + res\values + 1 + + + res\values + 1 + + + + + res\values-v21 + 1 + + + res\values-v21 + 1 + + + + + res\values-v31 + 1 + + + res\values-v31 + 1 + + + + + res\values-v35 + 1 + + + res\values-v35 + 1 + + + + + res\drawable-anydpi-v26 + 1 + + + res\drawable-anydpi-v26 + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable-anydpi-v33 + 1 + + + res\drawable-anydpi-v33 + 1 + + + + + res\values + 1 + + + res\values + 1 + + + + + res\values-night-v21 + 1 + + + res\values-night-v21 + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable-xxhdpi + 1 + + + res\drawable-xxhdpi + 1 + + + + + res\drawable-xxxhdpi + 1 + + + res\drawable-xxxhdpi + 1 + + + + + res\drawable-ldpi + 1 + + + res\drawable-ldpi + 1 + + + + + res\drawable-mdpi + 1 + + + res\drawable-mdpi + 1 + + + + + res\drawable-hdpi + 1 + + + res\drawable-hdpi + 1 + + + + + res\drawable-xhdpi + 1 + + + res\drawable-xhdpi + 1 + + + + + res\drawable-mdpi + 1 + + + res\drawable-mdpi + 1 + + + + + res\drawable-hdpi + 1 + + + res\drawable-hdpi + 1 + + + + + res\drawable-xhdpi + 1 + + + res\drawable-xhdpi + 1 + + + + + res\drawable-xxhdpi + 1 + + + res\drawable-xxhdpi + 1 + + + + + res\drawable-xxxhdpi + 1 + + + res\drawable-xxxhdpi + 1 + + + + + res\drawable-small + 1 + + + res\drawable-small + 1 + + + + + res\drawable-normal + 1 + + + res\drawable-normal + 1 + + + + + res\drawable-large + 1 + + + res\drawable-large + 1 + + + + + res\drawable-xlarge + 1 + + + res\drawable-xlarge + 1 + + + + + res\values + 1 + + + res\values + 1 + + + + + res\drawable-anydpi-v24 + 1 + + + res\drawable-anydpi-v24 + 1 + + + + + res\drawable + 1 + + + res\drawable + 1 + + + + + res\drawable-night-anydpi-v21 + 1 + + + res\drawable-night-anydpi-v21 + 1 + + + + + res\drawable-anydpi-v31 + 1 + + + res\drawable-anydpi-v31 + 1 + + + + + res\drawable-night-anydpi-v31 + 1 + + + res\drawable-night-anydpi-v31 + 1 + + + + + 1 + + + 1 + + + 0 + + + + + 1 + .framework + + + 1 + .framework + + + 1 + .framework + + + 0 + + + + + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + 0 + .dll;.bpl + + + + + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + 1 + .dylib + + + 0 + .bpl + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + 1 + + + 1 + + + + + + + + Contents\Resources + 1 + + + Contents\Resources + 1 + + + Contents\Resources + 1 + + + + + library\lib\armeabi-v7a + 1 + + + library\lib\arm64-v8a + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + 1 + + + 0 + + + + + library\lib\armeabi-v7a + 1 + + + + + 1 + + + 1 + + + 1 + + + 1 + + + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + ..\$(PROJECTNAME).app.dSYM\Contents\Resources\DWARF + 1 + + + + + + + + 1 + + + 1 + + + 1 + + + + + Assets + 1 + + + Assets + 1 + + + Assets + 1 + + + Assets + 1 + + + + + Assets + 1 + + + Assets + 1 + + + Assets + 1 + + + Assets + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\LaunchScreenImage.imageset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + ..\$(PROJECTNAME).launchscreen\Assets\AppIcon.appiconset + 1 + + + + + + + + + + + + + + + + + + True + False + False + + + 12 + + + + + diff --git a/PolicyCoder.cpp b/PolicyCoder.cpp new file mode 100644 index 0000000..e285483 --- /dev/null +++ b/PolicyCoder.cpp @@ -0,0 +1,334 @@ +#include +#include +#include +#include +#include + +#include "PolicyUnit.h" + +// 读整个文件到 String (UTF-8 字节 → UTF-16) +String ReadFileUTF8(const String& path) +{ + char szPath[1024]; + sprintf(szPath, "%s", ((UTF8String)path).c_str()); + FILE* fp = fopen(szPath, "rb"); + if(!fp) + return String(); + + fseek(fp, 0, SEEK_END); + long size = ftell(fp); + fseek(fp, 0, SEEK_SET); + + if(size <= 0){ + fclose(fp); + return String(); + } + + char* buf = new char[size + 1]; + size_t n = fread(buf, 1, size, fp); + buf[n] = 0; + fclose(fp); + + // UTF-8 字节 → UTF-16 String + String result = String((UTF8String)buf); + delete[] buf; + return result; +} + +// 按换行分行,解析 key=value +bool ParseConfig(const String& text, int& iType, int& iKind, int& iRoad, + String& sName, String& sDesc, String& sCode, int& iMiniChip) +{ + iType = -1; iKind = -1; iRoad = 0; iMiniChip = 0; + sName = sDesc = sCode = String(); + + // 去掉 \r,按 \n 分行 + std::vector lines; + { + String cur; + for(int i = 1; i <= text.Length(); i++){ + wchar_t c = text[i]; + if(c == L'\r') continue; + if(c == L'\n'){ + lines.push_back(cur); + cur = String(); + } else { + cur += c; + } + } + if(cur.Length() > 0) + lines.push_back(cur); + } + + for(size_t i = 0; i < lines.size(); i++){ + String line = TrimRight(lines[i]); + if(line.Length() == 0) continue; + if(line[1] == L'#') continue; + + // Pos 是 1-based,返回 = 在 line 中的位置(从 1 开始) + int eqPos = 0; + for(int j = 1; j <= line.Length(); j++){ + if(line[j] == L'='){ + eqPos = j; + break; + } + } + if(eqPos <= 1) continue; + + String key = TrimRight(line.SubString(1, eqPos - 1)); + String val = line.SubString(eqPos + 1, line.Length() - eqPos); + + // trim 两侧空格 + while(val.Length() > 0 && val[1] == L' ') + val = val.SubString(2, val.Length() - 1); + while(val.Length() > 1 && val[val.Length()] == L' ') + val = val.SubString(1, val.Length() - 1); + + if(key == "type") iType = StrToInt(val); + else if(key == "kind") iKind = StrToInt(val); + else if(key == "road") iRoad = StrToInt(val); + else if(key == "name") sName = val; + else if(key == "desc") sDesc = val; + else if(key == "code") sCode = val; + else if(key == "miniChip") iMiniChip = StrToInt(val); + else { + wprintf(L" 警告: 未知 key '%ls'\n", key.c_str()); + } + } + + return iType >= 0 && iKind > 0 && sName.Length() > 0 && sCode.Length() > 0; +} + +// 取路径的目录部分(含末尾分隔符);无分隔符则返回空串 +String GetDirPart(const String& path) +{ + int lastSep = 0; + for(int i = 1; i <= path.Length(); i++){ + if(path[i] == L'\\' || path[i] == L'/') + lastSep = i; + } + if(lastSep > 0) + return path.SubString(1, lastSep); + return String(); +} + +// 检查扩展名(小写比较),返回 .bpf=0, .cpf=1, 其他=-1 +int CheckExt(const String s) +{ + int l = s.Length(); + if(l < 4) return -1; + String ext = s.SubString(l - 2, 3).LowerCase(); + if(ext == L"bpf") return 0; + if(ext == L"cpf") return 1; + return -1; +} + +// 取文件名(不含目录、不含扩展名) +String GetFileNameNoExt(const String& path) +{ + int lastSep = 0; + for(int i = path.Length(); i >= 1; i--){ + if(path[i] == L'\\' || path[i] == L'/'){ + lastSep = i; + break; + } + } + String file = lastSep > 0 ? path.SubString(lastSep + 1, path.Length() - lastSep) : path; + // 去掉扩展名 + for(int i = file.Length(); i >= 1; i--){ + if(file[i] == L'.'){ + return file.SubString(1, i - 1); + } + } + return file; +} + +// 从 .bpf/.cpf 提取策略字段,写入 UTF-8 key=value 的 .txt;成功 0,失败负数 +int PolicyToText(const String& szInput, const String& szOutFile) +{ + int type = CheckExt(szInput); + if(type < 0) + return -1; + + TBasePolicy* p = NULL; + int ret = ImportPolicy(type, szInput, p); + if(ret != 0){ + wprintf(L"ImportPolicy 失败 (ret=%d)\n", ret); + delete p; + return -1; + } + + char szOut[1024]; + sprintf(szOut, "%s", ((UTF8String)szOutFile).c_str()); + FILE* fw = fopen(szOut, "w"); + if(!fw){ + delete p; + return -2; + } + + fprintf(fw, "type=%d\n", type); + fprintf(fw, "kind=%d\n", p->kind); + fprintf(fw, "name=%s\n", ((UTF8String)p->name).c_str()); + + if(p->desc.Length() > 0) + fprintf(fw, "desc=%s\n", ((UTF8String)p->desc).c_str()); + + if(IsCodePolicy(p->kind)){ + if(p->code.Length() > 0) + fprintf(fw, "code=%s\n", ((UTF8String)p->code).c_str()); + } + + if(type == TYPE_P_BET){ + fprintf(fw, "road=%d\n", ((TBetPolicy*)p)->road); + } + + int iMiniChip = 0; + if(type == TYPE_P_BET && p->kind == KIND_BET_WCH){ + iMiniChip = ((TBetChipPolicy*)p)->miniChip; + } + else if(type == TYPE_P_CHIP && IsCodePolicy(p->kind)){ + iMiniChip = ((TChipPolicy*)p)->miniChip; + } + if(iMiniChip > 0) + fprintf(fw, "miniChip=%d\n", iMiniChip); + + fclose(fw); + delete p; + return 0; +} + +// 解析 .txt 配置,校验并导出为 .bpf/.cpf;成功 0,失败负数 +int TextToPolicy(const String& szInput, const String& szOutFile) +{ + String text = ReadFileUTF8(szInput); + if(text.Length() == 0){ + wprintf(L"无法读取文件: %s\n", szInput.c_str()); + return -1; + } + + int iType, iKind, iRoad, iMiniChip; + String sName, sDesc, sCode; + if(!ParseConfig(text, iType, iKind, iRoad, sName, sDesc, sCode, iMiniChip)){ + wprintf(L"配置不完整: 需要 type, kind, name, code\n"); + return -2; + } + + // 缺省输出文件名 + String szOut = szOutFile; + if(szOut.Length() == 0){ + szOut = GetDirPart(szInput) + sName + (iType == TYPE_P_BET ? L".bpf" : L".cpf"); + } + + if(!IsCodePolicy(iKind)){ + wprintf(L"kind=%d 不是代码策略 (需要 101/102/121)\n", iKind); + return -3; + } + if(iType == TYPE_P_BET){ + if(iRoad < 0 || iRoad > 4){ + wprintf(L"road=%d 超出范围 (0-4)\n", iRoad); + return -4; + } + if(iKind != KIND_BET_SPE && iKind != KIND_BET_WCH){ + wprintf(L"type=0 时 kind 必须是 101 或 102\n"); + return -5; + } + } else if(iType == TYPE_P_CHIP){ + if(iKind != KIND_CHIP_SPE){ + wprintf(L"type=1 时 kind 必须是 121\n"); + return -6; + } + } else { + wprintf(L"type=%d 无效 (0=打法 1=注码)\n", iType); + return -7; + } + if(iMiniChip <= 0 && (iKind == KIND_BET_WCH || iKind == KIND_CHIP_SPE)){ + wprintf(L"kind=%d 需要 miniChip>0\n", iKind); + return -8; + } + + TBasePolicy* pPolicy = nullptr; + if(iType == TYPE_P_BET){ + if(iKind == KIND_BET_WCH){ + TBetChipPolicy* p = new TBetChipPolicy(); + p->road = iRoad; + p->code = sCode; + p->miniChip = iMiniChip; + pPolicy = p; + } else { + TBetPolicy* p = new TBetPolicy(); + p->road = iRoad; + p->code = sCode; + pPolicy = p; + } + } else { + TChipPolicy* p = new TChipPolicy(); + p->code = sCode; + p->miniChip = iMiniChip; + pPolicy = p; + } + + pPolicy->name = sName; + pPolicy->desc = sDesc; + pPolicy->type = 2; + pPolicy->id = 0; + pPolicy->kind = iKind; + pPolicy->actived = true; + + int ret = ExportPolicy(iType, pPolicy, szOut); + delete pPolicy; + + if(ret != 0) + wprintf(L"导出失败 (ret=%d)\n", ret); + return ret; +} + +int _tmain(int argc, _TCHAR* argv[]) +{ + if(argc < 2){ + wprintf(L"用法: PolicyCoder.exe [output.bpf|output.cpf]\n"); + wprintf(L" input.txt: UTF-8 配置文件,key=value 格式\n"); + wprintf(L" 支持的 key: type(0/1) kind(101/102/121) road(0-4) name desc code miniChip\n"); + wprintf(L" 输出: 缺省用 .bpf 或 .cpf,与 input.txt 同目录\n"); + wprintf(L"\n"); + wprintf(L"用法: PolicyCoder.exe [output.txt]\n"); + wprintf(L" 从策略文件提取 type/kind/name/desc/code/road/miniChip 写入 .txt\n"); + wprintf(L" 输出: 缺省用 <同名>.txt,与 input.bpf/cpf 同目录\n"); + return 1; + } + + String szInput = argv[1]; + + // 如果是 .bpf/.cpf → 提取模式 + int extType = CheckExt(szInput); + if(extType >= 0){ + String outFile; + if(argc >= 3){ + outFile = argv[2]; + } else { + String dir = GetDirPart(szInput); + outFile = dir + GetFileNameNoExt(szInput) + L".txt"; + } + + int ret = PolicyToText(szInput, outFile); + if(ret == 0) + wprintf(L"成功: %s\n", outFile.c_str()); + else + wprintf(L"提取失败 (ret=%d)\n", ret); + return ret == 0 ? 0 : 1; + } + + // .txt 导入模式 + String outFile; + if(argc >= 3){ + outFile = argv[2]; + } else { + outFile = String(); // 由 TextToPolicy 内部分配 + } + + int ret = TextToPolicy(szInput, outFile); + if(ret == 0) + wprintf(L"成功: %s\n", outFile.c_str()); + else + wprintf(L"导出失败 (ret=%d)\n", ret); + return ret == 0 ? 0 : 1; +} diff --git a/PolicyEditFormUnit.cpp b/PolicyEditFormUnit.cpp index b3aa78c..b1d30d9 100644 --- a/PolicyEditFormUnit.cpp +++ b/PolicyEditFormUnit.cpp @@ -83,6 +83,13 @@ void __fastcall TPolicyEditForm::TopDrawTab(TObject *Sender, TCanvas *TabCanvas, //--------------------------------------------------------------------------- void __fastcall TPolicyEditForm::TopChange(TObject *Sender, int NewTab, bool &AllowChange) { + //打注一体由打法策略自带注码,禁止切到注码页签 + if(m_iType==TYPE_P_BET && NewTab==TYPE_P_CHIP && g_iBetPolicy>=0 + && g_aBetPolicies[g_iBetPolicy]->kind==KIND_BET_WCH){ + AllowChange = false; + return; + } + SetView(NewTab); } //--------------------------------------------------------------------------- @@ -93,8 +100,8 @@ void __fastcall TPolicyEditForm::SetView(int type) m_lblPolicy->Caption = "编辑" + m_sType + ":"; m_cbPolicy->Text = "请选择" + m_sType; - m_btnSave->Caption = "保存" + m_sType; - m_btnSelect->Caption = "选择该" + m_sType; +// m_btnSave->Caption = "保存" + m_sType; +// m_btnSelect->Caption = "选择该" + m_sType; m_panChip->Visible = type==TYPE_P_CHIP; m_rgRoad->Visible = type==TYPE_P_BET; @@ -141,6 +148,7 @@ void __fastcall TPolicyEditForm::SetView(int type) m_cbPolicy->Text = AutoNewName(); UpdateGrid(); + UpdateExportBtn(); } //--------------------------------------------------------------------------- void __fastcall TPolicyEditForm::ClearSPFrame() @@ -178,9 +186,9 @@ void __fastcall TPolicyEditForm::UpdateGrid() { m_btnDelRow->Enabled = false; m_btnInsRow->Enabled = false; - m_btnSave->Enabled = m_bRowChanged = m_bColChanged = !m_editPolicy; - m_bRoadChanged = false; - m_btnSelect->Enabled = m_editPolicy; + m_btnSave->Enabled = m_bRowChanged = m_bColChanged = !m_editPolicy; + m_bRoadChanged = false; + m_btnSelect->Enabled = m_editPolicy; m_btnDel->Enabled = m_editPolicy && m_editPolicy->type>1; ClearSPFrame(); @@ -197,6 +205,12 @@ void __fastcall TPolicyEditForm::UpdateGrid() frmSP->m_lblTitle->Caption = (pBP->kind==KIND_BET_WCH ? "打注一体:" : "特殊打法:") + pBP->name; frmSP->SetDesc( pBP->desc ); + String sOption = pBP->road==1 ? "大路" : pBP->road==2 ? "大眼路" : pBP->road==3 ? "小路" + : pBP->road==4 ? "小强路" : "珠盘路"; + if(pBP->kind==KIND_BET_WCH) + sOption += " 最小注码:" + IntToStr(((TBetChipPolicy*)pBP)->miniChip); + frmSP->m_lblOption->Caption = sOption; + m_frmSP->Parent = m_panEdit; m_frmSP->Width = m_panEdit->Width; m_frmSP->Show(); @@ -243,6 +257,8 @@ void __fastcall TPolicyEditForm::UpdateGrid() frmSP->m_lblTitle->Caption = "特殊注码:" + pCP->name; frmSP->SetDesc( pCP->desc ); + frmSP->m_lblOption->Caption = "最小注码:" + IntToStr(pCP->miniChip); + m_frmSP->Parent = m_panEdit; m_frmSP->Width = m_panEdit->Width; m_frmSP->Show(); @@ -857,6 +873,7 @@ void __fastcall TPolicyEditForm::OnPolicyChange(TObject *Sender) Clear(); UpdateGrid(); + UpdateExportBtn(); } } //--------------------------------------------------------------------------- @@ -872,6 +889,7 @@ void __fastcall TPolicyEditForm::OnAddClick(TObject *Sender) Clear(); UpdateGrid(); + UpdateExportBtn(); } //--------------------------------------------------------------------------- void __fastcall TPolicyEditForm::OnSaveClick(TObject *Sender) @@ -885,6 +903,8 @@ void __fastcall TPolicyEditForm::OnSaveClick(TObject *Sender) g_RandomChip.minChip = Min(c1, c2); g_RandomChip.maxChip = Max(c1, c2); + ((TChipPolicy*)m_editPolicy)->miniChip = g_RandomChip.minChip; + m_btnSave->Enabled = false; return; @@ -1103,6 +1123,7 @@ void __fastcall TPolicyEditForm::OnSaveClick(TObject *Sender) m_editPolicy = pTmpPolicy; m_btnSave->Enabled = m_bRowChanged = m_bColChanged = false; + UpdateExportBtn(); m_btnSelect->Enabled = true; m_btnDel->Enabled = true; @@ -1322,6 +1343,8 @@ void __fastcall TPolicyEditForm::InitChipGrid(int kind) Hint = "常规注码按每次投注的输赢结果决定走向('和'不变)"; } } + + UpdateExportBtn(); } //--------------------------------------------------------------------------- void __fastcall TPolicyEditForm::OnChipOptionClick(TObject *Sender) @@ -1351,7 +1374,7 @@ void __fastcall TPolicyEditForm::OnTipClick(TObject *Sender) PostMessage(Application->MainFormHandle, UM_OPENMAUAL, 1, 0); } //--------------------------------------------------------------------------- -void __fastcall TPolicyEditForm::OnExport(TObject *Sender) +void __fastcall TPolicyEditForm::OnGridExport(TObject *Sender) { TStringGrid* pSG = m_sg; @@ -1434,7 +1457,7 @@ void __fastcall TPolicyEditForm::OnExport(TObject *Sender) delete pDlg; } //--------------------------------------------------------------------------- -void __fastcall TPolicyEditForm::OnImport(TObject *Sender) +void __fastcall TPolicyEditForm::OnGridImport(TObject *Sender) { TStringGrid* pSG = m_sg; @@ -1546,4 +1569,135 @@ void __fastcall TPolicyEditForm::OnImport(TObject *Sender) delete pDlg; } //--------------------------------------------------------------------------- +void __fastcall TPolicyEditForm::UpdateExportBtn() +{ //禁出:庄闲问路/庄闲差(外挂参在全局设置)、组合(引用跨机失效)、随机注码(面值在全局设置) + m_btnExport->Enabled = m_editPolicy + && !m_btnSave->Enabled + && !(m_editPolicy->kind==KIND_BET_ASK || m_editPolicy->kind==KIND_BET_DIF + || m_editPolicy->kind==KIND_CHIP_COM || m_editPolicy->kind==KIND_CHIP_RAN); +} +//--------------------------------------------------------------------------- +void __fastcall TPolicyEditForm::OnImportClick(TObject *Sender) +{ + TOpenDialog * pDlg = new TOpenDialog(NULL); + pDlg->Options << ofFileMustExist; + pDlg->Title = "导入"; + pDlg->Filter = m_iType==TYPE_P_BET ? "打法策略文件(*.bpf)|*.bpf" : "注码策略文件(*.cpf)|*.cpf"; + + if(pDlg->Execute(Application->MainFormHandle)){ + TBasePolicy* p = NULL; + int err = ImportPolicy(m_iType, pDlg->FileName, p); + TPolicySaveForm* pForm = NULL; + + if(err){ + String msg; + switch(err){ + case 1: msg = "无法打开文件"; break; + case 2: msg = "格式错误"; break; + case 3: msg = "策略文件版本过低,请用新版本软件导入"; break; + case 4: msg = "文件损坏或不完整"; break; + case 5: msg = "文件内容不合法"; break; + default: msg = "无法识别的文件"; break; + } + MessageBox(Handle, msg.c_str(), L"导入", MB_ICONERROR | MB_OK); + goto END_IMPORT; + } + + if(m_iType==TYPE_P_CHIP && p->kind==KIND_CHIP_COM){ //组合策略不支持导入 + MessageBox(Handle, L"组合注码策略不支持导入", L"导入", MB_ICONERROR | MB_OK); + delete p; + goto END_IMPORT; + } + + pForm = new TPolicySaveForm(this, m_iType, p->name); + if(pForm->ShowModal()==mrOk){ + p->name = pForm->m_name; + int index = pForm->m_iPolicy; + if(index>0){ + TBasePolicy* pP = m_iType==TYPE_P_BET ? g_aBetPolicies[index] : g_aChipPolicies[index]; + p->id = pP->id; + } + + String msg = "导入" + m_sType; + int ret = SavePolicy(m_iType, p, index); + if(ret>=0){ + if(index<0){ + m_cbPolicy->AddItem(p->name, NULL); + m_cbPolicy->ItemIndex = m_cbPolicy->Items->Count-1; + + if(m_iType==TYPE_P_CHIP && p->kind==KIND_CHIP_NOR){ + m_pCombo->AddItem(p->name, (TObject*)p->id); + } + + CalcNewName(); + + PostMessage(Application->MainFormHandle, UM_POLICYCHANGED, 0x10000 | m_iType, 0); + m_iSelPolicy = m_cbPolicy->ItemIndex; + } + else if(m_iSelPolicy!=index){ + m_cbPolicy->ItemIndex = index; + m_iSelPolicy = index; + + if(m_iType==TYPE_P_CHIP && p->kind==KIND_CHIP_NOR + && m_pCombo->Items->IndexOfObject((TObject*)p->id)<0 ){ + m_pCombo->AddItem(p->name, (TObject*)p->id); + } + } + + m_editPolicy = p; + + //强制重画:覆盖同名路径下 ItemIndex 不变,靠不上 OnChange 级联 + m_cbPolicy->ItemIndex = m_iSelPolicy; + Clear(); + UpdateGrid(); + + m_btnSave->Enabled = m_bRowChanged = m_bColChanged = false; + m_btnSelect->Enabled = true; + m_btnDel->Enabled = true; + + msg += "成功"; + MessageBox(Handle, msg.c_str(), L"导入", MB_ICONINFORMATION | MB_OK); + } + else{ + msg += "失败"; + MessageBox(Handle, msg.c_str(), L"导入", MB_ICONERROR | MB_OK); + delete p; + } + } + else + delete p; + + delete pForm; + } + +END_IMPORT: + delete pDlg; +} +//--------------------------------------------------------------------------- +void __fastcall TPolicyEditForm::OnExportClick(TObject *Sender) +{ + if(!m_editPolicy){ + MessageBox(Handle, L"请先选择一个策略", L"导出", MB_ICONINFORMATION | MB_OK); + return; + } + + TSaveDialog *pDlg = new TSaveDialog(this); + pDlg->Title = "导出"; + pDlg->FileName = m_editPolicy->name + (m_iType==TYPE_P_BET ? ".bpf" : ".cpf"); + pDlg->Filter = m_iType==TYPE_P_BET ? "打法策略文件(*.bpf)|*.bpf" : "注码策略文件(*.cpf)|*.cpf"; + + if(pDlg->Execute(Application->MainFormHandle)){ + int ret = ExportPolicy(m_iType, m_editPolicy, pDlg->FileName); + if(ret!=0){ + MessageBox(Handle, L"无法写入文件,请检查路径权限", L"导出", MB_ICONERROR | MB_OK); + } + else{ + String msg = m_sType + "已导出"; + MessageBox(Handle, msg.c_str(), L"导出", MB_ICONINFORMATION | MB_OK); + } + } + + delete pDlg; +} +//--------------------------------------------------------------------------- diff --git a/PolicyEditFormUnit.dfm b/PolicyEditFormUnit.dfm index def10a7..308adfe 100644 --- a/PolicyEditFormUnit.dfm +++ b/PolicyEditFormUnit.dfm @@ -28,7 +28,7 @@ object PolicyEditForm: TPolicyEditForm object m_cbPolicy: TComboBox Left = 87 Top = 41 - Width = 165 + Width = 160 Height = 23 AutoDropDown = True AutoCloseUp = True @@ -39,9 +39,9 @@ object PolicyEditForm: TPolicyEditForm OnChange = OnPolicyChange end object m_btnAdd: TButton - Left = 271 + Left = 258 Top = 41 - Width = 75 + Width = 56 Height = 23 Caption = #26032#24314 TabOrder = 1 @@ -66,33 +66,23 @@ object PolicyEditForm: TPolicyEditForm Shape = bsFrame ShowHint = False end - object m_btnDelRow: TButton - Left = 4 + object m_btnSave: TButton + Left = 198 Top = 313 - Width = 80 + Width = 54 Height = 25 - Caption = #21024#38500#34892 + Caption = #20445#23384 Enabled = False TabOrder = 1 - OnClick = OnDelRowClick - end - object m_btnSave: TButton - Left = 201 - Top = 313 - Width = 88 - Height = 25 - Caption = #20445#23384#25171#27861 - Enabled = False - TabOrder = 2 OnClick = OnSaveClick end object m_btnSelect: TButton - Left = 297 + Left = 322 Top = 313 - Width = 103 + Width = 76 Height = 25 - Caption = #36873#25321#35813#25171#27861 - TabOrder = 3 + Caption = #20840#23616#20351#29992 + TabOrder = 2 OnClick = OnSelectClick end object m_sg: TStringGrid @@ -116,7 +106,7 @@ object PolicyEditForm: TPolicyEditForm PopupMenu = m_pmSG ScrollBars = ssVertical ShowHint = False - TabOrder = 5 + TabOrder = 4 OnDrawCell = SGDrawCell OnKeyDown = SGKeyDown OnMouseDown = SGMouseDown @@ -140,7 +130,7 @@ object PolicyEditForm: TPolicyEditForm ParentCtl3D = False ParentShowHint = False ShowHint = False - TabOrder = 4 + TabOrder = 3 Visible = False OnExit = EditorExit OnKeyDown = EditorKeyDown @@ -166,7 +156,7 @@ object PolicyEditForm: TPolicyEditForm ParentColor = False ParentCtl3D = False ShowFrame = False - TabOrder = 7 + TabOrder = 6 OnClick = OnRoadClick end object m_panChip: TPanel @@ -178,9 +168,11 @@ object PolicyEditForm: TPolicyEditForm BevelOuter = bvNone Ctl3D = True ParentCtl3D = False - TabOrder = 6 + TabOrder = 5 OnClick = OnDeadClick OnMouseMove = FormMouseMove + ExplicitLeft = -2 + ExplicitTop = 23 object m_lblDead: TLabel Left = 17 Top = 32 @@ -364,16 +356,6 @@ object PolicyEditForm: TPolicyEditForm OnClick = OnChipOptionClick end end - object m_btnInsRow: TButton - Left = 92 - Top = 313 - Width = 80 - Height = 25 - Caption = #25554#20837#34892 - Enabled = False - TabOrder = 8 - OnClick = OnInsRowClick - end object m_pCombo: TComboBox Left = 72 Top = 146 @@ -389,11 +371,41 @@ object PolicyEditForm: TPolicyEditForm Visible = False OnKeyDown = ComboKeyDown end + object m_btnExport: TButton + Left = 260 + Top = 313 + Width = 54 + Height = 25 + Caption = #23548#20986 + Enabled = False + TabOrder = 7 + OnClick = OnExportClick + end + object m_btnDelRow: TButton + Left = 4 + Top = 313 + Width = 80 + Height = 25 + Caption = #21024#38500#34892 + Enabled = False + TabOrder = 8 + OnClick = OnDelRowClick + end + object m_btnInsRow: TButton + Left = 92 + Top = 313 + Width = 80 + Height = 25 + Caption = #25554#20837#34892 + Enabled = False + TabOrder = 9 + OnClick = OnInsRowClick + end end object m_btnDel: TButton - Left = 352 - Top = 40 - Width = 75 + Left = 315 + Top = 41 + Width = 56 Height = 23 Caption = #21024#38500 Enabled = False @@ -440,17 +452,26 @@ object PolicyEditForm: TPolicyEditForm OnDrawTab = TopDrawTab OnMeasureTab = TopMeasureTab end + object m_btnImport: TButton + Left = 372 + Top = 41 + Width = 56 + Height = 23 + Caption = #23548#20837 + TabOrder = 6 + OnClick = OnImportClick + end object m_pmSG: TPopupMenu AutoHotkeys = maManual Left = 301 Top = 307 object miExport: TMenuItem Caption = #23548#20986#34920#26684'...' - OnClick = OnExport + OnClick = OnGridExport end object miImport: TMenuItem Caption = #23548#20837#34920#26684'...' - OnClick = OnImport + OnClick = OnGridImport end end end diff --git a/PolicyEditFormUnit.h b/PolicyEditFormUnit.h index 932e99a..b3eeadd 100644 --- a/PolicyEditFormUnit.h +++ b/PolicyEditFormUnit.h @@ -52,6 +52,8 @@ __published: // IDE-managed Components TMenuItem *miImport; TCheckBox *m_cbTierLos0; TTabSet *m_tsTop; + TButton *m_btnExport; + TButton *m_btnImport; void __fastcall FormCreate(TObject *Sender); void __fastcall OnDelRowClick(TObject *Sender); void __fastcall OnPolicyChange(TObject *Sender); @@ -81,12 +83,14 @@ __published: // IDE-managed Components void __fastcall OnTipClick(TObject *Sender); void __fastcall ComboKeyDown(TObject *Sender, WORD &Key, TShiftState Shift); void __fastcall OnInsRowClick(TObject *Sender); - void __fastcall OnExport(TObject *Sender); - void __fastcall OnImport(TObject *Sender); + void __fastcall OnGridExport(TObject *Sender); + void __fastcall OnGridImport(TObject *Sender); void __fastcall TopMeasureTab(TObject *Sender, int Index, int &TabWidth); void __fastcall TopDrawTab(TObject *Sender, TCanvas *TabCanvas, TRect &R, int Index, bool Selected); void __fastcall TopChange(TObject *Sender, int NewTab, bool &AllowChange); void __fastcall FormMouseMove(TObject *Sender, TShiftState Shift, int X, int Y); + void __fastcall OnImportClick(TObject *Sender); + void __fastcall OnExportClick(TObject *Sender); private: // User declarations int m_iType; int m_iSelPolicy; @@ -112,6 +116,7 @@ private: // User declarations void __fastcall InitChipGrid(int kind); //0=普通注码 1=层级注码 void __fastcall ClearSPFrame(); void __fastcall SetView(int type); + void __fastcall UpdateExportBtn(); public: // User declarations diff --git a/PolicySave.cpp b/PolicySave.cpp index 1f75822..09b750e 100644 --- a/PolicySave.cpp +++ b/PolicySave.cpp @@ -28,8 +28,12 @@ void __fastcall TPolicySaveForm::FormCreate(TObject *Sender) //--------------------------------------------------------------------------- void __fastcall TPolicySaveForm::OnOkClick(TObject *Sender) { + if(m_leName->Text.Trim().IsEmpty()){ //名称不能为空 + MessageBox(Handle, L"名称不能为空", L"保存", MB_ICONERROR | MB_OK); + return; + } + vector& aPolicies = m_iType==TYPE_P_BET ? g_aBetPolicies : g_aChipPolicies; -// bool bRepeat = false; int type = -1; m_iPolicy = -1; for(int i=0; i u_aUserCPLen; ///////////////////////////////////////////////////////////////////////////// //文件定义 -#define USER_BPF_VERSION 0x04 //0x03起记录desc +#define USER_BPF_VERSION 0x06 //0x03起记录desc + //0x05起代码策略记录road + //0x06起name/desc/code加密 #define USER_BPF_FILE "betpolicy.dat" -#define USER_CPF_VERSION 0x09 //0x07起记录desc;0x09起记录miniChip(代码策略在code后,非代码在rows后) +#define USER_CPF_VERSION 0x0A //0x07起记录desc + //0x09起记录miniChip(代码策略在code后,非代码在rows后) + //0x0A起name/desc/code加密 #define USER_CPF_FILE "chipolicy.dat" //BetPolicy文件头 @@ -574,9 +579,42 @@ typedef struct tCPFHeader{ } } TCPFHEADER; +///////////////////////////////////////////////////////////////////////////// +// 加密定义 +#include "SHA2.h" + +unsigned char u_encKey[32]; +bool u_encKeyInited = false; + +void __fastcall InitEncKey() +{ + // 硬编码种子字符串,所有编译产物一致 + const char seed[] = "RBmasterPolicyEncSeed_v1"; + sha2_context ctx; + unsigned char digest[32]; + sha2_starts(&ctx, 0); + sha2_update(&ctx, (unsigned char*)seed, sizeof(seed)-1); + sha2_finish(&ctx, digest); + memcpy(u_encKey, digest, 32); + u_encKeyInited = true; +} + +// 加密:XOR 每字节 ^ g_encKey[i%32] +void __fastcall EncryptBytes(char* data, int len) +{ + if (!u_encKeyInited) + InitEncKey(); + + for (int i=0; i100; @@ -640,6 +678,7 @@ vector __fastcall PolicyInCombo(int id) return coms; } //--------------------------------------------------------------------------- +//写入字符串时,长度包含终止符 int __fastcall SaveBetPolicy(TBetPolicy* pPolicy, FILE* fp) { int posStart = ftell(fp); @@ -647,24 +686,31 @@ int __fastcall SaveBetPolicy(TBetPolicy* pPolicy, FILE* fp) char buff[1024]; //UTF8String显式锁死UTF-8,与系统ACP开关解耦(UTF-8开关机写出字节一致) sprintf( buff, "%s", ((UTF8String)pPolicy->name).c_str() ); - int len = strlen(buff)+1; + int len = strlen(buff)+1; + EncryptBytes(buff, len); // 加密(含 null 终止符) fwrite( &len, sizeof(int), 1, fp ); fwrite( buff, sizeof(char), len, fp ); sprintf( buff, "%s", ((UTF8String)pPolicy->desc).c_str() ); - len = strlen(buff)+1; + len = strlen(buff)+1; + EncryptBytes(buff, len); // 加密(含 null 终止符) fwrite( &len, sizeof(int), 1, fp ); fwrite( buff, sizeof(char), len, fp ); fwrite( &pPolicy->type, sizeof(int), 1, fp ); fwrite( &pPolicy->id, sizeof(int), 1, fp ); fwrite( &pPolicy->kind, sizeof(int), 1, fp ); + fwrite( &pPolicy->road, sizeof(int), 1, fp ); if(IsCodePolicy(pPolicy->kind)){ - //代码策略:kind之后存代码,无road、无行记录 + //代码策略:kind之后存代码与road,无行记录 int clen = ((UTF8String)pPolicy->code).Length() + 1; + char* cbuf = new char[clen]; + memcpy(cbuf, ((UTF8String)pPolicy->code).c_str(), clen); + EncryptBytes(cbuf, clen); fwrite( &clen, sizeof(int), 1, fp ); - fwrite( ((UTF8String)pPolicy->code).c_str(), sizeof(char), clen, fp ); + fwrite( cbuf, sizeof(char), clen, fp ); + delete[] cbuf; //打注一体还需记录最小非0注码(JSON提供) if(pPolicy->kind==KIND_BET_WCH){ @@ -673,8 +719,6 @@ int __fastcall SaveBetPolicy(TBetPolicy* pPolicy, FILE* fp) } } else{ - fwrite( &pPolicy->road, sizeof(int), 1, fp ); - int num = pPolicy->aRows.size(); fwrite( &num, sizeof(int), 1, fp ); @@ -708,11 +752,13 @@ int __fastcall SaveChipPolicy(TChipPolicy* pPolicy, FILE* fp) //UTF8String显式锁死UTF-8,与系统ACP开关解耦(UTF-8开关机写出字节一致) sprintf( buff, "%s", ((UTF8String)pPolicy->name).c_str() ); int len = strlen(buff)+1; + EncryptBytes(buff, len); // 加密(含 null 终止符) fwrite( &len, sizeof(int), 1, fp ); fwrite( buff, sizeof(char), len, fp ); sprintf( buff, "%s", ((UTF8String)pPolicy->desc).c_str() ); len = strlen(buff)+1; + EncryptBytes(buff, len); // 加密(含 null 终止符) fwrite( &len, sizeof(int), 1, fp ); fwrite( buff, sizeof(char), len, fp ); @@ -723,10 +769,12 @@ int __fastcall SaveChipPolicy(TChipPolicy* pPolicy, FILE* fp) //代码策略:kind之后存代码,无爆缆开关、无行记录 if(IsCodePolicy(pPolicy->kind)){ int clen = ((UTF8String)pPolicy->code).Length() + 1; + char* cbuf = new char[clen]; + memcpy(cbuf, ((UTF8String)pPolicy->code).c_str(), clen); + EncryptBytes(cbuf, clen); fwrite( &clen, sizeof(int), 1, fp ); - fwrite( ((UTF8String)pPolicy->code).c_str(), sizeof(char), clen, fp ); - - //代码策略的最小注码由JSON提供 + fwrite( cbuf, sizeof(char), clen, fp ); + delete[] cbuf; } else{ int op = (pPolicy->deadPause<<16) | pPolicy->dead; @@ -1039,6 +1087,306 @@ void __fastcall LoadSystemBetPolicies() } } //--------------------------------------------------------------------------- +//解析一条用户打法记录(加载器与单条导入共用):成功返回0,失败返回4 +static int __fastcall ParseBetPolicyRecord(FILE* fp, int ver, TBetPolicy*& pOut, int& iLen, bool bBookkeep = true) +{ + char buf[1024]; + int num = 0, count = 0, clen = 0, id = 0, bet = 0, cond = 0; + int posStart = ftell(fp), posEnd = 0; + TBetPolicy* pPolicy = new TBetPolicy; + + if(fread(&num, sizeof(int), 1, fp)!=1) goto __fail; + if(num>1024) goto __fail; //长度前缀超过buf容量,直接判失败 + if(fread(buf, sizeof(char), num, fp)!=(size_t)num) goto __fail; + + if (ver >= 0x06) EncryptBytes(buf, num); // 读入后解密 + pPolicy->name = ver<=3 ? GBKToUTF8(buf) : String((UTF8String)buf); //旧版本GBK;新版本UTF-8(bytes为0x04起统一) + + if(ver>=4){ //新版本才记录desc,紧跟name之后,恒为UTF-8 + if(fread(&num, sizeof(int), 1, fp)!=1) goto __fail; + if(num>1024) goto __fail; + if(fread(buf, sizeof(char), num, fp)!=(size_t)num) goto __fail; + + if (ver >= 0x06) EncryptBytes(buf, num); // 读入后解密 + pPolicy->desc = String((UTF8String)buf); + } + pPolicy->actived = true; + + if(fread(&pPolicy->type, sizeof(int), 1, fp)!=1) goto __fail; + + if(ver>=3){ + if(fread(&id, sizeof(int), 1, fp)!=1) goto __fail; + pPolicy->id = id; + + if(bBookkeep){ + if(id>u_iUserBetId) + u_iUserBetId = id; + } + } + else{ + pPolicy->id = ++u_iUserBetId; + } + + if(fread(&pPolicy->kind, sizeof(int), 1, fp)!=1) goto __fail; + if(ver>=0x06){ + if(fread(&pPolicy->road, sizeof(int), 1, fp)!=1) goto __fail; + } + + //打注一体用TBetChipPolicy(带miniChip),其余仍为TBetPolicy + if(pPolicy->kind==KIND_BET_WCH){ + TBetChipPolicy* pChip = new TBetChipPolicy; + pChip->name = pPolicy->name; + pChip->desc = pPolicy->desc; + pChip->type = pPolicy->type; + pChip->id = pPolicy->id; + pChip->kind = pPolicy->kind; + pChip->actived = pPolicy->actived; + delete pPolicy; + pPolicy = pChip; + } + + if(IsCodePolicy(pPolicy->kind)){ + //代码策略:kind之后是代码与road,无行记录 + if(fread(&clen, sizeof(int), 1, fp)!=1) goto __fail; + if(clen>262144) goto __fail; //代码长度上限,防止超大分配 + if(clen>0){ + char* cbuf = new char[clen]; + if(fread(cbuf, sizeof(char), clen, fp)!=(size_t)clen) goto __fail; + if (ver >= 0x06) EncryptBytes(cbuf, clen); // 读入后解密 + pPolicy->code = String((UTF8String)cbuf); + delete[] cbuf; + } + + if(ver<0x06){ + if(fread(&pPolicy->road, sizeof(int), 1, fp)!=1) goto __fail; + } + //打注一体在代码之后记录最小非0注码 + if(pPolicy->kind==KIND_BET_WCH){ + if(fread(&((TBetChipPolicy*)pPolicy)->miniChip, sizeof(int), 1, fp)!=1) goto __fail; + } + } + else{ + if(ver<0x06){ + if(fread(&pPolicy->road, sizeof(int), 1, fp)!=1) goto __fail; + } + + if(fread(&num, sizeof(int), 1, fp)!=1) goto __fail; + for(int k=0; kbets.push_back((char)bet); + } + else{ + if(fread(&count, sizeof(int), 1, fp)!=1){ delete row; goto __fail; } + for(int j=0; jbets.push_back((char)bet); + } + } + + if(fread(&count, sizeof(int), 1, fp)!=1){ delete row; goto __fail; } + for(int j=0; jcond.push_back(cond); + } + pPolicy->aRows.push_back(row); + } + } + + posEnd = ftell(fp); + if(bBookkeep){ + g_aBetPolicies.push_back(pPolicy); + u_aUserBPLen.push_back(posEnd-posStart); + } + + iLen = posEnd - posStart; + pOut = pPolicy; + return 0; + +__fail: + delete pPolicy; + pOut = NULL; + return 4; +} +//--------------------------------------------------------------------------- +//解析一条用户注码记录(含历史版本分支,加载器与单条导入共用):成功返回0,失败返回4 +static int __fastcall ParseChipPolicyRecord(FILE* fp, int ver, TChipPolicy*& pOut, int& iLen, bool bBookkeep = true) +{ + char name[1024]; + char desc[1024] = {0}; + int num = 0, type = 0, id = 0, kind = 0, clen = 0, op = 0; + int posStart = ftell(fp), posEnd = 0; + TChipPolicy* pPolicy = NULL; + + if(fread(&num, sizeof(int), 1, fp)!=1) goto __fail; + if(num>1024) goto __fail; //长度前缀超限,直接判失败 + if(fread(name, sizeof(char), num, fp)!=(size_t)num) goto __fail; + if (ver >= 0x0A) EncryptBytes(name, num); // 读入后解密 + + //新版本才记录desc,紧跟name之后;char[1024]清零保证旧版本时为空串 + if(ver>=8){ + if(fread(&num, sizeof(int), 1, fp)!=1) goto __fail; + if(num>1024) goto __fail; + if(fread(desc, sizeof(char), num, fp)!=(size_t)num) goto __fail; + if (ver >= 0x0A) EncryptBytes(desc, num); // 读入后解密 + } + + if(fread(&type, sizeof(int), 1, fp)!=1) goto __fail; + + if(ver>=5){ + if(fread(&id, sizeof(int), 1, fp)!=1) goto __fail; + if(bBookkeep){ + if(id>u_iUserChipId) + u_iUserChipId = id; + } + } + else{ + id = ++u_iUserChipId; + } + + kind = 0; + if(ver>=4){ + if(fread(&kind, sizeof(int), 1, fp)!=1) goto __fail; + + if(IsCodePolicy(kind)){ + //代码策略:kind之后是代码与最小注码,无爆缆开关、无行记录 + pPolicy = new TChipPolicy; + + if(fread(&clen, sizeof(int), 1, fp)!=1) goto __fail; + if(clen>262144) goto __fail; //代码长度上限,防止超大分配 + if(clen>0){ + char * cbuf = new char[clen]; + if(fread(cbuf, sizeof(char), clen, fp)!=(size_t)clen) goto __fail; + if (ver >= 0x0A) EncryptBytes(cbuf, clen); // 读入后解密 + pPolicy->code = String((UTF8String)cbuf); + delete[] cbuf; + } + + if(ver>=9){ + if(fread(&pPolicy->miniChip, sizeof(int), 1, fp)!=1) goto __fail; + } + + if(pPolicy->miniChip==0) + pPolicy->miniChip = 1; + } + else{ + if(kind==KIND_CHIP_HAN) + pPolicy = new TTierPolicy; + else if(kind==KIND_CHIP_LEV || kind==KIND_CHIP_COM) + pPolicy = new TLevelPolicy; + else if(kind==KIND_CHIP_WLD) + pPolicy = new TWLDiffPolicy; + else + pPolicy = new TChipPolicy; + + op = (pPolicy->deadPause<<16) | pPolicy->dead; + if(fread(&op, sizeof(int), 1, fp)!=1) goto __fail; + pPolicy->dead = op & 0xFF; + pPolicy->deadPause = (op & 0xFF0000)>>16; + + if(kind==KIND_CHIP_HAN){ + if(fread(&op, sizeof(int), 1, fp)!=1) goto __fail; + ((TTierPolicy*)pPolicy)->bTierWinRet = op & 0x1; // op & 0xFF; + if(ver>6){ + ((TTierPolicy*)pPolicy)->bTierAccChip = op & 0x2; + ((TTierPolicy*)pPolicy)->bTierLos0 = op & 0x4; + } + else{ + ((TTierPolicy*)pPolicy)->bTierAccChip = op & 0x10000; // (op & 0xFF0000)>>16; + } + } + else if((kind>=KIND_CHIP_LEV && kind<=KIND_CHIP_WLD) && ver>=6){ + if(fread(&op, sizeof(int), 1, fp)!=1) goto __fail; + ((TLevelPolicy*)pPolicy)->bTotalDiff = op & 0x1; + ((TLevelPolicy*)pPolicy)->bInstant = op & 0x2; + + if(kind==KIND_CHIP_WLD) + ((TWLDiffPolicy*)pPolicy)->bIndie = op & 0x10000; + } + } + } + else if(ver>=1){ + if(fread(&num, sizeof(int), 1, fp)!=1) goto __fail; + char dead = num & 0x0F, + pause = (num & 0xF0)>>4, + kind = ver<3 ? (num & 0x100)>>8 : (num & 0xFF00)>>8; + + if(kind==KIND_CHIP_HAN){ + pPolicy = new TTierPolicy; + ((TTierPolicy*)pPolicy)->bTierWinRet = ver<3 ? (num & 0x200)>>9 : (num & 0x10000)>>16; + ((TTierPolicy*)pPolicy)->bTierAccChip = ver<3 ? (num & 0x400)>>10 : (num & 0x20000)>>17; + } + else{ + pPolicy = new TChipPolicy; + } + + pPolicy->dead = dead; + pPolicy->deadPause = pause; + } + else{ + pPolicy = new TChipPolicy; + } + + pPolicy->type = type; + pPolicy->kind = kind; + pPolicy->name = ver<=7 ? GBKToUTF8(name) : String((UTF8String)name); //旧版本GBK;新版本UTF-8(0x08起统一) + pPolicy->desc = String((UTF8String)desc); //desc只在ver>=8,恒为UTF-8 + pPolicy->id = id; + pPolicy->actived = true; + + if(!IsCodePolicy(kind)){ + if(fread(&num, sizeof(int), 1, fp)!=1) goto __fail; + + for(int j=0; jchip, sizeof(int), 1, fp)!=1){ delete row; goto __fail; } + if(fread(&row->iWin, sizeof(int), 1, fp)!=1){ delete row; goto __fail; } + if(fread(&row->iLos, sizeof(int), 1, fp)!=1){ delete row; goto __fail; } + + if(pPolicy->kind==KIND_CHIP_HAN){ + if(fread(&((TTierRow*)row)->hands, sizeof(int), 1, fp)!=1){ delete row; goto __fail; } + } + else if(pPolicy->kind>=KIND_CHIP_LEV){ + if(pPolicy->kind==KIND_CHIP_COM){ + if(fread(&((TComboRow*)row)->id, sizeof(int), 1, fp)!=1){ delete row; goto __fail; } + } + + if(fread(&((TLevelRow*)row)->nCondWin, sizeof(int), 1, fp)!=1){ delete row; goto __fail; } + if(fread(&((TLevelRow*)row)->nCondLos, sizeof(int), 1, fp)!=1){ delete row; goto __fail; } + } + + row->iSeq = j+1; + pPolicy->aRows.push_back(row); + } + + //行记录之后是最小非0注码(0x09起) + if(ver>=9){ + if(fread(&pPolicy->miniChip, sizeof(int), 1, fp)!=1) goto __fail; + } + } + + posEnd = ftell(fp); + if(bBookkeep){ + g_aChipPolicies.push_back(pPolicy); + u_aUserCPLen.push_back(posEnd-posStart); + } + + iLen = posEnd - posStart; + pOut = pPolicy; + return 0; + +__fail: + delete pPolicy; + pOut = NULL; + return 4; +} +//--------------------------------------------------------------------------- void __fastcall LoadUserBetPolicies() { @@ -1049,7 +1397,6 @@ void __fastcall LoadUserBetPolicies() if(!fp) return; - char buf[1024]; char head[8]; TBPFHEADER header; int ret = fread( (void*)head, 1, sizeof(header), fp ); @@ -1059,103 +1406,12 @@ void __fastcall LoadUserBetPolicies() fread(&size, sizeof(int), 1, fp); for(int i=0; iname = head[3]<=3 ? GBKToUTF8(buf) : String((UTF8String)buf); //旧版本GBK;新版本UTF-8(bytes为0x04起统一) - if(head[3]>=4){ //新版本才记录desc,紧跟name之后,恒为UTF-8 - fread(&num, sizeof(int), 1, fp); - fread(buf, sizeof(char), num, fp); - pPolicy->desc = String((UTF8String)buf); - } - pPolicy->actived = true; - - fread(&pPolicy->type, sizeof(int), 1, fp); - - if(head[3]>=3){ - int id; - fread(&id, sizeof(int), 1, fp); - pPolicy->id = id; - - if(id>u_iUserBetId) - u_iUserBetId = id; - } - else{ - pPolicy->id = ++u_iUserBetId; - } - - if(head[3]>0) - fread(&pPolicy->kind, sizeof(int), 1, fp); - - //打注一体用TBetChipPolicy(带miniChip),其余仍为TBetPolicy - if(pPolicy->kind==KIND_BET_WCH){ - TBetChipPolicy* pChip = new TBetChipPolicy; - pChip->name = pPolicy->name; - pChip->desc = pPolicy->desc; - pChip->type = pPolicy->type; - pChip->id = pPolicy->id; - pChip->kind = pPolicy->kind; - pChip->actived = pPolicy->actived; - delete pPolicy; - pPolicy = pChip; - } - - if(IsCodePolicy(pPolicy->kind)){ - //代码策略:kind之后是代码,无road、无行记录 - int clen = 0; - fread(&clen, sizeof(int), 1, fp); - if(clen>0){ - vector cbuf(clen+1); - fread(&cbuf[0], sizeof(char), clen, fp); - cbuf[clen] = 0; - pPolicy->code = String((UTF8String)&cbuf[0]); - } - - //打注一体在代码之后记录最小非0注码 - if(pPolicy->kind==KIND_BET_WCH) - fread(&((TBetChipPolicy*)pPolicy)->miniChip, sizeof(int), 1, fp); - } - else{ - fread(&pPolicy->road, sizeof(int), 1, fp); - - fread(&num, sizeof(int), 1, fp); - for(int k=0; kbets.push_back((char)bet); - } - else{ - fread(&count, sizeof(int), 1, fp); - for(int j=0; jbets.push_back(bet); - } - } - - fread(&count, sizeof(int), 1, fp); - for(int j=0; jcond.push_back(cond); - } - pPolicy->aRows.push_back(row); - } - } - - int posEnd = ftell(fp); - g_aBetPolicies.push_back(pPolicy); - u_aUserBPLen.push_back(posEnd-posStart); - } - } + TBetPolicy* pPolicy = NULL; + int iLen = 0; + if(ParseBetPolicyRecord(fp, head[3], pPolicy, iLen, true)) + break; //解析失败:提前结束,照旧 fclose + } + } fclose(fp); @@ -1221,6 +1477,9 @@ void __fastcall LoadSystemChipPolicies() ((TWLDiffPolicy*)pPolicy)->bIndie = op & 0x4; } } + else if(kind==KIND_CHIP_RAN){ + pPolicy->miniChip = g_RandomChip.minChip; + } } else if(iPart==2){ int err = pPolicy->ParsePolicy(tmp, TYPE_P_CHIP); @@ -1228,27 +1487,23 @@ void __fastcall LoadSystemChipPolicies() //随机注码无行数据,取全局设置;其余在解析行时顺便算最小非0注码 int miniChip = -1; - if(pPolicy->kind==KIND_CHIP_RAN) - miniChip = g_RandomChip.minChip; - else{ - for(int j=0; j<(int)pPolicy->aRows.size(); j++){ - TChipRow* pRow = (TChipRow*)pPolicy->aRows[j]; - if(pPolicy->kind==KIND_CHIP_COM){ - //组合策略:引用前面已入 vector 的策略 - TComboRow* pCR = (TComboRow*)pRow; - if(pCR->iPolicy < g_aChipPolicies.size()){ - TChipPolicy* pRef = (TChipPolicy*)g_aChipPolicies[pCR->iPolicy]; - int refMini = (pRef->kind==KIND_CHIP_RAN) ? g_RandomChip.minChip : pRef->miniChip; - int comboChip = refMini * pRow->chip; - if(comboChip>0 && (miniChip<0 || comboChipchip>0 && (miniChip<0 || pRow->chipchip; + for(int j=0; j<(int)pPolicy->aRows.size(); j++){ + TChipRow* pRow = (TChipRow*)pPolicy->aRows[j]; + if(pPolicy->kind==KIND_CHIP_COM){ + //组合策略:引用前面已入 vector 的策略 + TComboRow* pCR = (TComboRow*)pRow; + if(pCR->id <= g_aChipPolicies.size()){ + TChipPolicy* pRef = (TChipPolicy*)g_aChipPolicies[pCR->id-1]; + int refMini = (pRef->kind==KIND_CHIP_RAN) ? g_RandomChip.minChip : pRef->miniChip; + int comboChip = refMini * pRow->chip; + if(comboChip>0 && (miniChip<0 || comboChipchip>0 && (miniChip<0 || pRow->chipchip; + } } pPolicy->miniChip = miniChip; } @@ -1290,7 +1545,6 @@ void __fastcall LoadUserChipPolicies() if(!fp) return; - char buf[1024]; char head[8]; TCPFHEADER header; int ret = fread( (void*)head, 1, sizeof(header), fp ); @@ -1299,157 +1553,12 @@ void __fastcall LoadUserChipPolicies() int size; fread(&size, sizeof(int), 1, fp); - int num; - int type; - int id; - char name[64]; for(int i=0; i=8){ - fread(&num, sizeof(int), 1, fp); - fread(desc, sizeof(char), num, fp); - } - - fread(&type, sizeof(int), 1, fp); - - if(head[3]>=5){ - fread(&id, sizeof(int), 1, fp); - if(id>u_iUserChipId) - u_iUserChipId = id; - } - else{ - id = ++u_iUserChipId; - } - - int kind = 0; - if(head[3]>=4){ - fread(&kind, sizeof(int), 1, fp); - - if(IsCodePolicy(kind)){ - //代码策略:kind之后是代码与最小注码,无爆缆开关、无行记录 - pPolicy = new TChipPolicy; - - int clen = 0; - fread(&clen, sizeof(int), 1, fp); - if(clen>0){ - vector cbuf(clen+1); - fread(&cbuf[0], sizeof(char), clen, fp); - cbuf[clen] = 0; - pPolicy->code = String((UTF8String)&cbuf[0]); - } - - if(head[3]>=9) - fread(&pPolicy->miniChip, sizeof(int), 1, fp); - } - else{ - if(kind==KIND_CHIP_HAN) - pPolicy = new TTierPolicy; - else if(kind==KIND_CHIP_LEV || kind==KIND_CHIP_COM) - pPolicy = new TLevelPolicy; - else if(kind==KIND_CHIP_WLD) - pPolicy = new TWLDiffPolicy; - else - pPolicy = new TChipPolicy; - - int op = (pPolicy->deadPause<<16) | pPolicy->dead; - fread( &op, sizeof(int), 1, fp ); - pPolicy->dead = op & 0xFF; - pPolicy->deadPause = (op & 0xFF0000)>>16; - - if(kind==KIND_CHIP_HAN){ - fread( &op, sizeof(int), 1, fp ); - ((TTierPolicy*)pPolicy)->bTierWinRet = op & 0x1; // op & 0xFF; - if(head[3]>6){ - ((TTierPolicy*)pPolicy)->bTierAccChip = op & 0x2; - ((TTierPolicy*)pPolicy)->bTierLos0 = op & 0x4; - } - else{ - ((TTierPolicy*)pPolicy)->bTierAccChip = op & 0x10000; // (op & 0xFF0000)>>16; - } - } - else if((kind>=KIND_CHIP_LEV && kind<=KIND_CHIP_WLD) && head[3]>=6){ - fread( &op, sizeof(int), 1, fp ); - ((TLevelPolicy*)pPolicy)->bTotalDiff = op & 0x1; - ((TLevelPolicy*)pPolicy)->bInstant = op & 0x2; - - if(kind==KIND_CHIP_WLD) - ((TWLDiffPolicy*)pPolicy)->bIndie = op & 0x10000; - } - } - } - else if(head[3]>=1){ - fread(&num, sizeof(int), 1, fp); - char dead = num & 0x0F, - pause = (num & 0xF0)>>4, - kind = head[3]<3 ? (num & 0x100)>>8 : (num & 0xFF00)>>8; - - if(kind==KIND_CHIP_HAN){ - pPolicy = new TTierPolicy; - ((TTierPolicy*)pPolicy)->bTierWinRet = head[3]<3 ? (num & 0x200)>>9 : (num & 0x10000)>>16; - ((TTierPolicy*)pPolicy)->bTierAccChip = head[3]<3 ? (num & 0x400)>>10 : (num & 0x20000)>>17; - } - else{ - pPolicy = new TChipPolicy; - } - - pPolicy->dead = dead; - pPolicy->deadPause = pause; - } - else{ - pPolicy = new TChipPolicy; - } - - pPolicy->type = type; - pPolicy->kind = kind; - pPolicy->name = head[3]<=7 ? GBKToUTF8(name) : String((UTF8String)name); //旧版本GBK;新版本UTF-8(0x08起统一) - pPolicy->desc = String((UTF8String)desc); //desc只在head[3]>=8,恒为UTF-8 - pPolicy->id = id; - pPolicy->actived = true; - - if(!IsCodePolicy(kind)){ - fread(&num, sizeof(int), 1, fp); - - for(int j=0; jchip, sizeof(int), 1, fp); - fread(&row->iWin, sizeof(int), 1, fp); - fread(&row->iLos, sizeof(int), 1, fp); - - if(pPolicy->kind==KIND_CHIP_HAN){ - fread(&((TTierRow*)row)->hands, sizeof(int), 1, fp); - } - else if(pPolicy->kind>=KIND_CHIP_LEV){ - if(pPolicy->kind==KIND_CHIP_COM) - fread(&((TComboRow*)row)->id, sizeof(int), 1, fp); - - fread(&((TLevelRow*)row)->nCondWin, sizeof(int), 1, fp); - fread(&((TLevelRow*)row)->nCondLos, sizeof(int), 1, fp); - } - - row->iSeq = j+1; - pPolicy->aRows.push_back(row); - } - - //行记录之后是最小非0注码(0x09起) - if(head[3]>=9) - fread(&pPolicy->miniChip, sizeof(int), 1, fp); - } - - int posEnd = ftell(fp); - g_aChipPolicies.push_back(pPolicy); - u_aUserCPLen.push_back(posEnd-posStart); - } + int iLen = 0; + if(ParseChipPolicyRecord(fp, head[3], pPolicy, iLen, true)) + break; //解析失败:提前结束,照旧 fclose + } } fclose(fp); @@ -1481,4 +1590,102 @@ void __fastcall LoadPolicies() LoadUserChipPolicies(); } //--------------------------------------------------------------------------- +//导出单条策略:4字节头 + 一条记录(不写count);成功0,打开失败-1 +int __fastcall ExportPolicy(int type, TBasePolicy* pPolicy, const String& file) +{ + char szFile[1024]; + sprintf(szFile, "%s", UTF8String(file).c_str()); //用户文件名可能带中文,显式转UTF-8字节 + FILE* fp = fopen(szFile, "wb"); + if(!fp) + return -1; + + if(type==TYPE_P_BET){ + TBPFHEADER header; + fwrite((void*)&header, sizeof(header), 1, fp); + SaveBetPolicy((TBetPolicy*)pPolicy, fp); + } + else{ + TCPFHEADER header; + fwrite((void*)&header, sizeof(header), 1, fp); + SaveChipPolicy((TChipPolicy*)pPolicy, fp); + } + + fclose(fp); + return 0; +} +//--------------------------------------------------------------------------- +//导入单条策略:0成功 1打开失败 2magic与当前标签页类型不符 3版本过低 4解析失败 5内容非法 +int __fastcall ImportPolicy(int type, const String& file, TBasePolicy*& pOut) +{ + char szFile[1024]; + sprintf(szFile, "%s", UTF8String(file).c_str()); //用户文件名可能带中文,显式转UTF-8字节 + FILE* fp = fopen(szFile, "rb"); + if(!fp){ + return 1; + } + + char head[8]; + if(fread((void*)head, 1, 4, fp)!=4){ + fclose(fp); + return 4; + } + + if(type==TYPE_P_BET && memcmp(head, "BPF", 3) || + type==TYPE_P_CHIP && memcmp(head, "CPF", 3)){ + fclose(fp); + return 2; + } + + int ver = (unsigned char)head[3]; + if(type==TYPE_P_BET ? ver<5 : ver<9){ + fclose(fp); + return 3; + } + + int len = 0; + if(type==TYPE_P_BET){ + TBetPolicy* p = NULL; + if(ParseBetPolicyRecord(fp, ver, p, len, false) || !p){ + delete p; + fclose(fp); + return 4; + } + + //内容校验:名称非空,kind白名单 {0,101,102} + if(Trim(p->name).IsEmpty() + || (p->kind!=KIND_BET_NOR && p->kind!=KIND_BET_SPE && p->kind!=KIND_BET_WCH)){ + delete p; + fclose(fp); + return 5; + } + + p->type = 2; //用户自定义,统一覆盖文件里带的旧type + fclose(fp); + pOut = p; + return 0; + } + else{ + TChipPolicy* p = NULL; + if(ParseChipPolicyRecord(fp, ver, p, len, false) || !p){ + delete p; + fclose(fp); + return 4; + } + + //内容校验:名称非空,kind白名单 {0,1,2,4,121} + if(Trim(p->name).IsEmpty() + || (p->kind!=KIND_CHIP_NOR && p->kind!=KIND_CHIP_HAN && p->kind!=KIND_CHIP_LEV + && p->kind!=KIND_CHIP_WLD && p->kind!=KIND_CHIP_SPE)){ + delete p; + fclose(fp); + return 5; + } + + p->type = 2; //用户自定义,统一覆盖文件里带的旧type + fclose(fp); + pOut = p; + return 0; + } +} +//--------------------------------------------------------------------------- diff --git a/PolicyUnit.h b/PolicyUnit.h index 261d323..d59f73c 100644 --- a/PolicyUnit.h +++ b/PolicyUnit.h @@ -13,7 +13,7 @@ #define KIND_BET_ASK 2 #define KIND_BET_DIF 3 #define KIND_BET_SPE 101 //特殊打法:代码策略 calcBet(road,context) -> bet -#define KIND_BET_WCH 103 //打注一体:代码策略 calcBetWithChip(road,mult,context) -> bet+chip +#define KIND_BET_WCH 102 //打注一体:代码策略 calcBetWithChip(road,mult,context) -> bet+chip #define KIND_CHIP_NOR 0 #define KIND_CHIP_HAN 1 @@ -21,7 +21,7 @@ #define KIND_CHIP_COM 3 #define KIND_CHIP_WLD 4 #define KIND_CHIP_RAN 8 -#define KIND_CHIP_SPE 102 //特殊注码:代码策略 calcChip(result,mult,context) -> chip +#define KIND_CHIP_SPE 121 //特殊注码:代码策略 calcChip(result,mult,context) -> chip //--------------------------------------------------------------------------- using namespace std; @@ -40,7 +40,7 @@ public: int id; //唯一ID int kind; //自定义类型 CHIP:0=普通 1=手数层级 2=组合层级 4=随机 ... BET:0=普通 2=庄闲问路 3=庄闲差... bool actived; //是否激活 - String code; //代码策略的JS源码(KIND_BET_SPE/KIND_BET_WCH/KIND_CHIP_SPE专用,其余为空) + String code; //代码策略的JS源码(KIND_BET_SPE/KIND_BET_WCH/KIND_CHIP_SPE专用,其余为空);代码打法另用road vector aRows; virtual void AddNewRow()=0; @@ -50,7 +50,7 @@ public: virtual void Reset(); TBasePolicy(){id=type=kind=0;} - ~TBasePolicy(); + virtual ~TBasePolicy(); }; //打法策略 @@ -71,7 +71,7 @@ public: class TBetPolicy : public TBasePolicy{ public: - int road; //适用路单 + int road; //适用路单 0=珠盘 1=大路 2=大眼路 3=小路 4=小强路(代码打法同样适用) TBetPolicy& operator = (const TBetPolicy& b); bool operator == (const TBetPolicy& b); @@ -175,7 +175,7 @@ public: typedef struct tagRandomChip{ int minChip, //最小随机 maxChip; //最大随机 - tagRandomChip(){minChip=20, maxChip=100;} + tagRandomChip(){minChip=1, maxChip=5;} }TRandomChip; typedef struct tagBPAskBet{ @@ -191,6 +191,8 @@ typedef struct tagBPDiffBet{ }TBPDiffBet; void __fastcall LoadPolicies(); +int __fastcall ExportPolicy(int type, TBasePolicy* pPolicy, const String& file); +int __fastcall ImportPolicy(int type, const String& file, TBasePolicy*& pOut); bool IsCodePolicy(int kind); int __fastcall SavePolicy(int type, TBasePolicy* pPolicy, int index); int __fastcall DeletePolicy(int type, int index); diff --git a/RBmaster.cbproj b/RBmaster.cbproj index e153535..efc50cd 100644 --- a/RBmaster.cbproj +++ b/RBmaster.cbproj @@ -80,7 +80,7 @@ _RBM_;$(Defines) true ..\Global\;..\CEF4Delphi\$(Platform)\hpps;$(IncludePath) - CompanyName=;FileDescription=;FileVersion=5.0.0.0;InternalName=RBmaster;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=红蓝大师;ProductVersion=3.0;Comments= + CompanyName=;FileDescription=;FileVersion=5.1.0.0;InternalName=RBmaster;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=红蓝大师;ProductVersion=3.0;Comments= 1033 System;Xml;Data;Datasnap;Web;Soap;Vcl;Vcl.Imaging;Vcl.Touch;Vcl.Samples;Vcl.Shell;$(DCC_Namespace) rtl.lib;vcl.lib;fmx.lib;vclimg.lib;xmlrtl.lib;vclactnband.lib;vclx.lib;CEF4DelphiVCLRTL.lib;vclwinx.lib;bindengine.lib;TPNGButton.lib @@ -102,6 +102,7 @@ $(BDS)\bin\Artwork\Windows\UWP\cppreg_UwpDefault_150.png 5 true + 1 ..\Deploy\$(Platform)\$(Config)\ @@ -165,12 +166,10 @@ $(BDSLIB)\$(PLATFORM)\debug\$(LANGDIR);$(ILINK_TranslatedLibraryPath) - CompanyName=;FileVersion=5.0.0.0;InternalName=RBmaster;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=红蓝大师;ProductVersion=3.0;Comments=;ProgramID=;FileDescription= - rtl.lib;vcl.lib;fmx.lib;vclimg.lib;xmlrtl.lib;vclactnband.lib;vclx.lib;CEF4DelphiVCLRTL.lib;vclwinx.lib;bindengine.lib;TPNGButton.lib - requireAdministrator + CompanyName=;FileVersion=5.1.0.0;InternalName=RBmaster;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=红蓝大师;ProductVersion=3.0;Comments=;ProgramID=;FileDescription= Debug -testing - ..\res\RBmaster.Artwork\Windows\AppIcon.ico + rtl.lib;vcl.lib;fmx.lib;vclimg.lib;xmlrtl.lib;vclactnband.lib;vclx.lib;CEF4DelphiVCLRTL.lib;vclwinx.lib;bindengine.lib;TPNGButton.lib true @@ -188,7 +187,7 @@ None - CompanyName=;FileVersion=5.0.0.0;InternalName=RBmaster;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=红蓝大师;ProductVersion=3.0;Comments=;ProgramID=;FileDescription= + CompanyName=;FileVersion=5.1.0.0;InternalName=RBmaster;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=红蓝大师;ProductVersion=3.0;Comments=;ProgramID=;FileDescription= rtl.lib;vcl.lib;fmx.lib;vclimg.lib;xmlrtl.lib;vclactnband.lib;vclx.lib;CEF4DelphiVCLRTL.lib;vclwinx.lib;bindengine.lib;TPNGButton.lib requireAdministrator ..\Deploy\$(Platform)\$(Config)\ @@ -223,6 +222,9 @@ ..\Global\HttpThread.h 16 + + 53 + ..\Global\SimpleMutex.h 25 @@ -489,8 +491,8 @@ - + Base diff --git a/RBmaster.cpp b/RBmaster.cpp index 45911d0..8b33b02 100644 --- a/RBmaster.cpp +++ b/RBmaster.cpp @@ -219,7 +219,25 @@ void InitUserPath() } //--------------------------------------------------------------------------- +USEFORM("SettingFormUnit.cpp", SettingForm); +USEFORM("ResetFormUnit.cpp", ResetForm); +USEFORM("PolicySave.cpp", PolicySaveForm); +USEFORM("PolicyEditFormUnit.cpp", PolicyEditForm); USEFORM("RBmasterMain.cpp", MainForm); +USEFORM("TableUnit.cpp", TableFrame); /* TFrame: File Type */ +USEFORM("TableSet.cpp", TabSetForm); +USEFORM("TableIPFormUnit.cpp", TableIPForm); +USEFORM("Bet03FrameUnit.cpp", Bet03Frame); /* TFrame: File Type */ +USEFORM("Bet02FrameUnit.cpp", Bet02Frame); /* TFrame: File Type */ +USEFORM("AIFormUnit.cpp", AIForm); +USEFORM("ActCodeFormUnit.cpp", ActCodeForm); +USEFORM("InfoFrameUnit.cpp", InfoFrame); /* TFrame: File Type */ +USEFORM("LoginUnit.cpp", LoginForm); +USEFORM("Chip02FrameUnit.cpp", Chip02Frame); /* TFrame: File Type */ +USEFORM("ChartFormUnit.cpp", ChartForm); +USEFORM("BetLogFormUnit.cpp", BetLogForm); +USEFORM("CodesFrameUnit.cpp", CodesFrame); /* TFrame: File Type */ +USEFORM("ChipsFormUnit.cpp", ChipsForm); //--------------------------------------------------------------------------- bool Startup() { diff --git a/RBmasterMain.cpp b/RBmasterMain.cpp index 457c805..a62f995 100644 --- a/RBmasterMain.cpp +++ b/RBmasterMain.cpp @@ -146,6 +146,7 @@ __fastcall TMainForm::TMainForm(TComponent* Owner) m_bDragReady = m_bDraging = false; m_pDragTimer = NULL; m_iLastSel = -1; + m_iLastChipPolicy = -1; sprintf(urServer, "%s:98", g_apiServer); } @@ -280,6 +281,8 @@ void __fastcall TMainForm::FormCreate(TObject *Sender) m_leChipMul->Enabled = true; } + AdjustChipMode(false); //打注一体:禁用注码选择,沿用已保存的倍数 + if(g_iPlatform > m_pmLogin->Items->Count) g_iPlatform = 0; else if(g_iPlatform>0) @@ -1938,7 +1941,7 @@ TStringList* __fastcall TMainForm::GetJQValue( String& str, _di_ICefFrame frame, v8Values->Clear(); frame->ExecuteJavaScript( str, "", 0 ); - DWORD dwRet = WaitForSingleObject( hV8ValueSema, bCode ? 500 : 2000 ); + DWORD dwRet = WaitForSingleObject( hV8ValueSema, bCode ? 1000 : 2000 ); TStringList* values = NULL; if( dwRet==WAIT_OBJECT_0 ){ @@ -1984,7 +1987,10 @@ bool __fastcall TMainForm::EvalJSCode(int kind, const String& sCode, TJSONValue* pRoot = NULL; try{ - String strJS = sPrelude + L" var context=" + (sCtx.Length() ? sCtx : String("{}") ) + L";" + sCode; + String strCode = StringReplace(sCode, "\n", "", TReplaceFlags() << rfReplaceAll); + String strJS = sPrelude + L" var context=" + (sCtx.Length() ? sCtx : String("{}") ) + L";" + strCode; + +// TLog::WriteLog(strJS); values = GetJQValue( strJS, m_chrmCode->Browser->MainFrame, true ); if( values && values->Count>0 && values->Strings[0].Length() ){ @@ -2324,7 +2330,7 @@ void __fastcall TMainForm::UMJsHandled(TMessage &msg) InitBrowser(true); //初始化代码执行浏览器 FileUserWeb(); -// InitBrowser(); //初始化游戏平台浏览器 + InitBrowser(); //初始化游戏平台浏览器 m_lblTips->Caption = "请登录游戏"; if(m_sActCode.Length()) @@ -2989,6 +2995,8 @@ void __fastcall TMainForm::UMStateUpdate(TMessage &msg) if(g_iChipPolicy>=0 && g_aChipPolicies[g_iChipPolicy]->kind!=KIND_CHIP_COM) RecalcMultiRate(); + else if(g_iBetPolicy>=0 && g_aBetPolicies[g_iBetPolicy]->kind==KIND_BET_WCH) + AdjustChipMode(); //打注一体:限红变动后按最小注码重算倍数 } else if(type==STATE_BET_R){ int wl = msg.LParam; @@ -3566,6 +3574,7 @@ void __fastcall TMainForm::InitBrowser(bool bCode) chrm->OnBeforeContextMenu = WebBeforeContextMenu; chrm->OnBeforePopup = WebBeforePopup; chrm->OnJsdialog = WebJsdialog; + chrm->OnProcessMessageReceived = WebProcessMessageReceived; if(bCode){ chrm->DefaultUrl = "about:blank"; @@ -3574,7 +3583,6 @@ void __fastcall TMainForm::InitBrowser(bool bCode) } else{ chrm->OnAfterCreated = WebAfterCreated; - chrm->OnProcessMessageReceived = WebProcessMessageReceived; chrm->OnLoadEnd = WebLoadEnd; chrm->OnResourceLoadComplete = WebResourceLoadComplete; chrm->OnLoadError = WebLoadError; @@ -3618,7 +3626,7 @@ void __fastcall TMainForm::OnStartClick(TObject *Sender) goto Start_Click_Exit; } - if(g_iChipPolicy<0){ + if(g_iChipPolicy<0 && g_aBetPolicies[g_iBetPolicy]->kind!=KIND_BET_WCH){ //打注一体注码由打法自带 ShowMessage( "请先选择注码" ); goto Start_Click_Exit; } @@ -3741,12 +3749,18 @@ void __fastcall TMainForm::OnPolicyEditClick(TObject *Sender) int iType = Sender==m_lblBetChipEdit; TComboBox* pCB = iType ? m_cbBetChips : m_cbBetWays; - TPolicyEditForm* pForm = new TPolicyEditForm(this, iType); - - if(pForm->ShowModal()==mrOk){ + //打注一体由打法策略自带注码,无需编辑注码策略 + if(iType==TYPE_P_CHIP && g_iBetPolicy>=0 && g_aBetPolicies[g_iBetPolicy]->kind==KIND_BET_WCH){ + ShowMessage("打注一体由打法策略自带注码,无需设置注码策略"); } + else{ + TPolicyEditForm* pForm = new TPolicyEditForm(this, iType); - delete pForm; + if(pForm->ShowModal()==mrOk){ + } + + delete pForm; + } SetTableFocus(); } @@ -3769,23 +3783,29 @@ void __fastcall TMainForm::OnPolicyChange(TObject *Sender) m_leChipMul->Text = ""; m_leChipMul->Enabled = false; } + else + AdjustChipMode(); //取消打法选择后恢复注码下拉 return; } if(combo==m_cbBetChips){ //根据最小注码调整倍数 - if(g_aChipPolicies[ind]->kind==KIND_CHIP_COM){ - g_nChipMul = 0; - m_leChipMul->Text = ""; - m_leChipMul->Enabled = false; - } - else{ +// if(g_aChipPolicies[ind]->kind==KIND_CHIP_COM){ +// g_nChipMul = 0; +// m_leChipMul->Text = ""; +// m_leChipMul->Enabled = false; +// } +// else{ RecalcMultiRate(); - } +// } } else{ //根据打法改变路珠显示 - m_cbRoad->ItemIndex = ((TBetPolicy*)g_aBetPolicies[ind])->road; + TBetPolicy* pBP = (TBetPolicy*)g_aBetPolicies[ind]; + + m_cbRoad->ItemIndex = pBP->road; OnRoadChange(m_cbRoad); + + AdjustChipMode(); //打注一体禁用注码选择,倍数按其最小注码计算 } if(g_bGameOn){ @@ -3804,19 +3824,71 @@ void __fastcall TMainForm::OnPolicyChange(TObject *Sender) } //--------------------------------------------------------------------------- +//打注一体(KIND_BET_WCH)的注码由打法策略自带,无需选注码: +//禁用注码下拉并按该策略的最小非0注码换算倍数;其余打法恢复正常 +void __fastcall TMainForm::AdjustChipMode(bool bResetMul) +{ + TBetPolicy* pBP = g_iBetPolicy>=0 ? (TBetPolicy*)g_aBetPolicies[g_iBetPolicy] : NULL; + + if(pBP && pBP->kind==KIND_BET_WCH){ + if(g_iChipPolicy>=0) //记住原注码,切回普通打法时恢复 + m_iLastChipPolicy = g_iChipPolicy; + + g_iChipPolicy = -1; + m_cbBetChips->Enabled = false; + m_cbBetChips->ItemIndex = -1; + m_cbBetChips->Text = "打注一体"; + + if(bResetMul || g_nChipMul<=0){ //按最小非0注码计算倍数 + int minChip = ((TBetChipPolicy*)pBP)->miniChip; + int multi = 0; + if(minChip>0){ + multi = g_MinOnBet / minChip; + if(g_MinOnBet % minChip) multi++; + } + + g_nChipMul = multi; + m_leChipMul->Text = multi>0 ? IntToStr(multi) : String(""); + } + + m_leChipMul->Enabled = true; //倍数允许用户输入 + + return; + } + + m_cbBetChips->Enabled = true; + + if(g_iChipPolicy<0){ //切回普通打法:恢复原注码 + int ind = m_iLastChipPolicy; + if(ind>=0 && ind<(int)g_aChipPolicies.size()){ + m_cbBetChips->ItemIndex = ind; + g_iChipPolicy = ind; + + RecalcMultiRate(); + } + else + m_cbBetChips->Text = m_cbBetChips->Hint; + } +} +//--------------------------------------------------------------------------- + void __fastcall TMainForm::RecalcMultiRate() { - int minChip = ((TChipPolicy*)g_aChipPolicies[g_iChipPolicy])->miniChip; + if(g_iChipPolicy<0) //未选注码(含打注一体)不换算倍数 + return; + + TChipPolicy* pCP = (TChipPolicy*)g_aChipPolicies[g_iChipPolicy]; + + int minChip = pCP->kind==KIND_CHIP_RAN ? g_RandomChip.minChip : pCP->miniChip; if(minChip>0){ int multi = g_MinOnBet / minChip; if(g_MinOnBet % minChip) multi++; - if(g_nChipMulText = IntToStr(multi); - m_leChipMul->Enabled = true; } - } + } } //--------------------------------------------------------------------------- @@ -3910,9 +3982,18 @@ void __fastcall TMainForm::OnAccountClick(TObject *Sender) void __fastcall TMainForm::OnChipMulExit(TObject *Sender) { - int minChip = ((TChipPolicy*)g_aChipPolicies[g_iChipPolicy])->miniChip; + int minChip; + if(g_iBetPolicy>=0 && g_aBetPolicies[g_iBetPolicy]->kind==KIND_BET_WCH) + minChip = ((TBetChipPolicy*)g_aBetPolicies[g_iBetPolicy])->miniChip; //打注一体 + else if(g_iChipPolicy>=0) + minChip = ((TChipPolicy*)g_aChipPolicies[g_iChipPolicy])->miniChip; + else + return; + int mul = m_leChipMul->Text.ToInt(); - if(minChip * mul < g_MinOnBet){ + if(minChip<=0) //无最小注码可参考,倍数直接生效 + g_nChipMul = m_leChipMul->Text.ToInt(); + else if(minChip * mul < g_MinOnBet){ int multi = g_MinOnBet / minChip; if(g_MinOnBet % minChip) multi++; diff --git a/RBmasterMain.dfm b/RBmasterMain.dfm index c14ed5e..79c78c4 100644 --- a/RBmasterMain.dfm +++ b/RBmasterMain.dfm @@ -3,7 +3,7 @@ object MainForm: TMainForm Top = 0 ParentCustomHint = False Caption = #32418#34013#22823#24072 - ClientHeight = 830 + ClientHeight = 861 ClientWidth = 1240 Color = clBtnFace CustomTitleBar.Control = m_tbp @@ -49,7 +49,7 @@ object MainForm: TMainForm TextHeight = 13 object m_panWeb: TScrollBox Left = 0 - Top = 152 + Top = 183 Width = 1240 Height = 678 Margins.Left = 0 @@ -139261,7 +139261,6 @@ object MainForm: TMainForm ParentCustomHint = False OnPaint = TitleBarPaint CustomButtons = <> - ExplicitWidth = 1234 object m_imgLogo: TImage Left = 10 Top = 10 diff --git a/RBmasterMain.h b/RBmasterMain.h index 5c770ae..7d12b68 100644 --- a/RBmasterMain.h +++ b/RBmasterMain.h @@ -185,6 +185,7 @@ private: // User declarations TTimer *m_pDragTimer; //拖动滚屏定时器 int m_iLastSel; //最后单独选中台桌 + int m_iLastChipPolicy; //打注一体前的全局注码,切回普通打法时恢复 set m_aSelTabs; //选中台桌集合 TBitmap *m_bmTBPBackTile, //标题栏背景贴条 @@ -227,6 +228,7 @@ private: // User declarations void __fastcall RBReport(); void __fastcall LoadUrl(); void __fastcall RecalcMultiRate(); + void __fastcall AdjustChipMode(bool bResetMul=true); void __fastcall SetTableFocus(); int __fastcall GetTableByPos(int x, int y); void __fastcall SelectTables(int x1, int y1, int x2, int y2); diff --git a/TableIPFormUnit.cpp b/TableIPFormUnit.cpp index a9a869b..940fd35 100644 --- a/TableIPFormUnit.cpp +++ b/TableIPFormUnit.cpp @@ -41,6 +41,24 @@ void __fastcall TTableIPForm::FormCreate(TObject *Sender) m_leChipMul->Enabled = true; } + //打注一体:注码由打法策略自带,禁用注码选择 + if(m_iBet>=0 && g_aBetPolicies[m_iBet]->kind==KIND_BET_WCH){ + m_iChip = -1; + m_cbChips->Enabled = false; + m_cbChips->ItemIndex = -1; + m_cbChips->Text = "打注一体"; + + int minChip = ((TBetChipPolicy*)g_aBetPolicies[m_iBet])->miniChip; + if(minChip>0 && m_nMul<=0){ + int mul = g_MinOnBet / minChip; + if(g_MinOnBet % minChip) mul++; + + m_nMul = mul; + m_leChipMul->Text = IntToStr(mul); + m_leChipMul->Enabled = true; + } + } + m_cbIndPolicy->Checked = m_pGame->bIndPolicy; } //--------------------------------------------------------------------------- @@ -53,7 +71,7 @@ void __fastcall TTableIPForm::OkClick(TObject *Sender) return; } - if(m_iChip<0){ + if(m_iChip<0 && g_aBetPolicies[m_iBet]->kind!=KIND_BET_WCH){ //打注一体注码由打法自带 ShowMessage("请选择注码策略"); m_cbChips->SetFocus(); return; @@ -120,6 +138,26 @@ void __fastcall TTableIPForm::PolicyChange(TObject *Sender) } else{ m_cbRoad->ItemIndex = ((TBetPolicy*)g_aBetPolicies[ind])->road; + + if(g_aBetPolicies[ind]->kind==KIND_BET_WCH){ //打注一体:禁用注码选择,倍数按最小注码计算 + m_iChip = -1; + m_cbChips->Enabled = false; + m_cbChips->ItemIndex = -1; + m_cbChips->Text = "打注一体"; + + int minChip = ((TBetChipPolicy*)g_aBetPolicies[ind])->miniChip; + if(minChip>0){ + int mul = g_MinOnBet / minChip; + if(g_MinOnBet % minChip) mul++; + + m_nMul = mul; + m_leChipMul->Text = IntToStr(mul); + } + m_leChipMul->Enabled = true; //倍数允许用户输入 + } + else{ + m_cbChips->Enabled = true; + } } } @@ -136,8 +174,13 @@ void __fastcall TTableIPForm::ChipMulExit(TObject *Sender) return; } else{ - int minChip = ((TChipPolicy*)g_aChipPolicies[m_iChip])->miniChip; - if(minChip * mul < g_MinOnBet){ + int minChip = 0; + if(m_iBet>=0 && g_aBetPolicies[m_iBet]->kind==KIND_BET_WCH) //打注一体 + minChip = ((TBetChipPolicy*)g_aBetPolicies[m_iBet])->miniChip; + else if(m_iChip>=0) + minChip = ((TChipPolicy*)g_aChipPolicies[m_iChip])->miniChip; + + if(minChip>0 && minChip * mul < g_MinOnBet){ int multi = g_MinOnBet / minChip; if(g_MinOnBet % minChip) multi++; @@ -159,7 +202,8 @@ void __fastcall TTableIPForm::ChipMulKeyDown(TObject *Sender, WORD &Key, TShiftS //--------------------------------------------------------------------------- void __fastcall TTableIPForm::SetChanged() { - if(m_iBet>=0 && m_iChip>=0 && (m_iBet!=g_iBetPolicy || m_iChip!=g_iChipPolicy + if(m_iBet>=0 && (m_iChip>=0 || g_aBetPolicies[m_iBet]->kind==KIND_BET_WCH) + && (m_iBet!=g_iBetPolicy || m_iChip!=g_iChipPolicy || m_nMul!=g_nChipMul)){ m_cbIndPolicy->Checked = true; m_btnOk->SetFocus(); diff --git a/TableUnit.cpp b/TableUnit.cpp index f7ddb49..5fe7d42 100644 --- a/TableUnit.cpp +++ b/TableUnit.cpp @@ -600,9 +600,10 @@ void __fastcall TTableFrame::UMLogUpdate(TMessage &msg) UpdateLogs(); } else if(iState==ST_PAID){ //显示输赢结果日志 - int ret = msg.LParam & 0xFFFF; + int ret = msg.LParam & 0xFF; int dead = (msg.LParam >> 16) & 0xFF; int stop = msg.LParam >> 24; + int blastMin = (msg.LParam >> 8) & 0xFF; //代码策略爆纤暂停分钟 if(ret==0){ //有错误发生 m_sgBets->Cells[3][m_logRows] = "X"; @@ -614,17 +615,19 @@ void __fastcall TTableFrame::UMLogUpdate(TMessage &msg) } if(g_bGameOn && (dead || stop)){ - int pause = 0; + int pause = blastMin ? blastMin : 0; //先取代码策略爆纤暂停分钟 if(dead && (m_pGame->bIndPolicy || !g_aGames.pRankChip)){ //独立策略或非全局注码 m_logRows++; m_sgBets->Cells[0][m_logRows] = "爆缆"; if(dead==3){ int iCP = m_pGame->bIndPolicy ? m_pGame->iChipPolicy : g_iChipPolicy; - TChipPolicy* pCP = (TChipPolicy*)g_aChipPolicies[iCP]; - m_sgBets->Cells[1][m_logRows] = pCP->deadPause ? "暂停" : "重启"; + int pm = blastMin; + if(!pm && iCP>=0) //打注一体无全局注码 + pm = ((TChipPolicy*)g_aChipPolicies[iCP])->deadPause; + m_sgBets->Cells[1][m_logRows] = pm ? "暂停" : "重启"; - if(pausedeadPause) - pause = pCP->deadPause; + if(pauseCells[1][m_logRows] = "局停"; diff --git a/app.manifest b/app.manifest index 250dbb3..239d5e0 100644 --- a/app.manifest +++ b/app.manifest @@ -1,9 +1,44 @@ + + + + + + + + + + + + + + + + + + + + + + + + + UTF-8 + + + True/PM + + \ No newline at end of file