V-MobItemMngLoad.asm
资源名称:VeMU.rar [点击查看]
上传用户:santakups8
上传日期:2021-03-23
资源大小:544k
文件大小:7k
源码类别:
模拟服务器
开发平台:
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...
- ;-----------------------------------------------------------------------------------
- MONSTER_ITEM_MANAGER_FILE Struct
- ItemCounter Byte ?
- ItemType Byte ?
- ItemIndex Byte ?
- DevilSquare Byte ?
- BloodCastle Byte ?
- ChaosCastle Byte ?
- MONSTER_ITEM_MANAGER_FILE EndS
- .const
- TOTAL_EVENTS_SUPPORTED equ 3
- .data?
- pObjMobItemMngFile DD ?
- .data
- szMonsterItemMng DB ".DataGamePlayMonstersMobItemManager.txt", 0
- TotalItemsMobMng DD ?
- .code
- V_MonsterItemMng_Load Proc
- local ItemAddeds:Dword
- local SeparatorFounded:Dword
- local pThisObj:Dword
- local LoopCounter:Dword
- local FilePosition:Dword
- local pBufferSpace:Dword
- local BytesReaded:Dword
- local StructFile:WIN32_FILE_ATTRIBUTE_DATA
- assume edx:ptr MONSTER_ITEM_MANAGER_FILE
- ;------------------------------------------------
- ; Clean local variables that are needed
- ;------------------------------------------------
- And SeparatorFounded, 0
- And LoopCounter, 0
- And ItemAddeds, 0
- ;------------------------------------------------
- ; Initialise space for hold data
- ;------------------------------------------------
- mov eax, TotalItemsLoaded
- imul eax, eax, SizeOf MONSTER_ITEM_MANAGER_FILE
- fastalloc eax, 2 ;Alloc space = Total items loaded (item.txt)*Size of MONSTER_ITEM_MANAGER_FILE
- .If (eax == 0)
- RGB 255, 64, 64 ;Red Collor
- Mov Edx, Eax
- Invoke vprint, $CTA0("MobItemMng:] ERROR IN ALLOCATING SPACE, PLEASE RESTART VeMU"), Edx, 0
- .Endif
- mov pObjMobItemMngFile, eax
- mov pThisObj, eax
- ;-------------------------------
- ;Load file into memory
- ;-------------------------------
- lea edx, StructFile
- GetFileLength addr szMonsterItemMng, edx
- mov eax, StructFile.nFileSizeLow
- fastalloc eax, 1 ;alloc space for file
- mov pBufferSpace, eax
- lea edx, StructFile
- lea ecx, BytesReaded
- ReadThisFile Addr szMonsterItemMng, pBufferSpace, ecx ;read of file and handles the close
- mov ecx, StructFile.nFileSizeLow
- add eax, ecx
- mov dword ptr [eax], 0 ;Append to 00 byte in the end of file for prevent bugs
- xor ecx, ecx
- .While (ecx != -1)
- mov ebx, 1 ;Avoid rewrite ItemCounter
- mov edx, pThisObj
- mov ItemAddeds, 0
- ;---------------------------------------------------------------------
- ;Take all the item types and index variables till the separator
- ;---------------------------------------------------------------------
- .Repeat
- push ebx
- invoke GetToken, pBufferSpace, ecx, NULL
- pop ebx
- .If (edx == 1)
- xor eax, eax
- .Break
- .Endif
- mov FilePosition, ecx
- mov edx, pThisObj
- mov [edx + ebx], Al ;Save ItemType or ItemIndex depending of the loop time
- add ebx, 1
- mov eax, LoopCounter
- and eax, 1 ;If its a unpair number then its exponencial (beatifull) (unpair caused we start from the 0 and add the +1 after this check)
- .If (eax == 1) ;If unpair number
- add [edx].ItemCounter, 1
- add ItemAddeds, 1 ;Each 2 reads i assume its a full item readed
- .Endif
- add LoopCounter, 1
- push ebx ;Counter for writte
- invoke GetString, pBufferSpace, ecx ;Search for string "Events" separator
- push ecx
- invoke szCmp, $CTA0("Events"), Addr StringToken
- pop ecx
- pop ebx ;Return counter for writte
- .if (eax != 0)
- mov SeparatorFounded, 1
- .else
- mov ecx, FilePosition ;make like nothing has happen (restoring file position before trying to read the string)
- .endif
- .Until (SeparatorFounded == 1)
- mov LoopCounter, 0
- mov SeparatorFounded, 0
- ;---------------------------------------------------------------------
- ;Take the events variable
- ;---------------------------------------------------------------------
- .Repeat
- push ebx
- invoke GetToken, pBufferSpace, ecx, NULL
- pop ebx
- .If (edx == 1)
- xor eax, eax
- .Break
- .Endif
- mov edx, pThisObj
- mov [edx + ebx], Al ;Save variable for all event supporteds (DS, CC, BC)
- add ebx, 1
- Add LoopCounter, 1
- .Until (LoopCounter == TOTAL_EVENTS_SUPPORTED)
- add edx, ebx
- mov pThisObj, edx
- mov FilePosition, ecx
- mov LoopCounter, 0
- ;---------------------------------------------------------------------
- ;Check limits !
- ;---------------------------------------------------------------------
- mov edx, ItemAddeds
- add TotalItemsMobMng, edx
- mov ItemAddeds, 0
- mov eax, TotalItemsLoaded
- .if (TotalItemsMobMng > eax)
- RGB 255, 64, 64 ;Red Collor
- Mov Edx, Eax
- Invoke vprint, $CTA0("MobItemMng:] ERROR YOU CANT BLOCK MORE THAN : [%d] ITEMS"), Edx, 1, TotalItemsLoaded
- mov eax, 1
- .Break
- .endif
- invoke GetString, pBufferSpace, ecx ;Search for string "End"
- push ecx
- invoke szCmp, $CTA0("end"), Addr StringToken
- pop ecx
- .if (eax != 0)
- push ecx
- invoke GetToken, pBufferSpace, ecx, NULL ;Lets check if its really the end of file
- pop ecx
- .if (edx == 1)
- mov eax, 1
- .Break
- .endif
- xor ebx, ebx
- .Continue ;Loop Back
- .endif
- xor ebx, ebx
- mov ecx, FilePosition
- .Endw
- .If (eax == 0)
- RGB 255, 64, 64 ;Red Collor
- Mov Edx, Eax
- Invoke vprint, $CTA0("MobItemMng:] UNKNOWN ERROR, LAST ITEM LOADED : [%d]"), Edx, 1, TotalItemsMobMng
- .Else
- RGB 24, 116, 205 ;Light blue
- Mov Edx, Eax
- Invoke vprint, $CTA0("MobItemMng:] Operation Successful total items blocked : [%d]"), Edx, 1, TotalItemsMobMng
- .Endif
- FastDeAlloc pBufferSpace, NULL, 0 ;Free the heap when we dont use it anymore
- ret
- V_MonsterItemMng_Load EndP