V-ObjInit.asm
资源名称:VeMU.rar [点击查看]
上传用户:santakups8
上传日期:2021-03-23
资源大小:544k
文件大小:8k
源码类别:
模拟服务器
开发平台:
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...
- ;-----------------------------------------------------------------------------------
- Object Struct
- ObjCleaned Dword ? ;Identifier for know if this section of pObjSpace has been cleaned
- ObjectID DWord ? ;Used has ClientID, also knowed as PlayerID (but its also for mobs)
- Connected DWord ? ;If 0 == Not connected if 1 == Connected
- Socket Dword ? ;
- SocketContext DWord ? ;Pointer to struct _PER_SOCKET_CONTEXT (not used for now)
- ObjCreationTime DWord ? ;Researching why used for
- RecallMonster DWord ?
- TempMagicInfo Dword ? ;Researching why we need it (dont edit for now)
- MagicInfo DWord ?
- pMobInventory Dword ? ;This variable should never been touch for players
- Inventory1 DWord ?
- Inventory2 DWord ?
- InventoryMap1 DWord ?
- InventoryMap2 DWord ?
- InventoryTrade DWord ?
- TradeMap DWord ?
- WareHouse DWord ?
- WareHouseMap DWord ?
- WareHouseCount Dword ?
- ChaosBox Dword ?
- Object EndS
- .Const
- .Data?
- .Data
- .Code
- V_Obj_Init Proc
- Local PlayerIndexCounter:DWord
- Local VectorRep:DWord
- ;//////////////////////
- ;Clean some local vars
- ;//////////////////////
- Mov PlayerIndexCounter, 0
- Mov VectorRep, 0
- ;-------------------------------------------------------------------------------
- ;Constructs vectors for:
- ;TempInventory & TempInventoryMap
- ;
- ;FOR NOW IT HAVE NO REAL USAGE
- ;-------------------------------------------------------------------------------
- ;.Repeat
- ; .if (VectorRep == 0)
- ; lea eax, pTempInventory ;Temporal inventory
- ; .else
- ; lea eax, pTempInventoryMap
- ; .endif
- ; Invoke V_VectorCreator, Eax, Offset V_CItem_Clear, SizeOf ItemStruct, INVENTORY_SIZE ;Vector constructor
- ; add VectorRep, 1
- ;.until (VectorRep == 2)
- ;mov VectorRep, 0
- ;/////////////////////////////////////////
- ;Lets make the loop for mobs and players
- ;/////////////////////////////////////////
- .Repeat
- ;-------------------------------------------------------------------------------
- ;Clean ObjectStruct to 00 bytes
- ;-------------------------------------------------------------------------------
- pObj PlayerIndexCounter, SizeOf Object, pObjSpace ;Macro to make lpObj
- push eax ;Save struct
- Invoke V_ZeroBuff, Eax, SizeOf Object ;fill Obj with ZERO bytes
- pop eax ;Return struct
- ;-------------------------------------------------------------------------------
- ;Set some basic data to Obj Struct for Mobs and Players
- ;-------------------------------------------------------------------------------
- Assume Eax:Ptr Object
- Mov [Eax].ObjCleaned, 0FFH ;ID for check if object is empty (cleaned)
- Mov [Eax].Socket, -1 ;Set Socket inactive mode
- Mov [Eax].RecallMonster, -1 ;Set Recall Monster inactive mode
- Push Eax
- Invoke GetTickCount
- Mov Edx, Eax
- Pop Eax
- Mov [Eax].ObjCreationTime, Edx ;Save current Tick Count time in Obj Struct
- ;-------------------------------------------------------------------------------
- ;Constructs vectors for:
- ;TempMagicInfo & MagicInfo
- ;Save into respective Obj struct
- ;-------------------------------------------------------------------------------
- .Repeat
- pObj PlayerIndexCounter, SizeOf Object, pObjSpace ;Calc object
- .if (VectorRep == 0)
- lea edx, pTempMagicInfo
- lea eax, [eax].TempMagicInfo
- .else
- lea edx, pMagicInfo
- lea eax, [eax].MagicInfo
- .endif
- push edx
- push eax
- Invoke V_VectorCreator, Edx, Offset V_MagicInfo_Clear, SizeOf MagicInfo, MAGIC_CAPACITY
- pop eax
- pop edx
- mov [eax], edx
- add VectorRep, 1
- .until (VectorRep == 2)
- mov VectorRep, 0
- .If (PlayerIndexCounter >= START_OBJ_PLAYERID) ;If PlayerIDObjects
- ;//////////////////////////////////
- ;Players Object !
- ;//////////////////////////////////
- ;-------------------------------------------------
- ;Constructs vectors for:
- ;Inventory1, Inventory2, TradeInv, WareHouse
- ;Later save pointers to respective Obj struct
- ;------------------------------------------------------------------------------------------------------------------------
- .Repeat
- pObj PlayerIndexCounter, SizeOf Object, pObjSpace ;Calc object
- .If (VectorRep == 0) ;First time loop
- mov ecx, INVENTORY_SIZE
- lea eax, [eax].Inventory1
- lea edx, pInventory1
- .elseif (VectorRep == 1) ;Second time loop
- mov ecx, INVENTORY_SIZE
- lea eax, [eax].Inventory2
- lea edx, pInventory2
- .elseif (VectorRep == 2) ;Third time loop
- mov ecx, TRADEINV_SIZE
- lea eax, [eax].InventoryTrade
- lea edx, pTempTradeInv
- .elseif (VectorRep == 3) ;Fourth time loop
- mov ecx, WAREHOUSE_SIZE
- lea eax, [eax].WareHouse
- lea edx, pTempWareHouse
- .else
- .endif
- push eax
- push edx
- Invoke V_VectorCreator, Edx, Offset V_CItem_Clear, SizeOf ItemStruct, ecx ;Create vector
- pop edx
- pop eax
- mov [eax], edx ;Save into player struct
- Add VectorRep, 1
- .Until (VectorRep == 4)
- Mov VectorRep, 0
- ;-------------------------------------------------
- ;Set into PlayerObject Struct
- ;*InventoryMap1, *InventoryMap2, *TradeMap
- ;------------------------------------------------------------------------------------------------------------------------
- pObj PlayerIndexCounter, SizeOf Object, pObjSpace ;Calc object
- .Repeat
- .If (VectorRep == 0)
- lea edx, pInventoryMap1
- Mov [Eax].InventoryMap1, Edx
- .Elseif (VectorRep == 1)
- lea edx, pInventoryMap2
- Mov [Eax].InventoryMap2, Edx
- .Elseif (VectorRep == 2)
- lea edx, pTempTradeMap
- mov [eax].TradeMap, edx
- .elseif (VectorRep == 3)
- lea edx, pTempWareHouseMap
- mov [eax].WareHouseMap, edx
- .else
- .EndIf
- Add VectorRep, 1
- .Until (VectorRep == 4)
- Mov VectorRep, 0 ;lets free again the counter
- ;;------------------------------------------------------------------------------------------------------------------------
- .Else
- ;//////////////////////////////////
- ;Mob ONLY code block !!
- ;THIS MUST BE SURE REMOVED
- ;IT HAVE NO REAL POTENTIAL
- ;//////////////////////////////////
- pObj PlayerIndexCounter, SizeOf Object, pObjSpace
- ; lea Edx, pTempInventory
- ; Mov [Eax].Inventory1, Edx
- ; Mov [Eax].Inventory2, Edx
- ; lea Edx, pTempInventoryMap
- ; Mov [Eax].InventoryMap1, Edx
- ; Mov [Eax].InventoryMap2, Edx
- Mov [Eax].WareHouseCount, 0
- Mov [Eax].ChaosBox, 0
- .EndIf
- Add PlayerIndexCounter, 1
- .Until (PlayerIndexCounter >= MAX_OBJ_ID) ;Repeat until MAX_OBJ_ID
- ;//////////////////////////////////
- ;END OF OBJ CREATION !
- ;//////////////////////////////////
- RGB 24, 116, 205
- Mov Edx, Eax
- Invoke vprint, $CTA0("ObjectInit:] All Objects are initialised, current ObjectStruct Size : [%d]"), Edx, 1, SizeOf Object
- Assume Eax:Nothing
- Ret
- V_Obj_Init EndP