⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cmain.~pas

📁 传奇的登陆器!也是在网上搜索的!不知道好不好用
💻 ~PAS
📖 第 1 页 / 共 5 页
字号:
    if Sender = ButtonServer4 then begin
    sSvrName := g_ServerList.Strings[3];
  end else
    if Sender = ButtonServer5 then begin
    sSvrName := g_ServerList.Strings[4];
  end else
    if Sender = ButtonServer6 then begin
    sSvrName := g_ServerList.Strings[5];
  end else
    if Sender = ButtonServer7 then begin
    sSvrName := g_ServerList.Strings[6];
  end else
    if Sender = ButtonServer8 then begin
    sSvrName := m_SelGameZone.sServerName;
  end;
  if sSvrName <> '' then begin
    g_sServerMiniName := sSvrName;
    g_sServerName := sSvrName;
    SendSelectServer(sSvrName);
  end;

end;

procedure TfrmCMain.ButtonSelectChr1Click(Sender: TObject);
var
  sChrName: string;
begin
  if Sender = ButtonSelectChr1 then begin
    if (not g_ChrArr[0].boSelected) and (g_ChrArr[0].boValid) then begin
      EditSelectChrCurChr.Text := (g_ChrArr[0].UserChr.sName);
      g_ChrArr[0].boSelected := True;
      g_ChrArr[1].boSelected := False;
      g_ChrArr[0].boUnfreezing := True;
      g_ChrArr[0].nAniIndex := 0;
      g_ChrArr[0].nDarkLevel := 0;
      g_ChrArr[0].nEffIndex := 0;
      g_ChrArr[0].dwStartTime := GetTickCount;
      g_ChrArr[0].dwMoretime := GetTickCount;
      g_ChrArr[0].dwStartefftime := GetTickCount;
    end;
  end else
    if Sender = ButtonSelectChr2 then begin
    if (not g_ChrArr[1].boSelected) and (g_ChrArr[1].boValid) then begin
      EditSelectChrCurChr.Text := (g_ChrArr[1].UserChr.sName);
      g_ChrArr[1].boSelected := True;
      g_ChrArr[0].boSelected := False;
      g_ChrArr[1].boUnfreezing := True;
      g_ChrArr[1].nAniIndex := 0;
      g_ChrArr[1].nDarkLevel := 0;
      g_ChrArr[1].nEffIndex := 0;
      g_ChrArr[1].dwStartTime := GetTickCount;
      g_ChrArr[1].dwMoretime := GetTickCount;
      g_ChrArr[1].dwStartefftime := GetTickCount;
    end;

  end else
    if Sender = ButtonSelectChrStartPlay then begin
    sChrName := '';
    if g_ChrArr[0].boValid and g_ChrArr[0].boSelected then sChrName := g_ChrArr[0].UserChr.sName;
    if g_ChrArr[1].boValid and g_ChrArr[1].boSelected then sChrName := g_ChrArr[1].UserChr.sName;
    if sChrName <> '' then begin
      SendSelChr(sChrName);
    end else begin
      MessageDlg('还没创建游戏角色!\点击创建角色按钮创建一个游戏角色。', [mbOk]);
    end;
  end else
    if Sender = ButtonSelectChrNewChr then begin
    if not g_ChrArr[0].boValid or not g_ChrArr[1].boValid then begin
      if not g_ChrArr[0].boValid then MakeNewChar(0)
      else MakeNewChar(1);
    end else begin
      MessageDlg('一个帐号最多只能创建二个游戏角色!', [mbOk]);
    end;
  end else
    if Sender = ButtonSelectChrDelChr then begin
    sChrName := EditSelectChrCurChr.Text;
    if MessageBox(Handle, PChar(format('是否确认删除此角色?'#13#13'角色名称: %s', [sChrName])), '确认信息', MB_YESNO + MB_ICONQUESTION) = ID_YES then begin
      SendDelChr(sChrName);
    end;
  end else
    if Sender = ButtonCreateNewChrWarr then begin
    EditCreateNewChrJob.Text := '武士';
    EditCreateNewChrJob.Tag := 0;
  end else
    if Sender = ButtonCreateNewChrWizard then begin
    EditCreateNewChrJob.Text := '法师';
    EditCreateNewChrJob.Tag := 1;
  end else
    if Sender = ButtonCreateNewChrTaos then begin
    EditCreateNewChrJob.Text := '道士';
    EditCreateNewChrJob.Tag := 2;
  end else
    if Sender = ButtonCreateNewChrMale then begin
    EditCreateNewChrSex.Text := '男';
    EditCreateNewChrSex.Tag := 0;
  end else
    if Sender = ButtonCreateNewChrFemale then begin
    EditCreateNewChrSex.Text := '女';
    EditCreateNewChrSex.Tag := 1;
  end else
    if Sender = ButtonCreateNewChrOK then begin
    SelectChrCreateNewChr();
  end;
end;

procedure TfrmCMain.DecodeMessagePacket(sDataBlock: string);
var
  sData: string;
  sTagStr: string;
  sDefMsg: string;
  sBody: string;
  DefMsg: TDefaultMessage;
begin
  if sDataBlock[1] = '+' then begin //checkcode
    sData := Copy(sDataBlock, 2, Length(sDataBlock) - 1);
    sData := GetValidStr3(sData, sTagStr, ['/']);
    if sTagStr = 'PWR' then g_boNextTimePowerHit := True; //打开攻杀
    if sTagStr = 'LNG' then g_boCanLongHit := True; //打开刺杀
    if sTagStr = 'ULNG' then g_boCanLongHit := False; //关闭刺杀
    if sTagStr = 'WID' then g_boCanWideHit := True; //打开半月
    if sTagStr = 'UWID' then g_boCanWideHit := False; //关闭半月
    if sTagStr = 'CRS' then g_boCanCrsHit := True;
    if sTagStr = 'UCRS' then g_boCanCrsHit := False;
    if sTagStr = 'TWN' then g_boCanTwnHit := True;
    if sTagStr = 'UTWN' then g_boCanTwnHit := False;
    if sTagStr = 'STN' then g_boCanStnHit := True;
    if sTagStr = 'USTN' then g_boCanStnHit := False;
    if sTagStr = 'FIR' then begin
      g_boNextTimeFireHit := True; //打开烈火
      g_dwLatestFireHitTick := GetTickCount;
      //Myself.SendMsg (SM_READYFIREHIT, Myself.XX, Myself.m_nCurrY, Myself.Dir, 0, 0, '', 0);
    end;
    if sTagStr = 'UFIR' then g_boNextTimeFireHit := False; //关闭烈火
    if sTagStr = 'GOOD' then begin
      g_boActionLock := False;
      Inc(g_nReceiveCount);
    end;
    if sTagStr = 'FAIL' then begin
      ActionFailed;
      g_boActionLock := False;
      Inc(g_nReceiveCount);
    end;
    if sData <> '' then begin
      CheckSpeedHack(Str_ToInt(sData, 0));
    end;
    Exit;
  end;
  if Length(sDataBlock) < DEFBLOCKSIZE then begin
    if sDataBlock[1] = '=' then begin
      sData := Copy(sDataBlock, 2, Length(sDataBlock) - 1);
      if sData = 'DIG' then begin
        g_PlayScene.m_MySelf.m_boDigFragment := True;
      end;
    end;
    Exit;
  end;

  sDefMsg := Copy(sDataBlock, 1, DEFBLOCKSIZE);
  sBody := Copy(sDataBlock, DEFBLOCKSIZE + 1, Length(sDataBlock) - DEFBLOCKSIZE);
  DefMsg := DecodeMessage(sDefMsg);

  if g_PlayScene.m_MySelf = nil then begin
    case DefMsg.Ident of
      SM_NEWID_SUCCESS: ClientNewIDSuccess();
      SM_NEWID_FAIL: ClientNewIDFail(DefMsg.Recog);
      SM_PASSWD_FAIL: ClientLoginFail(DefMsg.Recog);
      SM_PASSOK_SELECTSERVER: ClientGetPasswordOK(DefMsg, sBody);
      SM_SELECTSERVER_OK: ClientGetPasswdSuccess(sBody);
      SM_QUERYCHR: ClientGetReceiveChrs(sBody);
      SM_QUERYCHR_FAIL: ClientQueryChrFail(DefMsg.Recog);
      SM_NEWCHR_SUCCESS: SendQueryChr();
      SM_NEWCHR_FAIL: ClientNewChrFail(DefMsg.Recog);
      SM_DELCHR_SUCCESS: SendQueryChr();
      SM_DELCHR_FAIL: ClientDelChrFail(DefMsg.Recog);
      SM_STARTPLAY: ClientGetStartPlay(sBody);
      SM_STARTFAIL: ClientStartPlayFail();
      SM_VERSION_FAIL: ClientVersionFail();
      SM_OUTOFCONNECTION,
        SM_NEWMAP,
        SM_LOGON,
        SM_RECONNECT,
        SM_SENDNOTICE: ;
      else Exit;
    end;
  end;
  if g_boMapMoving then begin
    if DefMsg.Ident = SM_CHANGEMAP then begin
      g_WaitingMsg := DefMsg;
      g_sWaitingStr := DecodeString(sBody);
      g_boMapMovingWait := True;
      WaitMsgTimer.Enabled := True;
    end;
    Exit;
  end;
  case DefMsg.Ident of
    SM_NEWMAP: ClientGetNewMap(DefMsg, sBody);
    //SM_SERVERCONFIG    :;
    SM_RECONNECT: ClientGetReconnect(sBody);
    SM_TIMECHECK_MSG: CheckSpeedHack(DefMsg.Recog);
    SM_AREASTATE: ClientGetAreaState(DefMsg.Recog);
    SM_MAPDESCRIPTION: ClientGetMapDescription(DefMsg, sBody);
    //SM_GAMEGOLDNAME    :ClientGetGameGoldName(DefMsg,sBody);
    SM_ADJUST_BONUS: ClientGetAdjustBonus(DefMsg.Recog, sBody);
    SM_MYSTATUS: ClientGetMyStatus(DefMsg);
    SM_TURN: ClientGetObjTurn(DefMsg, sBody);
    SM_BACKSTEP: ClientGetBackStep(DefMsg, sBody);

    SM_ABILITY: ClientGetAbility(DefMsg, sBody);
    SM_SUBABILITY: ClientGetSubAbility(DefMsg);
    SM_DAYCHANGING: ClientGetDayChanging(DefMsg);
    SM_WINEXP: ClientGetWinExp(DefMsg);
    SM_LEVELUP: ClientGetLevelUp(DefMsg);
    SM_HEALTHSPELLCHANGED: CliengGetHealthSpellChaged(DefMsg);
    SM_STRUCK: ClientGetStruck(DefMsg, sBody);
    //SM_PASSWORD          :;
    SM_OPENHEALTH: ;
    SM_CLOSEHEALTH: ;
    SM_INSTANCEHEALGUAGE: ;
    SM_BREAKWEAPON: ;

    SM_SENDNOTICE: ClientGetSendNotice(sBody);
    SM_LOGON: ClientGetUserLogin(DefMsg, sBody);
    SM_CRY,
      SM_GROUPMESSAGE,
      SM_GUILDMESSAGE,
      SM_WHISPER,
      SM_SYSMESSAGE: ClientGetMessage(DefMsg, sBody);
    SM_HEAR: ClientHearMsg(DefMsg, sBody);
    SM_USERNAME: ClientGetUserName(DefMsg, sBody);
    SM_CHANGENAMECOLOR: ClientGetUserNameColor(DefMsg);
    SM_HIDE,
      SM_GHOST,
      SM_DISAPPEAR: ClientGetHideObject(DefMsg);
    SM_DIGUP: ClientObjDigup(DefMsg, sBody);
    SM_DIGDOWN: ClientObjDigDown(DefMsg);
    SM_SHOWEVENT: ;
    SM_HIDEEVENT: ;
    SM_ADDITEM: ClientGetAddItem(sBody);
    SM_BAGITEMS: ClientGetBagItmes(sBody);
    SM_UPDATEITEM: ClientGetUpdateItem(sBody);
    SM_DELITEM: ClientGetDelItem(sBody);
    SM_DELITEMS: ClientGetDelItems(sBody);
    SM_DROPITEM_SUCCESS: ClientDelDropItem(DefMsg.Recog, sBody);
    SM_DROPITEM_FAIL: ClientGetDropItemFail(DefMsg.Recog, sBody);
    SM_ITEMSHOW: ClientGetShowItem(DefMsg.Recog, DefMsg.Param {x}, DefMsg.Tag {y}, DefMsg.Series {looks}, DecodeString(sBody));
    SM_ITEMHIDE: ClientGetHideItem(DefMsg.Recog, DefMsg.Param, DefMsg.Tag);
    SM_OPENDOOR_OK: ; //Map.OpenDoor (msg.param, msg.tag);
    SM_OPENDOOR_LOCK: ; //DScreen.AddSysMsg ('此门被锁定!');
    SM_CLOSEDOOR: ; //Map.CloseDoor (msg.param, msg.tag);
    SM_TAKEON_OK: ClientGetTakeOnOK(DefMsg.Recog);
    SM_TAKEON_FAIL: ClientGetTakeOnFail();
    SM_TAKEOFF_OK: ClientGetTakeOffOK(DefMsg.Recog);
    SM_TAKEOFF_FAIL: ClientGetTakeOffFail();
    SM_EXCHGTAKEON_OK: ;
    SM_EXCHGTAKEON_FAIL: ;
    SM_SENDUSEITEMS: ClientGetSenduseItems(sBody);
    SM_WEIGHTCHANGED: ClientGetWeightChanged(DefMsg);
    SM_GOLDCHANGED: ClientGetGoldChanged(DefMsg);
    SM_FEATURECHANGED: ClientGetFeatureChange(DefMsg);
    SM_CHARSTATUSCHANGED: ClientGetCharStatusChange(DefMsg);
    SM_CLEAROBJECTS: ClientGetClearObjects();
    SM_EAT_OK: ClientGetEatItemOK();
    SM_EAT_FAIL: ClientGetEatItemFail();
    SM_ADDMAGIC: ClientGetAddMagic(sBody);
    SM_SENDMYMAGIC: ClientGetMyMagics(sBody);
    SM_DELMAGIC: ClientGetDelMagic(DefMsg.Recog);
    SM_MAGIC_LVEXP: ClientGetMagicLevelUp(DefMsg);
    SM_DURACHANGE: ClientGetDuraChange(DefMsg);
    SM_MERCHANTSAY: ClientGetMerchantSay(DefMsg, sBody);
    SM_MERCHANTDLGCLOSE: ClientGetMerchantClose();
    SM_SENDGOODSLIST: ClientGetSendGoodsList(DefMsg, sBody);
    SM_SENDUSERMAKEDRUGITEMLIST: ClientGetSendMakeDrugList(DefMsg, sBody);
    SM_SENDUSERSELL: ClientGetSendUserSell(DefMsg.Recog);
    SM_SENDUSERREPAIR: ClientGetSendUserRepair(DefMsg.Recog);
    SM_SENDBUYPRICE: ClientGetBuyPrice(DefMsg);
    SM_USERSELLITEM_OK: ClientGetUserSellItemOK();
    SM_SENDREPAIRCOST: ClientGetRepairCost(DefMsg);
    SM_USERREPAIRITEM_OK: ;
    SM_USERREPAIRITEM_FAIL: ;
    SM_STORAGE_OK,
      SM_STORAGE_FULL,
      SM_STORAGE_FAIL: ;
    SM_SAVEITEMLIST: ;
    SM_TAKEBACKSTORAGEITEM_OK,
      SM_TAKEBACKSTORAGEITEM_FAIL,
      SM_TAKEBACKSTORAGEITEM_FULLBAG: ;
  end;
end;

procedure TfrmCMain.CloseScene();
begin
  case g_CurrentScene of
    s_None: ;
    s_Intro: ;
    s_NewAccount: begin
        PanelNewAccount.Visible := False;
      end;
    s_Login: begin
        PanelUserLogin.Visible := False;
      end;
    s_SelectServer: begin
        PanelSelectServer.Visible := False;
      end;
    s_SelectChr: begin
        PanelSelectChr.Visible := False;
      end;
    s_LoginNotice: ;
    s_Play: begin
        PanelPlayGame.Visible := False;
      end;
  end;
end;
procedure TfrmCMain.OpenScene();
begin
  case g_CurrentScene of
    s_None: ;
    s_Intro: ;
    s_NewAccount: begin
        PanelNewAccount.Left := (PanelClient.Width - PanelNewAccount.Width) div 2;
        PanelNewAccount.top := (PanelClient.Height - PanelNewAccount.Height) div 2;
        SetTopOrder(PanelNewAccount);
        PanelNewAccount.Visible := True;
      end;
    s_Login: begin
        PanelUserLogin.Left := (Width - PanelUserLogin.Width) div 2;
        PanelUserLogin.top := (Height - PanelUserLogin.Height) div 2;
        PanelUserLogin.Visible := True;
        EditUserAccount.Text := '';
        EditUserPassword.Text := '';
        //EditUserAccount.SetFocus;
        EditUserAccount.Enabled := True;
        EditUserPassword.Enabled := True;
        ButtonStart.Enabled := True;
        SetTopOrder(PanelUserLogin);
      end;
    s_SelectServer: begin
        PanelSelectServer.Left := (PanelClient.Width - PanelSelectServer.Width) div 2;
        PanelSelectServer.top := (PanelClient.Height - PanelSelectServer.Height) div 2;
        ButtonServer1.Visible := False;
        ButtonServer2.Visible := False;
        ButtonServer3.Visible := False;
        ButtonServer4.Visible := False;
        ButtonServer5.Visible := False;
        ButtonServer6.Visible := False;
        ButtonServer7.Visible := False;
        ButtonServer8.Visible := False;
        PanelSelectServer.Visible := True;
        SetTopOrder(PanelSelectServer);
        ShowSelectServer();
        if m_boAutoLogin then begin
          //SendSelectServer(m_GameZone.sServerName);
        end;

      end;
    s_SelectChr: begin
        PanelSelectChr.Left := (PanelClient.Width - PanelSelectChr.Width) div 2;
        PanelSelectChr.top := (PanelClient.Height - PanelSelectChr.Height) div 2;
        PanelSelectChr.Visible := True;
        SetTopOrder(PanelSelectChr);
        if m_boAutoLogin then begin
          if m_nAutoChr = 0 then begin
            ButtonSelectChr1Click(ButtonSelectChr1);
          end else begin
            ButtonSelectChr1Click(ButtonSelectChr2);
          end;
          ButtonSelectChr1Click(ButtonSelectChrStartPlay);
        end;
      end;
    s_LoginNotice: ;
    s_Play: begin
        PanelPlayGame.Left := (PanelClient.Width - PanelPlayGame.Width) div 2;
        PanelPlayGame.top := (PanelClient.Height - PanelPlayGame.Height) div 2;
        PanelPlayGame.Align := alClient;
        SetTopOrder(PanelPlayGame);
        PanelPlay.Visible := False;
        PanelPlayGame.Visible := True;

      end;
  end;
end;
procedure TfrmCMain.ChangeScene(SceneType: TSceneType);
begin
  if g_CurrentScene <> s_None then CloseScene();


  case SceneType of
    stIntro: g_CurrentScene := s_Intro;
    st_NewAccount: g_CurrentScene := s_NewAccount;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -