V-ConnectServer.asm
资源名称:VeMU.rar [点击查看]
上传用户:santakups8
上传日期:2021-03-23
资源大小:544k
文件大小:4k
源码类别:
模拟服务器
开发平台:
Asm
- ;EasyCodeName=Module1,1
- ;-----------------------------------------------------------------------------------
- ; VeMU
- ; Its a package that allows the user to set his own server of the game
- ; "MuOnline", this is not an emulator since i am not "emulating"
- ; what the actual games does, i am "creating" a method for set a Server
- ; of this Game.
- ;
- ; Copyright (C) 2010 Felipe Ya馿z
- ;
- ; This program is free software: you can redistribute it and/or modify
- ; it under the terms of the GNU General Public License as published by
- ; the Free Software Foundation, either version 3 of the License, or
- ; (at your option) any later version.
- ;
- ; This program is distributed in the hope that it will be useful,
- ; but WITHOUT ANY WARRANTY; without even the implied warranty of
- ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- ; GNU General Public License for more details.
- ;
- ; You should have received a copy of the GNU General Public License
- ; along with this program. If not, see http://www.gnu.org/licenses/.
- ;-----------------------------------------------------------------------------------
- ;-----------------------------------------------------------------------------------
- ; -----------------
- ; Coded /
- ; By /
- ; -={FeN$x)=-
- ; / Felipe Y.
- ; /
- ; -----------------
- ; Programming Lang: ASM
- ; Country: Chile
- ; My respect for all those who lost their lifes
- ; In the earthquake of my country...
- ; Let god take their spirits home...
- ;-----------------------------------------------------------------------------------
- V_CS_ProtocolCore Proto :Dword, :Dword, :Dword
- Packet_CS_InfoPacket Struct
- UniHeaders PacketHeaders <>
- ServerCode Word ? ;Server Code
- ConnectedPlayers Byte ? ;ConnectedPlayers * 100 / 500
- NoUsage Byte ? ;The name says it
- TotalPlayers Word ? ;Real counter of total players connected, no calculation needed
- LoginCounter Word ? ;A counter with all the attemps of login
- LoginCounter2 Word ? ;For no usage rigth now
- MaxPlayers Word ? ;Max players can be connected to server (originally 500)
- Packet_CS_InfoPacket EndS
- .Const
- .Data?
- .Data
- .Code
- V_CS_ProtocolCore Proc PacketHeader:DWord, pRecvBuffer:DWord, PacketLength:DWord
- .const
- CSProto_MaxHeader Equ 7BH
- .Data
- ;===========
- ;Case Code
- ;===========
- CSCaseCode Byte 2 Dup (0, 1)
- ;===========
- ;jump table
- ;===========
- Align 4
- CSjmpTable DD Offset CSCase0
- DD Offset CSCase1
- .Code
- Mov Eax, PacketHeader
- .If (Eax > CSProto_MaxHeader)
- .else
- Xor Ecx, Ecx
- Mov Cl, Byte Ptr [Eax + CSCaseCode]
- Jmp DWord Ptr [Ecx * 4 + CSjmpTable] ;Jump table optimised C++
- CSCase0: ;Invalid case, i dont like Case 00
- Jmp CSEndProcedure
- CSCase1: ;SubHeader 01
- Jmp CSEndProcedure
- .endif
- CSEndProcedure:
- Ret
- V_CS_ProtocolCore EndP
- V_CS_InfoSend Proc
- local MyStruct:Dword
- mov MyStruct, ecx
- lea eax, InternalPacket
- assume eax:ptr Packet_CS_InfoPacket
- Mov [eax].UniHeaders.PacketType, 0C1H
- Mov [eax].UniHeaders.PacketLength, 10H
- Mov [eax].UniHeaders.Header, 1
- Mov [eax].UniHeaders.SubHeader, 10H
- Mov Edx, ServerCode
- Mov [eax].ServerCode, Dx
- .If (TotalPlayers != 0)
- push eax ;Save struct
- mov edx, MAXSERVERUSER
- mov eax, TotalPlayers
- IMul Eax, Eax, 100
- Cdq
- IDiv edx ;TotalPlayers * 100 / MaxServerUsers
- mov dl, al
- pop eax ;Return Struct
- Mov [eax].ConnectedPlayers, Dl
- .Else
- Mov [eax].ConnectedPlayers, 0
- .EndIf
- Mov ecx, TotalPlayers
- Mov [eax].TotalPlayers, Cx
- Mov edx, LoginCounter
- Mov [eax].LoginCounter, Dx
- Mov [eax].LoginCounter2, 0 ;for now no usage
- Mov ecx, MAXSERVERUSER
- Mov [eax].MaxPlayers, Cx
- Mov Ecx, MyStruct
- Invoke V_Sock_Send, Addr InternalPacket, [eax].UniHeaders.PacketLength
- Ret
- V_CS_InfoSend EndP