V-LogSystem.asm
资源名称:VeMU.rar [点击查看]
上传用户:santakups8
上传日期:2021-03-23
资源大小:544k
文件大小:9k
源码类别:
模拟服务器
开发平台:
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 Noob22||
- ; -------------------
- ; Programming Langs: C++ & ASM
- ; Country: Brazil
- ;------------------------------------------------------------------------------------
- LOG_SYSTEM_INFO Struct
- Number DWord ?
- Color DWord ?
- TextSize DWord ?
- TextBuff CHAR MAXPRINTCHAR Dup (?)
- LOG_SYSTEM_INFO EndS
- .Const
- WM_LOG_PAINT equ 666 ;- > Unique ID
- MAXLOGTABLE Equ 4 ;Edit here for more support
- .Data
- LogPrintEnableTable DB MAXLOGTABLE Dup (?)
- LogDirectoryTable DD MAXLOGTABLE Dup (?)
- LogDirectory1 DB ".ALL_LOGSLOG", 0
- LogDirectory2 DB ".ALL_LOGSMAP_LOG", 0
- LogDirectory3 DB ".ALL_LOGSMONSTER_LOG", 0
- LogDirectory4 DB ".ALL_LOGSITEM_LOG", 0
- .Code
- V_LogSystem_Init Proc
- ;---------------------------------------------------------------------------------------------
- ; Set which log type is going to be printed on screen
- ;---------------------------------------------------------------------------------------------
- Mov Byte Ptr [LogPrintEnableTable + 0], 1
- Mov Byte Ptr [LogPrintEnableTable + 1], 1
- Mov Byte Ptr [LogPrintEnableTable + 2], 1
- Mov Byte Ptr [LogPrintEnableTable + 3], 1
- ;---------------------------------------------------------------------------------------------
- ; Set Directory Table Info
- ;---------------------------------------------------------------------------------------------
- Mov DWord Ptr [LogDirectoryTable + 0], Offset LogDirectory1
- Mov DWord Ptr [LogDirectoryTable + 4], Offset LogDirectory2
- Mov DWord Ptr [LogDirectoryTable + 8], Offset LogDirectory3
- Mov DWord Ptr [LogDirectoryTable + 12], Offset LogDirectory4
- ;---------------------------------------------------------------------------------------------
- ; Create Directory's
- ;---------------------------------------------------------------------------------------------
- Invoke CreateDirectory, Addr LogDirectory1, 0
- Invoke CreateDirectory, Addr LogDirectory2, 0
- Invoke CreateDirectory, Addr LogDirectory3, 0
- Invoke CreateDirectory, Addr LogDirectory4, 0
- Ret
- V_LogSystem_Init EndP
- V_LogSystem_Output Proc C Number:DWord, Color:DWord, Text:DWord, Args:VarArg
- Local TextBuff[MAXPRINTCHAR]:CHAR
- Local TempBuff[MAXPRINTCHAR]:CHAR
- Local TextSize:DWord
- Local pAddr:DWord
- Local Time:SYSTEMTIME
- ;---------------------------------------------------------------------------------------------
- ; Zero Buff memory and get time info
- ;---------------------------------------------------------------------------------------------
- Invoke V_ZeroBuff, Addr TextBuff, SizeOf TextBuff
- Invoke V_ZeroBuff, Addr TempBuff, SizeOf TempBuff
- Invoke GetLocalTime, Addr Time
- ;---------------------------------------------------------------------------------------------
- ; Call wsprintf and set time information on text
- ;---------------------------------------------------------------------------------------------
- Invoke wsprintf, Addr TempBuff, $CTA0("%02d:%02d:%02d %sn"), Word Ptr Time.wHour, Word Ptr Time.wMinute, Word Ptr Time.wSecond, Text
- Mov Eax, Args
- .If (Eax != 0)
- Lea Ecx, Args
- .Repeat
- Push DWord Ptr [Ecx + Eax * 4]
- Sub Eax, 1
- .Until (Eax == 0)
- .EndIf
- Invoke wsprintf, Addr TextBuff, Addr TempBuff
- ;---------------------------------------------------------------------------------------------
- ; Get TextBuff string size
- ;---------------------------------------------------------------------------------------------
- Invoke lstrlen, Addr TextBuff
- Add Eax, 1
- Mov TextSize, Eax
- ;---------------------------------------------------------------------------------------------
- ; Alloc Memory for LOG_SYSTEM_INFO
- ;---------------------------------------------------------------------------------------------
- Mov Eax, MAXPRINTCHAR
- Sub Eax, TextSize
- Mov Ecx, SizeOf LOG_SYSTEM_INFO
- Sub Ecx, Eax
- fastalloc ecx, 1
- .If (Eax == 0)
- Jmp @PROC_END
- .EndIf
- Mov pAddr, Eax
- ;---------------------------------------------------------------------------------------------
- ; Alloc struct info
- ;---------------------------------------------------------------------------------------------
- Assume Eax:Ptr LOG_SYSTEM_INFO
- Mov Ecx, Number
- Mov [Eax].Number, Ecx
- Mov Ecx, Color
- Mov [Eax].Color, Ecx
- Mov Ecx, TextSize
- Mov [Eax].TextSize, Ecx
- Lea Esi, TextBuff
- Lea Edi, [Eax].TextBuff
- Rep Movsb
- ;---------------------------------------------------------------------------------------------
- ; Put a message on main window queue
- ;---------------------------------------------------------------------------------------------
- Invoke PostMessage, GShWnd, WM_LOG_PAINT, pAddr, 0
- @PROC_END:
- Ret
- V_LogSystem_Output EndP
- V_LogSystem_Print Proc pAddr:DWord
- Local Time:SYSTEMTIME
- Local File:HANDLE
- Local OutSize:DWord
- Local PathBuff[32]:Byte
- ;---------------------------------------------------------------------------------------------
- ; Check if addr is valid
- ;---------------------------------------------------------------------------------------------
- Mov Ecx, pAddr
- .If (Ecx == 0)
- Jmp @PROC_END3
- .EndIf
- Assume Ecx:Ptr LOG_SYSTEM_INFO
- ;---------------------------------------------------------------------------------------------
- ; Check if log number is correct
- ;---------------------------------------------------------------------------------------------
- .If ([Ecx].Number >= MAXLOGTABLE) ;It start from 0 to 4 thats why if == 4 then invalid
- Jmp @PROC_END2
- .EndIf
- ;---------------------------------------------------------------------------------------------
- ; Check if we want to print info on screen
- ;---------------------------------------------------------------------------------------------
- Mov Eax, [Ecx].Number
- Movzx Edx, Byte Ptr [LogPrintEnableTable + Eax]
- .If (Edx != 0)
- lea eax, [ecx].TextBuff
- mov edx, [ecx].TextSize
- add eax, edx
- mov word ptr [eax - 3], 0 ;Clean /n character at the end of text
- push eax
- Invoke vprint, Addr [Ecx].TextBuff, [Ecx].Color, 0
- pop eax
- mov word ptr [eax - 3], 0A0Dh ;Return the /n character
- .EndIf
- ;---------------------------------------------------------------------------------------------
- ; Zero Buff and Get Time Info
- ;---------------------------------------------------------------------------------------------
- Invoke V_ZeroBuff, Addr PathBuff, SizeOf PathBuff
- Invoke GetLocalTime, Addr Time
- ;---------------------------------------------------------------------------------------------
- ; Make file name with data stuff
- ;---------------------------------------------------------------------------------------------
- Mov Ecx, pAddr
- Mov Eax, [Ecx].Number
- Mov Edx, DWord Ptr [LogDirectoryTable + Eax * 4]
- Invoke wsprintf, Addr PathBuff, $CTA0("%s\%02d-%02d-%04d.txt"), Edx, Word Ptr Time.wDay, Word Ptr Time.wMonth, Word Ptr Time.wYear
- ;---------------------------------------------------------------------------------------------
- ; Write info on buff, Yey!
- ;---------------------------------------------------------------------------------------------
- Invoke CreateFile, Addr PathBuff, GENERIC_WRITE, 0, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0
- .If (Eax == 0)
- Jmp @PROC_END2
- .EndIf
- Mov File, Eax
- Invoke SetFilePointer, File, 0, 0, FILE_END
- .If (Eax == INVALID_SET_FILE_POINTER)
- Jmp @PROC_END1
- .EndIf
- Mov Ecx, pAddr
- Mov Edx, [Ecx].TextSize
- Sub Edx, 1
- Invoke WriteFile, File, Addr [Ecx].TextBuff, Edx, Addr OutSize, 0
- ;---------------------------------------------------------------------------------------------
- ; Free allocated memory, of course
- ;---------------------------------------------------------------------------------------------
- @PROC_END1:
- Invoke CloseHandle, File
- @PROC_END2:
- Invoke GetProcessHeap
- Invoke HeapFree, Eax, HEAP_NO_SERIALIZE, pAddr
- @PROC_END3:
- Ret
- V_LogSystem_Print EndP