?? game.pas
字號:
unit Game;interfaceuses Windows, MMSystem, Forms, Classes, Math, SysUtils, ScktComp, Path, Script, Common;//==============================================================================// 娭悢掕媊 procedure sv3PacketProcess(Socket: TCustomWinSocket); //edited by The Harbinger -- darkWeiss version//==============================================================================implementation//==============================================================================// 僎乕儉僒乕僶乕僷働僢僩張棟procedure sv3PacketProcess(Socket: TCustomWinSocket);var i :integer; h :integer; j :integer; k :integer; ii :integer; cmd :word; w :word; w1 :word; w2 :word; w3 :word;{捛壛} wjob:Int64;{捛壛僐僐傑偱}{傾僀僥儉惢憿捛壛} m1 :word;//庡偵惢憿偝傟傞傾僀僥儉偺ID偲偟偰棙梡 m :array[0..2] of word;//庡偵惢憿傾僀僥儉偵晄壜偝傟傞懏惈愇丄惎偺偐偗傜偺ID偲偟偰棙梡 e,e2 :word;//庡偵惢憿帪徚旓傾僀僥儉偺Inventory撪専嶕帪偵棙梡 anvil :word;//嬥晘偵傛?zhèn)羵膹銈獋閻瑢鳁?/span>{傾僀僥儉惢憿捛壛僐僐傑偱} id1,id2:cardinal; l :cardinal; l2 :cardinal; weight :cardinal; c :cardinal; b :byte; len :integer; str :string; str2 :string; accountid :string; charaid :string; npcid :string; tp :TPlayer; tc :TChara; tc1 :TChara; tm :TMap; tn :TNPC; ts :TMob; ts1 :TMob; tss :TSlaveDB; ma :TMArrowDB; tid :TIDTbl; ti :TItem; tk :TSkill; tkf :TKafra; tbn :TBan; tl :TSkillDB; td :TItemDB;{傾僀僥儉惢憿捛壛} tma :TMaterialDB;{傾僀僥儉惢憿捛壛僐僐傑偱}{僷乕僥傿乕婡擻捛壛} tpa :TParty;{僷乕僥傿乕婡擻捛壛僐僐傑偱}{僠儍僢僩儖乕儉婡擻捛壛} tcr :TChatRoom;{僠儍僢僩儖乕儉婡擻捛壛僐僐傑偱}{業(yè)揦僗僉儖捛壛} tv :TVender;{業(yè)揦僗僉儖捛壛僐僐傑偱} {庢堷婡擻捛壛} tdl :TDealings;{庢堷婡擻捛壛僐僐傑偱}{僉儏乕儁僢僩} tpd :TPetDB; tmd :TMobDB;{巵{敔捛壛} tsmn :TSummon;{巵{敔捛壛僐僐傑偱} tpe :TPet; i1, j1, k1 :integer;{僉儏乕儁僢僩偙偙傑偱}{NPC僀儀儞僩捛壛} mi :MapTbl;{NPC僀儀儞僩捛壛僐僐傑偱}{僊儖僪婡擻捛壛} tg :TGuild; tg1 :TGuild; tgb :TGBan; tgl :TGRel; tp1 :TPlayer;{僊儖僪婡擻捛壛僐僐傑偱} ta :TMapList; xy :TPoint; s :string; sl :TStringList; ww :array of array of word; tmpbuf:array of byte; txt:TextFile;begin j := 0; tcr := nil; while Socket.ReceiveLength >= 2 do begin //len := Socket.ReceiveLength; Socket.ReceiveBuf(buf[0], 2); RFIFOW(0, cmd); //if cmd = $00c8 then // DebugOut.Lines.Add('!'); tc := Socket.Data; if (cmd > $200) then begin //DebugOut.Lines.Add('晄柧側僷働僢僩' + IntToStr(Socket.ReceiveLength) + '僶僀僩傪攋婞偟傑偟偨'); SetLength(tmpbuf, Socket.ReceiveLength); Socket.ReceiveBuf(tmpbuf[0], Socket.ReceiveLength); continue; end; Assert((cmd > 0) and (cmd <= $200), 'Packet Type: index error ' + IntToStr(cmd)); if PacketLength[cmd] = -1 then begin Socket.ReceiveBuf(buf[2], 2); RFIFOW(2, w); Socket.ReceiveBuf(buf[4], w - 4); //DebugOut.Lines.Add(Format('3:%.8d CMD %.4x len:%d plen:%d', [tc.ID, cmd, w, len])); end else begin Socket.ReceiveBuf(buf[2], PacketLength[cmd] - 2); //if cmd <> $0072 then begin // DebugOut.Lines.Add(Format('3:%.8d CMD %.4x', [tc.ID, cmd])); //end; end; //DebugOut.Lines.Add('Command:' + IntToStr(cmd)); case cmd of //-------------------------------------------------------------------------- $0072: //僎乕儉嶪愙懕梫媮 begin RFIFOL( 2, l); accountid := IntToStr(l); //DebugOut.Lines.Add(Format('3:%.8d CMD %.4x', [l, cmd])); //DebugOut.Lines.Add(' AccountID = ' + IntToHex(l, 4)); RFIFOL( 6, l2); charaid := IntToStr(l2); //DebugOut.Lines.Add(' CharaID = ' + IntToHex(l, 4)); RFIFOL(10, id1); //DebugOut.Lines.Add(' LoginID1 = ' + IntToHex(id1, 4)); //RFIFOL(14, id2); if (Player.IndexOf(l) <> -1) and (Chara.IndexOf(l2) <> -1) then begin tp := Player.IndexOfObject(l) as TPlayer; tc := Chara.IndexOfObject(l2) as TChara; //if tc.IP = Socket.RemoteAddress then begin if (tp.LoginID1 = id1) and (tp.LoginID1 <> 0) then begin tc.ver2 := tp.ver2; //tp.LoginID1 := 0; tc.Login := 1; //tc.ID := tp.ID; //tc.Gender := tp.Gender; tc.PData := tp; if CharaPID.IndexOf(tc.ID) = -1 then CharaPID.AddObject(tc.ID, tc); tc.Socket := Socket; Socket.Data := tc; WFIFOL(0, $00000000); Socket.SendBuf(buf, 4); WFIFOW(0, $0073); WFIFOL(2, timeGetTime()); WFIFOM1(6, tc.Point); WFIFOW(9, $0505); Socket.SendBuf(buf, 11); //慜夞儚乕僾偵幐攕偟偰棊偪偨偲偒偺暅媽張棟 if tc.tmpMap <> '' then begin tc.Map := tc.tmpMap; tc.tmpMap := ''; end; //儅僢僾儘乕僪 if Map.IndexOf(tc.Map) = -1 then begin MapLoad(tc.Map); end;{僊儖僪婡擻捛壛} j := GuildList.IndexOf(tc.GuildID); if (j <> -1) then begin tg := GuildList.Objects[j] as TGuild; //儊儞僶乕偵捠抦 WFIFOW( 0, $016d); WFIFOL( 2, tc.ID); WFIFOL( 6, tc.CID); WFIFOL(10, 1); SendGuildMCmd(tc, 14, true); //僊儖僪忣曬 SendGLoginInfo(tg, tc); end;{僊儖僪婡擻捛壛僐僐傑偱} end else begin WFIFOW(0, $0074); //偁偭偰傞偐側丠 WFIFOB(2, 0); Socket.SendBuf(buf, 3); end; end; end; //-------------------------------------------------------------------------- $007d: //MAP儘乕僪姰椆 begin if tc.tmpMap <> '' then begin tc.Map := tc.tmpMap; tc.tmpMap := ''; end; tm := Map.Objects[Map.IndexOf(tc.Map)] as TMap; while tm.Mode < 2 do Application.ProcessMessages; tc.MData := tm; if CharaPID.IndexOf(tc.ID) = -1 then CharaPID.AddObject(tc.ID, tc); mi := MapInfo.Objects[MapInfo.IndexOf(tm.Name)] as MapTbl; //儅僢僾偵帺暘偑嫃傞偙偲傪婰榐 tm.CList.AddObject(tc.ID, tc); tm.Block[tc.Point.X div 8][tc.Point.Y div 8].CList.AddObject(tc.ID, tc); //惗偒曉傝張棟 if tc.Sit = 1 then tc.Sit := 3; if tc.HP = 0 then if tc.JID = 0 then tc.HP := tc.MAXHP div 2 else tc.HP := 1;{業(yè)揦僗僉儖捛壛} tc.VenderID := 0;{業(yè)揦僗僉儖捛壛僐僐傑偱}{僠儍僢僩儖乕儉婡擻捛壛} tc.ChatRoomID := 0;{僠儍僢僩儖乕儉婡擻捛壛僐僐傑偱}{庢堷婡擻捛壛} tc.DealingID := 0; tc.PreDealID := 0;{庢堷婡擻捛壛僐僐傑偱} //僽儘僢僋張棟 for j := tc.Point.Y div 8 - 2 to tc.Point.Y div 8 + 2 do begin for i := tc.Point.X div 8 - 2 to tc.Point.X div 8 + 2 do begin //NPC儘乕僪 for k := 0 to tm.Block[i][j].NPC.Count - 1 do begin tn := tm.Block[i][j].NPC.Objects[k] as TNPC; if (abs(tc.Point.X - tn.Point.X) < 16) and (abs(tc.Point.Y - tn.Point.Y) < 16) then begin{NPC僀儀儞僩捛壛} //SendNData(Socket, tn, tc.ver2); if (tn.Enable = true) then begin SendNData(Socket, tn,tc.ver2); if (tn.ScriptInitS <> -1) and (tn.ScriptInitD = false) then begin //OnInit儔儀儖傪幚峴 //DebugOut.Lines.Add(Format('OnInit Event(%d)', [tn.ID])); tc1 := TChara.Create; tc1.TalkNPCID := tn.ID; tc1.ScriptStep := tn.ScriptInitS; tc1.AMode := 3; tc1.AData := tn; tc1.Login := 0; NPCScript(tc1,0,1); tn.ScriptInitD := true; tc1.Free; end; if (tn.ChatRoomID <> 0) then begin //僠儍僢僩儖乕儉傪昞帵偡傞 ii := ChatRoomList.IndexOf(tn.ChatRoomID); if (ii <> -1) then begin tcr := ChatRoomList.Objects[ii] as TChatRoom; if (tn.ID = tcr.MemberID[0]) then begin w := Length(tcr.Title); WFIFOW(0, $00d7); WFIFOW(2, w + 17); WFIFOL(4, tcr.MemberID[0]); WFIFOL(8, tcr.ID); WFIFOW(12, tcr.Limit); WFIFOW(14, tcr.Users); WFIFOB(16, tcr.Pub); WFIFOS(17, tcr.Title, w); if tc.Socket <> nil then begin tc.Socket.SendBuf(buf, w + 17); end; end; end; end; end;{NPC僀儀儞僩捛壛僐僐傑偱} end; end; //廃傝偺恖偵捠抦&廃傝偵偄傞恖傪昞帵偝偣傞 for k := 0 to tm.Block[i][j].CList.Count - 1 do begin tc1 := tm.Block[i][j].CList.Objects[k] as TChara; if (tc <> tc1) and (abs(tc.Point.X - tc1.Point.X) < 16) and (abs(tc.Point.Y - tc1.Point.Y) < 16) then begin SendCData(tc.Socket, tc1); SendCData(tc1.Socket, tc, true);{僠儍僢僩儖乕儉婡擻捛壛} //廃曈偺僠儍僢僩儖乕儉傪昞帵 ChatRoomDisp(tc.Socket, tc1);{僠儍僢僩儖乕儉婡擻捛壛僐僐傑偱}{業(yè)揦僗僉儖捛壛} //廃曈偺業(yè)揦傪昞帵 VenderDisp(tc.Socket, tc1);{業(yè)揦僗僉儖捛壛僐僐傑偱} end; end; //儌儞僗僞乕儘乕僪 for k := 0 to tm.Block[i][j].Mob.Count - 1 do begin ts := tm.Block[i][j].Mob.Objects[k] as TMob; if (abs(tc.Point.X - ts.Point.X) < 16) and (abs(tc.Point.Y - ts.Point.Y) < 16) then begin SendMData(Socket, ts); end; end; end; end; //僗僉儖憲怣 SendCSkillList(tc); { WFIFOW( 0, $010f); j := 0; for i := 1 to 157 do begin if tc.Skill[i].Lv <> 0 then begin WFIFOW( 0+37*j+4, i); WFIFOW( 2+37*j+4, tc.Skill[i].Data.SType); WFIFOW( 4+37*j+4, 0); WFIFOW( 6+37*j+4, tc.Skill[i].Lv); WFIFOW( 8+37*j+4, tc.Skill[i].Data.SP[tc.Skill[i].Lv]); WFIFOW(10+37*j+4, tc.Skill[i].Data.Range); WFIFOS(12+37*j+4, tc.Skill[i].Data.IDC, 24); WFIFOB(36+37*j+4, 0); Inc(j); end; end; WFIFOW( 2, 4+37*j); Socket.SendBuf(buf, 4+37*j); } //僷儔儊乕僞 CalcStat(tc); SendCStat(tc); //傾僀僥儉僨乕僞 WFIFOW(0, $00a3); j := 0; for i := 1 to 100 do begin if (tc.Item[i].ID <> 0) and (not tc.Item[i].Data.IEquip) then begin WFIFOW( 4 +j*10, i); WFIFOW( 6 +j*10, tc.Item[i].Data.ID); WFIFOB( 8 +j*10, tc.Item[i].Data.IType); WFIFOB( 9 +j*10, tc.Item[i].Identify); WFIFOW(10 +j*10, tc.Item[i].Amount); if tc.Item[i].Data.IType = 10 then WFIFOW(12 +j*10, 32768) else WFIFOW(12 +j*10, 0); Inc(j); end; end; WFIFOW(2, 4+j*10); Socket.SendBuf(buf, 4+j*10); //憰旛僨乕僞 WFIFOW(0, $00a4); j := 0; for i := 1 to 100 do begin if (tc.Item[i].ID <> 0) and tc.Item[i].Data.IEquip then begin WFIFOW( 4 +j*20, i); WFIFOW( 6 +j*20, tc.Item[i].Data.ID); WFIFOB( 8 +j*20, tc.Item[i].Data.IType); WFIFOB( 9 +j*20, tc.Item[i].Identify); with tc.Item[i].Data do begin if (tc.JID = 12) and (IType = 4) and (Loc = 2) and ((View = 1) or (View = 2) or (View = 6)) then WFIFOW(10 +j*20, 34) else WFIFOW(10 +j*20, Loc); end; WFIFOW(12 +j*20, tc.Item[i].Equip); WFIFOB(14 +j*20, tc.Item[i].Attr); WFIFOB(15 +j*20, tc.Item[i].Refine); WFIFOW(16 +j*20, tc.Item[i].Card[0]); WFIFOW(18 +j*20, tc.Item[i].Card[1]); WFIFOW(20 +j*20, tc.Item[i].Card[2]); WFIFOW(22 +j*20, tc.Item[i].Card[3]); Inc(j); end; end; WFIFOW(2, 4+j*20); Socket.SendBuf(buf, 4+j*20); //憰旛偟偰偄傞媩 j := 0; for i := 1 to 100 do begin
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -