V-ShopLoad.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...
- ;-----------------------------------------------------------------------------------
- ;////////////////////////////////////////////////////////////////////////////////////
- ; VALKYRIE PROJECT
- ; SHOP LOAD !
- ;////////////////////////////////////////////////////////////////////////////////////
- V_CShop_LoadShop Proto :Dword, :Dword
- V_CShop_SetItem Proto :Dword, :Dword, :Dword, :Dword, :Dword, :Dword, :Dword
- ;-----------------------------------------------------------------
- ; Structure that contain most of the item options
- ;-----------------------------------------------------------------
- .Const
- TotalShopsVariable equ 7
- .Data?
- .Data
- ;///////////////////////////////////////////////////////
- ;Dont changes the 0, 0 this is aligment
- ;so i can use a loop system for load them
- ;///////////////////////////////////////////////////////
- szAlignShop DB ".DataGamePlayShopsShopX.txt", 0, 0 ;ITS NOT A SHOP JUST A STRING FOR GET SIZEOF
- szShops DB ".DataGamePlayShopsShop0.txt", 0, 0
- DB ".DataGamePlayShopsShop1.txt", 0, 0
- DB ".DataGamePlayShopsShop2.txt", 0, 0
- DB ".DataGamePlayShopsShop3.txt", 0, 0
- DB ".DataGamePlayShopsShop4.txt", 0, 0
- DB ".DataGamePlayShopsShop5.txt", 0, 0
- DB ".DataGamePlayShopsShop6.txt", 0, 0
- DB ".DataGamePlayShopsShop7.txt", 0, 0
- DB ".DataGamePlayShopsShop8.txt", 0, 0
- DB ".DataGamePlayShopsShop9.txt", 0, 0
- DB ".DataGamePlayShopsShop10.txt", 0
- DB ".DataGamePlayShopsShop11.txt", 0
- DB ".DataGamePlayShopsShop12.txt", 0
- DB ".DataGamePlayShopsShop13.txt", 0
- DB ".DataGamePlayShopsShop14.txt", 0
- DB ".DataGamePlayShopsShop15.txt", 0
- DB ".DataGamePlayShopsShop16.txt", 0
- DB ".DataGamePlayShopsShop17.txt", 0
- DB ".DataGamePlayShopsShop18.txt", 0
- DB ".DataGamePlayShopsShop19.txt", 0
- DB ".DataGamePlayShopsShop20.txt", 0
- .Code
- V_Shop_LoadAll Proc
- local LoopCounter:Dword
- And LoopCounter, 0
- .Repeat
- lea edx, szShops
- mov eax, LoopCounter
- imul eax, eax, SizeOf szAlignShop
- add edx, eax
- invoke V_CShop_LoadShop, edx, LoopCounter
- add LoopCounter, 1
- .Until (LoopCounter == MAX_SHOPS)
- Ret
- V_Shop_LoadAll EndP
- V_CShop_LoadShop Proc AddrShop:Dword, ShopNumber:Dword
- local PlaceHolder[TotalShopsVariable]:Dword ;ItemType, ItemIndex, Level, Dur, Luck, Skill, JOL
- local MyStruct:Dword
- local LoopCounter:Dword
- local pBufferSpace:Dword
- local FilePosition:Dword
- local BytesReaded:Dword
- local StructFile:WIN32_FILE_ATTRIBUTE_DATA
- assume edx:ptr SHOP_STRUCT
- ;-------------------------------
- ;Clean locals
- ;-------------------------------
- And FilePosition, 0
- And LoopCounter, 0
- ;-------------------------------
- ;Load file into memory
- ;-------------------------------
- lea edx, StructFile
- GetFileLength AddrShop, edx
- mov eax, StructFile.nFileSizeLow
- fastalloc eax, 1 ;alloc space for file
- mov pBufferSpace, eax
- lea ecx, BytesReaded
- ReadThisFile AddrShop, 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
- ;-------------------------------
- ;Initialise Loop
- ;-------------------------------
- .While (ecx != -1)
- ;-------------------------------
- ;Load all variables
- ;-------------------------------
- lea eax, PlaceHolder
- xor ebx, ebx
- .Repeat
- push eax
- push ebx ;Save EBX
- invoke GetToken, pBufferSpace, ecx, NULL
- .If (edx == 1)
- xor eax, eax
- .Break
- .Endif
- mov FilePosition, ecx
- mov ecx, edx ;Avoid bugs
- mov edx, eax ;Avoid bugs
- pop ebx
- pop eax
- mov [eax + ebx], edx
- add ebx, 4
- add LoopCounter, 1
- mov ecx, FilePosition
- .Until (LoopCounter == TotalShopsVariable)
- mov LoopCounter, 0
- mov edx, ShopNumber
- lea eax, pObjShops
- imul edx, SizeOf SHOP_STRUCT
- add edx, eax
- mov MyStruct, edx
- mov eax, [edx].ItemCounter
- imul eax, eax, SizeOf ItemStruct
- add edx, eax
- mov FilePosition, ecx
- invoke V_CShop_SetItem, PlaceHolder, PlaceHolder + 4, PlaceHolder + 8, PlaceHolder + 0Ch, PlaceHolder + 10h,
- PlaceHolder + 14h, PlaceHolder + 18h
- .If (eax == 0)
- RGB 255, 64, 64 ;Red Collor
- Mov Edx, Eax
- Invoke vprint, $CTA0("CShopLoad:] ERROR ON [%s] WHILE LOADING ITEM [%d] [%d]"), Edx, 3, AddrShop, PlaceHolder, PlaceHolder + 4
- mov ecx, FilePosition
- .Continue
- .Endif
- mov edx, MyStruct
- add [edx].ItemCounter, 1
- .If ([edx].ItemCounter > MAX_SHOP_ITEMS)
- RGB 255, 64, 64 ;Red Collor
- Mov Edx, Eax
- Invoke vprint, $CTA0("CShopLoad:] ERROR ON [%s] CANT LOAD MORE ITEMS"), Edx, 1, AddrShop
- .Break
- .ElseIf ([edx].ItemCounter == MAX_SHOP_ITEMS)
- mov eax, 1
- .Break
- .Endif
- mov ecx, FilePosition
- invoke GetString, pBufferSpace, ecx ;Try to search for "end" string
- invoke szCmp, $CTA0("end"), Addr StringToken ;If end string
- .If (eax != 0) ;Founded
- mov eax, 1
- .Break
- .Endif
- mov ecx, FilePosition
- .Endw
- .If (eax == 0)
- RGB 255, 64, 64 ;Red Collor
- Mov Edx, Eax
- Invoke vprint, $CTA0("CShopLoad:] UNKNOWN ERROR, ON SHOP : [%s]"), Edx, 1, AddrShop
- .Else
- RGB 24, 116, 205 ;Light blue
- mov ecx, eax
- mov edx, MyStruct
- Invoke vprint, $CTA0("CShopLoad:] Operation Successful Shop [%s] loaded with [%d] Items"), Ecx, 2, AddrShop, [edx].ItemCounter
- add TotalShopsLoaded, 1
- .Endif
- FastDeAlloc pBufferSpace, NULL, 0 ;Free the heap when we dont use it anymore
- assume edx:NOTHING
- Ret
- V_CShop_LoadShop EndP