* setting eol style to native
This commit is contained in:
parent
a8ad601dca
commit
44739d3952
192
PseuWoW.sln
192
PseuWoW.sln
@ -1,96 +1,96 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 8.00
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PseuWoW", "src\PseuWoW.vcproj", "{EFFE60F4-DA39-41E8-9E53-E462000A2D91}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270} = {F548FC51-24A4-45FF-A381-BEBC39F18270}
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480} = {262199E8-EEDF-4700-A1D1-E9CC901CF480}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "src\zlib.vcproj", "{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zthread", "src\zthread.vcproj", "{262199E8-EEDF-4700-A1D1-E9CC901CF480}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shared", "src\shared.vcproj", "{F548FC51-24A4-45FF-A381-BEBC39F18270}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480} = {262199E8-EEDF-4700-A1D1-E9CC901CF480}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Irrlicht", "src\dep\src\irrlicht\Irrlicht7.1.vcproj", "{E08E042A-6C45-411B-92BE-3CC31331019F}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StuffExtract", "src\tools\stuffextract.vcproj", "{EFFE60F4-DA39-41E8-9E53-E462000A2D91}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270} = {F548FC51-24A4-45FF-A381-BEBC39F18270}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
Debug = Debug
|
||||
Relase - Fast FPU = Relase - Fast FPU
|
||||
Release = Release
|
||||
Release - Fast FPU DebugInfo = Release - Fast FPU DebugInfo
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfiguration) = postSolution
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Debug.ActiveCfg = Debug|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Debug.Build.0 = Debug|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Relase - Fast FPU.ActiveCfg = Release|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Relase - Fast FPU.Build.0 = Release|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release.ActiveCfg = Release|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release.Build.0 = Release|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU DebugInfo.ActiveCfg = Release|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU DebugInfo.Build.0 = Release|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug.ActiveCfg = Debug|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug.Build.0 = Debug|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Relase - Fast FPU.ActiveCfg = Release|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Relase - Fast FPU.Build.0 = Release|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release.ActiveCfg = Release|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release.Build.0 = Release|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release - Fast FPU DebugInfo.ActiveCfg = Release|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release - Fast FPU DebugInfo.Build.0 = Release|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Debug.ActiveCfg = Debug|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Debug.Build.0 = Debug|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Relase - Fast FPU.ActiveCfg = Release|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Relase - Fast FPU.Build.0 = Release|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release.ActiveCfg = Release|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release.Build.0 = Release|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release - Fast FPU DebugInfo.ActiveCfg = Release|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release - Fast FPU DebugInfo.Build.0 = Release|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Debug.ActiveCfg = Debug|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Debug.Build.0 = Debug|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Relase - Fast FPU.ActiveCfg = Release|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Relase - Fast FPU.Build.0 = Release|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Release.ActiveCfg = Release|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Release.Build.0 = Release|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Release - Fast FPU DebugInfo.ActiveCfg = Release|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Release - Fast FPU DebugInfo.Build.0 = Release|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Debug.ActiveCfg = Debug|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Debug.Build.0 = Debug|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Relase - Fast FPU.ActiveCfg = Relase - Fast FPU|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Relase - Fast FPU.Build.0 = Relase - Fast FPU|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release.ActiveCfg = Release|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release.Build.0 = Release|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU DebugInfo.ActiveCfg = Release - Fast FPU DebugInfo|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU DebugInfo.Build.0 = Release - Fast FPU DebugInfo|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Debug.ActiveCfg = Debug|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Debug.Build.0 = Debug|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Relase - Fast FPU.ActiveCfg = Release|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Relase - Fast FPU.Build.0 = Release|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release.ActiveCfg = Release|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release.Build.0 = Release|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU DebugInfo.ActiveCfg = Release|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU DebugInfo.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
Microsoft Visual Studio Solution File, Format Version 8.00
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PseuWoW", "src\PseuWoW.vcproj", "{EFFE60F4-DA39-41E8-9E53-E462000A2D91}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270} = {F548FC51-24A4-45FF-A381-BEBC39F18270}
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480} = {262199E8-EEDF-4700-A1D1-E9CC901CF480}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "src\zlib.vcproj", "{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zthread", "src\zthread.vcproj", "{262199E8-EEDF-4700-A1D1-E9CC901CF480}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shared", "src\shared.vcproj", "{F548FC51-24A4-45FF-A381-BEBC39F18270}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480} = {262199E8-EEDF-4700-A1D1-E9CC901CF480}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Irrlicht", "src\dep\src\irrlicht\Irrlicht7.1.vcproj", "{E08E042A-6C45-411B-92BE-3CC31331019F}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StuffExtract", "src\tools\stuffextract.vcproj", "{EFFE60F4-DA39-41E8-9E53-E462000A2D91}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270} = {F548FC51-24A4-45FF-A381-BEBC39F18270}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfiguration) = preSolution
|
||||
Debug = Debug
|
||||
Relase - Fast FPU = Relase - Fast FPU
|
||||
Release = Release
|
||||
Release - Fast FPU DebugInfo = Release - Fast FPU DebugInfo
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfiguration) = postSolution
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Debug.ActiveCfg = Debug|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Debug.Build.0 = Debug|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Relase - Fast FPU.ActiveCfg = Release|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Relase - Fast FPU.Build.0 = Release|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release.ActiveCfg = Release|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release.Build.0 = Release|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU DebugInfo.ActiveCfg = Release|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU DebugInfo.Build.0 = Release|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug.ActiveCfg = Debug|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug.Build.0 = Debug|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Relase - Fast FPU.ActiveCfg = Release|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Relase - Fast FPU.Build.0 = Release|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release.ActiveCfg = Release|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release.Build.0 = Release|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release - Fast FPU DebugInfo.ActiveCfg = Release|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release - Fast FPU DebugInfo.Build.0 = Release|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Debug.ActiveCfg = Debug|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Debug.Build.0 = Debug|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Relase - Fast FPU.ActiveCfg = Release|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Relase - Fast FPU.Build.0 = Release|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release.ActiveCfg = Release|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release.Build.0 = Release|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release - Fast FPU DebugInfo.ActiveCfg = Release|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release - Fast FPU DebugInfo.Build.0 = Release|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Debug.ActiveCfg = Debug|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Debug.Build.0 = Debug|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Relase - Fast FPU.ActiveCfg = Release|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Relase - Fast FPU.Build.0 = Release|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Release.ActiveCfg = Release|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Release.Build.0 = Release|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Release - Fast FPU DebugInfo.ActiveCfg = Release|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Release - Fast FPU DebugInfo.Build.0 = Release|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Debug.ActiveCfg = Debug|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Debug.Build.0 = Debug|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Relase - Fast FPU.ActiveCfg = Relase - Fast FPU|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Relase - Fast FPU.Build.0 = Relase - Fast FPU|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release.ActiveCfg = Release|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release.Build.0 = Release|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU DebugInfo.ActiveCfg = Release - Fast FPU DebugInfo|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU DebugInfo.Build.0 = Release - Fast FPU DebugInfo|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Debug.ActiveCfg = Debug|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Debug.Build.0 = Debug|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Relase - Fast FPU.ActiveCfg = Release|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Relase - Fast FPU.Build.0 = Release|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release.ActiveCfg = Release|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release.Build.0 = Release|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU DebugInfo.ActiveCfg = Release|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU DebugInfo.Build.0 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
176
PseuWoW_VC80.sln
176
PseuWoW_VC80.sln
@ -1,88 +1,88 @@
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
# Visual Studio 2005
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PseuWoW_VC80", "src\PseuWoW_VC80.vcproj", "{EFFE60F4-DA39-41E8-9E53-E462000A2D91}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270} = {F548FC51-24A4-45FF-A381-BEBC39F18270}
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480} = {262199E8-EEDF-4700-A1D1-E9CC901CF480}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "src\zlib_VC80.vcproj", "{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zthread", "src\zthread_VC80.vcproj", "{262199E8-EEDF-4700-A1D1-E9CC901CF480}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shared", "src\shared_VC80.vcproj", "{F548FC51-24A4-45FF-A381-BEBC39F18270}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480} = {262199E8-EEDF-4700-A1D1-E9CC901CF480}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Irrlicht", "src\dep\src\irrlicht\Irrlicht8.0.vcproj", "{E08E042A-6C45-411B-92BE-3CC31331019F}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StuffExtract", "src\tools\stuffextract_VC80.vcproj", "{FBBE6172-CCDE-4ADD-94A6-55C91D700DB6}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270} = {F548FC51-24A4-45FF-A381-BEBC39F18270}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Relase - Fast FPU|Win32 = Relase - Fast FPU|Win32
|
||||
Release - Fast FPU DebugInfo|Win32 = Release - Fast FPU DebugInfo|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Relase - Fast FPU|Win32.ActiveCfg = Release|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Relase - Fast FPU|Win32.Build.0 = Release|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU DebugInfo|Win32.ActiveCfg = Release|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU DebugInfo|Win32.Build.0 = Release|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release|Win32.Build.0 = Release|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Relase - Fast FPU|Win32.ActiveCfg = Release|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Relase - Fast FPU|Win32.Build.0 = Release|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release - Fast FPU DebugInfo|Win32.ActiveCfg = Release|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release - Fast FPU DebugInfo|Win32.Build.0 = Release|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release|Win32.Build.0 = Release|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Relase - Fast FPU|Win32.ActiveCfg = Release|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Relase - Fast FPU|Win32.Build.0 = Release|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release - Fast FPU DebugInfo|Win32.ActiveCfg = Release|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release - Fast FPU DebugInfo|Win32.Build.0 = Release|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release|Win32.Build.0 = Release|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Relase - Fast FPU|Win32.ActiveCfg = Release|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Relase - Fast FPU|Win32.Build.0 = Release|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Release - Fast FPU DebugInfo|Win32.ActiveCfg = Release|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Release - Fast FPU DebugInfo|Win32.Build.0 = Release|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Release|Win32.Build.0 = Release|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Relase - Fast FPU|Win32.ActiveCfg = Relase - Fast FPU|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Relase - Fast FPU|Win32.Build.0 = Relase - Fast FPU|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU DebugInfo|Win32.ActiveCfg = Release - Fast FPU DebugInfo|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU DebugInfo|Win32.Build.0 = Release - Fast FPU DebugInfo|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release|Win32.Build.0 = Release|Win32
|
||||
{FBBE6172-CCDE-4ADD-94A6-55C91D700DB6}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{FBBE6172-CCDE-4ADD-94A6-55C91D700DB6}.Relase - Fast FPU|Win32.ActiveCfg = Release|Win32
|
||||
{FBBE6172-CCDE-4ADD-94A6-55C91D700DB6}.Release - Fast FPU DebugInfo|Win32.ActiveCfg = Release|Win32
|
||||
{FBBE6172-CCDE-4ADD-94A6-55C91D700DB6}.Release|Win32.ActiveCfg = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||
# Visual Studio 2005
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PseuWoW_VC80", "src\PseuWoW_VC80.vcproj", "{EFFE60F4-DA39-41E8-9E53-E462000A2D91}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F} = {E08E042A-6C45-411B-92BE-3CC31331019F}
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270} = {F548FC51-24A4-45FF-A381-BEBC39F18270}
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480} = {262199E8-EEDF-4700-A1D1-E9CC901CF480}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zlib", "src\zlib_VC80.vcproj", "{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zthread", "src\zthread_VC80.vcproj", "{262199E8-EEDF-4700-A1D1-E9CC901CF480}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "shared", "src\shared_VC80.vcproj", "{F548FC51-24A4-45FF-A381-BEBC39F18270}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480} = {262199E8-EEDF-4700-A1D1-E9CC901CF480}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Irrlicht", "src\dep\src\irrlicht\Irrlicht8.0.vcproj", "{E08E042A-6C45-411B-92BE-3CC31331019F}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "StuffExtract", "src\tools\stuffextract_VC80.vcproj", "{FBBE6172-CCDE-4ADD-94A6-55C91D700DB6}"
|
||||
ProjectSection(ProjectDependencies) = postProject
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2} = {8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270} = {F548FC51-24A4-45FF-A381-BEBC39F18270}
|
||||
EndProjectSection
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Relase - Fast FPU|Win32 = Relase - Fast FPU|Win32
|
||||
Release - Fast FPU DebugInfo|Win32 = Release - Fast FPU DebugInfo|Win32
|
||||
Release|Win32 = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Relase - Fast FPU|Win32.ActiveCfg = Release|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Relase - Fast FPU|Win32.Build.0 = Release|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU DebugInfo|Win32.ActiveCfg = Release|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release - Fast FPU DebugInfo|Win32.Build.0 = Release|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{EFFE60F4-DA39-41E8-9E53-E462000A2D91}.Release|Win32.Build.0 = Release|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Relase - Fast FPU|Win32.ActiveCfg = Release|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Relase - Fast FPU|Win32.Build.0 = Release|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release - Fast FPU DebugInfo|Win32.ActiveCfg = Release|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release - Fast FPU DebugInfo|Win32.Build.0 = Release|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{8F1DEA42-6A5B-4B62-839D-C141A7BFACF2}.Release|Win32.Build.0 = Release|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Relase - Fast FPU|Win32.ActiveCfg = Release|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Relase - Fast FPU|Win32.Build.0 = Release|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release - Fast FPU DebugInfo|Win32.ActiveCfg = Release|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release - Fast FPU DebugInfo|Win32.Build.0 = Release|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{262199E8-EEDF-4700-A1D1-E9CC901CF480}.Release|Win32.Build.0 = Release|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Relase - Fast FPU|Win32.ActiveCfg = Release|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Relase - Fast FPU|Win32.Build.0 = Release|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Release - Fast FPU DebugInfo|Win32.ActiveCfg = Release|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Release - Fast FPU DebugInfo|Win32.Build.0 = Release|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{F548FC51-24A4-45FF-A381-BEBC39F18270}.Release|Win32.Build.0 = Release|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Relase - Fast FPU|Win32.ActiveCfg = Relase - Fast FPU|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Relase - Fast FPU|Win32.Build.0 = Relase - Fast FPU|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU DebugInfo|Win32.ActiveCfg = Release - Fast FPU DebugInfo|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release - Fast FPU DebugInfo|Win32.Build.0 = Release - Fast FPU DebugInfo|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{E08E042A-6C45-411B-92BE-3CC31331019F}.Release|Win32.Build.0 = Release|Win32
|
||||
{FBBE6172-CCDE-4ADD-94A6-55C91D700DB6}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{FBBE6172-CCDE-4ADD-94A6-55C91D700DB6}.Relase - Fast FPU|Win32.ActiveCfg = Release|Win32
|
||||
{FBBE6172-CCDE-4ADD-94A6-55C91D700DB6}.Release - Fast FPU DebugInfo|Win32.ActiveCfg = Release|Win32
|
||||
{FBBE6172-CCDE-4ADD-94A6-55C91D700DB6}.Release|Win32.ActiveCfg = Release|Win32
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
||||
102
bin/_startup.def
102
bin/_startup.def
@ -1,51 +1,51 @@
|
||||
// PSEUWOW DEF_SCRIPT STARTUP FILE
|
||||
|
||||
// this is for debugging which scripts are loaded
|
||||
// set to false to disable output
|
||||
SET,LoadDebug true
|
||||
|
||||
LOG *** DefScript StartUp [${@version_short}]...
|
||||
|
||||
// first, load all scripts in path 'scripts' with extension .def
|
||||
SET,fcount ?{LGETFILES,scriptlist,def scripts}
|
||||
LSORT scriptlist
|
||||
LOG *** Loading ${fcount} script files.
|
||||
// iterate over all files and load them; if counter i is equal to the amount of files we are done.
|
||||
SET,i 0
|
||||
SET,errors 0
|
||||
LOOP
|
||||
IF ?{EQUAL,${i} ${fcount}}
|
||||
EXITLOOP
|
||||
ENDIF
|
||||
SET,fn ./scripts/?{LINDEX,scriptlist ${i}}
|
||||
IF ?{AND,?{IsSet LoadDebug} ${LoadDebug}}
|
||||
LOG * Loading script file [${fn}]
|
||||
ENDIF
|
||||
IF ?{NOT ?{LOADDEF ${fn}}}
|
||||
LOGERROR * Error loading [${fn}]
|
||||
ADD,errors 1
|
||||
ENDIF
|
||||
ADD,i 1
|
||||
ENDLOOP
|
||||
|
||||
UNSET tmp
|
||||
UNSET fcount
|
||||
UNSET i
|
||||
UNSET fn
|
||||
LDELETE scriptlist
|
||||
|
||||
IF ?{NOT ${errors}}
|
||||
LOG *** All files loaded without errors.
|
||||
ELSE
|
||||
LOG *** All files loaded, ${errors} errors.
|
||||
ENDIF
|
||||
UNSET errors
|
||||
|
||||
// Load some SCP files
|
||||
LOADALLSCP
|
||||
|
||||
// do more stuff here in future...
|
||||
|
||||
LOG * StartUp complete!
|
||||
|
||||
|
||||
// PSEUWOW DEF_SCRIPT STARTUP FILE
|
||||
|
||||
// this is for debugging which scripts are loaded
|
||||
// set to false to disable output
|
||||
SET,LoadDebug true
|
||||
|
||||
LOG *** DefScript StartUp [${@version_short}]...
|
||||
|
||||
// first, load all scripts in path 'scripts' with extension .def
|
||||
SET,fcount ?{LGETFILES,scriptlist,def scripts}
|
||||
LSORT scriptlist
|
||||
LOG *** Loading ${fcount} script files.
|
||||
// iterate over all files and load them; if counter i is equal to the amount of files we are done.
|
||||
SET,i 0
|
||||
SET,errors 0
|
||||
LOOP
|
||||
IF ?{EQUAL,${i} ${fcount}}
|
||||
EXITLOOP
|
||||
ENDIF
|
||||
SET,fn ./scripts/?{LINDEX,scriptlist ${i}}
|
||||
IF ?{AND,?{IsSet LoadDebug} ${LoadDebug}}
|
||||
LOG * Loading script file [${fn}]
|
||||
ENDIF
|
||||
IF ?{NOT ?{LOADDEF ${fn}}}
|
||||
LOGERROR * Error loading [${fn}]
|
||||
ADD,errors 1
|
||||
ENDIF
|
||||
ADD,i 1
|
||||
ENDLOOP
|
||||
|
||||
UNSET tmp
|
||||
UNSET fcount
|
||||
UNSET i
|
||||
UNSET fn
|
||||
LDELETE scriptlist
|
||||
|
||||
IF ?{NOT ${errors}}
|
||||
LOG *** All files loaded without errors.
|
||||
ELSE
|
||||
LOG *** All files loaded, ${errors} errors.
|
||||
ENDIF
|
||||
UNSET errors
|
||||
|
||||
// Load some SCP files
|
||||
LOADALLSCP
|
||||
|
||||
// do more stuff here in future...
|
||||
|
||||
LOG * StartUp complete!
|
||||
|
||||
|
||||
|
||||
@ -1,125 +1,125 @@
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// PseuWoW config file
|
||||
//
|
||||
// still under development :D
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// use // for comments (C++ style)
|
||||
|
||||
// its important to read & store the main conf variables UPPERCASED!!
|
||||
[#uppercase]
|
||||
[#noprefix]
|
||||
|
||||
// 3=max, 0=no debug output
|
||||
debug=0
|
||||
|
||||
// defines if the program should quit on error/exception or stay opened (for debugging)
|
||||
exitonerror=0
|
||||
|
||||
// reconnect on failure/disconnect
|
||||
// 0 = dont't reconnect
|
||||
// everything else: delay (in ms) until the next connection attempt.
|
||||
// default: 5000 ms (5 secs)
|
||||
reconnect=5000
|
||||
|
||||
// 0 - show none
|
||||
// 1 - show only known/handled
|
||||
// 2 - show only unknown/unhandled
|
||||
// 3 - show all
|
||||
showopcodes=0
|
||||
|
||||
|
||||
// Hide opcodes which is coming very frequently?
|
||||
// Has only an effect if you have showopcodes > 0
|
||||
// 1 - yes
|
||||
// 0 - No
|
||||
hidefreqopcodes=1
|
||||
|
||||
// Hide disabled (= unhandled, but known) opcodes?
|
||||
// 1 - Yes
|
||||
// 0 - No
|
||||
HideDisabledOpcodes=0
|
||||
|
||||
// the IP or hostname the realm server is running on
|
||||
realmlist=localhost
|
||||
|
||||
// port on which the realm server is listening (default=3724)
|
||||
realmport=3724
|
||||
|
||||
// PseuWoW will login on this realm
|
||||
// Case sensitive!
|
||||
realmname=My WoW Realm
|
||||
|
||||
// your account name
|
||||
accname=test
|
||||
|
||||
// your account password
|
||||
accpass=test
|
||||
|
||||
// the character name PseuWoW should choose to enter the world.
|
||||
// case sensitive!
|
||||
charname=Pseuwow
|
||||
|
||||
|
||||
// Client emulation configuration
|
||||
ClientVersion=2.3.3
|
||||
ClientBuild=7799
|
||||
ClientLanguage=enUS
|
||||
// or change to enGB, deDE, ...
|
||||
|
||||
|
||||
// packets get fetched every xx msecs. default=50
|
||||
// setting this to 0 will let PseuWoW eat up all CPU power
|
||||
// 1 is a good setting for maximum network performance and lowest ping times
|
||||
NetworkSleepTime=1
|
||||
|
||||
// defines if players may say/yell/whisper commands to PseuWoW
|
||||
// set this to 0 and PseuWoW will not react to given commands
|
||||
allowgamecmd=1
|
||||
|
||||
// enable this if you plan to enter commands on the console
|
||||
enablecli=1
|
||||
|
||||
// enable's chat ai which makes you bot respond to simple senteces
|
||||
// like "Hi" and "What do you think of x" etc.
|
||||
enablechatai=1
|
||||
|
||||
// show ping responses
|
||||
notifyping=1
|
||||
|
||||
// shows the opcodes pseuwow sends to the server
|
||||
showmyopcodes=0
|
||||
|
||||
// disable the check for learned spells.
|
||||
// if you disable it, you can cast spells you do not have in your spellbook!
|
||||
// WARNING: most servers will consider this as CHEATING!
|
||||
// DO NOT put 1 here!
|
||||
disablespellcheck=0
|
||||
|
||||
// will be used for all sendchatmessage calls. remove number/leave blank
|
||||
// to use the default language for your race (defined in race.scp)
|
||||
defaultlang=0
|
||||
|
||||
// set this to 1 if you want to have a 3D-window showing stuff
|
||||
// NOTE: this is only to activate the window for now, 3D-stuff will come later!!
|
||||
// until some frame-limiter is implemented, it will always use 100% CPU usage when
|
||||
// the GUI is enabled and activated. (if its in background - way less CPU load.)
|
||||
enablegui=0
|
||||
|
||||
// options for remote control:
|
||||
// port beeing listened on. set to 0 do disable.
|
||||
rmcontrolport=8101
|
||||
// IP or hostname that is allowed to connect. leave blank to allow connections from everywhere (dangerous!)
|
||||
rmcontrolhost=localhost
|
||||
|
||||
// if you have exported and copied data from your original client,
|
||||
// set this to 1 to enable movement and everything map related.
|
||||
// PseuWoW will need more memory with maps enabled!
|
||||
useMaps=0
|
||||
|
||||
// Addon language is usually not shown by client
|
||||
// Since addons are far from beeing used in PseuWoW, we can completely ignore addon chat messages.
|
||||
// Sometimes they even cause problems, like make the console window beep...
|
||||
SkipAddonChat=1
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// PseuWoW config file
|
||||
//
|
||||
// still under development :D
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// use // for comments (C++ style)
|
||||
|
||||
// its important to read & store the main conf variables UPPERCASED!!
|
||||
[#uppercase]
|
||||
[#noprefix]
|
||||
|
||||
// 3=max, 0=no debug output
|
||||
debug=0
|
||||
|
||||
// defines if the program should quit on error/exception or stay opened (for debugging)
|
||||
exitonerror=0
|
||||
|
||||
// reconnect on failure/disconnect
|
||||
// 0 = dont't reconnect
|
||||
// everything else: delay (in ms) until the next connection attempt.
|
||||
// default: 5000 ms (5 secs)
|
||||
reconnect=5000
|
||||
|
||||
// 0 - show none
|
||||
// 1 - show only known/handled
|
||||
// 2 - show only unknown/unhandled
|
||||
// 3 - show all
|
||||
showopcodes=0
|
||||
|
||||
|
||||
// Hide opcodes which is coming very frequently?
|
||||
// Has only an effect if you have showopcodes > 0
|
||||
// 1 - yes
|
||||
// 0 - No
|
||||
hidefreqopcodes=1
|
||||
|
||||
// Hide disabled (= unhandled, but known) opcodes?
|
||||
// 1 - Yes
|
||||
// 0 - No
|
||||
HideDisabledOpcodes=0
|
||||
|
||||
// the IP or hostname the realm server is running on
|
||||
realmlist=localhost
|
||||
|
||||
// port on which the realm server is listening (default=3724)
|
||||
realmport=3724
|
||||
|
||||
// PseuWoW will login on this realm
|
||||
// Case sensitive!
|
||||
realmname=My WoW Realm
|
||||
|
||||
// your account name
|
||||
accname=test
|
||||
|
||||
// your account password
|
||||
accpass=test
|
||||
|
||||
// the character name PseuWoW should choose to enter the world.
|
||||
// case sensitive!
|
||||
charname=Pseuwow
|
||||
|
||||
|
||||
// Client emulation configuration
|
||||
ClientVersion=2.3.3
|
||||
ClientBuild=7799
|
||||
ClientLanguage=enUS
|
||||
// or change to enGB, deDE, ...
|
||||
|
||||
|
||||
// packets get fetched every xx msecs. default=50
|
||||
// setting this to 0 will let PseuWoW eat up all CPU power
|
||||
// 1 is a good setting for maximum network performance and lowest ping times
|
||||
NetworkSleepTime=1
|
||||
|
||||
// defines if players may say/yell/whisper commands to PseuWoW
|
||||
// set this to 0 and PseuWoW will not react to given commands
|
||||
allowgamecmd=1
|
||||
|
||||
// enable this if you plan to enter commands on the console
|
||||
enablecli=1
|
||||
|
||||
// enable's chat ai which makes you bot respond to simple senteces
|
||||
// like "Hi" and "What do you think of x" etc.
|
||||
enablechatai=1
|
||||
|
||||
// show ping responses
|
||||
notifyping=1
|
||||
|
||||
// shows the opcodes pseuwow sends to the server
|
||||
showmyopcodes=0
|
||||
|
||||
// disable the check for learned spells.
|
||||
// if you disable it, you can cast spells you do not have in your spellbook!
|
||||
// WARNING: most servers will consider this as CHEATING!
|
||||
// DO NOT put 1 here!
|
||||
disablespellcheck=0
|
||||
|
||||
// will be used for all sendchatmessage calls. remove number/leave blank
|
||||
// to use the default language for your race (defined in race.scp)
|
||||
defaultlang=0
|
||||
|
||||
// set this to 1 if you want to have a 3D-window showing stuff
|
||||
// NOTE: this is only to activate the window for now, 3D-stuff will come later!!
|
||||
// until some frame-limiter is implemented, it will always use 100% CPU usage when
|
||||
// the GUI is enabled and activated. (if its in background - way less CPU load.)
|
||||
enablegui=0
|
||||
|
||||
// options for remote control:
|
||||
// port beeing listened on. set to 0 do disable.
|
||||
rmcontrolport=8101
|
||||
// IP or hostname that is allowed to connect. leave blank to allow connections from everywhere (dangerous!)
|
||||
rmcontrolhost=localhost
|
||||
|
||||
// if you have exported and copied data from your original client,
|
||||
// set this to 1 to enable movement and everything map related.
|
||||
// PseuWoW will need more memory with maps enabled!
|
||||
useMaps=0
|
||||
|
||||
// Addon language is usually not shown by client
|
||||
// Since addons are far from beeing used in PseuWoW, we can completely ignore addon chat messages.
|
||||
// Sometimes they even cause problems, like make the console window beep...
|
||||
SkipAddonChat=1
|
||||
|
||||
|
||||
|
||||
@ -1,44 +1,44 @@
|
||||
|
||||
// this config file has no effect on the core.
|
||||
// store variable definitions for scripts only!
|
||||
|
||||
|
||||
// ## GLOBAL SECTION ##
|
||||
|
||||
[#uppercase]
|
||||
[#noprefix]
|
||||
// special char that is used to trigger server commands (for example ".goname Player")
|
||||
// (WoWEmu="." MaNGOS="." or "!")
|
||||
// other servers might be different
|
||||
cmdchar=.
|
||||
|
||||
// MaNGOS does also accept ! as cmd identifier. put here all identifiers that can trigger a server command!
|
||||
other_cmd_chars=.!
|
||||
|
||||
// Set to 1 if PseuWoW should exit after the GUI is closed (if there is a GUI)
|
||||
ExitOnGUIClose=0
|
||||
|
||||
|
||||
|
||||
[#normal]
|
||||
// ## END OF GLOBAL SECTION ##
|
||||
|
||||
|
||||
|
||||
|
||||
// -- section for individual scripts --
|
||||
|
||||
[autobroadcast]
|
||||
enable=0
|
||||
// 20 mins by default
|
||||
secs=1200
|
||||
// the command the server uses to broadcast (.broadcast, .announce, .bc or whatever)
|
||||
// do NOT put a trailing "." or "!" , only the plain command name!
|
||||
cmd=announce
|
||||
// configure your texts here
|
||||
textcount=3
|
||||
text1=This is PseuWoW autobroadcast #1
|
||||
text2=And another one! Autobroadcast #2
|
||||
text3=The world is round, and so am I!
|
||||
|
||||
|
||||
|
||||
// this config file has no effect on the core.
|
||||
// store variable definitions for scripts only!
|
||||
|
||||
|
||||
// ## GLOBAL SECTION ##
|
||||
|
||||
[#uppercase]
|
||||
[#noprefix]
|
||||
// special char that is used to trigger server commands (for example ".goname Player")
|
||||
// (WoWEmu="." MaNGOS="." or "!")
|
||||
// other servers might be different
|
||||
cmdchar=.
|
||||
|
||||
// MaNGOS does also accept ! as cmd identifier. put here all identifiers that can trigger a server command!
|
||||
other_cmd_chars=.!
|
||||
|
||||
// Set to 1 if PseuWoW should exit after the GUI is closed (if there is a GUI)
|
||||
ExitOnGUIClose=0
|
||||
|
||||
|
||||
|
||||
[#normal]
|
||||
// ## END OF GLOBAL SECTION ##
|
||||
|
||||
|
||||
|
||||
|
||||
// -- section for individual scripts --
|
||||
|
||||
[autobroadcast]
|
||||
enable=0
|
||||
// 20 mins by default
|
||||
secs=1200
|
||||
// the command the server uses to broadcast (.broadcast, .announce, .bc or whatever)
|
||||
// do NOT put a trailing "." or "!" , only the plain command name!
|
||||
cmd=announce
|
||||
// configure your texts here
|
||||
textcount=3
|
||||
text1=This is PseuWoW autobroadcast #1
|
||||
text2=And another one! Autobroadcast #2
|
||||
text3=The world is round, and so am I!
|
||||
|
||||
|
||||
|
||||
@ -1,24 +1,24 @@
|
||||
[#uppercase]
|
||||
[GUI]
|
||||
|
||||
// drivers:
|
||||
// 0: Nulldevice (no graphics)
|
||||
// 1: fast but crappy software driver
|
||||
// 2: good software driver, but slower
|
||||
// 3: OpenGL
|
||||
// 4: DirectX 8.1
|
||||
// 5: DirectX 9.0c
|
||||
driver=5
|
||||
|
||||
// resolution and more
|
||||
resx=1024
|
||||
resy=768
|
||||
windowed=1
|
||||
vsync=0
|
||||
|
||||
// use realtime shadows?
|
||||
// works only with DirectX or OpenGL
|
||||
shadows=1
|
||||
|
||||
// color depth; 16 or 32 bit
|
||||
[#uppercase]
|
||||
[GUI]
|
||||
|
||||
// drivers:
|
||||
// 0: Nulldevice (no graphics)
|
||||
// 1: fast but crappy software driver
|
||||
// 2: good software driver, but slower
|
||||
// 3: OpenGL
|
||||
// 4: DirectX 8.1
|
||||
// 5: DirectX 9.0c
|
||||
driver=5
|
||||
|
||||
// resolution and more
|
||||
resx=1024
|
||||
resy=768
|
||||
windowed=1
|
||||
vsync=0
|
||||
|
||||
// use realtime shadows?
|
||||
// works only with DirectX or OpenGL
|
||||
shadows=1
|
||||
|
||||
// color depth; 16 or 32 bit
|
||||
depth=32
|
||||
@ -1,18 +1,18 @@
|
||||
/////////////////////////////////////////////////////////////
|
||||
// Player Permission Configuration file
|
||||
/////////////////////////////////////////////////////////////
|
||||
// Permission reaches from 0 to 255
|
||||
|
||||
[USERS]
|
||||
|
||||
Gamemaster=100
|
||||
Admin=255
|
||||
Trusted=30
|
||||
Niceplayer=10
|
||||
Falsegenesis=150
|
||||
//...
|
||||
// Add your names here
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////
|
||||
// Player Permission Configuration file
|
||||
/////////////////////////////////////////////////////////////
|
||||
// Permission reaches from 0 to 255
|
||||
|
||||
[USERS]
|
||||
|
||||
Gamemaster=100
|
||||
Admin=255
|
||||
Trusted=30
|
||||
Niceplayer=10
|
||||
Falsegenesis=150
|
||||
//...
|
||||
// Add your names here
|
||||
|
||||
|
||||
|
||||
// rest is 0 automatically
|
||||
@ -1,32 +1,32 @@
|
||||
[1]
|
||||
name=Warrior
|
||||
|
||||
[2]
|
||||
name=Paladin
|
||||
|
||||
[3]
|
||||
name=Hunter
|
||||
|
||||
[4]
|
||||
name=Rogue
|
||||
|
||||
[5]
|
||||
name=Priest
|
||||
|
||||
[6]
|
||||
name=UNKNOWN CLASS(6)
|
||||
|
||||
[7]
|
||||
name=Shaman
|
||||
|
||||
[8]
|
||||
name=Mage
|
||||
|
||||
[9]
|
||||
name=Warlock
|
||||
|
||||
[10]
|
||||
name=UNKNOWN CLASS(10)
|
||||
|
||||
[11]
|
||||
name=Druid
|
||||
[1]
|
||||
name=Warrior
|
||||
|
||||
[2]
|
||||
name=Paladin
|
||||
|
||||
[3]
|
||||
name=Hunter
|
||||
|
||||
[4]
|
||||
name=Rogue
|
||||
|
||||
[5]
|
||||
name=Priest
|
||||
|
||||
[6]
|
||||
name=UNKNOWN CLASS(6)
|
||||
|
||||
[7]
|
||||
name=Shaman
|
||||
|
||||
[8]
|
||||
name=Mage
|
||||
|
||||
[9]
|
||||
name=Warlock
|
||||
|
||||
[10]
|
||||
name=UNKNOWN CLASS(10)
|
||||
|
||||
[11]
|
||||
name=Druid
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
// define names of genders
|
||||
|
||||
[0]
|
||||
name=male
|
||||
|
||||
[1]
|
||||
name=female
|
||||
|
||||
[2]
|
||||
name=none
|
||||
// define names of genders
|
||||
|
||||
[0]
|
||||
name=male
|
||||
|
||||
[1]
|
||||
name=female
|
||||
|
||||
[2]
|
||||
name=none
|
||||
|
||||
@ -1,41 +1,41 @@
|
||||
[0]
|
||||
name=Global
|
||||
|
||||
[1]
|
||||
name=Orcish
|
||||
|
||||
[2]
|
||||
name=Darnassian
|
||||
|
||||
[3]
|
||||
name=Taurahe
|
||||
|
||||
[6]
|
||||
name=Dwarvish
|
||||
|
||||
[7]
|
||||
name=Common
|
||||
|
||||
[8]
|
||||
name=Demonic
|
||||
|
||||
[9]
|
||||
name=Titan
|
||||
|
||||
[10]
|
||||
name=Thalassian
|
||||
|
||||
[11]
|
||||
name=Draconic
|
||||
|
||||
[12]
|
||||
name=Kalimag
|
||||
|
||||
[13]
|
||||
name=Gnomish
|
||||
|
||||
[14]
|
||||
name=Troll
|
||||
|
||||
[33]
|
||||
name=Gutterspeak
|
||||
[0]
|
||||
name=Global
|
||||
|
||||
[1]
|
||||
name=Orcish
|
||||
|
||||
[2]
|
||||
name=Darnassian
|
||||
|
||||
[3]
|
||||
name=Taurahe
|
||||
|
||||
[6]
|
||||
name=Dwarvish
|
||||
|
||||
[7]
|
||||
name=Common
|
||||
|
||||
[8]
|
||||
name=Demonic
|
||||
|
||||
[9]
|
||||
name=Titan
|
||||
|
||||
[10]
|
||||
name=Thalassian
|
||||
|
||||
[11]
|
||||
name=Draconic
|
||||
|
||||
[12]
|
||||
name=Kalimag
|
||||
|
||||
[13]
|
||||
name=Gnomish
|
||||
|
||||
[14]
|
||||
name=Troll
|
||||
|
||||
[33]
|
||||
name=Gutterspeak
|
||||
|
||||
@ -1,321 +1,321 @@
|
||||
#dbname=map
|
||||
[0]
|
||||
name_general=Azeroth
|
||||
name=Eastern Kingdoms
|
||||
|
||||
[1]
|
||||
name_general=Kalimdor
|
||||
name=Kalimdor
|
||||
|
||||
[13]
|
||||
name_general=test
|
||||
name=Testing
|
||||
|
||||
[25]
|
||||
name_general=ScottTest
|
||||
name=Scott Test
|
||||
|
||||
[29]
|
||||
name_general=Test
|
||||
name=CashTest
|
||||
|
||||
[30]
|
||||
name_general=PVPZone01
|
||||
name=Alterac Valley
|
||||
|
||||
[33]
|
||||
name_general=Shadowfang
|
||||
name=Shadowfang Keep
|
||||
|
||||
[34]
|
||||
name_general=StormwindJail
|
||||
name=Stormwind Stockade
|
||||
|
||||
[35]
|
||||
name_general=StormwindPrison
|
||||
name=<unused>StormwindPrison
|
||||
|
||||
[36]
|
||||
name_general=DeadminesInstance
|
||||
name=Deadmines
|
||||
|
||||
[37]
|
||||
name_general=PVPZone02
|
||||
name=Azshara Crater
|
||||
|
||||
[42]
|
||||
name_general=Collin
|
||||
name=Collin's Test
|
||||
|
||||
[43]
|
||||
name_general=WailingCaverns
|
||||
name=Wailing Caverns
|
||||
|
||||
[44]
|
||||
name_general=Monastery
|
||||
name=<unused> Monastery
|
||||
|
||||
[47]
|
||||
name_general=RazorfenKraulInstance
|
||||
name=Razorfen Kraul
|
||||
|
||||
[48]
|
||||
name_general=Blackfathom
|
||||
name=Blackfathom Deeps
|
||||
|
||||
[70]
|
||||
name_general=Uldaman
|
||||
name=Uldaman
|
||||
|
||||
[90]
|
||||
name_general=GnomeragonInstance
|
||||
name=Gnomeregan
|
||||
|
||||
[109]
|
||||
name_general=SunkenTemple
|
||||
name=Sunken Temple
|
||||
|
||||
[129]
|
||||
name_general=RazorfenDowns
|
||||
name=Razorfen Downs
|
||||
|
||||
[169]
|
||||
name_general=EmeraldDream
|
||||
name=Emerald Dream
|
||||
|
||||
[189]
|
||||
name_general=MonasteryInstances
|
||||
name=Scarlet Monastery
|
||||
|
||||
[209]
|
||||
name_general=TanarisInstance
|
||||
name=Zul'Farrak
|
||||
|
||||
[229]
|
||||
name_general=BlackRockSpire
|
||||
name=Blackrock Spire
|
||||
|
||||
[230]
|
||||
name_general=BlackrockDepths
|
||||
name=Blackrock Depths
|
||||
|
||||
[249]
|
||||
name_general=OnyxiaLairInstance
|
||||
name=Onyxia's Lair
|
||||
|
||||
[269]
|
||||
name_general=CavernsOfTime
|
||||
name=Opening of the Dark Portal
|
||||
|
||||
[289]
|
||||
name_general=SchoolofNecromancy
|
||||
name=Scholomance
|
||||
|
||||
[309]
|
||||
name_general=Zul'gurub
|
||||
name=Zul'Gurub
|
||||
|
||||
[329]
|
||||
name_general=Stratholme
|
||||
name=Stratholme
|
||||
|
||||
[349]
|
||||
name_general=Mauradon
|
||||
name=Maraudon
|
||||
|
||||
[369]
|
||||
name_general=DeeprunTram
|
||||
name=Deeprun Tram
|
||||
|
||||
[389]
|
||||
name_general=OrgrimmarInstance
|
||||
name=Ragefire Chasm
|
||||
|
||||
[409]
|
||||
name_general=MoltenCore
|
||||
name=Molten Core
|
||||
|
||||
[429]
|
||||
name_general=DireMaul
|
||||
name=Dire Maul
|
||||
|
||||
[449]
|
||||
name_general=AlliancePVPBarracks
|
||||
name=Alliance PVP Barracks
|
||||
|
||||
[450]
|
||||
name_general=HordePVPBarracks
|
||||
name=Horde PVP Barracks
|
||||
|
||||
[451]
|
||||
name_general=development
|
||||
name=Development Land
|
||||
|
||||
[469]
|
||||
name_general=BlackwingLair
|
||||
name=Blackwing Lair
|
||||
|
||||
[489]
|
||||
name_general=PVPZone03
|
||||
name=Warsong Gulch
|
||||
|
||||
[509]
|
||||
name_general=AhnQiraj
|
||||
name=Ruins of Ahn'Qiraj
|
||||
|
||||
[529]
|
||||
name_general=PVPZone04
|
||||
name=Arathi Basin
|
||||
|
||||
[530]
|
||||
name_general=Expansion01
|
||||
name=Outland
|
||||
|
||||
[531]
|
||||
name_general=AhnQirajTemple
|
||||
name=Ahn'Qiraj Temple
|
||||
|
||||
[532]
|
||||
name_general=Karazahn
|
||||
name=Karazhan
|
||||
|
||||
[533]
|
||||
name_general=Stratholme Raid
|
||||
name=Naxxramas
|
||||
|
||||
[534]
|
||||
name_general=HyjalPast
|
||||
name=The Battle for Mount Hyjal
|
||||
|
||||
[540]
|
||||
name_general=HellfireMilitary
|
||||
name=Hellfire Citadel: The Shattered Halls
|
||||
|
||||
[542]
|
||||
name_general=HellfireDemon
|
||||
name=Hellfire Citadel: The Blood Furnace
|
||||
|
||||
[543]
|
||||
name_general=HellfireRampart
|
||||
name=Hellfire Citadel: Ramparts
|
||||
|
||||
[544]
|
||||
name_general=HellfireRaid
|
||||
name=Magtheridon's Lair
|
||||
|
||||
[545]
|
||||
name_general=CoilfangPumping
|
||||
name=Coilfang: The Steamvault
|
||||
|
||||
[546]
|
||||
name_general=CoilfangMarsh
|
||||
name=Coilfang: The Underbog
|
||||
|
||||
[547]
|
||||
name_general=CoilfangDraenei
|
||||
name=Coilfang: The Slave Pens
|
||||
|
||||
[548]
|
||||
name_general=CoilfangRaid
|
||||
name=Coilfang: Serpentshrine Cavern
|
||||
|
||||
[550]
|
||||
name_general=TempestKeepRaid
|
||||
name=Tempest Keep
|
||||
|
||||
[552]
|
||||
name_general=TempestKeepArcane
|
||||
name=Tempest Keep: The Arcatraz
|
||||
|
||||
[553]
|
||||
name_general=TempestKeepAtrium
|
||||
name=Tempest Keep: The Botanica
|
||||
|
||||
[554]
|
||||
name_general=TempestKeepFactory
|
||||
name=Tempest Keep: The Mechanar
|
||||
|
||||
[555]
|
||||
name_general=AuchindounShadow
|
||||
name=Auchindoun: Shadow Labyrinth
|
||||
|
||||
[556]
|
||||
name_general=AuchindounDemon
|
||||
name=Auchindoun: Sethekk Halls
|
||||
|
||||
[557]
|
||||
name_general=AuchindounEthereal
|
||||
name=Auchindoun: Mana-Tombs
|
||||
|
||||
[558]
|
||||
name_general=AuchindounDraenei
|
||||
name=Auchindoun: Auchenai Crypts
|
||||
|
||||
[559]
|
||||
name_general=PVPZone05
|
||||
name=Nagrand Arena
|
||||
|
||||
[560]
|
||||
name_general=HillsbradPast
|
||||
name=The Escape From Durnholde
|
||||
|
||||
[562]
|
||||
name_general=bladesedgearena
|
||||
name=Blade's Edge Arena
|
||||
|
||||
[564]
|
||||
name_general=BlackTemple
|
||||
name=Black Temple
|
||||
|
||||
[565]
|
||||
name_general=GruulsLair
|
||||
name=Gruul's Lair
|
||||
|
||||
[566]
|
||||
name_general=NetherstormBG
|
||||
name=Eye of the Storm
|
||||
|
||||
[568]
|
||||
name_general=ZulAman
|
||||
name=Zul'Aman
|
||||
|
||||
[572]
|
||||
name_general=PVPLordaeron
|
||||
name=Ruins of Lordaeron
|
||||
|
||||
[582]
|
||||
name_general=Transport176244
|
||||
name=Transport: Rut'theran to Auberdine
|
||||
|
||||
[584]
|
||||
name_general=Transport176231
|
||||
name=Transport: Menethil to Theramore
|
||||
|
||||
[586]
|
||||
name_general=Transport181645
|
||||
name=Transport: Exodar to Auberdine
|
||||
|
||||
[587]
|
||||
name_general=Transport177233
|
||||
name=Transport: Feathermoon Ferry
|
||||
|
||||
[588]
|
||||
name_general=Transport176310
|
||||
name=Transport: Menethil to Auberdine
|
||||
|
||||
[589]
|
||||
name_general=Transport175080
|
||||
name=Transport: Orgrimmar to Grom'Gol
|
||||
|
||||
[590]
|
||||
name_general=Transport176495
|
||||
name=Transport: Grom'Gol to Undercity
|
||||
|
||||
[591]
|
||||
name_general=Transport164871
|
||||
name=Transport: Undercity to Orgrimmar
|
||||
|
||||
[593]
|
||||
name_general=Transport20808
|
||||
name=Transport: Booty Bay to Ratchet
|
||||
|
||||
#dbname=map
|
||||
[0]
|
||||
name_general=Azeroth
|
||||
name=Eastern Kingdoms
|
||||
|
||||
[1]
|
||||
name_general=Kalimdor
|
||||
name=Kalimdor
|
||||
|
||||
[13]
|
||||
name_general=test
|
||||
name=Testing
|
||||
|
||||
[25]
|
||||
name_general=ScottTest
|
||||
name=Scott Test
|
||||
|
||||
[29]
|
||||
name_general=Test
|
||||
name=CashTest
|
||||
|
||||
[30]
|
||||
name_general=PVPZone01
|
||||
name=Alterac Valley
|
||||
|
||||
[33]
|
||||
name_general=Shadowfang
|
||||
name=Shadowfang Keep
|
||||
|
||||
[34]
|
||||
name_general=StormwindJail
|
||||
name=Stormwind Stockade
|
||||
|
||||
[35]
|
||||
name_general=StormwindPrison
|
||||
name=<unused>StormwindPrison
|
||||
|
||||
[36]
|
||||
name_general=DeadminesInstance
|
||||
name=Deadmines
|
||||
|
||||
[37]
|
||||
name_general=PVPZone02
|
||||
name=Azshara Crater
|
||||
|
||||
[42]
|
||||
name_general=Collin
|
||||
name=Collin's Test
|
||||
|
||||
[43]
|
||||
name_general=WailingCaverns
|
||||
name=Wailing Caverns
|
||||
|
||||
[44]
|
||||
name_general=Monastery
|
||||
name=<unused> Monastery
|
||||
|
||||
[47]
|
||||
name_general=RazorfenKraulInstance
|
||||
name=Razorfen Kraul
|
||||
|
||||
[48]
|
||||
name_general=Blackfathom
|
||||
name=Blackfathom Deeps
|
||||
|
||||
[70]
|
||||
name_general=Uldaman
|
||||
name=Uldaman
|
||||
|
||||
[90]
|
||||
name_general=GnomeragonInstance
|
||||
name=Gnomeregan
|
||||
|
||||
[109]
|
||||
name_general=SunkenTemple
|
||||
name=Sunken Temple
|
||||
|
||||
[129]
|
||||
name_general=RazorfenDowns
|
||||
name=Razorfen Downs
|
||||
|
||||
[169]
|
||||
name_general=EmeraldDream
|
||||
name=Emerald Dream
|
||||
|
||||
[189]
|
||||
name_general=MonasteryInstances
|
||||
name=Scarlet Monastery
|
||||
|
||||
[209]
|
||||
name_general=TanarisInstance
|
||||
name=Zul'Farrak
|
||||
|
||||
[229]
|
||||
name_general=BlackRockSpire
|
||||
name=Blackrock Spire
|
||||
|
||||
[230]
|
||||
name_general=BlackrockDepths
|
||||
name=Blackrock Depths
|
||||
|
||||
[249]
|
||||
name_general=OnyxiaLairInstance
|
||||
name=Onyxia's Lair
|
||||
|
||||
[269]
|
||||
name_general=CavernsOfTime
|
||||
name=Opening of the Dark Portal
|
||||
|
||||
[289]
|
||||
name_general=SchoolofNecromancy
|
||||
name=Scholomance
|
||||
|
||||
[309]
|
||||
name_general=Zul'gurub
|
||||
name=Zul'Gurub
|
||||
|
||||
[329]
|
||||
name_general=Stratholme
|
||||
name=Stratholme
|
||||
|
||||
[349]
|
||||
name_general=Mauradon
|
||||
name=Maraudon
|
||||
|
||||
[369]
|
||||
name_general=DeeprunTram
|
||||
name=Deeprun Tram
|
||||
|
||||
[389]
|
||||
name_general=OrgrimmarInstance
|
||||
name=Ragefire Chasm
|
||||
|
||||
[409]
|
||||
name_general=MoltenCore
|
||||
name=Molten Core
|
||||
|
||||
[429]
|
||||
name_general=DireMaul
|
||||
name=Dire Maul
|
||||
|
||||
[449]
|
||||
name_general=AlliancePVPBarracks
|
||||
name=Alliance PVP Barracks
|
||||
|
||||
[450]
|
||||
name_general=HordePVPBarracks
|
||||
name=Horde PVP Barracks
|
||||
|
||||
[451]
|
||||
name_general=development
|
||||
name=Development Land
|
||||
|
||||
[469]
|
||||
name_general=BlackwingLair
|
||||
name=Blackwing Lair
|
||||
|
||||
[489]
|
||||
name_general=PVPZone03
|
||||
name=Warsong Gulch
|
||||
|
||||
[509]
|
||||
name_general=AhnQiraj
|
||||
name=Ruins of Ahn'Qiraj
|
||||
|
||||
[529]
|
||||
name_general=PVPZone04
|
||||
name=Arathi Basin
|
||||
|
||||
[530]
|
||||
name_general=Expansion01
|
||||
name=Outland
|
||||
|
||||
[531]
|
||||
name_general=AhnQirajTemple
|
||||
name=Ahn'Qiraj Temple
|
||||
|
||||
[532]
|
||||
name_general=Karazahn
|
||||
name=Karazhan
|
||||
|
||||
[533]
|
||||
name_general=Stratholme Raid
|
||||
name=Naxxramas
|
||||
|
||||
[534]
|
||||
name_general=HyjalPast
|
||||
name=The Battle for Mount Hyjal
|
||||
|
||||
[540]
|
||||
name_general=HellfireMilitary
|
||||
name=Hellfire Citadel: The Shattered Halls
|
||||
|
||||
[542]
|
||||
name_general=HellfireDemon
|
||||
name=Hellfire Citadel: The Blood Furnace
|
||||
|
||||
[543]
|
||||
name_general=HellfireRampart
|
||||
name=Hellfire Citadel: Ramparts
|
||||
|
||||
[544]
|
||||
name_general=HellfireRaid
|
||||
name=Magtheridon's Lair
|
||||
|
||||
[545]
|
||||
name_general=CoilfangPumping
|
||||
name=Coilfang: The Steamvault
|
||||
|
||||
[546]
|
||||
name_general=CoilfangMarsh
|
||||
name=Coilfang: The Underbog
|
||||
|
||||
[547]
|
||||
name_general=CoilfangDraenei
|
||||
name=Coilfang: The Slave Pens
|
||||
|
||||
[548]
|
||||
name_general=CoilfangRaid
|
||||
name=Coilfang: Serpentshrine Cavern
|
||||
|
||||
[550]
|
||||
name_general=TempestKeepRaid
|
||||
name=Tempest Keep
|
||||
|
||||
[552]
|
||||
name_general=TempestKeepArcane
|
||||
name=Tempest Keep: The Arcatraz
|
||||
|
||||
[553]
|
||||
name_general=TempestKeepAtrium
|
||||
name=Tempest Keep: The Botanica
|
||||
|
||||
[554]
|
||||
name_general=TempestKeepFactory
|
||||
name=Tempest Keep: The Mechanar
|
||||
|
||||
[555]
|
||||
name_general=AuchindounShadow
|
||||
name=Auchindoun: Shadow Labyrinth
|
||||
|
||||
[556]
|
||||
name_general=AuchindounDemon
|
||||
name=Auchindoun: Sethekk Halls
|
||||
|
||||
[557]
|
||||
name_general=AuchindounEthereal
|
||||
name=Auchindoun: Mana-Tombs
|
||||
|
||||
[558]
|
||||
name_general=AuchindounDraenei
|
||||
name=Auchindoun: Auchenai Crypts
|
||||
|
||||
[559]
|
||||
name_general=PVPZone05
|
||||
name=Nagrand Arena
|
||||
|
||||
[560]
|
||||
name_general=HillsbradPast
|
||||
name=The Escape From Durnholde
|
||||
|
||||
[562]
|
||||
name_general=bladesedgearena
|
||||
name=Blade's Edge Arena
|
||||
|
||||
[564]
|
||||
name_general=BlackTemple
|
||||
name=Black Temple
|
||||
|
||||
[565]
|
||||
name_general=GruulsLair
|
||||
name=Gruul's Lair
|
||||
|
||||
[566]
|
||||
name_general=NetherstormBG
|
||||
name=Eye of the Storm
|
||||
|
||||
[568]
|
||||
name_general=ZulAman
|
||||
name=Zul'Aman
|
||||
|
||||
[572]
|
||||
name_general=PVPLordaeron
|
||||
name=Ruins of Lordaeron
|
||||
|
||||
[582]
|
||||
name_general=Transport176244
|
||||
name=Transport: Rut'theran to Auberdine
|
||||
|
||||
[584]
|
||||
name_general=Transport176231
|
||||
name=Transport: Menethil to Theramore
|
||||
|
||||
[586]
|
||||
name_general=Transport181645
|
||||
name=Transport: Exodar to Auberdine
|
||||
|
||||
[587]
|
||||
name_general=Transport177233
|
||||
name=Transport: Feathermoon Ferry
|
||||
|
||||
[588]
|
||||
name_general=Transport176310
|
||||
name=Transport: Menethil to Auberdine
|
||||
|
||||
[589]
|
||||
name_general=Transport175080
|
||||
name=Transport: Orgrimmar to Grom'Gol
|
||||
|
||||
[590]
|
||||
name_general=Transport176495
|
||||
name=Transport: Grom'Gol to Undercity
|
||||
|
||||
[591]
|
||||
name_general=Transport164871
|
||||
name=Transport: Undercity to Orgrimmar
|
||||
|
||||
[593]
|
||||
name_general=Transport20808
|
||||
name=Transport: Booty Bay to Ratchet
|
||||
|
||||
|
||||
@ -1,129 +1,129 @@
|
||||
#dbname=race
|
||||
[1]
|
||||
model_m=49
|
||||
model_f=50
|
||||
name_short=Hu
|
||||
faction=7
|
||||
name_general=Human
|
||||
name=Human
|
||||
|
||||
[2]
|
||||
model_m=51
|
||||
model_f=52
|
||||
name_short=Or
|
||||
faction=1
|
||||
name_general=Orc
|
||||
name=Orc
|
||||
|
||||
[3]
|
||||
model_m=53
|
||||
model_f=54
|
||||
name_short=Dw
|
||||
faction=7
|
||||
name_general=Dwarf
|
||||
name=Dwarf
|
||||
|
||||
[4]
|
||||
model_m=55
|
||||
model_f=56
|
||||
name_short=Ni
|
||||
faction=7
|
||||
name_general=NightElf
|
||||
name=Night Elf
|
||||
|
||||
[5]
|
||||
model_m=57
|
||||
model_f=58
|
||||
name_short=Sc
|
||||
faction=1
|
||||
name_general=Scourge
|
||||
name=Undead
|
||||
|
||||
[6]
|
||||
model_m=59
|
||||
model_f=60
|
||||
name_short=Ta
|
||||
faction=1
|
||||
name_general=Tauren
|
||||
name=Tauren
|
||||
|
||||
[7]
|
||||
model_m=1563
|
||||
model_f=1564
|
||||
name_short=Gn
|
||||
faction=7
|
||||
name_general=Gnome
|
||||
name=Gnome
|
||||
|
||||
[8]
|
||||
model_m=1478
|
||||
model_f=1479
|
||||
name_short=Tr
|
||||
faction=1
|
||||
name_general=Troll
|
||||
name=Troll
|
||||
|
||||
[9]
|
||||
model_m=6894
|
||||
model_f=6895
|
||||
name_short=Go
|
||||
faction=7
|
||||
name_general=Goblin
|
||||
name=Goblin
|
||||
|
||||
[10]
|
||||
model_m=15476
|
||||
model_f=15475
|
||||
name_short=Be
|
||||
faction=1
|
||||
name_general=BloodElf
|
||||
name=Blood Elf
|
||||
|
||||
[11]
|
||||
model_m=16125
|
||||
model_f=16126
|
||||
name_short=Dr
|
||||
faction=7
|
||||
name_general=Draenei
|
||||
name=Draenei
|
||||
|
||||
[12]
|
||||
model_m=16981
|
||||
model_f=16980
|
||||
name_short=Fo
|
||||
faction=7
|
||||
name_general=FelOrc
|
||||
name=Fel Orc
|
||||
|
||||
[13]
|
||||
model_m=17402
|
||||
model_f=17403
|
||||
name_short=Na
|
||||
faction=7
|
||||
name_general=Naga_
|
||||
name=Naga
|
||||
|
||||
[14]
|
||||
model_m=17576
|
||||
model_f=17577
|
||||
name_short=Br
|
||||
faction=7
|
||||
name_general=Broken
|
||||
name=Broken
|
||||
|
||||
[15]
|
||||
model_m=17578
|
||||
model_f=17579
|
||||
name_short=Sk
|
||||
faction=7
|
||||
name_general=Skeleton
|
||||
name=Skeleton
|
||||
|
||||
[18]
|
||||
model_m=21963
|
||||
model_f=21964
|
||||
name_short=Ft
|
||||
faction=7
|
||||
name_general=ForestTroll
|
||||
name=Forest Troll
|
||||
|
||||
#dbname=race
|
||||
[1]
|
||||
model_m=49
|
||||
model_f=50
|
||||
name_short=Hu
|
||||
faction=7
|
||||
name_general=Human
|
||||
name=Human
|
||||
|
||||
[2]
|
||||
model_m=51
|
||||
model_f=52
|
||||
name_short=Or
|
||||
faction=1
|
||||
name_general=Orc
|
||||
name=Orc
|
||||
|
||||
[3]
|
||||
model_m=53
|
||||
model_f=54
|
||||
name_short=Dw
|
||||
faction=7
|
||||
name_general=Dwarf
|
||||
name=Dwarf
|
||||
|
||||
[4]
|
||||
model_m=55
|
||||
model_f=56
|
||||
name_short=Ni
|
||||
faction=7
|
||||
name_general=NightElf
|
||||
name=Night Elf
|
||||
|
||||
[5]
|
||||
model_m=57
|
||||
model_f=58
|
||||
name_short=Sc
|
||||
faction=1
|
||||
name_general=Scourge
|
||||
name=Undead
|
||||
|
||||
[6]
|
||||
model_m=59
|
||||
model_f=60
|
||||
name_short=Ta
|
||||
faction=1
|
||||
name_general=Tauren
|
||||
name=Tauren
|
||||
|
||||
[7]
|
||||
model_m=1563
|
||||
model_f=1564
|
||||
name_short=Gn
|
||||
faction=7
|
||||
name_general=Gnome
|
||||
name=Gnome
|
||||
|
||||
[8]
|
||||
model_m=1478
|
||||
model_f=1479
|
||||
name_short=Tr
|
||||
faction=1
|
||||
name_general=Troll
|
||||
name=Troll
|
||||
|
||||
[9]
|
||||
model_m=6894
|
||||
model_f=6895
|
||||
name_short=Go
|
||||
faction=7
|
||||
name_general=Goblin
|
||||
name=Goblin
|
||||
|
||||
[10]
|
||||
model_m=15476
|
||||
model_f=15475
|
||||
name_short=Be
|
||||
faction=1
|
||||
name_general=BloodElf
|
||||
name=Blood Elf
|
||||
|
||||
[11]
|
||||
model_m=16125
|
||||
model_f=16126
|
||||
name_short=Dr
|
||||
faction=7
|
||||
name_general=Draenei
|
||||
name=Draenei
|
||||
|
||||
[12]
|
||||
model_m=16981
|
||||
model_f=16980
|
||||
name_short=Fo
|
||||
faction=7
|
||||
name_general=FelOrc
|
||||
name=Fel Orc
|
||||
|
||||
[13]
|
||||
model_m=17402
|
||||
model_f=17403
|
||||
name_short=Na
|
||||
faction=7
|
||||
name_general=Naga_
|
||||
name=Naga
|
||||
|
||||
[14]
|
||||
model_m=17576
|
||||
model_f=17577
|
||||
name_short=Br
|
||||
faction=7
|
||||
name_general=Broken
|
||||
name=Broken
|
||||
|
||||
[15]
|
||||
model_m=17578
|
||||
model_f=17579
|
||||
name_short=Sk
|
||||
faction=7
|
||||
name_general=Skeleton
|
||||
name=Skeleton
|
||||
|
||||
[18]
|
||||
model_m=21963
|
||||
model_f=21964
|
||||
name_short=Ft
|
||||
faction=7
|
||||
name_general=ForestTroll
|
||||
name=Forest Troll
|
||||
|
||||
|
||||
@ -1,229 +1,229 @@
|
||||
|
||||
//-----------------------------------------------------------
|
||||
#script=chan
|
||||
//-----------------------------------------------------------
|
||||
// Script to write on channels
|
||||
// Arguments:
|
||||
// ==========
|
||||
// @def: text to write
|
||||
// @0: channel name
|
||||
// @1: language name/number
|
||||
|
||||
#permission=10
|
||||
SET,lang ${@1}
|
||||
DEFAULT,lang 0
|
||||
SENDCHATMESSAGE,14,{${lang}},{${@def}},{${@0}}
|
||||
UNSET lang
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
#script=cmd
|
||||
#permission=255
|
||||
//-----------------------------------------------------------
|
||||
// purpose: send a server command.
|
||||
// args:
|
||||
// @def: command to send
|
||||
|
||||
SAY ${#CMDCHAR}${@def}
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
#script=reply
|
||||
#permission=255
|
||||
//-----------------------------------------------------------
|
||||
// purpose: reply to the player that whispered last
|
||||
|
||||
SET,player ${@thiswhisper_name}
|
||||
SET,lang ${@0}
|
||||
DEFAULT,lang 0
|
||||
SET,msg ${@def}
|
||||
|
||||
WHISPER,{${player}},{${lang}} ${msg}
|
||||
|
||||
UNSET player
|
||||
UNSET lang
|
||||
UNSET msg
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
#script=s
|
||||
#permission=0
|
||||
//-----------------------------------------------------------
|
||||
// is the char equal to the char we use for commands? does the player have a permission lvl below 255?
|
||||
IF ?{AND,?{string_is_command ${@def}} ?{SMALLER,?{GETPLAYERPERM ${@thiscmd_name}} 255}}
|
||||
// yes: say a warning and the command the player wanted to use
|
||||
SAY ${@thiscmd_name}: no permission to use commands [${@def}]
|
||||
RETURN false
|
||||
ELSE
|
||||
// no: say the text as usual.
|
||||
SAY,{${@0}} ${@def}
|
||||
RETURN true
|
||||
ENDIF
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
#script=say
|
||||
#permission=255
|
||||
//-----------------------------------------------------------
|
||||
// purpose: say something. @0: language ID or name, @def: text to say
|
||||
// setup some default values
|
||||
SET,lang ${@0}
|
||||
SET,msg ${@def}
|
||||
|
||||
DEFAULT,#DEFAULTLANG ?{GETSCPVALUE,race,{${@myrace}} faction}
|
||||
DEFAULT,lang ${#DEFAULTLANG}
|
||||
|
||||
LOGDEBUG * Saying '${msg}' in lang ${lang}
|
||||
|
||||
SENDCHATMESSAGE,0,${lang},{${msg}}
|
||||
UNSET lang
|
||||
UNSET msg
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
#script=sayguild
|
||||
#permission=255
|
||||
//-----------------------------------------------------------
|
||||
// purpose: say something to guild channel
|
||||
// setup some default values
|
||||
SET,lang ${@0}
|
||||
SET,msg ${@def}
|
||||
|
||||
default,lang 0
|
||||
|
||||
LOGDEBUG * Saying '${msg}' in lang ${lang} to guild
|
||||
|
||||
SENDCHATMESSAGE,3,${lang},{${msg}}
|
||||
UNSET lang
|
||||
UNSET msg
|
||||
|
||||
//-----------------------------------------------------------
|
||||
#script=sayitem
|
||||
#permission=0
|
||||
//-----------------------------------------------------------
|
||||
// example script to "say" a clickable item
|
||||
SAY ?{getchatitem ${@def}}
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
#script=sayparty
|
||||
#permission=255
|
||||
//-----------------------------------------------------------
|
||||
// purpose: say something to party channel
|
||||
// setup some default values
|
||||
SET,lang ${@0}
|
||||
SET,msg ${@def}
|
||||
|
||||
default,lang 0
|
||||
|
||||
LOGDEBUG * Saying '${msg}' in lang ${lang} to party
|
||||
|
||||
SENDCHATMESSAGE,1,${lang},{${msg}}
|
||||
UNSET lang
|
||||
UNSET msg
|
||||
|
||||
//-----------------------------------------------------------
|
||||
#script=sayred
|
||||
//-----------------------------------------------------------
|
||||
// example script how to output colored text
|
||||
#permission=0
|
||||
SAY,{${@0}} |cffFF0000${@def}
|
||||
|
||||
//-----------------------------------------------------------
|
||||
#script=sayv
|
||||
#permission=0
|
||||
//-----------------------------------------------------------
|
||||
// purpose: say the value of a variable
|
||||
// args: @0: language ID or name, @def: var name
|
||||
SET,vn #${@caller}::${@def}
|
||||
SET,vl ${@0}
|
||||
DEFAULT,vl 0
|
||||
|
||||
IF ?{NOT ?{ISSET ${vn}}}
|
||||
SAY,{${vl}} * Var '${@def}' not defined.
|
||||
ELSE
|
||||
SET,vv ${${vn}}
|
||||
SAY,{${vl}} * Var '${@def}' = '${vv}'
|
||||
ENDIF
|
||||
|
||||
UNSET vv
|
||||
UNSET vn
|
||||
UNSET vl
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
#script=whisper
|
||||
#permission=255
|
||||
//-----------------------------------------------------------
|
||||
// purpose: whisper text to a player.
|
||||
// args: @0: player name to whisper to; @1: language to use; @def: text
|
||||
|
||||
// setup some default values
|
||||
SET,msg ${@def}
|
||||
SET,player ${@0}
|
||||
SET,lang ${@1}
|
||||
|
||||
DEFAULT,#DEFAULTLANG ?{GETSCPVALUE,race,{${@myrace}} faction}
|
||||
DEFAULT,lang ${#DEFAULTLANG}
|
||||
|
||||
LOGDEBUG * Whisp to '{${player}}' '{${msg}}' in lang '${lang}'
|
||||
|
||||
SENDCHATMESSAGE,6,{${lang}},{${msg}},{${player}}
|
||||
UNSET lang
|
||||
UNSET msg
|
||||
UNSET player
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
#script=yell
|
||||
#permission=255
|
||||
//-------------------------------------------------------------
|
||||
// purpose: SHOUT!
|
||||
|
||||
// setup some default values
|
||||
SET,lang ${@0}
|
||||
SET,msg ${@def}
|
||||
|
||||
DEFAULT,#DEFAULTLANG ?{GETSCPVALUE,race,{${@myrace}} faction}
|
||||
DEFAULT,lang ${#DEFAULTLANG}
|
||||
|
||||
LOGDEBUG * Yelling '${msg}' in lang ${lang}
|
||||
|
||||
SENDCHATMESSAGE,5,${lang},{${msg}}
|
||||
UNSET lang
|
||||
UNSET msg
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
#script=y
|
||||
#permission=0
|
||||
//-----------------------------------------------------------
|
||||
// is the char equal to the char we use for commands? does the player have a permission lvl below 255?
|
||||
IF ?{AND,?{string_is_command ${@def}} ?{SMALLER,?{GETPLAYERPERM ${@thiscmd_name}} 255}}
|
||||
// yes: say a warning and the command the player wanted to use
|
||||
YELL ${@thiscmd_name}: no permission to use commands [${@def}]
|
||||
RETURN false
|
||||
ELSE
|
||||
// no: say the text as usual.
|
||||
YELL,{${@0}} ${@def}
|
||||
RETURN true
|
||||
ENDIF
|
||||
|
||||
|
||||
//----------------------------------------------------------
|
||||
#script=me
|
||||
#permission=0
|
||||
//----------------------------------------------------------
|
||||
// Send text emote. example: "me feels lolo" will result in "Pseuwow feels lolo" at other clients
|
||||
SET,lang ${@0}
|
||||
SET,msg ${@def}
|
||||
|
||||
DEFAULT,#DEFAULTLANG ?{GETSCPVALUE,race,{${@myrace}} faction}
|
||||
DEFAULT,lang ${#DEFAULTLANG}
|
||||
|
||||
LOGDEBUG * Me ${msg} (in lang ${lang})
|
||||
|
||||
SENDCHATMESSAGE,8,${lang},{${msg}}
|
||||
UNSET lang
|
||||
UNSET msg
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
#script=chan
|
||||
//-----------------------------------------------------------
|
||||
// Script to write on channels
|
||||
// Arguments:
|
||||
// ==========
|
||||
// @def: text to write
|
||||
// @0: channel name
|
||||
// @1: language name/number
|
||||
|
||||
#permission=10
|
||||
SET,lang ${@1}
|
||||
DEFAULT,lang 0
|
||||
SENDCHATMESSAGE,14,{${lang}},{${@def}},{${@0}}
|
||||
UNSET lang
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
#script=cmd
|
||||
#permission=255
|
||||
//-----------------------------------------------------------
|
||||
// purpose: send a server command.
|
||||
// args:
|
||||
// @def: command to send
|
||||
|
||||
SAY ${#CMDCHAR}${@def}
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
#script=reply
|
||||
#permission=255
|
||||
//-----------------------------------------------------------
|
||||
// purpose: reply to the player that whispered last
|
||||
|
||||
SET,player ${@thiswhisper_name}
|
||||
SET,lang ${@0}
|
||||
DEFAULT,lang 0
|
||||
SET,msg ${@def}
|
||||
|
||||
WHISPER,{${player}},{${lang}} ${msg}
|
||||
|
||||
UNSET player
|
||||
UNSET lang
|
||||
UNSET msg
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
#script=s
|
||||
#permission=0
|
||||
//-----------------------------------------------------------
|
||||
// is the char equal to the char we use for commands? does the player have a permission lvl below 255?
|
||||
IF ?{AND,?{string_is_command ${@def}} ?{SMALLER,?{GETPLAYERPERM ${@thiscmd_name}} 255}}
|
||||
// yes: say a warning and the command the player wanted to use
|
||||
SAY ${@thiscmd_name}: no permission to use commands [${@def}]
|
||||
RETURN false
|
||||
ELSE
|
||||
// no: say the text as usual.
|
||||
SAY,{${@0}} ${@def}
|
||||
RETURN true
|
||||
ENDIF
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
#script=say
|
||||
#permission=255
|
||||
//-----------------------------------------------------------
|
||||
// purpose: say something. @0: language ID or name, @def: text to say
|
||||
// setup some default values
|
||||
SET,lang ${@0}
|
||||
SET,msg ${@def}
|
||||
|
||||
DEFAULT,#DEFAULTLANG ?{GETSCPVALUE,race,{${@myrace}} faction}
|
||||
DEFAULT,lang ${#DEFAULTLANG}
|
||||
|
||||
LOGDEBUG * Saying '${msg}' in lang ${lang}
|
||||
|
||||
SENDCHATMESSAGE,0,${lang},{${msg}}
|
||||
UNSET lang
|
||||
UNSET msg
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
#script=sayguild
|
||||
#permission=255
|
||||
//-----------------------------------------------------------
|
||||
// purpose: say something to guild channel
|
||||
// setup some default values
|
||||
SET,lang ${@0}
|
||||
SET,msg ${@def}
|
||||
|
||||
default,lang 0
|
||||
|
||||
LOGDEBUG * Saying '${msg}' in lang ${lang} to guild
|
||||
|
||||
SENDCHATMESSAGE,3,${lang},{${msg}}
|
||||
UNSET lang
|
||||
UNSET msg
|
||||
|
||||
//-----------------------------------------------------------
|
||||
#script=sayitem
|
||||
#permission=0
|
||||
//-----------------------------------------------------------
|
||||
// example script to "say" a clickable item
|
||||
SAY ?{getchatitem ${@def}}
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
#script=sayparty
|
||||
#permission=255
|
||||
//-----------------------------------------------------------
|
||||
// purpose: say something to party channel
|
||||
// setup some default values
|
||||
SET,lang ${@0}
|
||||
SET,msg ${@def}
|
||||
|
||||
default,lang 0
|
||||
|
||||
LOGDEBUG * Saying '${msg}' in lang ${lang} to party
|
||||
|
||||
SENDCHATMESSAGE,1,${lang},{${msg}}
|
||||
UNSET lang
|
||||
UNSET msg
|
||||
|
||||
//-----------------------------------------------------------
|
||||
#script=sayred
|
||||
//-----------------------------------------------------------
|
||||
// example script how to output colored text
|
||||
#permission=0
|
||||
SAY,{${@0}} |cffFF0000${@def}
|
||||
|
||||
//-----------------------------------------------------------
|
||||
#script=sayv
|
||||
#permission=0
|
||||
//-----------------------------------------------------------
|
||||
// purpose: say the value of a variable
|
||||
// args: @0: language ID or name, @def: var name
|
||||
SET,vn #${@caller}::${@def}
|
||||
SET,vl ${@0}
|
||||
DEFAULT,vl 0
|
||||
|
||||
IF ?{NOT ?{ISSET ${vn}}}
|
||||
SAY,{${vl}} * Var '${@def}' not defined.
|
||||
ELSE
|
||||
SET,vv ${${vn}}
|
||||
SAY,{${vl}} * Var '${@def}' = '${vv}'
|
||||
ENDIF
|
||||
|
||||
UNSET vv
|
||||
UNSET vn
|
||||
UNSET vl
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
#script=whisper
|
||||
#permission=255
|
||||
//-----------------------------------------------------------
|
||||
// purpose: whisper text to a player.
|
||||
// args: @0: player name to whisper to; @1: language to use; @def: text
|
||||
|
||||
// setup some default values
|
||||
SET,msg ${@def}
|
||||
SET,player ${@0}
|
||||
SET,lang ${@1}
|
||||
|
||||
DEFAULT,#DEFAULTLANG ?{GETSCPVALUE,race,{${@myrace}} faction}
|
||||
DEFAULT,lang ${#DEFAULTLANG}
|
||||
|
||||
LOGDEBUG * Whisp to '{${player}}' '{${msg}}' in lang '${lang}'
|
||||
|
||||
SENDCHATMESSAGE,6,{${lang}},{${msg}},{${player}}
|
||||
UNSET lang
|
||||
UNSET msg
|
||||
UNSET player
|
||||
|
||||
|
||||
//-------------------------------------------------------------
|
||||
#script=yell
|
||||
#permission=255
|
||||
//-------------------------------------------------------------
|
||||
// purpose: SHOUT!
|
||||
|
||||
// setup some default values
|
||||
SET,lang ${@0}
|
||||
SET,msg ${@def}
|
||||
|
||||
DEFAULT,#DEFAULTLANG ?{GETSCPVALUE,race,{${@myrace}} faction}
|
||||
DEFAULT,lang ${#DEFAULTLANG}
|
||||
|
||||
LOGDEBUG * Yelling '${msg}' in lang ${lang}
|
||||
|
||||
SENDCHATMESSAGE,5,${lang},{${msg}}
|
||||
UNSET lang
|
||||
UNSET msg
|
||||
|
||||
|
||||
//-----------------------------------------------------------
|
||||
#script=y
|
||||
#permission=0
|
||||
//-----------------------------------------------------------
|
||||
// is the char equal to the char we use for commands? does the player have a permission lvl below 255?
|
||||
IF ?{AND,?{string_is_command ${@def}} ?{SMALLER,?{GETPLAYERPERM ${@thiscmd_name}} 255}}
|
||||
// yes: say a warning and the command the player wanted to use
|
||||
YELL ${@thiscmd_name}: no permission to use commands [${@def}]
|
||||
RETURN false
|
||||
ELSE
|
||||
// no: say the text as usual.
|
||||
YELL,{${@0}} ${@def}
|
||||
RETURN true
|
||||
ENDIF
|
||||
|
||||
|
||||
//----------------------------------------------------------
|
||||
#script=me
|
||||
#permission=0
|
||||
//----------------------------------------------------------
|
||||
// Send text emote. example: "me feels lolo" will result in "Pseuwow feels lolo" at other clients
|
||||
SET,lang ${@0}
|
||||
SET,msg ${@def}
|
||||
|
||||
DEFAULT,#DEFAULTLANG ?{GETSCPVALUE,race,{${@myrace}} faction}
|
||||
DEFAULT,lang ${#DEFAULTLANG}
|
||||
|
||||
LOGDEBUG * Me ${msg} (in lang ${lang})
|
||||
|
||||
SENDCHATMESSAGE,8,${lang},{${msg}}
|
||||
UNSET lang
|
||||
UNSET msg
|
||||
|
||||
|
||||
@ -1,177 +1,177 @@
|
||||
|
||||
// -----------------------------------
|
||||
#script=FlushChatAI
|
||||
#permission=255
|
||||
// -----------------------------------
|
||||
// purpose: remove all registered chat AI scripts. usable as command.
|
||||
logdebug flushing chat AI scripts.
|
||||
lclean #processchatai::pattern_list
|
||||
lclean #processchatai::script_list
|
||||
lclean #processchatai::cond_list
|
||||
lclean #processchatai::register_list
|
||||
|
||||
// ----------------------------------
|
||||
#script=DropChatAIScript
|
||||
// ----------------------------------
|
||||
// purpose: drop all entries registered to call the script specified in @def
|
||||
set,amount 0
|
||||
loop
|
||||
set,pos ?{lfind,#processchatai::script_list,true ${@def}}
|
||||
if ?{not ?{strlen ${pos}}}
|
||||
exitloop
|
||||
endif
|
||||
set,what_sc ?{lerase,#processchatai::script_list ${pos}}
|
||||
set,what_cond ?{lerase,#processchatai::cond_list ${pos}}
|
||||
set,what_ptn ?{lerase,#processchatai::pattern_list ${pos}}
|
||||
lerase,#processchatai::register_list ${pos}
|
||||
logdetail Dropped ChatAI for script '${what_sc}', cond [${what_cond}], pattern [${what_ptn}]
|
||||
add,amount 1
|
||||
endloop
|
||||
unset what_sc
|
||||
unset what_cond
|
||||
unset what_ptn
|
||||
unset pos
|
||||
return ${amount}
|
||||
|
||||
|
||||
// ----------------------------------
|
||||
#script=processchatai
|
||||
// ----------------------------------
|
||||
// purpose: iterate over registered AI scripts, test if the chat message matches a given condition,
|
||||
// and execute appropriate script with predefined arguments.
|
||||
// returns: false if the incoming chatmessage was invalid, else true
|
||||
// TODO: get object name (player or creature) and pass it to the called scripts
|
||||
|
||||
// if the list doesnt exist, it will return "", but this counts as false also
|
||||
if ?{not ?{llen pattern_list}}
|
||||
return
|
||||
endif
|
||||
|
||||
// filter out chat messages that came from us
|
||||
if ?{equal,${@myguid} ${@2}}
|
||||
return false
|
||||
endif
|
||||
|
||||
// filter out CHAT_MSG_WHISPER_INFORM ("whisper to ... : blah blah")
|
||||
if ?{equal,${@0} 7}
|
||||
return false
|
||||
endif
|
||||
|
||||
set,msg ?{lowercase ${@def}}
|
||||
|
||||
default,filter { !?,;.:-_\\/<>()[]"$=+&#'*~`´^°}
|
||||
|
||||
// split the msg into a list containing only words. remove special characters also.
|
||||
lcsplit,wlist,{${filter}} ${msg}
|
||||
|
||||
// remove empty entries
|
||||
lclean,wlist
|
||||
|
||||
|
||||
// obtain name of the language that was used
|
||||
set,langname ?{GetSCPValue,language,${@1} name}
|
||||
default,langname UNKNOWN
|
||||
|
||||
|
||||
set,i 0
|
||||
set,len ?{llen pattern_list}
|
||||
|
||||
loop
|
||||
if ?{bigger_eq,${i} ${len}}
|
||||
exitloop
|
||||
endif
|
||||
|
||||
set,script ?{lindex,script_list ${i}}
|
||||
set,cond ?{lindex,cond_list ${i}}
|
||||
set,pattern ?{lindex,pattern_list ${i}}
|
||||
|
||||
set,call false
|
||||
|
||||
if ?{equal,NONE ${cond}}
|
||||
set,call true
|
||||
else
|
||||
if ?{equal,ANY ${cond}}
|
||||
set,call ?{lcontains_ext,wlist,{ } ${pattern}}
|
||||
else
|
||||
if ?{equal,EXACT ${cond}}
|
||||
set,call ?{equal,{${pattern}} ${msg}}
|
||||
else
|
||||
if ?{equal,EXACT_PARTIAL ${cond}}
|
||||
set,call ?{strlen ?{strfind,{${pattern}} ${msg}}}
|
||||
else
|
||||
if ?{equal,ALL ${cond}}
|
||||
// split the pattern into a list, then get its size. the amount of words matching the pattern list must be
|
||||
// equal or greater then the amount of words in the pattern list
|
||||
lcsplit,tmpl,{${filter}} ${pattern}
|
||||
lclean,tmpl
|
||||
set,pattln ?{llen tmpl}
|
||||
set,matched ?{lcontains_ext,wlist,{ } ${pattern}}
|
||||
set,call ?{greater_eq,${matched} ${pattln}}
|
||||
unset pattln
|
||||
unset matched
|
||||
ldelete tmpl
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if ${call}
|
||||
// logdebug DEBUG: ChatAI: calling script ${script}, condition ${cond} matched.
|
||||
${script},{${@0}},{${@1}},{${@2}},{${@3}},{${langname}} ${@def}
|
||||
//else
|
||||
// logdebug DEBUG: ChatAI: NOT called script ${script}, condition ${cond} not matched.
|
||||
endif
|
||||
|
||||
add,i 1
|
||||
endloop
|
||||
|
||||
|
||||
|
||||
// cleanup
|
||||
ldelete wlist
|
||||
|
||||
return true
|
||||
|
||||
|
||||
// ----------------------------------
|
||||
#script=RegisterChatAIScript
|
||||
// ----------------------------------
|
||||
// purpose: registers a custom script to handle an incoming chat message if a condition is matched.
|
||||
// args:
|
||||
// @def: word pattern (words are delimited with spaces)
|
||||
// @0: script name that has to be called if the condition is matched
|
||||
// @1: condition. allowed values are:
|
||||
// ALL - the chat message must contain all words provided
|
||||
// ANY - the chat message must contain any word provided
|
||||
// ALL_ORDER - same like all, but in the order provided -- NOT YET IMPLEMENTED
|
||||
// ALL_CONSECUTIVE - same like ALL_ORDER, but the words must follow exactly one after another -- NOT YET IMPLEMENTED
|
||||
// EXACT - the chat message must be exactly equal to the string supplied.
|
||||
// EXACT_PARTIAL - the chat message must contain the string supplied.
|
||||
// NONE - the script will be always called; no testing is done. its up to the user how to deal with it. (default)
|
||||
// note that @def is not case sensitive!
|
||||
|
||||
if ?{not ?{strlen ${@0}}}
|
||||
logerror Script error: RegisterChatAIScript: no function defined (called by '${@caller}')
|
||||
return false
|
||||
endif
|
||||
|
||||
set,pattern ?{lowercase ${@def}}
|
||||
|
||||
set,cond ?{uppercase ${@1}}
|
||||
default,cond NONE
|
||||
|
||||
|
||||
if ?{lcontains,#processchatai::register_list {[${@0};${pattern};${cond}]}}
|
||||
logdebug Chat AI script already registered. script: '${@0}', condition: ${cond}, pattern: '${@def}'
|
||||
return false
|
||||
endif
|
||||
|
||||
lpushback,#processchatai::pattern_list ${pattern}
|
||||
lpushback,#processchatai::script_list ${@0}
|
||||
lpushback,#processchatai::cond_list ${cond}
|
||||
lpushback,#processchatai::register_list {[${@0};${pattern};${cond}]}
|
||||
|
||||
logdetail Chat AI script registered. script: '${@0}', condition: ${cond}, pattern: '${pattern}' [now ?{llen #processchatai::pattern_list} registered]
|
||||
|
||||
return true
|
||||
|
||||
// -----------------------------------
|
||||
#script=FlushChatAI
|
||||
#permission=255
|
||||
// -----------------------------------
|
||||
// purpose: remove all registered chat AI scripts. usable as command.
|
||||
logdebug flushing chat AI scripts.
|
||||
lclean #processchatai::pattern_list
|
||||
lclean #processchatai::script_list
|
||||
lclean #processchatai::cond_list
|
||||
lclean #processchatai::register_list
|
||||
|
||||
// ----------------------------------
|
||||
#script=DropChatAIScript
|
||||
// ----------------------------------
|
||||
// purpose: drop all entries registered to call the script specified in @def
|
||||
set,amount 0
|
||||
loop
|
||||
set,pos ?{lfind,#processchatai::script_list,true ${@def}}
|
||||
if ?{not ?{strlen ${pos}}}
|
||||
exitloop
|
||||
endif
|
||||
set,what_sc ?{lerase,#processchatai::script_list ${pos}}
|
||||
set,what_cond ?{lerase,#processchatai::cond_list ${pos}}
|
||||
set,what_ptn ?{lerase,#processchatai::pattern_list ${pos}}
|
||||
lerase,#processchatai::register_list ${pos}
|
||||
logdetail Dropped ChatAI for script '${what_sc}', cond [${what_cond}], pattern [${what_ptn}]
|
||||
add,amount 1
|
||||
endloop
|
||||
unset what_sc
|
||||
unset what_cond
|
||||
unset what_ptn
|
||||
unset pos
|
||||
return ${amount}
|
||||
|
||||
|
||||
// ----------------------------------
|
||||
#script=processchatai
|
||||
// ----------------------------------
|
||||
// purpose: iterate over registered AI scripts, test if the chat message matches a given condition,
|
||||
// and execute appropriate script with predefined arguments.
|
||||
// returns: false if the incoming chatmessage was invalid, else true
|
||||
// TODO: get object name (player or creature) and pass it to the called scripts
|
||||
|
||||
// if the list doesnt exist, it will return "", but this counts as false also
|
||||
if ?{not ?{llen pattern_list}}
|
||||
return
|
||||
endif
|
||||
|
||||
// filter out chat messages that came from us
|
||||
if ?{equal,${@myguid} ${@2}}
|
||||
return false
|
||||
endif
|
||||
|
||||
// filter out CHAT_MSG_WHISPER_INFORM ("whisper to ... : blah blah")
|
||||
if ?{equal,${@0} 7}
|
||||
return false
|
||||
endif
|
||||
|
||||
set,msg ?{lowercase ${@def}}
|
||||
|
||||
default,filter { !?,;.:-_\\/<>()[]"$=+&#'*~`´^°}
|
||||
|
||||
// split the msg into a list containing only words. remove special characters also.
|
||||
lcsplit,wlist,{${filter}} ${msg}
|
||||
|
||||
// remove empty entries
|
||||
lclean,wlist
|
||||
|
||||
|
||||
// obtain name of the language that was used
|
||||
set,langname ?{GetSCPValue,language,${@1} name}
|
||||
default,langname UNKNOWN
|
||||
|
||||
|
||||
set,i 0
|
||||
set,len ?{llen pattern_list}
|
||||
|
||||
loop
|
||||
if ?{bigger_eq,${i} ${len}}
|
||||
exitloop
|
||||
endif
|
||||
|
||||
set,script ?{lindex,script_list ${i}}
|
||||
set,cond ?{lindex,cond_list ${i}}
|
||||
set,pattern ?{lindex,pattern_list ${i}}
|
||||
|
||||
set,call false
|
||||
|
||||
if ?{equal,NONE ${cond}}
|
||||
set,call true
|
||||
else
|
||||
if ?{equal,ANY ${cond}}
|
||||
set,call ?{lcontains_ext,wlist,{ } ${pattern}}
|
||||
else
|
||||
if ?{equal,EXACT ${cond}}
|
||||
set,call ?{equal,{${pattern}} ${msg}}
|
||||
else
|
||||
if ?{equal,EXACT_PARTIAL ${cond}}
|
||||
set,call ?{strlen ?{strfind,{${pattern}} ${msg}}}
|
||||
else
|
||||
if ?{equal,ALL ${cond}}
|
||||
// split the pattern into a list, then get its size. the amount of words matching the pattern list must be
|
||||
// equal or greater then the amount of words in the pattern list
|
||||
lcsplit,tmpl,{${filter}} ${pattern}
|
||||
lclean,tmpl
|
||||
set,pattln ?{llen tmpl}
|
||||
set,matched ?{lcontains_ext,wlist,{ } ${pattern}}
|
||||
set,call ?{greater_eq,${matched} ${pattln}}
|
||||
unset pattln
|
||||
unset matched
|
||||
ldelete tmpl
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if ${call}
|
||||
// logdebug DEBUG: ChatAI: calling script ${script}, condition ${cond} matched.
|
||||
${script},{${@0}},{${@1}},{${@2}},{${@3}},{${langname}} ${@def}
|
||||
//else
|
||||
// logdebug DEBUG: ChatAI: NOT called script ${script}, condition ${cond} not matched.
|
||||
endif
|
||||
|
||||
add,i 1
|
||||
endloop
|
||||
|
||||
|
||||
|
||||
// cleanup
|
||||
ldelete wlist
|
||||
|
||||
return true
|
||||
|
||||
|
||||
// ----------------------------------
|
||||
#script=RegisterChatAIScript
|
||||
// ----------------------------------
|
||||
// purpose: registers a custom script to handle an incoming chat message if a condition is matched.
|
||||
// args:
|
||||
// @def: word pattern (words are delimited with spaces)
|
||||
// @0: script name that has to be called if the condition is matched
|
||||
// @1: condition. allowed values are:
|
||||
// ALL - the chat message must contain all words provided
|
||||
// ANY - the chat message must contain any word provided
|
||||
// ALL_ORDER - same like all, but in the order provided -- NOT YET IMPLEMENTED
|
||||
// ALL_CONSECUTIVE - same like ALL_ORDER, but the words must follow exactly one after another -- NOT YET IMPLEMENTED
|
||||
// EXACT - the chat message must be exactly equal to the string supplied.
|
||||
// EXACT_PARTIAL - the chat message must contain the string supplied.
|
||||
// NONE - the script will be always called; no testing is done. its up to the user how to deal with it. (default)
|
||||
// note that @def is not case sensitive!
|
||||
|
||||
if ?{not ?{strlen ${@0}}}
|
||||
logerror Script error: RegisterChatAIScript: no function defined (called by '${@caller}')
|
||||
return false
|
||||
endif
|
||||
|
||||
set,pattern ?{lowercase ${@def}}
|
||||
|
||||
set,cond ?{uppercase ${@1}}
|
||||
default,cond NONE
|
||||
|
||||
|
||||
if ?{lcontains,#processchatai::register_list {[${@0};${pattern};${cond}]}}
|
||||
logdebug Chat AI script already registered. script: '${@0}', condition: ${cond}, pattern: '${@def}'
|
||||
return false
|
||||
endif
|
||||
|
||||
lpushback,#processchatai::pattern_list ${pattern}
|
||||
lpushback,#processchatai::script_list ${@0}
|
||||
lpushback,#processchatai::cond_list ${cond}
|
||||
lpushback,#processchatai::register_list {[${@0};${pattern};${cond}]}
|
||||
|
||||
logdetail Chat AI script registered. script: '${@0}', condition: ${cond}, pattern: '${pattern}' [now ?{llen #processchatai::pattern_list} registered]
|
||||
|
||||
return true
|
||||
|
||||
@ -1,114 +1,114 @@
|
||||
|
||||
// ----==== CHAT MESSAGES ====----
|
||||
// -------------------------------------------
|
||||
#script=_onchatmessage
|
||||
// purpose: do something if specific chat messages are recieved.
|
||||
// args:
|
||||
// @def: chat message text
|
||||
// @0: message type id (check ChatMsg enum in src/Client/SharedDefines.h)
|
||||
// @1: language id (also defined in SharedDefines.h), alternatively look up bin/data/scp/language.scp
|
||||
// @2: GUID of the player or creature this msg came from
|
||||
// @3: channel name. empty string if the chat message was not sent in a channel (for example say, yell or whisper)
|
||||
//--------------------------------------------
|
||||
processchatai,{${@0}},{${@1}},{${@2}},{${@3}} ${@def} // this is required for the ChatAI script to work
|
||||
|
||||
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
|
||||
|
||||
// ----==== TELEPORTATION ====----
|
||||
|
||||
#script=_onteleport
|
||||
// @def: [far teleport=true, else false]
|
||||
// @0: [far teleport: map ID, else teleported GUID]
|
||||
// @1: X position
|
||||
// @2: Y position
|
||||
// @3: Z position
|
||||
// @4: Orientation
|
||||
|
||||
//- script content here...
|
||||
|
||||
|
||||
// ----==== GUI RELATED ====----
|
||||
|
||||
#script=_onguiclose
|
||||
// no args. gets called when the GUI is closed.
|
||||
if ?{GetVar #EXITONGUICLOSE}
|
||||
exit
|
||||
endif
|
||||
|
||||
|
||||
// ----==== OBJECT HANDLING ====----
|
||||
|
||||
#script=_onobjectcreate
|
||||
// @def: GUID of created object
|
||||
// @0 TypeID of created object
|
||||
// The object can be accessed with GetName, GetEntry, GetObjectType, GetObjectValue, GetRace, GetClass, ... via the guid
|
||||
|
||||
//- script content here...
|
||||
|
||||
|
||||
|
||||
#script=_onobjectdelete
|
||||
// @def: GUID of deleted object
|
||||
// @0: TypeID of deleted object
|
||||
// @1: [out of range object deletion=true, else false]
|
||||
// The object can be accessed with the object handling functions listed above.
|
||||
// It will be deleted right after handling this script.
|
||||
|
||||
//- script content here...
|
||||
|
||||
|
||||
|
||||
|
||||
// ----==== ENTERING/LEAVING WORLD ====----
|
||||
|
||||
#script=_leaveworld
|
||||
// no args. gets called when the world is left.
|
||||
|
||||
//- script content here...
|
||||
|
||||
|
||||
#script=_enterworld
|
||||
// no args. called when the world is entered
|
||||
log * World entered!
|
||||
say [${@version_short}] login successful.
|
||||
emote 126 // = TEXTEMOTE_READY
|
||||
joinchannel General
|
||||
joinchannel Trade
|
||||
joinchannel LookingForGroup
|
||||
castspell 836 // LoginEffect
|
||||
|
||||
|
||||
|
||||
// ----==== IN-GAME SCRIPT COMMANDS ====----
|
||||
|
||||
#script=_nopermission
|
||||
// this script gets executed if a player tries to give pseuwow a command but is not allowed to
|
||||
// Arguments:
|
||||
// ==========
|
||||
// @0 : name of the player who wanted to execute a command
|
||||
// @1 : permission level of this user
|
||||
// @2 : permission level needed to execute the script
|
||||
// @3 : name of the script that should get executed
|
||||
|
||||
SAY Forget it, ${@0}, you have only permission ${@1} but need ${@2} to run the script '${@3}'
|
||||
LOG Player '${@0}' (p:${@1}) wanted to execute '${@3}' (p:${@2})
|
||||
EMOTE 66 // say NO!
|
||||
|
||||
|
||||
|
||||
// ----==== INTERNAL/MISC ====----
|
||||
|
||||
#script=_onworldsessioncreate
|
||||
// no args. called when an instance of the WorldSession class is created
|
||||
|
||||
//- script content here
|
||||
|
||||
|
||||
#script=_onworldsessiondelete
|
||||
// no args. called when an instance of the WorldSession class is deleted
|
||||
|
||||
//- script content here
|
||||
|
||||
|
||||
|
||||
|
||||
// ----==== CHAT MESSAGES ====----
|
||||
// -------------------------------------------
|
||||
#script=_onchatmessage
|
||||
// purpose: do something if specific chat messages are recieved.
|
||||
// args:
|
||||
// @def: chat message text
|
||||
// @0: message type id (check ChatMsg enum in src/Client/SharedDefines.h)
|
||||
// @1: language id (also defined in SharedDefines.h), alternatively look up bin/data/scp/language.scp
|
||||
// @2: GUID of the player or creature this msg came from
|
||||
// @3: channel name. empty string if the chat message was not sent in a channel (for example say, yell or whisper)
|
||||
//--------------------------------------------
|
||||
processchatai,{${@0}},{${@1}},{${@2}},{${@3}} ${@def} // this is required for the ChatAI script to work
|
||||
|
||||
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
|
||||
|
||||
|
||||
// ----==== TELEPORTATION ====----
|
||||
|
||||
#script=_onteleport
|
||||
// @def: [far teleport=true, else false]
|
||||
// @0: [far teleport: map ID, else teleported GUID]
|
||||
// @1: X position
|
||||
// @2: Y position
|
||||
// @3: Z position
|
||||
// @4: Orientation
|
||||
|
||||
//- script content here...
|
||||
|
||||
|
||||
// ----==== GUI RELATED ====----
|
||||
|
||||
#script=_onguiclose
|
||||
// no args. gets called when the GUI is closed.
|
||||
if ?{GetVar #EXITONGUICLOSE}
|
||||
exit
|
||||
endif
|
||||
|
||||
|
||||
// ----==== OBJECT HANDLING ====----
|
||||
|
||||
#script=_onobjectcreate
|
||||
// @def: GUID of created object
|
||||
// @0 TypeID of created object
|
||||
// The object can be accessed with GetName, GetEntry, GetObjectType, GetObjectValue, GetRace, GetClass, ... via the guid
|
||||
|
||||
//- script content here...
|
||||
|
||||
|
||||
|
||||
#script=_onobjectdelete
|
||||
// @def: GUID of deleted object
|
||||
// @0: TypeID of deleted object
|
||||
// @1: [out of range object deletion=true, else false]
|
||||
// The object can be accessed with the object handling functions listed above.
|
||||
// It will be deleted right after handling this script.
|
||||
|
||||
//- script content here...
|
||||
|
||||
|
||||
|
||||
|
||||
// ----==== ENTERING/LEAVING WORLD ====----
|
||||
|
||||
#script=_leaveworld
|
||||
// no args. gets called when the world is left.
|
||||
|
||||
//- script content here...
|
||||
|
||||
|
||||
#script=_enterworld
|
||||
// no args. called when the world is entered
|
||||
log * World entered!
|
||||
say [${@version_short}] login successful.
|
||||
emote 126 // = TEXTEMOTE_READY
|
||||
joinchannel General
|
||||
joinchannel Trade
|
||||
joinchannel LookingForGroup
|
||||
castspell 836 // LoginEffect
|
||||
|
||||
|
||||
|
||||
// ----==== IN-GAME SCRIPT COMMANDS ====----
|
||||
|
||||
#script=_nopermission
|
||||
// this script gets executed if a player tries to give pseuwow a command but is not allowed to
|
||||
// Arguments:
|
||||
// ==========
|
||||
// @0 : name of the player who wanted to execute a command
|
||||
// @1 : permission level of this user
|
||||
// @2 : permission level needed to execute the script
|
||||
// @3 : name of the script that should get executed
|
||||
|
||||
SAY Forget it, ${@0}, you have only permission ${@1} but need ${@2} to run the script '${@3}'
|
||||
LOG Player '${@0}' (p:${@1}) wanted to execute '${@3}' (p:${@2})
|
||||
EMOTE 66 // say NO!
|
||||
|
||||
|
||||
|
||||
// ----==== INTERNAL/MISC ====----
|
||||
|
||||
#script=_onworldsessioncreate
|
||||
// no args. called when an instance of the WorldSession class is created
|
||||
|
||||
//- script content here
|
||||
|
||||
|
||||
#script=_onworldsessiondelete
|
||||
// no args. called when an instance of the WorldSession class is deleted
|
||||
|
||||
//- script content here
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,176 +1,176 @@
|
||||
// core functions. required by other scripts to run!
|
||||
#onload
|
||||
log * Loading core scripts...
|
||||
#/onload
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
#script=append
|
||||
//--------------------------------------------------------
|
||||
// usage: append text to a string.
|
||||
// args:
|
||||
// @def: text to append
|
||||
// @0: variable to which the text should be appended
|
||||
|
||||
// get the var name if the original variable
|
||||
SET,v #${@caller}::${@0}
|
||||
// if it has not been set before, init it now
|
||||
DEFAULT,${v}
|
||||
// append to the original var. inner ${..} gets the var name, outer ${..} get the value of the var name we just got.
|
||||
SET,${v} ${${v}}${@def}
|
||||
// remove the name placeholder
|
||||
UNSET v
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
#script=exloadscp
|
||||
#permission=255
|
||||
//--------------------------------------------------------
|
||||
if ?{fileexists ${@def}}
|
||||
loadscp,{${@0}} ${@def}
|
||||
else
|
||||
logdebug skipped loading of non-existent file '${@def}'
|
||||
endif
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
#script=loadallscp
|
||||
#permission=255
|
||||
//--------------------------------------------------------
|
||||
LOG * Loading SCP data storages...
|
||||
|
||||
// example:
|
||||
// LOADSCP,test data/test.scp
|
||||
|
||||
// load default databases
|
||||
LOADSCP,class data/scp/class.scp
|
||||
LOADSCP,gender data/scp/gender.scp
|
||||
LOADSCP,language data/scp/language.scp
|
||||
LOADSCP,map data/scp/map.scp
|
||||
LOADSCP,race data/scp/race.scp
|
||||
|
||||
// load extended databases if present.
|
||||
EXLOADSCP,sound data/scp/sound.scp
|
||||
EXLOADSCP,emote data/scp/emote.scp
|
||||
EXLOADSCP,zone data/scp/zone.scp
|
||||
|
||||
LOG * SCP loaded.
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
#script=string_is_command
|
||||
//-------------------------------------------------
|
||||
// purpose: detect if @def might be a server command.
|
||||
|
||||
// split all chars we have set in the config files to a list.
|
||||
lsplit,#CMDCHARLIST ${#OTHER_CMD_CHARS}
|
||||
|
||||
// find out the first char of the string
|
||||
SET,c ?{SUBSTR,1 ${@def}}
|
||||
|
||||
// does the char list contain our first char? if yes it can trigger a server command.
|
||||
if ?{lcontains,#CMDCHARLIST ${c}}
|
||||
unset c
|
||||
return true
|
||||
endif
|
||||
unset c
|
||||
return false
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
#script=normalize_name
|
||||
//--------------------------------------------------------
|
||||
// uppercases first char, lowercases rest
|
||||
set,name ?{uppercase ?{substr,1 ${@def}}}
|
||||
set,len ?{strlen ${@def}}
|
||||
sub,len 1
|
||||
append,name ?{lowercase ?{substr,${len},1 ${@def}}}
|
||||
return ${name}
|
||||
|
||||
//---------------------------------------------------------
|
||||
#script=globname
|
||||
//---------------------------------------------------------
|
||||
// purpose: returns the global name of a variable
|
||||
// args: @def: var name, @0 (optional): name of the intended parent func
|
||||
set,c ?{substr,1 ${@def}}
|
||||
// it is a global var if the varname starts with # or there is no caller script
|
||||
if ?{or,?{equal,# ${c}} ?{not ${@caller}}}
|
||||
return ${@def}
|
||||
endif
|
||||
set,top ${@0}
|
||||
default,top ${@caller}
|
||||
return #${top}::${@def}
|
||||
|
||||
//---------------------------------------------------------
|
||||
#script=sclistname
|
||||
//---------------------------------------------------------
|
||||
// purpose: returns the global name of a script list
|
||||
// args: @def: script name
|
||||
set,c ?{substr,1 ${@def}}
|
||||
// it is a global name already if the script name starts with # or there is no caller script
|
||||
if ?{or,?{equal,# ${c}} ?{not ${@caller}}}
|
||||
return ${@def}
|
||||
endif
|
||||
return #DEFSCRIPT::SCRIPT::${@def}
|
||||
|
||||
//---------------------------------------------------------
|
||||
#script=getvar
|
||||
//---------------------------------------------------------
|
||||
// purpose: returns the value of a variable. if the variable hasnt been set return empty string.
|
||||
set,top ${@caller}
|
||||
default,top #
|
||||
set,v ?{globname,${top} ${@def}}
|
||||
unset top
|
||||
//out getvar: v=${v} -> ${${v}}
|
||||
if ?{isset ${v}}
|
||||
return ${${v}}
|
||||
endif
|
||||
return
|
||||
|
||||
//---------------------------------------------------------
|
||||
#script=reverse
|
||||
//---------------------------------------------------------
|
||||
// purpose: reverse a srtring
|
||||
// args: @def: string to reverse
|
||||
// returns: reversed string
|
||||
|
||||
set,outstr
|
||||
set,elems ?{lsplit,mylist ${@def}}
|
||||
set,i ${elems}
|
||||
loop
|
||||
sub,i 1
|
||||
if ?{equal,${i} -1}
|
||||
exitloop
|
||||
endif
|
||||
append,outstr ?{lindex,mylist ${i}}
|
||||
endloop
|
||||
ldelete mylist
|
||||
return ${outstr}
|
||||
|
||||
//--------------------------------------------------------
|
||||
#script=appenddef
|
||||
//--------------------------------------------------------
|
||||
// purpose: append a line of code to a script
|
||||
// args: @0: script name; @def: code
|
||||
// be sure that the code you append is valid and working DefScript code! (no if/loop block mismatches, etc)
|
||||
// if you need to use { or }, escape them: "appenddef,myscript log Myscript: finished, @def=$\{@def\}"
|
||||
set,sc ?{lowercase ${@0}}
|
||||
if ?{and,{?{strlen ${@def}}} ?{strlen ${sc}}}
|
||||
if ?{not ?{ScriptExists ${sc}}}
|
||||
createdef ${sc}
|
||||
endif
|
||||
|
||||
lpushback,{?{sclistname ${sc}}} ${@def}
|
||||
unset cmd
|
||||
endif
|
||||
|
||||
//---------------------------------------------------------
|
||||
#script=scripthasline
|
||||
//---------------------------------------------------------
|
||||
// purpose: check if a script has a certain line of code (exact match)
|
||||
// args:
|
||||
// @0: script name
|
||||
// @def: line of text to look for
|
||||
|
||||
return ?{lcontains,{?{sclistname ?{lowercase ${@0}}}} ${@def}}
|
||||
|
||||
// core functions. required by other scripts to run!
|
||||
#onload
|
||||
log * Loading core scripts...
|
||||
#/onload
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
#script=append
|
||||
//--------------------------------------------------------
|
||||
// usage: append text to a string.
|
||||
// args:
|
||||
// @def: text to append
|
||||
// @0: variable to which the text should be appended
|
||||
|
||||
// get the var name if the original variable
|
||||
SET,v #${@caller}::${@0}
|
||||
// if it has not been set before, init it now
|
||||
DEFAULT,${v}
|
||||
// append to the original var. inner ${..} gets the var name, outer ${..} get the value of the var name we just got.
|
||||
SET,${v} ${${v}}${@def}
|
||||
// remove the name placeholder
|
||||
UNSET v
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
#script=exloadscp
|
||||
#permission=255
|
||||
//--------------------------------------------------------
|
||||
if ?{fileexists ${@def}}
|
||||
loadscp,{${@0}} ${@def}
|
||||
else
|
||||
logdebug skipped loading of non-existent file '${@def}'
|
||||
endif
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
#script=loadallscp
|
||||
#permission=255
|
||||
//--------------------------------------------------------
|
||||
LOG * Loading SCP data storages...
|
||||
|
||||
// example:
|
||||
// LOADSCP,test data/test.scp
|
||||
|
||||
// load default databases
|
||||
LOADSCP,class data/scp/class.scp
|
||||
LOADSCP,gender data/scp/gender.scp
|
||||
LOADSCP,language data/scp/language.scp
|
||||
LOADSCP,map data/scp/map.scp
|
||||
LOADSCP,race data/scp/race.scp
|
||||
|
||||
// load extended databases if present.
|
||||
EXLOADSCP,sound data/scp/sound.scp
|
||||
EXLOADSCP,emote data/scp/emote.scp
|
||||
EXLOADSCP,zone data/scp/zone.scp
|
||||
|
||||
LOG * SCP loaded.
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
#script=string_is_command
|
||||
//-------------------------------------------------
|
||||
// purpose: detect if @def might be a server command.
|
||||
|
||||
// split all chars we have set in the config files to a list.
|
||||
lsplit,#CMDCHARLIST ${#OTHER_CMD_CHARS}
|
||||
|
||||
// find out the first char of the string
|
||||
SET,c ?{SUBSTR,1 ${@def}}
|
||||
|
||||
// does the char list contain our first char? if yes it can trigger a server command.
|
||||
if ?{lcontains,#CMDCHARLIST ${c}}
|
||||
unset c
|
||||
return true
|
||||
endif
|
||||
unset c
|
||||
return false
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
#script=normalize_name
|
||||
//--------------------------------------------------------
|
||||
// uppercases first char, lowercases rest
|
||||
set,name ?{uppercase ?{substr,1 ${@def}}}
|
||||
set,len ?{strlen ${@def}}
|
||||
sub,len 1
|
||||
append,name ?{lowercase ?{substr,${len},1 ${@def}}}
|
||||
return ${name}
|
||||
|
||||
//---------------------------------------------------------
|
||||
#script=globname
|
||||
//---------------------------------------------------------
|
||||
// purpose: returns the global name of a variable
|
||||
// args: @def: var name, @0 (optional): name of the intended parent func
|
||||
set,c ?{substr,1 ${@def}}
|
||||
// it is a global var if the varname starts with # or there is no caller script
|
||||
if ?{or,?{equal,# ${c}} ?{not ${@caller}}}
|
||||
return ${@def}
|
||||
endif
|
||||
set,top ${@0}
|
||||
default,top ${@caller}
|
||||
return #${top}::${@def}
|
||||
|
||||
//---------------------------------------------------------
|
||||
#script=sclistname
|
||||
//---------------------------------------------------------
|
||||
// purpose: returns the global name of a script list
|
||||
// args: @def: script name
|
||||
set,c ?{substr,1 ${@def}}
|
||||
// it is a global name already if the script name starts with # or there is no caller script
|
||||
if ?{or,?{equal,# ${c}} ?{not ${@caller}}}
|
||||
return ${@def}
|
||||
endif
|
||||
return #DEFSCRIPT::SCRIPT::${@def}
|
||||
|
||||
//---------------------------------------------------------
|
||||
#script=getvar
|
||||
//---------------------------------------------------------
|
||||
// purpose: returns the value of a variable. if the variable hasnt been set return empty string.
|
||||
set,top ${@caller}
|
||||
default,top #
|
||||
set,v ?{globname,${top} ${@def}}
|
||||
unset top
|
||||
//out getvar: v=${v} -> ${${v}}
|
||||
if ?{isset ${v}}
|
||||
return ${${v}}
|
||||
endif
|
||||
return
|
||||
|
||||
//---------------------------------------------------------
|
||||
#script=reverse
|
||||
//---------------------------------------------------------
|
||||
// purpose: reverse a srtring
|
||||
// args: @def: string to reverse
|
||||
// returns: reversed string
|
||||
|
||||
set,outstr
|
||||
set,elems ?{lsplit,mylist ${@def}}
|
||||
set,i ${elems}
|
||||
loop
|
||||
sub,i 1
|
||||
if ?{equal,${i} -1}
|
||||
exitloop
|
||||
endif
|
||||
append,outstr ?{lindex,mylist ${i}}
|
||||
endloop
|
||||
ldelete mylist
|
||||
return ${outstr}
|
||||
|
||||
//--------------------------------------------------------
|
||||
#script=appenddef
|
||||
//--------------------------------------------------------
|
||||
// purpose: append a line of code to a script
|
||||
// args: @0: script name; @def: code
|
||||
// be sure that the code you append is valid and working DefScript code! (no if/loop block mismatches, etc)
|
||||
// if you need to use { or }, escape them: "appenddef,myscript log Myscript: finished, @def=$\{@def\}"
|
||||
set,sc ?{lowercase ${@0}}
|
||||
if ?{and,{?{strlen ${@def}}} ?{strlen ${sc}}}
|
||||
if ?{not ?{ScriptExists ${sc}}}
|
||||
createdef ${sc}
|
||||
endif
|
||||
|
||||
lpushback,{?{sclistname ${sc}}} ${@def}
|
||||
unset cmd
|
||||
endif
|
||||
|
||||
//---------------------------------------------------------
|
||||
#script=scripthasline
|
||||
//---------------------------------------------------------
|
||||
// purpose: check if a script has a certain line of code (exact match)
|
||||
// args:
|
||||
// @0: script name
|
||||
// @def: line of text to look for
|
||||
|
||||
return ?{lcontains,{?{sclistname ?{lowercase ${@0}}}} ${@def}}
|
||||
|
||||
|
||||
@ -1,125 +1,125 @@
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
#script=slap
|
||||
#permission=255
|
||||
//-------------------------------------------------
|
||||
// purpose: let a player fly. (at least works on MaNGOS)
|
||||
// args: @def: player name
|
||||
// returns: guid of the targeted player, else false. empty string if we are not in the world.
|
||||
|
||||
// we can use this script only if we are in the world
|
||||
if ?{not ${@inworld}}
|
||||
logerror Can't slap anything if i am not in the world!
|
||||
return
|
||||
endif
|
||||
|
||||
// normalize player name. first char uppercased, rest lowercased.
|
||||
set,name ?{normalize_name ${@def}}
|
||||
|
||||
// target the player. if targeting was successful, cast spell "Knockback 500".
|
||||
set,t ?{target ${name}}
|
||||
if ${t}
|
||||
logdebug slapping player '${name}'
|
||||
castspell 11027
|
||||
target
|
||||
else
|
||||
logerror Can't target player '${name}'
|
||||
endif
|
||||
|
||||
unset name
|
||||
|
||||
return ${t}
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------
|
||||
#script=toleet
|
||||
//------------------------------------------------
|
||||
// purpose: convert any text into leetspeak [1337sp34k]
|
||||
// args: @def: the text to convert
|
||||
// returns: leetspeak^^
|
||||
|
||||
#onload
|
||||
// this can be used by other scripts to check if we have loaded this script
|
||||
set,#HAVE_LEET true
|
||||
#endonload
|
||||
|
||||
// empty the string where the leet will be stored
|
||||
set,str
|
||||
// total length of the string to convert
|
||||
set,l ?{strlen ${@def}}
|
||||
// position counter
|
||||
set,x 0
|
||||
|
||||
loop
|
||||
|
||||
// check if we have reached the end of the string
|
||||
if ?{bigger,${x} ${l}}
|
||||
exitloop
|
||||
endif
|
||||
|
||||
// c stores current char (@def at position x); c2 is the same char but always lowercased
|
||||
set,c ?{substr,1,${x} ${@def}}
|
||||
set,c2 ?{lowercase ${c}}
|
||||
|
||||
// conversion functions:
|
||||
|
||||
// note that "+" is a variable name here!
|
||||
// it will store the "new" char if c/c2 could be converted
|
||||
|
||||
if ?{equal,${c2} a}
|
||||
set,+ 4
|
||||
endif
|
||||
if ?{equal,${c2} e}
|
||||
set,+ 3
|
||||
endif
|
||||
if ?{equal,${c2} i}
|
||||
set,+ !
|
||||
endif
|
||||
if ?{equal,${c2} l}
|
||||
set,+ 1
|
||||
endif
|
||||
if ?{equal,${c2} t}
|
||||
set,+ 7
|
||||
endif
|
||||
if ?{equal,${c2} s}
|
||||
set,+ 5
|
||||
endif
|
||||
if ?{equal,${c2} o}
|
||||
set,+ 0
|
||||
endif
|
||||
if ?{equal,${c2} f}
|
||||
set,+ ph
|
||||
endif
|
||||
if ?{equal,${c2} h}
|
||||
set,+ #
|
||||
endif
|
||||
if ?{equal,${c} Z}
|
||||
set,+ 7
|
||||
endif
|
||||
if ?{equal,${c} R}
|
||||
set,+ 2
|
||||
endif
|
||||
if ?{equal,${c} B}
|
||||
set,+ <3
|
||||
endif
|
||||
|
||||
// if var "+" is still empty, default it to our current char
|
||||
default,+ ${c}
|
||||
// and append it to the final output
|
||||
append,str ${+}
|
||||
// finally delete it again
|
||||
unset +
|
||||
// and increase the counter by 1
|
||||
add,x 1
|
||||
endloop
|
||||
|
||||
unset l
|
||||
unset x
|
||||
unset c
|
||||
unset c2
|
||||
|
||||
return ${str}
|
||||
|
||||
|
||||
|
||||
|
||||
//-------------------------------------------------
|
||||
#script=slap
|
||||
#permission=255
|
||||
//-------------------------------------------------
|
||||
// purpose: let a player fly. (at least works on MaNGOS)
|
||||
// args: @def: player name
|
||||
// returns: guid of the targeted player, else false. empty string if we are not in the world.
|
||||
|
||||
// we can use this script only if we are in the world
|
||||
if ?{not ${@inworld}}
|
||||
logerror Can't slap anything if i am not in the world!
|
||||
return
|
||||
endif
|
||||
|
||||
// normalize player name. first char uppercased, rest lowercased.
|
||||
set,name ?{normalize_name ${@def}}
|
||||
|
||||
// target the player. if targeting was successful, cast spell "Knockback 500".
|
||||
set,t ?{target ${name}}
|
||||
if ${t}
|
||||
logdebug slapping player '${name}'
|
||||
castspell 11027
|
||||
target
|
||||
else
|
||||
logerror Can't target player '${name}'
|
||||
endif
|
||||
|
||||
unset name
|
||||
|
||||
return ${t}
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------
|
||||
#script=toleet
|
||||
//------------------------------------------------
|
||||
// purpose: convert any text into leetspeak [1337sp34k]
|
||||
// args: @def: the text to convert
|
||||
// returns: leetspeak^^
|
||||
|
||||
#onload
|
||||
// this can be used by other scripts to check if we have loaded this script
|
||||
set,#HAVE_LEET true
|
||||
#endonload
|
||||
|
||||
// empty the string where the leet will be stored
|
||||
set,str
|
||||
// total length of the string to convert
|
||||
set,l ?{strlen ${@def}}
|
||||
// position counter
|
||||
set,x 0
|
||||
|
||||
loop
|
||||
|
||||
// check if we have reached the end of the string
|
||||
if ?{bigger,${x} ${l}}
|
||||
exitloop
|
||||
endif
|
||||
|
||||
// c stores current char (@def at position x); c2 is the same char but always lowercased
|
||||
set,c ?{substr,1,${x} ${@def}}
|
||||
set,c2 ?{lowercase ${c}}
|
||||
|
||||
// conversion functions:
|
||||
|
||||
// note that "+" is a variable name here!
|
||||
// it will store the "new" char if c/c2 could be converted
|
||||
|
||||
if ?{equal,${c2} a}
|
||||
set,+ 4
|
||||
endif
|
||||
if ?{equal,${c2} e}
|
||||
set,+ 3
|
||||
endif
|
||||
if ?{equal,${c2} i}
|
||||
set,+ !
|
||||
endif
|
||||
if ?{equal,${c2} l}
|
||||
set,+ 1
|
||||
endif
|
||||
if ?{equal,${c2} t}
|
||||
set,+ 7
|
||||
endif
|
||||
if ?{equal,${c2} s}
|
||||
set,+ 5
|
||||
endif
|
||||
if ?{equal,${c2} o}
|
||||
set,+ 0
|
||||
endif
|
||||
if ?{equal,${c2} f}
|
||||
set,+ ph
|
||||
endif
|
||||
if ?{equal,${c2} h}
|
||||
set,+ #
|
||||
endif
|
||||
if ?{equal,${c} Z}
|
||||
set,+ 7
|
||||
endif
|
||||
if ?{equal,${c} R}
|
||||
set,+ 2
|
||||
endif
|
||||
if ?{equal,${c} B}
|
||||
set,+ <3
|
||||
endif
|
||||
|
||||
// if var "+" is still empty, default it to our current char
|
||||
default,+ ${c}
|
||||
// and append it to the final output
|
||||
append,str ${+}
|
||||
// finally delete it again
|
||||
unset +
|
||||
// and increase the counter by 1
|
||||
add,x 1
|
||||
endloop
|
||||
|
||||
unset l
|
||||
unset x
|
||||
unset c
|
||||
unset c2
|
||||
|
||||
return ${str}
|
||||
|
||||
|
||||
|
||||
@ -1,150 +1,150 @@
|
||||
|
||||
#script=hookhelper
|
||||
#onload
|
||||
set,CurScript
|
||||
#/onload
|
||||
|
||||
#script=IsHooked
|
||||
// @def: script name
|
||||
// [@0: hook name / name of script that hooked script in @def]
|
||||
set,sc ${@0}
|
||||
default,sc ${@caller}
|
||||
return ?{ScriptHasLine,{${@def}} #tag:hook:${sc}}
|
||||
|
||||
#script=HookStart
|
||||
// @def: script name
|
||||
// [@0: calling script]
|
||||
set,c ${@0}
|
||||
default,c ${@caller}
|
||||
appenddef,{${@def}} #tag:hook:${c}
|
||||
set,{#hookhelper::CurScript} ${@def}
|
||||
|
||||
#script=HookEnd
|
||||
// [@def: name of script that was hooked]
|
||||
// [@0: name of calling script]
|
||||
set,sc ${@def}
|
||||
default,sc ${#hookhelper::CurScript}
|
||||
set,c ${@0}
|
||||
default,c ${@caller}
|
||||
appenddef,{${sc}} #tag:hook-end
|
||||
set,#hookhelper::CurScript
|
||||
unset ${sc}
|
||||
unset sc
|
||||
|
||||
#script=HookAdd
|
||||
// @def: script line
|
||||
// [@0: script name. default: last script passed to HookStart]
|
||||
set,sc ${@0}
|
||||
default,sc ${#hookhelper::CurScript}
|
||||
if ?{not ?{strlen ${sc}}}
|
||||
return
|
||||
endif
|
||||
appenddef,{${sc}} ${@def}
|
||||
unset sc
|
||||
|
||||
#script=HookAddList
|
||||
// @def: list name
|
||||
// [@0: script name. default: last script passed to HookStart]
|
||||
// [@1: name of calling script]
|
||||
set,sc ${@0}
|
||||
set,c ${@1}
|
||||
default,c ${@caller}
|
||||
set,l ?{globname,{${c}} ${@def}}
|
||||
default,sc ${#hookhelper::CurScript}
|
||||
if ?{not ?{strlen ${sc}}}
|
||||
return
|
||||
endif
|
||||
set,i 0
|
||||
loop
|
||||
if ?{bigger_eq,${i} ?{llen ${l}}}
|
||||
exitloop
|
||||
endif
|
||||
HookAdd,{${sc}} ?{lindex,{${l}} ${i}}
|
||||
add,i 1
|
||||
endloop
|
||||
unset sc
|
||||
|
||||
#script=HookStartOpcode
|
||||
// @def: opcode name
|
||||
// [@0: calling script]
|
||||
set,c ${@0}
|
||||
default,c ${@caller}
|
||||
HookStart,{${c}} OPCODE::${@def}
|
||||
|
||||
#script=UnHook
|
||||
// @def: name of script where to remove hook from
|
||||
// [@0: hook name (usually name of script that installed the hook). default: name of calling script]
|
||||
set,target ?{lowercase ${@def}}
|
||||
if ?{not ?{scriptexists ${target}}}
|
||||
logerror UnHook called for nonexisting script '${target}' by '${@caller}'
|
||||
endif
|
||||
set,sc ${@0}
|
||||
default,sc ${@caller}
|
||||
set,sc ?{lowercase ${sc}}
|
||||
set,sl ?{sclistname ${target}}
|
||||
set,hn #tag:hook:${sc}
|
||||
set,hne #tag:hook-end
|
||||
//logdebug -- sl='${sl}' hn='${hn}' hne='${hne}'
|
||||
loop
|
||||
if ?{not ?{IsHooked,{${sc}} ${target}}}
|
||||
//logdebug -- unhook done
|
||||
exitloop
|
||||
endif
|
||||
set,p ?{lfind,{${sl}} ${hn}}
|
||||
set,line ?{lindex,{${sl}} ${p}}
|
||||
//logdebug -- line[${p}] = ${line}
|
||||
if ?{strlen ${p}} // p is empty string if the line wasnt found
|
||||
loop
|
||||
set,line2 ?{lerase,{${sl}} ${p}}
|
||||
//logdebug -- removed: '${line2}'
|
||||
if ?{equal,{${line2}} ${hne}}
|
||||
exitloop
|
||||
endif
|
||||
endloop
|
||||
endif
|
||||
endloop
|
||||
unset sl
|
||||
unset hn
|
||||
unset hne
|
||||
unset sc
|
||||
|
||||
#script=UnHookOpcode
|
||||
// @def: opcode name
|
||||
// [@0: name of calling script]
|
||||
set,sc ${@0}
|
||||
default,sc ${@caller}
|
||||
UnHook,{${sc}} OPCODE::${@def}
|
||||
|
||||
#script=UnHookAll
|
||||
// @def: name of script to remove all hooks from
|
||||
// [@0: name of calling script]
|
||||
set,sc ${@0}
|
||||
set,sl ?{sclistname ${@def}}
|
||||
set,hn #tag:hook:
|
||||
set,hne #tag:hook-end
|
||||
set,i 0
|
||||
set,hookcode false
|
||||
loop
|
||||
set,erased false
|
||||
if ?{bigger_eq,${i} ?{llen ${sl}}}
|
||||
exitloop
|
||||
endif
|
||||
set,line ?{lindex,{${sl}} ${i}}
|
||||
if ?{equal,{${hn}} ?{substr,?{strlen ${hn}} ${line}}}
|
||||
set,hookcode true
|
||||
else
|
||||
if ?{equal,{${hne}} ?{substr,?{strlen ${hn}} ${line}}}
|
||||
lerase,{${sl}} ${i}
|
||||
set,hookcode false
|
||||
set,erased true
|
||||
endif
|
||||
endif
|
||||
|
||||
if ${hookcode}
|
||||
lerase,{${sl}} ${i}
|
||||
set,erased true
|
||||
endif
|
||||
if ?{not ${erased}}
|
||||
add,i 1
|
||||
endif
|
||||
endloop
|
||||
|
||||
#script=hookhelper
|
||||
#onload
|
||||
set,CurScript
|
||||
#/onload
|
||||
|
||||
#script=IsHooked
|
||||
// @def: script name
|
||||
// [@0: hook name / name of script that hooked script in @def]
|
||||
set,sc ${@0}
|
||||
default,sc ${@caller}
|
||||
return ?{ScriptHasLine,{${@def}} #tag:hook:${sc}}
|
||||
|
||||
#script=HookStart
|
||||
// @def: script name
|
||||
// [@0: calling script]
|
||||
set,c ${@0}
|
||||
default,c ${@caller}
|
||||
appenddef,{${@def}} #tag:hook:${c}
|
||||
set,{#hookhelper::CurScript} ${@def}
|
||||
|
||||
#script=HookEnd
|
||||
// [@def: name of script that was hooked]
|
||||
// [@0: name of calling script]
|
||||
set,sc ${@def}
|
||||
default,sc ${#hookhelper::CurScript}
|
||||
set,c ${@0}
|
||||
default,c ${@caller}
|
||||
appenddef,{${sc}} #tag:hook-end
|
||||
set,#hookhelper::CurScript
|
||||
unset ${sc}
|
||||
unset sc
|
||||
|
||||
#script=HookAdd
|
||||
// @def: script line
|
||||
// [@0: script name. default: last script passed to HookStart]
|
||||
set,sc ${@0}
|
||||
default,sc ${#hookhelper::CurScript}
|
||||
if ?{not ?{strlen ${sc}}}
|
||||
return
|
||||
endif
|
||||
appenddef,{${sc}} ${@def}
|
||||
unset sc
|
||||
|
||||
#script=HookAddList
|
||||
// @def: list name
|
||||
// [@0: script name. default: last script passed to HookStart]
|
||||
// [@1: name of calling script]
|
||||
set,sc ${@0}
|
||||
set,c ${@1}
|
||||
default,c ${@caller}
|
||||
set,l ?{globname,{${c}} ${@def}}
|
||||
default,sc ${#hookhelper::CurScript}
|
||||
if ?{not ?{strlen ${sc}}}
|
||||
return
|
||||
endif
|
||||
set,i 0
|
||||
loop
|
||||
if ?{bigger_eq,${i} ?{llen ${l}}}
|
||||
exitloop
|
||||
endif
|
||||
HookAdd,{${sc}} ?{lindex,{${l}} ${i}}
|
||||
add,i 1
|
||||
endloop
|
||||
unset sc
|
||||
|
||||
#script=HookStartOpcode
|
||||
// @def: opcode name
|
||||
// [@0: calling script]
|
||||
set,c ${@0}
|
||||
default,c ${@caller}
|
||||
HookStart,{${c}} OPCODE::${@def}
|
||||
|
||||
#script=UnHook
|
||||
// @def: name of script where to remove hook from
|
||||
// [@0: hook name (usually name of script that installed the hook). default: name of calling script]
|
||||
set,target ?{lowercase ${@def}}
|
||||
if ?{not ?{scriptexists ${target}}}
|
||||
logerror UnHook called for nonexisting script '${target}' by '${@caller}'
|
||||
endif
|
||||
set,sc ${@0}
|
||||
default,sc ${@caller}
|
||||
set,sc ?{lowercase ${sc}}
|
||||
set,sl ?{sclistname ${target}}
|
||||
set,hn #tag:hook:${sc}
|
||||
set,hne #tag:hook-end
|
||||
//logdebug -- sl='${sl}' hn='${hn}' hne='${hne}'
|
||||
loop
|
||||
if ?{not ?{IsHooked,{${sc}} ${target}}}
|
||||
//logdebug -- unhook done
|
||||
exitloop
|
||||
endif
|
||||
set,p ?{lfind,{${sl}} ${hn}}
|
||||
set,line ?{lindex,{${sl}} ${p}}
|
||||
//logdebug -- line[${p}] = ${line}
|
||||
if ?{strlen ${p}} // p is empty string if the line wasnt found
|
||||
loop
|
||||
set,line2 ?{lerase,{${sl}} ${p}}
|
||||
//logdebug -- removed: '${line2}'
|
||||
if ?{equal,{${line2}} ${hne}}
|
||||
exitloop
|
||||
endif
|
||||
endloop
|
||||
endif
|
||||
endloop
|
||||
unset sl
|
||||
unset hn
|
||||
unset hne
|
||||
unset sc
|
||||
|
||||
#script=UnHookOpcode
|
||||
// @def: opcode name
|
||||
// [@0: name of calling script]
|
||||
set,sc ${@0}
|
||||
default,sc ${@caller}
|
||||
UnHook,{${sc}} OPCODE::${@def}
|
||||
|
||||
#script=UnHookAll
|
||||
// @def: name of script to remove all hooks from
|
||||
// [@0: name of calling script]
|
||||
set,sc ${@0}
|
||||
set,sl ?{sclistname ${@def}}
|
||||
set,hn #tag:hook:
|
||||
set,hne #tag:hook-end
|
||||
set,i 0
|
||||
set,hookcode false
|
||||
loop
|
||||
set,erased false
|
||||
if ?{bigger_eq,${i} ?{llen ${sl}}}
|
||||
exitloop
|
||||
endif
|
||||
set,line ?{lindex,{${sl}} ${i}}
|
||||
if ?{equal,{${hn}} ?{substr,?{strlen ${hn}} ${line}}}
|
||||
set,hookcode true
|
||||
else
|
||||
if ?{equal,{${hne}} ?{substr,?{strlen ${hn}} ${line}}}
|
||||
lerase,{${sl}} ${i}
|
||||
set,hookcode false
|
||||
set,erased true
|
||||
endif
|
||||
endif
|
||||
|
||||
if ${hookcode}
|
||||
lerase,{${sl}} ${i}
|
||||
set,erased true
|
||||
endif
|
||||
if ?{not ${erased}}
|
||||
add,i 1
|
||||
endif
|
||||
endloop
|
||||
|
||||
@ -1,118 +1,118 @@
|
||||
// scripts used for configuration! DO NOT MODIFY unless you know what you do!!
|
||||
|
||||
#onload
|
||||
log * Loading core scripts (internal config)...
|
||||
#/onload
|
||||
|
||||
//--------------------------------------------------------
|
||||
#script=exit
|
||||
#permission=255
|
||||
//--------------------------------------------------------
|
||||
// just a name alternative
|
||||
QUIT
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
#script=quit
|
||||
#permission=255
|
||||
//--------------------------------------------------------
|
||||
// quit PseuWoW, say goodbye when logged in
|
||||
IF ${@inworld}
|
||||
SAY Terminating proc...
|
||||
ENDIF
|
||||
SHDN
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
#script=cleanupvars
|
||||
//-----------------------------------------------
|
||||
// purpose: unset all variables that could be abused by someone
|
||||
LOGDETAIL * Cleaning up variables...
|
||||
UNSET #ACCPASS
|
||||
UNSET #ACCNAME
|
||||
LOGDETAIL * Dangerous variables removed.
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
#script=config
|
||||
#permission=255
|
||||
//-----------------------------------------------
|
||||
#onload
|
||||
// create empty variable. stores if config script was already run successfully once.
|
||||
SET,DONE
|
||||
#/onload
|
||||
// Load all conf files from directory /conf/
|
||||
// get all *.conf file names from /conf/ directory, store the names in list 'fl' and the amount in 'fcount'
|
||||
LOG ** Configuring PseuWoW...
|
||||
SET,fcount ?{LGETFILES,fl,conf conf}
|
||||
// sort the list, load conf files alphabetically.
|
||||
LSORT fl
|
||||
|
||||
IF ?{NOT ${fcount}}
|
||||
LOGERROR No conf file found! Can't load.
|
||||
RETURN
|
||||
ENDIF
|
||||
|
||||
LOG * Loading ${fcount} conf files.
|
||||
// iterate over all files and load them; if counter i is equal to the amount of files we are done.
|
||||
SET,i 0
|
||||
LOOP
|
||||
IF ?{EQUAL,${i} ${fcount}}
|
||||
EXITLOOP
|
||||
ENDIF
|
||||
SET,fn ?{LINDEX,fl ${i}}
|
||||
LOG * Loading conf file [ ${fn} ]
|
||||
LOADCONF ${fn}
|
||||
ADD,i 1
|
||||
ENDLOOP
|
||||
|
||||
UNSET fcount
|
||||
UNSET i
|
||||
UNSET fn
|
||||
LDELETE fl
|
||||
|
||||
// Apply the configuration
|
||||
APPLYCONF
|
||||
LOG * Configuration applied.
|
||||
|
||||
// Apply user permissions
|
||||
APPLYPERMISSIONS
|
||||
|
||||
// remove dangerous variables
|
||||
CLEANUPVARS
|
||||
|
||||
// set permissions for internal functions
|
||||
INTERNAL_PERM
|
||||
|
||||
// if its not set in the conf file, default it to "." (WoWEmu & MaNGOS style)
|
||||
DEFAULT,#CMDCHAR .
|
||||
|
||||
LOG ** All Config done.
|
||||
SET,DONE true
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
#script=internal_perm
|
||||
#permission=255
|
||||
//--------------------------------------------------
|
||||
// purpose: set script permissions for internal functions that cant be set otherwise.
|
||||
// if you don't set a permission for a script manually, it will have permission 255 (highest)
|
||||
|
||||
LOG * Assigning permissions for internal functions...
|
||||
// emotes are hard to abuse, allow for everyone
|
||||
setscriptpermission,emote 0
|
||||
// ... set more permissions here ...
|
||||
|
||||
|
||||
// this dummy script does nothing actually but since its loaded last in this file it causes the config
|
||||
// script to be run before all .def files are loaded
|
||||
// (this is important for scripts that depend on the config already existing during load-time)
|
||||
//-------------------------------------------------
|
||||
#script=dummy
|
||||
//-------------------------------------------------
|
||||
#onload
|
||||
if ?{not ${#config::DONE}}
|
||||
config
|
||||
endif
|
||||
#/onload
|
||||
|
||||
// scripts used for configuration! DO NOT MODIFY unless you know what you do!!
|
||||
|
||||
#onload
|
||||
log * Loading core scripts (internal config)...
|
||||
#/onload
|
||||
|
||||
//--------------------------------------------------------
|
||||
#script=exit
|
||||
#permission=255
|
||||
//--------------------------------------------------------
|
||||
// just a name alternative
|
||||
QUIT
|
||||
|
||||
|
||||
//--------------------------------------------------------
|
||||
#script=quit
|
||||
#permission=255
|
||||
//--------------------------------------------------------
|
||||
// quit PseuWoW, say goodbye when logged in
|
||||
IF ${@inworld}
|
||||
SAY Terminating proc...
|
||||
ENDIF
|
||||
SHDN
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
#script=cleanupvars
|
||||
//-----------------------------------------------
|
||||
// purpose: unset all variables that could be abused by someone
|
||||
LOGDETAIL * Cleaning up variables...
|
||||
UNSET #ACCPASS
|
||||
UNSET #ACCNAME
|
||||
LOGDETAIL * Dangerous variables removed.
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
#script=config
|
||||
#permission=255
|
||||
//-----------------------------------------------
|
||||
#onload
|
||||
// create empty variable. stores if config script was already run successfully once.
|
||||
SET,DONE
|
||||
#/onload
|
||||
// Load all conf files from directory /conf/
|
||||
// get all *.conf file names from /conf/ directory, store the names in list 'fl' and the amount in 'fcount'
|
||||
LOG ** Configuring PseuWoW...
|
||||
SET,fcount ?{LGETFILES,fl,conf conf}
|
||||
// sort the list, load conf files alphabetically.
|
||||
LSORT fl
|
||||
|
||||
IF ?{NOT ${fcount}}
|
||||
LOGERROR No conf file found! Can't load.
|
||||
RETURN
|
||||
ENDIF
|
||||
|
||||
LOG * Loading ${fcount} conf files.
|
||||
// iterate over all files and load them; if counter i is equal to the amount of files we are done.
|
||||
SET,i 0
|
||||
LOOP
|
||||
IF ?{EQUAL,${i} ${fcount}}
|
||||
EXITLOOP
|
||||
ENDIF
|
||||
SET,fn ?{LINDEX,fl ${i}}
|
||||
LOG * Loading conf file [ ${fn} ]
|
||||
LOADCONF ${fn}
|
||||
ADD,i 1
|
||||
ENDLOOP
|
||||
|
||||
UNSET fcount
|
||||
UNSET i
|
||||
UNSET fn
|
||||
LDELETE fl
|
||||
|
||||
// Apply the configuration
|
||||
APPLYCONF
|
||||
LOG * Configuration applied.
|
||||
|
||||
// Apply user permissions
|
||||
APPLYPERMISSIONS
|
||||
|
||||
// remove dangerous variables
|
||||
CLEANUPVARS
|
||||
|
||||
// set permissions for internal functions
|
||||
INTERNAL_PERM
|
||||
|
||||
// if its not set in the conf file, default it to "." (WoWEmu & MaNGOS style)
|
||||
DEFAULT,#CMDCHAR .
|
||||
|
||||
LOG ** All Config done.
|
||||
SET,DONE true
|
||||
|
||||
|
||||
//--------------------------------------------------
|
||||
#script=internal_perm
|
||||
#permission=255
|
||||
//--------------------------------------------------
|
||||
// purpose: set script permissions for internal functions that cant be set otherwise.
|
||||
// if you don't set a permission for a script manually, it will have permission 255 (highest)
|
||||
|
||||
LOG * Assigning permissions for internal functions...
|
||||
// emotes are hard to abuse, allow for everyone
|
||||
setscriptpermission,emote 0
|
||||
// ... set more permissions here ...
|
||||
|
||||
|
||||
// this dummy script does nothing actually but since its loaded last in this file it causes the config
|
||||
// script to be run before all .def files are loaded
|
||||
// (this is important for scripts that depend on the config already existing during load-time)
|
||||
//-------------------------------------------------
|
||||
#script=dummy
|
||||
//-------------------------------------------------
|
||||
#onload
|
||||
if ?{not ${#config::DONE}}
|
||||
config
|
||||
endif
|
||||
#/onload
|
||||
|
||||
|
||||
@ -1,136 +1,136 @@
|
||||
|
||||
|
||||
//--------------------------------------------
|
||||
#script=lcontains
|
||||
//--------------------------------------------
|
||||
// return true if any list element matches @def, else return false.
|
||||
// @0: list name, @def: search string
|
||||
|
||||
set,i 0
|
||||
set,l ?{globname,{${@caller}} ${@0}}
|
||||
|
||||
if ?{not ?{llen ${l}}}
|
||||
return
|
||||
endif
|
||||
|
||||
set,result false
|
||||
loop
|
||||
if ?{equal,${i} ?{llen ${l}}}
|
||||
exitloop
|
||||
endif
|
||||
set,elem ?{lindex,{${l}} ${i}}
|
||||
if ?{equal,{${elem}} ${@def}}
|
||||
set,result true
|
||||
exitloop
|
||||
endif
|
||||
add,i 1
|
||||
endloop
|
||||
unset i
|
||||
unset l
|
||||
unset elem
|
||||
return ${result}
|
||||
|
||||
|
||||
// -----------------------------------------
|
||||
#script=lcontains_ext
|
||||
// -----------------------------------------
|
||||
// returns the amount of matched substrings of @def in list @0.
|
||||
// default delimiter is space, override with @1.
|
||||
// by default, any char in @1 serves as delimiter.
|
||||
// if you set @2 to true, the exact string @1 is used as delimiter (no default is set)
|
||||
// to check for individual chars in @def, use the following: "lcontains_ex,<list>,,true string_of_chars_for_example"
|
||||
|
||||
set,i 0
|
||||
set,j 0
|
||||
set,l ?{globname,{${@caller}} ${@0}}
|
||||
set,delim ${@1}
|
||||
|
||||
if ${@2}
|
||||
set,engine lsplit
|
||||
else
|
||||
set,engine lcsplit
|
||||
// take care of the whitespaces: we use space as delimiter!
|
||||
default,delim { }
|
||||
endif
|
||||
|
||||
${engine},myl,{${delim}} ${@def}
|
||||
|
||||
// list to check must at least contain 1 element
|
||||
if ?{not ?{llen ${l}}}
|
||||
return 0
|
||||
endif
|
||||
|
||||
// and our pattern list must contain 1 element also
|
||||
if ?{not ?{llen myl}}
|
||||
return 0
|
||||
endif
|
||||
|
||||
set,result 0
|
||||
|
||||
loop
|
||||
if ?{equal,${i} ?{llen ${l}}}
|
||||
exitloop
|
||||
endif
|
||||
set,elem ?{lindex,{${l}} ${i}}
|
||||
set,j 0
|
||||
loop
|
||||
if ?{equal,${j} ?{llen myl}}
|
||||
exitloop
|
||||
endif
|
||||
set,myelem ?{lindex,myl ${j}}
|
||||
if ?{equal,{${elem}} ${myelem}}
|
||||
add,result 1
|
||||
endif
|
||||
add,j 1
|
||||
endloop
|
||||
add,i 1
|
||||
endloop
|
||||
|
||||
unset i
|
||||
unset j
|
||||
unset l
|
||||
unset engine
|
||||
unset elem
|
||||
unset myelem
|
||||
ldelete myl
|
||||
unset delim
|
||||
|
||||
return ${result}
|
||||
|
||||
|
||||
//--------------------------------------------
|
||||
#script=lfind
|
||||
//--------------------------------------------
|
||||
// return the position of the first element matching @def
|
||||
// @0: list name, @def: search string
|
||||
// @1: ignore case?
|
||||
// if nothing is found, return empty string
|
||||
|
||||
set,i 0
|
||||
set,l ?{globname,{${@caller}} ${@0}}
|
||||
|
||||
if ?{not ?{llen ${l}}}
|
||||
return
|
||||
endif
|
||||
|
||||
set,result
|
||||
loop
|
||||
if ?{equal,${i} ?{llen ${l}}}
|
||||
exitloop
|
||||
endif
|
||||
set,elem ?{lindex,{${l}} ${i}}
|
||||
if ${@1}
|
||||
set,eq ?{equal,{?{lowercase ${elem}}} ?{lowercase ${@def}}}
|
||||
else
|
||||
set,eq ?{equal,{${elem}} ${@def}}
|
||||
endif
|
||||
if ${eq}
|
||||
set,result ${i}
|
||||
exitloop
|
||||
endif
|
||||
add,i 1
|
||||
endloop
|
||||
unset i
|
||||
unset l
|
||||
unset elem
|
||||
return ${result}
|
||||
|
||||
|
||||
//--------------------------------------------
|
||||
#script=lcontains
|
||||
//--------------------------------------------
|
||||
// return true if any list element matches @def, else return false.
|
||||
// @0: list name, @def: search string
|
||||
|
||||
set,i 0
|
||||
set,l ?{globname,{${@caller}} ${@0}}
|
||||
|
||||
if ?{not ?{llen ${l}}}
|
||||
return
|
||||
endif
|
||||
|
||||
set,result false
|
||||
loop
|
||||
if ?{equal,${i} ?{llen ${l}}}
|
||||
exitloop
|
||||
endif
|
||||
set,elem ?{lindex,{${l}} ${i}}
|
||||
if ?{equal,{${elem}} ${@def}}
|
||||
set,result true
|
||||
exitloop
|
||||
endif
|
||||
add,i 1
|
||||
endloop
|
||||
unset i
|
||||
unset l
|
||||
unset elem
|
||||
return ${result}
|
||||
|
||||
|
||||
// -----------------------------------------
|
||||
#script=lcontains_ext
|
||||
// -----------------------------------------
|
||||
// returns the amount of matched substrings of @def in list @0.
|
||||
// default delimiter is space, override with @1.
|
||||
// by default, any char in @1 serves as delimiter.
|
||||
// if you set @2 to true, the exact string @1 is used as delimiter (no default is set)
|
||||
// to check for individual chars in @def, use the following: "lcontains_ex,<list>,,true string_of_chars_for_example"
|
||||
|
||||
set,i 0
|
||||
set,j 0
|
||||
set,l ?{globname,{${@caller}} ${@0}}
|
||||
set,delim ${@1}
|
||||
|
||||
if ${@2}
|
||||
set,engine lsplit
|
||||
else
|
||||
set,engine lcsplit
|
||||
// take care of the whitespaces: we use space as delimiter!
|
||||
default,delim { }
|
||||
endif
|
||||
|
||||
${engine},myl,{${delim}} ${@def}
|
||||
|
||||
// list to check must at least contain 1 element
|
||||
if ?{not ?{llen ${l}}}
|
||||
return 0
|
||||
endif
|
||||
|
||||
// and our pattern list must contain 1 element also
|
||||
if ?{not ?{llen myl}}
|
||||
return 0
|
||||
endif
|
||||
|
||||
set,result 0
|
||||
|
||||
loop
|
||||
if ?{equal,${i} ?{llen ${l}}}
|
||||
exitloop
|
||||
endif
|
||||
set,elem ?{lindex,{${l}} ${i}}
|
||||
set,j 0
|
||||
loop
|
||||
if ?{equal,${j} ?{llen myl}}
|
||||
exitloop
|
||||
endif
|
||||
set,myelem ?{lindex,myl ${j}}
|
||||
if ?{equal,{${elem}} ${myelem}}
|
||||
add,result 1
|
||||
endif
|
||||
add,j 1
|
||||
endloop
|
||||
add,i 1
|
||||
endloop
|
||||
|
||||
unset i
|
||||
unset j
|
||||
unset l
|
||||
unset engine
|
||||
unset elem
|
||||
unset myelem
|
||||
ldelete myl
|
||||
unset delim
|
||||
|
||||
return ${result}
|
||||
|
||||
|
||||
//--------------------------------------------
|
||||
#script=lfind
|
||||
//--------------------------------------------
|
||||
// return the position of the first element matching @def
|
||||
// @0: list name, @def: search string
|
||||
// @1: ignore case?
|
||||
// if nothing is found, return empty string
|
||||
|
||||
set,i 0
|
||||
set,l ?{globname,{${@caller}} ${@0}}
|
||||
|
||||
if ?{not ?{llen ${l}}}
|
||||
return
|
||||
endif
|
||||
|
||||
set,result
|
||||
loop
|
||||
if ?{equal,${i} ?{llen ${l}}}
|
||||
exitloop
|
||||
endif
|
||||
set,elem ?{lindex,{${l}} ${i}}
|
||||
if ${@1}
|
||||
set,eq ?{equal,{?{lowercase ${elem}}} ?{lowercase ${@def}}}
|
||||
else
|
||||
set,eq ?{equal,{${elem}} ${@def}}
|
||||
endif
|
||||
if ${eq}
|
||||
set,result ${i}
|
||||
exitloop
|
||||
endif
|
||||
add,i 1
|
||||
endloop
|
||||
unset i
|
||||
unset l
|
||||
unset elem
|
||||
return ${result}
|
||||
|
||||
@ -1,57 +1,57 @@
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
#script=getchatitem
|
||||
#permission=255
|
||||
//-----------------------------------------------
|
||||
// expected args:
|
||||
// @def: item id
|
||||
// @0 (optional): color (in RGB hex format: 00FF00 = pure green)
|
||||
// returns: clickable item link to use it chat messages
|
||||
|
||||
SET,i ${@def}
|
||||
SET,color ${@0}
|
||||
DEFAULT,i 0
|
||||
TOINT,i ${i}
|
||||
DEFAULT,color 6679FF
|
||||
SET,link |cff${color}|Hitem:${i}:0:0:0:0:0:0:0|h[Item ${i}]|h|r
|
||||
|
||||
UNSET i
|
||||
UNSET color
|
||||
|
||||
RETURN ${link}
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
#script=makechatitem
|
||||
#permission=255
|
||||
//-----------------------------------------------
|
||||
// purpose: write the text of a clickable item link into a variable
|
||||
// expected args:
|
||||
// @def: item id
|
||||
// @0: variable name to write into
|
||||
// @1 (optional): color (in hex format: 00FF00 = pure green)
|
||||
SET,v #${@caller}::${target}
|
||||
SET,{${v}} ?{getchatitem,{${@1}} ${@def}}
|
||||
UNSET v
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
#script=outv
|
||||
#permission=0
|
||||
//-----------------------------------------------
|
||||
// purpose: output a variable's value to the console.
|
||||
// usage: "outv x"
|
||||
|
||||
SET,vn #${@caller}::${@def}
|
||||
|
||||
IF ?{NOT ?{ISSET ${vn}}}
|
||||
OUT * Var '${@def}' not defined.
|
||||
RETURN
|
||||
ENDIF
|
||||
|
||||
SET,vv ${${vn}}
|
||||
OUT * Var '${@def}' = '${vv}'
|
||||
|
||||
UNSET vv
|
||||
UNSET vn
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
#script=getchatitem
|
||||
#permission=255
|
||||
//-----------------------------------------------
|
||||
// expected args:
|
||||
// @def: item id
|
||||
// @0 (optional): color (in RGB hex format: 00FF00 = pure green)
|
||||
// returns: clickable item link to use it chat messages
|
||||
|
||||
SET,i ${@def}
|
||||
SET,color ${@0}
|
||||
DEFAULT,i 0
|
||||
TOINT,i ${i}
|
||||
DEFAULT,color 6679FF
|
||||
SET,link |cff${color}|Hitem:${i}:0:0:0:0:0:0:0|h[Item ${i}]|h|r
|
||||
|
||||
UNSET i
|
||||
UNSET color
|
||||
|
||||
RETURN ${link}
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
#script=makechatitem
|
||||
#permission=255
|
||||
//-----------------------------------------------
|
||||
// purpose: write the text of a clickable item link into a variable
|
||||
// expected args:
|
||||
// @def: item id
|
||||
// @0: variable name to write into
|
||||
// @1 (optional): color (in hex format: 00FF00 = pure green)
|
||||
SET,v #${@caller}::${target}
|
||||
SET,{${v}} ?{getchatitem,{${@1}} ${@def}}
|
||||
UNSET v
|
||||
|
||||
|
||||
//-----------------------------------------------
|
||||
#script=outv
|
||||
#permission=0
|
||||
//-----------------------------------------------
|
||||
// purpose: output a variable's value to the console.
|
||||
// usage: "outv x"
|
||||
|
||||
SET,vn #${@caller}::${@def}
|
||||
|
||||
IF ?{NOT ?{ISSET ${vn}}}
|
||||
OUT * Var '${@def}' not defined.
|
||||
RETURN
|
||||
ENDIF
|
||||
|
||||
SET,vv ${${vn}}
|
||||
OUT * Var '${@def}' = '${vv}'
|
||||
|
||||
UNSET vv
|
||||
UNSET vn
|
||||
|
||||
@ -1,40 +1,40 @@
|
||||
// example file. wrap a few functions together.
|
||||
|
||||
//------------------------------------------------
|
||||
#script=gc
|
||||
#permission=0
|
||||
//------------------------------------------------
|
||||
// example script to write into channel "generalchat"
|
||||
// usage: "gc bla bla..."
|
||||
chan,generalchat ${@def}
|
||||
|
||||
|
||||
//------------------------------------------------
|
||||
#script=gcl
|
||||
#permission=0
|
||||
//------------------------------------------------
|
||||
// write leetspeak to channel generalchat (see "gc" script)
|
||||
// usage: "gcl moo, cow syndrome!"
|
||||
gc ?{toleet ${@def}}
|
||||
|
||||
|
||||
//------------------------------------------------
|
||||
#script=selfheal
|
||||
#permission=0
|
||||
//------------------------------------------------
|
||||
// purpose: heal self with full hp. GM-ONLY!!
|
||||
// be sure you have this spell in your spellbook!
|
||||
// DO NOT USE THIS SCRIPT IF YOU ARE NO GM!
|
||||
|
||||
// target self (the name we used to login)
|
||||
TARGET ${#CHARNAME}
|
||||
// 23965 = instant heal
|
||||
CASTSPELL 23965
|
||||
|
||||
//------------------------------------------------
|
||||
#script=sl
|
||||
#permission=0
|
||||
//------------------------------------------------
|
||||
// say leetspeak text. gm-commands can't be executed this way
|
||||
s,{${@0}} ?{toleet ${@def}}
|
||||
|
||||
// example file. wrap a few functions together.
|
||||
|
||||
//------------------------------------------------
|
||||
#script=gc
|
||||
#permission=0
|
||||
//------------------------------------------------
|
||||
// example script to write into channel "generalchat"
|
||||
// usage: "gc bla bla..."
|
||||
chan,generalchat ${@def}
|
||||
|
||||
|
||||
//------------------------------------------------
|
||||
#script=gcl
|
||||
#permission=0
|
||||
//------------------------------------------------
|
||||
// write leetspeak to channel generalchat (see "gc" script)
|
||||
// usage: "gcl moo, cow syndrome!"
|
||||
gc ?{toleet ${@def}}
|
||||
|
||||
|
||||
//------------------------------------------------
|
||||
#script=selfheal
|
||||
#permission=0
|
||||
//------------------------------------------------
|
||||
// purpose: heal self with full hp. GM-ONLY!!
|
||||
// be sure you have this spell in your spellbook!
|
||||
// DO NOT USE THIS SCRIPT IF YOU ARE NO GM!
|
||||
|
||||
// target self (the name we used to login)
|
||||
TARGET ${#CHARNAME}
|
||||
// 23965 = instant heal
|
||||
CASTSPELL 23965
|
||||
|
||||
//------------------------------------------------
|
||||
#script=sl
|
||||
#permission=0
|
||||
//------------------------------------------------
|
||||
// say leetspeak text. gm-commands can't be executed this way
|
||||
s,{${@0}} ?{toleet ${@def}}
|
||||
|
||||
|
||||
@ -1,46 +1,46 @@
|
||||
// -- using conf/ScriptConfig.conf
|
||||
|
||||
// run this file to broadcast immediately (the timer will not change if you do!)
|
||||
|
||||
#permission=255
|
||||
|
||||
#onload
|
||||
|
||||
// check if this script should be loaded.
|
||||
if ?{or,?{not ?{isset enable}} ?{not ${enable}}}
|
||||
log ** AutoBroadcast: skipped loading.
|
||||
return
|
||||
endif
|
||||
|
||||
// convert secs into msecs
|
||||
set,timer ${secs}
|
||||
mul,timer 1000
|
||||
|
||||
// we need this variable later as "array-index"
|
||||
set,x 0
|
||||
|
||||
// unregister the timer if it has been registered before
|
||||
removeevent event_{${@myname}}
|
||||
|
||||
// register the timer.
|
||||
// script name is "autobroadcast", so the event name will be "event_autobroadcast" and the script command to call will be "autobroadcast"
|
||||
// so we basically register ourselves
|
||||
addevent,event_{${@myname}},${timer} ${@myname}
|
||||
|
||||
// yay we are loaded :)
|
||||
log ** AutoBroadcast loaded. ${textcount} Texts.
|
||||
|
||||
#endonload
|
||||
|
||||
// --- begin of the script body ---
|
||||
|
||||
// every call the value of x gets increased by 1
|
||||
add,x 1
|
||||
|
||||
// broadcast the text number x
|
||||
CMD ${cmd} ${text${x}}
|
||||
|
||||
// if x = textcount: reset text counter x to 0 (using the modulo operator)
|
||||
mod,x ${textcount}
|
||||
|
||||
|
||||
// -- using conf/ScriptConfig.conf
|
||||
|
||||
// run this file to broadcast immediately (the timer will not change if you do!)
|
||||
|
||||
#permission=255
|
||||
|
||||
#onload
|
||||
|
||||
// check if this script should be loaded.
|
||||
if ?{or,?{not ?{isset enable}} ?{not ${enable}}}
|
||||
log ** AutoBroadcast: skipped loading.
|
||||
return
|
||||
endif
|
||||
|
||||
// convert secs into msecs
|
||||
set,timer ${secs}
|
||||
mul,timer 1000
|
||||
|
||||
// we need this variable later as "array-index"
|
||||
set,x 0
|
||||
|
||||
// unregister the timer if it has been registered before
|
||||
removeevent event_{${@myname}}
|
||||
|
||||
// register the timer.
|
||||
// script name is "autobroadcast", so the event name will be "event_autobroadcast" and the script command to call will be "autobroadcast"
|
||||
// so we basically register ourselves
|
||||
addevent,event_{${@myname}},${timer} ${@myname}
|
||||
|
||||
// yay we are loaded :)
|
||||
log ** AutoBroadcast loaded. ${textcount} Texts.
|
||||
|
||||
#endonload
|
||||
|
||||
// --- begin of the script body ---
|
||||
|
||||
// every call the value of x gets increased by 1
|
||||
add,x 1
|
||||
|
||||
// broadcast the text number x
|
||||
CMD ${cmd} ${text${x}}
|
||||
|
||||
// if x = textcount: reset text counter x to 0 (using the modulo operator)
|
||||
mod,x ${textcount}
|
||||
|
||||
|
||||
|
||||
@ -1,36 +1,36 @@
|
||||
#permission=255
|
||||
|
||||
// PSEUWOW DEF_SCRIPT WORLD-ENTER FILE
|
||||
|
||||
LOG * World entered, executing appropriate script...
|
||||
|
||||
// MaNGOS: make PseuWoW invincible
|
||||
// CMD gmon
|
||||
|
||||
// you can also teleport on every startup to a certain player...
|
||||
// simple: use the .goname command as usual.
|
||||
// SAY .goname Gamemaster
|
||||
// or teleport to a specific loacation...
|
||||
// CMD tele gmisland
|
||||
|
||||
// to know everything worked fine, etc
|
||||
SAY [${@version_short}] login successful.
|
||||
|
||||
// yaay we are online. Ready!
|
||||
// 126 = TEXTEMOTE_READY
|
||||
EMOTE 126
|
||||
|
||||
// join some channels...
|
||||
JOINCHANNEL General
|
||||
JOINCHANNEL LookingForGroup
|
||||
// and a custom channel
|
||||
JOINCHANNEL generlachat
|
||||
|
||||
// Spell 836 = LoginEffect
|
||||
CASTSPELL 836
|
||||
|
||||
// add your own stuff here
|
||||
// ...
|
||||
|
||||
|
||||
#permission=255
|
||||
|
||||
// PSEUWOW DEF_SCRIPT WORLD-ENTER FILE
|
||||
|
||||
LOG * World entered, executing appropriate script...
|
||||
|
||||
// MaNGOS: make PseuWoW invincible
|
||||
// CMD gmon
|
||||
|
||||
// you can also teleport on every startup to a certain player...
|
||||
// simple: use the .goname command as usual.
|
||||
// SAY .goname Gamemaster
|
||||
// or teleport to a specific loacation...
|
||||
// CMD tele gmisland
|
||||
|
||||
// to know everything worked fine, etc
|
||||
SAY [${@version_short}] login successful.
|
||||
|
||||
// yaay we are online. Ready!
|
||||
// 126 = TEXTEMOTE_READY
|
||||
EMOTE 126
|
||||
|
||||
// join some channels...
|
||||
JOINCHANNEL General
|
||||
JOINCHANNEL LookingForGroup
|
||||
// and a custom channel
|
||||
JOINCHANNEL generlachat
|
||||
|
||||
// Spell 836 = LoginEffect
|
||||
CASTSPELL 836
|
||||
|
||||
// add your own stuff here
|
||||
// ...
|
||||
|
||||
|
||||
LOG * finished executing script.
|
||||
@ -1,3 +1,3 @@
|
||||
#permission=255
|
||||
|
||||
#permission=255
|
||||
|
||||
// EXECUTED WHEN THE WORLD IS LEFT
|
||||
@ -1,14 +1,14 @@
|
||||
// this script gets executed if a player tries to give pseuwow a command but is not allowed to
|
||||
|
||||
// Arguments:
|
||||
// ==========
|
||||
// @0 : name of the player who wanted to execute a command
|
||||
// @1 : permission level of this user
|
||||
// @2 : permission level needed to execute the script
|
||||
// @3 : name of the script that should get executed
|
||||
|
||||
SAY Forget it, ${@0}, you have only permission ${@1} but need ${@2} to run the script '${@3}'
|
||||
LOG Player '${@0}' (p:${@1}) wanted to execute '${@3}' (p:${@2})
|
||||
|
||||
// say NO!
|
||||
// this script gets executed if a player tries to give pseuwow a command but is not allowed to
|
||||
|
||||
// Arguments:
|
||||
// ==========
|
||||
// @0 : name of the player who wanted to execute a command
|
||||
// @1 : permission level of this user
|
||||
// @2 : permission level needed to execute the script
|
||||
// @3 : name of the script that should get executed
|
||||
|
||||
SAY Forget it, ${@0}, you have only permission ${@1} but need ${@2} to run the script '${@3}'
|
||||
LOG Player '${@0}' (p:${@1}) wanted to execute '${@3}' (p:${@2})
|
||||
|
||||
// say NO!
|
||||
EMOTE 66
|
||||
@ -1,4 +1,4 @@
|
||||
// EXECUTED EVERYTIME A WHISPER IS BEEING RECIEVED
|
||||
|
||||
// comment out the following line if you dont need it
|
||||
// EXECUTED EVERYTIME A WHISPER IS BEEING RECIEVED
|
||||
|
||||
// comment out the following line if you dont need it
|
||||
//REPLY,0 [BOT] No need to whisper, nobody is here who could read what you wrote.
|
||||
@ -1,22 +1,22 @@
|
||||
// temporary wrapper for requesting info about a certain player until implemented into the core
|
||||
#script=SendWhoForPlayer
|
||||
|
||||
// minlvl 0
|
||||
bbappend,pkt,uint32 0
|
||||
// maxlvl 100
|
||||
bbappend,pkt,uint32 100
|
||||
// player name, case-sensitive string
|
||||
bbappend,pkt,string ${@def}
|
||||
// no guild, empty string
|
||||
bbappend,pkt,string
|
||||
// racemask - all races
|
||||
bbappend,pkt,uint32 0xFFFFFFFF
|
||||
// classmask - all classes
|
||||
bbappend,pkt,uint32 0xFFFFFFFF
|
||||
// 0 zones to check
|
||||
bbappend,pkt,uint32 0
|
||||
// 0 additional strings
|
||||
bbappend,pkt,uint32 0
|
||||
|
||||
SendWorldPacket,{?{GetOpcodeID CMSG_WHO}} pkt
|
||||
// temporary wrapper for requesting info about a certain player until implemented into the core
|
||||
#script=SendWhoForPlayer
|
||||
|
||||
// minlvl 0
|
||||
bbappend,pkt,uint32 0
|
||||
// maxlvl 100
|
||||
bbappend,pkt,uint32 100
|
||||
// player name, case-sensitive string
|
||||
bbappend,pkt,string ${@def}
|
||||
// no guild, empty string
|
||||
bbappend,pkt,string
|
||||
// racemask - all races
|
||||
bbappend,pkt,uint32 0xFFFFFFFF
|
||||
// classmask - all classes
|
||||
bbappend,pkt,uint32 0xFFFFFFFF
|
||||
// 0 zones to check
|
||||
bbappend,pkt,uint32 0
|
||||
// 0 additional strings
|
||||
bbappend,pkt,uint32 0
|
||||
|
||||
SendWorldPacket,{?{GetOpcodeID CMSG_WHO}} pkt
|
||||
bbdelete pkt
|
||||
@ -1,29 +1,29 @@
|
||||
#script=bbexample
|
||||
bbinit,50 mybb
|
||||
bbappend,mybb,uint32 123456
|
||||
bbappend,mybb,uint8 255
|
||||
bbappend,mybb,float 3.141592
|
||||
bbappend,mybb,string Hello World!
|
||||
bbappend,mybb,uint32 0xDEADBABE
|
||||
bbappend,mybb,uint16 1024
|
||||
bbappend,mybb,uint64 0
|
||||
bbappend,mybb,uint64 0
|
||||
|
||||
out ByteBuffer Example:
|
||||
bbhexlike mybb
|
||||
bbtextlike mybb
|
||||
|
||||
bbrpos,mybb 0
|
||||
out Reading uint32 - ?{bbread,mybb uint32}
|
||||
out Reading uint8 - ?{bbread,mybb uint8}
|
||||
out Reading float - ?{bbread,mybb float}
|
||||
out Reading string - ?{bbread,mybb string}
|
||||
set,t ?{bbread,mybb uint32}
|
||||
out Reading uint32 - ${t} hex: ?{tohex ${t}}
|
||||
out Reading uint16 - ?{bbread,mybb uint16}
|
||||
out skipping 16 bytes
|
||||
bbread,mybb uint64
|
||||
bbread,mybb uint64
|
||||
out read from invalid position: result='?{bbread,mybb uint8}'
|
||||
|
||||
bbdelete mybb
|
||||
#script=bbexample
|
||||
bbinit,50 mybb
|
||||
bbappend,mybb,uint32 123456
|
||||
bbappend,mybb,uint8 255
|
||||
bbappend,mybb,float 3.141592
|
||||
bbappend,mybb,string Hello World!
|
||||
bbappend,mybb,uint32 0xDEADBABE
|
||||
bbappend,mybb,uint16 1024
|
||||
bbappend,mybb,uint64 0
|
||||
bbappend,mybb,uint64 0
|
||||
|
||||
out ByteBuffer Example:
|
||||
bbhexlike mybb
|
||||
bbtextlike mybb
|
||||
|
||||
bbrpos,mybb 0
|
||||
out Reading uint32 - ?{bbread,mybb uint32}
|
||||
out Reading uint8 - ?{bbread,mybb uint8}
|
||||
out Reading float - ?{bbread,mybb float}
|
||||
out Reading string - ?{bbread,mybb string}
|
||||
set,t ?{bbread,mybb uint32}
|
||||
out Reading uint32 - ${t} hex: ?{tohex ${t}}
|
||||
out Reading uint16 - ?{bbread,mybb uint16}
|
||||
out skipping 16 bytes
|
||||
bbread,mybb uint64
|
||||
bbread,mybb uint64
|
||||
out read from invalid position: result='?{bbread,mybb uint8}'
|
||||
|
||||
bbdelete mybb
|
||||
|
||||
@ -1,39 +1,39 @@
|
||||
// example script that registers itself to get called on incoming chat messages.
|
||||
// args passed to this script are as follows:
|
||||
// @def: chat msg
|
||||
// @0: message type
|
||||
// @1: lang id
|
||||
// @2: guid of sender
|
||||
// @3: channel name
|
||||
// @4: language name
|
||||
|
||||
// ---------------------------------------
|
||||
#script=chat_ai_helloworld
|
||||
// ---------------------------------------
|
||||
#onload
|
||||
// call us only if somebody says a text containing "hello" and "world"
|
||||
RegisterChatAIScript,{${@myname}},ALL hello world
|
||||
set,counter 0
|
||||
#/onload
|
||||
|
||||
if ?{equal,${@0} 0}
|
||||
// say some stuff is the language that was used by the sender
|
||||
say,${@1} Hello World! This is an example! You used ${@4} language.
|
||||
else
|
||||
// or shout back in our default language
|
||||
if ?{equal,${@0} 5}
|
||||
yell Yah "Hello World!" is widely used to proof that something is working!! You used ${@4} language.
|
||||
else
|
||||
if ?{equal,${@0} 14}
|
||||
chan,{${@3}} Recieved a nice "Hello World" in channel ${@3} ;)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
add,counter 1
|
||||
|
||||
// after 5 times of calling this script, it might get annoying, drop it
|
||||
if ?{greater_eq,${counter} 5}
|
||||
DropChatAIScript ${@myname}
|
||||
endif
|
||||
|
||||
// example script that registers itself to get called on incoming chat messages.
|
||||
// args passed to this script are as follows:
|
||||
// @def: chat msg
|
||||
// @0: message type
|
||||
// @1: lang id
|
||||
// @2: guid of sender
|
||||
// @3: channel name
|
||||
// @4: language name
|
||||
|
||||
// ---------------------------------------
|
||||
#script=chat_ai_helloworld
|
||||
// ---------------------------------------
|
||||
#onload
|
||||
// call us only if somebody says a text containing "hello" and "world"
|
||||
RegisterChatAIScript,{${@myname}},ALL hello world
|
||||
set,counter 0
|
||||
#/onload
|
||||
|
||||
if ?{equal,${@0} 0}
|
||||
// say some stuff is the language that was used by the sender
|
||||
say,${@1} Hello World! This is an example! You used ${@4} language.
|
||||
else
|
||||
// or shout back in our default language
|
||||
if ?{equal,${@0} 5}
|
||||
yell Yah "Hello World!" is widely used to proof that something is working!! You used ${@4} language.
|
||||
else
|
||||
if ?{equal,${@0} 14}
|
||||
chan,{${@3}} Recieved a nice "Hello World" in channel ${@3} ;)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
add,counter 1
|
||||
|
||||
// after 5 times of calling this script, it might get annoying, drop it
|
||||
if ?{greater_eq,${counter} 5}
|
||||
DropChatAIScript ${@myname}
|
||||
endif
|
||||
|
||||
|
||||
@ -1,21 +1,21 @@
|
||||
#script=dumppcache
|
||||
fopen,fh,rb ./cache/playernames.cache
|
||||
freadbb,fh bb
|
||||
set,size ?{bbread,bb uint32}
|
||||
log PlayerNameCache: ${size} entries.
|
||||
set,i 0
|
||||
loop
|
||||
if ?{bigger_eq,${i} ${size}}
|
||||
exitloop
|
||||
endif
|
||||
set,guid ?{bbread,bb uint64}
|
||||
set,len ?{bbread,bb uint8}
|
||||
set,name ?{bbread,bb,${len} strnz}
|
||||
log PlayerNameCache[${i}]: ${guid} = ${name} (${len})
|
||||
add,i 1
|
||||
endloop
|
||||
|
||||
#script=dummy
|
||||
#onload
|
||||
dumppcache
|
||||
#/onload
|
||||
#script=dumppcache
|
||||
fopen,fh,rb ./cache/playernames.cache
|
||||
freadbb,fh bb
|
||||
set,size ?{bbread,bb uint32}
|
||||
log PlayerNameCache: ${size} entries.
|
||||
set,i 0
|
||||
loop
|
||||
if ?{bigger_eq,${i} ${size}}
|
||||
exitloop
|
||||
endif
|
||||
set,guid ?{bbread,bb uint64}
|
||||
set,len ?{bbread,bb uint8}
|
||||
set,name ?{bbread,bb,${len} strnz}
|
||||
log PlayerNameCache[${i}]: ${guid} = ${name} (${len})
|
||||
add,i 1
|
||||
endloop
|
||||
|
||||
#script=dummy
|
||||
#onload
|
||||
dumppcache
|
||||
#/onload
|
||||
|
||||
@ -1,56 +1,56 @@
|
||||
//----------------------------------
|
||||
#script=hook_example_base
|
||||
//----------------------------------
|
||||
// just do some random stuff here
|
||||
set,var 0
|
||||
set,x hello world
|
||||
add,var 15
|
||||
out base: var=${var}
|
||||
|
||||
|
||||
|
||||
//----------------------------------
|
||||
#script=hook_example_hooker
|
||||
//----------------------------------
|
||||
#onload
|
||||
set,counter 0
|
||||
#/onload
|
||||
|
||||
// check if we have already added our code
|
||||
if ?{ScriptHasLine,hook_example_base #tag:hook:${@myname}}
|
||||
out Hook Example: code already added, skipping.
|
||||
else
|
||||
set,somevar some text
|
||||
|
||||
// this is a custom "tag" to indicate the modification. its necessary because a 'reloaddef' on base script removes our custom content,
|
||||
// so we can check if our added lines are still there; and a reloaddef on this script would cause the lines to get added twice or more.
|
||||
appenddef,hook_example_base #tag:hook:${@myname}
|
||||
|
||||
appenddef,hook_example_base out == this is the hooked part ==
|
||||
appenddef,hook_example_base out text copied from hooking script: ${somevar}
|
||||
appenddef,hook_example_base out x in base script: $\{x\}
|
||||
appenddef,hook_example_base out add,a 10
|
||||
appenddef,hook_example_base out var=$\{var\}
|
||||
out Hook Example: ++ code appended.
|
||||
endif
|
||||
|
||||
// everytine this script gets executed, add the same line of code to a "new" script (its not defined if you call this first time)
|
||||
appenddef,hook_example_new out line of text [${counter}]
|
||||
add,counter 1
|
||||
|
||||
|
||||
|
||||
//----------------------------------
|
||||
#script=hook_example_cleanup
|
||||
//----------------------------------
|
||||
unloaddef hook_example_new
|
||||
// other possible, but wrong way: delete DEFSCRIPT::SCRIPT::hook_example_new
|
||||
|
||||
|
||||
|
||||
//-----------------------------------
|
||||
// dummy for running scripts as soon as all scripts in this file are loaded
|
||||
#script=dummy
|
||||
#onload
|
||||
hook_example_hooker
|
||||
#/onload
|
||||
//----------------------------------
|
||||
#script=hook_example_base
|
||||
//----------------------------------
|
||||
// just do some random stuff here
|
||||
set,var 0
|
||||
set,x hello world
|
||||
add,var 15
|
||||
out base: var=${var}
|
||||
|
||||
|
||||
|
||||
//----------------------------------
|
||||
#script=hook_example_hooker
|
||||
//----------------------------------
|
||||
#onload
|
||||
set,counter 0
|
||||
#/onload
|
||||
|
||||
// check if we have already added our code
|
||||
if ?{ScriptHasLine,hook_example_base #tag:hook:${@myname}}
|
||||
out Hook Example: code already added, skipping.
|
||||
else
|
||||
set,somevar some text
|
||||
|
||||
// this is a custom "tag" to indicate the modification. its necessary because a 'reloaddef' on base script removes our custom content,
|
||||
// so we can check if our added lines are still there; and a reloaddef on this script would cause the lines to get added twice or more.
|
||||
appenddef,hook_example_base #tag:hook:${@myname}
|
||||
|
||||
appenddef,hook_example_base out == this is the hooked part ==
|
||||
appenddef,hook_example_base out text copied from hooking script: ${somevar}
|
||||
appenddef,hook_example_base out x in base script: $\{x\}
|
||||
appenddef,hook_example_base out add,a 10
|
||||
appenddef,hook_example_base out var=$\{var\}
|
||||
out Hook Example: ++ code appended.
|
||||
endif
|
||||
|
||||
// everytine this script gets executed, add the same line of code to a "new" script (its not defined if you call this first time)
|
||||
appenddef,hook_example_new out line of text [${counter}]
|
||||
add,counter 1
|
||||
|
||||
|
||||
|
||||
//----------------------------------
|
||||
#script=hook_example_cleanup
|
||||
//----------------------------------
|
||||
unloaddef hook_example_new
|
||||
// other possible, but wrong way: delete DEFSCRIPT::SCRIPT::hook_example_new
|
||||
|
||||
|
||||
|
||||
//-----------------------------------
|
||||
// dummy for running scripts as soon as all scripts in this file are loaded
|
||||
#script=dummy
|
||||
#onload
|
||||
hook_example_hooker
|
||||
#/onload
|
||||
|
||||
@ -1,113 +1,113 @@
|
||||
// Item/Inventory debugger
|
||||
// Using Player/Item fields
|
||||
// Works for 2.3.x
|
||||
// Usage: As soon as this file is loaded, the debugger will be attached automatically (put this file in /scripts/ directory)
|
||||
// Known problems: If player/item names are not yet known, this script will display empty names. At second time everything will be fine.
|
||||
|
||||
#script=itemdebugger_loader
|
||||
#onload
|
||||
if ?{not ?{ishooked _onobjectcreate}}
|
||||
hookstart _onobjectcreate
|
||||
#escape-all=1
|
||||
hookadd if ?{equal,4 ${@0}} // MaNGOS creates the player object after all items are created, so just need to check for that and read everything out of the player fields
|
||||
hookadd playeritemdebugger ${@def}
|
||||
hookadd endif
|
||||
#escape-all=0
|
||||
hookend
|
||||
endif
|
||||
if ?{not ?{ishooked _onobjectdelete}}
|
||||
hookstart _onobjectdelete
|
||||
#escape-all=1
|
||||
hookadd if ?{or,?{equal,1 ${@0}} ?{equal,2 ${@0}}}
|
||||
hookadd itemdebugger_del ${@def}
|
||||
hookadd endif
|
||||
#escape-all=0
|
||||
hookend
|
||||
endif
|
||||
#/onload
|
||||
logdetail Item debugger attached
|
||||
|
||||
|
||||
|
||||
#script=playeritemdebugger
|
||||
// @def: player guid
|
||||
|
||||
set,pguid ${@def}
|
||||
set,pname ?{getname,guid ${pguid}}
|
||||
|
||||
// between these fields all item guids are stored (check UpdateFields.h)
|
||||
set,fstart 0x26E // PLAYER_FIELD_INV_SLOT_HEAD
|
||||
set,fend 0x35A // PLAYER_FIELD_KEYRING_SLOT_1 + 64
|
||||
|
||||
set,f ${fstart}
|
||||
set,slot 0
|
||||
loop
|
||||
if ?{bigger_eq,${f} ${fend}}
|
||||
exitloop
|
||||
endif
|
||||
set,iguid ?{getobjectvalue,${f},i64 ${pguid}}
|
||||
if ${iguid}
|
||||
//-- show info about item
|
||||
itemdebugger,{Player '${pname}' Slot ${slot} (field ${f}): } ${iguid}
|
||||
|
||||
//-- Iterate over bags --
|
||||
if ?{equal,2 ?{getobjecttype ${iguid}}}
|
||||
bagitemdebugger ${iguid}
|
||||
endif
|
||||
endif
|
||||
|
||||
add,f 2
|
||||
add,slot 1
|
||||
endloop
|
||||
|
||||
|
||||
#script=bagitemdebugger
|
||||
set,bagslots ?{getobjectvalue,60 ${@def}} // CONTAINER_FIELD_NUM_SLOTS
|
||||
set,j 0
|
||||
loop
|
||||
set,t ${j}
|
||||
mul,t 2
|
||||
if ?{bigger,${t} ${bagslots}} // max. bag size = 36 slots
|
||||
exitloop
|
||||
endif
|
||||
set,field 62 // CONTAINER_FIELD_SLOT_1 - 36
|
||||
add,field ${t}
|
||||
set,itemguid ?{getobjectvalue,${field},i64 ${@def}}
|
||||
itemdebugger,{Bag slot ${j} (field: ${field}) -> } ${itemguid}
|
||||
|
||||
add,j 1
|
||||
endloop
|
||||
|
||||
|
||||
#script=itemdebugger
|
||||
// @def: item guid
|
||||
// @0: text prefix
|
||||
set,itemguid ${@def}
|
||||
if ?{not ?{objectknown ${itemguid}}}
|
||||
return
|
||||
endif
|
||||
|
||||
if ${itemguid}
|
||||
set,itemname ?{getname,guid ${itemguid}}
|
||||
set,itementry ?{getentry ${itemguid}}
|
||||
log ${@0}Item: '${itemname}' (${itementry}) [${itemguid}]
|
||||
endif
|
||||
|
||||
|
||||
#script=itemdebugger_del
|
||||
// @def: item guid
|
||||
|
||||
set,itemguid ${@def}
|
||||
//if ?{not ?{objectknown ${itemguid}}}
|
||||
// return
|
||||
//endif
|
||||
|
||||
if ${itemguid}
|
||||
set,itemname ?{getname,guid ${itemguid}}
|
||||
set,itementry ?{getentry ${itemguid}}
|
||||
set,owner ?{getobjectvalue,6,i64 ${itemguid}}
|
||||
set,ownername ?{getname,guid ${owner}}
|
||||
|
||||
log Delete Item: '${itemname}' (${itementry}) (${ownername}) [${itemguid}]
|
||||
endif
|
||||
|
||||
// Item/Inventory debugger
|
||||
// Using Player/Item fields
|
||||
// Works for 2.3.x
|
||||
// Usage: As soon as this file is loaded, the debugger will be attached automatically (put this file in /scripts/ directory)
|
||||
// Known problems: If player/item names are not yet known, this script will display empty names. At second time everything will be fine.
|
||||
|
||||
#script=itemdebugger_loader
|
||||
#onload
|
||||
if ?{not ?{ishooked _onobjectcreate}}
|
||||
hookstart _onobjectcreate
|
||||
#escape-all=1
|
||||
hookadd if ?{equal,4 ${@0}} // MaNGOS creates the player object after all items are created, so just need to check for that and read everything out of the player fields
|
||||
hookadd playeritemdebugger ${@def}
|
||||
hookadd endif
|
||||
#escape-all=0
|
||||
hookend
|
||||
endif
|
||||
if ?{not ?{ishooked _onobjectdelete}}
|
||||
hookstart _onobjectdelete
|
||||
#escape-all=1
|
||||
hookadd if ?{or,?{equal,1 ${@0}} ?{equal,2 ${@0}}}
|
||||
hookadd itemdebugger_del ${@def}
|
||||
hookadd endif
|
||||
#escape-all=0
|
||||
hookend
|
||||
endif
|
||||
#/onload
|
||||
logdetail Item debugger attached
|
||||
|
||||
|
||||
|
||||
#script=playeritemdebugger
|
||||
// @def: player guid
|
||||
|
||||
set,pguid ${@def}
|
||||
set,pname ?{getname,guid ${pguid}}
|
||||
|
||||
// between these fields all item guids are stored (check UpdateFields.h)
|
||||
set,fstart 0x26E // PLAYER_FIELD_INV_SLOT_HEAD
|
||||
set,fend 0x35A // PLAYER_FIELD_KEYRING_SLOT_1 + 64
|
||||
|
||||
set,f ${fstart}
|
||||
set,slot 0
|
||||
loop
|
||||
if ?{bigger_eq,${f} ${fend}}
|
||||
exitloop
|
||||
endif
|
||||
set,iguid ?{getobjectvalue,${f},i64 ${pguid}}
|
||||
if ${iguid}
|
||||
//-- show info about item
|
||||
itemdebugger,{Player '${pname}' Slot ${slot} (field ${f}): } ${iguid}
|
||||
|
||||
//-- Iterate over bags --
|
||||
if ?{equal,2 ?{getobjecttype ${iguid}}}
|
||||
bagitemdebugger ${iguid}
|
||||
endif
|
||||
endif
|
||||
|
||||
add,f 2
|
||||
add,slot 1
|
||||
endloop
|
||||
|
||||
|
||||
#script=bagitemdebugger
|
||||
set,bagslots ?{getobjectvalue,60 ${@def}} // CONTAINER_FIELD_NUM_SLOTS
|
||||
set,j 0
|
||||
loop
|
||||
set,t ${j}
|
||||
mul,t 2
|
||||
if ?{bigger,${t} ${bagslots}} // max. bag size = 36 slots
|
||||
exitloop
|
||||
endif
|
||||
set,field 62 // CONTAINER_FIELD_SLOT_1 - 36
|
||||
add,field ${t}
|
||||
set,itemguid ?{getobjectvalue,${field},i64 ${@def}}
|
||||
itemdebugger,{Bag slot ${j} (field: ${field}) -> } ${itemguid}
|
||||
|
||||
add,j 1
|
||||
endloop
|
||||
|
||||
|
||||
#script=itemdebugger
|
||||
// @def: item guid
|
||||
// @0: text prefix
|
||||
set,itemguid ${@def}
|
||||
if ?{not ?{objectknown ${itemguid}}}
|
||||
return
|
||||
endif
|
||||
|
||||
if ${itemguid}
|
||||
set,itemname ?{getname,guid ${itemguid}}
|
||||
set,itementry ?{getentry ${itemguid}}
|
||||
log ${@0}Item: '${itemname}' (${itementry}) [${itemguid}]
|
||||
endif
|
||||
|
||||
|
||||
#script=itemdebugger_del
|
||||
// @def: item guid
|
||||
|
||||
set,itemguid ${@def}
|
||||
//if ?{not ?{objectknown ${itemguid}}}
|
||||
// return
|
||||
//endif
|
||||
|
||||
if ${itemguid}
|
||||
set,itemname ?{getname,guid ${itemguid}}
|
||||
set,itementry ?{getentry ${itemguid}}
|
||||
set,owner ?{getobjectvalue,6,i64 ${itemguid}}
|
||||
set,ownername ?{getname,guid ${owner}}
|
||||
|
||||
log Delete Item: '${itemname}' (${itementry}) (${ownername}) [${itemguid}]
|
||||
endif
|
||||
|
||||
|
||||
@ -1,38 +1,38 @@
|
||||
#script=getuptime
|
||||
// purpose: pseuwow uptime counter
|
||||
// args: @def: "say", "yell", "chan,General", etc. any command that accepts a string in @def and does something with it.
|
||||
|
||||
// returns: uptime formatted as 0h 0m 0s
|
||||
|
||||
set,s ${@clock}
|
||||
div,s 1000
|
||||
set,s ?{toint ${s}}
|
||||
set,secs ${s}
|
||||
|
||||
set,h ${s}
|
||||
div,h 3600
|
||||
toint,h ${h}
|
||||
mod,s 3600
|
||||
|
||||
set,m ${s}
|
||||
div,m 60
|
||||
toint,m ${m}
|
||||
mod,s 60
|
||||
toint,s ${s}
|
||||
set,str ${h}h ${m}m ${s}s
|
||||
out UPTIME: ${secs} secs = ${str}
|
||||
|
||||
if ?{strlen ${@def}}
|
||||
${@def} UPTIME: ${h} hours, ${m} minutes, ${s} seconds
|
||||
endif
|
||||
|
||||
unset h
|
||||
unset m
|
||||
unset s
|
||||
unset secs
|
||||
|
||||
return ${str}
|
||||
|
||||
#script=uptime
|
||||
#permission=0
|
||||
#script=getuptime
|
||||
// purpose: pseuwow uptime counter
|
||||
// args: @def: "say", "yell", "chan,General", etc. any command that accepts a string in @def and does something with it.
|
||||
|
||||
// returns: uptime formatted as 0h 0m 0s
|
||||
|
||||
set,s ${@clock}
|
||||
div,s 1000
|
||||
set,s ?{toint ${s}}
|
||||
set,secs ${s}
|
||||
|
||||
set,h ${s}
|
||||
div,h 3600
|
||||
toint,h ${h}
|
||||
mod,s 3600
|
||||
|
||||
set,m ${s}
|
||||
div,m 60
|
||||
toint,m ${m}
|
||||
mod,s 60
|
||||
toint,s ${s}
|
||||
set,str ${h}h ${m}m ${s}s
|
||||
out UPTIME: ${secs} secs = ${str}
|
||||
|
||||
if ?{strlen ${@def}}
|
||||
${@def} UPTIME: ${h} hours, ${m} minutes, ${s} seconds
|
||||
endif
|
||||
|
||||
unset h
|
||||
unset m
|
||||
unset s
|
||||
unset secs
|
||||
|
||||
return ${str}
|
||||
|
||||
#script=uptime
|
||||
#permission=0
|
||||
return ?{getuptime say}
|
||||
48
license.txt
48
license.txt
@ -1,24 +1,24 @@
|
||||
Find the full license at:
|
||||
http://www.gnu.org/licenses/gpl.html
|
||||
|
||||
|
||||
Summary:
|
||||
|
||||
Copyright (C) 2006 False.Genesis @ SnowStom Software
|
||||
|
||||
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 2 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Every part of program code belongs to its respective owner.
|
||||
Find the full license at:
|
||||
http://www.gnu.org/licenses/gpl.html
|
||||
|
||||
|
||||
Summary:
|
||||
|
||||
Copyright (C) 2006 False.Genesis @ SnowStom Software
|
||||
|
||||
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 2 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, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Every part of program code belongs to its respective owner.
|
||||
|
||||
@ -1,18 +1,18 @@
|
||||
#ifndef _CLI_H
|
||||
#define _CLI_H
|
||||
|
||||
class PseuInstance;
|
||||
|
||||
class CliRunnable : public ZThread::Runnable
|
||||
{
|
||||
public:
|
||||
CliRunnable(PseuInstance*);
|
||||
void run(void);
|
||||
void stop() { _stop=true; }
|
||||
|
||||
private:
|
||||
bool _stop;
|
||||
PseuInstance *_instance;
|
||||
};
|
||||
|
||||
#ifndef _CLI_H
|
||||
#define _CLI_H
|
||||
|
||||
class PseuInstance;
|
||||
|
||||
class CliRunnable : public ZThread::Runnable
|
||||
{
|
||||
public:
|
||||
CliRunnable(PseuInstance*);
|
||||
void run(void);
|
||||
void stop() { _stop=true; }
|
||||
|
||||
private:
|
||||
bool _stop;
|
||||
PseuInstance *_instance;
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -1,59 +1,59 @@
|
||||
#include "common.h"
|
||||
#include "PseuWoW.h"
|
||||
#include "RemoteController.h"
|
||||
#include "ControlSocket.h"
|
||||
|
||||
ControlSocket::ControlSocket(SocketHandler& h) : TcpSocket(h)
|
||||
{
|
||||
_ok = false;
|
||||
DEBUG(logdebug("ControlSocket created"));
|
||||
}
|
||||
|
||||
void ControlSocket::OnAccept(void)
|
||||
{
|
||||
logdetail("ControlSocket: Incoming connection from %s:%u [host:%s]",GetRemoteAddress().c_str(),GetRemotePort(),GetRemoteHostname().c_str());
|
||||
|
||||
// must perform some crappy ptr conversion here, doesnt want to typecast SocketHandler -> ControlSocketHandler directly
|
||||
SocketHandler& hnd = Handler();
|
||||
ControlSocketHandler *chnd = static_cast<ControlSocketHandler*>(&hnd);
|
||||
_instance = chnd->GetInstance();
|
||||
DEBUG(logdebug("ControlSocket: setting instance = %X",_instance));
|
||||
|
||||
// accept only connections from one host for now, if set
|
||||
if(_instance->GetConf()->rmcontrolhost.length()
|
||||
&& !(GetRemoteAddress() == _instance->GetConf()->rmcontrolhost || GetRemoteHostname() == _instance->GetConf()->rmcontrolhost))
|
||||
{
|
||||
logdetail("ControlSocket: connection rejected. closing.");
|
||||
SetCloseAndDelete(true);
|
||||
return;
|
||||
}
|
||||
|
||||
_ok = true;
|
||||
}
|
||||
|
||||
void ControlSocket::OnRead(void)
|
||||
{
|
||||
if(!_ok)
|
||||
return;
|
||||
TcpSocket::OnRead();
|
||||
uint32 len = ibuf.GetLength();
|
||||
if(!len)
|
||||
{
|
||||
logdetail("ControlSocket: connection to %s:%u closed.",GetRemoteAddress().c_str(),GetRemotePort());
|
||||
return;
|
||||
}
|
||||
|
||||
char *buf = new char[len];
|
||||
ibuf.Read(buf,len);
|
||||
if(buf[0]==0)
|
||||
{
|
||||
// reserved for future applications
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_instance && _instance->GetScripts())
|
||||
_instance->GetScripts()->RunSingleLine(&buf[0]);
|
||||
}
|
||||
|
||||
delete [] buf;
|
||||
}
|
||||
#include "common.h"
|
||||
#include "PseuWoW.h"
|
||||
#include "RemoteController.h"
|
||||
#include "ControlSocket.h"
|
||||
|
||||
ControlSocket::ControlSocket(SocketHandler& h) : TcpSocket(h)
|
||||
{
|
||||
_ok = false;
|
||||
DEBUG(logdebug("ControlSocket created"));
|
||||
}
|
||||
|
||||
void ControlSocket::OnAccept(void)
|
||||
{
|
||||
logdetail("ControlSocket: Incoming connection from %s:%u [host:%s]",GetRemoteAddress().c_str(),GetRemotePort(),GetRemoteHostname().c_str());
|
||||
|
||||
// must perform some crappy ptr conversion here, doesnt want to typecast SocketHandler -> ControlSocketHandler directly
|
||||
SocketHandler& hnd = Handler();
|
||||
ControlSocketHandler *chnd = static_cast<ControlSocketHandler*>(&hnd);
|
||||
_instance = chnd->GetInstance();
|
||||
DEBUG(logdebug("ControlSocket: setting instance = %X",_instance));
|
||||
|
||||
// accept only connections from one host for now, if set
|
||||
if(_instance->GetConf()->rmcontrolhost.length()
|
||||
&& !(GetRemoteAddress() == _instance->GetConf()->rmcontrolhost || GetRemoteHostname() == _instance->GetConf()->rmcontrolhost))
|
||||
{
|
||||
logdetail("ControlSocket: connection rejected. closing.");
|
||||
SetCloseAndDelete(true);
|
||||
return;
|
||||
}
|
||||
|
||||
_ok = true;
|
||||
}
|
||||
|
||||
void ControlSocket::OnRead(void)
|
||||
{
|
||||
if(!_ok)
|
||||
return;
|
||||
TcpSocket::OnRead();
|
||||
uint32 len = ibuf.GetLength();
|
||||
if(!len)
|
||||
{
|
||||
logdetail("ControlSocket: connection to %s:%u closed.",GetRemoteAddress().c_str(),GetRemotePort());
|
||||
return;
|
||||
}
|
||||
|
||||
char *buf = new char[len];
|
||||
ibuf.Read(buf,len);
|
||||
if(buf[0]==0)
|
||||
{
|
||||
// reserved for future applications
|
||||
}
|
||||
else
|
||||
{
|
||||
if(_instance && _instance->GetScripts())
|
||||
_instance->GetScripts()->RunSingleLine(&buf[0]);
|
||||
}
|
||||
|
||||
delete [] buf;
|
||||
}
|
||||
|
||||
@ -1,23 +1,23 @@
|
||||
#ifndef CONTROLSOCKET_H
|
||||
#define CONTROLSOCKET_H
|
||||
|
||||
#include "Network/TcpSocket.h"
|
||||
#include "RemoteController.h"
|
||||
|
||||
class ControlSocket : public TcpSocket
|
||||
{
|
||||
public:
|
||||
ControlSocket(SocketHandler& h);
|
||||
|
||||
void SetInstance(PseuInstance *in) { _instance = in; }
|
||||
|
||||
void OnAccept();
|
||||
void OnRead();
|
||||
|
||||
private:
|
||||
PseuInstance *_instance;
|
||||
bool _ok;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
#ifndef CONTROLSOCKET_H
|
||||
#define CONTROLSOCKET_H
|
||||
|
||||
#include "Network/TcpSocket.h"
|
||||
#include "RemoteController.h"
|
||||
|
||||
class ControlSocket : public TcpSocket
|
||||
{
|
||||
public:
|
||||
ControlSocket(SocketHandler& h);
|
||||
|
||||
void SetInstance(PseuInstance *in) { _instance = in; }
|
||||
|
||||
void OnAccept();
|
||||
void OnRead();
|
||||
|
||||
private:
|
||||
PseuInstance *_instance;
|
||||
bool _ok;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,288 +1,288 @@
|
||||
|
||||
#ifndef __DEFSCRIPT_H
|
||||
#define __DEFSCRIPT_H
|
||||
|
||||
#include "DefScriptDefines.h"
|
||||
#include <map>
|
||||
#include <deque>
|
||||
#include <fstream>
|
||||
#include "VarSet.h"
|
||||
#include "ByteBuffer.h"
|
||||
#include "DynamicEvent.h"
|
||||
#include "TypeStorage.h"
|
||||
#include "DefScriptTools.h"
|
||||
|
||||
class DefScriptPackage;
|
||||
class DefScript;
|
||||
|
||||
typedef void (*_slog_func)(const char*,...);
|
||||
|
||||
// general struct for if..else..endif / loop..endloop blocks
|
||||
struct Def_Block
|
||||
{
|
||||
unsigned char type; // stores DefScriptBlockType
|
||||
bool istrue; // only relevant for if-statements
|
||||
unsigned int startline; // line where loop-statement started
|
||||
};
|
||||
|
||||
struct DefReturnResult
|
||||
{
|
||||
DefReturnResult() { ok=true; mustreturn=false; ret="true"; }
|
||||
DefReturnResult(bool b) { ok=true; mustreturn=false; ret=b?"true":"false"; }
|
||||
DefReturnResult(std::string s) { ok=true; mustreturn=false; ret=s; }
|
||||
DefReturnResult(const char *s) { DefReturnResult(std::string(s)); }
|
||||
bool ok; // true if the execution of the current statement was successful
|
||||
bool mustreturn;
|
||||
std::string ret; // return value used by ?{..}
|
||||
//bool abrt; // true if ALL current script execution must be aborted.
|
||||
//std::string err; // error string, including tracestack, etc.
|
||||
};
|
||||
|
||||
#define DEF_RETURN_ERROR { DefReturnResult __defreturnresult(false); __defreturnresult.ok=false; return __defreturnresult; }
|
||||
|
||||
struct DefXChgResult
|
||||
{
|
||||
DefXChgResult() { changed=false; }
|
||||
bool changed;
|
||||
std::string str;
|
||||
DefReturnResult result;
|
||||
};
|
||||
|
||||
typedef std::map<unsigned int,std::string> _CmdSetArgMap;
|
||||
|
||||
class CmdSet {
|
||||
public:
|
||||
CmdSet();
|
||||
~CmdSet();
|
||||
void Clear();
|
||||
std::string cmd;
|
||||
_CmdSetArgMap arg;
|
||||
std::string defaultarg;
|
||||
std::string myname;
|
||||
std::string caller;
|
||||
};
|
||||
|
||||
struct DefScriptFunctionEntry {
|
||||
DefScriptFunctionEntry(std::string n,DefReturnResult (DefScriptPackage::*f)(CmdSet& Set), bool esc)
|
||||
{
|
||||
name=n;
|
||||
func=f;
|
||||
escape=esc;
|
||||
}
|
||||
std::string name;
|
||||
DefReturnResult (DefScriptPackage::*func)(CmdSet& Set);
|
||||
bool escape;
|
||||
};
|
||||
|
||||
typedef std::deque<DefScriptFunctionEntry> DefScriptFunctionTable;
|
||||
|
||||
typedef std::deque<std::string> DefList;
|
||||
typedef std::map<std::string,DefList*> DefListMap;
|
||||
|
||||
class DefScript {
|
||||
friend class DefScriptPackage;
|
||||
public:
|
||||
DefScript(DefScriptPackage *p);
|
||||
~DefScript();
|
||||
|
||||
inline std::string GetLine(unsigned int id) { return Line[id]; }
|
||||
inline unsigned int GetLines(void) { return Line.size(); }
|
||||
bool AddLine(std::string );
|
||||
std::string GetName(void);
|
||||
void SetName(std::string);
|
||||
void SetPermission(unsigned char);
|
||||
unsigned char GetPermission(void);
|
||||
void Clear(void);
|
||||
void SetDebug(bool);
|
||||
bool GetDebug(void);
|
||||
//DefScriptPackage *GetParent(void);
|
||||
|
||||
|
||||
private:
|
||||
DefList Line;
|
||||
unsigned int lines;
|
||||
std::string scriptname;
|
||||
unsigned char permission;
|
||||
bool debugmode;
|
||||
|
||||
DefScriptPackage *_parent;
|
||||
};
|
||||
|
||||
|
||||
class DefScriptPackage {
|
||||
friend class DefScript;
|
||||
public:
|
||||
DefScriptPackage();
|
||||
~DefScriptPackage();
|
||||
void SetParentMethod(void*); // used to extend the scripts with own c++ interface functions
|
||||
void Clear(void);
|
||||
DefScript *GetScript(std::string);
|
||||
unsigned int GetScripts(void);
|
||||
bool LoadScriptFromFile(std::string);
|
||||
DefReturnResult RunScript(std::string name,CmdSet* pSet,std::string override_name="");
|
||||
bool BoolRunScript(std::string,CmdSet*);
|
||||
bool RunScriptIfExists(std::string name, CmdSet *pSet = NULL);
|
||||
unsigned int GetScriptID(std::string);
|
||||
DefReturnResult RunSingleLine(std::string);
|
||||
bool ScriptExists(std::string);
|
||||
void DeleteScript(std::string);
|
||||
VarSet variables;
|
||||
void SetPath(std::string);
|
||||
bool LoadByName(std::string);
|
||||
std::string _NormalizeVarName(std::string, std::string);
|
||||
DefReturnResult RunSingleLineFromScript(std::string line, DefScript *pScript);
|
||||
DefScript_DynamicEventMgr *GetEventMgr(void);
|
||||
void AddFunc(DefScriptFunctionEntry);
|
||||
void AddFunc(std::string n,DefReturnResult (DefScriptPackage::*)(CmdSet& Set), bool esc=true);
|
||||
bool HasFunc(std::string);
|
||||
void DelFunc(std::string);
|
||||
TypeStorage<DefList> lists;
|
||||
TypeStorage<ByteBuffer> bytebuffers;
|
||||
TypeStorage<std::fstream> files;
|
||||
std::string SecureString(std::string);
|
||||
std::string EscapeString(std::string);
|
||||
std::string UnescapeString(std::string);
|
||||
std::string GetUnescapedVar(std::string);
|
||||
|
||||
|
||||
// own logging functions. default is printf.
|
||||
// DO NOT USE THEM YET! THEY DO NOT WORK CORRECTLY!
|
||||
// need some help with this [FG]
|
||||
inline void SetLog(void *ptr) { _slog=(_slog_func)ptr; }
|
||||
inline void SetDebugLog(void *ptr) { _sdebuglog=(_slog_func)ptr; }
|
||||
inline void SetErrorLog(void *ptr) { _serrorlog=(_slog_func)ptr; }
|
||||
void Log(const char*,...);
|
||||
void DebugLog(const char*,...);
|
||||
void ErrorLog(const char*,...);
|
||||
|
||||
|
||||
std::string scPath;
|
||||
|
||||
// Own executor functions
|
||||
void My_LoadUserPermissions(VarSet&);
|
||||
void My_Run(std::string line,std::string username);
|
||||
|
||||
private:
|
||||
void _UpdateOrCreateScriptByName(std::string);
|
||||
void _InitFunctions(void);
|
||||
DefXChgResult ReplaceVars(std::string str, CmdSet* pSet, unsigned char VarType, bool run_embedded);
|
||||
void SplitLine(CmdSet&,std::string);
|
||||
DefReturnResult Interpret(CmdSet&);
|
||||
void RemoveBrackets(CmdSet&);
|
||||
void UnescapeSet(CmdSet&);
|
||||
std::string RemoveBracketsFromString(std::string);
|
||||
void *parentMethod;
|
||||
DefScript_DynamicEventMgr *_eventmgr;
|
||||
std::map<std::string,DefScript*> Script;
|
||||
std::map<std::string,unsigned char> scriptPermissionMap;
|
||||
DefScriptFunctionTable _functable;
|
||||
_slog_func _slog,_serrorlog,_sdebuglog;
|
||||
_DEFSC_DEBUG(std::fstream hLogfile);
|
||||
|
||||
// Usable internal basic functions:
|
||||
DefReturnResult func_default(CmdSet&);
|
||||
DefReturnResult func_set(CmdSet&);
|
||||
DefReturnResult func_unset(CmdSet&);
|
||||
DefReturnResult func_loaddef(CmdSet&);
|
||||
DefReturnResult func_reloaddef(CmdSet&);
|
||||
DefReturnResult func_createdef(CmdSet&);
|
||||
DefReturnResult func_unloaddef(CmdSet&);
|
||||
DefReturnResult func_out(CmdSet&);
|
||||
DefReturnResult func_eof(CmdSet&);
|
||||
DefReturnResult func_shdn(CmdSet&);
|
||||
DefReturnResult func_setscriptpermission(CmdSet&);
|
||||
DefReturnResult func_toint(CmdSet&);
|
||||
DefReturnResult func_add(CmdSet&);
|
||||
DefReturnResult func_sub(CmdSet&);
|
||||
DefReturnResult func_mul(CmdSet&);
|
||||
DefReturnResult func_div(CmdSet&);
|
||||
DefReturnResult func_mod(CmdSet&);
|
||||
DefReturnResult func_pow(CmdSet&);
|
||||
DefReturnResult func_bitor(CmdSet&);
|
||||
DefReturnResult func_bitand(CmdSet&);
|
||||
DefReturnResult func_bitxor(CmdSet&);
|
||||
DefReturnResult func_addevent(CmdSet&);
|
||||
DefReturnResult func_removeevent(CmdSet&);
|
||||
DefReturnResult func_abs(CmdSet&);
|
||||
DefReturnResult func_bigger(CmdSet&);
|
||||
DefReturnResult func_bigger_eq(CmdSet&);
|
||||
DefReturnResult func_equal(CmdSet&);
|
||||
DefReturnResult func_isset(CmdSet&);
|
||||
DefReturnResult func_not(CmdSet&);
|
||||
DefReturnResult func_smaller(CmdSet&);
|
||||
DefReturnResult func_smaller_eq(CmdSet&);
|
||||
DefReturnResult func_strlen(CmdSet&);
|
||||
DefReturnResult func_tohex(CmdSet&);
|
||||
DefReturnResult func_and(CmdSet&);
|
||||
DefReturnResult func_or(CmdSet&);
|
||||
DefReturnResult func_xor(CmdSet&);
|
||||
DefReturnResult func_substr(CmdSet&);
|
||||
DefReturnResult func_uppercase(CmdSet&);
|
||||
DefReturnResult func_lowercase(CmdSet&);
|
||||
DefReturnResult func_random(CmdSet&);
|
||||
DefReturnResult func_fileexists(CmdSet&);
|
||||
DefReturnResult func_strfind(CmdSet&);
|
||||
DefReturnResult func_scriptexists(CmdSet&);
|
||||
DefReturnResult func_funcexists(CmdSet&);
|
||||
|
||||
|
||||
// list functions
|
||||
DefReturnResult func_lpushback(CmdSet&);
|
||||
DefReturnResult func_lpushfront(CmdSet&);
|
||||
DefReturnResult func_lpopback(CmdSet&);
|
||||
DefReturnResult func_lpopfront(CmdSet&);
|
||||
DefReturnResult func_ldelete(CmdSet&);
|
||||
DefReturnResult func_lexists(CmdSet&);
|
||||
DefReturnResult func_llen(CmdSet&);
|
||||
DefReturnResult func_linsert(CmdSet&);
|
||||
DefReturnResult func_lsplit(CmdSet&);
|
||||
DefReturnResult func_lcsplit(CmdSet&);
|
||||
DefReturnResult func_ljoin(CmdSet&);
|
||||
DefReturnResult func_lindex(CmdSet&);
|
||||
DefReturnResult func_lclean(CmdSet&);
|
||||
DefReturnResult func_lmclean(CmdSet&);
|
||||
DefReturnResult func_lerase(CmdSet&);
|
||||
DefReturnResult func_lsort(CmdSet&);
|
||||
|
||||
// ByteBuffer functions
|
||||
DefReturnResult func_bbinit(CmdSet&);
|
||||
DefReturnResult func_bbdelete(CmdSet&);
|
||||
DefReturnResult func_bbappend(CmdSet&);
|
||||
DefReturnResult func_bbread(CmdSet&);
|
||||
DefReturnResult func_bbsetrpos(CmdSet&);
|
||||
DefReturnResult func_bbsetwpos(CmdSet&);
|
||||
DefReturnResult func_bbhexlike(CmdSet&);
|
||||
DefReturnResult func_bbtextlike(CmdSet&);
|
||||
DefReturnResult func_bbsize(CmdSet&);
|
||||
|
||||
// file functions
|
||||
DefReturnResult func_fopen(CmdSet&);
|
||||
DefReturnResult func_fclose(CmdSet&);
|
||||
DefReturnResult func_fisopen(CmdSet&);
|
||||
DefReturnResult func_feof(CmdSet&);
|
||||
DefReturnResult func_frpos(CmdSet&);
|
||||
DefReturnResult func_fwpos(CmdSet&);
|
||||
DefReturnResult func_fdel(CmdSet&);
|
||||
DefReturnResult func_fflush(CmdSet&);
|
||||
DefReturnResult func_fwrite(CmdSet&);
|
||||
DefReturnResult func_fread(CmdSet&);
|
||||
DefReturnResult func_freadb(CmdSet&);
|
||||
DefReturnResult func_fwriteb(CmdSet&);
|
||||
DefReturnResult func_freadbb(CmdSet&);
|
||||
DefReturnResult func_fwritebb(CmdSet&);
|
||||
DefReturnResult func_fsize(CmdSet&);
|
||||
DefReturnResult func_freadline(CmdSet&);
|
||||
DefReturnResult func_fseekw(CmdSet&);
|
||||
DefReturnResult func_fseekr(CmdSet&);
|
||||
|
||||
// setup own function declarations here
|
||||
# include "DefScriptInterfaceInclude.h"
|
||||
|
||||
// Own variable declarations
|
||||
std::map<std::string, unsigned char> my_usrPermissionMap;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef __DEFSCRIPT_H
|
||||
#define __DEFSCRIPT_H
|
||||
|
||||
#include "DefScriptDefines.h"
|
||||
#include <map>
|
||||
#include <deque>
|
||||
#include <fstream>
|
||||
#include "VarSet.h"
|
||||
#include "ByteBuffer.h"
|
||||
#include "DynamicEvent.h"
|
||||
#include "TypeStorage.h"
|
||||
#include "DefScriptTools.h"
|
||||
|
||||
class DefScriptPackage;
|
||||
class DefScript;
|
||||
|
||||
typedef void (*_slog_func)(const char*,...);
|
||||
|
||||
// general struct for if..else..endif / loop..endloop blocks
|
||||
struct Def_Block
|
||||
{
|
||||
unsigned char type; // stores DefScriptBlockType
|
||||
bool istrue; // only relevant for if-statements
|
||||
unsigned int startline; // line where loop-statement started
|
||||
};
|
||||
|
||||
struct DefReturnResult
|
||||
{
|
||||
DefReturnResult() { ok=true; mustreturn=false; ret="true"; }
|
||||
DefReturnResult(bool b) { ok=true; mustreturn=false; ret=b?"true":"false"; }
|
||||
DefReturnResult(std::string s) { ok=true; mustreturn=false; ret=s; }
|
||||
DefReturnResult(const char *s) { DefReturnResult(std::string(s)); }
|
||||
bool ok; // true if the execution of the current statement was successful
|
||||
bool mustreturn;
|
||||
std::string ret; // return value used by ?{..}
|
||||
//bool abrt; // true if ALL current script execution must be aborted.
|
||||
//std::string err; // error string, including tracestack, etc.
|
||||
};
|
||||
|
||||
#define DEF_RETURN_ERROR { DefReturnResult __defreturnresult(false); __defreturnresult.ok=false; return __defreturnresult; }
|
||||
|
||||
struct DefXChgResult
|
||||
{
|
||||
DefXChgResult() { changed=false; }
|
||||
bool changed;
|
||||
std::string str;
|
||||
DefReturnResult result;
|
||||
};
|
||||
|
||||
typedef std::map<unsigned int,std::string> _CmdSetArgMap;
|
||||
|
||||
class CmdSet {
|
||||
public:
|
||||
CmdSet();
|
||||
~CmdSet();
|
||||
void Clear();
|
||||
std::string cmd;
|
||||
_CmdSetArgMap arg;
|
||||
std::string defaultarg;
|
||||
std::string myname;
|
||||
std::string caller;
|
||||
};
|
||||
|
||||
struct DefScriptFunctionEntry {
|
||||
DefScriptFunctionEntry(std::string n,DefReturnResult (DefScriptPackage::*f)(CmdSet& Set), bool esc)
|
||||
{
|
||||
name=n;
|
||||
func=f;
|
||||
escape=esc;
|
||||
}
|
||||
std::string name;
|
||||
DefReturnResult (DefScriptPackage::*func)(CmdSet& Set);
|
||||
bool escape;
|
||||
};
|
||||
|
||||
typedef std::deque<DefScriptFunctionEntry> DefScriptFunctionTable;
|
||||
|
||||
typedef std::deque<std::string> DefList;
|
||||
typedef std::map<std::string,DefList*> DefListMap;
|
||||
|
||||
class DefScript {
|
||||
friend class DefScriptPackage;
|
||||
public:
|
||||
DefScript(DefScriptPackage *p);
|
||||
~DefScript();
|
||||
|
||||
inline std::string GetLine(unsigned int id) { return Line[id]; }
|
||||
inline unsigned int GetLines(void) { return Line.size(); }
|
||||
bool AddLine(std::string );
|
||||
std::string GetName(void);
|
||||
void SetName(std::string);
|
||||
void SetPermission(unsigned char);
|
||||
unsigned char GetPermission(void);
|
||||
void Clear(void);
|
||||
void SetDebug(bool);
|
||||
bool GetDebug(void);
|
||||
//DefScriptPackage *GetParent(void);
|
||||
|
||||
|
||||
private:
|
||||
DefList Line;
|
||||
unsigned int lines;
|
||||
std::string scriptname;
|
||||
unsigned char permission;
|
||||
bool debugmode;
|
||||
|
||||
DefScriptPackage *_parent;
|
||||
};
|
||||
|
||||
|
||||
class DefScriptPackage {
|
||||
friend class DefScript;
|
||||
public:
|
||||
DefScriptPackage();
|
||||
~DefScriptPackage();
|
||||
void SetParentMethod(void*); // used to extend the scripts with own c++ interface functions
|
||||
void Clear(void);
|
||||
DefScript *GetScript(std::string);
|
||||
unsigned int GetScripts(void);
|
||||
bool LoadScriptFromFile(std::string);
|
||||
DefReturnResult RunScript(std::string name,CmdSet* pSet,std::string override_name="");
|
||||
bool BoolRunScript(std::string,CmdSet*);
|
||||
bool RunScriptIfExists(std::string name, CmdSet *pSet = NULL);
|
||||
unsigned int GetScriptID(std::string);
|
||||
DefReturnResult RunSingleLine(std::string);
|
||||
bool ScriptExists(std::string);
|
||||
void DeleteScript(std::string);
|
||||
VarSet variables;
|
||||
void SetPath(std::string);
|
||||
bool LoadByName(std::string);
|
||||
std::string _NormalizeVarName(std::string, std::string);
|
||||
DefReturnResult RunSingleLineFromScript(std::string line, DefScript *pScript);
|
||||
DefScript_DynamicEventMgr *GetEventMgr(void);
|
||||
void AddFunc(DefScriptFunctionEntry);
|
||||
void AddFunc(std::string n,DefReturnResult (DefScriptPackage::*)(CmdSet& Set), bool esc=true);
|
||||
bool HasFunc(std::string);
|
||||
void DelFunc(std::string);
|
||||
TypeStorage<DefList> lists;
|
||||
TypeStorage<ByteBuffer> bytebuffers;
|
||||
TypeStorage<std::fstream> files;
|
||||
std::string SecureString(std::string);
|
||||
std::string EscapeString(std::string);
|
||||
std::string UnescapeString(std::string);
|
||||
std::string GetUnescapedVar(std::string);
|
||||
|
||||
|
||||
// own logging functions. default is printf.
|
||||
// DO NOT USE THEM YET! THEY DO NOT WORK CORRECTLY!
|
||||
// need some help with this [FG]
|
||||
inline void SetLog(void *ptr) { _slog=(_slog_func)ptr; }
|
||||
inline void SetDebugLog(void *ptr) { _sdebuglog=(_slog_func)ptr; }
|
||||
inline void SetErrorLog(void *ptr) { _serrorlog=(_slog_func)ptr; }
|
||||
void Log(const char*,...);
|
||||
void DebugLog(const char*,...);
|
||||
void ErrorLog(const char*,...);
|
||||
|
||||
|
||||
std::string scPath;
|
||||
|
||||
// Own executor functions
|
||||
void My_LoadUserPermissions(VarSet&);
|
||||
void My_Run(std::string line,std::string username);
|
||||
|
||||
private:
|
||||
void _UpdateOrCreateScriptByName(std::string);
|
||||
void _InitFunctions(void);
|
||||
DefXChgResult ReplaceVars(std::string str, CmdSet* pSet, unsigned char VarType, bool run_embedded);
|
||||
void SplitLine(CmdSet&,std::string);
|
||||
DefReturnResult Interpret(CmdSet&);
|
||||
void RemoveBrackets(CmdSet&);
|
||||
void UnescapeSet(CmdSet&);
|
||||
std::string RemoveBracketsFromString(std::string);
|
||||
void *parentMethod;
|
||||
DefScript_DynamicEventMgr *_eventmgr;
|
||||
std::map<std::string,DefScript*> Script;
|
||||
std::map<std::string,unsigned char> scriptPermissionMap;
|
||||
DefScriptFunctionTable _functable;
|
||||
_slog_func _slog,_serrorlog,_sdebuglog;
|
||||
_DEFSC_DEBUG(std::fstream hLogfile);
|
||||
|
||||
// Usable internal basic functions:
|
||||
DefReturnResult func_default(CmdSet&);
|
||||
DefReturnResult func_set(CmdSet&);
|
||||
DefReturnResult func_unset(CmdSet&);
|
||||
DefReturnResult func_loaddef(CmdSet&);
|
||||
DefReturnResult func_reloaddef(CmdSet&);
|
||||
DefReturnResult func_createdef(CmdSet&);
|
||||
DefReturnResult func_unloaddef(CmdSet&);
|
||||
DefReturnResult func_out(CmdSet&);
|
||||
DefReturnResult func_eof(CmdSet&);
|
||||
DefReturnResult func_shdn(CmdSet&);
|
||||
DefReturnResult func_setscriptpermission(CmdSet&);
|
||||
DefReturnResult func_toint(CmdSet&);
|
||||
DefReturnResult func_add(CmdSet&);
|
||||
DefReturnResult func_sub(CmdSet&);
|
||||
DefReturnResult func_mul(CmdSet&);
|
||||
DefReturnResult func_div(CmdSet&);
|
||||
DefReturnResult func_mod(CmdSet&);
|
||||
DefReturnResult func_pow(CmdSet&);
|
||||
DefReturnResult func_bitor(CmdSet&);
|
||||
DefReturnResult func_bitand(CmdSet&);
|
||||
DefReturnResult func_bitxor(CmdSet&);
|
||||
DefReturnResult func_addevent(CmdSet&);
|
||||
DefReturnResult func_removeevent(CmdSet&);
|
||||
DefReturnResult func_abs(CmdSet&);
|
||||
DefReturnResult func_bigger(CmdSet&);
|
||||
DefReturnResult func_bigger_eq(CmdSet&);
|
||||
DefReturnResult func_equal(CmdSet&);
|
||||
DefReturnResult func_isset(CmdSet&);
|
||||
DefReturnResult func_not(CmdSet&);
|
||||
DefReturnResult func_smaller(CmdSet&);
|
||||
DefReturnResult func_smaller_eq(CmdSet&);
|
||||
DefReturnResult func_strlen(CmdSet&);
|
||||
DefReturnResult func_tohex(CmdSet&);
|
||||
DefReturnResult func_and(CmdSet&);
|
||||
DefReturnResult func_or(CmdSet&);
|
||||
DefReturnResult func_xor(CmdSet&);
|
||||
DefReturnResult func_substr(CmdSet&);
|
||||
DefReturnResult func_uppercase(CmdSet&);
|
||||
DefReturnResult func_lowercase(CmdSet&);
|
||||
DefReturnResult func_random(CmdSet&);
|
||||
DefReturnResult func_fileexists(CmdSet&);
|
||||
DefReturnResult func_strfind(CmdSet&);
|
||||
DefReturnResult func_scriptexists(CmdSet&);
|
||||
DefReturnResult func_funcexists(CmdSet&);
|
||||
|
||||
|
||||
// list functions
|
||||
DefReturnResult func_lpushback(CmdSet&);
|
||||
DefReturnResult func_lpushfront(CmdSet&);
|
||||
DefReturnResult func_lpopback(CmdSet&);
|
||||
DefReturnResult func_lpopfront(CmdSet&);
|
||||
DefReturnResult func_ldelete(CmdSet&);
|
||||
DefReturnResult func_lexists(CmdSet&);
|
||||
DefReturnResult func_llen(CmdSet&);
|
||||
DefReturnResult func_linsert(CmdSet&);
|
||||
DefReturnResult func_lsplit(CmdSet&);
|
||||
DefReturnResult func_lcsplit(CmdSet&);
|
||||
DefReturnResult func_ljoin(CmdSet&);
|
||||
DefReturnResult func_lindex(CmdSet&);
|
||||
DefReturnResult func_lclean(CmdSet&);
|
||||
DefReturnResult func_lmclean(CmdSet&);
|
||||
DefReturnResult func_lerase(CmdSet&);
|
||||
DefReturnResult func_lsort(CmdSet&);
|
||||
|
||||
// ByteBuffer functions
|
||||
DefReturnResult func_bbinit(CmdSet&);
|
||||
DefReturnResult func_bbdelete(CmdSet&);
|
||||
DefReturnResult func_bbappend(CmdSet&);
|
||||
DefReturnResult func_bbread(CmdSet&);
|
||||
DefReturnResult func_bbsetrpos(CmdSet&);
|
||||
DefReturnResult func_bbsetwpos(CmdSet&);
|
||||
DefReturnResult func_bbhexlike(CmdSet&);
|
||||
DefReturnResult func_bbtextlike(CmdSet&);
|
||||
DefReturnResult func_bbsize(CmdSet&);
|
||||
|
||||
// file functions
|
||||
DefReturnResult func_fopen(CmdSet&);
|
||||
DefReturnResult func_fclose(CmdSet&);
|
||||
DefReturnResult func_fisopen(CmdSet&);
|
||||
DefReturnResult func_feof(CmdSet&);
|
||||
DefReturnResult func_frpos(CmdSet&);
|
||||
DefReturnResult func_fwpos(CmdSet&);
|
||||
DefReturnResult func_fdel(CmdSet&);
|
||||
DefReturnResult func_fflush(CmdSet&);
|
||||
DefReturnResult func_fwrite(CmdSet&);
|
||||
DefReturnResult func_fread(CmdSet&);
|
||||
DefReturnResult func_freadb(CmdSet&);
|
||||
DefReturnResult func_fwriteb(CmdSet&);
|
||||
DefReturnResult func_freadbb(CmdSet&);
|
||||
DefReturnResult func_fwritebb(CmdSet&);
|
||||
DefReturnResult func_fsize(CmdSet&);
|
||||
DefReturnResult func_freadline(CmdSet&);
|
||||
DefReturnResult func_fseekw(CmdSet&);
|
||||
DefReturnResult func_fseekr(CmdSet&);
|
||||
|
||||
// setup own function declarations here
|
||||
# include "DefScriptInterfaceInclude.h"
|
||||
|
||||
// Own variable declarations
|
||||
std::map<std::string, unsigned char> my_usrPermissionMap;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,177 +1,177 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include "DefScript.h"
|
||||
#include "DefScriptTools.h"
|
||||
#include "SysDefs.h"
|
||||
#include "ByteBuffer.h"
|
||||
|
||||
using namespace DefScriptTools;
|
||||
|
||||
// Helper macros for insert/extract various datatypes that need type casting
|
||||
#define BB_CAN_READ(bytebuffer, _ty) ((*(bytebuffer)).size() - (*(bytebuffer)).rpos() >= sizeof(_ty))
|
||||
#define BB_MACRO_INSERT_I(bytebuffer, _sty, _ty) if( (_sty)==(#_ty) ) { *(bytebuffer) << (_ty)toUint64(Set.defaultarg); return true; }
|
||||
#define BB_MACRO_INSERT_F(bytebuffer, _sty, _ty) if( (_sty)==(#_ty) ) { *(bytebuffer) << (_ty)toNumber(Set.defaultarg); return true; }
|
||||
#define BB_MACRO_EXTRACT_I(bytebuffer, _sty, _ty) if( (_sty)==(#_ty) && BB_CAN_READ(bytebuffer,_ty) ) {_ty _var; *(bytebuffer) >> _var; return DefScriptTools::toString((uint64)_var); }
|
||||
#define BB_MACRO_EXTRACT_F(bytebuffer, _sty, _ty) if( (_sty)==(#_ty) && BB_CAN_READ(bytebuffer,_ty) ) {_ty _var; *(bytebuffer) >> _var; return DefScriptTools::toString((ldbl)_var); }
|
||||
|
||||
|
||||
// Initializes bytebuffer with initial capacity (reserved, not resized)
|
||||
// @def - bytebuffer identifier
|
||||
// @0 - if set, initial capacity
|
||||
DefReturnResult DefScriptPackage::func_bbinit(CmdSet& Set)
|
||||
{
|
||||
ByteBuffer *bb = bytebuffers.Get(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
bb->clear(); // also resets wpos & rpos
|
||||
if (!Set.arg[0].empty())
|
||||
bb->reserve((size_t)DefScriptTools::toUint64(Set.arg[0]));
|
||||
return true;
|
||||
}
|
||||
|
||||
// Cleans memory and deletes ByteBuffer from storage
|
||||
DefReturnResult DefScriptPackage::func_bbdelete(CmdSet& Set)
|
||||
{
|
||||
bytebuffers.Delete(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
return true;
|
||||
}
|
||||
|
||||
// Appends data to ByteBuffer
|
||||
// @def - data
|
||||
// @0 - bytebuffer identifier
|
||||
// @1 - datatype of added data (uint8,uint16,uint32,uint64,float,double,string,strnz)
|
||||
DefReturnResult DefScriptPackage::func_bbappend(CmdSet& Set)
|
||||
{
|
||||
ByteBuffer *bb = bytebuffers.Get(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
|
||||
std::string dtype = DefScriptTools::stringToLower(Set.arg[1]);
|
||||
|
||||
if (dtype == "string")
|
||||
{
|
||||
*bb << Set.defaultarg;
|
||||
return true;
|
||||
}
|
||||
else if(dtype == "strnz")
|
||||
{
|
||||
bb->append(Set.defaultarg.c_str(), Set.defaultarg.length()); // append the string skipping \0
|
||||
return true;
|
||||
}
|
||||
|
||||
BB_MACRO_INSERT_I(bb, dtype, uint8);
|
||||
BB_MACRO_INSERT_I(bb, dtype, uint16);
|
||||
BB_MACRO_INSERT_I(bb, dtype, uint32);
|
||||
BB_MACRO_INSERT_I(bb, dtype, uint64);
|
||||
BB_MACRO_INSERT_F(bb, dtype, float);
|
||||
BB_MACRO_INSERT_F(bb, dtype, double);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Extracts data from bytebuffer
|
||||
// @def - datatype to extract (uint8,uint16,uint32,uint64,float,double,string)
|
||||
// @0 - bytebuffer identifier
|
||||
DefReturnResult DefScriptPackage::func_bbread(CmdSet& Set)
|
||||
{
|
||||
ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if (!bb)
|
||||
return false;
|
||||
|
||||
std::string dtype = DefScriptTools::stringToLower(Set.defaultarg);
|
||||
|
||||
if (dtype == "string") {
|
||||
std::string g;
|
||||
*bb >> g;
|
||||
return g;
|
||||
}
|
||||
else if(dtype == "strnz") // extract some amount of bytes not terminated by \0
|
||||
{
|
||||
uint32 bytes = (uint32)toUint64(Set.arg[1]);
|
||||
if(bytes)
|
||||
{
|
||||
std::string g;
|
||||
char *buf = new char[bytes+1]; // +1 for \0
|
||||
buf[bytes] = 0;
|
||||
bb->read((uint8*)buf,bytes);
|
||||
g = buf;
|
||||
delete [] buf;
|
||||
return g;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
BB_MACRO_EXTRACT_I(bb, dtype, uint8);
|
||||
BB_MACRO_EXTRACT_I(bb, dtype, uint16);
|
||||
BB_MACRO_EXTRACT_I(bb, dtype, uint32);
|
||||
BB_MACRO_EXTRACT_I(bb, dtype, uint64);
|
||||
BB_MACRO_EXTRACT_F(bb, dtype, float);
|
||||
BB_MACRO_EXTRACT_F(bb, dtype, double);
|
||||
|
||||
return ""; // if extraction unsuccessful, return empty string
|
||||
}
|
||||
|
||||
// Sets read position in bytebuffer
|
||||
// @0 - bytebuffer identifier
|
||||
// @def - setted rpos (if "end", automatically set at end)
|
||||
DefReturnResult DefScriptPackage::func_bbsetrpos(CmdSet& Set)
|
||||
{
|
||||
ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if (!bb)
|
||||
return false;
|
||||
|
||||
if (Set.defaultarg == "end")
|
||||
bb->rpos( bb->size() );
|
||||
else
|
||||
bb->rpos( (unsigned int)toNumber(Set.defaultarg) );
|
||||
return true;
|
||||
}
|
||||
|
||||
// Sets write position in bytebuffer
|
||||
// @0 - bytebuffer identifier
|
||||
// @def - setted wpos (if "end", automatically set at end)
|
||||
DefReturnResult DefScriptPackage::func_bbsetwpos(CmdSet& Set)
|
||||
{
|
||||
ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if (!bb)
|
||||
return false;
|
||||
|
||||
if (Set.defaultarg == "end")
|
||||
bb->wpos( bb->size() );
|
||||
else
|
||||
bb->wpos( (unsigned int)toNumber(Set.defaultarg) );
|
||||
return true;
|
||||
}
|
||||
|
||||
// Hexlike output of bytebuffer to console
|
||||
// @def - bytebuffer identifier
|
||||
DefReturnResult DefScriptPackage::func_bbhexlike(CmdSet& Set)
|
||||
{
|
||||
ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
if (!bb)
|
||||
return false;
|
||||
|
||||
bb->hexlike();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Textlike output of bytebuffer to console
|
||||
// @def - bytebuffer identifier
|
||||
DefReturnResult DefScriptPackage::func_bbtextlike(CmdSet& Set)
|
||||
{
|
||||
ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
if (!bb)
|
||||
return false;
|
||||
|
||||
bb->textlike();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returns size of bytebuffer
|
||||
// @def - bytebuffer identifier
|
||||
DefReturnResult DefScriptPackage::func_bbsize(CmdSet& Set)
|
||||
{
|
||||
ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
if (!bb)
|
||||
return false;
|
||||
|
||||
return DefScriptTools::toString((uint64)bb->size());
|
||||
}
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include "DefScript.h"
|
||||
#include "DefScriptTools.h"
|
||||
#include "SysDefs.h"
|
||||
#include "ByteBuffer.h"
|
||||
|
||||
using namespace DefScriptTools;
|
||||
|
||||
// Helper macros for insert/extract various datatypes that need type casting
|
||||
#define BB_CAN_READ(bytebuffer, _ty) ((*(bytebuffer)).size() - (*(bytebuffer)).rpos() >= sizeof(_ty))
|
||||
#define BB_MACRO_INSERT_I(bytebuffer, _sty, _ty) if( (_sty)==(#_ty) ) { *(bytebuffer) << (_ty)toUint64(Set.defaultarg); return true; }
|
||||
#define BB_MACRO_INSERT_F(bytebuffer, _sty, _ty) if( (_sty)==(#_ty) ) { *(bytebuffer) << (_ty)toNumber(Set.defaultarg); return true; }
|
||||
#define BB_MACRO_EXTRACT_I(bytebuffer, _sty, _ty) if( (_sty)==(#_ty) && BB_CAN_READ(bytebuffer,_ty) ) {_ty _var; *(bytebuffer) >> _var; return DefScriptTools::toString((uint64)_var); }
|
||||
#define BB_MACRO_EXTRACT_F(bytebuffer, _sty, _ty) if( (_sty)==(#_ty) && BB_CAN_READ(bytebuffer,_ty) ) {_ty _var; *(bytebuffer) >> _var; return DefScriptTools::toString((ldbl)_var); }
|
||||
|
||||
|
||||
// Initializes bytebuffer with initial capacity (reserved, not resized)
|
||||
// @def - bytebuffer identifier
|
||||
// @0 - if set, initial capacity
|
||||
DefReturnResult DefScriptPackage::func_bbinit(CmdSet& Set)
|
||||
{
|
||||
ByteBuffer *bb = bytebuffers.Get(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
bb->clear(); // also resets wpos & rpos
|
||||
if (!Set.arg[0].empty())
|
||||
bb->reserve((size_t)DefScriptTools::toUint64(Set.arg[0]));
|
||||
return true;
|
||||
}
|
||||
|
||||
// Cleans memory and deletes ByteBuffer from storage
|
||||
DefReturnResult DefScriptPackage::func_bbdelete(CmdSet& Set)
|
||||
{
|
||||
bytebuffers.Delete(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
return true;
|
||||
}
|
||||
|
||||
// Appends data to ByteBuffer
|
||||
// @def - data
|
||||
// @0 - bytebuffer identifier
|
||||
// @1 - datatype of added data (uint8,uint16,uint32,uint64,float,double,string,strnz)
|
||||
DefReturnResult DefScriptPackage::func_bbappend(CmdSet& Set)
|
||||
{
|
||||
ByteBuffer *bb = bytebuffers.Get(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
|
||||
std::string dtype = DefScriptTools::stringToLower(Set.arg[1]);
|
||||
|
||||
if (dtype == "string")
|
||||
{
|
||||
*bb << Set.defaultarg;
|
||||
return true;
|
||||
}
|
||||
else if(dtype == "strnz")
|
||||
{
|
||||
bb->append(Set.defaultarg.c_str(), Set.defaultarg.length()); // append the string skipping \0
|
||||
return true;
|
||||
}
|
||||
|
||||
BB_MACRO_INSERT_I(bb, dtype, uint8);
|
||||
BB_MACRO_INSERT_I(bb, dtype, uint16);
|
||||
BB_MACRO_INSERT_I(bb, dtype, uint32);
|
||||
BB_MACRO_INSERT_I(bb, dtype, uint64);
|
||||
BB_MACRO_INSERT_F(bb, dtype, float);
|
||||
BB_MACRO_INSERT_F(bb, dtype, double);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Extracts data from bytebuffer
|
||||
// @def - datatype to extract (uint8,uint16,uint32,uint64,float,double,string)
|
||||
// @0 - bytebuffer identifier
|
||||
DefReturnResult DefScriptPackage::func_bbread(CmdSet& Set)
|
||||
{
|
||||
ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if (!bb)
|
||||
return false;
|
||||
|
||||
std::string dtype = DefScriptTools::stringToLower(Set.defaultarg);
|
||||
|
||||
if (dtype == "string") {
|
||||
std::string g;
|
||||
*bb >> g;
|
||||
return g;
|
||||
}
|
||||
else if(dtype == "strnz") // extract some amount of bytes not terminated by \0
|
||||
{
|
||||
uint32 bytes = (uint32)toUint64(Set.arg[1]);
|
||||
if(bytes)
|
||||
{
|
||||
std::string g;
|
||||
char *buf = new char[bytes+1]; // +1 for \0
|
||||
buf[bytes] = 0;
|
||||
bb->read((uint8*)buf,bytes);
|
||||
g = buf;
|
||||
delete [] buf;
|
||||
return g;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
BB_MACRO_EXTRACT_I(bb, dtype, uint8);
|
||||
BB_MACRO_EXTRACT_I(bb, dtype, uint16);
|
||||
BB_MACRO_EXTRACT_I(bb, dtype, uint32);
|
||||
BB_MACRO_EXTRACT_I(bb, dtype, uint64);
|
||||
BB_MACRO_EXTRACT_F(bb, dtype, float);
|
||||
BB_MACRO_EXTRACT_F(bb, dtype, double);
|
||||
|
||||
return ""; // if extraction unsuccessful, return empty string
|
||||
}
|
||||
|
||||
// Sets read position in bytebuffer
|
||||
// @0 - bytebuffer identifier
|
||||
// @def - setted rpos (if "end", automatically set at end)
|
||||
DefReturnResult DefScriptPackage::func_bbsetrpos(CmdSet& Set)
|
||||
{
|
||||
ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if (!bb)
|
||||
return false;
|
||||
|
||||
if (Set.defaultarg == "end")
|
||||
bb->rpos( bb->size() );
|
||||
else
|
||||
bb->rpos( (unsigned int)toNumber(Set.defaultarg) );
|
||||
return true;
|
||||
}
|
||||
|
||||
// Sets write position in bytebuffer
|
||||
// @0 - bytebuffer identifier
|
||||
// @def - setted wpos (if "end", automatically set at end)
|
||||
DefReturnResult DefScriptPackage::func_bbsetwpos(CmdSet& Set)
|
||||
{
|
||||
ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if (!bb)
|
||||
return false;
|
||||
|
||||
if (Set.defaultarg == "end")
|
||||
bb->wpos( bb->size() );
|
||||
else
|
||||
bb->wpos( (unsigned int)toNumber(Set.defaultarg) );
|
||||
return true;
|
||||
}
|
||||
|
||||
// Hexlike output of bytebuffer to console
|
||||
// @def - bytebuffer identifier
|
||||
DefReturnResult DefScriptPackage::func_bbhexlike(CmdSet& Set)
|
||||
{
|
||||
ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
if (!bb)
|
||||
return false;
|
||||
|
||||
bb->hexlike();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Textlike output of bytebuffer to console
|
||||
// @def - bytebuffer identifier
|
||||
DefReturnResult DefScriptPackage::func_bbtextlike(CmdSet& Set)
|
||||
{
|
||||
ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
if (!bb)
|
||||
return false;
|
||||
|
||||
bb->textlike();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Returns size of bytebuffer
|
||||
// @def - bytebuffer identifier
|
||||
DefReturnResult DefScriptPackage::func_bbsize(CmdSet& Set)
|
||||
{
|
||||
ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
if (!bb)
|
||||
return false;
|
||||
|
||||
return DefScriptTools::toString((uint64)bb->size());
|
||||
}
|
||||
|
||||
@ -1,40 +1,40 @@
|
||||
#ifndef DEFSCRIPTDEFINES_H
|
||||
#define DEFSCRIPTDEFINES_H
|
||||
|
||||
#include "SysDefs.h"
|
||||
|
||||
// use this directive to check if the parser is working correctly
|
||||
#define DEF_DEBUG_SCRIPT_CALLS
|
||||
|
||||
#ifdef _DEBUG
|
||||
# define _DEFSC_DEBUG(code) code;
|
||||
# define _DEFSC_DEBUG_LOG DebugLog // does NOT YET work!!
|
||||
#else
|
||||
# define _DEFSC_DEBUG(code)
|
||||
# define _DEFSC_DEBUG_LOG
|
||||
#endif
|
||||
|
||||
// now included in SysDefs.h
|
||||
/*
|
||||
#if COMPILER == COMPILER_MICROSOFT
|
||||
typedef __int64 int64;
|
||||
typedef unsigned __int64 uint64;
|
||||
#else
|
||||
typedef __int64_t int64;
|
||||
typedef __uint64_t uint64;
|
||||
// TODO: correct ATOI64 for linux if necessary
|
||||
#endif
|
||||
*/
|
||||
|
||||
enum VariableType
|
||||
{
|
||||
DEFSCRIPT_NONE=0,
|
||||
DEFSCRIPT_VAR,
|
||||
DEFSCRIPT_FUNC
|
||||
};
|
||||
|
||||
typedef long double ldbl;
|
||||
|
||||
#define SCRIPT_NAMESPACE "DEFSCRIPT::SCRIPT::"
|
||||
|
||||
#ifndef DEFSCRIPTDEFINES_H
|
||||
#define DEFSCRIPTDEFINES_H
|
||||
|
||||
#include "SysDefs.h"
|
||||
|
||||
// use this directive to check if the parser is working correctly
|
||||
#define DEF_DEBUG_SCRIPT_CALLS
|
||||
|
||||
#ifdef _DEBUG
|
||||
# define _DEFSC_DEBUG(code) code;
|
||||
# define _DEFSC_DEBUG_LOG DebugLog // does NOT YET work!!
|
||||
#else
|
||||
# define _DEFSC_DEBUG(code)
|
||||
# define _DEFSC_DEBUG_LOG
|
||||
#endif
|
||||
|
||||
// now included in SysDefs.h
|
||||
/*
|
||||
#if COMPILER == COMPILER_MICROSOFT
|
||||
typedef __int64 int64;
|
||||
typedef unsigned __int64 uint64;
|
||||
#else
|
||||
typedef __int64_t int64;
|
||||
typedef __uint64_t uint64;
|
||||
// TODO: correct ATOI64 for linux if necessary
|
||||
#endif
|
||||
*/
|
||||
|
||||
enum VariableType
|
||||
{
|
||||
DEFSCRIPT_NONE=0,
|
||||
DEFSCRIPT_VAR,
|
||||
DEFSCRIPT_FUNC
|
||||
};
|
||||
|
||||
typedef long double ldbl;
|
||||
|
||||
#define SCRIPT_NAMESPACE "DEFSCRIPT::SCRIPT::"
|
||||
|
||||
#endif
|
||||
@ -1,361 +1,361 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include "DefScript.h"
|
||||
#include "DefScriptTools.h"
|
||||
#include "SysDefs.h"
|
||||
|
||||
using namespace DefScriptTools;
|
||||
|
||||
#define FH_MACRO_READ_I(_f,_sty,_ty) if(_sty==(#_ty)) { _ty _in; (_f)->read((char*)&_in,sizeof(_ty)); return toString((uint64)_in); }
|
||||
#define FH_MACRO_READ_F(_f,_sty,_ty) if(_sty==(#_ty)) { _ty _in; (_f)->read((char*)&_in,sizeof(_ty)); return toString((ldbl)_in); }
|
||||
|
||||
DefReturnResult DefScriptPackage::func_fopen(CmdSet& Set)
|
||||
{
|
||||
std::fstream *fh = files.Get(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if(fh->is_open())
|
||||
return "";
|
||||
std::string mode = stringToLower(Set.arg[1]);
|
||||
std::ios::openmode m = 0;
|
||||
if(mode.find('b') != std::string::npos)
|
||||
m |= std::ios_base::binary;
|
||||
if(mode.find('a') != std::string::npos)
|
||||
m |= std::ios_base::app;
|
||||
if(mode.find('r') != std::string::npos)
|
||||
m |= std::ios_base::in;
|
||||
if(mode.find('w') != std::string::npos)
|
||||
m |= std::ios_base::out;
|
||||
|
||||
// sort out some possible errors with bad open modes
|
||||
if(m & std::ios_base::app)
|
||||
m |= std::ios_base::out; // always open for writing when appending
|
||||
if(m == 0 || m == std::ios_base::binary)
|
||||
m |= std::ios_base::out | std::ios_base::in; // if no openmode or binary only specified, use both r+w additionally
|
||||
|
||||
fh->open(Set.defaultarg.c_str(), m);
|
||||
|
||||
// if the file didnt open properly, like if a not existing file opened in read+write mode,
|
||||
// try fallback mode with write mode only
|
||||
if(!fh->is_open() && (m & std::ios_base::in))
|
||||
{
|
||||
m &= (~std::ios_base::in);
|
||||
fh->open(Set.defaultarg.c_str(), m);
|
||||
}
|
||||
_DEFSC_DEBUG( if(!fh->is_open()) printf("DefScript: Can't open file '%s'\n",Set.defaultarg.c_str()));
|
||||
return fh->is_open();
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_fclose(CmdSet& Set)
|
||||
{
|
||||
std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
if(fh)
|
||||
{
|
||||
fh->flush();
|
||||
fh->close();
|
||||
files.DeleteByPtr(fh);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_fisopen(CmdSet& Set)
|
||||
{
|
||||
std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
return fh && fh->good() && fh->is_open();
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_feof(CmdSet& Set)
|
||||
{
|
||||
std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
return (!fh) || fh->eof();
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_frpos(CmdSet& Set)
|
||||
{
|
||||
std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
if(!fh)
|
||||
return "";
|
||||
return toString((uint64)fh->tellg());
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_fwpos(CmdSet& Set)
|
||||
{
|
||||
std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
if(!fh)
|
||||
return "";
|
||||
return toString((uint64)fh->tellp());
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_fdel(CmdSet& Set)
|
||||
{
|
||||
return (remove(Set.defaultarg.c_str()) == 0);
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_fflush(CmdSet& Set)
|
||||
{
|
||||
std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
if(fh && fh->is_open())
|
||||
fh->flush();
|
||||
return "";
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_fwrite(CmdSet& Set)
|
||||
{
|
||||
std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if(fh && fh->is_open())
|
||||
{
|
||||
*fh << Set.defaultarg;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_fread(CmdSet& Set)
|
||||
{
|
||||
std::string fn = _NormalizeVarName(Set.arg[0],Set.myname);
|
||||
std::fstream *fh = files.GetNoCreate(fn);
|
||||
if(fh && fh->is_open())
|
||||
{
|
||||
uint64 bytes;
|
||||
uint64 read = 0;
|
||||
if(stringToLower(Set.defaultarg) == "all")
|
||||
{
|
||||
std::fstream::pos_type begin_pos, end_pos, old_pos = fh->tellg();
|
||||
fh->seekg(0, std::ios_base::beg);
|
||||
begin_pos=fh->tellg();
|
||||
fh->seekg(0, std::ios_base::end);
|
||||
end_pos = fh->tellg();
|
||||
fh->seekg(old_pos, std::ios_base::beg);
|
||||
bytes = (end_pos - begin_pos);
|
||||
}
|
||||
else
|
||||
bytes = toUint64(Set.defaultarg);
|
||||
std::string ret;
|
||||
ret.reserve(bytes);
|
||||
for(uint64 i = 0; i < bytes && !fh->eof(); i++)
|
||||
{
|
||||
ret += fh->get();
|
||||
read++;
|
||||
}
|
||||
return toString(read);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_freadb(CmdSet& Set)
|
||||
{
|
||||
std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if(fh && fh->is_open())
|
||||
{
|
||||
std::string t = stringToLower(Set.defaultarg);
|
||||
if(t == "string")
|
||||
{
|
||||
std::string ret;
|
||||
while(char c = fh->get() && !fh->eof())
|
||||
ret += c;
|
||||
return ret;
|
||||
}
|
||||
else if(t == "strnz")
|
||||
{
|
||||
uint32 bytes = (uint32)toUint64(Set.arg[1]);
|
||||
if(bytes)
|
||||
{
|
||||
std::string g;
|
||||
for(uint32 i = 0; i < bytes; i++)
|
||||
{
|
||||
g += fh->get();
|
||||
}
|
||||
return g;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
FH_MACRO_READ_I(fh,t,uint8);
|
||||
FH_MACRO_READ_I(fh,t,uint16);
|
||||
FH_MACRO_READ_I(fh,t,uint32);
|
||||
FH_MACRO_READ_I(fh,t,uint64);
|
||||
FH_MACRO_READ_F(fh,t,float);
|
||||
FH_MACRO_READ_F(fh,t,double);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_fwriteb(CmdSet& Set)
|
||||
{
|
||||
std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if(fh && fh->is_open())
|
||||
{
|
||||
std::string t = stringToLower(Set.arg[1]);
|
||||
if(t == "string")
|
||||
{
|
||||
fh->write(Set.defaultarg.c_str(), Set.defaultarg.size() + 1); // also put \0
|
||||
return true;
|
||||
}
|
||||
else if(t == "strnz")
|
||||
{
|
||||
fh->write(Set.defaultarg.c_str(), Set.defaultarg.size()); // skip \0
|
||||
return true;
|
||||
}
|
||||
else if(t == "uint8")
|
||||
{
|
||||
uint8 o = (uint8)toUint64(Set.defaultarg);
|
||||
fh->write((char*)&o,sizeof(uint8));
|
||||
return true;
|
||||
}
|
||||
else if(t == "uint16")
|
||||
{
|
||||
uint16 o = (uint16)toUint64(Set.defaultarg);
|
||||
fh->write((char*)&o,sizeof(uint16));
|
||||
return true;
|
||||
}
|
||||
else if(t == "uint32")
|
||||
{
|
||||
uint32 o = (uint32)toUint64(Set.defaultarg);
|
||||
fh->write((char*)&o,sizeof(uint32));
|
||||
return true;
|
||||
}
|
||||
else if(t == "uint64")
|
||||
{
|
||||
uint64 o = toUint64(Set.defaultarg);
|
||||
fh->write((char*)&o,sizeof(uint64));
|
||||
return true;
|
||||
}
|
||||
else if(t == "float")
|
||||
{
|
||||
float o = (float)toNumber(Set.defaultarg);
|
||||
fh->write((char*)&o,sizeof(float));
|
||||
return true;
|
||||
}
|
||||
else if(t == "double")
|
||||
{
|
||||
double o = (double)toNumber(Set.defaultarg);
|
||||
fh->write((char*)&o,sizeof(double));
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_fwritebb(CmdSet& Set)
|
||||
{
|
||||
std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if(fh && fh->is_open())
|
||||
{
|
||||
ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
if(bb)
|
||||
{
|
||||
uint32 bytes = (uint32)toUint64(Set.arg[1]);
|
||||
if(!bytes)
|
||||
{
|
||||
bytes = bb->size();
|
||||
}
|
||||
if(bytes)
|
||||
{
|
||||
fh->write((char*)bb->contents(), bytes);
|
||||
}
|
||||
return toString((uint64)bytes);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_freadbb(CmdSet& Set)
|
||||
{
|
||||
std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if(fh && fh->is_open())
|
||||
{
|
||||
ByteBuffer *bb = bytebuffers.Get(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
uint32 bytes = (uint32)toUint64(Set.arg[1]);
|
||||
if(!bytes)
|
||||
{
|
||||
// get amount of remaining bytes
|
||||
std::ios::pos_type oldpos = fh->tellg();
|
||||
fh->seekg(0,std::ios_base::end);
|
||||
bytes = uint32(fh->tellg() - oldpos);
|
||||
fh->seekg(oldpos,std::ios_base::beg);
|
||||
}
|
||||
if(bytes)
|
||||
{
|
||||
bb->resize(bb->size() + bytes);
|
||||
fh->read((char*)bb->contents(), bytes);
|
||||
}
|
||||
return toString((uint64)bytes);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_fsize(CmdSet& Set)
|
||||
{
|
||||
std::ifstream f;
|
||||
f.open(Set.defaultarg.c_str(), std::ios_base::binary | std::ios_base::in);
|
||||
if (!f.good() || f.eof() || !f.is_open()) { return ""; }
|
||||
f.seekg(0, std::ios_base::beg);
|
||||
std::ifstream::pos_type begin_pos = f.tellg(), end_pos;
|
||||
f.seekg(0, std::ios_base::end);
|
||||
end_pos = f.tellg();
|
||||
f.close();
|
||||
return toString((uint64)(end_pos - begin_pos));
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_freadline(CmdSet& Set)
|
||||
{
|
||||
std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
if(fh && fh->is_open())
|
||||
{
|
||||
char c;
|
||||
std::string line;
|
||||
line.reserve(30); // rough guess to speedup appending
|
||||
while(!fh->eof())
|
||||
{
|
||||
c = fh->get();
|
||||
if(c == '\n' || fh->eof())
|
||||
return line;
|
||||
else
|
||||
line += c;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_fseekw(CmdSet& Set)
|
||||
{
|
||||
std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if(fh && fh->is_open())
|
||||
{
|
||||
std::string w = stringToLower(Set.arg[1]);
|
||||
uint32 pos = (uint32)toUint64(Set.defaultarg);
|
||||
if(w.empty() || w == "begin")
|
||||
{
|
||||
fh->seekp(pos, std::ios_base::beg);
|
||||
return true;
|
||||
}
|
||||
else if(w == "end")
|
||||
{
|
||||
fh->seekp(pos, std::ios_base::end);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_fseekr(CmdSet& Set)
|
||||
{
|
||||
std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if(fh && fh->is_open())
|
||||
{
|
||||
std::string w = stringToLower(Set.arg[1]);
|
||||
uint32 pos = (uint32)toUint64(Set.defaultarg);
|
||||
if(w.empty() || w == "begin")
|
||||
{
|
||||
fh->seekg(pos, std::ios_base::beg);
|
||||
return true;
|
||||
}
|
||||
else if(w == "end")
|
||||
{
|
||||
fh->seekg(pos, std::ios_base::end);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include "DefScript.h"
|
||||
#include "DefScriptTools.h"
|
||||
#include "SysDefs.h"
|
||||
|
||||
using namespace DefScriptTools;
|
||||
|
||||
#define FH_MACRO_READ_I(_f,_sty,_ty) if(_sty==(#_ty)) { _ty _in; (_f)->read((char*)&_in,sizeof(_ty)); return toString((uint64)_in); }
|
||||
#define FH_MACRO_READ_F(_f,_sty,_ty) if(_sty==(#_ty)) { _ty _in; (_f)->read((char*)&_in,sizeof(_ty)); return toString((ldbl)_in); }
|
||||
|
||||
DefReturnResult DefScriptPackage::func_fopen(CmdSet& Set)
|
||||
{
|
||||
std::fstream *fh = files.Get(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if(fh->is_open())
|
||||
return "";
|
||||
std::string mode = stringToLower(Set.arg[1]);
|
||||
std::ios::openmode m = 0;
|
||||
if(mode.find('b') != std::string::npos)
|
||||
m |= std::ios_base::binary;
|
||||
if(mode.find('a') != std::string::npos)
|
||||
m |= std::ios_base::app;
|
||||
if(mode.find('r') != std::string::npos)
|
||||
m |= std::ios_base::in;
|
||||
if(mode.find('w') != std::string::npos)
|
||||
m |= std::ios_base::out;
|
||||
|
||||
// sort out some possible errors with bad open modes
|
||||
if(m & std::ios_base::app)
|
||||
m |= std::ios_base::out; // always open for writing when appending
|
||||
if(m == 0 || m == std::ios_base::binary)
|
||||
m |= std::ios_base::out | std::ios_base::in; // if no openmode or binary only specified, use both r+w additionally
|
||||
|
||||
fh->open(Set.defaultarg.c_str(), m);
|
||||
|
||||
// if the file didnt open properly, like if a not existing file opened in read+write mode,
|
||||
// try fallback mode with write mode only
|
||||
if(!fh->is_open() && (m & std::ios_base::in))
|
||||
{
|
||||
m &= (~std::ios_base::in);
|
||||
fh->open(Set.defaultarg.c_str(), m);
|
||||
}
|
||||
_DEFSC_DEBUG( if(!fh->is_open()) printf("DefScript: Can't open file '%s'\n",Set.defaultarg.c_str()));
|
||||
return fh->is_open();
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_fclose(CmdSet& Set)
|
||||
{
|
||||
std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
if(fh)
|
||||
{
|
||||
fh->flush();
|
||||
fh->close();
|
||||
files.DeleteByPtr(fh);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_fisopen(CmdSet& Set)
|
||||
{
|
||||
std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
return fh && fh->good() && fh->is_open();
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_feof(CmdSet& Set)
|
||||
{
|
||||
std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
return (!fh) || fh->eof();
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_frpos(CmdSet& Set)
|
||||
{
|
||||
std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
if(!fh)
|
||||
return "";
|
||||
return toString((uint64)fh->tellg());
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_fwpos(CmdSet& Set)
|
||||
{
|
||||
std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
if(!fh)
|
||||
return "";
|
||||
return toString((uint64)fh->tellp());
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_fdel(CmdSet& Set)
|
||||
{
|
||||
return (remove(Set.defaultarg.c_str()) == 0);
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_fflush(CmdSet& Set)
|
||||
{
|
||||
std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
if(fh && fh->is_open())
|
||||
fh->flush();
|
||||
return "";
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_fwrite(CmdSet& Set)
|
||||
{
|
||||
std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if(fh && fh->is_open())
|
||||
{
|
||||
*fh << Set.defaultarg;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_fread(CmdSet& Set)
|
||||
{
|
||||
std::string fn = _NormalizeVarName(Set.arg[0],Set.myname);
|
||||
std::fstream *fh = files.GetNoCreate(fn);
|
||||
if(fh && fh->is_open())
|
||||
{
|
||||
uint64 bytes;
|
||||
uint64 read = 0;
|
||||
if(stringToLower(Set.defaultarg) == "all")
|
||||
{
|
||||
std::fstream::pos_type begin_pos, end_pos, old_pos = fh->tellg();
|
||||
fh->seekg(0, std::ios_base::beg);
|
||||
begin_pos=fh->tellg();
|
||||
fh->seekg(0, std::ios_base::end);
|
||||
end_pos = fh->tellg();
|
||||
fh->seekg(old_pos, std::ios_base::beg);
|
||||
bytes = (end_pos - begin_pos);
|
||||
}
|
||||
else
|
||||
bytes = toUint64(Set.defaultarg);
|
||||
std::string ret;
|
||||
ret.reserve(bytes);
|
||||
for(uint64 i = 0; i < bytes && !fh->eof(); i++)
|
||||
{
|
||||
ret += fh->get();
|
||||
read++;
|
||||
}
|
||||
return toString(read);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_freadb(CmdSet& Set)
|
||||
{
|
||||
std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if(fh && fh->is_open())
|
||||
{
|
||||
std::string t = stringToLower(Set.defaultarg);
|
||||
if(t == "string")
|
||||
{
|
||||
std::string ret;
|
||||
while(char c = fh->get() && !fh->eof())
|
||||
ret += c;
|
||||
return ret;
|
||||
}
|
||||
else if(t == "strnz")
|
||||
{
|
||||
uint32 bytes = (uint32)toUint64(Set.arg[1]);
|
||||
if(bytes)
|
||||
{
|
||||
std::string g;
|
||||
for(uint32 i = 0; i < bytes; i++)
|
||||
{
|
||||
g += fh->get();
|
||||
}
|
||||
return g;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
FH_MACRO_READ_I(fh,t,uint8);
|
||||
FH_MACRO_READ_I(fh,t,uint16);
|
||||
FH_MACRO_READ_I(fh,t,uint32);
|
||||
FH_MACRO_READ_I(fh,t,uint64);
|
||||
FH_MACRO_READ_F(fh,t,float);
|
||||
FH_MACRO_READ_F(fh,t,double);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_fwriteb(CmdSet& Set)
|
||||
{
|
||||
std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if(fh && fh->is_open())
|
||||
{
|
||||
std::string t = stringToLower(Set.arg[1]);
|
||||
if(t == "string")
|
||||
{
|
||||
fh->write(Set.defaultarg.c_str(), Set.defaultarg.size() + 1); // also put \0
|
||||
return true;
|
||||
}
|
||||
else if(t == "strnz")
|
||||
{
|
||||
fh->write(Set.defaultarg.c_str(), Set.defaultarg.size()); // skip \0
|
||||
return true;
|
||||
}
|
||||
else if(t == "uint8")
|
||||
{
|
||||
uint8 o = (uint8)toUint64(Set.defaultarg);
|
||||
fh->write((char*)&o,sizeof(uint8));
|
||||
return true;
|
||||
}
|
||||
else if(t == "uint16")
|
||||
{
|
||||
uint16 o = (uint16)toUint64(Set.defaultarg);
|
||||
fh->write((char*)&o,sizeof(uint16));
|
||||
return true;
|
||||
}
|
||||
else if(t == "uint32")
|
||||
{
|
||||
uint32 o = (uint32)toUint64(Set.defaultarg);
|
||||
fh->write((char*)&o,sizeof(uint32));
|
||||
return true;
|
||||
}
|
||||
else if(t == "uint64")
|
||||
{
|
||||
uint64 o = toUint64(Set.defaultarg);
|
||||
fh->write((char*)&o,sizeof(uint64));
|
||||
return true;
|
||||
}
|
||||
else if(t == "float")
|
||||
{
|
||||
float o = (float)toNumber(Set.defaultarg);
|
||||
fh->write((char*)&o,sizeof(float));
|
||||
return true;
|
||||
}
|
||||
else if(t == "double")
|
||||
{
|
||||
double o = (double)toNumber(Set.defaultarg);
|
||||
fh->write((char*)&o,sizeof(double));
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_fwritebb(CmdSet& Set)
|
||||
{
|
||||
std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if(fh && fh->is_open())
|
||||
{
|
||||
ByteBuffer *bb = bytebuffers.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
if(bb)
|
||||
{
|
||||
uint32 bytes = (uint32)toUint64(Set.arg[1]);
|
||||
if(!bytes)
|
||||
{
|
||||
bytes = bb->size();
|
||||
}
|
||||
if(bytes)
|
||||
{
|
||||
fh->write((char*)bb->contents(), bytes);
|
||||
}
|
||||
return toString((uint64)bytes);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_freadbb(CmdSet& Set)
|
||||
{
|
||||
std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if(fh && fh->is_open())
|
||||
{
|
||||
ByteBuffer *bb = bytebuffers.Get(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
uint32 bytes = (uint32)toUint64(Set.arg[1]);
|
||||
if(!bytes)
|
||||
{
|
||||
// get amount of remaining bytes
|
||||
std::ios::pos_type oldpos = fh->tellg();
|
||||
fh->seekg(0,std::ios_base::end);
|
||||
bytes = uint32(fh->tellg() - oldpos);
|
||||
fh->seekg(oldpos,std::ios_base::beg);
|
||||
}
|
||||
if(bytes)
|
||||
{
|
||||
bb->resize(bb->size() + bytes);
|
||||
fh->read((char*)bb->contents(), bytes);
|
||||
}
|
||||
return toString((uint64)bytes);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_fsize(CmdSet& Set)
|
||||
{
|
||||
std::ifstream f;
|
||||
f.open(Set.defaultarg.c_str(), std::ios_base::binary | std::ios_base::in);
|
||||
if (!f.good() || f.eof() || !f.is_open()) { return ""; }
|
||||
f.seekg(0, std::ios_base::beg);
|
||||
std::ifstream::pos_type begin_pos = f.tellg(), end_pos;
|
||||
f.seekg(0, std::ios_base::end);
|
||||
end_pos = f.tellg();
|
||||
f.close();
|
||||
return toString((uint64)(end_pos - begin_pos));
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_freadline(CmdSet& Set)
|
||||
{
|
||||
std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
if(fh && fh->is_open())
|
||||
{
|
||||
char c;
|
||||
std::string line;
|
||||
line.reserve(30); // rough guess to speedup appending
|
||||
while(!fh->eof())
|
||||
{
|
||||
c = fh->get();
|
||||
if(c == '\n' || fh->eof())
|
||||
return line;
|
||||
else
|
||||
line += c;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_fseekw(CmdSet& Set)
|
||||
{
|
||||
std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if(fh && fh->is_open())
|
||||
{
|
||||
std::string w = stringToLower(Set.arg[1]);
|
||||
uint32 pos = (uint32)toUint64(Set.defaultarg);
|
||||
if(w.empty() || w == "begin")
|
||||
{
|
||||
fh->seekp(pos, std::ios_base::beg);
|
||||
return true;
|
||||
}
|
||||
else if(w == "end")
|
||||
{
|
||||
fh->seekp(pos, std::ios_base::end);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_fseekr(CmdSet& Set)
|
||||
{
|
||||
std::fstream *fh = files.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if(fh && fh->is_open())
|
||||
{
|
||||
std::string w = stringToLower(Set.arg[1]);
|
||||
uint32 pos = (uint32)toUint64(Set.defaultarg);
|
||||
if(w.empty() || w == "begin")
|
||||
{
|
||||
fh->seekg(pos, std::ios_base::beg);
|
||||
return true;
|
||||
}
|
||||
else if(w == "end")
|
||||
{
|
||||
fh->seekg(pos, std::ios_base::end);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,296 +1,296 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include "DefScript.h"
|
||||
|
||||
using namespace DefScriptTools;
|
||||
|
||||
DefReturnResult DefScriptPackage::func_lpushback(CmdSet& Set)
|
||||
{
|
||||
DefList *l = lists.Get(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
l->push_back(Set.defaultarg);
|
||||
return true;
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_lpushfront(CmdSet& Set)
|
||||
{
|
||||
DefList *l = lists.Get(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
l->push_front(Set.defaultarg);
|
||||
return true;
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_lpopback(CmdSet& Set)
|
||||
{
|
||||
std::string r;
|
||||
DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
if( (!l) || (!l->size()) ) // cant pop any element if the list doesnt exist or is empty
|
||||
return "";
|
||||
r= l->back();
|
||||
l->pop_back();
|
||||
return r;
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_lpopfront(CmdSet& Set)
|
||||
{
|
||||
std::string r;
|
||||
DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
if( (!l) || (!l->size()) ) // cant pop any element if the list doesnt exist or is empty
|
||||
return "";
|
||||
r = l->front();
|
||||
l->pop_front();
|
||||
return r;
|
||||
}
|
||||
|
||||
// delete a list and all its elements
|
||||
DefReturnResult DefScriptPackage::func_ldelete(CmdSet& Set)
|
||||
{
|
||||
std::string lname = _NormalizeVarName(Set.defaultarg,Set.myname);
|
||||
if(strncmp(lname.c_str(), SCRIPT_NAMESPACE,strlen(SCRIPT_NAMESPACE))==0)
|
||||
{
|
||||
printf("DefScript: WARNING: ldelete used on a script list, clearing instead! (called by '%s', list '%s')\n",Set.myname.c_str(), lname.c_str());
|
||||
DefList *l = lists.GetNoCreate(lname);
|
||||
if(l)
|
||||
l->clear();
|
||||
return true;
|
||||
}
|
||||
lists.Delete(lname);
|
||||
return true;
|
||||
}
|
||||
|
||||
// returns true if a list with the given name exists, else false
|
||||
DefReturnResult DefScriptPackage::func_lexists(CmdSet& Set)
|
||||
{
|
||||
return lists.Exists(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
}
|
||||
|
||||
// return list element count
|
||||
DefReturnResult DefScriptPackage::func_llen(CmdSet& Set)
|
||||
{
|
||||
DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
if(!l)
|
||||
return ""; // return nothing if list doesnt exist
|
||||
return toString((uint64)l->size()); // return any number
|
||||
}
|
||||
|
||||
// insert item at some position in the list
|
||||
DefReturnResult DefScriptPackage::func_linsert(CmdSet& Set)
|
||||
{
|
||||
bool result;
|
||||
DefList *l = lists.Get(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
unsigned int pos = (unsigned int)toNumber(Set.arg[1]);
|
||||
if(pos > l->size()) // if the list is too short to insert at that pos...
|
||||
{
|
||||
l->push_back(Set.defaultarg); // ... just append at the end
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
DefList::iterator it = l->begin();
|
||||
advance(it,pos);
|
||||
l->insert(it,Set.defaultarg); // ... else insert at correct position
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// returns the amount of string fragments added to the list
|
||||
// arg0: list name; arg1: delimiter string; defaultarg: string to split
|
||||
DefReturnResult DefScriptPackage::func_lsplit(CmdSet& Set)
|
||||
{
|
||||
// 1st create a new list, or get an already existing one and clear it
|
||||
DefList *l = lists.Get(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
l->clear();
|
||||
if(Set.defaultarg.empty()) // we cant split an empty string, return nothing, and keep empty list
|
||||
return "";
|
||||
|
||||
// special case: empty delimiter -> split in chars
|
||||
if(Set.arg[1].empty())
|
||||
{
|
||||
for(unsigned int i=0; i<Set.defaultarg.length(); i++)
|
||||
{
|
||||
std::string tmp;
|
||||
tmp = Set.defaultarg[i];
|
||||
l->push_back(tmp);
|
||||
}
|
||||
return toString((uint64)l->size());
|
||||
}
|
||||
|
||||
unsigned int p,q=0; // p=position of substr; q=next pos to start searching at
|
||||
while( (p = Set.defaultarg.find(Set.arg[1].c_str(),q)) != std::string::npos)
|
||||
{
|
||||
l->push_back( Set.defaultarg.substr(q,p - q) );
|
||||
q = p + Set.arg[1].length();
|
||||
}
|
||||
if(q < Set.defaultarg.length()) // also append the last string fragment (that has no delimiter)
|
||||
{
|
||||
l->push_back(Set.defaultarg.c_str() + q);
|
||||
}
|
||||
return toString((uint64)l->size());
|
||||
}
|
||||
|
||||
// multi-split by chars
|
||||
// returns the amount of string fragments added to the list
|
||||
// arg0: list name; args: delimit; defaultarg: string to split
|
||||
DefReturnResult DefScriptPackage::func_lcsplit(CmdSet& Set)
|
||||
{
|
||||
// 1st create a new list, or get an already existing one and clear it
|
||||
DefList *l = lists.Get(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
l->clear();
|
||||
if(Set.defaultarg.empty()) // we cant split an empty string, return nothing, and keep empty list
|
||||
return "";
|
||||
|
||||
unsigned int p,q=0; // p=position of substr; q=next pos to start searching at
|
||||
while( (p = Set.defaultarg.find_first_of(Set.arg[1].c_str(),q)) != std::string::npos)
|
||||
{
|
||||
l->push_back( Set.defaultarg.substr(q,p - q) );
|
||||
q = p + 1;
|
||||
}
|
||||
if(q < Set.defaultarg.length()) // also append the last string fragment (that has no delimiter)
|
||||
{
|
||||
l->push_back(Set.defaultarg.c_str() + q);
|
||||
}
|
||||
return toString((uint64)l->size());
|
||||
}
|
||||
|
||||
// create a string from a list, using <defaultarg> as delimiter
|
||||
DefReturnResult DefScriptPackage::func_ljoin(CmdSet& Set)
|
||||
{
|
||||
std::string r;
|
||||
DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if(!l)
|
||||
return "";
|
||||
for(unsigned int i = 0; i < l->size(); i++)
|
||||
{
|
||||
r += (*l)[i];
|
||||
if( i+1 != l->size() )
|
||||
r += Set.defaultarg;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
// return list item at position xx
|
||||
DefReturnResult DefScriptPackage::func_lindex(CmdSet& Set)
|
||||
{
|
||||
DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if(!l)
|
||||
return "";
|
||||
unsigned int pos = (unsigned int)toNumber(Set.defaultarg);
|
||||
if(pos+1 > l->size()) // ot of bounds?
|
||||
return "";
|
||||
return (*l)[pos];
|
||||
}
|
||||
|
||||
// clean list: remove every element that matches @def
|
||||
// use _only_ this function to remove empty strings from a list
|
||||
DefReturnResult DefScriptPackage::func_lclean(CmdSet& Set)
|
||||
{
|
||||
unsigned int r=0;
|
||||
DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if(!l)
|
||||
return "";
|
||||
for(DefList::iterator i=l->begin(); i!=l->end(); )
|
||||
{
|
||||
if(*i == Set.defaultarg)
|
||||
{
|
||||
i = l->erase(i);
|
||||
r++;
|
||||
continue;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return toString((uint64)r);
|
||||
}
|
||||
|
||||
// multi-clean list: remove every element that matches any of the args, if it isn't empty
|
||||
// NOTE: arg0 = list name, this one is skipped!
|
||||
// this func does NOT remove empty strings from a list, use lclean instead!!
|
||||
DefReturnResult DefScriptPackage::func_lmclean(CmdSet& Set)
|
||||
{
|
||||
unsigned int r=0;
|
||||
DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if(!l)
|
||||
return "";
|
||||
|
||||
_CmdSetArgMap::iterator it=Set.arg.begin();
|
||||
advance(it,1); // skip list name
|
||||
|
||||
for( ; it != Set.arg.end(); it++)
|
||||
{
|
||||
if(it->second.length())
|
||||
{
|
||||
for(DefList::iterator i=l->begin(); i!=l->end(); i++)
|
||||
{
|
||||
if(*i == it->second)
|
||||
{
|
||||
l->erase(i);
|
||||
r++;
|
||||
if(i==l->end()) // must be checked here, else causing crash (?!)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// erase defaultarg if given
|
||||
if(Set.defaultarg.length())
|
||||
{
|
||||
for(DefList::iterator i=l->begin(); i!=l->end(); i++)
|
||||
{
|
||||
if(*i == Set.defaultarg)
|
||||
{
|
||||
l->erase(i);
|
||||
r++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return toString((uint64)r);
|
||||
}
|
||||
|
||||
// erase element at position @def, return erased element
|
||||
DefReturnResult DefScriptPackage::func_lerase(CmdSet& Set)
|
||||
{
|
||||
DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if(!l)
|
||||
return "";
|
||||
std::string r;
|
||||
unsigned int pos = (unsigned int)toNumber(Set.defaultarg);
|
||||
if(pos > l->size()) // if the list is too short to erase at that pos...
|
||||
return ""; // ... return nothing
|
||||
|
||||
DefList::iterator it = l->begin();
|
||||
advance(it,pos);
|
||||
r = *it;
|
||||
l->erase(it); // ... else erase at correct position
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_lsort(CmdSet& Set)
|
||||
{
|
||||
DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
if(!l)
|
||||
return false;
|
||||
sort(l->begin(),l->end());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//DefReturnResult DefScriptPackage::func_lmerge(CmdSet& Set)
|
||||
//{
|
||||
|
||||
// to be continued...
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include "DefScript.h"
|
||||
|
||||
using namespace DefScriptTools;
|
||||
|
||||
DefReturnResult DefScriptPackage::func_lpushback(CmdSet& Set)
|
||||
{
|
||||
DefList *l = lists.Get(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
l->push_back(Set.defaultarg);
|
||||
return true;
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_lpushfront(CmdSet& Set)
|
||||
{
|
||||
DefList *l = lists.Get(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
l->push_front(Set.defaultarg);
|
||||
return true;
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_lpopback(CmdSet& Set)
|
||||
{
|
||||
std::string r;
|
||||
DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
if( (!l) || (!l->size()) ) // cant pop any element if the list doesnt exist or is empty
|
||||
return "";
|
||||
r= l->back();
|
||||
l->pop_back();
|
||||
return r;
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_lpopfront(CmdSet& Set)
|
||||
{
|
||||
std::string r;
|
||||
DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
if( (!l) || (!l->size()) ) // cant pop any element if the list doesnt exist or is empty
|
||||
return "";
|
||||
r = l->front();
|
||||
l->pop_front();
|
||||
return r;
|
||||
}
|
||||
|
||||
// delete a list and all its elements
|
||||
DefReturnResult DefScriptPackage::func_ldelete(CmdSet& Set)
|
||||
{
|
||||
std::string lname = _NormalizeVarName(Set.defaultarg,Set.myname);
|
||||
if(strncmp(lname.c_str(), SCRIPT_NAMESPACE,strlen(SCRIPT_NAMESPACE))==0)
|
||||
{
|
||||
printf("DefScript: WARNING: ldelete used on a script list, clearing instead! (called by '%s', list '%s')\n",Set.myname.c_str(), lname.c_str());
|
||||
DefList *l = lists.GetNoCreate(lname);
|
||||
if(l)
|
||||
l->clear();
|
||||
return true;
|
||||
}
|
||||
lists.Delete(lname);
|
||||
return true;
|
||||
}
|
||||
|
||||
// returns true if a list with the given name exists, else false
|
||||
DefReturnResult DefScriptPackage::func_lexists(CmdSet& Set)
|
||||
{
|
||||
return lists.Exists(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
}
|
||||
|
||||
// return list element count
|
||||
DefReturnResult DefScriptPackage::func_llen(CmdSet& Set)
|
||||
{
|
||||
DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
if(!l)
|
||||
return ""; // return nothing if list doesnt exist
|
||||
return toString((uint64)l->size()); // return any number
|
||||
}
|
||||
|
||||
// insert item at some position in the list
|
||||
DefReturnResult DefScriptPackage::func_linsert(CmdSet& Set)
|
||||
{
|
||||
bool result;
|
||||
DefList *l = lists.Get(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
unsigned int pos = (unsigned int)toNumber(Set.arg[1]);
|
||||
if(pos > l->size()) // if the list is too short to insert at that pos...
|
||||
{
|
||||
l->push_back(Set.defaultarg); // ... just append at the end
|
||||
result = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
DefList::iterator it = l->begin();
|
||||
advance(it,pos);
|
||||
l->insert(it,Set.defaultarg); // ... else insert at correct position
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
// returns the amount of string fragments added to the list
|
||||
// arg0: list name; arg1: delimiter string; defaultarg: string to split
|
||||
DefReturnResult DefScriptPackage::func_lsplit(CmdSet& Set)
|
||||
{
|
||||
// 1st create a new list, or get an already existing one and clear it
|
||||
DefList *l = lists.Get(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
l->clear();
|
||||
if(Set.defaultarg.empty()) // we cant split an empty string, return nothing, and keep empty list
|
||||
return "";
|
||||
|
||||
// special case: empty delimiter -> split in chars
|
||||
if(Set.arg[1].empty())
|
||||
{
|
||||
for(unsigned int i=0; i<Set.defaultarg.length(); i++)
|
||||
{
|
||||
std::string tmp;
|
||||
tmp = Set.defaultarg[i];
|
||||
l->push_back(tmp);
|
||||
}
|
||||
return toString((uint64)l->size());
|
||||
}
|
||||
|
||||
unsigned int p,q=0; // p=position of substr; q=next pos to start searching at
|
||||
while( (p = Set.defaultarg.find(Set.arg[1].c_str(),q)) != std::string::npos)
|
||||
{
|
||||
l->push_back( Set.defaultarg.substr(q,p - q) );
|
||||
q = p + Set.arg[1].length();
|
||||
}
|
||||
if(q < Set.defaultarg.length()) // also append the last string fragment (that has no delimiter)
|
||||
{
|
||||
l->push_back(Set.defaultarg.c_str() + q);
|
||||
}
|
||||
return toString((uint64)l->size());
|
||||
}
|
||||
|
||||
// multi-split by chars
|
||||
// returns the amount of string fragments added to the list
|
||||
// arg0: list name; args: delimit; defaultarg: string to split
|
||||
DefReturnResult DefScriptPackage::func_lcsplit(CmdSet& Set)
|
||||
{
|
||||
// 1st create a new list, or get an already existing one and clear it
|
||||
DefList *l = lists.Get(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
l->clear();
|
||||
if(Set.defaultarg.empty()) // we cant split an empty string, return nothing, and keep empty list
|
||||
return "";
|
||||
|
||||
unsigned int p,q=0; // p=position of substr; q=next pos to start searching at
|
||||
while( (p = Set.defaultarg.find_first_of(Set.arg[1].c_str(),q)) != std::string::npos)
|
||||
{
|
||||
l->push_back( Set.defaultarg.substr(q,p - q) );
|
||||
q = p + 1;
|
||||
}
|
||||
if(q < Set.defaultarg.length()) // also append the last string fragment (that has no delimiter)
|
||||
{
|
||||
l->push_back(Set.defaultarg.c_str() + q);
|
||||
}
|
||||
return toString((uint64)l->size());
|
||||
}
|
||||
|
||||
// create a string from a list, using <defaultarg> as delimiter
|
||||
DefReturnResult DefScriptPackage::func_ljoin(CmdSet& Set)
|
||||
{
|
||||
std::string r;
|
||||
DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if(!l)
|
||||
return "";
|
||||
for(unsigned int i = 0; i < l->size(); i++)
|
||||
{
|
||||
r += (*l)[i];
|
||||
if( i+1 != l->size() )
|
||||
r += Set.defaultarg;
|
||||
}
|
||||
return r;
|
||||
}
|
||||
|
||||
// return list item at position xx
|
||||
DefReturnResult DefScriptPackage::func_lindex(CmdSet& Set)
|
||||
{
|
||||
DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if(!l)
|
||||
return "";
|
||||
unsigned int pos = (unsigned int)toNumber(Set.defaultarg);
|
||||
if(pos+1 > l->size()) // ot of bounds?
|
||||
return "";
|
||||
return (*l)[pos];
|
||||
}
|
||||
|
||||
// clean list: remove every element that matches @def
|
||||
// use _only_ this function to remove empty strings from a list
|
||||
DefReturnResult DefScriptPackage::func_lclean(CmdSet& Set)
|
||||
{
|
||||
unsigned int r=0;
|
||||
DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if(!l)
|
||||
return "";
|
||||
for(DefList::iterator i=l->begin(); i!=l->end(); )
|
||||
{
|
||||
if(*i == Set.defaultarg)
|
||||
{
|
||||
i = l->erase(i);
|
||||
r++;
|
||||
continue;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return toString((uint64)r);
|
||||
}
|
||||
|
||||
// multi-clean list: remove every element that matches any of the args, if it isn't empty
|
||||
// NOTE: arg0 = list name, this one is skipped!
|
||||
// this func does NOT remove empty strings from a list, use lclean instead!!
|
||||
DefReturnResult DefScriptPackage::func_lmclean(CmdSet& Set)
|
||||
{
|
||||
unsigned int r=0;
|
||||
DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if(!l)
|
||||
return "";
|
||||
|
||||
_CmdSetArgMap::iterator it=Set.arg.begin();
|
||||
advance(it,1); // skip list name
|
||||
|
||||
for( ; it != Set.arg.end(); it++)
|
||||
{
|
||||
if(it->second.length())
|
||||
{
|
||||
for(DefList::iterator i=l->begin(); i!=l->end(); i++)
|
||||
{
|
||||
if(*i == it->second)
|
||||
{
|
||||
l->erase(i);
|
||||
r++;
|
||||
if(i==l->end()) // must be checked here, else causing crash (?!)
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// erase defaultarg if given
|
||||
if(Set.defaultarg.length())
|
||||
{
|
||||
for(DefList::iterator i=l->begin(); i!=l->end(); i++)
|
||||
{
|
||||
if(*i == Set.defaultarg)
|
||||
{
|
||||
l->erase(i);
|
||||
r++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return toString((uint64)r);
|
||||
}
|
||||
|
||||
// erase element at position @def, return erased element
|
||||
DefReturnResult DefScriptPackage::func_lerase(CmdSet& Set)
|
||||
{
|
||||
DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.arg[0],Set.myname));
|
||||
if(!l)
|
||||
return "";
|
||||
std::string r;
|
||||
unsigned int pos = (unsigned int)toNumber(Set.defaultarg);
|
||||
if(pos > l->size()) // if the list is too short to erase at that pos...
|
||||
return ""; // ... return nothing
|
||||
|
||||
DefList::iterator it = l->begin();
|
||||
advance(it,pos);
|
||||
r = *it;
|
||||
l->erase(it); // ... else erase at correct position
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
DefReturnResult DefScriptPackage::func_lsort(CmdSet& Set)
|
||||
{
|
||||
DefList *l = lists.GetNoCreate(_NormalizeVarName(Set.defaultarg,Set.myname));
|
||||
if(!l)
|
||||
return false;
|
||||
sort(l->begin(),l->end());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//DefReturnResult DefScriptPackage::func_lmerge(CmdSet& Set)
|
||||
//{
|
||||
|
||||
// to be continued...
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,30 +1,30 @@
|
||||
#ifndef _DEFSCRIPTTOOLS_H
|
||||
#define _DEFSCRIPTTOOLS_H
|
||||
|
||||
#include <sstream>
|
||||
|
||||
namespace DefScriptTools
|
||||
{
|
||||
std::string stringToUpper(std::string);
|
||||
std::string stringToLower(std::string);
|
||||
std::string toString(ldbl);
|
||||
inline std::string toString(double num) { return toString(ldbl(num)); }
|
||||
inline std::string toString(float num) { return toString(ldbl(num)); }
|
||||
|
||||
template <class T> inline std::string toString(T num)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << num;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
ldbl toNumber(std::string&);
|
||||
bool isTrue(std::string&);
|
||||
uint64 toUint64(std::string&);
|
||||
uint64 atoi64(std::string&);
|
||||
inline long double Round(long double z,unsigned int n);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
#ifndef _DEFSCRIPTTOOLS_H
|
||||
#define _DEFSCRIPTTOOLS_H
|
||||
|
||||
#include <sstream>
|
||||
|
||||
namespace DefScriptTools
|
||||
{
|
||||
std::string stringToUpper(std::string);
|
||||
std::string stringToLower(std::string);
|
||||
std::string toString(ldbl);
|
||||
inline std::string toString(double num) { return toString(ldbl(num)); }
|
||||
inline std::string toString(float num) { return toString(ldbl(num)); }
|
||||
|
||||
template <class T> inline std::string toString(T num)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << num;
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
ldbl toNumber(std::string&);
|
||||
bool isTrue(std::string&);
|
||||
uint64 toUint64(std::string&);
|
||||
uint64 atoi64(std::string&);
|
||||
inline long double Round(long double z,unsigned int n);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,31 +1,31 @@
|
||||
#ifndef _DEF_DYNAMICEVENT_H
|
||||
#define _DEF_DYNAMICEVENT_H
|
||||
|
||||
#include <time.h>
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
#include "TypeStorage.h"
|
||||
|
||||
struct DefScript_DynamicEvent;
|
||||
class DefScript;
|
||||
class DefScriptPackage;
|
||||
typedef TypeStorage<DefScript_DynamicEvent> DefDynamicEventStorage;
|
||||
|
||||
class DefScript_DynamicEventMgr
|
||||
{
|
||||
public:
|
||||
DefScript_DynamicEventMgr(DefScriptPackage *pack);
|
||||
~DefScript_DynamicEventMgr();
|
||||
void Add(std::string name, std::string script, clock_t interval, const char *parent, bool force = false);
|
||||
void Remove(std::string name);
|
||||
void Update(void);
|
||||
|
||||
private:
|
||||
DefDynamicEventStorage _storage;
|
||||
clock_t _lastclock;
|
||||
DefScriptPackage *_pack;
|
||||
bool _events_changed; // this one helps to detect if a script called from an event has modified the event storage (risk of iterator invalidation!)
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef _DEF_DYNAMICEVENT_H
|
||||
#define _DEF_DYNAMICEVENT_H
|
||||
|
||||
#include <time.h>
|
||||
#include <list>
|
||||
#include <string>
|
||||
|
||||
#include "TypeStorage.h"
|
||||
|
||||
struct DefScript_DynamicEvent;
|
||||
class DefScript;
|
||||
class DefScriptPackage;
|
||||
typedef TypeStorage<DefScript_DynamicEvent> DefDynamicEventStorage;
|
||||
|
||||
class DefScript_DynamicEventMgr
|
||||
{
|
||||
public:
|
||||
DefScript_DynamicEventMgr(DefScriptPackage *pack);
|
||||
~DefScript_DynamicEventMgr();
|
||||
void Add(std::string name, std::string script, clock_t interval, const char *parent, bool force = false);
|
||||
void Remove(std::string name);
|
||||
void Update(void);
|
||||
|
||||
private:
|
||||
DefDynamicEventStorage _storage;
|
||||
clock_t _lastclock;
|
||||
DefScriptPackage *_pack;
|
||||
bool _events_changed; // this one helps to detect if a script called from an event has modified the event storage (risk of iterator invalidation!)
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,148 +1,148 @@
|
||||
#ifndef DEFSCRIPT_TYPESTORAGE_H
|
||||
#define DEFSCRIPT_TYPESTORAGE_H
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
template <class T> class TypeStorage
|
||||
{
|
||||
public:
|
||||
typedef typename std::map<std::string,T*> _TypeMap;
|
||||
typedef typename _TypeMap::iterator _TypeIter;
|
||||
TypeStorage() { _keep = false; }
|
||||
~TypeStorage();
|
||||
bool Exists(std::string);
|
||||
void Delete(std::string);
|
||||
void DeleteByPtr(T*);
|
||||
T *Get(std::string);
|
||||
T *GetNoCreate(std::string);
|
||||
void Assign(std::string,T*);
|
||||
void Unlink(std::string);
|
||||
void UnlinkByPtr(T*);
|
||||
std::string GetNameByPtr(T*);
|
||||
inline std::map<std::string,T*> &GetMap(void) { return _storage; }
|
||||
inline void SetKeepOnDestruct(bool b = true) { _keep = true; }
|
||||
inline unsigned int Size(void) { return _storage.size(); }
|
||||
void Clear(bool keep = false);
|
||||
|
||||
private:
|
||||
T *_Create(std::string);
|
||||
_TypeMap _storage;
|
||||
bool _keep;
|
||||
};
|
||||
|
||||
// check whether an object with this name is already present
|
||||
template<class T> bool TypeStorage<T>::Exists(std::string s)
|
||||
{
|
||||
return _storage.find(s) != _storage.end();
|
||||
}
|
||||
|
||||
// helper to create and assign a new object
|
||||
template<class T> T *TypeStorage<T>::_Create(std::string s)
|
||||
{
|
||||
T *elem = new T;
|
||||
_storage[s] = elem;
|
||||
return elem;
|
||||
}
|
||||
|
||||
// delete object with that name, if present
|
||||
template<class T> void TypeStorage<T>::Delete(std::string s)
|
||||
{
|
||||
_TypeIter it = _storage.find(s);
|
||||
if(it != _storage.end())
|
||||
{
|
||||
delete it->second;
|
||||
_storage.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
// delete object with that ptr, if present
|
||||
template<class T> void TypeStorage<T>::DeleteByPtr(T *ptr)
|
||||
{
|
||||
for(_TypeIter it = _storage.begin(); it != _storage.end(); it++)
|
||||
{
|
||||
if(it->second == ptr)
|
||||
{
|
||||
delete it->second;
|
||||
_storage.erase(it);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// return the the object with that name. return NULL if not found
|
||||
template <class T> T *TypeStorage<T>::GetNoCreate(std::string s)
|
||||
{
|
||||
_TypeIter it = _storage.find(s);
|
||||
if(it != _storage.end())
|
||||
return it->second;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// return the the object with that name. create and return new object if not found
|
||||
template<class T> T *TypeStorage<T>::Get(std::string s)
|
||||
{
|
||||
T *elem = GetNoCreate(s);
|
||||
return elem ? elem : _Create(s);
|
||||
}
|
||||
|
||||
// when destroying the TypeStorage, delete all stored objects
|
||||
template<class T> TypeStorage<T>::~TypeStorage()
|
||||
{
|
||||
Clear(_keep);
|
||||
}
|
||||
|
||||
template<class T> void TypeStorage<T>::Clear(bool keep)
|
||||
{
|
||||
if(keep)
|
||||
{
|
||||
_storage.clear();
|
||||
return;
|
||||
}
|
||||
for(_TypeIter it = _storage.begin(); it != _storage.end();)
|
||||
{
|
||||
delete it->second;
|
||||
_storage.erase(it++);
|
||||
}
|
||||
}
|
||||
|
||||
// stores an already existing object's pointer under a specific name; deletes and overwrites old of present
|
||||
template<class T> void TypeStorage<T>::Assign(std::string s,T *elem)
|
||||
{
|
||||
if(Exists(s))
|
||||
Delete(s);
|
||||
_storage[s] = elem;
|
||||
}
|
||||
|
||||
// removes the pointer from the storage without deleting it
|
||||
template<class T> void TypeStorage<T>::Unlink(std::string s)
|
||||
{
|
||||
_storage.erase(s);
|
||||
}
|
||||
|
||||
// removes the pointer from the storage without deleting it, if name is unknown
|
||||
template<class T> void TypeStorage<T>::UnlinkByPtr(T *ptr)
|
||||
{
|
||||
for(_TypeIter it = _storage.begin(); it != _storage.end();)
|
||||
{
|
||||
if(it->second == ptr)
|
||||
{
|
||||
Unlink(it->first);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<class T> std::string TypeStorage<T>::GetNameByPtr(T *ptr)
|
||||
{
|
||||
for(_TypeIter it = _storage.begin(); it != _storage.end();)
|
||||
{
|
||||
if(it->second == ptr)
|
||||
{
|
||||
return it->first;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
#endif
|
||||
#ifndef DEFSCRIPT_TYPESTORAGE_H
|
||||
#define DEFSCRIPT_TYPESTORAGE_H
|
||||
|
||||
#include <string>
|
||||
#include <map>
|
||||
|
||||
template <class T> class TypeStorage
|
||||
{
|
||||
public:
|
||||
typedef typename std::map<std::string,T*> _TypeMap;
|
||||
typedef typename _TypeMap::iterator _TypeIter;
|
||||
TypeStorage() { _keep = false; }
|
||||
~TypeStorage();
|
||||
bool Exists(std::string);
|
||||
void Delete(std::string);
|
||||
void DeleteByPtr(T*);
|
||||
T *Get(std::string);
|
||||
T *GetNoCreate(std::string);
|
||||
void Assign(std::string,T*);
|
||||
void Unlink(std::string);
|
||||
void UnlinkByPtr(T*);
|
||||
std::string GetNameByPtr(T*);
|
||||
inline std::map<std::string,T*> &GetMap(void) { return _storage; }
|
||||
inline void SetKeepOnDestruct(bool b = true) { _keep = true; }
|
||||
inline unsigned int Size(void) { return _storage.size(); }
|
||||
void Clear(bool keep = false);
|
||||
|
||||
private:
|
||||
T *_Create(std::string);
|
||||
_TypeMap _storage;
|
||||
bool _keep;
|
||||
};
|
||||
|
||||
// check whether an object with this name is already present
|
||||
template<class T> bool TypeStorage<T>::Exists(std::string s)
|
||||
{
|
||||
return _storage.find(s) != _storage.end();
|
||||
}
|
||||
|
||||
// helper to create and assign a new object
|
||||
template<class T> T *TypeStorage<T>::_Create(std::string s)
|
||||
{
|
||||
T *elem = new T;
|
||||
_storage[s] = elem;
|
||||
return elem;
|
||||
}
|
||||
|
||||
// delete object with that name, if present
|
||||
template<class T> void TypeStorage<T>::Delete(std::string s)
|
||||
{
|
||||
_TypeIter it = _storage.find(s);
|
||||
if(it != _storage.end())
|
||||
{
|
||||
delete it->second;
|
||||
_storage.erase(it);
|
||||
}
|
||||
}
|
||||
|
||||
// delete object with that ptr, if present
|
||||
template<class T> void TypeStorage<T>::DeleteByPtr(T *ptr)
|
||||
{
|
||||
for(_TypeIter it = _storage.begin(); it != _storage.end(); it++)
|
||||
{
|
||||
if(it->second == ptr)
|
||||
{
|
||||
delete it->second;
|
||||
_storage.erase(it);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// return the the object with that name. return NULL if not found
|
||||
template <class T> T *TypeStorage<T>::GetNoCreate(std::string s)
|
||||
{
|
||||
_TypeIter it = _storage.find(s);
|
||||
if(it != _storage.end())
|
||||
return it->second;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// return the the object with that name. create and return new object if not found
|
||||
template<class T> T *TypeStorage<T>::Get(std::string s)
|
||||
{
|
||||
T *elem = GetNoCreate(s);
|
||||
return elem ? elem : _Create(s);
|
||||
}
|
||||
|
||||
// when destroying the TypeStorage, delete all stored objects
|
||||
template<class T> TypeStorage<T>::~TypeStorage()
|
||||
{
|
||||
Clear(_keep);
|
||||
}
|
||||
|
||||
template<class T> void TypeStorage<T>::Clear(bool keep)
|
||||
{
|
||||
if(keep)
|
||||
{
|
||||
_storage.clear();
|
||||
return;
|
||||
}
|
||||
for(_TypeIter it = _storage.begin(); it != _storage.end();)
|
||||
{
|
||||
delete it->second;
|
||||
_storage.erase(it++);
|
||||
}
|
||||
}
|
||||
|
||||
// stores an already existing object's pointer under a specific name; deletes and overwrites old of present
|
||||
template<class T> void TypeStorage<T>::Assign(std::string s,T *elem)
|
||||
{
|
||||
if(Exists(s))
|
||||
Delete(s);
|
||||
_storage[s] = elem;
|
||||
}
|
||||
|
||||
// removes the pointer from the storage without deleting it
|
||||
template<class T> void TypeStorage<T>::Unlink(std::string s)
|
||||
{
|
||||
_storage.erase(s);
|
||||
}
|
||||
|
||||
// removes the pointer from the storage without deleting it, if name is unknown
|
||||
template<class T> void TypeStorage<T>::UnlinkByPtr(T *ptr)
|
||||
{
|
||||
for(_TypeIter it = _storage.begin(); it != _storage.end();)
|
||||
{
|
||||
if(it->second == ptr)
|
||||
{
|
||||
Unlink(it->first);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<class T> std::string TypeStorage<T>::GetNameByPtr(T *ptr)
|
||||
{
|
||||
for(_TypeIter it = _storage.begin(); it != _storage.end();)
|
||||
{
|
||||
if(it->second == ptr)
|
||||
{
|
||||
return it->first;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,56 +1,56 @@
|
||||
#ifndef DEFSCRIPTINTERFACEINCLUDE_H
|
||||
#define DEFSCRIPTINTERFACEINCLUDE_H
|
||||
#define USING_DEFSCRIPT_EXTENSIONS true
|
||||
|
||||
void _InitDefScriptInterface(void);
|
||||
// Usable own internal functions:
|
||||
DefReturnResult SCpause(CmdSet&);
|
||||
DefReturnResult SCSendChatMessage(CmdSet&);
|
||||
DefReturnResult SCsavecache(CmdSet&);
|
||||
DefReturnResult SCemote(CmdSet&);
|
||||
DefReturnResult SCfollow(CmdSet&);
|
||||
DefReturnResult SCshdn(CmdSet&);
|
||||
DefReturnResult SCjoinchannel(CmdSet&);
|
||||
DefReturnResult SCleavechannel(CmdSet&);
|
||||
DefReturnResult SClistchannel(CmdSet&);
|
||||
DefReturnResult SCloadconf(CmdSet&);
|
||||
DefReturnResult SCapplypermissions(CmdSet&);
|
||||
DefReturnResult SCapplyconf(CmdSet&);
|
||||
DefReturnResult SClog(CmdSet&);
|
||||
DefReturnResult SClogdetail(CmdSet&);
|
||||
DefReturnResult SClogdebug(CmdSet&);
|
||||
DefReturnResult SClogerror(CmdSet&);
|
||||
DefReturnResult SCcastspell(CmdSet&);
|
||||
DefReturnResult SCqueryitem(CmdSet&);
|
||||
DefReturnResult SCtarget(CmdSet&);
|
||||
DefReturnResult SCloadscp(CmdSet&);
|
||||
DefReturnResult SCScpExists(CmdSet&);
|
||||
DefReturnResult SCScpSectionExists(CmdSet&);
|
||||
DefReturnResult SCScpEntryExists(CmdSet&);
|
||||
DefReturnResult SCGetScpValue(CmdSet&);
|
||||
DefReturnResult SCGetName(CmdSet&);
|
||||
DefReturnResult SCGetPlayerGuid(CmdSet&);
|
||||
DefReturnResult SCGetEntry(CmdSet&);
|
||||
DefReturnResult SCGetItemProtoValue(CmdSet&);
|
||||
DefReturnResult SCGetObjectType(CmdSet&);
|
||||
DefReturnResult SCObjectKnown(CmdSet&);
|
||||
DefReturnResult SCGetPlayerPerm(CmdSet&);
|
||||
DefReturnResult SCGetScriptPerm(CmdSet&);
|
||||
DefReturnResult SCGetFileList(CmdSet&);
|
||||
DefReturnResult SCPrintScript(CmdSet&);
|
||||
DefReturnResult SCGetObjectValue(CmdSet&);
|
||||
DefReturnResult SCGetRace(CmdSet&);
|
||||
DefReturnResult SCGetClass(CmdSet&);
|
||||
DefReturnResult SCSendWorldPacket(CmdSet&);
|
||||
DefReturnResult SCGetOpcodeName(CmdSet&);
|
||||
DefReturnResult SCGetOpcodeID(CmdSet&);
|
||||
DefReturnResult SCBBGetPackedGuid(CmdSet&);
|
||||
DefReturnResult SCBBPutPackedGuid(CmdSet&);
|
||||
DefReturnResult SCGui(CmdSet&);
|
||||
DefReturnResult SCSendWho(CmdSet&);
|
||||
DefReturnResult SCGetObjectDistance(CmdSet&);
|
||||
DefReturnResult SCSwitchOpcodeHandler(CmdSet&);
|
||||
DefReturnResult SCOpcodeDisabled(CmdSet&);
|
||||
DefReturnResult SCSpoofWorldPacket(CmdSet&);
|
||||
|
||||
#endif
|
||||
#ifndef DEFSCRIPTINTERFACEINCLUDE_H
|
||||
#define DEFSCRIPTINTERFACEINCLUDE_H
|
||||
#define USING_DEFSCRIPT_EXTENSIONS true
|
||||
|
||||
void _InitDefScriptInterface(void);
|
||||
// Usable own internal functions:
|
||||
DefReturnResult SCpause(CmdSet&);
|
||||
DefReturnResult SCSendChatMessage(CmdSet&);
|
||||
DefReturnResult SCsavecache(CmdSet&);
|
||||
DefReturnResult SCemote(CmdSet&);
|
||||
DefReturnResult SCfollow(CmdSet&);
|
||||
DefReturnResult SCshdn(CmdSet&);
|
||||
DefReturnResult SCjoinchannel(CmdSet&);
|
||||
DefReturnResult SCleavechannel(CmdSet&);
|
||||
DefReturnResult SClistchannel(CmdSet&);
|
||||
DefReturnResult SCloadconf(CmdSet&);
|
||||
DefReturnResult SCapplypermissions(CmdSet&);
|
||||
DefReturnResult SCapplyconf(CmdSet&);
|
||||
DefReturnResult SClog(CmdSet&);
|
||||
DefReturnResult SClogdetail(CmdSet&);
|
||||
DefReturnResult SClogdebug(CmdSet&);
|
||||
DefReturnResult SClogerror(CmdSet&);
|
||||
DefReturnResult SCcastspell(CmdSet&);
|
||||
DefReturnResult SCqueryitem(CmdSet&);
|
||||
DefReturnResult SCtarget(CmdSet&);
|
||||
DefReturnResult SCloadscp(CmdSet&);
|
||||
DefReturnResult SCScpExists(CmdSet&);
|
||||
DefReturnResult SCScpSectionExists(CmdSet&);
|
||||
DefReturnResult SCScpEntryExists(CmdSet&);
|
||||
DefReturnResult SCGetScpValue(CmdSet&);
|
||||
DefReturnResult SCGetName(CmdSet&);
|
||||
DefReturnResult SCGetPlayerGuid(CmdSet&);
|
||||
DefReturnResult SCGetEntry(CmdSet&);
|
||||
DefReturnResult SCGetItemProtoValue(CmdSet&);
|
||||
DefReturnResult SCGetObjectType(CmdSet&);
|
||||
DefReturnResult SCObjectKnown(CmdSet&);
|
||||
DefReturnResult SCGetPlayerPerm(CmdSet&);
|
||||
DefReturnResult SCGetScriptPerm(CmdSet&);
|
||||
DefReturnResult SCGetFileList(CmdSet&);
|
||||
DefReturnResult SCPrintScript(CmdSet&);
|
||||
DefReturnResult SCGetObjectValue(CmdSet&);
|
||||
DefReturnResult SCGetRace(CmdSet&);
|
||||
DefReturnResult SCGetClass(CmdSet&);
|
||||
DefReturnResult SCSendWorldPacket(CmdSet&);
|
||||
DefReturnResult SCGetOpcodeName(CmdSet&);
|
||||
DefReturnResult SCGetOpcodeID(CmdSet&);
|
||||
DefReturnResult SCBBGetPackedGuid(CmdSet&);
|
||||
DefReturnResult SCBBPutPackedGuid(CmdSet&);
|
||||
DefReturnResult SCGui(CmdSet&);
|
||||
DefReturnResult SCSendWho(CmdSet&);
|
||||
DefReturnResult SCGetObjectDistance(CmdSet&);
|
||||
DefReturnResult SCSwitchOpcodeHandler(CmdSet&);
|
||||
DefReturnResult SCOpcodeDisabled(CmdSet&);
|
||||
DefReturnResult SCSpoofWorldPacket(CmdSet&);
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,392 +1,392 @@
|
||||
/*-----------------------------------------------------------------------------*
|
||||
| headerfile MCamera.h |
|
||||
| |
|
||||
| version 1.20 |
|
||||
| date: (29.04.2007) |
|
||||
| |
|
||||
| author: Michal Švantner |
|
||||
| |
|
||||
| for Irrlicht engine |
|
||||
| firsth person and orbiting cameras |
|
||||
*-----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef MCAMERA_H
|
||||
#define MCAMERA_H
|
||||
|
||||
#include "irrlicht/irrlicht.h"
|
||||
using namespace irr;
|
||||
|
||||
class MCameraFPS
|
||||
{
|
||||
scene::ICameraSceneNode* camera;
|
||||
f32 rotationX;
|
||||
f32 rotationY;
|
||||
core::vector3df direction;
|
||||
|
||||
public:
|
||||
MCameraFPS(scene::ISceneManager* smgr)
|
||||
{
|
||||
camera = smgr->addCameraSceneNode();
|
||||
rotationX = 0.0f;
|
||||
rotationY = 0.0f;
|
||||
direction = core::vector3df(0,0,1);
|
||||
}
|
||||
|
||||
~MCameraFPS(){}
|
||||
|
||||
void turnRight(f32 i)
|
||||
{
|
||||
rotationY += i;
|
||||
if(rotationY>=360)rotationY-=360;
|
||||
if(rotationY<0)rotationY+=360;
|
||||
|
||||
direction = core::vector3df(0,0,1);
|
||||
|
||||
core::matrix4 matrix;
|
||||
matrix.setRotationDegrees(core::vector3df (rotationX,rotationY,0));
|
||||
matrix.rotateVect(direction);
|
||||
|
||||
camera->setTarget(camera->getPosition() + direction);
|
||||
camera->updateAbsolutePosition();
|
||||
}
|
||||
|
||||
void turnLeft(f32 i)
|
||||
{
|
||||
rotationY -= i;
|
||||
if(rotationY>=360)rotationY-=360;
|
||||
if(rotationY<0)rotationY+=360;
|
||||
|
||||
direction = core::vector3df(0,0,1);
|
||||
|
||||
core::matrix4 matrix;
|
||||
matrix.setRotationDegrees(core::vector3df (rotationX,rotationY,0));
|
||||
matrix.rotateVect(direction);
|
||||
|
||||
camera->setTarget(camera->getPosition() + direction);
|
||||
camera->updateAbsolutePosition();
|
||||
}
|
||||
|
||||
void turnUp(f32 i)
|
||||
{
|
||||
rotationX += i;
|
||||
if(rotationX>=360)rotationX-=360;
|
||||
if(rotationX<0)rotationX+=360;
|
||||
|
||||
direction = core::vector3df(0,0,1);
|
||||
|
||||
core::matrix4 matrix;
|
||||
matrix.setRotationDegrees(core::vector3df (rotationX,rotationY,0));
|
||||
matrix.rotateVect(direction);
|
||||
|
||||
camera->setTarget(camera->getPosition() + direction);
|
||||
camera->updateAbsolutePosition();
|
||||
}
|
||||
|
||||
void turnDown(f32 i)
|
||||
{
|
||||
rotationX -= i;
|
||||
if(rotationX>=360)rotationX-=360;
|
||||
if(rotationX<0)rotationX+=360;
|
||||
|
||||
direction = core::vector3df(0,0,1);
|
||||
|
||||
core::matrix4 matrix;
|
||||
matrix.setRotationDegrees(core::vector3df (rotationX,rotationY,0));
|
||||
matrix.rotateVect(direction);
|
||||
|
||||
camera->setTarget(camera->getPosition() + direction);
|
||||
camera->updateAbsolutePosition();
|
||||
}
|
||||
|
||||
void moveForward(f32 i)
|
||||
{
|
||||
core::vector3df step = core::vector3df(0,0,i);
|
||||
|
||||
core::matrix4 matrix;
|
||||
matrix.setRotationDegrees(core::vector3df (0,rotationY,0));
|
||||
matrix.rotateVect(step);
|
||||
|
||||
camera->setPosition(camera->getPosition() + step);
|
||||
camera->setTarget(camera->getPosition() + direction);
|
||||
camera->updateAbsolutePosition();
|
||||
}
|
||||
|
||||
void moveBack(f32 i)
|
||||
{
|
||||
core::vector3df step = core::vector3df(0,0,-i);
|
||||
|
||||
core::matrix4 matrix;
|
||||
matrix.setRotationDegrees(core::vector3df (0,rotationY,0));
|
||||
matrix.rotateVect(step);
|
||||
|
||||
camera->setPosition(camera->getPosition() + step);
|
||||
camera->setTarget(camera->getPosition() + direction);
|
||||
camera->updateAbsolutePosition();
|
||||
}
|
||||
|
||||
void moveRight(f32 i)
|
||||
{
|
||||
core::vector3df step = core::vector3df(i,0,0);
|
||||
|
||||
core::matrix4 matrix;
|
||||
matrix.setRotationDegrees(core::vector3df (0,rotationY,0));
|
||||
matrix.rotateVect(step);
|
||||
|
||||
camera->setPosition(camera->getPosition() + step);
|
||||
camera->setTarget(camera->getPosition() + direction);
|
||||
camera->updateAbsolutePosition();
|
||||
}
|
||||
|
||||
void moveLeft(f32 i)
|
||||
{
|
||||
core::vector3df step = core::vector3df(-i,0,0);
|
||||
|
||||
core::matrix4 matrix;
|
||||
matrix.setRotationDegrees(core::vector3df (0,rotationY,0));
|
||||
matrix.rotateVect(step);
|
||||
|
||||
camera->setPosition(camera->getPosition() + step);
|
||||
camera->setTarget(camera->getPosition() + direction);
|
||||
camera->updateAbsolutePosition();
|
||||
}
|
||||
|
||||
void setHeight(f32 i)
|
||||
{
|
||||
camera->setPosition(core::vector3df(camera->getPosition().X, i, camera->getPosition().Z));
|
||||
camera->setTarget(camera->getPosition() + direction);
|
||||
camera->updateAbsolutePosition();
|
||||
}
|
||||
|
||||
void setPosition(core::vector3df pos)
|
||||
{
|
||||
camera->setPosition(pos);
|
||||
camera->updateAbsolutePosition();
|
||||
}
|
||||
|
||||
core::vector3df getPosition()
|
||||
{
|
||||
return camera->getPosition();
|
||||
}
|
||||
|
||||
core::vector3df getDirection()
|
||||
{
|
||||
return direction;
|
||||
}
|
||||
|
||||
core::vector3df getTarget()
|
||||
{
|
||||
return camera->getTarget();
|
||||
}
|
||||
|
||||
f32 getHeading()
|
||||
{
|
||||
return rotationY;
|
||||
}
|
||||
|
||||
f32 getPitch()
|
||||
{
|
||||
return rotationX;
|
||||
}
|
||||
|
||||
f32 getFarValue()
|
||||
{
|
||||
return camera->getFarValue();
|
||||
}
|
||||
|
||||
void setFarValue(f32 f)
|
||||
{
|
||||
camera->setFarValue(f);
|
||||
}
|
||||
|
||||
f32 getNearValue()
|
||||
{
|
||||
return camera->getNearValue();
|
||||
}
|
||||
|
||||
void setNearValue(f32 n)
|
||||
{
|
||||
camera->setNearValue(n);
|
||||
}
|
||||
|
||||
f32 getFOV()
|
||||
{
|
||||
return camera->getFOV();
|
||||
}
|
||||
|
||||
void setFOV(f32 v)
|
||||
{
|
||||
camera->setFOV(v);
|
||||
}
|
||||
|
||||
f32 getAspectRatio()
|
||||
{
|
||||
return camera->getAspectRatio();
|
||||
}
|
||||
|
||||
void setAspectRatio(f32 a)
|
||||
{
|
||||
camera->setAspectRatio(a);
|
||||
}
|
||||
|
||||
scene::ISceneNode* getNode()
|
||||
{
|
||||
return camera;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class MCameraOrbit
|
||||
{
|
||||
scene::ICameraSceneNode* camera;
|
||||
f32 rotationX;
|
||||
f32 rotationY;
|
||||
f32 distance;
|
||||
|
||||
void update()
|
||||
{
|
||||
core::vector3df direction = core::vector3df(0,0,distance);
|
||||
|
||||
core::matrix4 matrix;
|
||||
matrix.setRotationDegrees(core::vector3df (rotationX,rotationY,0));
|
||||
matrix.rotateVect(direction);
|
||||
|
||||
camera->setPosition(camera->getTarget() + direction);
|
||||
camera->updateAbsolutePosition();
|
||||
}
|
||||
|
||||
public:
|
||||
MCameraOrbit(scene::ISceneManager* smgr)
|
||||
{
|
||||
camera = smgr->addCameraSceneNode();
|
||||
rotationX = 0.0f;
|
||||
rotationY = 0.0f;
|
||||
distance = 1.0f;
|
||||
camera->setTarget(core::vector3df(0,0,0));
|
||||
update();
|
||||
}
|
||||
|
||||
~MCameraOrbit(){}
|
||||
|
||||
void turnRight(f32 i)
|
||||
{
|
||||
rotationY += i;
|
||||
if(rotationY>=360)rotationY-=360;
|
||||
if(rotationY<0)rotationY+=360;
|
||||
update();
|
||||
}
|
||||
|
||||
void turnLeft(f32 i)
|
||||
{
|
||||
rotationY -= i;
|
||||
if(rotationY>=360)rotationY-=360;
|
||||
if(rotationY<0)rotationY+=360;
|
||||
update();
|
||||
}
|
||||
|
||||
void turnUp(f32 i)
|
||||
{
|
||||
rotationX += i;
|
||||
if(rotationX>=360)rotationX-=360;
|
||||
if(rotationX<0)rotationX+=360;
|
||||
update();
|
||||
}
|
||||
|
||||
void turnDown(f32 i)
|
||||
{
|
||||
rotationX -= i;
|
||||
if(rotationX>=360)rotationX-=360;
|
||||
if(rotationX<0)rotationX+=360;
|
||||
update();
|
||||
}
|
||||
|
||||
core::vector3df getTarget()
|
||||
{
|
||||
return camera->getTarget();
|
||||
}
|
||||
|
||||
void setTarget(core::vector3df target)
|
||||
{
|
||||
camera->setTarget(target);
|
||||
update();
|
||||
}
|
||||
|
||||
core::vector3df getPosition()
|
||||
{
|
||||
return camera->getPosition();
|
||||
}
|
||||
|
||||
f32 getDistance()
|
||||
{
|
||||
return distance;
|
||||
}
|
||||
|
||||
void setDistance(f32 i)
|
||||
{
|
||||
distance = i;
|
||||
update();
|
||||
}
|
||||
|
||||
void adjustDistance(f32 i)
|
||||
{
|
||||
distance += i;
|
||||
update();
|
||||
}
|
||||
|
||||
f32 getHeading()
|
||||
{
|
||||
return rotationY;
|
||||
}
|
||||
|
||||
f32 getPitch()
|
||||
{
|
||||
return rotationX;
|
||||
}
|
||||
|
||||
f32 getFarValue()
|
||||
{
|
||||
return camera->getFarValue();
|
||||
}
|
||||
|
||||
void setFarValue(f32 f)
|
||||
{
|
||||
camera->setFarValue(f);
|
||||
}
|
||||
|
||||
f32 getNearValue()
|
||||
{
|
||||
return camera->getNearValue();
|
||||
}
|
||||
|
||||
void setNearValue(f32 n)
|
||||
{
|
||||
camera->setNearValue(n);
|
||||
}
|
||||
|
||||
f32 getFOV()
|
||||
{
|
||||
return camera->getFOV();
|
||||
}
|
||||
|
||||
void setFOV(f32 v)
|
||||
{
|
||||
camera->setFOV(v);
|
||||
}
|
||||
|
||||
f32 getAspectRatio()
|
||||
{
|
||||
return camera->getAspectRatio();
|
||||
}
|
||||
|
||||
void setAspectRatio(f32 a)
|
||||
{
|
||||
camera->setAspectRatio(a);
|
||||
}
|
||||
|
||||
scene::ISceneNode* getNode()
|
||||
{
|
||||
return camera;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
/*-----------------------------------------------------------------------------*
|
||||
| headerfile MCamera.h |
|
||||
| |
|
||||
| version 1.20 |
|
||||
| date: (29.04.2007) |
|
||||
| |
|
||||
| author: Michal Švantner |
|
||||
| |
|
||||
| for Irrlicht engine |
|
||||
| firsth person and orbiting cameras |
|
||||
*-----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef MCAMERA_H
|
||||
#define MCAMERA_H
|
||||
|
||||
#include "irrlicht/irrlicht.h"
|
||||
using namespace irr;
|
||||
|
||||
class MCameraFPS
|
||||
{
|
||||
scene::ICameraSceneNode* camera;
|
||||
f32 rotationX;
|
||||
f32 rotationY;
|
||||
core::vector3df direction;
|
||||
|
||||
public:
|
||||
MCameraFPS(scene::ISceneManager* smgr)
|
||||
{
|
||||
camera = smgr->addCameraSceneNode();
|
||||
rotationX = 0.0f;
|
||||
rotationY = 0.0f;
|
||||
direction = core::vector3df(0,0,1);
|
||||
}
|
||||
|
||||
~MCameraFPS(){}
|
||||
|
||||
void turnRight(f32 i)
|
||||
{
|
||||
rotationY += i;
|
||||
if(rotationY>=360)rotationY-=360;
|
||||
if(rotationY<0)rotationY+=360;
|
||||
|
||||
direction = core::vector3df(0,0,1);
|
||||
|
||||
core::matrix4 matrix;
|
||||
matrix.setRotationDegrees(core::vector3df (rotationX,rotationY,0));
|
||||
matrix.rotateVect(direction);
|
||||
|
||||
camera->setTarget(camera->getPosition() + direction);
|
||||
camera->updateAbsolutePosition();
|
||||
}
|
||||
|
||||
void turnLeft(f32 i)
|
||||
{
|
||||
rotationY -= i;
|
||||
if(rotationY>=360)rotationY-=360;
|
||||
if(rotationY<0)rotationY+=360;
|
||||
|
||||
direction = core::vector3df(0,0,1);
|
||||
|
||||
core::matrix4 matrix;
|
||||
matrix.setRotationDegrees(core::vector3df (rotationX,rotationY,0));
|
||||
matrix.rotateVect(direction);
|
||||
|
||||
camera->setTarget(camera->getPosition() + direction);
|
||||
camera->updateAbsolutePosition();
|
||||
}
|
||||
|
||||
void turnUp(f32 i)
|
||||
{
|
||||
rotationX += i;
|
||||
if(rotationX>=360)rotationX-=360;
|
||||
if(rotationX<0)rotationX+=360;
|
||||
|
||||
direction = core::vector3df(0,0,1);
|
||||
|
||||
core::matrix4 matrix;
|
||||
matrix.setRotationDegrees(core::vector3df (rotationX,rotationY,0));
|
||||
matrix.rotateVect(direction);
|
||||
|
||||
camera->setTarget(camera->getPosition() + direction);
|
||||
camera->updateAbsolutePosition();
|
||||
}
|
||||
|
||||
void turnDown(f32 i)
|
||||
{
|
||||
rotationX -= i;
|
||||
if(rotationX>=360)rotationX-=360;
|
||||
if(rotationX<0)rotationX+=360;
|
||||
|
||||
direction = core::vector3df(0,0,1);
|
||||
|
||||
core::matrix4 matrix;
|
||||
matrix.setRotationDegrees(core::vector3df (rotationX,rotationY,0));
|
||||
matrix.rotateVect(direction);
|
||||
|
||||
camera->setTarget(camera->getPosition() + direction);
|
||||
camera->updateAbsolutePosition();
|
||||
}
|
||||
|
||||
void moveForward(f32 i)
|
||||
{
|
||||
core::vector3df step = core::vector3df(0,0,i);
|
||||
|
||||
core::matrix4 matrix;
|
||||
matrix.setRotationDegrees(core::vector3df (0,rotationY,0));
|
||||
matrix.rotateVect(step);
|
||||
|
||||
camera->setPosition(camera->getPosition() + step);
|
||||
camera->setTarget(camera->getPosition() + direction);
|
||||
camera->updateAbsolutePosition();
|
||||
}
|
||||
|
||||
void moveBack(f32 i)
|
||||
{
|
||||
core::vector3df step = core::vector3df(0,0,-i);
|
||||
|
||||
core::matrix4 matrix;
|
||||
matrix.setRotationDegrees(core::vector3df (0,rotationY,0));
|
||||
matrix.rotateVect(step);
|
||||
|
||||
camera->setPosition(camera->getPosition() + step);
|
||||
camera->setTarget(camera->getPosition() + direction);
|
||||
camera->updateAbsolutePosition();
|
||||
}
|
||||
|
||||
void moveRight(f32 i)
|
||||
{
|
||||
core::vector3df step = core::vector3df(i,0,0);
|
||||
|
||||
core::matrix4 matrix;
|
||||
matrix.setRotationDegrees(core::vector3df (0,rotationY,0));
|
||||
matrix.rotateVect(step);
|
||||
|
||||
camera->setPosition(camera->getPosition() + step);
|
||||
camera->setTarget(camera->getPosition() + direction);
|
||||
camera->updateAbsolutePosition();
|
||||
}
|
||||
|
||||
void moveLeft(f32 i)
|
||||
{
|
||||
core::vector3df step = core::vector3df(-i,0,0);
|
||||
|
||||
core::matrix4 matrix;
|
||||
matrix.setRotationDegrees(core::vector3df (0,rotationY,0));
|
||||
matrix.rotateVect(step);
|
||||
|
||||
camera->setPosition(camera->getPosition() + step);
|
||||
camera->setTarget(camera->getPosition() + direction);
|
||||
camera->updateAbsolutePosition();
|
||||
}
|
||||
|
||||
void setHeight(f32 i)
|
||||
{
|
||||
camera->setPosition(core::vector3df(camera->getPosition().X, i, camera->getPosition().Z));
|
||||
camera->setTarget(camera->getPosition() + direction);
|
||||
camera->updateAbsolutePosition();
|
||||
}
|
||||
|
||||
void setPosition(core::vector3df pos)
|
||||
{
|
||||
camera->setPosition(pos);
|
||||
camera->updateAbsolutePosition();
|
||||
}
|
||||
|
||||
core::vector3df getPosition()
|
||||
{
|
||||
return camera->getPosition();
|
||||
}
|
||||
|
||||
core::vector3df getDirection()
|
||||
{
|
||||
return direction;
|
||||
}
|
||||
|
||||
core::vector3df getTarget()
|
||||
{
|
||||
return camera->getTarget();
|
||||
}
|
||||
|
||||
f32 getHeading()
|
||||
{
|
||||
return rotationY;
|
||||
}
|
||||
|
||||
f32 getPitch()
|
||||
{
|
||||
return rotationX;
|
||||
}
|
||||
|
||||
f32 getFarValue()
|
||||
{
|
||||
return camera->getFarValue();
|
||||
}
|
||||
|
||||
void setFarValue(f32 f)
|
||||
{
|
||||
camera->setFarValue(f);
|
||||
}
|
||||
|
||||
f32 getNearValue()
|
||||
{
|
||||
return camera->getNearValue();
|
||||
}
|
||||
|
||||
void setNearValue(f32 n)
|
||||
{
|
||||
camera->setNearValue(n);
|
||||
}
|
||||
|
||||
f32 getFOV()
|
||||
{
|
||||
return camera->getFOV();
|
||||
}
|
||||
|
||||
void setFOV(f32 v)
|
||||
{
|
||||
camera->setFOV(v);
|
||||
}
|
||||
|
||||
f32 getAspectRatio()
|
||||
{
|
||||
return camera->getAspectRatio();
|
||||
}
|
||||
|
||||
void setAspectRatio(f32 a)
|
||||
{
|
||||
camera->setAspectRatio(a);
|
||||
}
|
||||
|
||||
scene::ISceneNode* getNode()
|
||||
{
|
||||
return camera;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
class MCameraOrbit
|
||||
{
|
||||
scene::ICameraSceneNode* camera;
|
||||
f32 rotationX;
|
||||
f32 rotationY;
|
||||
f32 distance;
|
||||
|
||||
void update()
|
||||
{
|
||||
core::vector3df direction = core::vector3df(0,0,distance);
|
||||
|
||||
core::matrix4 matrix;
|
||||
matrix.setRotationDegrees(core::vector3df (rotationX,rotationY,0));
|
||||
matrix.rotateVect(direction);
|
||||
|
||||
camera->setPosition(camera->getTarget() + direction);
|
||||
camera->updateAbsolutePosition();
|
||||
}
|
||||
|
||||
public:
|
||||
MCameraOrbit(scene::ISceneManager* smgr)
|
||||
{
|
||||
camera = smgr->addCameraSceneNode();
|
||||
rotationX = 0.0f;
|
||||
rotationY = 0.0f;
|
||||
distance = 1.0f;
|
||||
camera->setTarget(core::vector3df(0,0,0));
|
||||
update();
|
||||
}
|
||||
|
||||
~MCameraOrbit(){}
|
||||
|
||||
void turnRight(f32 i)
|
||||
{
|
||||
rotationY += i;
|
||||
if(rotationY>=360)rotationY-=360;
|
||||
if(rotationY<0)rotationY+=360;
|
||||
update();
|
||||
}
|
||||
|
||||
void turnLeft(f32 i)
|
||||
{
|
||||
rotationY -= i;
|
||||
if(rotationY>=360)rotationY-=360;
|
||||
if(rotationY<0)rotationY+=360;
|
||||
update();
|
||||
}
|
||||
|
||||
void turnUp(f32 i)
|
||||
{
|
||||
rotationX += i;
|
||||
if(rotationX>=360)rotationX-=360;
|
||||
if(rotationX<0)rotationX+=360;
|
||||
update();
|
||||
}
|
||||
|
||||
void turnDown(f32 i)
|
||||
{
|
||||
rotationX -= i;
|
||||
if(rotationX>=360)rotationX-=360;
|
||||
if(rotationX<0)rotationX+=360;
|
||||
update();
|
||||
}
|
||||
|
||||
core::vector3df getTarget()
|
||||
{
|
||||
return camera->getTarget();
|
||||
}
|
||||
|
||||
void setTarget(core::vector3df target)
|
||||
{
|
||||
camera->setTarget(target);
|
||||
update();
|
||||
}
|
||||
|
||||
core::vector3df getPosition()
|
||||
{
|
||||
return camera->getPosition();
|
||||
}
|
||||
|
||||
f32 getDistance()
|
||||
{
|
||||
return distance;
|
||||
}
|
||||
|
||||
void setDistance(f32 i)
|
||||
{
|
||||
distance = i;
|
||||
update();
|
||||
}
|
||||
|
||||
void adjustDistance(f32 i)
|
||||
{
|
||||
distance += i;
|
||||
update();
|
||||
}
|
||||
|
||||
f32 getHeading()
|
||||
{
|
||||
return rotationY;
|
||||
}
|
||||
|
||||
f32 getPitch()
|
||||
{
|
||||
return rotationX;
|
||||
}
|
||||
|
||||
f32 getFarValue()
|
||||
{
|
||||
return camera->getFarValue();
|
||||
}
|
||||
|
||||
void setFarValue(f32 f)
|
||||
{
|
||||
camera->setFarValue(f);
|
||||
}
|
||||
|
||||
f32 getNearValue()
|
||||
{
|
||||
return camera->getNearValue();
|
||||
}
|
||||
|
||||
void setNearValue(f32 n)
|
||||
{
|
||||
camera->setNearValue(n);
|
||||
}
|
||||
|
||||
f32 getFOV()
|
||||
{
|
||||
return camera->getFOV();
|
||||
}
|
||||
|
||||
void setFOV(f32 v)
|
||||
{
|
||||
camera->setFOV(v);
|
||||
}
|
||||
|
||||
f32 getAspectRatio()
|
||||
{
|
||||
return camera->getAspectRatio();
|
||||
}
|
||||
|
||||
void setAspectRatio(f32 a)
|
||||
{
|
||||
camera->setAspectRatio(a);
|
||||
}
|
||||
|
||||
scene::ISceneNode* getNode()
|
||||
{
|
||||
return camera;
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -1,160 +1,160 @@
|
||||
/*-----------------------------------------------------------------------------*
|
||||
| headerfile MInput.h |
|
||||
| |
|
||||
| version 1.10 |
|
||||
| date: (29.04.2007) |
|
||||
| |
|
||||
| author: Michal Švantner |
|
||||
| |
|
||||
| for Irrlicht engine |
|
||||
| store keyboard and mouse input in structures "key" and "mouse" |
|
||||
*-----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef MINPUT_H
|
||||
#define MINPUT_H
|
||||
|
||||
#include "irrlicht/irrlicht.h"
|
||||
using namespace irr;
|
||||
|
||||
struct IKeys
|
||||
{
|
||||
bool pressed(EKEY_CODE keycode)
|
||||
{
|
||||
return code[keycode];
|
||||
}
|
||||
|
||||
bool pressed_once(EKEY_CODE keycode)
|
||||
{
|
||||
if(code[keycode])
|
||||
{
|
||||
code[keycode] = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
for(s32 i=0; i<KEY_KEY_CODES_COUNT; i++) code[i] = false;
|
||||
}
|
||||
|
||||
bool code[KEY_KEY_CODES_COUNT];
|
||||
|
||||
};
|
||||
|
||||
struct IMouse
|
||||
{
|
||||
bool left_pressed()
|
||||
{
|
||||
return left;
|
||||
}
|
||||
|
||||
bool middle_pressed()
|
||||
{
|
||||
return middle;
|
||||
}
|
||||
|
||||
bool right_pressed()
|
||||
{
|
||||
return right;
|
||||
}
|
||||
|
||||
bool left_pressed_once()
|
||||
{
|
||||
if(left)
|
||||
{
|
||||
left = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool middle_pressed_once()
|
||||
{
|
||||
if(middle)
|
||||
{
|
||||
middle = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool right_pressed_once()
|
||||
{
|
||||
if(right)
|
||||
{
|
||||
right = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
X = 0;
|
||||
Y = 0;
|
||||
wheel = 0.0f;
|
||||
left = false;
|
||||
middle = false;
|
||||
right = false;
|
||||
}
|
||||
|
||||
s32 X;
|
||||
s32 Y;
|
||||
f32 wheel;
|
||||
bool left;
|
||||
bool middle;
|
||||
bool right;
|
||||
|
||||
};
|
||||
|
||||
class MyEventReceiver : public IEventReceiver
|
||||
{
|
||||
public:
|
||||
MyEventReceiver()
|
||||
{
|
||||
for(s32 i=0; i<KEY_KEY_CODES_COUNT; i++)
|
||||
key.code[i] = false;
|
||||
|
||||
mouse.X = 0;
|
||||
mouse.Y = 0;
|
||||
mouse.wheel = 0.0f;
|
||||
mouse.left = false;
|
||||
mouse.middle = false;
|
||||
mouse.right = false;
|
||||
}
|
||||
|
||||
virtual bool OnEvent(SEvent event)
|
||||
{
|
||||
bool value = false;
|
||||
|
||||
if (event.EventType == irr::EET_KEY_INPUT_EVENT)
|
||||
{
|
||||
key.code[event.KeyInput.Key] = event.KeyInput.PressedDown;
|
||||
value = true;
|
||||
}
|
||||
|
||||
if (event.EventType == irr::EET_MOUSE_INPUT_EVENT)
|
||||
{
|
||||
switch(event.MouseInput.Event)
|
||||
{
|
||||
case EMIE_LMOUSE_PRESSED_DOWN: mouse.left = true; break;
|
||||
case EMIE_RMOUSE_PRESSED_DOWN: mouse.right = true; break;
|
||||
case EMIE_MMOUSE_PRESSED_DOWN: mouse.middle = true; break;
|
||||
case EMIE_LMOUSE_LEFT_UP: mouse.left = false; break;
|
||||
case EMIE_RMOUSE_LEFT_UP: mouse.right = false; break;
|
||||
case EMIE_MMOUSE_LEFT_UP: mouse.middle = false; break;
|
||||
case EMIE_MOUSE_MOVED: mouse.X = event.MouseInput.X; mouse.Y = event.MouseInput.Y; break;
|
||||
case EMIE_MOUSE_WHEEL: mouse.wheel = mouse.wheel + event.MouseInput.Wheel; break;
|
||||
}
|
||||
value = true;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
IMouse mouse;
|
||||
IKeys key;
|
||||
};
|
||||
|
||||
#endif
|
||||
/*-----------------------------------------------------------------------------*
|
||||
| headerfile MInput.h |
|
||||
| |
|
||||
| version 1.10 |
|
||||
| date: (29.04.2007) |
|
||||
| |
|
||||
| author: Michal Švantner |
|
||||
| |
|
||||
| for Irrlicht engine |
|
||||
| store keyboard and mouse input in structures "key" and "mouse" |
|
||||
*-----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef MINPUT_H
|
||||
#define MINPUT_H
|
||||
|
||||
#include "irrlicht/irrlicht.h"
|
||||
using namespace irr;
|
||||
|
||||
struct IKeys
|
||||
{
|
||||
bool pressed(EKEY_CODE keycode)
|
||||
{
|
||||
return code[keycode];
|
||||
}
|
||||
|
||||
bool pressed_once(EKEY_CODE keycode)
|
||||
{
|
||||
if(code[keycode])
|
||||
{
|
||||
code[keycode] = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
for(s32 i=0; i<KEY_KEY_CODES_COUNT; i++) code[i] = false;
|
||||
}
|
||||
|
||||
bool code[KEY_KEY_CODES_COUNT];
|
||||
|
||||
};
|
||||
|
||||
struct IMouse
|
||||
{
|
||||
bool left_pressed()
|
||||
{
|
||||
return left;
|
||||
}
|
||||
|
||||
bool middle_pressed()
|
||||
{
|
||||
return middle;
|
||||
}
|
||||
|
||||
bool right_pressed()
|
||||
{
|
||||
return right;
|
||||
}
|
||||
|
||||
bool left_pressed_once()
|
||||
{
|
||||
if(left)
|
||||
{
|
||||
left = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool middle_pressed_once()
|
||||
{
|
||||
if(middle)
|
||||
{
|
||||
middle = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool right_pressed_once()
|
||||
{
|
||||
if(right)
|
||||
{
|
||||
right = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void reset()
|
||||
{
|
||||
X = 0;
|
||||
Y = 0;
|
||||
wheel = 0.0f;
|
||||
left = false;
|
||||
middle = false;
|
||||
right = false;
|
||||
}
|
||||
|
||||
s32 X;
|
||||
s32 Y;
|
||||
f32 wheel;
|
||||
bool left;
|
||||
bool middle;
|
||||
bool right;
|
||||
|
||||
};
|
||||
|
||||
class MyEventReceiver : public IEventReceiver
|
||||
{
|
||||
public:
|
||||
MyEventReceiver()
|
||||
{
|
||||
for(s32 i=0; i<KEY_KEY_CODES_COUNT; i++)
|
||||
key.code[i] = false;
|
||||
|
||||
mouse.X = 0;
|
||||
mouse.Y = 0;
|
||||
mouse.wheel = 0.0f;
|
||||
mouse.left = false;
|
||||
mouse.middle = false;
|
||||
mouse.right = false;
|
||||
}
|
||||
|
||||
virtual bool OnEvent(SEvent event)
|
||||
{
|
||||
bool value = false;
|
||||
|
||||
if (event.EventType == irr::EET_KEY_INPUT_EVENT)
|
||||
{
|
||||
key.code[event.KeyInput.Key] = event.KeyInput.PressedDown;
|
||||
value = true;
|
||||
}
|
||||
|
||||
if (event.EventType == irr::EET_MOUSE_INPUT_EVENT)
|
||||
{
|
||||
switch(event.MouseInput.Event)
|
||||
{
|
||||
case EMIE_LMOUSE_PRESSED_DOWN: mouse.left = true; break;
|
||||
case EMIE_RMOUSE_PRESSED_DOWN: mouse.right = true; break;
|
||||
case EMIE_MMOUSE_PRESSED_DOWN: mouse.middle = true; break;
|
||||
case EMIE_LMOUSE_LEFT_UP: mouse.left = false; break;
|
||||
case EMIE_RMOUSE_LEFT_UP: mouse.right = false; break;
|
||||
case EMIE_MMOUSE_LEFT_UP: mouse.middle = false; break;
|
||||
case EMIE_MOUSE_MOVED: mouse.X = event.MouseInput.X; mouse.Y = event.MouseInput.Y; break;
|
||||
case EMIE_MOUSE_WHEEL: mouse.wheel = mouse.wheel + event.MouseInput.Wheel; break;
|
||||
}
|
||||
value = true;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
IMouse mouse;
|
||||
IKeys key;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,324 +1,324 @@
|
||||
#include "common.h"
|
||||
#include "irrlicht/irrlicht.h"
|
||||
#include "Object.h"
|
||||
#include "DrawObject.h"
|
||||
#include "PseuWoW.h"
|
||||
#include "Scene.h"
|
||||
#include "PseuGUI.h"
|
||||
|
||||
PseuGUIRunnable::PseuGUIRunnable()
|
||||
{
|
||||
_gui = new PseuGUI();
|
||||
}
|
||||
|
||||
void PseuGUIRunnable::run(void)
|
||||
{
|
||||
_gui->Run();
|
||||
}
|
||||
|
||||
PseuGUI *PseuGUIRunnable::GetGUI(void)
|
||||
{
|
||||
return _gui;
|
||||
}
|
||||
|
||||
PseuGUIRunnable::~PseuGUIRunnable()
|
||||
{
|
||||
delete _gui;
|
||||
}
|
||||
|
||||
PseuGUI::PseuGUI()
|
||||
{
|
||||
_xres = 640;
|
||||
_yres = 480;
|
||||
_colordepth = 32;
|
||||
_shadows = false;
|
||||
_windowed = true;
|
||||
_vsync = false;
|
||||
_initialized = false;
|
||||
_mustdie = false;
|
||||
_driverType = video::EDT_BURNINGSVIDEO; // nulldevice makes not really a sense to display stuff
|
||||
_scenestate = _scenestate_new = SCENESTATE_NULL;
|
||||
_smgr = NULL;
|
||||
_device = NULL;
|
||||
_guienv = NULL;
|
||||
_scene = NULL;
|
||||
_passtime = _lastpasstime = _passtimediff = 0;
|
||||
_updateWorldPos = false;
|
||||
}
|
||||
|
||||
PseuGUI::~PseuGUI()
|
||||
{
|
||||
this->Cancel();
|
||||
_instance->DeleteGUI(); // this makes the instance set its gui ptr to NULL
|
||||
logdebug("PseuGUI::~PseuGUI()");
|
||||
}
|
||||
|
||||
void PseuGUI::SetDriver(uint8 driverId)
|
||||
{
|
||||
switch(driverId)
|
||||
{
|
||||
case DIRECTX9: _driverType = video::EDT_DIRECT3D9; break;
|
||||
case DIRECTX8: _driverType = video::EDT_DIRECT3D8; break;
|
||||
case OPENGL: _driverType = video::EDT_OPENGL; break;
|
||||
case SOFTWARE: _driverType = video::EDT_SOFTWARE; break;
|
||||
case BURNINGSVIDEO: _driverType = video::EDT_BURNINGSVIDEO; break;
|
||||
case NULLDEVICE: _driverType = video::EDT_NULL; break;
|
||||
default: _driverType = video::EDT_BURNINGSVIDEO; // if no valid driver detected, use software
|
||||
}
|
||||
|
||||
// TODO: add support for changing driver during runtime?
|
||||
}
|
||||
|
||||
void PseuGUI::SetResolution(uint16 x, uint16 y, uint16 depth)
|
||||
{
|
||||
_xres = x;
|
||||
_yres = y;
|
||||
_colordepth = depth;
|
||||
}
|
||||
|
||||
void PseuGUI::SetWindowed(bool b)
|
||||
{
|
||||
_windowed = b;
|
||||
// see PseuGUI::Init(): !_windowed == fullscreen
|
||||
}
|
||||
|
||||
void PseuGUI::SetVSync(bool b)
|
||||
{
|
||||
_vsync = b;
|
||||
}
|
||||
|
||||
void PseuGUI::UseShadows(bool b)
|
||||
{
|
||||
_shadows = b;
|
||||
}
|
||||
|
||||
// if this fuction is called from another thread the device will not work correctly. o_O
|
||||
void PseuGUI::_Init(void)
|
||||
{
|
||||
_device = createDevice(_driverType,dimension2d<s32>(_xres,_yres),_colordepth,!_windowed,_shadows,_vsync);
|
||||
if(!_device)
|
||||
{
|
||||
logerror("PseuGUI: Can't use specified video driver, trying software mode...");
|
||||
_device = createDevice(video::EDT_SOFTWARE,dimension2d<s32>(_xres,_yres),_colordepth,!_windowed,false,false);
|
||||
if(!_device)
|
||||
{
|
||||
logerror("ERROR: PseuGUI::_Init() failed, no video driver available!");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
logerror("PseuGUI: Software mode OK!");
|
||||
}
|
||||
}
|
||||
DEBUG(logdebug("PseuGUI::Init() _device=%X",_device));
|
||||
_device->setWindowCaption(L"PseuWoW - Initializing");
|
||||
_device->setResizeAble(true);
|
||||
_driver = _device->getVideoDriver();
|
||||
_smgr = _device->getSceneManager();
|
||||
_guienv = _device->getGUIEnvironment();
|
||||
_timer = _device->getTimer();
|
||||
//...
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
void PseuGUI::Cancel(void)
|
||||
{
|
||||
DEBUG(logdebug("PseuGUI::Cancel()"));
|
||||
|
||||
if(_scene)
|
||||
{
|
||||
_scene->OnDelete();
|
||||
delete _scene;
|
||||
_scene = NULL;
|
||||
}
|
||||
if(_device)
|
||||
{
|
||||
_device->drop();
|
||||
_device = NULL;
|
||||
|
||||
}
|
||||
_mustdie = true;
|
||||
}
|
||||
|
||||
void PseuGUI::Shutdown(void)
|
||||
{
|
||||
DEBUG(logdebug("PseuGUI::Shutdown()"));
|
||||
_mustdie = true;
|
||||
}
|
||||
|
||||
void PseuGUI::Run(void)
|
||||
{
|
||||
if(!_initialized)
|
||||
this->_Init();
|
||||
if(!_initialized) // recheck
|
||||
{
|
||||
logerror("PseuGUI: not initialized, using non-GUI mode");
|
||||
Cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG(logdebug("PseuGUI::Run() _device=%X",_device));
|
||||
|
||||
int lastFPS = -1, fps = -1;
|
||||
|
||||
while(_device && _device->run() && !_mustdie)
|
||||
{
|
||||
_lastpasstime = _passtime;
|
||||
_passtime = _timer->getTime();
|
||||
_passtimediff = _passtime - _lastpasstime;
|
||||
// _HandleWindowResize(); // not yet used; doesnt work
|
||||
|
||||
if (!_device->isWindowActive())
|
||||
{
|
||||
_device->sleep(10); // save cpu & gpu power if not focused
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_UpdateSceneState();
|
||||
|
||||
if(_scene && _initialized)
|
||||
{
|
||||
if(_updateWorldPos)
|
||||
SetWorldPosition(_worldpos_tmp);
|
||||
_scene->OnUpdate(_passtimediff);
|
||||
}
|
||||
|
||||
_driver->beginScene(true, true, 0);
|
||||
|
||||
DrawCurrentScene();
|
||||
|
||||
_smgr->drawAll();
|
||||
_guienv->drawAll();
|
||||
|
||||
_driver->endScene();
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
logerror("Unhandled exception in PseuGUI::Run() device=%X smgr=%X objects:%u", _device, _smgr, domgr.StorageSize());
|
||||
}
|
||||
|
||||
fps = _driver->getFPS();
|
||||
|
||||
if (lastFPS != fps)
|
||||
{
|
||||
core::stringw str = L"PseuWoW [";
|
||||
str += _driver->getName();
|
||||
str += "] FPS:";
|
||||
str += fps;
|
||||
|
||||
_device->setWindowCaption(str.c_str());
|
||||
|
||||
lastFPS = fps;
|
||||
}
|
||||
|
||||
}
|
||||
DEBUG(logdebug("PseuGUI::Run() finished"));
|
||||
Cancel(); // already got shut down somehow, we can now safely cancel and drop the device
|
||||
}
|
||||
|
||||
// called from ObjMgr::Remove(guid)
|
||||
void PseuGUI::NotifyObjectDeletion(uint64 guid)
|
||||
{
|
||||
domgr.Delete(guid);
|
||||
}
|
||||
|
||||
// called from ObjMgr::Add(Object*)
|
||||
void PseuGUI::NotifyObjectCreation(Object *o)
|
||||
{
|
||||
DrawObject *d = new DrawObject(_smgr,o);
|
||||
domgr.Add(o->GetGUID(),d);
|
||||
}
|
||||
|
||||
void PseuGUI::SetInstance(PseuInstance* in)
|
||||
{
|
||||
_instance = in;
|
||||
}
|
||||
|
||||
void PseuGUI::SetSceneState(SceneState state)
|
||||
{
|
||||
_scenestate_new = state; // will be applied at next cycle
|
||||
}
|
||||
|
||||
void PseuGUI::_UpdateSceneState(void)
|
||||
{
|
||||
if(_scenestate != _scenestate_new && _smgr)
|
||||
{
|
||||
if(_scene)
|
||||
{
|
||||
_scene->OnDelete();
|
||||
delete _scene;
|
||||
}
|
||||
_smgr->clear();
|
||||
_guienv->clear();
|
||||
|
||||
_scenestate = _scenestate_new;
|
||||
|
||||
logdebug("PseuGUI: switched to SceneState %u", _scenestate);
|
||||
|
||||
switch (_scenestate)
|
||||
{
|
||||
case SCENESTATE_GUISTART: _scene = new SceneGuiStart(this); break;
|
||||
case SCENESTATE_WORLD: _scene = new SceneWorld(this); break;
|
||||
default: _scene = new Scene(this); // will draw nothing, just yield the gui
|
||||
}
|
||||
_scene->SetState(_scenestate);
|
||||
|
||||
logdebug("PseuGUI: scene created.");
|
||||
}
|
||||
}
|
||||
|
||||
void PseuGUI::DrawCurrentScene(void)
|
||||
{
|
||||
if(_scene && _initialized)
|
||||
_scene->OnDraw();
|
||||
}
|
||||
|
||||
// used to get our current WorldPosition
|
||||
WorldPosition PseuGUI::GetWorldPosition(void)
|
||||
{
|
||||
if(_scene && _scene->GetState() == SCENESTATE_WORLD)
|
||||
{
|
||||
return ((SceneWorld*)_scene)->GetWorldPosition();
|
||||
}
|
||||
return WorldPosition();
|
||||
}
|
||||
|
||||
// used to notify the SceneWorld about a position change the server sent to us
|
||||
void PseuGUI::SetWorldPosition(WorldPosition wp)
|
||||
{
|
||||
// buffer new position if the scene is not (yet) a world scene
|
||||
_worldpos_tmp = wp;
|
||||
if(_scene && _scene->GetState() == SCENESTATE_WORLD)
|
||||
{
|
||||
_updateWorldPos = false;
|
||||
((SceneWorld*)_scene)->SetWorldPosition(wp);
|
||||
}
|
||||
else
|
||||
{
|
||||
_updateWorldPos = true;
|
||||
}
|
||||
}
|
||||
|
||||
void PseuGUI::_HandleWindowResize(void)
|
||||
{
|
||||
dimension2d<s32> scrn = _driver->getScreenSize();
|
||||
if(_screendimension.Width != scrn.Width)
|
||||
{
|
||||
scrn.Height = s32(scrn.Width * 0.8f); // for now use aspect ratio 5:4
|
||||
_screendimension = scrn;
|
||||
_driver->OnResize(scrn);
|
||||
DEBUG(logdebug("DEBUG: Width resize handled, Height adjusted"));
|
||||
|
||||
}
|
||||
else if(_screendimension.Height != scrn.Height)
|
||||
{
|
||||
scrn.Width = s32(scrn.Height * 1.25); // 5:4 here too
|
||||
_screendimension = scrn;
|
||||
_driver->OnResize(scrn);
|
||||
DEBUG(logdebug("DEBUG: Height resize handled, Width adjusted"));
|
||||
|
||||
}
|
||||
// TODO: how to set irrlicht window size ?!
|
||||
|
||||
}
|
||||
#include "common.h"
|
||||
#include "irrlicht/irrlicht.h"
|
||||
#include "Object.h"
|
||||
#include "DrawObject.h"
|
||||
#include "PseuWoW.h"
|
||||
#include "Scene.h"
|
||||
#include "PseuGUI.h"
|
||||
|
||||
PseuGUIRunnable::PseuGUIRunnable()
|
||||
{
|
||||
_gui = new PseuGUI();
|
||||
}
|
||||
|
||||
void PseuGUIRunnable::run(void)
|
||||
{
|
||||
_gui->Run();
|
||||
}
|
||||
|
||||
PseuGUI *PseuGUIRunnable::GetGUI(void)
|
||||
{
|
||||
return _gui;
|
||||
}
|
||||
|
||||
PseuGUIRunnable::~PseuGUIRunnable()
|
||||
{
|
||||
delete _gui;
|
||||
}
|
||||
|
||||
PseuGUI::PseuGUI()
|
||||
{
|
||||
_xres = 640;
|
||||
_yres = 480;
|
||||
_colordepth = 32;
|
||||
_shadows = false;
|
||||
_windowed = true;
|
||||
_vsync = false;
|
||||
_initialized = false;
|
||||
_mustdie = false;
|
||||
_driverType = video::EDT_BURNINGSVIDEO; // nulldevice makes not really a sense to display stuff
|
||||
_scenestate = _scenestate_new = SCENESTATE_NULL;
|
||||
_smgr = NULL;
|
||||
_device = NULL;
|
||||
_guienv = NULL;
|
||||
_scene = NULL;
|
||||
_passtime = _lastpasstime = _passtimediff = 0;
|
||||
_updateWorldPos = false;
|
||||
}
|
||||
|
||||
PseuGUI::~PseuGUI()
|
||||
{
|
||||
this->Cancel();
|
||||
_instance->DeleteGUI(); // this makes the instance set its gui ptr to NULL
|
||||
logdebug("PseuGUI::~PseuGUI()");
|
||||
}
|
||||
|
||||
void PseuGUI::SetDriver(uint8 driverId)
|
||||
{
|
||||
switch(driverId)
|
||||
{
|
||||
case DIRECTX9: _driverType = video::EDT_DIRECT3D9; break;
|
||||
case DIRECTX8: _driverType = video::EDT_DIRECT3D8; break;
|
||||
case OPENGL: _driverType = video::EDT_OPENGL; break;
|
||||
case SOFTWARE: _driverType = video::EDT_SOFTWARE; break;
|
||||
case BURNINGSVIDEO: _driverType = video::EDT_BURNINGSVIDEO; break;
|
||||
case NULLDEVICE: _driverType = video::EDT_NULL; break;
|
||||
default: _driverType = video::EDT_BURNINGSVIDEO; // if no valid driver detected, use software
|
||||
}
|
||||
|
||||
// TODO: add support for changing driver during runtime?
|
||||
}
|
||||
|
||||
void PseuGUI::SetResolution(uint16 x, uint16 y, uint16 depth)
|
||||
{
|
||||
_xres = x;
|
||||
_yres = y;
|
||||
_colordepth = depth;
|
||||
}
|
||||
|
||||
void PseuGUI::SetWindowed(bool b)
|
||||
{
|
||||
_windowed = b;
|
||||
// see PseuGUI::Init(): !_windowed == fullscreen
|
||||
}
|
||||
|
||||
void PseuGUI::SetVSync(bool b)
|
||||
{
|
||||
_vsync = b;
|
||||
}
|
||||
|
||||
void PseuGUI::UseShadows(bool b)
|
||||
{
|
||||
_shadows = b;
|
||||
}
|
||||
|
||||
// if this fuction is called from another thread the device will not work correctly. o_O
|
||||
void PseuGUI::_Init(void)
|
||||
{
|
||||
_device = createDevice(_driverType,dimension2d<s32>(_xres,_yres),_colordepth,!_windowed,_shadows,_vsync);
|
||||
if(!_device)
|
||||
{
|
||||
logerror("PseuGUI: Can't use specified video driver, trying software mode...");
|
||||
_device = createDevice(video::EDT_SOFTWARE,dimension2d<s32>(_xres,_yres),_colordepth,!_windowed,false,false);
|
||||
if(!_device)
|
||||
{
|
||||
logerror("ERROR: PseuGUI::_Init() failed, no video driver available!");
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
logerror("PseuGUI: Software mode OK!");
|
||||
}
|
||||
}
|
||||
DEBUG(logdebug("PseuGUI::Init() _device=%X",_device));
|
||||
_device->setWindowCaption(L"PseuWoW - Initializing");
|
||||
_device->setResizeAble(true);
|
||||
_driver = _device->getVideoDriver();
|
||||
_smgr = _device->getSceneManager();
|
||||
_guienv = _device->getGUIEnvironment();
|
||||
_timer = _device->getTimer();
|
||||
//...
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
void PseuGUI::Cancel(void)
|
||||
{
|
||||
DEBUG(logdebug("PseuGUI::Cancel()"));
|
||||
|
||||
if(_scene)
|
||||
{
|
||||
_scene->OnDelete();
|
||||
delete _scene;
|
||||
_scene = NULL;
|
||||
}
|
||||
if(_device)
|
||||
{
|
||||
_device->drop();
|
||||
_device = NULL;
|
||||
|
||||
}
|
||||
_mustdie = true;
|
||||
}
|
||||
|
||||
void PseuGUI::Shutdown(void)
|
||||
{
|
||||
DEBUG(logdebug("PseuGUI::Shutdown()"));
|
||||
_mustdie = true;
|
||||
}
|
||||
|
||||
void PseuGUI::Run(void)
|
||||
{
|
||||
if(!_initialized)
|
||||
this->_Init();
|
||||
if(!_initialized) // recheck
|
||||
{
|
||||
logerror("PseuGUI: not initialized, using non-GUI mode");
|
||||
Cancel();
|
||||
return;
|
||||
}
|
||||
|
||||
DEBUG(logdebug("PseuGUI::Run() _device=%X",_device));
|
||||
|
||||
int lastFPS = -1, fps = -1;
|
||||
|
||||
while(_device && _device->run() && !_mustdie)
|
||||
{
|
||||
_lastpasstime = _passtime;
|
||||
_passtime = _timer->getTime();
|
||||
_passtimediff = _passtime - _lastpasstime;
|
||||
// _HandleWindowResize(); // not yet used; doesnt work
|
||||
|
||||
if (!_device->isWindowActive())
|
||||
{
|
||||
_device->sleep(10); // save cpu & gpu power if not focused
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
_UpdateSceneState();
|
||||
|
||||
if(_scene && _initialized)
|
||||
{
|
||||
if(_updateWorldPos)
|
||||
SetWorldPosition(_worldpos_tmp);
|
||||
_scene->OnUpdate(_passtimediff);
|
||||
}
|
||||
|
||||
_driver->beginScene(true, true, 0);
|
||||
|
||||
DrawCurrentScene();
|
||||
|
||||
_smgr->drawAll();
|
||||
_guienv->drawAll();
|
||||
|
||||
_driver->endScene();
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
logerror("Unhandled exception in PseuGUI::Run() device=%X smgr=%X objects:%u", _device, _smgr, domgr.StorageSize());
|
||||
}
|
||||
|
||||
fps = _driver->getFPS();
|
||||
|
||||
if (lastFPS != fps)
|
||||
{
|
||||
core::stringw str = L"PseuWoW [";
|
||||
str += _driver->getName();
|
||||
str += "] FPS:";
|
||||
str += fps;
|
||||
|
||||
_device->setWindowCaption(str.c_str());
|
||||
|
||||
lastFPS = fps;
|
||||
}
|
||||
|
||||
}
|
||||
DEBUG(logdebug("PseuGUI::Run() finished"));
|
||||
Cancel(); // already got shut down somehow, we can now safely cancel and drop the device
|
||||
}
|
||||
|
||||
// called from ObjMgr::Remove(guid)
|
||||
void PseuGUI::NotifyObjectDeletion(uint64 guid)
|
||||
{
|
||||
domgr.Delete(guid);
|
||||
}
|
||||
|
||||
// called from ObjMgr::Add(Object*)
|
||||
void PseuGUI::NotifyObjectCreation(Object *o)
|
||||
{
|
||||
DrawObject *d = new DrawObject(_smgr,o);
|
||||
domgr.Add(o->GetGUID(),d);
|
||||
}
|
||||
|
||||
void PseuGUI::SetInstance(PseuInstance* in)
|
||||
{
|
||||
_instance = in;
|
||||
}
|
||||
|
||||
void PseuGUI::SetSceneState(SceneState state)
|
||||
{
|
||||
_scenestate_new = state; // will be applied at next cycle
|
||||
}
|
||||
|
||||
void PseuGUI::_UpdateSceneState(void)
|
||||
{
|
||||
if(_scenestate != _scenestate_new && _smgr)
|
||||
{
|
||||
if(_scene)
|
||||
{
|
||||
_scene->OnDelete();
|
||||
delete _scene;
|
||||
}
|
||||
_smgr->clear();
|
||||
_guienv->clear();
|
||||
|
||||
_scenestate = _scenestate_new;
|
||||
|
||||
logdebug("PseuGUI: switched to SceneState %u", _scenestate);
|
||||
|
||||
switch (_scenestate)
|
||||
{
|
||||
case SCENESTATE_GUISTART: _scene = new SceneGuiStart(this); break;
|
||||
case SCENESTATE_WORLD: _scene = new SceneWorld(this); break;
|
||||
default: _scene = new Scene(this); // will draw nothing, just yield the gui
|
||||
}
|
||||
_scene->SetState(_scenestate);
|
||||
|
||||
logdebug("PseuGUI: scene created.");
|
||||
}
|
||||
}
|
||||
|
||||
void PseuGUI::DrawCurrentScene(void)
|
||||
{
|
||||
if(_scene && _initialized)
|
||||
_scene->OnDraw();
|
||||
}
|
||||
|
||||
// used to get our current WorldPosition
|
||||
WorldPosition PseuGUI::GetWorldPosition(void)
|
||||
{
|
||||
if(_scene && _scene->GetState() == SCENESTATE_WORLD)
|
||||
{
|
||||
return ((SceneWorld*)_scene)->GetWorldPosition();
|
||||
}
|
||||
return WorldPosition();
|
||||
}
|
||||
|
||||
// used to notify the SceneWorld about a position change the server sent to us
|
||||
void PseuGUI::SetWorldPosition(WorldPosition wp)
|
||||
{
|
||||
// buffer new position if the scene is not (yet) a world scene
|
||||
_worldpos_tmp = wp;
|
||||
if(_scene && _scene->GetState() == SCENESTATE_WORLD)
|
||||
{
|
||||
_updateWorldPos = false;
|
||||
((SceneWorld*)_scene)->SetWorldPosition(wp);
|
||||
}
|
||||
else
|
||||
{
|
||||
_updateWorldPos = true;
|
||||
}
|
||||
}
|
||||
|
||||
void PseuGUI::_HandleWindowResize(void)
|
||||
{
|
||||
dimension2d<s32> scrn = _driver->getScreenSize();
|
||||
if(_screendimension.Width != scrn.Width)
|
||||
{
|
||||
scrn.Height = s32(scrn.Width * 0.8f); // for now use aspect ratio 5:4
|
||||
_screendimension = scrn;
|
||||
_driver->OnResize(scrn);
|
||||
DEBUG(logdebug("DEBUG: Width resize handled, Height adjusted"));
|
||||
|
||||
}
|
||||
else if(_screendimension.Height != scrn.Height)
|
||||
{
|
||||
scrn.Width = s32(scrn.Height * 1.25); // 5:4 here too
|
||||
_screendimension = scrn;
|
||||
_driver->OnResize(scrn);
|
||||
DEBUG(logdebug("DEBUG: Height resize handled, Width adjusted"));
|
||||
|
||||
}
|
||||
// TODO: how to set irrlicht window size ?!
|
||||
|
||||
}
|
||||
|
||||
@ -1,110 +1,110 @@
|
||||
#ifndef PSEUGUI_H
|
||||
#define PSEUGUI_H
|
||||
|
||||
#include "irrlicht/irrlicht.h"
|
||||
#include "DrawObjMgr.h"
|
||||
#include "World.h"
|
||||
|
||||
class PseuGUI;
|
||||
class Object;
|
||||
class PseuInstance;
|
||||
class Scene;
|
||||
|
||||
enum SceneState
|
||||
{
|
||||
SCENESTATE_NULL,
|
||||
SCENESTATE_GUISTART,
|
||||
SCENESTATE_LOGINSCREEN,
|
||||
SCENESTATE_CHARACTERSELECTION,
|
||||
SCENESTATE_LOADING,
|
||||
SCENESTATE_WORLD
|
||||
};
|
||||
|
||||
enum DriverIDs
|
||||
{
|
||||
NULLDEVICE = 0,
|
||||
SOFTWARE = 1,
|
||||
BURNINGSVIDEO = 2,
|
||||
OPENGL = 3,
|
||||
DIRECTX8 = 4,
|
||||
DIRECTX9 = 5,
|
||||
};
|
||||
|
||||
class PseuGUIRunnable : public ZThread::Runnable
|
||||
{
|
||||
public:
|
||||
PseuGUIRunnable();
|
||||
~PseuGUIRunnable();
|
||||
void run(void);
|
||||
PseuGUI *GetGUI(void);
|
||||
private:
|
||||
PseuGUI* _gui;
|
||||
};
|
||||
|
||||
|
||||
class PseuGUI
|
||||
{
|
||||
// too bad friends are not inherited...
|
||||
friend class Scene;
|
||||
friend class SceneWorld;
|
||||
friend class SceneGuiStart;
|
||||
// ...
|
||||
|
||||
public:
|
||||
PseuGUI();
|
||||
~PseuGUI();
|
||||
|
||||
void SetInstance(PseuInstance*);
|
||||
inline PseuInstance *GetInstance(void) { return _instance; }
|
||||
void Run(void);
|
||||
void SetDriver(uint8);
|
||||
void SetResolution(uint16 x, uint16 y, uint16 depth=32);
|
||||
void SetWindowed(bool);
|
||||
void SetVSync(bool);
|
||||
void UseShadows(bool);
|
||||
void Cancel(void);
|
||||
void Shutdown(void);
|
||||
inline bool IsInitialized(void) { return _initialized; }
|
||||
|
||||
inline bool MustDie(void) { return _mustdie; }
|
||||
|
||||
// interfaces to tell the gui what to draw
|
||||
void NotifyObjectDeletion(uint64 guid);
|
||||
void NotifyObjectCreation(Object *o);
|
||||
|
||||
// scenes
|
||||
void DrawCurrentScene(void);
|
||||
void SetSceneState(SceneState);
|
||||
|
||||
// helpers
|
||||
WorldPosition GetWorldPosition(void);
|
||||
void SetWorldPosition(WorldPosition);
|
||||
|
||||
private:
|
||||
void _Init(void);
|
||||
void _UpdateSceneState(void);
|
||||
void _HandleWindowResize(void);
|
||||
uint16 _xres,_yres,_colordepth;
|
||||
bool _windowed,_vsync,_shadows;
|
||||
bool _initialized,_mustdie;
|
||||
irr::IrrlichtDevice *_device;
|
||||
irr::video::IVideoDriver* _driver;
|
||||
irr::scene::ISceneManager* _smgr;
|
||||
irr::gui::IGUIEnvironment* _guienv;
|
||||
irr::video::E_DRIVER_TYPE _driverType;
|
||||
DrawObjMgr domgr;
|
||||
PseuInstance *_instance;
|
||||
SceneState _scenestate, _scenestate_new;
|
||||
Scene *_scene;
|
||||
irr::ITimer *_timer;
|
||||
uint32 _passtime, _lastpasstime, _passtimediff;
|
||||
irr::core::dimension2d<irr::s32> _screendimension;
|
||||
WorldPosition _worldpos_tmp;
|
||||
bool _updateWorldPos;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef PSEUGUI_H
|
||||
#define PSEUGUI_H
|
||||
|
||||
#include "irrlicht/irrlicht.h"
|
||||
#include "DrawObjMgr.h"
|
||||
#include "World.h"
|
||||
|
||||
class PseuGUI;
|
||||
class Object;
|
||||
class PseuInstance;
|
||||
class Scene;
|
||||
|
||||
enum SceneState
|
||||
{
|
||||
SCENESTATE_NULL,
|
||||
SCENESTATE_GUISTART,
|
||||
SCENESTATE_LOGINSCREEN,
|
||||
SCENESTATE_CHARACTERSELECTION,
|
||||
SCENESTATE_LOADING,
|
||||
SCENESTATE_WORLD
|
||||
};
|
||||
|
||||
enum DriverIDs
|
||||
{
|
||||
NULLDEVICE = 0,
|
||||
SOFTWARE = 1,
|
||||
BURNINGSVIDEO = 2,
|
||||
OPENGL = 3,
|
||||
DIRECTX8 = 4,
|
||||
DIRECTX9 = 5,
|
||||
};
|
||||
|
||||
class PseuGUIRunnable : public ZThread::Runnable
|
||||
{
|
||||
public:
|
||||
PseuGUIRunnable();
|
||||
~PseuGUIRunnable();
|
||||
void run(void);
|
||||
PseuGUI *GetGUI(void);
|
||||
private:
|
||||
PseuGUI* _gui;
|
||||
};
|
||||
|
||||
|
||||
class PseuGUI
|
||||
{
|
||||
// too bad friends are not inherited...
|
||||
friend class Scene;
|
||||
friend class SceneWorld;
|
||||
friend class SceneGuiStart;
|
||||
// ...
|
||||
|
||||
public:
|
||||
PseuGUI();
|
||||
~PseuGUI();
|
||||
|
||||
void SetInstance(PseuInstance*);
|
||||
inline PseuInstance *GetInstance(void) { return _instance; }
|
||||
void Run(void);
|
||||
void SetDriver(uint8);
|
||||
void SetResolution(uint16 x, uint16 y, uint16 depth=32);
|
||||
void SetWindowed(bool);
|
||||
void SetVSync(bool);
|
||||
void UseShadows(bool);
|
||||
void Cancel(void);
|
||||
void Shutdown(void);
|
||||
inline bool IsInitialized(void) { return _initialized; }
|
||||
|
||||
inline bool MustDie(void) { return _mustdie; }
|
||||
|
||||
// interfaces to tell the gui what to draw
|
||||
void NotifyObjectDeletion(uint64 guid);
|
||||
void NotifyObjectCreation(Object *o);
|
||||
|
||||
// scenes
|
||||
void DrawCurrentScene(void);
|
||||
void SetSceneState(SceneState);
|
||||
|
||||
// helpers
|
||||
WorldPosition GetWorldPosition(void);
|
||||
void SetWorldPosition(WorldPosition);
|
||||
|
||||
private:
|
||||
void _Init(void);
|
||||
void _UpdateSceneState(void);
|
||||
void _HandleWindowResize(void);
|
||||
uint16 _xres,_yres,_colordepth;
|
||||
bool _windowed,_vsync,_shadows;
|
||||
bool _initialized,_mustdie;
|
||||
irr::IrrlichtDevice *_device;
|
||||
irr::video::IVideoDriver* _driver;
|
||||
irr::scene::ISceneManager* _smgr;
|
||||
irr::gui::IGUIEnvironment* _guienv;
|
||||
irr::video::E_DRIVER_TYPE _driverType;
|
||||
DrawObjMgr domgr;
|
||||
PseuInstance *_instance;
|
||||
SceneState _scenestate, _scenestate_new;
|
||||
Scene *_scene;
|
||||
irr::ITimer *_timer;
|
||||
uint32 _passtime, _lastpasstime, _passtimediff;
|
||||
irr::core::dimension2d<irr::s32> _screendimension;
|
||||
WorldPosition _worldpos_tmp;
|
||||
bool _updateWorldPos;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@ -1,31 +1,31 @@
|
||||
#include "common.h"
|
||||
#include "PseuGUI.h"
|
||||
#include "PseuWoW.h"
|
||||
#include "Scene.h"
|
||||
|
||||
Scene::Scene(PseuGUI *g)
|
||||
{
|
||||
gui = g;
|
||||
device = gui->_device;
|
||||
driver = gui->_driver;
|
||||
smgr = gui->_smgr;
|
||||
guienv = gui->_guienv;
|
||||
}
|
||||
|
||||
void Scene::OnDraw(void)
|
||||
{
|
||||
device->yield();
|
||||
}
|
||||
|
||||
void Scene::OnDelete(void)
|
||||
{
|
||||
}
|
||||
|
||||
void Scene::OnUpdate(s32)
|
||||
{
|
||||
}
|
||||
|
||||
Scene::~Scene()
|
||||
{
|
||||
DEBUG(logdebug("Scene::~Scene()"));
|
||||
}
|
||||
#include "common.h"
|
||||
#include "PseuGUI.h"
|
||||
#include "PseuWoW.h"
|
||||
#include "Scene.h"
|
||||
|
||||
Scene::Scene(PseuGUI *g)
|
||||
{
|
||||
gui = g;
|
||||
device = gui->_device;
|
||||
driver = gui->_driver;
|
||||
smgr = gui->_smgr;
|
||||
guienv = gui->_guienv;
|
||||
}
|
||||
|
||||
void Scene::OnDraw(void)
|
||||
{
|
||||
device->yield();
|
||||
}
|
||||
|
||||
void Scene::OnDelete(void)
|
||||
{
|
||||
}
|
||||
|
||||
void Scene::OnUpdate(s32)
|
||||
{
|
||||
}
|
||||
|
||||
Scene::~Scene()
|
||||
{
|
||||
DEBUG(logdebug("Scene::~Scene()"));
|
||||
}
|
||||
|
||||
@ -1,33 +1,33 @@
|
||||
#include "common.h"
|
||||
#include "PseuGUI.h"
|
||||
#include "PseuWoW.h"
|
||||
#include "Scene.h"
|
||||
|
||||
|
||||
SceneGuiStart::SceneGuiStart(PseuGUI *gui) : Scene(gui)
|
||||
{
|
||||
|
||||
irrlogo = guienv->addImage(driver->getTexture("data/misc/irrlichtlogo.png"), core::position2d<s32>(5,5));
|
||||
char *fn;
|
||||
switch(gui->_driverType)
|
||||
{
|
||||
case DIRECTX8:
|
||||
case DIRECTX9:
|
||||
fn = "data/misc/directxlogo.png";
|
||||
break;
|
||||
|
||||
case OPENGL:
|
||||
fn = "data/misc/opengllogo.png";
|
||||
break;
|
||||
|
||||
default:
|
||||
fn = "data/misc/burninglogo.png";
|
||||
}
|
||||
driverlogo = guienv->addImage(driver->getTexture(fn), core::position2d<s32>(50,50));
|
||||
|
||||
}
|
||||
|
||||
void SceneGuiStart::OnDelete(void)
|
||||
{
|
||||
// not necessary to delete the images, because they are deleted by guienv->clear()
|
||||
}
|
||||
#include "common.h"
|
||||
#include "PseuGUI.h"
|
||||
#include "PseuWoW.h"
|
||||
#include "Scene.h"
|
||||
|
||||
|
||||
SceneGuiStart::SceneGuiStart(PseuGUI *gui) : Scene(gui)
|
||||
{
|
||||
|
||||
irrlogo = guienv->addImage(driver->getTexture("data/misc/irrlichtlogo.png"), core::position2d<s32>(5,5));
|
||||
char *fn;
|
||||
switch(gui->_driverType)
|
||||
{
|
||||
case DIRECTX8:
|
||||
case DIRECTX9:
|
||||
fn = "data/misc/directxlogo.png";
|
||||
break;
|
||||
|
||||
case OPENGL:
|
||||
fn = "data/misc/opengllogo.png";
|
||||
break;
|
||||
|
||||
default:
|
||||
fn = "data/misc/burninglogo.png";
|
||||
}
|
||||
driverlogo = guienv->addImage(driver->getTexture(fn), core::position2d<s32>(50,50));
|
||||
|
||||
}
|
||||
|
||||
void SceneGuiStart::OnDelete(void)
|
||||
{
|
||||
// not necessary to delete the images, because they are deleted by guienv->clear()
|
||||
}
|
||||
|
||||
@ -1,376 +1,376 @@
|
||||
#include <sstream>
|
||||
#include <math.h>
|
||||
#include "common.h"
|
||||
#include "PseuGUI.h"
|
||||
#include "PseuWoW.h"
|
||||
#include "Scene.h"
|
||||
#include "MapTile.h"
|
||||
#include "MapMgr.h"
|
||||
#include "ShTlTerrainSceneNode.h"
|
||||
#include "MCamera.h"
|
||||
#include "MInput.h"
|
||||
#include "WorldSession.h"
|
||||
#include "World.h"
|
||||
|
||||
#define MOUSE_SENSIVITY 0.5f
|
||||
#define ANGLE_STEP (M_PI/180)
|
||||
#define DEG_TO_RAD(x) ((x)*ANGLE_STEP)
|
||||
#define RAD_TO_DEG(x) ((x)/ANGLE_STEP)
|
||||
#define RAD_FIX(x) ( (x)>(2*M_PI) ? ((x)-(2*M_PI)) : (x) )
|
||||
#define DEG_FIX(x) ( (x)>360 ? ((x)-360) : (x) )
|
||||
|
||||
#define COORD_SCALE_VALUE_X 0.336f
|
||||
#define COORD_SCALE_VALUE_Y 0.2f
|
||||
|
||||
|
||||
|
||||
SceneWorld::SceneWorld(PseuGUI *g) : Scene(g)
|
||||
{
|
||||
DEBUG(logdebug("SceneWorld: Initializing..."));
|
||||
debugmode = false;
|
||||
|
||||
// store some pointers right now to prevent repeated ptr dereferencing later (speeds up code)
|
||||
gui = g;
|
||||
wsession = gui->GetInstance()->GetWSession();
|
||||
mapmgr = wsession->GetWorld()->GetMapMgr();
|
||||
|
||||
// TODO: hardcoded for now, make this adjustable later
|
||||
float fogdist = 150;
|
||||
|
||||
ILightSceneNode* light = smgr->addLightSceneNode(0, core::vector3df(0,0,0), SColorf(255, 255, 255, 255), 1000.0f);
|
||||
SLight ldata = light->getLightData();
|
||||
ldata.AmbientColor = video::SColorf(0.2f,0.2f,0.2f);
|
||||
ldata.DiffuseColor = video::SColorf(1.0f,1.0f,1.0f);
|
||||
ldata.Type = video::ELT_DIRECTIONAL;
|
||||
ldata.Position = core::vector3df(-10,5,-5);
|
||||
light->setLightData(ldata);
|
||||
|
||||
eventrecv = new MyEventReceiver();
|
||||
device->setEventReceiver(eventrecv);
|
||||
|
||||
camera = new MCameraFPS(smgr);
|
||||
camera->setNearValue(0.1f);
|
||||
camera->setFarValue(12000); // TODO: adjust
|
||||
|
||||
debugText = guienv->addStaticText(L"< debug text >",rect<s32>(0,0,driver->getScreenSize().Width,30),true,true,0,-1,true);
|
||||
|
||||
smgr->addSkyDomeSceneNode(driver->getTexture("data/misc/sky.jpg"),64,64,1.0f,2.0f);
|
||||
|
||||
driver->setFog(video::SColor(0,100,101,190), true, fogdist, fogdist + 30, 0.02f);
|
||||
|
||||
// setup cursor
|
||||
device->getCursorControl()->setVisible(false);
|
||||
|
||||
InitTerrain();
|
||||
UpdateTerrain();
|
||||
|
||||
DEBUG(logdebug("SceneWorld: Init done!"));
|
||||
}
|
||||
|
||||
void SceneWorld::OnUpdate(s32 timediff)
|
||||
{
|
||||
static position2d<s32> mouse_pos;
|
||||
|
||||
UpdateTerrain();
|
||||
|
||||
bool mouse_pressed_left = eventrecv->mouse.left_pressed();
|
||||
bool mouse_pressed_right = eventrecv->mouse.right_pressed();
|
||||
float timediff_f = timediff / 1000.0f;
|
||||
|
||||
if(eventrecv->key.pressed(KEY_KEY_W) || (mouse_pressed_left && mouse_pressed_right))
|
||||
camera->moveForward(50 * timediff_f);
|
||||
if(eventrecv->key.pressed(KEY_KEY_S))
|
||||
camera->moveBack(50 * timediff_f);
|
||||
if(eventrecv->key.pressed(KEY_KEY_E))
|
||||
camera->moveRight(50 * timediff_f);
|
||||
if(eventrecv->key.pressed(KEY_KEY_Q))
|
||||
camera->moveLeft(50 * timediff_f);
|
||||
|
||||
// if right mouse button pressed, move in axis, if not, turn camera
|
||||
if(eventrecv->key.pressed(KEY_KEY_D))
|
||||
{
|
||||
if(mouse_pressed_right)
|
||||
camera->moveRight(50 * timediff_f);
|
||||
else
|
||||
camera->turnRight(timediff_f * M_PI * 25);
|
||||
}
|
||||
if(eventrecv->key.pressed(KEY_KEY_A))
|
||||
{
|
||||
if(mouse_pressed_right)
|
||||
camera->moveLeft(50 * timediff_f);
|
||||
else
|
||||
camera->turnLeft(timediff_f * M_PI * 25);
|
||||
}
|
||||
|
||||
if(eventrecv->key.pressed_once(KEY_BACK))
|
||||
{
|
||||
debugmode = !debugmode;
|
||||
if(debugmode)
|
||||
{
|
||||
terrain->setDebugDataVisible(EDS_FULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
terrain->setDebugDataVisible(EDS_OFF);
|
||||
}
|
||||
}
|
||||
|
||||
if(eventrecv->key.pressed_once(KEY_INSERT))
|
||||
{
|
||||
IImage *scrnshot = driver->createScreenShot();
|
||||
if(scrnshot)
|
||||
{
|
||||
CreateDir("screenshots");
|
||||
std::string date = getDateString();
|
||||
for(uint32 i = 0; i < date.length(); i++)
|
||||
{
|
||||
if(date[i] == ':')
|
||||
date[i] = '_';
|
||||
}
|
||||
if(date[date.length()-1] == ' ')
|
||||
{
|
||||
date = date.substr(0,date.length()-2);
|
||||
}
|
||||
driver->writeImageToFile(scrnshot, ("screenshots/PseuWoW " + date + ".jpg").c_str(), device->getTimer()->getRealTime());
|
||||
scrnshot->drop();
|
||||
}
|
||||
}
|
||||
|
||||
if(mouse_pressed_left || mouse_pressed_right)
|
||||
{
|
||||
//if(device->getCursorControl()->isVisible())
|
||||
//device->getCursorControl()->setVisible(false);
|
||||
if(mouse_pos != device->getCursorControl()->getPosition())
|
||||
{
|
||||
camera->turnRight(MOUSE_SENSIVITY * (device->getCursorControl()->getPosition().X - mouse_pos.X));
|
||||
// check if new camera pitch would cause camera to flip over; if thats the case keep current pitch
|
||||
f32 upval = MOUSE_SENSIVITY * (device->getCursorControl()->getPosition().Y - mouse_pos.Y);
|
||||
f32 newval = camera->getPitch() + upval;
|
||||
if( newval > 270.1f || newval < 89.9f)
|
||||
{
|
||||
camera->turnUp(upval);
|
||||
}
|
||||
device->getCursorControl()->setPosition(mouse_pos);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
device->getCursorControl()->setPosition(device->getCursorControl()->getPosition());
|
||||
//if(!device->getCursorControl()->isVisible())
|
||||
//device->getCursorControl()->setVisible(true);
|
||||
mouse_pos = device->getCursorControl()->getPosition();
|
||||
}
|
||||
|
||||
// camera height control
|
||||
if (eventrecv->mouse.wheel < 10) eventrecv->mouse.wheel = 10;
|
||||
camera->setHeight( eventrecv->mouse.wheel + terrain->getHeight(camera->getPosition()) );
|
||||
|
||||
WorldPosition wp = GetWorldPosition();
|
||||
core::stringw str = L"Camera: pitch:";
|
||||
str += camera->getPitch();
|
||||
str += L" c pos:";
|
||||
str += camera->getPosition().X;
|
||||
str += L",";
|
||||
str += camera->getPosition().Y;
|
||||
str += L",";
|
||||
str += camera->getPosition().Z;
|
||||
str += " ## HEAD: ";
|
||||
str += DEG_TO_RAD(camera->getHeading());
|
||||
str += L" Pos: ";
|
||||
str = ((((((str + wp.x) + L" | ") + wp.y) + L" | ") + wp.z) + L" | OR:") + wp.o;
|
||||
str += L" -- Terrain: Sectors: ";
|
||||
str += (int)terrain->getSectorsRendered();
|
||||
str += L" / ";
|
||||
str += (int)terrain->getSectorCount();
|
||||
debugText->setText(str.c_str());
|
||||
|
||||
}
|
||||
|
||||
void SceneWorld::OnDraw(void)
|
||||
{
|
||||
// draw all objects
|
||||
gui->domgr.Update(); // iterate over DrawObjects, draw them and clean up
|
||||
}
|
||||
|
||||
void SceneWorld::OnDelete(void)
|
||||
{
|
||||
DEBUG(logdebug("~SceneWorld()"));
|
||||
}
|
||||
|
||||
void SceneWorld::InitTerrain(void)
|
||||
{
|
||||
if(!mapmgr)
|
||||
{
|
||||
logerror("SceneWorld: MapMgr not present, cant create World GUI. Switching back GUI to idle.");
|
||||
gui->SetSceneState(SCENESTATE_GUISTART);
|
||||
return;
|
||||
}
|
||||
|
||||
mapsize = 8 * 16 * 3; // 9-1 height floats in 16 chunks per tile per axis in 3 MapTiles
|
||||
tilesize = UNITSIZE;
|
||||
meshsize = (s32)CHUNKSIZE*3;
|
||||
vector3df terrainPos(0.0f, 0.0f, 0.0f); // TODO: use PseuWoW's world coords here?
|
||||
|
||||
camera->setPosition(core::vector3df(mapsize*tilesize/2, 0, mapsize*tilesize/2) + terrainPos);
|
||||
|
||||
terrain = new ShTlTerrainSceneNode(smgr,mapsize,mapsize,tilesize,meshsize);
|
||||
terrain->drop();
|
||||
terrain->follow(camera->getNode());
|
||||
terrain->setMaterialTexture(0, driver->getTexture("data/misc/dirt_test.jpg"));
|
||||
terrain->setMaterialFlag(video::EMF_LIGHTING, true);
|
||||
terrain->setMaterialFlag(video::EMF_FOG_ENABLE, true);
|
||||
terrain->setPosition(terrainPos);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void SceneWorld::UpdateTerrain(void)
|
||||
{
|
||||
// check if we changed the maptile
|
||||
if(map_gridX == mapmgr->GetGridX() && map_gridY == mapmgr->GetGridY())
|
||||
return; // grid not changed, not necessary to update tile data
|
||||
|
||||
// ... if changed, do necessary stuff...
|
||||
map_gridX = mapmgr->GetGridX();
|
||||
map_gridY = mapmgr->GetGridY();
|
||||
|
||||
// TODO: better to do this with some ZThread Condition or FastMutex, but dont know how to. help plz! [FG]
|
||||
if(!mapmgr->Loaded())
|
||||
{
|
||||
logdebug("SceneWorld: Waiting until maps are loaded...");
|
||||
while(!mapmgr->Loaded())
|
||||
device->sleep(1);
|
||||
}
|
||||
|
||||
// TODO: as soon as WMO-only worlds are implemented, remove this!!
|
||||
if(!mapmgr->GetLoadedMapsCount())
|
||||
{
|
||||
logerror("SceneWorld: Error: No maps loaded, not able to draw any terrain. Switching back GUI to idle.");
|
||||
logerror("SceneWorld: Hint: Be sure you are not in an WMO-only world (e.g. human capital city or most instances)!");
|
||||
gui->SetSceneState(SCENESTATE_GUISTART);
|
||||
return;
|
||||
}
|
||||
|
||||
// something is not good here. we have terrain, but the chunks are read incorrectly.
|
||||
// need to find out where which formula is wrong
|
||||
// the current terrain renderer code is just a test to see if ADT files are read correctly.
|
||||
// EDIT: it seems to display fine now, but i am still not sure if the way it is done is correct...
|
||||
mutex.acquire(); // prevent other threads from deleting the maptile
|
||||
logdebug("SceneWorld: Displaying MapTiles near grids x:%u y:%u",mapmgr->GetGridX(),mapmgr->GetGridY());
|
||||
for(s32 tiley = 0; tiley < 3; tiley++)
|
||||
{
|
||||
for(s32 tilex = 0; tilex < 3; tilex++)
|
||||
{
|
||||
MapTile *maptile = mapmgr->GetNearTile(tilex - 1, tiley - 1);
|
||||
if(maptile)
|
||||
{
|
||||
// apply map height data
|
||||
for(uint32 chy = 0; chy < 16; chy++)
|
||||
for(uint32 chx = 0; chx < 16; chx++)
|
||||
{
|
||||
MapChunk *chunk = maptile->GetChunk(chx, chy);
|
||||
for(uint32 hy = 0; hy < 8; hy++)
|
||||
{
|
||||
for(uint32 hx = 0; hx < 8; hx++)
|
||||
{
|
||||
f32 h = chunk->hmap_rough[hy * 9 + hx] + chunk->baseheight; // not sure if hx and hy are used correctly here
|
||||
u32 terrainx = (128 * tilex) + (8 * chx) + hx;
|
||||
u32 terrainy = (128 * tiley) + (8 * chy) + hy;
|
||||
terrain->setHeight(terrainy, terrainx, h);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logerror("SceneWorld: MapTile not loaded, can't apply heightmap!");
|
||||
}
|
||||
}
|
||||
}
|
||||
mutex.release();
|
||||
|
||||
// find out highest/lowest spot
|
||||
f32 highest = terrain->getHeight(0,0);
|
||||
f32 lowest = terrain->getHeight(0,0);
|
||||
f32 curheight;
|
||||
for(s32 j=0; j<terrain->getSize().Height+1; j++)
|
||||
for(s32 i=0; i<terrain->getSize().Width+1; i++)
|
||||
{
|
||||
curheight = terrain->getHeight(i,j);
|
||||
highest = max(highest,curheight);
|
||||
lowest = min(lowest,curheight);
|
||||
}
|
||||
// f32 heightdiff = highest - lowest;
|
||||
|
||||
// randomize terrain color depending on height
|
||||
for(s32 j=0; j<terrain->getSize().Height+1; j++)
|
||||
for(s32 i=0; i<terrain->getSize().Width+1; i++)
|
||||
{
|
||||
curheight = terrain->getHeight(i,j);
|
||||
u32 g = (u32)(curheight / highest * 120) + 125;
|
||||
u32 r = (u32)(curheight / highest * 120) + 60;
|
||||
u32 b = (u32)(curheight / highest * 120) + 60;
|
||||
|
||||
terrain->setColor(i,j, video::SColor(255,r,g,b));
|
||||
}
|
||||
|
||||
logdebug("SceneWorld: Smoothing terrain normals...");
|
||||
terrain->smoothNormals();
|
||||
}
|
||||
|
||||
WorldPosition SceneWorld::GetWorldPosition(void)
|
||||
{
|
||||
// TODO: later do not use CAMERA, but CHARACTER position, as soon as camera is changed from 1st to 3rd person view
|
||||
// and floating around character in the middle
|
||||
vector3df cam = camera->getPosition();
|
||||
// TODO: need to correct camera values, the coords irrlicht returns are not suitable
|
||||
|
||||
// get the current maptile and use the coords of the top-left corner as relative positions
|
||||
MapTile *tile = mapmgr->GetCurrentTile();
|
||||
if(!tile)
|
||||
{
|
||||
logerror("SceneWorld::GetWorldPosition failed, MapTile not loaded!");
|
||||
return WorldPosition();
|
||||
}
|
||||
|
||||
float mapx = tile->GetBaseX();
|
||||
float mapy = tile->GetBaseY();
|
||||
|
||||
// the following formulas are NOT correct, just estimated. in most places they will differ from real expected values a lot!
|
||||
float relx = cam.X * COORD_SCALE_VALUE_X + CHUNKSIZE;
|
||||
float rely = cam.Z * COORD_SCALE_VALUE_Y + CHUNKSIZE;
|
||||
|
||||
float o = DEG_TO_RAD(camera->getHeading()) + ((M_PI*3.0f)/2.0f);
|
||||
return WorldPosition(mapx - relx, mapy - rely, cam.Y, RAD_FIX(o) );
|
||||
}
|
||||
|
||||
void SceneWorld::SetWorldPosition(WorldPosition wp)
|
||||
{
|
||||
UpdateTerrain();
|
||||
vector3df cam;
|
||||
dimension2d<s32> tsize = terrain->getSize();
|
||||
MapTile *tile = mapmgr->GetTile(MapMgr::GetGridCoord(wp.x), MapMgr::GetGridCoord(wp.y));
|
||||
ASSERT(tile == mapmgr->GetCurrentTile()); // for debugging; we should already be located on the new tile
|
||||
if(!tile)
|
||||
{
|
||||
logerror("SceneWorld::SetWorldPosition(): MapTile not loaded!");
|
||||
return;
|
||||
}
|
||||
cam.X = tile->GetBaseX() - wp.x + (tsize.Width * UNITSIZE);
|
||||
cam.Z = tile->GetBaseX() - wp.y + (tsize.Height * UNITSIZE);
|
||||
float heading = RAD_TO_DEG(((M_PI*3.0f)/2.0f) - wp.o);
|
||||
float heading_diff = camera->getHeading() - heading;
|
||||
logdebug("Setting camera to x: %3f y: %3f z:%3f head: %3f", cam.X, cam.Y, cam.Z, heading);
|
||||
camera->turnLeft(heading_diff);
|
||||
|
||||
// TODO:
|
||||
// - correct the above formulas
|
||||
// - find out terrain height where the camera should be set
|
||||
// - set camera to correct position
|
||||
// - correct camera turning
|
||||
//camera->setPosition(cam);
|
||||
//camera->turnRight(heading_diff);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include <sstream>
|
||||
#include <math.h>
|
||||
#include "common.h"
|
||||
#include "PseuGUI.h"
|
||||
#include "PseuWoW.h"
|
||||
#include "Scene.h"
|
||||
#include "MapTile.h"
|
||||
#include "MapMgr.h"
|
||||
#include "ShTlTerrainSceneNode.h"
|
||||
#include "MCamera.h"
|
||||
#include "MInput.h"
|
||||
#include "WorldSession.h"
|
||||
#include "World.h"
|
||||
|
||||
#define MOUSE_SENSIVITY 0.5f
|
||||
#define ANGLE_STEP (M_PI/180)
|
||||
#define DEG_TO_RAD(x) ((x)*ANGLE_STEP)
|
||||
#define RAD_TO_DEG(x) ((x)/ANGLE_STEP)
|
||||
#define RAD_FIX(x) ( (x)>(2*M_PI) ? ((x)-(2*M_PI)) : (x) )
|
||||
#define DEG_FIX(x) ( (x)>360 ? ((x)-360) : (x) )
|
||||
|
||||
#define COORD_SCALE_VALUE_X 0.336f
|
||||
#define COORD_SCALE_VALUE_Y 0.2f
|
||||
|
||||
|
||||
|
||||
SceneWorld::SceneWorld(PseuGUI *g) : Scene(g)
|
||||
{
|
||||
DEBUG(logdebug("SceneWorld: Initializing..."));
|
||||
debugmode = false;
|
||||
|
||||
// store some pointers right now to prevent repeated ptr dereferencing later (speeds up code)
|
||||
gui = g;
|
||||
wsession = gui->GetInstance()->GetWSession();
|
||||
mapmgr = wsession->GetWorld()->GetMapMgr();
|
||||
|
||||
// TODO: hardcoded for now, make this adjustable later
|
||||
float fogdist = 150;
|
||||
|
||||
ILightSceneNode* light = smgr->addLightSceneNode(0, core::vector3df(0,0,0), SColorf(255, 255, 255, 255), 1000.0f);
|
||||
SLight ldata = light->getLightData();
|
||||
ldata.AmbientColor = video::SColorf(0.2f,0.2f,0.2f);
|
||||
ldata.DiffuseColor = video::SColorf(1.0f,1.0f,1.0f);
|
||||
ldata.Type = video::ELT_DIRECTIONAL;
|
||||
ldata.Position = core::vector3df(-10,5,-5);
|
||||
light->setLightData(ldata);
|
||||
|
||||
eventrecv = new MyEventReceiver();
|
||||
device->setEventReceiver(eventrecv);
|
||||
|
||||
camera = new MCameraFPS(smgr);
|
||||
camera->setNearValue(0.1f);
|
||||
camera->setFarValue(12000); // TODO: adjust
|
||||
|
||||
debugText = guienv->addStaticText(L"< debug text >",rect<s32>(0,0,driver->getScreenSize().Width,30),true,true,0,-1,true);
|
||||
|
||||
smgr->addSkyDomeSceneNode(driver->getTexture("data/misc/sky.jpg"),64,64,1.0f,2.0f);
|
||||
|
||||
driver->setFog(video::SColor(0,100,101,190), true, fogdist, fogdist + 30, 0.02f);
|
||||
|
||||
// setup cursor
|
||||
device->getCursorControl()->setVisible(false);
|
||||
|
||||
InitTerrain();
|
||||
UpdateTerrain();
|
||||
|
||||
DEBUG(logdebug("SceneWorld: Init done!"));
|
||||
}
|
||||
|
||||
void SceneWorld::OnUpdate(s32 timediff)
|
||||
{
|
||||
static position2d<s32> mouse_pos;
|
||||
|
||||
UpdateTerrain();
|
||||
|
||||
bool mouse_pressed_left = eventrecv->mouse.left_pressed();
|
||||
bool mouse_pressed_right = eventrecv->mouse.right_pressed();
|
||||
float timediff_f = timediff / 1000.0f;
|
||||
|
||||
if(eventrecv->key.pressed(KEY_KEY_W) || (mouse_pressed_left && mouse_pressed_right))
|
||||
camera->moveForward(50 * timediff_f);
|
||||
if(eventrecv->key.pressed(KEY_KEY_S))
|
||||
camera->moveBack(50 * timediff_f);
|
||||
if(eventrecv->key.pressed(KEY_KEY_E))
|
||||
camera->moveRight(50 * timediff_f);
|
||||
if(eventrecv->key.pressed(KEY_KEY_Q))
|
||||
camera->moveLeft(50 * timediff_f);
|
||||
|
||||
// if right mouse button pressed, move in axis, if not, turn camera
|
||||
if(eventrecv->key.pressed(KEY_KEY_D))
|
||||
{
|
||||
if(mouse_pressed_right)
|
||||
camera->moveRight(50 * timediff_f);
|
||||
else
|
||||
camera->turnRight(timediff_f * M_PI * 25);
|
||||
}
|
||||
if(eventrecv->key.pressed(KEY_KEY_A))
|
||||
{
|
||||
if(mouse_pressed_right)
|
||||
camera->moveLeft(50 * timediff_f);
|
||||
else
|
||||
camera->turnLeft(timediff_f * M_PI * 25);
|
||||
}
|
||||
|
||||
if(eventrecv->key.pressed_once(KEY_BACK))
|
||||
{
|
||||
debugmode = !debugmode;
|
||||
if(debugmode)
|
||||
{
|
||||
terrain->setDebugDataVisible(EDS_FULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
terrain->setDebugDataVisible(EDS_OFF);
|
||||
}
|
||||
}
|
||||
|
||||
if(eventrecv->key.pressed_once(KEY_INSERT))
|
||||
{
|
||||
IImage *scrnshot = driver->createScreenShot();
|
||||
if(scrnshot)
|
||||
{
|
||||
CreateDir("screenshots");
|
||||
std::string date = getDateString();
|
||||
for(uint32 i = 0; i < date.length(); i++)
|
||||
{
|
||||
if(date[i] == ':')
|
||||
date[i] = '_';
|
||||
}
|
||||
if(date[date.length()-1] == ' ')
|
||||
{
|
||||
date = date.substr(0,date.length()-2);
|
||||
}
|
||||
driver->writeImageToFile(scrnshot, ("screenshots/PseuWoW " + date + ".jpg").c_str(), device->getTimer()->getRealTime());
|
||||
scrnshot->drop();
|
||||
}
|
||||
}
|
||||
|
||||
if(mouse_pressed_left || mouse_pressed_right)
|
||||
{
|
||||
//if(device->getCursorControl()->isVisible())
|
||||
//device->getCursorControl()->setVisible(false);
|
||||
if(mouse_pos != device->getCursorControl()->getPosition())
|
||||
{
|
||||
camera->turnRight(MOUSE_SENSIVITY * (device->getCursorControl()->getPosition().X - mouse_pos.X));
|
||||
// check if new camera pitch would cause camera to flip over; if thats the case keep current pitch
|
||||
f32 upval = MOUSE_SENSIVITY * (device->getCursorControl()->getPosition().Y - mouse_pos.Y);
|
||||
f32 newval = camera->getPitch() + upval;
|
||||
if( newval > 270.1f || newval < 89.9f)
|
||||
{
|
||||
camera->turnUp(upval);
|
||||
}
|
||||
device->getCursorControl()->setPosition(mouse_pos);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
device->getCursorControl()->setPosition(device->getCursorControl()->getPosition());
|
||||
//if(!device->getCursorControl()->isVisible())
|
||||
//device->getCursorControl()->setVisible(true);
|
||||
mouse_pos = device->getCursorControl()->getPosition();
|
||||
}
|
||||
|
||||
// camera height control
|
||||
if (eventrecv->mouse.wheel < 10) eventrecv->mouse.wheel = 10;
|
||||
camera->setHeight( eventrecv->mouse.wheel + terrain->getHeight(camera->getPosition()) );
|
||||
|
||||
WorldPosition wp = GetWorldPosition();
|
||||
core::stringw str = L"Camera: pitch:";
|
||||
str += camera->getPitch();
|
||||
str += L" c pos:";
|
||||
str += camera->getPosition().X;
|
||||
str += L",";
|
||||
str += camera->getPosition().Y;
|
||||
str += L",";
|
||||
str += camera->getPosition().Z;
|
||||
str += " ## HEAD: ";
|
||||
str += DEG_TO_RAD(camera->getHeading());
|
||||
str += L" Pos: ";
|
||||
str = ((((((str + wp.x) + L" | ") + wp.y) + L" | ") + wp.z) + L" | OR:") + wp.o;
|
||||
str += L" -- Terrain: Sectors: ";
|
||||
str += (int)terrain->getSectorsRendered();
|
||||
str += L" / ";
|
||||
str += (int)terrain->getSectorCount();
|
||||
debugText->setText(str.c_str());
|
||||
|
||||
}
|
||||
|
||||
void SceneWorld::OnDraw(void)
|
||||
{
|
||||
// draw all objects
|
||||
gui->domgr.Update(); // iterate over DrawObjects, draw them and clean up
|
||||
}
|
||||
|
||||
void SceneWorld::OnDelete(void)
|
||||
{
|
||||
DEBUG(logdebug("~SceneWorld()"));
|
||||
}
|
||||
|
||||
void SceneWorld::InitTerrain(void)
|
||||
{
|
||||
if(!mapmgr)
|
||||
{
|
||||
logerror("SceneWorld: MapMgr not present, cant create World GUI. Switching back GUI to idle.");
|
||||
gui->SetSceneState(SCENESTATE_GUISTART);
|
||||
return;
|
||||
}
|
||||
|
||||
mapsize = 8 * 16 * 3; // 9-1 height floats in 16 chunks per tile per axis in 3 MapTiles
|
||||
tilesize = UNITSIZE;
|
||||
meshsize = (s32)CHUNKSIZE*3;
|
||||
vector3df terrainPos(0.0f, 0.0f, 0.0f); // TODO: use PseuWoW's world coords here?
|
||||
|
||||
camera->setPosition(core::vector3df(mapsize*tilesize/2, 0, mapsize*tilesize/2) + terrainPos);
|
||||
|
||||
terrain = new ShTlTerrainSceneNode(smgr,mapsize,mapsize,tilesize,meshsize);
|
||||
terrain->drop();
|
||||
terrain->follow(camera->getNode());
|
||||
terrain->setMaterialTexture(0, driver->getTexture("data/misc/dirt_test.jpg"));
|
||||
terrain->setMaterialFlag(video::EMF_LIGHTING, true);
|
||||
terrain->setMaterialFlag(video::EMF_FOG_ENABLE, true);
|
||||
terrain->setPosition(terrainPos);
|
||||
|
||||
}
|
||||
|
||||
|
||||
void SceneWorld::UpdateTerrain(void)
|
||||
{
|
||||
// check if we changed the maptile
|
||||
if(map_gridX == mapmgr->GetGridX() && map_gridY == mapmgr->GetGridY())
|
||||
return; // grid not changed, not necessary to update tile data
|
||||
|
||||
// ... if changed, do necessary stuff...
|
||||
map_gridX = mapmgr->GetGridX();
|
||||
map_gridY = mapmgr->GetGridY();
|
||||
|
||||
// TODO: better to do this with some ZThread Condition or FastMutex, but dont know how to. help plz! [FG]
|
||||
if(!mapmgr->Loaded())
|
||||
{
|
||||
logdebug("SceneWorld: Waiting until maps are loaded...");
|
||||
while(!mapmgr->Loaded())
|
||||
device->sleep(1);
|
||||
}
|
||||
|
||||
// TODO: as soon as WMO-only worlds are implemented, remove this!!
|
||||
if(!mapmgr->GetLoadedMapsCount())
|
||||
{
|
||||
logerror("SceneWorld: Error: No maps loaded, not able to draw any terrain. Switching back GUI to idle.");
|
||||
logerror("SceneWorld: Hint: Be sure you are not in an WMO-only world (e.g. human capital city or most instances)!");
|
||||
gui->SetSceneState(SCENESTATE_GUISTART);
|
||||
return;
|
||||
}
|
||||
|
||||
// something is not good here. we have terrain, but the chunks are read incorrectly.
|
||||
// need to find out where which formula is wrong
|
||||
// the current terrain renderer code is just a test to see if ADT files are read correctly.
|
||||
// EDIT: it seems to display fine now, but i am still not sure if the way it is done is correct...
|
||||
mutex.acquire(); // prevent other threads from deleting the maptile
|
||||
logdebug("SceneWorld: Displaying MapTiles near grids x:%u y:%u",mapmgr->GetGridX(),mapmgr->GetGridY());
|
||||
for(s32 tiley = 0; tiley < 3; tiley++)
|
||||
{
|
||||
for(s32 tilex = 0; tilex < 3; tilex++)
|
||||
{
|
||||
MapTile *maptile = mapmgr->GetNearTile(tilex - 1, tiley - 1);
|
||||
if(maptile)
|
||||
{
|
||||
// apply map height data
|
||||
for(uint32 chy = 0; chy < 16; chy++)
|
||||
for(uint32 chx = 0; chx < 16; chx++)
|
||||
{
|
||||
MapChunk *chunk = maptile->GetChunk(chx, chy);
|
||||
for(uint32 hy = 0; hy < 8; hy++)
|
||||
{
|
||||
for(uint32 hx = 0; hx < 8; hx++)
|
||||
{
|
||||
f32 h = chunk->hmap_rough[hy * 9 + hx] + chunk->baseheight; // not sure if hx and hy are used correctly here
|
||||
u32 terrainx = (128 * tilex) + (8 * chx) + hx;
|
||||
u32 terrainy = (128 * tiley) + (8 * chy) + hy;
|
||||
terrain->setHeight(terrainy, terrainx, h);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logerror("SceneWorld: MapTile not loaded, can't apply heightmap!");
|
||||
}
|
||||
}
|
||||
}
|
||||
mutex.release();
|
||||
|
||||
// find out highest/lowest spot
|
||||
f32 highest = terrain->getHeight(0,0);
|
||||
f32 lowest = terrain->getHeight(0,0);
|
||||
f32 curheight;
|
||||
for(s32 j=0; j<terrain->getSize().Height+1; j++)
|
||||
for(s32 i=0; i<terrain->getSize().Width+1; i++)
|
||||
{
|
||||
curheight = terrain->getHeight(i,j);
|
||||
highest = max(highest,curheight);
|
||||
lowest = min(lowest,curheight);
|
||||
}
|
||||
// f32 heightdiff = highest - lowest;
|
||||
|
||||
// randomize terrain color depending on height
|
||||
for(s32 j=0; j<terrain->getSize().Height+1; j++)
|
||||
for(s32 i=0; i<terrain->getSize().Width+1; i++)
|
||||
{
|
||||
curheight = terrain->getHeight(i,j);
|
||||
u32 g = (u32)(curheight / highest * 120) + 125;
|
||||
u32 r = (u32)(curheight / highest * 120) + 60;
|
||||
u32 b = (u32)(curheight / highest * 120) + 60;
|
||||
|
||||
terrain->setColor(i,j, video::SColor(255,r,g,b));
|
||||
}
|
||||
|
||||
logdebug("SceneWorld: Smoothing terrain normals...");
|
||||
terrain->smoothNormals();
|
||||
}
|
||||
|
||||
WorldPosition SceneWorld::GetWorldPosition(void)
|
||||
{
|
||||
// TODO: later do not use CAMERA, but CHARACTER position, as soon as camera is changed from 1st to 3rd person view
|
||||
// and floating around character in the middle
|
||||
vector3df cam = camera->getPosition();
|
||||
// TODO: need to correct camera values, the coords irrlicht returns are not suitable
|
||||
|
||||
// get the current maptile and use the coords of the top-left corner as relative positions
|
||||
MapTile *tile = mapmgr->GetCurrentTile();
|
||||
if(!tile)
|
||||
{
|
||||
logerror("SceneWorld::GetWorldPosition failed, MapTile not loaded!");
|
||||
return WorldPosition();
|
||||
}
|
||||
|
||||
float mapx = tile->GetBaseX();
|
||||
float mapy = tile->GetBaseY();
|
||||
|
||||
// the following formulas are NOT correct, just estimated. in most places they will differ from real expected values a lot!
|
||||
float relx = cam.X * COORD_SCALE_VALUE_X + CHUNKSIZE;
|
||||
float rely = cam.Z * COORD_SCALE_VALUE_Y + CHUNKSIZE;
|
||||
|
||||
float o = DEG_TO_RAD(camera->getHeading()) + ((M_PI*3.0f)/2.0f);
|
||||
return WorldPosition(mapx - relx, mapy - rely, cam.Y, RAD_FIX(o) );
|
||||
}
|
||||
|
||||
void SceneWorld::SetWorldPosition(WorldPosition wp)
|
||||
{
|
||||
UpdateTerrain();
|
||||
vector3df cam;
|
||||
dimension2d<s32> tsize = terrain->getSize();
|
||||
MapTile *tile = mapmgr->GetTile(MapMgr::GetGridCoord(wp.x), MapMgr::GetGridCoord(wp.y));
|
||||
ASSERT(tile == mapmgr->GetCurrentTile()); // for debugging; we should already be located on the new tile
|
||||
if(!tile)
|
||||
{
|
||||
logerror("SceneWorld::SetWorldPosition(): MapTile not loaded!");
|
||||
return;
|
||||
}
|
||||
cam.X = tile->GetBaseX() - wp.x + (tsize.Width * UNITSIZE);
|
||||
cam.Z = tile->GetBaseX() - wp.y + (tsize.Height * UNITSIZE);
|
||||
float heading = RAD_TO_DEG(((M_PI*3.0f)/2.0f) - wp.o);
|
||||
float heading_diff = camera->getHeading() - heading;
|
||||
logdebug("Setting camera to x: %3f y: %3f z:%3f head: %3f", cam.X, cam.Y, cam.Z, heading);
|
||||
camera->turnLeft(heading_diff);
|
||||
|
||||
// TODO:
|
||||
// - correct the above formulas
|
||||
// - find out terrain height where the camera should be set
|
||||
// - set camera to correct position
|
||||
// - correct camera turning
|
||||
//camera->setPosition(cam);
|
||||
//camera->turnRight(heading_diff);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,317 +1,317 @@
|
||||
/*-----------------------------------------------------------------------------*
|
||||
| headerfile ShTlTerrainSceneNode.h |
|
||||
| |
|
||||
| version 2.00 |
|
||||
| date: (29.04.2007) |
|
||||
| |
|
||||
| author: Michal Švantner |
|
||||
| |
|
||||
| Shifting Tiled Terrain Scene Node |
|
||||
| |
|
||||
| This node can render quit large terrain consisting of tiles by storing data |
|
||||
| of individual tiles in array and rendering only part of terrain around |
|
||||
| defined position and in defined size. This can be position of another scene |
|
||||
| node defined by user and terrain node can be set to render around it |
|
||||
| automaticaly. |
|
||||
| It is done by creating mesh of given size which then glide over invisible |
|
||||
| data skelet like a peace of soft cloth, updating its atributes from data |
|
||||
| arrays each time it shifts to a new position. |
|
||||
| |
|
||||
| Diferent atributes of individual tiles can be adjusted, most of them on run |
|
||||
| time. Namely texture coordinates, position of tile vertices, normals and |
|
||||
| color. |
|
||||
| |
|
||||
| Scene node use 2 texture layers. |
|
||||
| Firsth texture is standard texture which gives detail to terrain close by |
|
||||
| and can by assigned to individual tiles by setting their UV coordinates. |
|
||||
| User have complete freedom as howe to apply this texture to tiles. Texture |
|
||||
| can for example consist of seweral subtextures and each can be set to |
|
||||
| diferent tiles using UV coordinates. |
|
||||
| |
|
||||
| Second texture is created by terrain node internaly and is used to render |
|
||||
| color of individual tiles. This adds some variability to terrain at distance.|
|
||||
| Both textures are blended together using EMT_DETAIL_MAP material type. |
|
||||
| |
|
||||
| Normaly textures should be set in oposite order but there are some bugs with |
|
||||
| updating texture under OpenGL so until it gets solved I have to stick with |
|
||||
| detailmap applyed as firsth texture layer. Not perfect but working. |
|
||||
| |
|
||||
| This scene node also provide user with functions to get height at given |
|
||||
| coordinates and test 3d line for collision useful for line of sight or bullet|
|
||||
| collision testing. |
|
||||
| |
|
||||
| Rendered mesh is split in to seweral sectors which are culled individualy. |
|
||||
| This exclude around 60% of polygoons from rendering. |
|
||||
| |
|
||||
| Writen for Irrlicht engine version 1.3 |
|
||||
*-----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef SHTLTERRAINSCENENODE_H
|
||||
#define SHTLTERRAINSCENENODE_H
|
||||
|
||||
#include "irrlicht/irrlicht.h"
|
||||
using namespace irr;
|
||||
|
||||
#include "TlTMesh.h"
|
||||
|
||||
// Shifting Tiled Terrain Scene Node class
|
||||
class ShTlTerrainSceneNode : public scene::ISceneNode
|
||||
{
|
||||
// dimensions of whole terrain
|
||||
core::dimension2d<s32> Size;
|
||||
|
||||
// bounding box of terrain mesh
|
||||
core::aabbox3d<f32> BoundingBox;
|
||||
|
||||
// terrain vertex data
|
||||
array2d<TlTData> Data;
|
||||
|
||||
// terrain tile UV data for 1th texture layer
|
||||
array2d<TlTCoords> UVdata;
|
||||
|
||||
// terrain mesh sectors
|
||||
array2d<TlTSector> Sector;
|
||||
|
||||
// array of pointers to vertices of tiles
|
||||
array2d<TlTTile> Tile;
|
||||
|
||||
// size of vissible terrain mesh
|
||||
core::dimension2d<s32> MeshSize;
|
||||
|
||||
// position of vissible terrain mesh relative to whole terrain in tiles
|
||||
core::vector2d<s32> MeshPosition;
|
||||
|
||||
// material
|
||||
core::array<video::SMaterial> Material;
|
||||
|
||||
// size of terrain tiles
|
||||
f32 TileSize;
|
||||
|
||||
// node terrain mesh should be rendered around
|
||||
scene::ISceneNode* Fnode;
|
||||
|
||||
// color texture set as 2nd texture layer
|
||||
video::ITexture* CTexture;
|
||||
|
||||
// number of sectors rendered last frame
|
||||
u32 SectorsRendered;
|
||||
|
||||
// howe many tiles should be skiped before terrain mesh gets updated
|
||||
s32 ShStep;
|
||||
|
||||
// return true if sector is on screen
|
||||
virtual bool isSectorOnScreen(TlTSector* sctr);
|
||||
|
||||
// update vertices of sector
|
||||
virtual void updateVertices(TlTSector §or);
|
||||
|
||||
// update 2nd texture layer
|
||||
virtual void updateTexture(u32* p, TlTSector §or);
|
||||
|
||||
// return true if 3d line colide with tile
|
||||
virtual bool getIntersectionWithTile(s32 w, s32 h, core::line3d<f32> line,
|
||||
core::vector3df &outIntersection);
|
||||
|
||||
public:
|
||||
|
||||
// constructor
|
||||
// \param smgr -pointer to scene manager
|
||||
// \param width - width of terrain in tiles
|
||||
// \param height - heighth of terrain in tiles
|
||||
// \param tilesize -size of tile
|
||||
// \param rendersize -size of rendered terrain mesh in tiles
|
||||
// \param parent -parent scene node
|
||||
// \param id -ID number
|
||||
ShTlTerrainSceneNode(scene::ISceneManager* pSceneManager, s32 width, s32 height,
|
||||
f32 tilesize, s32 rendersize, scene::ISceneNode* parent = 0, s32 id = -1);
|
||||
|
||||
// destructor
|
||||
~ShTlTerrainSceneNode();
|
||||
|
||||
// frame
|
||||
virtual void OnRegisterSceneNode();
|
||||
|
||||
// renders terrain
|
||||
virtual void render();
|
||||
|
||||
// returns the axis aligned bounding box of terrain
|
||||
virtual const core::aabbox3d<f32>& getBoundingBox() const;
|
||||
|
||||
// recalculate terrain bounding box
|
||||
virtual void recalculateBoundingBox();
|
||||
|
||||
// returns amount of materials used by terrain
|
||||
// this terrain uses only one material
|
||||
virtual u32 getMaterialCount();
|
||||
|
||||
// returns the material of terrain based on the zero based index
|
||||
// \param i -index of material to return
|
||||
virtual video::SMaterial& getMaterial(u32 i);
|
||||
|
||||
// return number of tiles to skip before terrain mesh gets updated
|
||||
virtual s32 getStep();
|
||||
|
||||
// set number of tiles to skip before terrain mesh gets updated, default is 1
|
||||
// updating slows down rendering and seting step higher will cause terrain to update less ofthen
|
||||
// \param newstep -amount of tiles to skip before updating
|
||||
virtual void setStep(u32 newstep);
|
||||
|
||||
// return dimensions of whole terrain in tiles
|
||||
virtual core::dimension2d<s32> getSize();
|
||||
|
||||
// return dimension of terrain tile
|
||||
virtual f32 getTileSize();
|
||||
|
||||
// set new dimensions of terrain tile
|
||||
// \param newsize -new size of tile
|
||||
virtual void setTileSize(f32 newsize);
|
||||
|
||||
// returns dimension of rendered mesh in tiles
|
||||
virtual core::dimension2d<s32> getRenderedSize();
|
||||
|
||||
// return number of sectors into which terrain mesh is divided
|
||||
virtual u32 getSectorCount();
|
||||
|
||||
// returns sectors rendered last frame
|
||||
virtual u32 getSectorsRendered();
|
||||
|
||||
// return relative height of terrain spot at terrain coordinates
|
||||
// \param w -width coordinate of spot in tiles
|
||||
// \param h -height coordinate of spot in tiles
|
||||
virtual f32 getHeight(u32 w, u32 h);
|
||||
|
||||
// return height of terrain at any position
|
||||
// \param pos -3d coordinates at which to get height of terrain
|
||||
virtual f32 getHeight(core::vector3df pos);
|
||||
|
||||
// set relative height of terrain spot at terrain coordinates
|
||||
// \param w -width coordinate of spot in tiles
|
||||
// \param h -height coordinate of spot in tiles
|
||||
// \param newheight -new height of spot
|
||||
virtual void setHeight(u32 w, u32 h, f32 newheight);
|
||||
|
||||
// return normal of terrain at terrain coordinates
|
||||
// \param w -width coordinate of spot in tiles
|
||||
// \param h -height coordinate of spot in tiles
|
||||
virtual core::vector3df getNormal(u32 w, u32 h);
|
||||
|
||||
// set normal of terrain at terrain coordinates
|
||||
// \param w -width coordinate of spot in tiles
|
||||
// \param h -height coordinate of spot in tiles
|
||||
// \param newnormal -new normal vector terrain spot
|
||||
virtual void setNormal(s32 w, s32 h, core::vector3df newnormal);
|
||||
|
||||
// recalculate normal at terrain coordinates
|
||||
// \param w -width coordinate of spot in tiles
|
||||
// \param h -height coordinate of spot in tiles
|
||||
virtual void recalculateNormal(s32 w, s32 h);
|
||||
|
||||
// recalculare normals of whole terrain making it look smooth under light
|
||||
virtual void smoothNormals();
|
||||
|
||||
// get texture coordinates of tile corner
|
||||
// \param w -width coordinate of tile
|
||||
// \param h -height coordinate of tile
|
||||
// \param corner -tile corner, can be LOWER_LEFT, UPPER_LEFT, UPPER_RIGHT, LOWER_RIGHT
|
||||
virtual core::vector2d<f32> getTileUV(u32 w, u32 h, TILE_VERTEX corner);
|
||||
|
||||
// set texture coordinates of tile
|
||||
// \param w -width coordinate of tile
|
||||
// \param h -height coordinate of tile
|
||||
// \param UVLowerLeft -UV coordinates of lower left corner
|
||||
// \param UVUpperLeft -UV coordinates of upper left corner
|
||||
// \param UVUpperRight -UV coordinates of upper right corner
|
||||
// \param UVLowerRight -UV coordinates of lower right corner
|
||||
virtual void setTileUV(u32 w, u32 h, core::vector2d<f32> UVLowerLeft,
|
||||
core::vector2d<f32> UVUpperLeft, core::vector2d<f32> UVUpperRight,
|
||||
core::vector2d<f32> UVLowerRight);
|
||||
|
||||
// stretch texture over whole terrain
|
||||
// \param scale -scale of the texture stretched, 2,2 would stretch it twice
|
||||
virtual void stretchTexture(core::vector2d<f32> scale = core::vector2d<f32>(1,1));
|
||||
|
||||
// stretch texture over every tile individualy
|
||||
// \param scale -scale of the texture stretched, 0.5,0.5 would display half of texture over each tile
|
||||
virtual void stretchTextureOverTile(core::vector2d<f32> scale = core::vector2d<f32>(1,1));
|
||||
|
||||
// rotate texture of tile 90 degrees
|
||||
// \param w -width coordinate of tile
|
||||
// \param h -height coordinate of tile
|
||||
virtual void rotateTileTexture90(u32 w, u32 h);
|
||||
|
||||
// rotate texture of tile 180 degrees
|
||||
// \param w -width coordinate of tile
|
||||
// \param h -height coordinate of tile
|
||||
virtual void rotateTileTexture180(u32 w, u32 h);
|
||||
|
||||
// rotate texture of tile 270 degrees
|
||||
// \param w -width coordinate of tile
|
||||
// \param h -height coordinate of tile
|
||||
virtual void rotateTileTexture270(u32 w, u32 h);
|
||||
|
||||
// flip (mirror) texture of tile horizontaly
|
||||
// \param w -width coordinate of tile
|
||||
// \param h -height coordinate of tile
|
||||
virtual void flipTileTextureHorizontal(u32 w, u32 h);
|
||||
|
||||
// flip (mirror) texture of tile verticaly
|
||||
// \param w -width coordinate of tile
|
||||
// \param h -height coordinate of tile
|
||||
virtual void flipTileTextureVertical(u32 w, u32 h);
|
||||
|
||||
// get color of tile at terrain coordinates
|
||||
// \param w -width coordinate of tile
|
||||
// \param h -height coordinate of tile
|
||||
virtual video::SColor getColor(u32 w, u32 h);
|
||||
|
||||
// set color of tile at terrain coordinates
|
||||
// \param w -width coordinate of tile
|
||||
// \param h -height coordinate of tile
|
||||
// \param newcolor -new color of tile
|
||||
virtual void setColor(u32 w, u32 h, video::SColor newcolor);
|
||||
|
||||
// set rendered mesh position relative to terrain
|
||||
// note that origin of mesh is in its lower left corner
|
||||
// \param pos -new position of mesh relative to terrain in tiles
|
||||
virtual void setMeshPosition(core::vector2d<s32> pos);
|
||||
|
||||
// center rendered mesh at 3d coordinates
|
||||
// \param pos -new position mesh should be rendered around
|
||||
virtual void centerAt(core::vector3d<f32> pos);
|
||||
|
||||
// update rendered mesh
|
||||
virtual void update();
|
||||
|
||||
// set scene node terrain mesh should be automaticly rendered arround
|
||||
// can be camera or player node for example
|
||||
// \param node -scene node to automaticaly follow
|
||||
virtual void follow(scene::ISceneNode* node);
|
||||
|
||||
// cancel pervious function
|
||||
// stop following scene node if any
|
||||
virtual void stop();
|
||||
|
||||
// test if 3d line colide with terrain
|
||||
// returns true if yes, false if not and store intersection in "outIntersection" vector
|
||||
// \param line -3d line
|
||||
// \param outIntersection -vector to store intersection point if any
|
||||
virtual bool getIntersectionWithLine( core::line3d<f32> line, core::vector3df &outIntersection);
|
||||
|
||||
// load height data from texture
|
||||
// parameters allow to specify place where to load data, which makes possible
|
||||
// to load terrain from seweral smaller textures
|
||||
// \param filename -filename of texture
|
||||
// \param scale -scale to apply at height data, if you want white color to be height of 10.5 set scale to 10.5
|
||||
// \param w -width coordinate of tile were to start loading
|
||||
// \param h -height coordinate of tile were to start loading
|
||||
virtual void loadHeightMap(const c8 *filename, f32 scale, u32 w = 0, u32 h = 0);
|
||||
|
||||
// load color data from texture
|
||||
// parameters allow to specify place where to load data, which makes possible
|
||||
// to load terrain from seweral smaller textures
|
||||
// \param filename -filename of texture
|
||||
// \param w -width coordinate of tile were to start loading
|
||||
// \param h -height coordinate of tile were to start loading
|
||||
virtual void loadColorMap(const c8 *filename, u32 w = 0, u32 h = 0);
|
||||
};
|
||||
#endif
|
||||
/*-----------------------------------------------------------------------------*
|
||||
| headerfile ShTlTerrainSceneNode.h |
|
||||
| |
|
||||
| version 2.00 |
|
||||
| date: (29.04.2007) |
|
||||
| |
|
||||
| author: Michal Švantner |
|
||||
| |
|
||||
| Shifting Tiled Terrain Scene Node |
|
||||
| |
|
||||
| This node can render quit large terrain consisting of tiles by storing data |
|
||||
| of individual tiles in array and rendering only part of terrain around |
|
||||
| defined position and in defined size. This can be position of another scene |
|
||||
| node defined by user and terrain node can be set to render around it |
|
||||
| automaticaly. |
|
||||
| It is done by creating mesh of given size which then glide over invisible |
|
||||
| data skelet like a peace of soft cloth, updating its atributes from data |
|
||||
| arrays each time it shifts to a new position. |
|
||||
| |
|
||||
| Diferent atributes of individual tiles can be adjusted, most of them on run |
|
||||
| time. Namely texture coordinates, position of tile vertices, normals and |
|
||||
| color. |
|
||||
| |
|
||||
| Scene node use 2 texture layers. |
|
||||
| Firsth texture is standard texture which gives detail to terrain close by |
|
||||
| and can by assigned to individual tiles by setting their UV coordinates. |
|
||||
| User have complete freedom as howe to apply this texture to tiles. Texture |
|
||||
| can for example consist of seweral subtextures and each can be set to |
|
||||
| diferent tiles using UV coordinates. |
|
||||
| |
|
||||
| Second texture is created by terrain node internaly and is used to render |
|
||||
| color of individual tiles. This adds some variability to terrain at distance.|
|
||||
| Both textures are blended together using EMT_DETAIL_MAP material type. |
|
||||
| |
|
||||
| Normaly textures should be set in oposite order but there are some bugs with |
|
||||
| updating texture under OpenGL so until it gets solved I have to stick with |
|
||||
| detailmap applyed as firsth texture layer. Not perfect but working. |
|
||||
| |
|
||||
| This scene node also provide user with functions to get height at given |
|
||||
| coordinates and test 3d line for collision useful for line of sight or bullet|
|
||||
| collision testing. |
|
||||
| |
|
||||
| Rendered mesh is split in to seweral sectors which are culled individualy. |
|
||||
| This exclude around 60% of polygoons from rendering. |
|
||||
| |
|
||||
| Writen for Irrlicht engine version 1.3 |
|
||||
*-----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef SHTLTERRAINSCENENODE_H
|
||||
#define SHTLTERRAINSCENENODE_H
|
||||
|
||||
#include "irrlicht/irrlicht.h"
|
||||
using namespace irr;
|
||||
|
||||
#include "TlTMesh.h"
|
||||
|
||||
// Shifting Tiled Terrain Scene Node class
|
||||
class ShTlTerrainSceneNode : public scene::ISceneNode
|
||||
{
|
||||
// dimensions of whole terrain
|
||||
core::dimension2d<s32> Size;
|
||||
|
||||
// bounding box of terrain mesh
|
||||
core::aabbox3d<f32> BoundingBox;
|
||||
|
||||
// terrain vertex data
|
||||
array2d<TlTData> Data;
|
||||
|
||||
// terrain tile UV data for 1th texture layer
|
||||
array2d<TlTCoords> UVdata;
|
||||
|
||||
// terrain mesh sectors
|
||||
array2d<TlTSector> Sector;
|
||||
|
||||
// array of pointers to vertices of tiles
|
||||
array2d<TlTTile> Tile;
|
||||
|
||||
// size of vissible terrain mesh
|
||||
core::dimension2d<s32> MeshSize;
|
||||
|
||||
// position of vissible terrain mesh relative to whole terrain in tiles
|
||||
core::vector2d<s32> MeshPosition;
|
||||
|
||||
// material
|
||||
core::array<video::SMaterial> Material;
|
||||
|
||||
// size of terrain tiles
|
||||
f32 TileSize;
|
||||
|
||||
// node terrain mesh should be rendered around
|
||||
scene::ISceneNode* Fnode;
|
||||
|
||||
// color texture set as 2nd texture layer
|
||||
video::ITexture* CTexture;
|
||||
|
||||
// number of sectors rendered last frame
|
||||
u32 SectorsRendered;
|
||||
|
||||
// howe many tiles should be skiped before terrain mesh gets updated
|
||||
s32 ShStep;
|
||||
|
||||
// return true if sector is on screen
|
||||
virtual bool isSectorOnScreen(TlTSector* sctr);
|
||||
|
||||
// update vertices of sector
|
||||
virtual void updateVertices(TlTSector §or);
|
||||
|
||||
// update 2nd texture layer
|
||||
virtual void updateTexture(u32* p, TlTSector §or);
|
||||
|
||||
// return true if 3d line colide with tile
|
||||
virtual bool getIntersectionWithTile(s32 w, s32 h, core::line3d<f32> line,
|
||||
core::vector3df &outIntersection);
|
||||
|
||||
public:
|
||||
|
||||
// constructor
|
||||
// \param smgr -pointer to scene manager
|
||||
// \param width - width of terrain in tiles
|
||||
// \param height - heighth of terrain in tiles
|
||||
// \param tilesize -size of tile
|
||||
// \param rendersize -size of rendered terrain mesh in tiles
|
||||
// \param parent -parent scene node
|
||||
// \param id -ID number
|
||||
ShTlTerrainSceneNode(scene::ISceneManager* pSceneManager, s32 width, s32 height,
|
||||
f32 tilesize, s32 rendersize, scene::ISceneNode* parent = 0, s32 id = -1);
|
||||
|
||||
// destructor
|
||||
~ShTlTerrainSceneNode();
|
||||
|
||||
// frame
|
||||
virtual void OnRegisterSceneNode();
|
||||
|
||||
// renders terrain
|
||||
virtual void render();
|
||||
|
||||
// returns the axis aligned bounding box of terrain
|
||||
virtual const core::aabbox3d<f32>& getBoundingBox() const;
|
||||
|
||||
// recalculate terrain bounding box
|
||||
virtual void recalculateBoundingBox();
|
||||
|
||||
// returns amount of materials used by terrain
|
||||
// this terrain uses only one material
|
||||
virtual u32 getMaterialCount();
|
||||
|
||||
// returns the material of terrain based on the zero based index
|
||||
// \param i -index of material to return
|
||||
virtual video::SMaterial& getMaterial(u32 i);
|
||||
|
||||
// return number of tiles to skip before terrain mesh gets updated
|
||||
virtual s32 getStep();
|
||||
|
||||
// set number of tiles to skip before terrain mesh gets updated, default is 1
|
||||
// updating slows down rendering and seting step higher will cause terrain to update less ofthen
|
||||
// \param newstep -amount of tiles to skip before updating
|
||||
virtual void setStep(u32 newstep);
|
||||
|
||||
// return dimensions of whole terrain in tiles
|
||||
virtual core::dimension2d<s32> getSize();
|
||||
|
||||
// return dimension of terrain tile
|
||||
virtual f32 getTileSize();
|
||||
|
||||
// set new dimensions of terrain tile
|
||||
// \param newsize -new size of tile
|
||||
virtual void setTileSize(f32 newsize);
|
||||
|
||||
// returns dimension of rendered mesh in tiles
|
||||
virtual core::dimension2d<s32> getRenderedSize();
|
||||
|
||||
// return number of sectors into which terrain mesh is divided
|
||||
virtual u32 getSectorCount();
|
||||
|
||||
// returns sectors rendered last frame
|
||||
virtual u32 getSectorsRendered();
|
||||
|
||||
// return relative height of terrain spot at terrain coordinates
|
||||
// \param w -width coordinate of spot in tiles
|
||||
// \param h -height coordinate of spot in tiles
|
||||
virtual f32 getHeight(u32 w, u32 h);
|
||||
|
||||
// return height of terrain at any position
|
||||
// \param pos -3d coordinates at which to get height of terrain
|
||||
virtual f32 getHeight(core::vector3df pos);
|
||||
|
||||
// set relative height of terrain spot at terrain coordinates
|
||||
// \param w -width coordinate of spot in tiles
|
||||
// \param h -height coordinate of spot in tiles
|
||||
// \param newheight -new height of spot
|
||||
virtual void setHeight(u32 w, u32 h, f32 newheight);
|
||||
|
||||
// return normal of terrain at terrain coordinates
|
||||
// \param w -width coordinate of spot in tiles
|
||||
// \param h -height coordinate of spot in tiles
|
||||
virtual core::vector3df getNormal(u32 w, u32 h);
|
||||
|
||||
// set normal of terrain at terrain coordinates
|
||||
// \param w -width coordinate of spot in tiles
|
||||
// \param h -height coordinate of spot in tiles
|
||||
// \param newnormal -new normal vector terrain spot
|
||||
virtual void setNormal(s32 w, s32 h, core::vector3df newnormal);
|
||||
|
||||
// recalculate normal at terrain coordinates
|
||||
// \param w -width coordinate of spot in tiles
|
||||
// \param h -height coordinate of spot in tiles
|
||||
virtual void recalculateNormal(s32 w, s32 h);
|
||||
|
||||
// recalculare normals of whole terrain making it look smooth under light
|
||||
virtual void smoothNormals();
|
||||
|
||||
// get texture coordinates of tile corner
|
||||
// \param w -width coordinate of tile
|
||||
// \param h -height coordinate of tile
|
||||
// \param corner -tile corner, can be LOWER_LEFT, UPPER_LEFT, UPPER_RIGHT, LOWER_RIGHT
|
||||
virtual core::vector2d<f32> getTileUV(u32 w, u32 h, TILE_VERTEX corner);
|
||||
|
||||
// set texture coordinates of tile
|
||||
// \param w -width coordinate of tile
|
||||
// \param h -height coordinate of tile
|
||||
// \param UVLowerLeft -UV coordinates of lower left corner
|
||||
// \param UVUpperLeft -UV coordinates of upper left corner
|
||||
// \param UVUpperRight -UV coordinates of upper right corner
|
||||
// \param UVLowerRight -UV coordinates of lower right corner
|
||||
virtual void setTileUV(u32 w, u32 h, core::vector2d<f32> UVLowerLeft,
|
||||
core::vector2d<f32> UVUpperLeft, core::vector2d<f32> UVUpperRight,
|
||||
core::vector2d<f32> UVLowerRight);
|
||||
|
||||
// stretch texture over whole terrain
|
||||
// \param scale -scale of the texture stretched, 2,2 would stretch it twice
|
||||
virtual void stretchTexture(core::vector2d<f32> scale = core::vector2d<f32>(1,1));
|
||||
|
||||
// stretch texture over every tile individualy
|
||||
// \param scale -scale of the texture stretched, 0.5,0.5 would display half of texture over each tile
|
||||
virtual void stretchTextureOverTile(core::vector2d<f32> scale = core::vector2d<f32>(1,1));
|
||||
|
||||
// rotate texture of tile 90 degrees
|
||||
// \param w -width coordinate of tile
|
||||
// \param h -height coordinate of tile
|
||||
virtual void rotateTileTexture90(u32 w, u32 h);
|
||||
|
||||
// rotate texture of tile 180 degrees
|
||||
// \param w -width coordinate of tile
|
||||
// \param h -height coordinate of tile
|
||||
virtual void rotateTileTexture180(u32 w, u32 h);
|
||||
|
||||
// rotate texture of tile 270 degrees
|
||||
// \param w -width coordinate of tile
|
||||
// \param h -height coordinate of tile
|
||||
virtual void rotateTileTexture270(u32 w, u32 h);
|
||||
|
||||
// flip (mirror) texture of tile horizontaly
|
||||
// \param w -width coordinate of tile
|
||||
// \param h -height coordinate of tile
|
||||
virtual void flipTileTextureHorizontal(u32 w, u32 h);
|
||||
|
||||
// flip (mirror) texture of tile verticaly
|
||||
// \param w -width coordinate of tile
|
||||
// \param h -height coordinate of tile
|
||||
virtual void flipTileTextureVertical(u32 w, u32 h);
|
||||
|
||||
// get color of tile at terrain coordinates
|
||||
// \param w -width coordinate of tile
|
||||
// \param h -height coordinate of tile
|
||||
virtual video::SColor getColor(u32 w, u32 h);
|
||||
|
||||
// set color of tile at terrain coordinates
|
||||
// \param w -width coordinate of tile
|
||||
// \param h -height coordinate of tile
|
||||
// \param newcolor -new color of tile
|
||||
virtual void setColor(u32 w, u32 h, video::SColor newcolor);
|
||||
|
||||
// set rendered mesh position relative to terrain
|
||||
// note that origin of mesh is in its lower left corner
|
||||
// \param pos -new position of mesh relative to terrain in tiles
|
||||
virtual void setMeshPosition(core::vector2d<s32> pos);
|
||||
|
||||
// center rendered mesh at 3d coordinates
|
||||
// \param pos -new position mesh should be rendered around
|
||||
virtual void centerAt(core::vector3d<f32> pos);
|
||||
|
||||
// update rendered mesh
|
||||
virtual void update();
|
||||
|
||||
// set scene node terrain mesh should be automaticly rendered arround
|
||||
// can be camera or player node for example
|
||||
// \param node -scene node to automaticaly follow
|
||||
virtual void follow(scene::ISceneNode* node);
|
||||
|
||||
// cancel pervious function
|
||||
// stop following scene node if any
|
||||
virtual void stop();
|
||||
|
||||
// test if 3d line colide with terrain
|
||||
// returns true if yes, false if not and store intersection in "outIntersection" vector
|
||||
// \param line -3d line
|
||||
// \param outIntersection -vector to store intersection point if any
|
||||
virtual bool getIntersectionWithLine( core::line3d<f32> line, core::vector3df &outIntersection);
|
||||
|
||||
// load height data from texture
|
||||
// parameters allow to specify place where to load data, which makes possible
|
||||
// to load terrain from seweral smaller textures
|
||||
// \param filename -filename of texture
|
||||
// \param scale -scale to apply at height data, if you want white color to be height of 10.5 set scale to 10.5
|
||||
// \param w -width coordinate of tile were to start loading
|
||||
// \param h -height coordinate of tile were to start loading
|
||||
virtual void loadHeightMap(const c8 *filename, f32 scale, u32 w = 0, u32 h = 0);
|
||||
|
||||
// load color data from texture
|
||||
// parameters allow to specify place where to load data, which makes possible
|
||||
// to load terrain from seweral smaller textures
|
||||
// \param filename -filename of texture
|
||||
// \param w -width coordinate of tile were to start loading
|
||||
// \param h -height coordinate of tile were to start loading
|
||||
virtual void loadColorMap(const c8 *filename, u32 w = 0, u32 h = 0);
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -1,148 +1,148 @@
|
||||
/*-----------------------------------------------------------------------------*
|
||||
| headerfile TLTMesh.h |
|
||||
| |
|
||||
| version 1.00 |
|
||||
| date: (17.04.2007) |
|
||||
| |
|
||||
| author: Michal Švantner |
|
||||
| |
|
||||
| Some structures used for Tiled Terrain |
|
||||
| Writen for Irrlicht engine version 1.3 |
|
||||
*-----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef TLTMESH_H
|
||||
#define TLTMESH_H
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
using namespace irr;
|
||||
|
||||
|
||||
|
||||
// dynamic 2d array
|
||||
template <class T> class array2d
|
||||
{
|
||||
T** data;
|
||||
s32 w, h;
|
||||
|
||||
public:
|
||||
array2d() : w(0), h(0) {}
|
||||
|
||||
array2d(int width, int height) : w(width), h(height)
|
||||
{
|
||||
data = new T*[w];
|
||||
for(int i=0; i<w; i++) data[i] = new T[h];
|
||||
}
|
||||
|
||||
virtual void reset(int width, int height)
|
||||
{
|
||||
if(w && h)
|
||||
{
|
||||
for(int i=0; i<w; i++) delete data[i];
|
||||
delete [] data;
|
||||
}
|
||||
|
||||
if(width && height)
|
||||
{
|
||||
w = width;
|
||||
h = height;
|
||||
|
||||
data = new T*[w];
|
||||
for(int i=0; i<w; i++) data[i] = new T[h];
|
||||
}
|
||||
else
|
||||
{
|
||||
w = 0;
|
||||
h = 0;
|
||||
}
|
||||
}
|
||||
|
||||
~array2d()
|
||||
{
|
||||
if(w && h)
|
||||
{
|
||||
for(int i=0; i<w; i++) delete [] data[i];
|
||||
delete [] data;
|
||||
}
|
||||
}
|
||||
|
||||
virtual T& operator ()(u32 index1, u32 index2)
|
||||
{
|
||||
return data[index1][index2];
|
||||
}
|
||||
|
||||
virtual s32 width() {return w;}
|
||||
|
||||
virtual s32 height() {return h;}
|
||||
};
|
||||
|
||||
|
||||
|
||||
// enumeration of tile vertices
|
||||
enum TILE_VERTEX
|
||||
{
|
||||
LOWER_LEFT = 0,
|
||||
UPPER_LEFT,
|
||||
UPPER_RIGHT,
|
||||
LOWER_RIGHT,
|
||||
};
|
||||
|
||||
|
||||
|
||||
// structure holding pointers to 4 vertices of tile
|
||||
// makes possible to acces vertex data based on tile structure
|
||||
struct TlTTile
|
||||
{
|
||||
video::S3DVertex2TCoords* Vertex[4];
|
||||
};
|
||||
|
||||
|
||||
|
||||
// structure holding texture coordinates of tile
|
||||
struct TlTCoords
|
||||
{
|
||||
core::vector2d<f32> Vertex[4];
|
||||
};
|
||||
|
||||
|
||||
|
||||
// structure which holds some data about spot on tiled terrain
|
||||
struct TlTData
|
||||
{
|
||||
f32 Height;
|
||||
core::vector3df Normal;
|
||||
video::SColor Color;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// structure which is used as meshbuffer for Tiled Terrain
|
||||
class TlTSector
|
||||
{
|
||||
public:
|
||||
TlTSector() {};
|
||||
~TlTSector() {};
|
||||
// position relative to whole mesh of which sector is part in tiles
|
||||
core::vector2d<s32> Offset;
|
||||
|
||||
// dimension of sector in tiles
|
||||
core::dimension2d<u32> Size;
|
||||
|
||||
// array of vertices
|
||||
core::array<video::S3DVertex2TCoords> Vertex;
|
||||
|
||||
// array of indices
|
||||
core::array<u16> Index;
|
||||
|
||||
// axis aligned bounding box
|
||||
core::aabbox3d<f32> BoundingBox;
|
||||
|
||||
// update texture flag
|
||||
bool UpdateTexture;
|
||||
|
||||
// update vertices flag
|
||||
bool UpdateVertices;
|
||||
|
||||
// vissibility flag
|
||||
bool isVissible;
|
||||
};
|
||||
#endif
|
||||
/*-----------------------------------------------------------------------------*
|
||||
| headerfile TLTMesh.h |
|
||||
| |
|
||||
| version 1.00 |
|
||||
| date: (17.04.2007) |
|
||||
| |
|
||||
| author: Michal Švantner |
|
||||
| |
|
||||
| Some structures used for Tiled Terrain |
|
||||
| Writen for Irrlicht engine version 1.3 |
|
||||
*-----------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef TLTMESH_H
|
||||
#define TLTMESH_H
|
||||
|
||||
#include <irrlicht/irrlicht.h>
|
||||
using namespace irr;
|
||||
|
||||
|
||||
|
||||
// dynamic 2d array
|
||||
template <class T> class array2d
|
||||
{
|
||||
T** data;
|
||||
s32 w, h;
|
||||
|
||||
public:
|
||||
array2d() : w(0), h(0) {}
|
||||
|
||||
array2d(int width, int height) : w(width), h(height)
|
||||
{
|
||||
data = new T*[w];
|
||||
for(int i=0; i<w; i++) data[i] = new T[h];
|
||||
}
|
||||
|
||||
virtual void reset(int width, int height)
|
||||
{
|
||||
if(w && h)
|
||||
{
|
||||
for(int i=0; i<w; i++) delete data[i];
|
||||
delete [] data;
|
||||
}
|
||||
|
||||
if(width && height)
|
||||
{
|
||||
w = width;
|
||||
h = height;
|
||||
|
||||
data = new T*[w];
|
||||
for(int i=0; i<w; i++) data[i] = new T[h];
|
||||
}
|
||||
else
|
||||
{
|
||||
w = 0;
|
||||
h = 0;
|
||||
}
|
||||
}
|
||||
|
||||
~array2d()
|
||||
{
|
||||
if(w && h)
|
||||
{
|
||||
for(int i=0; i<w; i++) delete [] data[i];
|
||||
delete [] data;
|
||||
}
|
||||
}
|
||||
|
||||
virtual T& operator ()(u32 index1, u32 index2)
|
||||
{
|
||||
return data[index1][index2];
|
||||
}
|
||||
|
||||
virtual s32 width() {return w;}
|
||||
|
||||
virtual s32 height() {return h;}
|
||||
};
|
||||
|
||||
|
||||
|
||||
// enumeration of tile vertices
|
||||
enum TILE_VERTEX
|
||||
{
|
||||
LOWER_LEFT = 0,
|
||||
UPPER_LEFT,
|
||||
UPPER_RIGHT,
|
||||
LOWER_RIGHT,
|
||||
};
|
||||
|
||||
|
||||
|
||||
// structure holding pointers to 4 vertices of tile
|
||||
// makes possible to acces vertex data based on tile structure
|
||||
struct TlTTile
|
||||
{
|
||||
video::S3DVertex2TCoords* Vertex[4];
|
||||
};
|
||||
|
||||
|
||||
|
||||
// structure holding texture coordinates of tile
|
||||
struct TlTCoords
|
||||
{
|
||||
core::vector2d<f32> Vertex[4];
|
||||
};
|
||||
|
||||
|
||||
|
||||
// structure which holds some data about spot on tiled terrain
|
||||
struct TlTData
|
||||
{
|
||||
f32 Height;
|
||||
core::vector3df Normal;
|
||||
video::SColor Color;
|
||||
};
|
||||
|
||||
|
||||
|
||||
// structure which is used as meshbuffer for Tiled Terrain
|
||||
class TlTSector
|
||||
{
|
||||
public:
|
||||
TlTSector() {};
|
||||
~TlTSector() {};
|
||||
// position relative to whole mesh of which sector is part in tiles
|
||||
core::vector2d<s32> Offset;
|
||||
|
||||
// dimension of sector in tiles
|
||||
core::dimension2d<u32> Size;
|
||||
|
||||
// array of vertices
|
||||
core::array<video::S3DVertex2TCoords> Vertex;
|
||||
|
||||
// array of indices
|
||||
core::array<u16> Index;
|
||||
|
||||
// axis aligned bounding box
|
||||
core::aabbox3d<f32> BoundingBox;
|
||||
|
||||
// update texture flag
|
||||
bool UpdateTexture;
|
||||
|
||||
// update vertices flag
|
||||
bool UpdateVertices;
|
||||
|
||||
// vissibility flag
|
||||
bool isVissible;
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -1,10 +1,10 @@
|
||||
#ifndef _HELPERDEFS_H
|
||||
#define _HELPERDEFS_H
|
||||
|
||||
#define GUID_HIPART(x) (*(((uint32*)&(x))+1))
|
||||
#define GUID_LOPART(x) (*((uint32*)&(x)))
|
||||
#define MAKE_GUID(l, h) uint64( uint32(l) | ( uint64(h) << 32 ) )
|
||||
|
||||
#define CHAT_ITEM_BEGIN_STRING "|Hitem:"
|
||||
|
||||
#endif
|
||||
#ifndef _HELPERDEFS_H
|
||||
#define _HELPERDEFS_H
|
||||
|
||||
#define GUID_HIPART(x) (*(((uint32*)&(x))+1))
|
||||
#define GUID_LOPART(x) (*((uint32*)&(x)))
|
||||
#define MAKE_GUID(l, h) uint64( uint32(l) | ( uint64(h) << 32 ) )
|
||||
|
||||
#define CHAT_ITEM_BEGIN_STRING "|Hitem:"
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,143 +1,143 @@
|
||||
#include <fstream>
|
||||
#include "MemoryDataHolder.h"
|
||||
#include "DefScript/TypeStorage.h"
|
||||
|
||||
namespace MemoryDataHolder
|
||||
{
|
||||
class DataLoaderRunnable;
|
||||
|
||||
ZThread::FastMutex mutex;
|
||||
TypeStorage<uint8*> storage;
|
||||
TypeStorage<DataLoaderRunnable> loaders;
|
||||
|
||||
// instances of this class MUST be created with new-operator, or Destroy() will cause a crash!
|
||||
class DataLoaderRunnable : public ZThread::Runnable
|
||||
{
|
||||
public:
|
||||
DataLoaderRunnable()
|
||||
{
|
||||
_buf = NULL;
|
||||
_threaded = false;
|
||||
}
|
||||
// the threaded part
|
||||
void run()
|
||||
{
|
||||
uint32 size = GetFileSize(_name.c_str());
|
||||
// couldnt open file if size is 0
|
||||
if(!size)
|
||||
{
|
||||
logerror("DataLoaderRunnable: Error opening file: '%s'",_name.c_str());
|
||||
DoCallbacks(false); // call callback func, 'false' to indicate file coulsnt be loaded
|
||||
Destroy();
|
||||
return;
|
||||
}
|
||||
_buf = new uint8[size];
|
||||
std::ifstream fh;
|
||||
fh.open(_name.c_str(), std::ios_base::in | std::ios_base::binary);
|
||||
if(!fh.is_open())
|
||||
{
|
||||
logerror("DataLoaderRunnable: Error opening file: '%s'",_name.c_str());
|
||||
delete _buf;
|
||||
_buf = NULL;
|
||||
DoCallbacks(false);
|
||||
Destroy();
|
||||
return;
|
||||
}
|
||||
fh.read((char*)_buf,size);
|
||||
fh.close();
|
||||
storage.Assign(_name,&_buf);
|
||||
loaders.UnlinkByPtr(this); // must be unlinked after the file is fully loaded, but before the callbacks are processed!
|
||||
DoCallbacks(true);
|
||||
Destroy();
|
||||
}
|
||||
|
||||
inline void AddCallback(callback_func func, void *ptr = NULL)
|
||||
{
|
||||
_callbacks[func] = ptr;
|
||||
}
|
||||
inline void SetName(std::string name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
// if this class has done its work, delete self
|
||||
inline void Destroy(void)
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
inline uint8 *GetBuf(void)
|
||||
{
|
||||
return _buf;
|
||||
}
|
||||
inline void DoCallbacks(bool success = true)
|
||||
{
|
||||
for(std::map<callback_func,void*>::iterator it = _callbacks.begin(); it != _callbacks.end(); it++)
|
||||
{
|
||||
(*(it->first))(it->second,success);
|
||||
}
|
||||
}
|
||||
inline void SetThreaded(bool t)
|
||||
{
|
||||
_threaded = t;
|
||||
}
|
||||
inline bool IsThreaded(void)
|
||||
{
|
||||
return _threaded;
|
||||
}
|
||||
inline bool HasCallbackFunc(callback_func f)
|
||||
{
|
||||
return _callbacks.find(f) != _callbacks.end();
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
std::string _name;
|
||||
std::map<callback_func, void*> _callbacks;
|
||||
uint8 *_buf;
|
||||
bool _threaded;
|
||||
};
|
||||
|
||||
|
||||
uint8 *GetFile(std::string s, bool threaded = false, callback_func func = NULL,void *ptr = NULL)
|
||||
{
|
||||
mutex.acquire(); // we need excusive access, other threads might unload the requested file during checking
|
||||
if(uint8 **buf = storage.GetNoCreate(s))
|
||||
{
|
||||
// the file was requested some other time, is still present in memory and the pointer can simply be returned
|
||||
mutex.release(); // everything ok, mutex can be unloaded safely before returning
|
||||
return *buf;
|
||||
}
|
||||
else
|
||||
{
|
||||
DataLoaderRunnable *r = loaders.GetNoCreate(s);
|
||||
if(r == NULL)
|
||||
{
|
||||
// no loader thread is working on that file...
|
||||
r = new DataLoaderRunnable();
|
||||
loaders.Assign(s,r);
|
||||
r->AddCallback(func,ptr); // not threadsafe!
|
||||
// after assigning/registering a new loader to the file, the mutex can be released safely
|
||||
mutex.release();
|
||||
r->SetName(s);
|
||||
r->SetThreaded(threaded);
|
||||
if(threaded)
|
||||
{
|
||||
ZThread::Thread t(r); // start thread
|
||||
}
|
||||
else
|
||||
{
|
||||
r->run(); // will exit after the whole file is loaded and the (one) callback is run
|
||||
return r->GetBuf();
|
||||
}
|
||||
}
|
||||
else // if a loader is already existing, add callbacks to that loader.
|
||||
{
|
||||
r->AddCallback(func,ptr);
|
||||
mutex.release();
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
#include <fstream>
|
||||
#include "MemoryDataHolder.h"
|
||||
#include "DefScript/TypeStorage.h"
|
||||
|
||||
namespace MemoryDataHolder
|
||||
{
|
||||
class DataLoaderRunnable;
|
||||
|
||||
ZThread::FastMutex mutex;
|
||||
TypeStorage<uint8*> storage;
|
||||
TypeStorage<DataLoaderRunnable> loaders;
|
||||
|
||||
// instances of this class MUST be created with new-operator, or Destroy() will cause a crash!
|
||||
class DataLoaderRunnable : public ZThread::Runnable
|
||||
{
|
||||
public:
|
||||
DataLoaderRunnable()
|
||||
{
|
||||
_buf = NULL;
|
||||
_threaded = false;
|
||||
}
|
||||
// the threaded part
|
||||
void run()
|
||||
{
|
||||
uint32 size = GetFileSize(_name.c_str());
|
||||
// couldnt open file if size is 0
|
||||
if(!size)
|
||||
{
|
||||
logerror("DataLoaderRunnable: Error opening file: '%s'",_name.c_str());
|
||||
DoCallbacks(false); // call callback func, 'false' to indicate file coulsnt be loaded
|
||||
Destroy();
|
||||
return;
|
||||
}
|
||||
_buf = new uint8[size];
|
||||
std::ifstream fh;
|
||||
fh.open(_name.c_str(), std::ios_base::in | std::ios_base::binary);
|
||||
if(!fh.is_open())
|
||||
{
|
||||
logerror("DataLoaderRunnable: Error opening file: '%s'",_name.c_str());
|
||||
delete _buf;
|
||||
_buf = NULL;
|
||||
DoCallbacks(false);
|
||||
Destroy();
|
||||
return;
|
||||
}
|
||||
fh.read((char*)_buf,size);
|
||||
fh.close();
|
||||
storage.Assign(_name,&_buf);
|
||||
loaders.UnlinkByPtr(this); // must be unlinked after the file is fully loaded, but before the callbacks are processed!
|
||||
DoCallbacks(true);
|
||||
Destroy();
|
||||
}
|
||||
|
||||
inline void AddCallback(callback_func func, void *ptr = NULL)
|
||||
{
|
||||
_callbacks[func] = ptr;
|
||||
}
|
||||
inline void SetName(std::string name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
// if this class has done its work, delete self
|
||||
inline void Destroy(void)
|
||||
{
|
||||
delete this;
|
||||
}
|
||||
inline uint8 *GetBuf(void)
|
||||
{
|
||||
return _buf;
|
||||
}
|
||||
inline void DoCallbacks(bool success = true)
|
||||
{
|
||||
for(std::map<callback_func,void*>::iterator it = _callbacks.begin(); it != _callbacks.end(); it++)
|
||||
{
|
||||
(*(it->first))(it->second,success);
|
||||
}
|
||||
}
|
||||
inline void SetThreaded(bool t)
|
||||
{
|
||||
_threaded = t;
|
||||
}
|
||||
inline bool IsThreaded(void)
|
||||
{
|
||||
return _threaded;
|
||||
}
|
||||
inline bool HasCallbackFunc(callback_func f)
|
||||
{
|
||||
return _callbacks.find(f) != _callbacks.end();
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
std::string _name;
|
||||
std::map<callback_func, void*> _callbacks;
|
||||
uint8 *_buf;
|
||||
bool _threaded;
|
||||
};
|
||||
|
||||
|
||||
uint8 *GetFile(std::string s, bool threaded = false, callback_func func = NULL,void *ptr = NULL)
|
||||
{
|
||||
mutex.acquire(); // we need excusive access, other threads might unload the requested file during checking
|
||||
if(uint8 **buf = storage.GetNoCreate(s))
|
||||
{
|
||||
// the file was requested some other time, is still present in memory and the pointer can simply be returned
|
||||
mutex.release(); // everything ok, mutex can be unloaded safely before returning
|
||||
return *buf;
|
||||
}
|
||||
else
|
||||
{
|
||||
DataLoaderRunnable *r = loaders.GetNoCreate(s);
|
||||
if(r == NULL)
|
||||
{
|
||||
// no loader thread is working on that file...
|
||||
r = new DataLoaderRunnable();
|
||||
loaders.Assign(s,r);
|
||||
r->AddCallback(func,ptr); // not threadsafe!
|
||||
// after assigning/registering a new loader to the file, the mutex can be released safely
|
||||
mutex.release();
|
||||
r->SetName(s);
|
||||
r->SetThreaded(threaded);
|
||||
if(threaded)
|
||||
{
|
||||
ZThread::Thread t(r); // start thread
|
||||
}
|
||||
else
|
||||
{
|
||||
r->run(); // will exit after the whole file is loaded and the (one) callback is run
|
||||
return r->GetBuf();
|
||||
}
|
||||
}
|
||||
else // if a loader is already existing, add callbacks to that loader.
|
||||
{
|
||||
r->AddCallback(func,ptr);
|
||||
mutex.release();
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
@ -1,14 +1,14 @@
|
||||
#ifndef MEMORYDATAHOLDER_H
|
||||
#define MEMORYDATAHOLDER_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
namespace MemoryDataHolder
|
||||
{
|
||||
typedef void (*callback_func)(void*,bool);
|
||||
|
||||
|
||||
uint8 *GetFile(std::string&,bool,callback_func,void*);
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef MEMORYDATAHOLDER_H
|
||||
#define MEMORYDATAHOLDER_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
namespace MemoryDataHolder
|
||||
{
|
||||
typedef void (*callback_func)(void*,bool);
|
||||
|
||||
|
||||
uint8 *GetFile(std::string&,bool,callback_func,void*);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,451 +1,451 @@
|
||||
#include "common.h"
|
||||
#include "PseuWoW.h"
|
||||
#include <time.h>
|
||||
#include <openssl/rand.h>
|
||||
|
||||
#include "ByteBuffer.h"
|
||||
#include "DefScript/DefScript.h"
|
||||
#include "DefScriptInterface.h"
|
||||
#include "Auth/BigNumber.h"
|
||||
#include "DefScript/DefScript.h"
|
||||
#include "RealmSession.h"
|
||||
#include "WorldSession.h"
|
||||
#include "CacheHandler.h"
|
||||
#include "GUI/PseuGUI.h"
|
||||
#include "RemoteController.h"
|
||||
#include "Cli.h"
|
||||
|
||||
|
||||
//###### Start of program code #######
|
||||
|
||||
PseuInstanceRunnable::PseuInstanceRunnable()
|
||||
{
|
||||
}
|
||||
|
||||
void PseuInstanceRunnable::run(void)
|
||||
{
|
||||
_i = new PseuInstance(this);
|
||||
_i->SetConfDir("./conf/");
|
||||
_i->SetScpDir("./scripts/");
|
||||
if(_i->Init())
|
||||
{
|
||||
_i->Run();
|
||||
}
|
||||
else
|
||||
{
|
||||
getchar(); // if init failed, wait for keypress before exit
|
||||
}
|
||||
delete _i;
|
||||
}
|
||||
|
||||
void PseuInstanceRunnable::sleep(uint32 msecs)
|
||||
{
|
||||
ZThread::Thread::sleep(msecs);
|
||||
}
|
||||
|
||||
PseuInstance::PseuInstance(PseuInstanceRunnable *run)
|
||||
{
|
||||
_runnable=run;
|
||||
_ver="PseuWoW Alpha Build 13.51" DEBUG_APPENDIX;
|
||||
_ver_short="A13.51" DEBUG_APPENDIX;
|
||||
_wsession=NULL;
|
||||
_rsession=NULL;
|
||||
_scp=NULL;
|
||||
_conf=NULL;
|
||||
_cli=NULL;
|
||||
_rmcontrol=NULL;
|
||||
_gui=NULL;
|
||||
_guithread=NULL;
|
||||
_stop=false;
|
||||
_fastquit=false;
|
||||
_startrealm=true;
|
||||
_createws=false;
|
||||
_error=false;
|
||||
_initialized=false;
|
||||
|
||||
}
|
||||
|
||||
PseuInstance::~PseuInstance()
|
||||
{
|
||||
if(_cli)
|
||||
{
|
||||
_cli->stop();
|
||||
// delete _cli; // ok this is a little mem leak... can be fixed sometime in future
|
||||
}
|
||||
|
||||
if(_gui)
|
||||
_gui->Shutdown();
|
||||
if(_guithread)
|
||||
_guithread->wait();
|
||||
|
||||
if(_rmcontrol)
|
||||
delete _rmcontrol;
|
||||
if(_rsession)
|
||||
delete _rsession;
|
||||
if(_wsession)
|
||||
delete _wsession;
|
||||
|
||||
delete _scp;
|
||||
delete _conf;
|
||||
|
||||
log("--- Instance shut down ---");
|
||||
}
|
||||
|
||||
bool PseuInstance::Init(void)
|
||||
{
|
||||
log_setloglevel(0);
|
||||
log("");
|
||||
log("--- Initializing Instance ---");
|
||||
|
||||
if(_confdir.empty())
|
||||
_confdir="./conf/";
|
||||
if(_scpdir.empty())
|
||||
_scpdir="./scripts/";
|
||||
|
||||
srand((unsigned)time(NULL));
|
||||
RAND_set_rand_method(RAND_SSLeay()); // init openssl randomizer
|
||||
|
||||
_scp=new DefScriptPackage();
|
||||
_scp->SetParentMethod((void*)this);
|
||||
_conf=new PseuInstanceConf();
|
||||
|
||||
_scp->SetPath(_scpdir);
|
||||
_scp->SetLog(logdetail); // does anyone have an idea why log() is not accepted here?
|
||||
_scp->SetDebugLog(logdebug);
|
||||
_scp->SetErrorLog(logerror);
|
||||
|
||||
_scp->variables.Set("@version_short",_ver_short);
|
||||
_scp->variables.Set("@version",_ver);
|
||||
_scp->variables.Set("@inworld","false");
|
||||
|
||||
if(!_scp->LoadScriptFromFile("./_startup.def"))
|
||||
{
|
||||
logerror("Error loading '_startup.def'");
|
||||
SetError();
|
||||
}
|
||||
else if(!_scp->BoolRunScript("_startup",NULL))
|
||||
{
|
||||
logerror("Error executing '_startup.def'");
|
||||
SetError();
|
||||
}
|
||||
|
||||
// TODO: find a better loaction where to place this block!
|
||||
if(GetConf()->enablegui)
|
||||
{
|
||||
if(InitGUI())
|
||||
logdebug("GUI: Init successful.");
|
||||
else
|
||||
logerror("GUI: Init failed!");
|
||||
}
|
||||
|
||||
if(GetConf()->rmcontrolport)
|
||||
{
|
||||
_rmcontrol = new RemoteController(this,GetConf()->rmcontrolport);
|
||||
}
|
||||
|
||||
if(GetConf()->enablecli)
|
||||
{
|
||||
log("Starting CLI...");
|
||||
_cli = new CliRunnable(this);
|
||||
ZThread::Thread t(_cli);
|
||||
}
|
||||
|
||||
if(_error)
|
||||
{
|
||||
logcritical("Errors while initializing!");
|
||||
return false;
|
||||
}
|
||||
|
||||
log("Init complete.");
|
||||
_initialized=true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PseuInstance::InitGUI(void)
|
||||
{
|
||||
if(GetGUI())
|
||||
{
|
||||
logerror("GUI: Aborting init, GUI already exists!");
|
||||
return false;
|
||||
}
|
||||
uint16 x,y,depth;
|
||||
uint8 driver;
|
||||
bool shadows,vsync,win;
|
||||
|
||||
driver=(uint8)atoi(GetScripts()->variables.Get("GUI::DRIVER").c_str());
|
||||
vsync=(bool)atoi(GetScripts()->variables.Get("GUI::VSYNC").c_str());
|
||||
depth=(uint8)atoi(GetScripts()->variables.Get("GUI::DEPTH").c_str());
|
||||
x=(uint16)atoi(GetScripts()->variables.Get("GUI::RESX").c_str());
|
||||
y=(uint16)atoi(GetScripts()->variables.Get("GUI::RESY").c_str());
|
||||
win=(bool)atoi(GetScripts()->variables.Get("GUI::WINDOWED").c_str());
|
||||
shadows=(bool)atoi(GetScripts()->variables.Get("GUI::SHADOWS").c_str());
|
||||
log("GUI settings: driver=%u, depth=%u, res=%ux%u, windowed=%u, shadows=%u",driver,depth,x,y,win,shadows);
|
||||
if(x>0 && y>0 && (depth==16 || depth==32) && driver>0 && driver<=5)
|
||||
{
|
||||
PseuGUIRunnable *rgui = new PseuGUIRunnable();
|
||||
_gui = rgui->GetGUI();
|
||||
_gui->SetInstance(this);
|
||||
_gui->SetDriver(driver);
|
||||
_gui->SetResolution(x,y,depth);
|
||||
_gui->SetVSync(vsync);
|
||||
_gui->UseShadows(shadows);
|
||||
_guithread = new ZThread::Thread(rgui);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
logerror("GUI: incorrect settings!");
|
||||
return false;
|
||||
}
|
||||
|
||||
void PseuInstance::Run(void)
|
||||
{
|
||||
if(!_initialized)
|
||||
return;
|
||||
|
||||
logdetail("PseuInstance: Initialized and running!");
|
||||
|
||||
if(GetGUI())
|
||||
{
|
||||
while(!GetGUI()->IsInitialized())
|
||||
Sleep(1); // wait until the gui is ready. it will crash otherwise
|
||||
logdebug("GUI: switching to startup display...");
|
||||
GetGUI()->SetSceneState(SCENESTATE_GUISTART);
|
||||
}
|
||||
// TODO: as soon as username and password can be inputted into the gui, wait until it was set by user.
|
||||
|
||||
if(GetConf()->realmlist.empty() || GetConf()->realmport==0)
|
||||
{
|
||||
logcritical("Realmlist address not set, can't connect.");
|
||||
SetError();
|
||||
}
|
||||
else
|
||||
{
|
||||
// for now: create the realmsession only on startup.
|
||||
// may be extended to a script command later on.
|
||||
// then try to connect
|
||||
_rsession = new RealmSession(this);
|
||||
_rsession->Connect();
|
||||
_rsession->SendLogonChallenge();
|
||||
|
||||
// this is the mainloop
|
||||
while(!_stop)
|
||||
{
|
||||
Update();
|
||||
if(_error)
|
||||
_stop=true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// fastquit is defined if we clicked [X] (on windows)
|
||||
if(_fastquit)
|
||||
{
|
||||
log("Aborting Instance...");
|
||||
return;
|
||||
}
|
||||
|
||||
log("Shutting down instance...");
|
||||
|
||||
// if there was an error, better dont save, as the data might be damaged
|
||||
if(!_error)
|
||||
{
|
||||
SaveAllCache();
|
||||
//...
|
||||
}
|
||||
|
||||
if(GetConf()->exitonerror == false && _error)
|
||||
{
|
||||
log("Exiting on error is disabled, PseuWoW is now IDLE");
|
||||
log("-- Press enter to exit --");
|
||||
char crap[100];
|
||||
fgets(crap,sizeof(crap),stdin); // workaround, need to press enter 2x for now
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void PseuInstance::Update()
|
||||
{
|
||||
// if the user typed anything into the console, process it before anything else.
|
||||
// note that it can also be used for simulated cli commands sent by other threads, so it needs to be checked even if cli is disabled
|
||||
ProcessCliQueue();
|
||||
|
||||
// delete sessions if they are no longer needed
|
||||
if(_rsession && _rsession->MustDie())
|
||||
{
|
||||
delete _rsession;
|
||||
_rsession = NULL;
|
||||
}
|
||||
|
||||
if(_wsession && _wsession->MustDie())
|
||||
{
|
||||
delete _wsession;
|
||||
_wsession = NULL;
|
||||
}
|
||||
|
||||
if(_createws)
|
||||
{
|
||||
_createws = false;
|
||||
if(_wsession)
|
||||
delete _wsession;
|
||||
_wsession = new WorldSession(this);
|
||||
_wsession->Start();
|
||||
}
|
||||
|
||||
// if we have no active sessions, we may reconnect
|
||||
if((!_rsession) && (!_wsession) && GetConf()->reconnect)
|
||||
{
|
||||
logdetail("Waiting %u ms before reconnecting.",GetConf()->reconnect);
|
||||
for(uint32 t = 0; t < GetConf()->reconnect && !this->Stopped(); t+=100) Sleep(100);
|
||||
this->Sleep(1000); // wait 1 sec before reconnecting
|
||||
_rsession = new RealmSession(this);
|
||||
_rsession->Connect();
|
||||
_rsession->SendLogonChallenge(); // and login again
|
||||
}
|
||||
|
||||
// update currently existing/active sessions
|
||||
if(_rsession)
|
||||
_rsession->Update();
|
||||
if(_wsession)
|
||||
try { _wsession->Update(); } catch (...)
|
||||
{
|
||||
logerror("Unhandled exception in WorldSession::Update()");
|
||||
}
|
||||
|
||||
|
||||
if(_rmcontrol)
|
||||
{
|
||||
_rmcontrol->Update();
|
||||
if(_rmcontrol->MustDie())
|
||||
{
|
||||
delete _rmcontrol;
|
||||
_rmcontrol = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
GetScripts()->GetEventMgr()->Update();
|
||||
|
||||
this->Sleep(GetConf()->networksleeptime);
|
||||
}
|
||||
|
||||
void PseuInstance::ProcessCliQueue(void)
|
||||
{
|
||||
std::string cmd;
|
||||
while(_cliQueue.size())
|
||||
{
|
||||
cmd = _cliQueue.next();
|
||||
try
|
||||
{
|
||||
GetScripts()->RunSingleLine(cmd);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
logerror("Exception while executing CLI command: \"%s\"",cmd.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PseuInstance::AddCliCommand(std::string cmd)
|
||||
{
|
||||
_cliQueue.add(cmd);
|
||||
}
|
||||
|
||||
void PseuInstance::SaveAllCache(void)
|
||||
{
|
||||
//...
|
||||
if(GetWSession())
|
||||
{
|
||||
GetWSession()->plrNameCache.SaveToFile();
|
||||
ItemProtoCache_WriteDataToCache(GetWSession());
|
||||
CreatureTemplateCache_WriteDataToCache(GetWSession());
|
||||
//...
|
||||
}
|
||||
}
|
||||
|
||||
void PseuInstance::Sleep(uint32 msecs)
|
||||
{
|
||||
GetRunnable()->sleep(msecs);
|
||||
}
|
||||
|
||||
void PseuInstance::DeleteGUI(void)
|
||||
{
|
||||
_gui = NULL;
|
||||
delete _guithread; // since it was allocated with new
|
||||
_guithread = NULL;
|
||||
if(GetScripts()->ScriptExists("_onguiclose"))
|
||||
AddCliCommand("_onguiclose"); // since this func is called from another thread, use threadsafe variant via CLI
|
||||
}
|
||||
|
||||
PseuInstanceConf::PseuInstanceConf()
|
||||
{
|
||||
enablecli=false;
|
||||
enablegui=false;
|
||||
exitonerror=false;
|
||||
debug=0;
|
||||
rmcontrolport=0;
|
||||
}
|
||||
|
||||
void PseuInstanceConf::ApplyFromVarSet(VarSet &v)
|
||||
{
|
||||
debug=atoi(v.Get("DEBUG").c_str());
|
||||
realmlist=v.Get("REALMLIST");
|
||||
accname=v.Get("ACCNAME");
|
||||
accpass=v.Get("ACCPASS");
|
||||
exitonerror=(bool)atoi(v.Get("EXITONERROR").c_str());
|
||||
reconnect=atoi(v.Get("RECONNECT").c_str());
|
||||
realmport=atoi(v.Get("REALMPORT").c_str());
|
||||
clientversion_string=v.Get("CLIENTVERSION");
|
||||
clientbuild=atoi(v.Get("CLIENTBUILD").c_str());
|
||||
clientlang=v.Get("CLIENTLANGUAGE");
|
||||
realmname=v.Get("REALMNAME");
|
||||
charname=v.Get("CHARNAME");
|
||||
networksleeptime=atoi(v.Get("NETWORKSLEEPTIME").c_str());
|
||||
showopcodes=atoi(v.Get("SHOWOPCODES").c_str());
|
||||
hidefreqopcodes=(bool)atoi(v.Get("HIDEFREQOPCODES").c_str());
|
||||
hideDisabledOpcodes=(bool)atoi(v.Get("HIDEDISABLEDOPCODES").c_str());
|
||||
enablecli=(bool)atoi(v.Get("ENABLECLI").c_str());
|
||||
allowgamecmd=(bool)atoi(v.Get("ALLOWGAMECMD").c_str());
|
||||
enablechatai=(bool)atoi(v.Get("ENABLECHATAI").c_str());
|
||||
notifyping=(bool)atoi(v.Get("NOTIFYPING").c_str());
|
||||
showmyopcodes=(bool)atoi(v.Get("SHOWMYOPCODES").c_str());
|
||||
disablespellcheck=(bool)atoi(v.Get("DISABLESPELLCHECK").c_str());
|
||||
enablegui=(bool)atoi(v.Get("ENABLEGUI").c_str());
|
||||
rmcontrolport=atoi(v.Get("RMCONTROLPORT").c_str());
|
||||
rmcontrolhost=v.Get("RMCONTROLHOST");
|
||||
useMaps=(bool)atoi(v.Get("USEMAPS").c_str());
|
||||
skipaddonchat=(bool)atoi(v.Get("SKIPADDONCHAT").c_str());
|
||||
|
||||
// clientversion is a bit more complicated to add
|
||||
{
|
||||
std::string opt=clientversion_string + ".";
|
||||
std::string num;
|
||||
uint8 p=0;
|
||||
for(uint8 i=0;i<opt.length();i++)
|
||||
{
|
||||
if(!isdigit(opt.at(i)))
|
||||
{
|
||||
clientversion[p]=(unsigned char)atoi(num.c_str());
|
||||
num.clear();
|
||||
p++;
|
||||
if(p>2)
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
num+=opt.at(i);
|
||||
}
|
||||
}
|
||||
|
||||
log_setloglevel(debug);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
PseuInstanceConf::~PseuInstanceConf()
|
||||
{
|
||||
//...
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#include "common.h"
|
||||
#include "PseuWoW.h"
|
||||
#include <time.h>
|
||||
#include <openssl/rand.h>
|
||||
|
||||
#include "ByteBuffer.h"
|
||||
#include "DefScript/DefScript.h"
|
||||
#include "DefScriptInterface.h"
|
||||
#include "Auth/BigNumber.h"
|
||||
#include "DefScript/DefScript.h"
|
||||
#include "RealmSession.h"
|
||||
#include "WorldSession.h"
|
||||
#include "CacheHandler.h"
|
||||
#include "GUI/PseuGUI.h"
|
||||
#include "RemoteController.h"
|
||||
#include "Cli.h"
|
||||
|
||||
|
||||
//###### Start of program code #######
|
||||
|
||||
PseuInstanceRunnable::PseuInstanceRunnable()
|
||||
{
|
||||
}
|
||||
|
||||
void PseuInstanceRunnable::run(void)
|
||||
{
|
||||
_i = new PseuInstance(this);
|
||||
_i->SetConfDir("./conf/");
|
||||
_i->SetScpDir("./scripts/");
|
||||
if(_i->Init())
|
||||
{
|
||||
_i->Run();
|
||||
}
|
||||
else
|
||||
{
|
||||
getchar(); // if init failed, wait for keypress before exit
|
||||
}
|
||||
delete _i;
|
||||
}
|
||||
|
||||
void PseuInstanceRunnable::sleep(uint32 msecs)
|
||||
{
|
||||
ZThread::Thread::sleep(msecs);
|
||||
}
|
||||
|
||||
PseuInstance::PseuInstance(PseuInstanceRunnable *run)
|
||||
{
|
||||
_runnable=run;
|
||||
_ver="PseuWoW Alpha Build 13.51" DEBUG_APPENDIX;
|
||||
_ver_short="A13.51" DEBUG_APPENDIX;
|
||||
_wsession=NULL;
|
||||
_rsession=NULL;
|
||||
_scp=NULL;
|
||||
_conf=NULL;
|
||||
_cli=NULL;
|
||||
_rmcontrol=NULL;
|
||||
_gui=NULL;
|
||||
_guithread=NULL;
|
||||
_stop=false;
|
||||
_fastquit=false;
|
||||
_startrealm=true;
|
||||
_createws=false;
|
||||
_error=false;
|
||||
_initialized=false;
|
||||
|
||||
}
|
||||
|
||||
PseuInstance::~PseuInstance()
|
||||
{
|
||||
if(_cli)
|
||||
{
|
||||
_cli->stop();
|
||||
// delete _cli; // ok this is a little mem leak... can be fixed sometime in future
|
||||
}
|
||||
|
||||
if(_gui)
|
||||
_gui->Shutdown();
|
||||
if(_guithread)
|
||||
_guithread->wait();
|
||||
|
||||
if(_rmcontrol)
|
||||
delete _rmcontrol;
|
||||
if(_rsession)
|
||||
delete _rsession;
|
||||
if(_wsession)
|
||||
delete _wsession;
|
||||
|
||||
delete _scp;
|
||||
delete _conf;
|
||||
|
||||
log("--- Instance shut down ---");
|
||||
}
|
||||
|
||||
bool PseuInstance::Init(void)
|
||||
{
|
||||
log_setloglevel(0);
|
||||
log("");
|
||||
log("--- Initializing Instance ---");
|
||||
|
||||
if(_confdir.empty())
|
||||
_confdir="./conf/";
|
||||
if(_scpdir.empty())
|
||||
_scpdir="./scripts/";
|
||||
|
||||
srand((unsigned)time(NULL));
|
||||
RAND_set_rand_method(RAND_SSLeay()); // init openssl randomizer
|
||||
|
||||
_scp=new DefScriptPackage();
|
||||
_scp->SetParentMethod((void*)this);
|
||||
_conf=new PseuInstanceConf();
|
||||
|
||||
_scp->SetPath(_scpdir);
|
||||
_scp->SetLog(logdetail); // does anyone have an idea why log() is not accepted here?
|
||||
_scp->SetDebugLog(logdebug);
|
||||
_scp->SetErrorLog(logerror);
|
||||
|
||||
_scp->variables.Set("@version_short",_ver_short);
|
||||
_scp->variables.Set("@version",_ver);
|
||||
_scp->variables.Set("@inworld","false");
|
||||
|
||||
if(!_scp->LoadScriptFromFile("./_startup.def"))
|
||||
{
|
||||
logerror("Error loading '_startup.def'");
|
||||
SetError();
|
||||
}
|
||||
else if(!_scp->BoolRunScript("_startup",NULL))
|
||||
{
|
||||
logerror("Error executing '_startup.def'");
|
||||
SetError();
|
||||
}
|
||||
|
||||
// TODO: find a better loaction where to place this block!
|
||||
if(GetConf()->enablegui)
|
||||
{
|
||||
if(InitGUI())
|
||||
logdebug("GUI: Init successful.");
|
||||
else
|
||||
logerror("GUI: Init failed!");
|
||||
}
|
||||
|
||||
if(GetConf()->rmcontrolport)
|
||||
{
|
||||
_rmcontrol = new RemoteController(this,GetConf()->rmcontrolport);
|
||||
}
|
||||
|
||||
if(GetConf()->enablecli)
|
||||
{
|
||||
log("Starting CLI...");
|
||||
_cli = new CliRunnable(this);
|
||||
ZThread::Thread t(_cli);
|
||||
}
|
||||
|
||||
if(_error)
|
||||
{
|
||||
logcritical("Errors while initializing!");
|
||||
return false;
|
||||
}
|
||||
|
||||
log("Init complete.");
|
||||
_initialized=true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool PseuInstance::InitGUI(void)
|
||||
{
|
||||
if(GetGUI())
|
||||
{
|
||||
logerror("GUI: Aborting init, GUI already exists!");
|
||||
return false;
|
||||
}
|
||||
uint16 x,y,depth;
|
||||
uint8 driver;
|
||||
bool shadows,vsync,win;
|
||||
|
||||
driver=(uint8)atoi(GetScripts()->variables.Get("GUI::DRIVER").c_str());
|
||||
vsync=(bool)atoi(GetScripts()->variables.Get("GUI::VSYNC").c_str());
|
||||
depth=(uint8)atoi(GetScripts()->variables.Get("GUI::DEPTH").c_str());
|
||||
x=(uint16)atoi(GetScripts()->variables.Get("GUI::RESX").c_str());
|
||||
y=(uint16)atoi(GetScripts()->variables.Get("GUI::RESY").c_str());
|
||||
win=(bool)atoi(GetScripts()->variables.Get("GUI::WINDOWED").c_str());
|
||||
shadows=(bool)atoi(GetScripts()->variables.Get("GUI::SHADOWS").c_str());
|
||||
log("GUI settings: driver=%u, depth=%u, res=%ux%u, windowed=%u, shadows=%u",driver,depth,x,y,win,shadows);
|
||||
if(x>0 && y>0 && (depth==16 || depth==32) && driver>0 && driver<=5)
|
||||
{
|
||||
PseuGUIRunnable *rgui = new PseuGUIRunnable();
|
||||
_gui = rgui->GetGUI();
|
||||
_gui->SetInstance(this);
|
||||
_gui->SetDriver(driver);
|
||||
_gui->SetResolution(x,y,depth);
|
||||
_gui->SetVSync(vsync);
|
||||
_gui->UseShadows(shadows);
|
||||
_guithread = new ZThread::Thread(rgui);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
logerror("GUI: incorrect settings!");
|
||||
return false;
|
||||
}
|
||||
|
||||
void PseuInstance::Run(void)
|
||||
{
|
||||
if(!_initialized)
|
||||
return;
|
||||
|
||||
logdetail("PseuInstance: Initialized and running!");
|
||||
|
||||
if(GetGUI())
|
||||
{
|
||||
while(!GetGUI()->IsInitialized())
|
||||
Sleep(1); // wait until the gui is ready. it will crash otherwise
|
||||
logdebug("GUI: switching to startup display...");
|
||||
GetGUI()->SetSceneState(SCENESTATE_GUISTART);
|
||||
}
|
||||
// TODO: as soon as username and password can be inputted into the gui, wait until it was set by user.
|
||||
|
||||
if(GetConf()->realmlist.empty() || GetConf()->realmport==0)
|
||||
{
|
||||
logcritical("Realmlist address not set, can't connect.");
|
||||
SetError();
|
||||
}
|
||||
else
|
||||
{
|
||||
// for now: create the realmsession only on startup.
|
||||
// may be extended to a script command later on.
|
||||
// then try to connect
|
||||
_rsession = new RealmSession(this);
|
||||
_rsession->Connect();
|
||||
_rsession->SendLogonChallenge();
|
||||
|
||||
// this is the mainloop
|
||||
while(!_stop)
|
||||
{
|
||||
Update();
|
||||
if(_error)
|
||||
_stop=true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// fastquit is defined if we clicked [X] (on windows)
|
||||
if(_fastquit)
|
||||
{
|
||||
log("Aborting Instance...");
|
||||
return;
|
||||
}
|
||||
|
||||
log("Shutting down instance...");
|
||||
|
||||
// if there was an error, better dont save, as the data might be damaged
|
||||
if(!_error)
|
||||
{
|
||||
SaveAllCache();
|
||||
//...
|
||||
}
|
||||
|
||||
if(GetConf()->exitonerror == false && _error)
|
||||
{
|
||||
log("Exiting on error is disabled, PseuWoW is now IDLE");
|
||||
log("-- Press enter to exit --");
|
||||
char crap[100];
|
||||
fgets(crap,sizeof(crap),stdin); // workaround, need to press enter 2x for now
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void PseuInstance::Update()
|
||||
{
|
||||
// if the user typed anything into the console, process it before anything else.
|
||||
// note that it can also be used for simulated cli commands sent by other threads, so it needs to be checked even if cli is disabled
|
||||
ProcessCliQueue();
|
||||
|
||||
// delete sessions if they are no longer needed
|
||||
if(_rsession && _rsession->MustDie())
|
||||
{
|
||||
delete _rsession;
|
||||
_rsession = NULL;
|
||||
}
|
||||
|
||||
if(_wsession && _wsession->MustDie())
|
||||
{
|
||||
delete _wsession;
|
||||
_wsession = NULL;
|
||||
}
|
||||
|
||||
if(_createws)
|
||||
{
|
||||
_createws = false;
|
||||
if(_wsession)
|
||||
delete _wsession;
|
||||
_wsession = new WorldSession(this);
|
||||
_wsession->Start();
|
||||
}
|
||||
|
||||
// if we have no active sessions, we may reconnect
|
||||
if((!_rsession) && (!_wsession) && GetConf()->reconnect)
|
||||
{
|
||||
logdetail("Waiting %u ms before reconnecting.",GetConf()->reconnect);
|
||||
for(uint32 t = 0; t < GetConf()->reconnect && !this->Stopped(); t+=100) Sleep(100);
|
||||
this->Sleep(1000); // wait 1 sec before reconnecting
|
||||
_rsession = new RealmSession(this);
|
||||
_rsession->Connect();
|
||||
_rsession->SendLogonChallenge(); // and login again
|
||||
}
|
||||
|
||||
// update currently existing/active sessions
|
||||
if(_rsession)
|
||||
_rsession->Update();
|
||||
if(_wsession)
|
||||
try { _wsession->Update(); } catch (...)
|
||||
{
|
||||
logerror("Unhandled exception in WorldSession::Update()");
|
||||
}
|
||||
|
||||
|
||||
if(_rmcontrol)
|
||||
{
|
||||
_rmcontrol->Update();
|
||||
if(_rmcontrol->MustDie())
|
||||
{
|
||||
delete _rmcontrol;
|
||||
_rmcontrol = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
GetScripts()->GetEventMgr()->Update();
|
||||
|
||||
this->Sleep(GetConf()->networksleeptime);
|
||||
}
|
||||
|
||||
void PseuInstance::ProcessCliQueue(void)
|
||||
{
|
||||
std::string cmd;
|
||||
while(_cliQueue.size())
|
||||
{
|
||||
cmd = _cliQueue.next();
|
||||
try
|
||||
{
|
||||
GetScripts()->RunSingleLine(cmd);
|
||||
}
|
||||
catch(...)
|
||||
{
|
||||
logerror("Exception while executing CLI command: \"%s\"",cmd.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void PseuInstance::AddCliCommand(std::string cmd)
|
||||
{
|
||||
_cliQueue.add(cmd);
|
||||
}
|
||||
|
||||
void PseuInstance::SaveAllCache(void)
|
||||
{
|
||||
//...
|
||||
if(GetWSession())
|
||||
{
|
||||
GetWSession()->plrNameCache.SaveToFile();
|
||||
ItemProtoCache_WriteDataToCache(GetWSession());
|
||||
CreatureTemplateCache_WriteDataToCache(GetWSession());
|
||||
//...
|
||||
}
|
||||
}
|
||||
|
||||
void PseuInstance::Sleep(uint32 msecs)
|
||||
{
|
||||
GetRunnable()->sleep(msecs);
|
||||
}
|
||||
|
||||
void PseuInstance::DeleteGUI(void)
|
||||
{
|
||||
_gui = NULL;
|
||||
delete _guithread; // since it was allocated with new
|
||||
_guithread = NULL;
|
||||
if(GetScripts()->ScriptExists("_onguiclose"))
|
||||
AddCliCommand("_onguiclose"); // since this func is called from another thread, use threadsafe variant via CLI
|
||||
}
|
||||
|
||||
PseuInstanceConf::PseuInstanceConf()
|
||||
{
|
||||
enablecli=false;
|
||||
enablegui=false;
|
||||
exitonerror=false;
|
||||
debug=0;
|
||||
rmcontrolport=0;
|
||||
}
|
||||
|
||||
void PseuInstanceConf::ApplyFromVarSet(VarSet &v)
|
||||
{
|
||||
debug=atoi(v.Get("DEBUG").c_str());
|
||||
realmlist=v.Get("REALMLIST");
|
||||
accname=v.Get("ACCNAME");
|
||||
accpass=v.Get("ACCPASS");
|
||||
exitonerror=(bool)atoi(v.Get("EXITONERROR").c_str());
|
||||
reconnect=atoi(v.Get("RECONNECT").c_str());
|
||||
realmport=atoi(v.Get("REALMPORT").c_str());
|
||||
clientversion_string=v.Get("CLIENTVERSION");
|
||||
clientbuild=atoi(v.Get("CLIENTBUILD").c_str());
|
||||
clientlang=v.Get("CLIENTLANGUAGE");
|
||||
realmname=v.Get("REALMNAME");
|
||||
charname=v.Get("CHARNAME");
|
||||
networksleeptime=atoi(v.Get("NETWORKSLEEPTIME").c_str());
|
||||
showopcodes=atoi(v.Get("SHOWOPCODES").c_str());
|
||||
hidefreqopcodes=(bool)atoi(v.Get("HIDEFREQOPCODES").c_str());
|
||||
hideDisabledOpcodes=(bool)atoi(v.Get("HIDEDISABLEDOPCODES").c_str());
|
||||
enablecli=(bool)atoi(v.Get("ENABLECLI").c_str());
|
||||
allowgamecmd=(bool)atoi(v.Get("ALLOWGAMECMD").c_str());
|
||||
enablechatai=(bool)atoi(v.Get("ENABLECHATAI").c_str());
|
||||
notifyping=(bool)atoi(v.Get("NOTIFYPING").c_str());
|
||||
showmyopcodes=(bool)atoi(v.Get("SHOWMYOPCODES").c_str());
|
||||
disablespellcheck=(bool)atoi(v.Get("DISABLESPELLCHECK").c_str());
|
||||
enablegui=(bool)atoi(v.Get("ENABLEGUI").c_str());
|
||||
rmcontrolport=atoi(v.Get("RMCONTROLPORT").c_str());
|
||||
rmcontrolhost=v.Get("RMCONTROLHOST");
|
||||
useMaps=(bool)atoi(v.Get("USEMAPS").c_str());
|
||||
skipaddonchat=(bool)atoi(v.Get("SKIPADDONCHAT").c_str());
|
||||
|
||||
// clientversion is a bit more complicated to add
|
||||
{
|
||||
std::string opt=clientversion_string + ".";
|
||||
std::string num;
|
||||
uint8 p=0;
|
||||
for(uint8 i=0;i<opt.length();i++)
|
||||
{
|
||||
if(!isdigit(opt.at(i)))
|
||||
{
|
||||
clientversion[p]=(unsigned char)atoi(num.c_str());
|
||||
num.clear();
|
||||
p++;
|
||||
if(p>2)
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
num+=opt.at(i);
|
||||
}
|
||||
}
|
||||
|
||||
log_setloglevel(debug);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
PseuInstanceConf::~PseuInstanceConf()
|
||||
{
|
||||
//...
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,145 +1,145 @@
|
||||
|
||||
#ifndef _PSEUWOW_H
|
||||
#define _PSEUWOW_H
|
||||
|
||||
#include "common.h"
|
||||
#include "HelperDefs.h"
|
||||
#include "log.h"
|
||||
#include "Auth/BigNumber.h"
|
||||
#include "DefScript/DefScript.h"
|
||||
#include "Network/SocketHandler.h"
|
||||
#include "SCPDatabase.h"
|
||||
#include "GUI/PseuGUI.h"
|
||||
|
||||
class RealmSession;
|
||||
class WorldSession;
|
||||
class Sockethandler;
|
||||
class PseuInstanceRunnable;
|
||||
class CliRunnable;
|
||||
class RemoteController;
|
||||
|
||||
class PseuInstanceConf
|
||||
{
|
||||
public:
|
||||
|
||||
PseuInstanceConf();
|
||||
~PseuInstanceConf();
|
||||
void ApplyFromVarSet(VarSet &v);
|
||||
|
||||
|
||||
uint8 debug;
|
||||
std::string realmlist;
|
||||
std::string accname;
|
||||
std::string accpass;
|
||||
bool exitonerror;
|
||||
uint32 reconnect;
|
||||
uint16 realmport;
|
||||
uint16 worldport;
|
||||
uint8 clientversion[3];
|
||||
std::string clientversion_string;
|
||||
uint16 clientbuild;
|
||||
std::string clientlang;
|
||||
std::string realmname;
|
||||
std::string charname;
|
||||
std::string worldhost;
|
||||
uint16 networksleeptime;
|
||||
uint8 showopcodes;
|
||||
bool hidefreqopcodes;
|
||||
bool hideDisabledOpcodes;
|
||||
bool allowgamecmd;
|
||||
bool enablecli;
|
||||
bool enablechatai;
|
||||
bool notifyping;
|
||||
bool showmyopcodes;
|
||||
bool disablespellcheck;
|
||||
uint32 rmcontrolport;
|
||||
std::string rmcontrolhost;
|
||||
bool useMaps;
|
||||
bool skipaddonchat;
|
||||
|
||||
// gui related
|
||||
bool enablegui;
|
||||
// need more here
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
class PseuInstance
|
||||
{
|
||||
public:
|
||||
|
||||
PseuInstance(PseuInstanceRunnable *run);
|
||||
~PseuInstance();
|
||||
|
||||
|
||||
inline WorldSession *GetWSession(void) { return _wsession; }
|
||||
inline RealmSession *GetRSession(void) { return _rsession; }
|
||||
inline PseuInstanceConf *GetConf(void) { return _conf; }
|
||||
inline DefScriptPackage *GetScripts(void) { return _scp; }
|
||||
inline PseuInstanceRunnable *GetRunnable(void) { return _runnable; }
|
||||
inline PseuGUI *GetGUI(void) { return _gui; }
|
||||
void DeleteGUI(void);
|
||||
|
||||
inline void SetConfDir(std::string dir) { _confdir = dir; }
|
||||
inline std::string GetConfDir(void) { return _confdir; }
|
||||
inline void SetScpDir(std::string dir) { _scpdir = dir; }
|
||||
inline void SetSessionKey(BigNumber key) { _sessionkey = key; }
|
||||
inline BigNumber *GetSessionKey(void) { return &_sessionkey; }
|
||||
inline void SetError(void) { _error = true; }
|
||||
SCPDatabaseMgr dbmgr;
|
||||
|
||||
bool Init(void);
|
||||
bool InitGUI(void);
|
||||
void SaveAllCache(void);
|
||||
inline void Stop(void) { _stop = true; }
|
||||
inline bool Stopped(void) { return _stop; }
|
||||
inline void SetFastQuit(bool q=true) { _fastquit=true; }
|
||||
void Run(void);
|
||||
void Update(void);
|
||||
void Sleep(uint32 msecs);
|
||||
|
||||
inline void CreateWorldSession(void) { _createws = true; }
|
||||
|
||||
void ProcessCliQueue(void);
|
||||
void AddCliCommand(std::string);
|
||||
|
||||
private:
|
||||
|
||||
PseuInstanceRunnable *_runnable;
|
||||
RealmSession *_rsession;
|
||||
WorldSession *_wsession;
|
||||
PseuInstanceConf *_conf;
|
||||
DefScriptPackage *_scp;
|
||||
std::string _confdir,_scpdir; // _scpdir is the scripts dir, and NOT where SCP files are stored!!
|
||||
bool _initialized;
|
||||
bool _stop,_fastquit;
|
||||
bool _startrealm;
|
||||
bool _error;
|
||||
bool _createws;
|
||||
BigNumber _sessionkey;
|
||||
char *_ver,*_ver_short;
|
||||
SocketHandler _sh;
|
||||
CliRunnable *_cli;
|
||||
ZThread::Thread _clithread;
|
||||
RemoteController *_rmcontrol;
|
||||
ZThread::LockedQueue<std::string,ZThread::FastMutex> _cliQueue;
|
||||
PseuGUI *_gui;
|
||||
ZThread::Thread *_guithread;
|
||||
|
||||
};
|
||||
|
||||
class PseuInstanceRunnable : public ZThread::Runnable
|
||||
{
|
||||
public:
|
||||
PseuInstanceRunnable();
|
||||
void run(void);
|
||||
void sleep(uint32);
|
||||
inline PseuInstance *GetInstance(void) { return _i; }
|
||||
|
||||
private:
|
||||
PseuInstance *_i;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef _PSEUWOW_H
|
||||
#define _PSEUWOW_H
|
||||
|
||||
#include "common.h"
|
||||
#include "HelperDefs.h"
|
||||
#include "log.h"
|
||||
#include "Auth/BigNumber.h"
|
||||
#include "DefScript/DefScript.h"
|
||||
#include "Network/SocketHandler.h"
|
||||
#include "SCPDatabase.h"
|
||||
#include "GUI/PseuGUI.h"
|
||||
|
||||
class RealmSession;
|
||||
class WorldSession;
|
||||
class Sockethandler;
|
||||
class PseuInstanceRunnable;
|
||||
class CliRunnable;
|
||||
class RemoteController;
|
||||
|
||||
class PseuInstanceConf
|
||||
{
|
||||
public:
|
||||
|
||||
PseuInstanceConf();
|
||||
~PseuInstanceConf();
|
||||
void ApplyFromVarSet(VarSet &v);
|
||||
|
||||
|
||||
uint8 debug;
|
||||
std::string realmlist;
|
||||
std::string accname;
|
||||
std::string accpass;
|
||||
bool exitonerror;
|
||||
uint32 reconnect;
|
||||
uint16 realmport;
|
||||
uint16 worldport;
|
||||
uint8 clientversion[3];
|
||||
std::string clientversion_string;
|
||||
uint16 clientbuild;
|
||||
std::string clientlang;
|
||||
std::string realmname;
|
||||
std::string charname;
|
||||
std::string worldhost;
|
||||
uint16 networksleeptime;
|
||||
uint8 showopcodes;
|
||||
bool hidefreqopcodes;
|
||||
bool hideDisabledOpcodes;
|
||||
bool allowgamecmd;
|
||||
bool enablecli;
|
||||
bool enablechatai;
|
||||
bool notifyping;
|
||||
bool showmyopcodes;
|
||||
bool disablespellcheck;
|
||||
uint32 rmcontrolport;
|
||||
std::string rmcontrolhost;
|
||||
bool useMaps;
|
||||
bool skipaddonchat;
|
||||
|
||||
// gui related
|
||||
bool enablegui;
|
||||
// need more here
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
class PseuInstance
|
||||
{
|
||||
public:
|
||||
|
||||
PseuInstance(PseuInstanceRunnable *run);
|
||||
~PseuInstance();
|
||||
|
||||
|
||||
inline WorldSession *GetWSession(void) { return _wsession; }
|
||||
inline RealmSession *GetRSession(void) { return _rsession; }
|
||||
inline PseuInstanceConf *GetConf(void) { return _conf; }
|
||||
inline DefScriptPackage *GetScripts(void) { return _scp; }
|
||||
inline PseuInstanceRunnable *GetRunnable(void) { return _runnable; }
|
||||
inline PseuGUI *GetGUI(void) { return _gui; }
|
||||
void DeleteGUI(void);
|
||||
|
||||
inline void SetConfDir(std::string dir) { _confdir = dir; }
|
||||
inline std::string GetConfDir(void) { return _confdir; }
|
||||
inline void SetScpDir(std::string dir) { _scpdir = dir; }
|
||||
inline void SetSessionKey(BigNumber key) { _sessionkey = key; }
|
||||
inline BigNumber *GetSessionKey(void) { return &_sessionkey; }
|
||||
inline void SetError(void) { _error = true; }
|
||||
SCPDatabaseMgr dbmgr;
|
||||
|
||||
bool Init(void);
|
||||
bool InitGUI(void);
|
||||
void SaveAllCache(void);
|
||||
inline void Stop(void) { _stop = true; }
|
||||
inline bool Stopped(void) { return _stop; }
|
||||
inline void SetFastQuit(bool q=true) { _fastquit=true; }
|
||||
void Run(void);
|
||||
void Update(void);
|
||||
void Sleep(uint32 msecs);
|
||||
|
||||
inline void CreateWorldSession(void) { _createws = true; }
|
||||
|
||||
void ProcessCliQueue(void);
|
||||
void AddCliCommand(std::string);
|
||||
|
||||
private:
|
||||
|
||||
PseuInstanceRunnable *_runnable;
|
||||
RealmSession *_rsession;
|
||||
WorldSession *_wsession;
|
||||
PseuInstanceConf *_conf;
|
||||
DefScriptPackage *_scp;
|
||||
std::string _confdir,_scpdir; // _scpdir is the scripts dir, and NOT where SCP files are stored!!
|
||||
bool _initialized;
|
||||
bool _stop,_fastquit;
|
||||
bool _startrealm;
|
||||
bool _error;
|
||||
bool _createws;
|
||||
BigNumber _sessionkey;
|
||||
char *_ver,*_ver_short;
|
||||
SocketHandler _sh;
|
||||
CliRunnable *_cli;
|
||||
ZThread::Thread _clithread;
|
||||
RemoteController *_rmcontrol;
|
||||
ZThread::LockedQueue<std::string,ZThread::FastMutex> _cliQueue;
|
||||
PseuGUI *_gui;
|
||||
ZThread::Thread *_guithread;
|
||||
|
||||
};
|
||||
|
||||
class PseuInstanceRunnable : public ZThread::Runnable
|
||||
{
|
||||
public:
|
||||
PseuInstanceRunnable();
|
||||
void run(void);
|
||||
void sleep(uint32);
|
||||
inline PseuInstance *GetInstance(void) { return _i; }
|
||||
|
||||
private:
|
||||
PseuInstance *_i;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,71 +1,71 @@
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// German (Germany) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
|
||||
#ifdef _WIN32
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_ICON1 ICON "Pseu1.ico"
|
||||
#endif // German (Germany) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
// Microsoft Visual C++ generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// German (Germany) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU)
|
||||
#ifdef _WIN32
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_ICON1 ICON "Pseu1.ico"
|
||||
#endif // German (Germany) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,96 +1,96 @@
|
||||
#include "common.h"
|
||||
#include "PseuWoW.h"
|
||||
#include "ByteBuffer.h"
|
||||
#include "RealmSession.h"
|
||||
#include "RealmSocket.h"
|
||||
#include "Network/Utility.h"
|
||||
|
||||
|
||||
|
||||
|
||||
RealmSocket::RealmSocket(SocketHandler& h) : TcpSocket(h)
|
||||
{
|
||||
_session = NULL;
|
||||
_ok = false;
|
||||
}
|
||||
|
||||
RealmSocket::~RealmSocket()
|
||||
{
|
||||
this->Close();
|
||||
}
|
||||
|
||||
bool RealmSocket::IsOk(void)
|
||||
{
|
||||
return _ok;
|
||||
}
|
||||
|
||||
void RealmSocket::SetSession(RealmSession *rs)
|
||||
{
|
||||
_session = rs;
|
||||
}
|
||||
|
||||
int RealmSocket::Close(void)
|
||||
{
|
||||
_ok = false;
|
||||
return TcpSocket::Close();
|
||||
}
|
||||
|
||||
|
||||
void RealmSocket::OnRead(void)
|
||||
{
|
||||
TcpSocket::OnRead();
|
||||
uint32 len = ibuf.GetLength();
|
||||
logdev("RealmSocket::OnRead() %u bytes",len);
|
||||
if(!len)
|
||||
return;
|
||||
ByteBuffer *pkt = new ByteBuffer(len);
|
||||
uint8* data = new uint8[len];
|
||||
ibuf.Read((char*)data,len);
|
||||
pkt->append(data,len);
|
||||
delete [] data;
|
||||
_session->AddToPktQueue(pkt);
|
||||
}
|
||||
|
||||
|
||||
RealmSession *RealmSocket::GetSession(void)
|
||||
{
|
||||
return _session;
|
||||
}
|
||||
|
||||
void RealmSocket::OnAccept(void)
|
||||
{
|
||||
logdev("RealmSocket accepted.");
|
||||
}
|
||||
|
||||
void RealmSocket::OnConnect(void)
|
||||
{
|
||||
logdetail("RealmSocket connected!");
|
||||
_ok = true;
|
||||
}
|
||||
|
||||
void RealmSocket::OnConnectFailed(void)
|
||||
{
|
||||
logerror("Connecting to Realm failed!");
|
||||
_ok = false;
|
||||
}
|
||||
|
||||
void RealmSocket::OnException(void)
|
||||
{
|
||||
if(_ok)
|
||||
{
|
||||
logerror("RealmSocket: Exception!");
|
||||
_ok = false;
|
||||
}
|
||||
}
|
||||
|
||||
void RealmSocket::OnDelete(void)
|
||||
{
|
||||
_ok = false;
|
||||
_session->SetMustDie();
|
||||
}
|
||||
|
||||
uint32 RealmSocket::GetMyIP(void)
|
||||
{
|
||||
return GetRemoteIP4();
|
||||
}
|
||||
|
||||
#include "common.h"
|
||||
#include "PseuWoW.h"
|
||||
#include "ByteBuffer.h"
|
||||
#include "RealmSession.h"
|
||||
#include "RealmSocket.h"
|
||||
#include "Network/Utility.h"
|
||||
|
||||
|
||||
|
||||
|
||||
RealmSocket::RealmSocket(SocketHandler& h) : TcpSocket(h)
|
||||
{
|
||||
_session = NULL;
|
||||
_ok = false;
|
||||
}
|
||||
|
||||
RealmSocket::~RealmSocket()
|
||||
{
|
||||
this->Close();
|
||||
}
|
||||
|
||||
bool RealmSocket::IsOk(void)
|
||||
{
|
||||
return _ok;
|
||||
}
|
||||
|
||||
void RealmSocket::SetSession(RealmSession *rs)
|
||||
{
|
||||
_session = rs;
|
||||
}
|
||||
|
||||
int RealmSocket::Close(void)
|
||||
{
|
||||
_ok = false;
|
||||
return TcpSocket::Close();
|
||||
}
|
||||
|
||||
|
||||
void RealmSocket::OnRead(void)
|
||||
{
|
||||
TcpSocket::OnRead();
|
||||
uint32 len = ibuf.GetLength();
|
||||
logdev("RealmSocket::OnRead() %u bytes",len);
|
||||
if(!len)
|
||||
return;
|
||||
ByteBuffer *pkt = new ByteBuffer(len);
|
||||
uint8* data = new uint8[len];
|
||||
ibuf.Read((char*)data,len);
|
||||
pkt->append(data,len);
|
||||
delete [] data;
|
||||
_session->AddToPktQueue(pkt);
|
||||
}
|
||||
|
||||
|
||||
RealmSession *RealmSocket::GetSession(void)
|
||||
{
|
||||
return _session;
|
||||
}
|
||||
|
||||
void RealmSocket::OnAccept(void)
|
||||
{
|
||||
logdev("RealmSocket accepted.");
|
||||
}
|
||||
|
||||
void RealmSocket::OnConnect(void)
|
||||
{
|
||||
logdetail("RealmSocket connected!");
|
||||
_ok = true;
|
||||
}
|
||||
|
||||
void RealmSocket::OnConnectFailed(void)
|
||||
{
|
||||
logerror("Connecting to Realm failed!");
|
||||
_ok = false;
|
||||
}
|
||||
|
||||
void RealmSocket::OnException(void)
|
||||
{
|
||||
if(_ok)
|
||||
{
|
||||
logerror("RealmSocket: Exception!");
|
||||
_ok = false;
|
||||
}
|
||||
}
|
||||
|
||||
void RealmSocket::OnDelete(void)
|
||||
{
|
||||
_ok = false;
|
||||
_session->SetMustDie();
|
||||
}
|
||||
|
||||
uint32 RealmSocket::GetMyIP(void)
|
||||
{
|
||||
return GetRemoteIP4();
|
||||
}
|
||||
|
||||
|
||||
@ -1,38 +1,38 @@
|
||||
#include "common.h"
|
||||
#include "log.h"
|
||||
#include "ControlSocket.h"
|
||||
#include "Network/ListenSocket.h"
|
||||
#include "RemoteController.h"
|
||||
|
||||
RemoteController::RemoteController(PseuInstance *in,uint32 port)
|
||||
{
|
||||
DEBUG(logdebug("RemoteController: setting instance = %X",in));
|
||||
h.SetInstance(in);
|
||||
_mustdie = false;
|
||||
_instance = in;
|
||||
ListenSocket<ControlSocket> *ls = new ListenSocket<ControlSocket>(h);
|
||||
if(ls->Bind(port))
|
||||
{
|
||||
logerror("RemoteController: Can't bind to port %u",port);
|
||||
_mustdie = true;
|
||||
return;
|
||||
}
|
||||
h.Add(ls);
|
||||
log("RemoteController: listening on port %u",port);
|
||||
}
|
||||
|
||||
RemoteController::~RemoteController()
|
||||
{
|
||||
DEBUG(logdebug("~RemoteController()"));
|
||||
}
|
||||
|
||||
void RemoteController::Update(void)
|
||||
{
|
||||
if(_mustdie)
|
||||
return;
|
||||
h.Select(0,0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#include "common.h"
|
||||
#include "log.h"
|
||||
#include "ControlSocket.h"
|
||||
#include "Network/ListenSocket.h"
|
||||
#include "RemoteController.h"
|
||||
|
||||
RemoteController::RemoteController(PseuInstance *in,uint32 port)
|
||||
{
|
||||
DEBUG(logdebug("RemoteController: setting instance = %X",in));
|
||||
h.SetInstance(in);
|
||||
_mustdie = false;
|
||||
_instance = in;
|
||||
ListenSocket<ControlSocket> *ls = new ListenSocket<ControlSocket>(h);
|
||||
if(ls->Bind(port))
|
||||
{
|
||||
logerror("RemoteController: Can't bind to port %u",port);
|
||||
_mustdie = true;
|
||||
return;
|
||||
}
|
||||
h.Add(ls);
|
||||
log("RemoteController: listening on port %u",port);
|
||||
}
|
||||
|
||||
RemoteController::~RemoteController()
|
||||
{
|
||||
DEBUG(logdebug("~RemoteController()"));
|
||||
}
|
||||
|
||||
void RemoteController::Update(void)
|
||||
{
|
||||
if(_mustdie)
|
||||
return;
|
||||
h.Select(0,0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,210 +1,210 @@
|
||||
#include <fstream>
|
||||
#include "common.h"
|
||||
#include "SCPDatabase.h"
|
||||
|
||||
|
||||
uint32 SCPDatabase::LoadFromFile(char *fn)
|
||||
{
|
||||
std::fstream fh;
|
||||
uint32 size = GetFileSize(fn);
|
||||
if(!size)
|
||||
return 0;
|
||||
|
||||
fh.open(fn,std::ios_base::in | std::ios_base::binary);
|
||||
if( !fh.is_open() )
|
||||
return 0;
|
||||
|
||||
char *buf = new char[size];
|
||||
fh.read(buf,size);
|
||||
fh.close();
|
||||
|
||||
uint32 sections = LoadFromMem(buf,size);
|
||||
delete [] buf;
|
||||
return sections;
|
||||
}
|
||||
|
||||
|
||||
uint32 SCPDatabase::LoadFromMem(char *buf, uint32 size)
|
||||
{
|
||||
std::string line,value,entry,storage;
|
||||
uint32 id=0,sections=0;
|
||||
|
||||
for(uint32 pos = 0; pos < size; pos++)
|
||||
{
|
||||
if(buf[pos] == '\n')
|
||||
{
|
||||
if(line.empty())
|
||||
continue;
|
||||
while(line[0]==' ' || line[0]=='\t')
|
||||
line.erase(0,1);
|
||||
if(line.empty() || (line.length() > 1 && (line[0]=='#' || (line[0]=='/' && line[1]=='/'))) )
|
||||
{
|
||||
line.clear();
|
||||
continue;
|
||||
}
|
||||
if(line[line.size()-1] == 13 || line[line.size()-1] == 10) // this fixes the annoying newline problems on windows + binary mode
|
||||
line[line.size()-1] = 0;
|
||||
if(line[0]=='[')
|
||||
{
|
||||
id=(uint32)toInt(line.c_str()+1); // start reading after '['
|
||||
sections++;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 pos=line.find("=");
|
||||
if(pos!=std::string::npos)
|
||||
{
|
||||
entry=stringToLower(line.substr(0,pos));
|
||||
value=line.substr(pos+1,line.length()-1);
|
||||
_map[id].Set(entry,value);
|
||||
}
|
||||
// else invalid line, must have '='
|
||||
}
|
||||
line.clear();
|
||||
}
|
||||
else
|
||||
line += buf[pos]; // fill up line until a newline is reached (see above)
|
||||
}
|
||||
return sections;
|
||||
}
|
||||
|
||||
bool SCPDatabase::HasField(uint32 id)
|
||||
{
|
||||
for(SCPFieldMap::iterator i = _map.begin(); i != _map.end(); i++)
|
||||
if(i->first == id)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SCPField::HasEntry(std::string e)
|
||||
{
|
||||
for(SCPEntryMap::iterator i = _map.begin(); i != _map.end(); i++)
|
||||
{
|
||||
std::string ch = i->first;
|
||||
if(ch == e)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string SCPField::GetString(std::string entry)
|
||||
{
|
||||
//return HasEntry(entry) ? _map[entry] : "";
|
||||
return _map[entry];
|
||||
}
|
||||
|
||||
// note that this can take a while depending on the size of the database!
|
||||
uint32 SCPDatabase::GetFieldByValue(std::string entry, std::string value)
|
||||
{
|
||||
for(SCPFieldMap::iterator fm = _map.begin(); fm != _map.end(); fm++)
|
||||
if(fm->second.HasEntry(entry) && fm->second.GetString(entry)==value)
|
||||
return fm->first;
|
||||
return uint32(-1);
|
||||
}
|
||||
|
||||
bool SCPDatabaseMgr::HasDB(std::string n)
|
||||
{
|
||||
for(SCPDatabaseMap::iterator i = _map.begin(); i != _map.end(); i++)
|
||||
if(i->first == n)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
SCPDatabase& SCPDatabaseMgr::GetDB(std::string n)
|
||||
{
|
||||
return _map[n];
|
||||
}
|
||||
|
||||
uint32 SCPDatabaseMgr::AutoLoadFile(char *fn)
|
||||
{
|
||||
std::fstream fh;
|
||||
uint32 size = GetFileSize(fn);
|
||||
if(!size)
|
||||
return 0;
|
||||
|
||||
fh.open(fn,std::ios_base::in | std::ios_base::binary);
|
||||
if( !fh.is_open() )
|
||||
return 0;
|
||||
|
||||
char *buf = new char[size];
|
||||
|
||||
fh.read(buf,size);
|
||||
fh.close();
|
||||
|
||||
std::string line,dbname;
|
||||
for(uint32 pos = 0; pos < size; pos++)
|
||||
{
|
||||
if(buf[pos] == '\n')
|
||||
{
|
||||
if(line.empty())
|
||||
continue;
|
||||
while(line[0]==' ' || line[0]=='\t')
|
||||
line.erase(0,1);
|
||||
if(line[0] == '#')
|
||||
{
|
||||
uint32 eq = line.find("=");
|
||||
if(eq != std::string::npos)
|
||||
{
|
||||
std::string info = stringToLower(line.substr(0,pos));
|
||||
std::string value = stringToLower(line.substr(pos+1,line.length()-1));
|
||||
if(info == "#dbname")
|
||||
{
|
||||
dbname = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
line += buf[pos];
|
||||
}
|
||||
delete [] buf;
|
||||
|
||||
if(dbname.empty())
|
||||
return 0;
|
||||
|
||||
uint32 sections = GetDB(dbname).LoadFromMem(buf,size);
|
||||
return sections;
|
||||
|
||||
}
|
||||
|
||||
// -- helper functions -- //
|
||||
|
||||
std::string SCPDatabaseMgr::GetZoneName(uint32 id)
|
||||
{
|
||||
return GetDB("zone").GetField(id).GetString("name");
|
||||
}
|
||||
|
||||
std::string SCPDatabaseMgr::GetRaceName(uint32 id)
|
||||
{
|
||||
std::string r = GetDB("race").GetField(id).GetString("name");
|
||||
//if(r.empty())
|
||||
// r = raceName[id];
|
||||
return r;
|
||||
}
|
||||
|
||||
std::string SCPDatabaseMgr::GetMapName(uint32 id)
|
||||
{
|
||||
return GetDB("map").GetField(id).GetString("name");
|
||||
}
|
||||
|
||||
std::string SCPDatabaseMgr::GetClassName_(uint32 id)
|
||||
{
|
||||
std::string r = GetDB("class").GetField(id).GetString("name");
|
||||
//if(r.empty())
|
||||
// r = className[id];
|
||||
return r;
|
||||
}
|
||||
|
||||
std::string SCPDatabaseMgr::GetGenderName(uint32 id)
|
||||
{
|
||||
return GetDB("gender").GetField(id).GetString("name");
|
||||
}
|
||||
|
||||
std::string SCPDatabaseMgr::GetLangName(uint32 id)
|
||||
{
|
||||
std::string r = GetDB("language").GetField(id).GetString("name");
|
||||
//if(r.empty())
|
||||
// r = LookupName(id,langNames);
|
||||
return r;
|
||||
}
|
||||
#include <fstream>
|
||||
#include "common.h"
|
||||
#include "SCPDatabase.h"
|
||||
|
||||
|
||||
uint32 SCPDatabase::LoadFromFile(char *fn)
|
||||
{
|
||||
std::fstream fh;
|
||||
uint32 size = GetFileSize(fn);
|
||||
if(!size)
|
||||
return 0;
|
||||
|
||||
fh.open(fn,std::ios_base::in | std::ios_base::binary);
|
||||
if( !fh.is_open() )
|
||||
return 0;
|
||||
|
||||
char *buf = new char[size];
|
||||
fh.read(buf,size);
|
||||
fh.close();
|
||||
|
||||
uint32 sections = LoadFromMem(buf,size);
|
||||
delete [] buf;
|
||||
return sections;
|
||||
}
|
||||
|
||||
|
||||
uint32 SCPDatabase::LoadFromMem(char *buf, uint32 size)
|
||||
{
|
||||
std::string line,value,entry,storage;
|
||||
uint32 id=0,sections=0;
|
||||
|
||||
for(uint32 pos = 0; pos < size; pos++)
|
||||
{
|
||||
if(buf[pos] == '\n')
|
||||
{
|
||||
if(line.empty())
|
||||
continue;
|
||||
while(line[0]==' ' || line[0]=='\t')
|
||||
line.erase(0,1);
|
||||
if(line.empty() || (line.length() > 1 && (line[0]=='#' || (line[0]=='/' && line[1]=='/'))) )
|
||||
{
|
||||
line.clear();
|
||||
continue;
|
||||
}
|
||||
if(line[line.size()-1] == 13 || line[line.size()-1] == 10) // this fixes the annoying newline problems on windows + binary mode
|
||||
line[line.size()-1] = 0;
|
||||
if(line[0]=='[')
|
||||
{
|
||||
id=(uint32)toInt(line.c_str()+1); // start reading after '['
|
||||
sections++;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32 pos=line.find("=");
|
||||
if(pos!=std::string::npos)
|
||||
{
|
||||
entry=stringToLower(line.substr(0,pos));
|
||||
value=line.substr(pos+1,line.length()-1);
|
||||
_map[id].Set(entry,value);
|
||||
}
|
||||
// else invalid line, must have '='
|
||||
}
|
||||
line.clear();
|
||||
}
|
||||
else
|
||||
line += buf[pos]; // fill up line until a newline is reached (see above)
|
||||
}
|
||||
return sections;
|
||||
}
|
||||
|
||||
bool SCPDatabase::HasField(uint32 id)
|
||||
{
|
||||
for(SCPFieldMap::iterator i = _map.begin(); i != _map.end(); i++)
|
||||
if(i->first == id)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
bool SCPField::HasEntry(std::string e)
|
||||
{
|
||||
for(SCPEntryMap::iterator i = _map.begin(); i != _map.end(); i++)
|
||||
{
|
||||
std::string ch = i->first;
|
||||
if(ch == e)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string SCPField::GetString(std::string entry)
|
||||
{
|
||||
//return HasEntry(entry) ? _map[entry] : "";
|
||||
return _map[entry];
|
||||
}
|
||||
|
||||
// note that this can take a while depending on the size of the database!
|
||||
uint32 SCPDatabase::GetFieldByValue(std::string entry, std::string value)
|
||||
{
|
||||
for(SCPFieldMap::iterator fm = _map.begin(); fm != _map.end(); fm++)
|
||||
if(fm->second.HasEntry(entry) && fm->second.GetString(entry)==value)
|
||||
return fm->first;
|
||||
return uint32(-1);
|
||||
}
|
||||
|
||||
bool SCPDatabaseMgr::HasDB(std::string n)
|
||||
{
|
||||
for(SCPDatabaseMap::iterator i = _map.begin(); i != _map.end(); i++)
|
||||
if(i->first == n)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
SCPDatabase& SCPDatabaseMgr::GetDB(std::string n)
|
||||
{
|
||||
return _map[n];
|
||||
}
|
||||
|
||||
uint32 SCPDatabaseMgr::AutoLoadFile(char *fn)
|
||||
{
|
||||
std::fstream fh;
|
||||
uint32 size = GetFileSize(fn);
|
||||
if(!size)
|
||||
return 0;
|
||||
|
||||
fh.open(fn,std::ios_base::in | std::ios_base::binary);
|
||||
if( !fh.is_open() )
|
||||
return 0;
|
||||
|
||||
char *buf = new char[size];
|
||||
|
||||
fh.read(buf,size);
|
||||
fh.close();
|
||||
|
||||
std::string line,dbname;
|
||||
for(uint32 pos = 0; pos < size; pos++)
|
||||
{
|
||||
if(buf[pos] == '\n')
|
||||
{
|
||||
if(line.empty())
|
||||
continue;
|
||||
while(line[0]==' ' || line[0]=='\t')
|
||||
line.erase(0,1);
|
||||
if(line[0] == '#')
|
||||
{
|
||||
uint32 eq = line.find("=");
|
||||
if(eq != std::string::npos)
|
||||
{
|
||||
std::string info = stringToLower(line.substr(0,pos));
|
||||
std::string value = stringToLower(line.substr(pos+1,line.length()-1));
|
||||
if(info == "#dbname")
|
||||
{
|
||||
dbname = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
line += buf[pos];
|
||||
}
|
||||
delete [] buf;
|
||||
|
||||
if(dbname.empty())
|
||||
return 0;
|
||||
|
||||
uint32 sections = GetDB(dbname).LoadFromMem(buf,size);
|
||||
return sections;
|
||||
|
||||
}
|
||||
|
||||
// -- helper functions -- //
|
||||
|
||||
std::string SCPDatabaseMgr::GetZoneName(uint32 id)
|
||||
{
|
||||
return GetDB("zone").GetField(id).GetString("name");
|
||||
}
|
||||
|
||||
std::string SCPDatabaseMgr::GetRaceName(uint32 id)
|
||||
{
|
||||
std::string r = GetDB("race").GetField(id).GetString("name");
|
||||
//if(r.empty())
|
||||
// r = raceName[id];
|
||||
return r;
|
||||
}
|
||||
|
||||
std::string SCPDatabaseMgr::GetMapName(uint32 id)
|
||||
{
|
||||
return GetDB("map").GetField(id).GetString("name");
|
||||
}
|
||||
|
||||
std::string SCPDatabaseMgr::GetClassName_(uint32 id)
|
||||
{
|
||||
std::string r = GetDB("class").GetField(id).GetString("name");
|
||||
//if(r.empty())
|
||||
// r = className[id];
|
||||
return r;
|
||||
}
|
||||
|
||||
std::string SCPDatabaseMgr::GetGenderName(uint32 id)
|
||||
{
|
||||
return GetDB("gender").GetField(id).GetString("name");
|
||||
}
|
||||
|
||||
std::string SCPDatabaseMgr::GetLangName(uint32 id)
|
||||
{
|
||||
std::string r = GetDB("language").GetField(id).GetString("name");
|
||||
//if(r.empty())
|
||||
// r = LookupName(id,langNames);
|
||||
return r;
|
||||
}
|
||||
|
||||
@ -1,116 +1,116 @@
|
||||
#ifndef _SCPDATABASE_H
|
||||
#define _SCPDATABASE_H
|
||||
|
||||
#include <map>
|
||||
|
||||
/*
|
||||
* Some preparations for compiled databases. i will continue this later. [FG]
|
||||
|
||||
enum SCPTypes
|
||||
{
|
||||
SCP_TYPE_STRING = 0,
|
||||
SCP_TYPE_INT,
|
||||
SCP_TYPE_UINT,
|
||||
SCP_TYPE_FLOAT
|
||||
};
|
||||
|
||||
class SCPEntry
|
||||
{
|
||||
private:
|
||||
char *str;
|
||||
|
||||
public:
|
||||
|
||||
SCPEntry() { str = NULL; }
|
||||
~SCPEntry() { if(str) delete [] str; }
|
||||
|
||||
union
|
||||
{
|
||||
int32 intvalue
|
||||
uint32 uintvalue;
|
||||
float floatvalue;
|
||||
};
|
||||
|
||||
inline char *GetString(uint8 type)
|
||||
{
|
||||
if(str)
|
||||
return str;
|
||||
else
|
||||
{
|
||||
char buf[25];
|
||||
char *fmt;
|
||||
switch (type)
|
||||
{
|
||||
case SCP_TYPE_INT: sprintf(buf,"%d",intvalue); break;
|
||||
case SCP_TYPE_UINT: sprintf(buf,"%u",uintvalue); break;
|
||||
case SCP_TYPE_FLOAT: sprintf(buf,"%f",floatvalue); break;
|
||||
}
|
||||
str = new char[strlen(buf) + 1];
|
||||
memcpy(str,buf,strlen(buf) + 1);
|
||||
return str;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
typedef std::map<std::string,std::string> SCPEntryMap;
|
||||
|
||||
class SCPField
|
||||
{
|
||||
public:
|
||||
std::string GetString(std::string);
|
||||
inline uint64 GetInteger(std::string entry) { return toInt(GetString(entry)); }
|
||||
inline double GetDouble(std::string entry) { return strtod(GetString(entry).c_str(),NULL); }
|
||||
inline void Set(std::string entry,std::string value) { _map[entry]=value; }
|
||||
bool HasEntry(std::string);
|
||||
|
||||
private:
|
||||
SCPEntryMap _map;
|
||||
};
|
||||
|
||||
typedef std::map<uint32,SCPField> SCPFieldMap;
|
||||
|
||||
|
||||
class SCPDatabase
|
||||
{
|
||||
public:
|
||||
inline SCPField& GetField(uint32 id) { return _map[id]; }
|
||||
bool HasField(uint32 id);
|
||||
uint32 LoadFromFile(char*);
|
||||
uint32 LoadFromMem(char*,uint32);
|
||||
uint32 GetFieldByValue(std::string entry, std::string value);
|
||||
|
||||
private:
|
||||
SCPFieldMap _map;
|
||||
|
||||
};
|
||||
|
||||
typedef std::map<std::string,SCPDatabase> SCPDatabaseMap;
|
||||
|
||||
class SCPDatabaseMgr
|
||||
{
|
||||
public:
|
||||
bool HasDB(std::string);
|
||||
SCPDatabase& GetDB(std::string);
|
||||
uint32 AutoLoadFile(char *fn);
|
||||
inline void DropDB(std::string s) { _map.erase(stringToLower(s)); }
|
||||
|
||||
//////////////////////
|
||||
// helper functions //
|
||||
//////////////////////
|
||||
std::string GetZoneName(uint32 id);
|
||||
std::string GetRaceName(uint32 id);
|
||||
std::string GetClassName_(uint32 id);
|
||||
std::string GetGenderName(uint32 id);
|
||||
std::string GetMapName(uint32 id);
|
||||
std::string GetLangName(uint32 id);
|
||||
|
||||
private:
|
||||
SCPDatabaseMap _map;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
#ifndef _SCPDATABASE_H
|
||||
#define _SCPDATABASE_H
|
||||
|
||||
#include <map>
|
||||
|
||||
/*
|
||||
* Some preparations for compiled databases. i will continue this later. [FG]
|
||||
|
||||
enum SCPTypes
|
||||
{
|
||||
SCP_TYPE_STRING = 0,
|
||||
SCP_TYPE_INT,
|
||||
SCP_TYPE_UINT,
|
||||
SCP_TYPE_FLOAT
|
||||
};
|
||||
|
||||
class SCPEntry
|
||||
{
|
||||
private:
|
||||
char *str;
|
||||
|
||||
public:
|
||||
|
||||
SCPEntry() { str = NULL; }
|
||||
~SCPEntry() { if(str) delete [] str; }
|
||||
|
||||
union
|
||||
{
|
||||
int32 intvalue
|
||||
uint32 uintvalue;
|
||||
float floatvalue;
|
||||
};
|
||||
|
||||
inline char *GetString(uint8 type)
|
||||
{
|
||||
if(str)
|
||||
return str;
|
||||
else
|
||||
{
|
||||
char buf[25];
|
||||
char *fmt;
|
||||
switch (type)
|
||||
{
|
||||
case SCP_TYPE_INT: sprintf(buf,"%d",intvalue); break;
|
||||
case SCP_TYPE_UINT: sprintf(buf,"%u",uintvalue); break;
|
||||
case SCP_TYPE_FLOAT: sprintf(buf,"%f",floatvalue); break;
|
||||
}
|
||||
str = new char[strlen(buf) + 1];
|
||||
memcpy(str,buf,strlen(buf) + 1);
|
||||
return str;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
*/
|
||||
|
||||
typedef std::map<std::string,std::string> SCPEntryMap;
|
||||
|
||||
class SCPField
|
||||
{
|
||||
public:
|
||||
std::string GetString(std::string);
|
||||
inline uint64 GetInteger(std::string entry) { return toInt(GetString(entry)); }
|
||||
inline double GetDouble(std::string entry) { return strtod(GetString(entry).c_str(),NULL); }
|
||||
inline void Set(std::string entry,std::string value) { _map[entry]=value; }
|
||||
bool HasEntry(std::string);
|
||||
|
||||
private:
|
||||
SCPEntryMap _map;
|
||||
};
|
||||
|
||||
typedef std::map<uint32,SCPField> SCPFieldMap;
|
||||
|
||||
|
||||
class SCPDatabase
|
||||
{
|
||||
public:
|
||||
inline SCPField& GetField(uint32 id) { return _map[id]; }
|
||||
bool HasField(uint32 id);
|
||||
uint32 LoadFromFile(char*);
|
||||
uint32 LoadFromMem(char*,uint32);
|
||||
uint32 GetFieldByValue(std::string entry, std::string value);
|
||||
|
||||
private:
|
||||
SCPFieldMap _map;
|
||||
|
||||
};
|
||||
|
||||
typedef std::map<std::string,SCPDatabase> SCPDatabaseMap;
|
||||
|
||||
class SCPDatabaseMgr
|
||||
{
|
||||
public:
|
||||
bool HasDB(std::string);
|
||||
SCPDatabase& GetDB(std::string);
|
||||
uint32 AutoLoadFile(char *fn);
|
||||
inline void DropDB(std::string s) { _map.erase(stringToLower(s)); }
|
||||
|
||||
//////////////////////
|
||||
// helper functions //
|
||||
//////////////////////
|
||||
std::string GetZoneName(uint32 id);
|
||||
std::string GetRaceName(uint32 id);
|
||||
std::string GetClassName_(uint32 id);
|
||||
std::string GetGenderName(uint32 id);
|
||||
std::string GetMapName(uint32 id);
|
||||
std::string GetLangName(uint32 id);
|
||||
|
||||
private:
|
||||
SCPDatabaseMap _map;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,18 +1,18 @@
|
||||
#ifndef _BAG_H
|
||||
#define _BAG_H
|
||||
|
||||
#include "common.h"
|
||||
#include "Item.h"
|
||||
|
||||
class Bag : public Item
|
||||
{
|
||||
public:
|
||||
Bag();
|
||||
void Create(uint64);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
#ifndef _BAG_H
|
||||
#define _BAG_H
|
||||
|
||||
#include "common.h"
|
||||
#include "Item.h"
|
||||
|
||||
class Bag : public Item
|
||||
{
|
||||
public:
|
||||
Bag();
|
||||
void Create(uint64);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,196 +1,196 @@
|
||||
#include "common.h"
|
||||
#include "PseuWoW.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "Opcodes.h"
|
||||
#include "Player.h"
|
||||
#include "WorldSession.h"
|
||||
#include "Channel.h"
|
||||
|
||||
void WorldSession::SendChatMessage(uint32 type, uint32 lang, std::string msg, std::string to)
|
||||
{
|
||||
if((!_logged) || msg.empty())
|
||||
return;
|
||||
WorldPacket packet;
|
||||
packet << type << lang;
|
||||
switch(type){
|
||||
case CHAT_MSG_WHISPER:
|
||||
if(to.empty())
|
||||
return;
|
||||
packet << to << msg;
|
||||
break;
|
||||
case CHAT_MSG_CHANNEL:
|
||||
if(to.empty() /*|| !_channels->IsOnChannel(to)*/)
|
||||
return;
|
||||
packet << to << msg;
|
||||
break;
|
||||
default:
|
||||
packet << msg;
|
||||
}
|
||||
packet.SetOpcode(CMSG_MESSAGECHAT);
|
||||
SendWorldPacket(packet);
|
||||
}
|
||||
|
||||
void WorldSession::SendQueryPlayerName(uint64 guid)
|
||||
{
|
||||
if((!_logged) || guid==0)
|
||||
return;
|
||||
WorldPacket packet;
|
||||
packet << guid;
|
||||
packet.SetOpcode(CMSG_NAME_QUERY);
|
||||
SendWorldPacket(packet);
|
||||
// to prevent opcode spam, we need to make a list with already requested names
|
||||
}
|
||||
|
||||
void WorldSession::SendPing(uint32 ping)
|
||||
{
|
||||
if(!_logged)
|
||||
return;
|
||||
WorldPacket packet;
|
||||
packet << ping;
|
||||
packet << GetLagMS();
|
||||
packet.SetOpcode(CMSG_PING);
|
||||
SendWorldPacket(packet);
|
||||
}
|
||||
|
||||
void WorldSession::SendEmote(uint32 id)
|
||||
{
|
||||
if(!_logged)
|
||||
return;
|
||||
WorldPacket packet;
|
||||
int32 variation = 0; // randomized usually
|
||||
packet << id << (uint32)variation << GetMyChar()->GetTarget();
|
||||
packet.SetOpcode(CMSG_TEXT_EMOTE);
|
||||
SendWorldPacket(packet);
|
||||
}
|
||||
|
||||
void WorldSession::SendQueryItem(uint32 entry, uint64 guid) // is it a guid? not sure
|
||||
{
|
||||
if(objmgr.ItemNonExistent(entry))
|
||||
{
|
||||
logdebug("Skipped query of item %u (was marked as nonexistent before)",entry);
|
||||
return;
|
||||
}
|
||||
logdebug("Sending Item query, id=%u",entry);
|
||||
WorldPacket packet;
|
||||
packet << entry << guid;
|
||||
packet.SetOpcode(CMSG_ITEM_QUERY_SINGLE);
|
||||
SendWorldPacket(packet);
|
||||
}
|
||||
|
||||
// use ONLY this function to target objects and notify the server about it.
|
||||
// (server & client need to stay synced)
|
||||
void WorldSession::SendSetSelection(uint64 guid)
|
||||
{
|
||||
ASSERT(GetMyChar()) // we need to be logged in to select something
|
||||
if(guid==GetMyChar()->GetTarget())
|
||||
return; // no need to select already selected target
|
||||
GetMyChar()->SetTarget(guid);
|
||||
logdebug("SetSelection GUID="I64FMT,guid);
|
||||
WorldPacket packet;
|
||||
packet << guid;
|
||||
packet.SetOpcode(CMSG_SET_SELECTION);
|
||||
SendWorldPacket(packet);
|
||||
}
|
||||
|
||||
void WorldSession::SendCastSpell(uint32 spellid, bool nocheck)
|
||||
{
|
||||
if(!spellid)
|
||||
return;
|
||||
MyCharacter *my = GetMyChar();
|
||||
bool known = nocheck ? true : my->HasSpell(spellid);
|
||||
|
||||
//-- TEMP FIX --// TODO: need a list of spells that is excluded from the check and can always be casted.
|
||||
// settable via DefScript?
|
||||
if(spellid==836)
|
||||
known=true;
|
||||
|
||||
if( (!known) && (!GetInstance()->GetConf()->disablespellcheck) )
|
||||
{
|
||||
logerror("Attempt to cast not-known spell %u",spellid);
|
||||
return;
|
||||
}
|
||||
|
||||
Object *target = objmgr.GetObj(my->GetTarget());
|
||||
|
||||
//if(!target) // this is wrong, some spells dont require a target (areaspells, self-only spells)
|
||||
// return; // but for now, this should be ok, until a db is used that provides spell info
|
||||
|
||||
WorldPacket packet;
|
||||
ByteBuffer temp;
|
||||
uint16 flags=TARGET_FLAG_SELF; // target mask. spellcast implementeation needs to be changed if TARGET_MASK_SELF is != 0
|
||||
packet << spellid;
|
||||
packet << (uint8)0; // unk
|
||||
if(target && my->GetTarget() != GetGuid()) // self cast?
|
||||
{
|
||||
if(target->GetTypeId() == TYPEID_PLAYER || target->GetTypeId() == TYPEID_UNIT)
|
||||
{
|
||||
flags |= TARGET_FLAG_UNIT;
|
||||
temp << (uint8)0xFF << my->GetTarget(); // need to send packed guid?
|
||||
}
|
||||
if(target->GetTypeId() == TYPEID_OBJECT)
|
||||
{
|
||||
flags |= TARGET_FLAG_OBJECT;
|
||||
temp << (uint8)0xFF <<my->GetTarget(); // need to send packed guid?
|
||||
}
|
||||
// TODO: need implementation of areaspells & item targets (enchant) here (temp << itemGUID)!
|
||||
// TODO: append floats x,y,z according to target type srcloc & dstloc to temp
|
||||
// TODO: append string to temp if TARGET_FLAG_STRING is set. what string for what purpose??
|
||||
// and whats with TARGET_CORPSE?
|
||||
}
|
||||
packet << flags;
|
||||
packet.append(temp);
|
||||
|
||||
// cast it
|
||||
packet.SetOpcode(CMSG_CAST_SPELL);
|
||||
SendWorldPacket(packet);
|
||||
logdetail("Casting spell %u on target "I64FMT,spellid,my->GetTarget());
|
||||
if(!known)
|
||||
logcustom(1,LRED," - WARNING: spell is NOT known!");
|
||||
}
|
||||
|
||||
void WorldSession::SendWhoListRequest(uint32 minlvl, uint32 maxlvl, uint32 racemask, uint32 classmask, std::string name, std::string guildname, std::vector<uint32> *zonelist, std::vector<std::string> *strlist)
|
||||
{
|
||||
WorldPacket pkt(CMSG_WHO, 50); // guess size
|
||||
pkt << minlvl;
|
||||
pkt << maxlvl;
|
||||
pkt << name;
|
||||
pkt << guildname;
|
||||
pkt << racemask;
|
||||
pkt << classmask;
|
||||
|
||||
if(zonelist)
|
||||
{
|
||||
pkt << (uint32)zonelist->size();
|
||||
for(uint32 i = 0; i < zonelist->size(); i++)
|
||||
pkt << (*zonelist)[i];
|
||||
}
|
||||
else
|
||||
pkt << uint32(0);
|
||||
|
||||
if(strlist)
|
||||
{
|
||||
pkt << (uint32)strlist->size();
|
||||
for(uint32 i = 0; i < strlist->size(); i++)
|
||||
pkt << (*strlist)[i];
|
||||
}
|
||||
else
|
||||
pkt << uint32(0);
|
||||
|
||||
SendWorldPacket(pkt);
|
||||
}
|
||||
|
||||
void WorldSession::SendQueryCreature(uint32 entry, uint64 guid)
|
||||
{
|
||||
if(objmgr.CreatureNonExistent(entry))
|
||||
{
|
||||
logdebug("Skipped query of creature %u (was marked as nonexistent before)",entry);
|
||||
return;
|
||||
}
|
||||
logdebug("Sending creature query, id=%u",entry);
|
||||
WorldPacket wp(CMSG_CREATURE_QUERY,4+8);
|
||||
wp << entry << guid;
|
||||
SendWorldPacket(wp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#include "common.h"
|
||||
#include "PseuWoW.h"
|
||||
#include "WorldPacket.h"
|
||||
#include "Opcodes.h"
|
||||
#include "Player.h"
|
||||
#include "WorldSession.h"
|
||||
#include "Channel.h"
|
||||
|
||||
void WorldSession::SendChatMessage(uint32 type, uint32 lang, std::string msg, std::string to)
|
||||
{
|
||||
if((!_logged) || msg.empty())
|
||||
return;
|
||||
WorldPacket packet;
|
||||
packet << type << lang;
|
||||
switch(type){
|
||||
case CHAT_MSG_WHISPER:
|
||||
if(to.empty())
|
||||
return;
|
||||
packet << to << msg;
|
||||
break;
|
||||
case CHAT_MSG_CHANNEL:
|
||||
if(to.empty() /*|| !_channels->IsOnChannel(to)*/)
|
||||
return;
|
||||
packet << to << msg;
|
||||
break;
|
||||
default:
|
||||
packet << msg;
|
||||
}
|
||||
packet.SetOpcode(CMSG_MESSAGECHAT);
|
||||
SendWorldPacket(packet);
|
||||
}
|
||||
|
||||
void WorldSession::SendQueryPlayerName(uint64 guid)
|
||||
{
|
||||
if((!_logged) || guid==0)
|
||||
return;
|
||||
WorldPacket packet;
|
||||
packet << guid;
|
||||
packet.SetOpcode(CMSG_NAME_QUERY);
|
||||
SendWorldPacket(packet);
|
||||
// to prevent opcode spam, we need to make a list with already requested names
|
||||
}
|
||||
|
||||
void WorldSession::SendPing(uint32 ping)
|
||||
{
|
||||
if(!_logged)
|
||||
return;
|
||||
WorldPacket packet;
|
||||
packet << ping;
|
||||
packet << GetLagMS();
|
||||
packet.SetOpcode(CMSG_PING);
|
||||
SendWorldPacket(packet);
|
||||
}
|
||||
|
||||
void WorldSession::SendEmote(uint32 id)
|
||||
{
|
||||
if(!_logged)
|
||||
return;
|
||||
WorldPacket packet;
|
||||
int32 variation = 0; // randomized usually
|
||||
packet << id << (uint32)variation << GetMyChar()->GetTarget();
|
||||
packet.SetOpcode(CMSG_TEXT_EMOTE);
|
||||
SendWorldPacket(packet);
|
||||
}
|
||||
|
||||
void WorldSession::SendQueryItem(uint32 entry, uint64 guid) // is it a guid? not sure
|
||||
{
|
||||
if(objmgr.ItemNonExistent(entry))
|
||||
{
|
||||
logdebug("Skipped query of item %u (was marked as nonexistent before)",entry);
|
||||
return;
|
||||
}
|
||||
logdebug("Sending Item query, id=%u",entry);
|
||||
WorldPacket packet;
|
||||
packet << entry << guid;
|
||||
packet.SetOpcode(CMSG_ITEM_QUERY_SINGLE);
|
||||
SendWorldPacket(packet);
|
||||
}
|
||||
|
||||
// use ONLY this function to target objects and notify the server about it.
|
||||
// (server & client need to stay synced)
|
||||
void WorldSession::SendSetSelection(uint64 guid)
|
||||
{
|
||||
ASSERT(GetMyChar()) // we need to be logged in to select something
|
||||
if(guid==GetMyChar()->GetTarget())
|
||||
return; // no need to select already selected target
|
||||
GetMyChar()->SetTarget(guid);
|
||||
logdebug("SetSelection GUID="I64FMT,guid);
|
||||
WorldPacket packet;
|
||||
packet << guid;
|
||||
packet.SetOpcode(CMSG_SET_SELECTION);
|
||||
SendWorldPacket(packet);
|
||||
}
|
||||
|
||||
void WorldSession::SendCastSpell(uint32 spellid, bool nocheck)
|
||||
{
|
||||
if(!spellid)
|
||||
return;
|
||||
MyCharacter *my = GetMyChar();
|
||||
bool known = nocheck ? true : my->HasSpell(spellid);
|
||||
|
||||
//-- TEMP FIX --// TODO: need a list of spells that is excluded from the check and can always be casted.
|
||||
// settable via DefScript?
|
||||
if(spellid==836)
|
||||
known=true;
|
||||
|
||||
if( (!known) && (!GetInstance()->GetConf()->disablespellcheck) )
|
||||
{
|
||||
logerror("Attempt to cast not-known spell %u",spellid);
|
||||
return;
|
||||
}
|
||||
|
||||
Object *target = objmgr.GetObj(my->GetTarget());
|
||||
|
||||
//if(!target) // this is wrong, some spells dont require a target (areaspells, self-only spells)
|
||||
// return; // but for now, this should be ok, until a db is used that provides spell info
|
||||
|
||||
WorldPacket packet;
|
||||
ByteBuffer temp;
|
||||
uint16 flags=TARGET_FLAG_SELF; // target mask. spellcast implementeation needs to be changed if TARGET_MASK_SELF is != 0
|
||||
packet << spellid;
|
||||
packet << (uint8)0; // unk
|
||||
if(target && my->GetTarget() != GetGuid()) // self cast?
|
||||
{
|
||||
if(target->GetTypeId() == TYPEID_PLAYER || target->GetTypeId() == TYPEID_UNIT)
|
||||
{
|
||||
flags |= TARGET_FLAG_UNIT;
|
||||
temp << (uint8)0xFF << my->GetTarget(); // need to send packed guid?
|
||||
}
|
||||
if(target->GetTypeId() == TYPEID_OBJECT)
|
||||
{
|
||||
flags |= TARGET_FLAG_OBJECT;
|
||||
temp << (uint8)0xFF <<my->GetTarget(); // need to send packed guid?
|
||||
}
|
||||
// TODO: need implementation of areaspells & item targets (enchant) here (temp << itemGUID)!
|
||||
// TODO: append floats x,y,z according to target type srcloc & dstloc to temp
|
||||
// TODO: append string to temp if TARGET_FLAG_STRING is set. what string for what purpose??
|
||||
// and whats with TARGET_CORPSE?
|
||||
}
|
||||
packet << flags;
|
||||
packet.append(temp);
|
||||
|
||||
// cast it
|
||||
packet.SetOpcode(CMSG_CAST_SPELL);
|
||||
SendWorldPacket(packet);
|
||||
logdetail("Casting spell %u on target "I64FMT,spellid,my->GetTarget());
|
||||
if(!known)
|
||||
logcustom(1,LRED," - WARNING: spell is NOT known!");
|
||||
}
|
||||
|
||||
void WorldSession::SendWhoListRequest(uint32 minlvl, uint32 maxlvl, uint32 racemask, uint32 classmask, std::string name, std::string guildname, std::vector<uint32> *zonelist, std::vector<std::string> *strlist)
|
||||
{
|
||||
WorldPacket pkt(CMSG_WHO, 50); // guess size
|
||||
pkt << minlvl;
|
||||
pkt << maxlvl;
|
||||
pkt << name;
|
||||
pkt << guildname;
|
||||
pkt << racemask;
|
||||
pkt << classmask;
|
||||
|
||||
if(zonelist)
|
||||
{
|
||||
pkt << (uint32)zonelist->size();
|
||||
for(uint32 i = 0; i < zonelist->size(); i++)
|
||||
pkt << (*zonelist)[i];
|
||||
}
|
||||
else
|
||||
pkt << uint32(0);
|
||||
|
||||
if(strlist)
|
||||
{
|
||||
pkt << (uint32)strlist->size();
|
||||
for(uint32 i = 0; i < strlist->size(); i++)
|
||||
pkt << (*strlist)[i];
|
||||
}
|
||||
else
|
||||
pkt << uint32(0);
|
||||
|
||||
SendWorldPacket(pkt);
|
||||
}
|
||||
|
||||
void WorldSession::SendQueryCreature(uint32 entry, uint64 guid)
|
||||
{
|
||||
if(objmgr.CreatureNonExistent(entry))
|
||||
{
|
||||
logdebug("Skipped query of creature %u (was marked as nonexistent before)",entry);
|
||||
return;
|
||||
}
|
||||
logdebug("Sending creature query, id=%u",entry);
|
||||
WorldPacket wp(CMSG_CREATURE_QUERY,4+8);
|
||||
wp << entry << guid;
|
||||
SendWorldPacket(wp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,31 +1,31 @@
|
||||
#ifndef _CACHEHANDLER_H
|
||||
#define _CACHEHANDLER_H
|
||||
|
||||
struct PlayerNameCacheItem {
|
||||
uint64 _guid;
|
||||
std::string _name;
|
||||
};
|
||||
|
||||
class PlayerNameCache {
|
||||
public:
|
||||
~PlayerNameCache();
|
||||
|
||||
std::string GetName(uint64);
|
||||
bool IsKnown(uint64);
|
||||
uint64 GetGuid(std::string);
|
||||
bool AddInfo(uint64 guid, std::string name);
|
||||
bool AddInfo(PlayerNameCacheItem*);
|
||||
bool SaveToFile(void);
|
||||
bool ReadFromFile(void);
|
||||
uint32 GetSize(void);
|
||||
private:
|
||||
std::vector<PlayerNameCacheItem*> _cache;
|
||||
};
|
||||
|
||||
void ItemProtoCache_InsertDataToSession(WorldSession *session);
|
||||
void ItemProtoCache_WriteDataToCache(WorldSession *session);
|
||||
|
||||
void CreatureTemplateCache_InsertDataToSession(WorldSession *session);
|
||||
void CreatureTemplateCache_WriteDataToCache(WorldSession *session);
|
||||
|
||||
#endif
|
||||
#ifndef _CACHEHANDLER_H
|
||||
#define _CACHEHANDLER_H
|
||||
|
||||
struct PlayerNameCacheItem {
|
||||
uint64 _guid;
|
||||
std::string _name;
|
||||
};
|
||||
|
||||
class PlayerNameCache {
|
||||
public:
|
||||
~PlayerNameCache();
|
||||
|
||||
std::string GetName(uint64);
|
||||
bool IsKnown(uint64);
|
||||
uint64 GetGuid(std::string);
|
||||
bool AddInfo(uint64 guid, std::string name);
|
||||
bool AddInfo(PlayerNameCacheItem*);
|
||||
bool SaveToFile(void);
|
||||
bool ReadFromFile(void);
|
||||
uint32 GetSize(void);
|
||||
private:
|
||||
std::vector<PlayerNameCacheItem*> _cache;
|
||||
};
|
||||
|
||||
void ItemProtoCache_InsertDataToSession(WorldSession *session);
|
||||
void ItemProtoCache_WriteDataToCache(WorldSession *session);
|
||||
|
||||
void CreatureTemplateCache_InsertDataToSession(WorldSession *session);
|
||||
void CreatureTemplateCache_WriteDataToCache(WorldSession *session);
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,273 +1,273 @@
|
||||
#include "common.h"
|
||||
#include "PseuWoW.h"
|
||||
#include <map>
|
||||
#include "Channel.h"
|
||||
|
||||
enum NotifyTypes
|
||||
{
|
||||
JOINED = 0x00,
|
||||
LEFT = 0x01,
|
||||
YOUJOINED = 0x02,
|
||||
YOULEFT = 0x03,
|
||||
WRONGPASS = 0x04,
|
||||
NOTON1 = 0x05, // Not on channel channel name.
|
||||
NOTMOD = 0x06,
|
||||
SETPASS = 0x07,
|
||||
CHANGEOWNER = 0x08,
|
||||
NOTON2 = 0x09, // Player %s is not on channel.
|
||||
NOTOWNER = 0x0A,
|
||||
WHOOWNER = 0x0B,
|
||||
MODECHANGE = 0x0C,
|
||||
ANNOUNCEON = 0x0D,
|
||||
ANNOUNCEOFF = 0x0E,
|
||||
MODERATED = 0x0F,
|
||||
UNMODERATED = 0x10,
|
||||
YOUCANTSPEAK = 0x11,
|
||||
KICKED = 0x12,
|
||||
YOUAREBANNED = 0x13,
|
||||
BANNED = 0x14,
|
||||
UNBANNED = 0x15,
|
||||
UNKNOWN1 = 0x16, // is not banned
|
||||
ALREADYON = 0x17,
|
||||
INVITED = 0x18,
|
||||
WRONGALLIANCE = 0x19, // target is in the wrong alliance for channel name
|
||||
UNKNOWN2 = 0x1A, // wrong alliance for channel name
|
||||
UNKNOWN3 = 0x1B, // invalid channel name
|
||||
ISNOTMODERATED = 0x1C,
|
||||
YOUINVITED = 0x1D,
|
||||
UNKNOWN4 = 0x1E, // %s has been banned.
|
||||
UNKNOWN5 = 0x1F, // The number of messages that can be sent to this channel is limited, please wait to send another message.
|
||||
UNKNOWN6 = 0x20 // You are in not the correct area for this channel.
|
||||
};
|
||||
|
||||
enum ChannelFlags
|
||||
{
|
||||
CHANNEL_FLAG_CUSTOM = 0x01,
|
||||
// 0x02
|
||||
CHANNEL_FLAG_TRADE = 0x04,
|
||||
CHANNEL_FLAG_NOT_LFG = 0x08,
|
||||
CHANNEL_FLAG_GENERAL = 0x10,
|
||||
CHANNEL_FLAG_CITY = 0x20,
|
||||
CHANNEL_FLAG_LFG = 0x40,
|
||||
CHANNEL_FLAG_VOICE = 0x80
|
||||
// General 0x18 = 0x10 | 0x08
|
||||
// Trade 0x3C = 0x20 | 0x10 | 0x08 | 0x04
|
||||
// LocalDefence 0x18 = 0x10 | 0x08
|
||||
// GuildRecruitment 0x38 = 0x20 | 0x10 | 0x08
|
||||
// LookingForGroup 0x50 = 0x40 | 0x10
|
||||
};
|
||||
|
||||
enum ChannelMemberFlags
|
||||
{
|
||||
MEMBER_FLAG_NONE = 0x00,
|
||||
MEMBER_FLAG_OWNER = 0x01,
|
||||
MEMBER_FLAG_MODERATOR = 0x02,
|
||||
MEMBER_FLAG_VOICED = 0x04,
|
||||
MEMBER_FLAG_MUTED = 0x08,
|
||||
MEMBER_FLAG_CUSTOM = 0x10,
|
||||
MEMBER_FLAG_MIC_MUTED = 0x20,
|
||||
// 0x40
|
||||
// 0x80
|
||||
};
|
||||
|
||||
typedef std::map<uint64,uint8> ChannelPlayerList;
|
||||
|
||||
|
||||
void Channel::Join(std::string channel, std::string password)
|
||||
{
|
||||
if (IsOnChannel(channel))
|
||||
return;
|
||||
|
||||
// Send join channel request
|
||||
WorldPacket worldPacket;
|
||||
worldPacket.SetOpcode(CMSG_JOIN_CHANNEL);
|
||||
worldPacket << (uint32)0; // new since 2.0.x, some channel ID? server answers us with that number later if channel joined
|
||||
worldPacket << (uint8)0; // unk
|
||||
worldPacket << (uint8)0; // unk, new since 2.2.x
|
||||
worldPacket << channel << password;
|
||||
_worldSession->SendWorldPacket(worldPacket);
|
||||
}
|
||||
|
||||
void Channel::Leave(std::string channel)
|
||||
{
|
||||
for(std::vector<std::string>::iterator i = channels.begin(); i != channels.end(); i++)
|
||||
{
|
||||
if (*i == channel)
|
||||
{
|
||||
// Send leave channel request
|
||||
WorldPacket worldPacket;
|
||||
worldPacket.SetOpcode(CMSG_LEAVE_CHANNEL);
|
||||
worldPacket << (uint32)0; // new since 2.0.x, maybe channel id
|
||||
worldPacket << channel;
|
||||
_worldSession->SendWorldPacket(worldPacket);
|
||||
return;
|
||||
}
|
||||
}
|
||||
log("Can't leave channel \"%s\": not joined",channel.c_str());
|
||||
}
|
||||
|
||||
void Channel::Say(std::string channel, std::string text, uint32 lang)
|
||||
{
|
||||
_worldSession->SendChatMessage(CHAT_MSG_CHANNEL, lang, text, channel);
|
||||
}
|
||||
|
||||
bool Channel::IsOnChannel(std::string channel)
|
||||
{
|
||||
for(std::vector<std::string>::iterator i = channels.begin(); i != channels.end(); i++)
|
||||
{
|
||||
if (*i == channel)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Channel::HandleNotifyOpcode(WorldPacket &packet)
|
||||
{
|
||||
uint8 code;
|
||||
uint64 guid;
|
||||
|
||||
std::string channel, name;
|
||||
|
||||
packet >> code >> channel;
|
||||
|
||||
switch (code)
|
||||
{
|
||||
// Player joined channel you are on
|
||||
case JOINED:
|
||||
packet >> guid;
|
||||
if(guid)
|
||||
{
|
||||
name = _worldSession->GetOrRequestPlayerName(guid);
|
||||
if (name.empty())
|
||||
{
|
||||
_worldSession->_DelayWorldPacket(packet, uint32(_worldSession->GetLagMS() * 1.2f));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
log("%s joined channel %s",name.c_str(),channel.c_str());
|
||||
break;
|
||||
|
||||
// Player leaved channel you are on
|
||||
case LEFT:
|
||||
packet >> guid;
|
||||
if(guid)
|
||||
{
|
||||
name = _worldSession->GetOrRequestPlayerName(guid);
|
||||
if (name.empty())
|
||||
{
|
||||
_worldSession->_DelayWorldPacket(packet, uint32(_worldSession->GetLagMS() * 1.2f));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
log("%s left channel %s", name.c_str(), channel.c_str());
|
||||
break;
|
||||
|
||||
// You joined channel successfully
|
||||
case YOUJOINED:
|
||||
log("Joined channel %s", channel.c_str());
|
||||
channels.push_back(channel);
|
||||
break;
|
||||
|
||||
// You leaved channel successfully
|
||||
case YOULEFT:
|
||||
for(std::vector<std::string>::iterator i = channels.begin(); i != channels.end(); i++)
|
||||
{
|
||||
if(*i == channel)
|
||||
{
|
||||
channels.erase(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
log("Left channel %s", channel.c_str());
|
||||
break;
|
||||
|
||||
// Wrong password while trying to join channel
|
||||
case WRONGPASS:
|
||||
log("Could not join channel %s (Wrong password)", channel.c_str());
|
||||
break;
|
||||
|
||||
// Not on channel while trying to write to channel etc.
|
||||
case NOTON1:
|
||||
log("You are not on channel %s", channel.c_str());
|
||||
break;
|
||||
}
|
||||
|
||||
// TODO: Even more channel notices to handle
|
||||
/*
|
||||
printf("Channel notice not handled! Code: %d - Channel name: %s\nData:\n", code, channel.c_str());
|
||||
packet.textlike();
|
||||
printf("\n");
|
||||
*/
|
||||
}
|
||||
|
||||
void Channel::RequestList(std::string ch)
|
||||
{
|
||||
if(!IsOnChannel(ch))
|
||||
logdebug("Requesting list of not joined channel '%s'",ch.c_str());
|
||||
WorldPacket wp;
|
||||
wp.SetOpcode(CMSG_CHANNEL_LIST);
|
||||
wp << ch;
|
||||
_worldSession->SendWorldPacket(wp);
|
||||
}
|
||||
|
||||
void Channel::HandleListRequest(WorldPacket& recvPacket)
|
||||
{
|
||||
ChannelPlayerList cpl;
|
||||
uint8 unk;
|
||||
uint32 size;
|
||||
uint64 guid;
|
||||
uint8 mode, flags; // mode: player flags; flags: channel flags
|
||||
std::string name;
|
||||
bool must_delay = false;
|
||||
|
||||
recvPacket >> unk >> name >> flags >> size;
|
||||
|
||||
for(uint32 i = 0; i < size; i++)
|
||||
{
|
||||
recvPacket >> guid >> mode;
|
||||
// all player names in this packet must be known before
|
||||
if(_worldSession->GetOrRequestPlayerName(guid).empty())
|
||||
{
|
||||
_worldSession->_DelayWorldPacket(recvPacket, uint32(_worldSession->GetLagMS() * 1.2f));
|
||||
must_delay = true;
|
||||
}
|
||||
cpl[guid] = mode;
|
||||
}
|
||||
if(must_delay)
|
||||
return;
|
||||
|
||||
// store list of GUIDs in: @ChannelList - see below
|
||||
DefList *l = _worldSession->GetInstance()->GetScripts()->lists.Get("@ChannelList");
|
||||
l->clear();
|
||||
|
||||
std::string pname;
|
||||
bool muted,mod;
|
||||
logcustom(0,WHITE,"Player channel list, %u players:",size);
|
||||
for(ChannelPlayerList::iterator i = cpl.begin(); i != cpl.end(); i++)
|
||||
{
|
||||
pname = _worldSession->GetOrRequestPlayerName(i->first); // all names should be known now
|
||||
mode = i->second;
|
||||
if(pname.empty())
|
||||
pname = "<unknown>";
|
||||
|
||||
muted = mode & MEMBER_FLAG_MUTED;
|
||||
mod = mode & MEMBER_FLAG_MODERATOR;
|
||||
|
||||
while(pname.length() < MAX_PLAYERNAME_LENGTH)
|
||||
pname += " "; // for better formatting
|
||||
|
||||
logcustom(0,WHITE,"%s ["I64FMT"] %s %s",pname.c_str(),i->first,muted?"(muted)":"",mod?"(moderator)":"");
|
||||
|
||||
// DefScript binding
|
||||
l->push_back(DefScriptTools::toString(guid));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#include "common.h"
|
||||
#include "PseuWoW.h"
|
||||
#include <map>
|
||||
#include "Channel.h"
|
||||
|
||||
enum NotifyTypes
|
||||
{
|
||||
JOINED = 0x00,
|
||||
LEFT = 0x01,
|
||||
YOUJOINED = 0x02,
|
||||
YOULEFT = 0x03,
|
||||
WRONGPASS = 0x04,
|
||||
NOTON1 = 0x05, // Not on channel channel name.
|
||||
NOTMOD = 0x06,
|
||||
SETPASS = 0x07,
|
||||
CHANGEOWNER = 0x08,
|
||||
NOTON2 = 0x09, // Player %s is not on channel.
|
||||
NOTOWNER = 0x0A,
|
||||
WHOOWNER = 0x0B,
|
||||
MODECHANGE = 0x0C,
|
||||
ANNOUNCEON = 0x0D,
|
||||
ANNOUNCEOFF = 0x0E,
|
||||
MODERATED = 0x0F,
|
||||
UNMODERATED = 0x10,
|
||||
YOUCANTSPEAK = 0x11,
|
||||
KICKED = 0x12,
|
||||
YOUAREBANNED = 0x13,
|
||||
BANNED = 0x14,
|
||||
UNBANNED = 0x15,
|
||||
UNKNOWN1 = 0x16, // is not banned
|
||||
ALREADYON = 0x17,
|
||||
INVITED = 0x18,
|
||||
WRONGALLIANCE = 0x19, // target is in the wrong alliance for channel name
|
||||
UNKNOWN2 = 0x1A, // wrong alliance for channel name
|
||||
UNKNOWN3 = 0x1B, // invalid channel name
|
||||
ISNOTMODERATED = 0x1C,
|
||||
YOUINVITED = 0x1D,
|
||||
UNKNOWN4 = 0x1E, // %s has been banned.
|
||||
UNKNOWN5 = 0x1F, // The number of messages that can be sent to this channel is limited, please wait to send another message.
|
||||
UNKNOWN6 = 0x20 // You are in not the correct area for this channel.
|
||||
};
|
||||
|
||||
enum ChannelFlags
|
||||
{
|
||||
CHANNEL_FLAG_CUSTOM = 0x01,
|
||||
// 0x02
|
||||
CHANNEL_FLAG_TRADE = 0x04,
|
||||
CHANNEL_FLAG_NOT_LFG = 0x08,
|
||||
CHANNEL_FLAG_GENERAL = 0x10,
|
||||
CHANNEL_FLAG_CITY = 0x20,
|
||||
CHANNEL_FLAG_LFG = 0x40,
|
||||
CHANNEL_FLAG_VOICE = 0x80
|
||||
// General 0x18 = 0x10 | 0x08
|
||||
// Trade 0x3C = 0x20 | 0x10 | 0x08 | 0x04
|
||||
// LocalDefence 0x18 = 0x10 | 0x08
|
||||
// GuildRecruitment 0x38 = 0x20 | 0x10 | 0x08
|
||||
// LookingForGroup 0x50 = 0x40 | 0x10
|
||||
};
|
||||
|
||||
enum ChannelMemberFlags
|
||||
{
|
||||
MEMBER_FLAG_NONE = 0x00,
|
||||
MEMBER_FLAG_OWNER = 0x01,
|
||||
MEMBER_FLAG_MODERATOR = 0x02,
|
||||
MEMBER_FLAG_VOICED = 0x04,
|
||||
MEMBER_FLAG_MUTED = 0x08,
|
||||
MEMBER_FLAG_CUSTOM = 0x10,
|
||||
MEMBER_FLAG_MIC_MUTED = 0x20,
|
||||
// 0x40
|
||||
// 0x80
|
||||
};
|
||||
|
||||
typedef std::map<uint64,uint8> ChannelPlayerList;
|
||||
|
||||
|
||||
void Channel::Join(std::string channel, std::string password)
|
||||
{
|
||||
if (IsOnChannel(channel))
|
||||
return;
|
||||
|
||||
// Send join channel request
|
||||
WorldPacket worldPacket;
|
||||
worldPacket.SetOpcode(CMSG_JOIN_CHANNEL);
|
||||
worldPacket << (uint32)0; // new since 2.0.x, some channel ID? server answers us with that number later if channel joined
|
||||
worldPacket << (uint8)0; // unk
|
||||
worldPacket << (uint8)0; // unk, new since 2.2.x
|
||||
worldPacket << channel << password;
|
||||
_worldSession->SendWorldPacket(worldPacket);
|
||||
}
|
||||
|
||||
void Channel::Leave(std::string channel)
|
||||
{
|
||||
for(std::vector<std::string>::iterator i = channels.begin(); i != channels.end(); i++)
|
||||
{
|
||||
if (*i == channel)
|
||||
{
|
||||
// Send leave channel request
|
||||
WorldPacket worldPacket;
|
||||
worldPacket.SetOpcode(CMSG_LEAVE_CHANNEL);
|
||||
worldPacket << (uint32)0; // new since 2.0.x, maybe channel id
|
||||
worldPacket << channel;
|
||||
_worldSession->SendWorldPacket(worldPacket);
|
||||
return;
|
||||
}
|
||||
}
|
||||
log("Can't leave channel \"%s\": not joined",channel.c_str());
|
||||
}
|
||||
|
||||
void Channel::Say(std::string channel, std::string text, uint32 lang)
|
||||
{
|
||||
_worldSession->SendChatMessage(CHAT_MSG_CHANNEL, lang, text, channel);
|
||||
}
|
||||
|
||||
bool Channel::IsOnChannel(std::string channel)
|
||||
{
|
||||
for(std::vector<std::string>::iterator i = channels.begin(); i != channels.end(); i++)
|
||||
{
|
||||
if (*i == channel)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Channel::HandleNotifyOpcode(WorldPacket &packet)
|
||||
{
|
||||
uint8 code;
|
||||
uint64 guid;
|
||||
|
||||
std::string channel, name;
|
||||
|
||||
packet >> code >> channel;
|
||||
|
||||
switch (code)
|
||||
{
|
||||
// Player joined channel you are on
|
||||
case JOINED:
|
||||
packet >> guid;
|
||||
if(guid)
|
||||
{
|
||||
name = _worldSession->GetOrRequestPlayerName(guid);
|
||||
if (name.empty())
|
||||
{
|
||||
_worldSession->_DelayWorldPacket(packet, uint32(_worldSession->GetLagMS() * 1.2f));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
log("%s joined channel %s",name.c_str(),channel.c_str());
|
||||
break;
|
||||
|
||||
// Player leaved channel you are on
|
||||
case LEFT:
|
||||
packet >> guid;
|
||||
if(guid)
|
||||
{
|
||||
name = _worldSession->GetOrRequestPlayerName(guid);
|
||||
if (name.empty())
|
||||
{
|
||||
_worldSession->_DelayWorldPacket(packet, uint32(_worldSession->GetLagMS() * 1.2f));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
log("%s left channel %s", name.c_str(), channel.c_str());
|
||||
break;
|
||||
|
||||
// You joined channel successfully
|
||||
case YOUJOINED:
|
||||
log("Joined channel %s", channel.c_str());
|
||||
channels.push_back(channel);
|
||||
break;
|
||||
|
||||
// You leaved channel successfully
|
||||
case YOULEFT:
|
||||
for(std::vector<std::string>::iterator i = channels.begin(); i != channels.end(); i++)
|
||||
{
|
||||
if(*i == channel)
|
||||
{
|
||||
channels.erase(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
log("Left channel %s", channel.c_str());
|
||||
break;
|
||||
|
||||
// Wrong password while trying to join channel
|
||||
case WRONGPASS:
|
||||
log("Could not join channel %s (Wrong password)", channel.c_str());
|
||||
break;
|
||||
|
||||
// Not on channel while trying to write to channel etc.
|
||||
case NOTON1:
|
||||
log("You are not on channel %s", channel.c_str());
|
||||
break;
|
||||
}
|
||||
|
||||
// TODO: Even more channel notices to handle
|
||||
/*
|
||||
printf("Channel notice not handled! Code: %d - Channel name: %s\nData:\n", code, channel.c_str());
|
||||
packet.textlike();
|
||||
printf("\n");
|
||||
*/
|
||||
}
|
||||
|
||||
void Channel::RequestList(std::string ch)
|
||||
{
|
||||
if(!IsOnChannel(ch))
|
||||
logdebug("Requesting list of not joined channel '%s'",ch.c_str());
|
||||
WorldPacket wp;
|
||||
wp.SetOpcode(CMSG_CHANNEL_LIST);
|
||||
wp << ch;
|
||||
_worldSession->SendWorldPacket(wp);
|
||||
}
|
||||
|
||||
void Channel::HandleListRequest(WorldPacket& recvPacket)
|
||||
{
|
||||
ChannelPlayerList cpl;
|
||||
uint8 unk;
|
||||
uint32 size;
|
||||
uint64 guid;
|
||||
uint8 mode, flags; // mode: player flags; flags: channel flags
|
||||
std::string name;
|
||||
bool must_delay = false;
|
||||
|
||||
recvPacket >> unk >> name >> flags >> size;
|
||||
|
||||
for(uint32 i = 0; i < size; i++)
|
||||
{
|
||||
recvPacket >> guid >> mode;
|
||||
// all player names in this packet must be known before
|
||||
if(_worldSession->GetOrRequestPlayerName(guid).empty())
|
||||
{
|
||||
_worldSession->_DelayWorldPacket(recvPacket, uint32(_worldSession->GetLagMS() * 1.2f));
|
||||
must_delay = true;
|
||||
}
|
||||
cpl[guid] = mode;
|
||||
}
|
||||
if(must_delay)
|
||||
return;
|
||||
|
||||
// store list of GUIDs in: @ChannelList - see below
|
||||
DefList *l = _worldSession->GetInstance()->GetScripts()->lists.Get("@ChannelList");
|
||||
l->clear();
|
||||
|
||||
std::string pname;
|
||||
bool muted,mod;
|
||||
logcustom(0,WHITE,"Player channel list, %u players:",size);
|
||||
for(ChannelPlayerList::iterator i = cpl.begin(); i != cpl.end(); i++)
|
||||
{
|
||||
pname = _worldSession->GetOrRequestPlayerName(i->first); // all names should be known now
|
||||
mode = i->second;
|
||||
if(pname.empty())
|
||||
pname = "<unknown>";
|
||||
|
||||
muted = mode & MEMBER_FLAG_MUTED;
|
||||
mod = mode & MEMBER_FLAG_MODERATOR;
|
||||
|
||||
while(pname.length() < MAX_PLAYERNAME_LENGTH)
|
||||
pname += " "; // for better formatting
|
||||
|
||||
logcustom(0,WHITE,"%s ["I64FMT"] %s %s",pname.c_str(),i->first,muted?"(muted)":"",mod?"(moderator)":"");
|
||||
|
||||
// DefScript binding
|
||||
l->push_back(DefScriptTools::toString(guid));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
#ifndef _CORPSE_H
|
||||
#define _CORPSE_H
|
||||
|
||||
#include "Object.h"
|
||||
|
||||
class Corpse : public WorldObject
|
||||
{
|
||||
public:
|
||||
Corpse();
|
||||
void Create(uint64);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef _CORPSE_H
|
||||
#define _CORPSE_H
|
||||
|
||||
#include "Object.h"
|
||||
|
||||
class Corpse : public WorldObject
|
||||
{
|
||||
public:
|
||||
Corpse();
|
||||
void Create(uint64);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
#ifndef _DYNAMICOBJECT_H
|
||||
#define _DYNAMICOBJECT_H
|
||||
|
||||
#include "Object.h"
|
||||
|
||||
class DynamicObject : public WorldObject
|
||||
{
|
||||
public:
|
||||
DynamicObject();
|
||||
void Create(uint64);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef _DYNAMICOBJECT_H
|
||||
#define _DYNAMICOBJECT_H
|
||||
|
||||
#include "Object.h"
|
||||
|
||||
class DynamicObject : public WorldObject
|
||||
{
|
||||
public:
|
||||
DynamicObject();
|
||||
void Create(uint64);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
#ifndef _GAMEOBJECT_H
|
||||
#define _GAMEOBJECT_H
|
||||
|
||||
#include "Object.h"
|
||||
|
||||
class GameObject : public WorldObject
|
||||
{
|
||||
public:
|
||||
GameObject();
|
||||
void Create(uint64);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef _GAMEOBJECT_H
|
||||
#define _GAMEOBJECT_H
|
||||
|
||||
#include "Object.h"
|
||||
|
||||
class GameObject : public WorldObject
|
||||
{
|
||||
public:
|
||||
GameObject();
|
||||
void Create(uint64);
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,129 +1,129 @@
|
||||
#include "WorldSession.h"
|
||||
#include "UpdateFields.h"
|
||||
|
||||
#include "Item.h"
|
||||
#include "Bag.h"
|
||||
|
||||
void WorldSession::_HandleItemQuerySingleResponseOpcode(WorldPacket& recvPacket)
|
||||
{
|
||||
ItemProto *proto = new ItemProto();
|
||||
recvPacket >> proto->Id;
|
||||
uint8 field[64];
|
||||
uint32 unk;
|
||||
std::string s;
|
||||
memset(field,0,64);
|
||||
if(memcmp(recvPacket.contents()+sizeof(uint32),field,64))
|
||||
{
|
||||
recvPacket >> proto->Class;
|
||||
recvPacket >> proto->SubClass;
|
||||
recvPacket >> unk; // dont need that value?
|
||||
recvPacket >> proto->Name;
|
||||
recvPacket >> s >> s >> s; // strip name2-4
|
||||
recvPacket >> proto->DisplayInfoID;
|
||||
recvPacket >> proto->Quality;
|
||||
recvPacket >> proto->Flags;
|
||||
recvPacket >> proto->BuyPrice;
|
||||
recvPacket >> proto->SellPrice;
|
||||
recvPacket >> proto->InventoryType;
|
||||
recvPacket >> proto->AllowableClass;
|
||||
recvPacket >> proto->AllowableRace;
|
||||
recvPacket >> proto->ItemLevel;
|
||||
recvPacket >> proto->RequiredLevel;
|
||||
recvPacket >> proto->RequiredSkill;
|
||||
recvPacket >> proto->RequiredSkillRank;
|
||||
recvPacket >> proto->RequiredSpell;
|
||||
recvPacket >> proto->RequiredHonorRank;
|
||||
recvPacket >> proto->RequiredCityRank;
|
||||
recvPacket >> proto->RequiredReputationFaction;
|
||||
recvPacket >> proto->RequiredReputationRank;
|
||||
recvPacket >> proto->MaxCount;
|
||||
recvPacket >> proto->Stackable;
|
||||
recvPacket >> proto->ContainerSlots;
|
||||
for(int i = 0; i < 10; i++)
|
||||
{
|
||||
recvPacket >> proto->ItemStat[i].ItemStatType;
|
||||
recvPacket >> proto->ItemStat[i].ItemStatValue;
|
||||
}
|
||||
for(int i = 0; i < 5; i++)
|
||||
{
|
||||
recvPacket >> proto->Damage[i].DamageMin;
|
||||
recvPacket >> proto->Damage[i].DamageMax;
|
||||
recvPacket >> proto->Damage[i].DamageType;
|
||||
}
|
||||
recvPacket >> proto->Armor;
|
||||
recvPacket >> proto->HolyRes;
|
||||
recvPacket >> proto->FireRes;
|
||||
recvPacket >> proto->NatureRes;
|
||||
recvPacket >> proto->FrostRes;
|
||||
recvPacket >> proto->ShadowRes;
|
||||
recvPacket >> proto->ArcaneRes;
|
||||
recvPacket >> proto->Delay;
|
||||
recvPacket >> proto->Ammo_type;
|
||||
|
||||
recvPacket >> proto->RangedModRange;
|
||||
for(int s = 0; s < 5; s++)
|
||||
{
|
||||
recvPacket >> proto->Spells[s].SpellId;
|
||||
recvPacket >> proto->Spells[s].SpellTrigger;
|
||||
recvPacket >> proto->Spells[s].SpellCharges;
|
||||
recvPacket >> proto->Spells[s].SpellCooldown;
|
||||
recvPacket >> proto->Spells[s].SpellCategory;
|
||||
recvPacket >> proto->Spells[s].SpellCategoryCooldown;
|
||||
}
|
||||
recvPacket >> proto->Bonding;
|
||||
recvPacket >> proto->Description;
|
||||
recvPacket >> proto->PageText;
|
||||
recvPacket >> proto->LanguageID;
|
||||
recvPacket >> proto->PageMaterial;
|
||||
recvPacket >> proto->StartQuest;
|
||||
recvPacket >> proto->LockID;
|
||||
recvPacket >> proto->Material;
|
||||
recvPacket >> proto->Sheath;
|
||||
recvPacket >> proto->Extra;
|
||||
recvPacket >> proto->Block;
|
||||
recvPacket >> proto->ItemSet;
|
||||
recvPacket >> proto->MaxDurability;
|
||||
recvPacket >> proto->Area;
|
||||
recvPacket >> proto->Map;
|
||||
recvPacket >> proto->BagFamily;
|
||||
recvPacket >> proto->TotemCategory; // Added in 1.12.x client branch
|
||||
for(uint32 s = 0; s < 3; s++)
|
||||
{
|
||||
recvPacket >> proto->Socket[s].Color;
|
||||
recvPacket >> proto->Socket[s].Content;
|
||||
}
|
||||
recvPacket >> proto->socketBonus;
|
||||
recvPacket >> proto->GemProperties;
|
||||
recvPacket >> proto->ExtendedCost;
|
||||
recvPacket >> proto->RequiredDisenchantSkill;
|
||||
recvPacket >> proto->ArmorDamageModifier;
|
||||
|
||||
logdetail("Got Item Info: Id=%u Name='%s' ReqLevel=%u Armor=%u Desc='%s'",
|
||||
proto->Id, proto->Name.c_str(), proto->RequiredLevel, proto->Armor, proto->Description.c_str());
|
||||
objmgr.Add(proto);
|
||||
objmgr.AssignNameToObj(proto->Id, TYPEID_ITEM, proto->Name);
|
||||
objmgr.AssignNameToObj(proto->Id, TYPEID_CONTAINER, proto->Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
logdetail("Got info of nonexistent Item %u",proto->Id);
|
||||
objmgr.AddNonexistentItem(proto->Id);
|
||||
delete proto;
|
||||
}
|
||||
}
|
||||
|
||||
Item::Item()
|
||||
{
|
||||
_type |= TYPE_ITEM;
|
||||
_typeid = TYPEID_ITEM;
|
||||
|
||||
_valuescount = ITEM_END;
|
||||
_slot = 0;
|
||||
//_bag = NULL; // not yet implemented
|
||||
}
|
||||
|
||||
void Item::Create(uint64 guid)
|
||||
{
|
||||
Object::Create(guid);
|
||||
// what else?
|
||||
}
|
||||
#include "WorldSession.h"
|
||||
#include "UpdateFields.h"
|
||||
|
||||
#include "Item.h"
|
||||
#include "Bag.h"
|
||||
|
||||
void WorldSession::_HandleItemQuerySingleResponseOpcode(WorldPacket& recvPacket)
|
||||
{
|
||||
ItemProto *proto = new ItemProto();
|
||||
recvPacket >> proto->Id;
|
||||
uint8 field[64];
|
||||
uint32 unk;
|
||||
std::string s;
|
||||
memset(field,0,64);
|
||||
if(memcmp(recvPacket.contents()+sizeof(uint32),field,64))
|
||||
{
|
||||
recvPacket >> proto->Class;
|
||||
recvPacket >> proto->SubClass;
|
||||
recvPacket >> unk; // dont need that value?
|
||||
recvPacket >> proto->Name;
|
||||
recvPacket >> s >> s >> s; // strip name2-4
|
||||
recvPacket >> proto->DisplayInfoID;
|
||||
recvPacket >> proto->Quality;
|
||||
recvPacket >> proto->Flags;
|
||||
recvPacket >> proto->BuyPrice;
|
||||
recvPacket >> proto->SellPrice;
|
||||
recvPacket >> proto->InventoryType;
|
||||
recvPacket >> proto->AllowableClass;
|
||||
recvPacket >> proto->AllowableRace;
|
||||
recvPacket >> proto->ItemLevel;
|
||||
recvPacket >> proto->RequiredLevel;
|
||||
recvPacket >> proto->RequiredSkill;
|
||||
recvPacket >> proto->RequiredSkillRank;
|
||||
recvPacket >> proto->RequiredSpell;
|
||||
recvPacket >> proto->RequiredHonorRank;
|
||||
recvPacket >> proto->RequiredCityRank;
|
||||
recvPacket >> proto->RequiredReputationFaction;
|
||||
recvPacket >> proto->RequiredReputationRank;
|
||||
recvPacket >> proto->MaxCount;
|
||||
recvPacket >> proto->Stackable;
|
||||
recvPacket >> proto->ContainerSlots;
|
||||
for(int i = 0; i < 10; i++)
|
||||
{
|
||||
recvPacket >> proto->ItemStat[i].ItemStatType;
|
||||
recvPacket >> proto->ItemStat[i].ItemStatValue;
|
||||
}
|
||||
for(int i = 0; i < 5; i++)
|
||||
{
|
||||
recvPacket >> proto->Damage[i].DamageMin;
|
||||
recvPacket >> proto->Damage[i].DamageMax;
|
||||
recvPacket >> proto->Damage[i].DamageType;
|
||||
}
|
||||
recvPacket >> proto->Armor;
|
||||
recvPacket >> proto->HolyRes;
|
||||
recvPacket >> proto->FireRes;
|
||||
recvPacket >> proto->NatureRes;
|
||||
recvPacket >> proto->FrostRes;
|
||||
recvPacket >> proto->ShadowRes;
|
||||
recvPacket >> proto->ArcaneRes;
|
||||
recvPacket >> proto->Delay;
|
||||
recvPacket >> proto->Ammo_type;
|
||||
|
||||
recvPacket >> proto->RangedModRange;
|
||||
for(int s = 0; s < 5; s++)
|
||||
{
|
||||
recvPacket >> proto->Spells[s].SpellId;
|
||||
recvPacket >> proto->Spells[s].SpellTrigger;
|
||||
recvPacket >> proto->Spells[s].SpellCharges;
|
||||
recvPacket >> proto->Spells[s].SpellCooldown;
|
||||
recvPacket >> proto->Spells[s].SpellCategory;
|
||||
recvPacket >> proto->Spells[s].SpellCategoryCooldown;
|
||||
}
|
||||
recvPacket >> proto->Bonding;
|
||||
recvPacket >> proto->Description;
|
||||
recvPacket >> proto->PageText;
|
||||
recvPacket >> proto->LanguageID;
|
||||
recvPacket >> proto->PageMaterial;
|
||||
recvPacket >> proto->StartQuest;
|
||||
recvPacket >> proto->LockID;
|
||||
recvPacket >> proto->Material;
|
||||
recvPacket >> proto->Sheath;
|
||||
recvPacket >> proto->Extra;
|
||||
recvPacket >> proto->Block;
|
||||
recvPacket >> proto->ItemSet;
|
||||
recvPacket >> proto->MaxDurability;
|
||||
recvPacket >> proto->Area;
|
||||
recvPacket >> proto->Map;
|
||||
recvPacket >> proto->BagFamily;
|
||||
recvPacket >> proto->TotemCategory; // Added in 1.12.x client branch
|
||||
for(uint32 s = 0; s < 3; s++)
|
||||
{
|
||||
recvPacket >> proto->Socket[s].Color;
|
||||
recvPacket >> proto->Socket[s].Content;
|
||||
}
|
||||
recvPacket >> proto->socketBonus;
|
||||
recvPacket >> proto->GemProperties;
|
||||
recvPacket >> proto->ExtendedCost;
|
||||
recvPacket >> proto->RequiredDisenchantSkill;
|
||||
recvPacket >> proto->ArmorDamageModifier;
|
||||
|
||||
logdetail("Got Item Info: Id=%u Name='%s' ReqLevel=%u Armor=%u Desc='%s'",
|
||||
proto->Id, proto->Name.c_str(), proto->RequiredLevel, proto->Armor, proto->Description.c_str());
|
||||
objmgr.Add(proto);
|
||||
objmgr.AssignNameToObj(proto->Id, TYPEID_ITEM, proto->Name);
|
||||
objmgr.AssignNameToObj(proto->Id, TYPEID_CONTAINER, proto->Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
logdetail("Got info of nonexistent Item %u",proto->Id);
|
||||
objmgr.AddNonexistentItem(proto->Id);
|
||||
delete proto;
|
||||
}
|
||||
}
|
||||
|
||||
Item::Item()
|
||||
{
|
||||
_type |= TYPE_ITEM;
|
||||
_typeid = TYPEID_ITEM;
|
||||
|
||||
_valuescount = ITEM_END;
|
||||
_slot = 0;
|
||||
//_bag = NULL; // not yet implemented
|
||||
}
|
||||
|
||||
void Item::Create(uint64 guid)
|
||||
{
|
||||
Object::Create(guid);
|
||||
// what else?
|
||||
}
|
||||
|
||||
@ -1,440 +1,440 @@
|
||||
#ifndef _ITEM_H
|
||||
#define _ITEM_H
|
||||
|
||||
#include "common.h"
|
||||
#include "Object.h"
|
||||
|
||||
class Bag;
|
||||
|
||||
enum InventoryChangeFailure
|
||||
{
|
||||
EQUIP_ERR_OK = 0,
|
||||
EQUIP_ERR_YOU_MUST_REACH_LEVEL_N = 1,
|
||||
EQUIP_ERR_SKILL_ISNT_HIGH_ENOUGH = 2,
|
||||
EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT = 3,
|
||||
EQUIP_ERR_BAG_FULL = 4,
|
||||
EQUIP_ERR_NONEMPTY_BAG_OVER_OTHER_BAG = 5,
|
||||
EQUIP_ERR_CANT_TRADE_EQUIP_BAGS = 6,
|
||||
EQUIP_ERR_ONLY_AMMO_CAN_GO_HERE = 7,
|
||||
EQUIP_ERR_NO_REQUIRED_PROFICIENCY = 8,
|
||||
EQUIP_ERR_NO_EQUIPMENT_SLOT_AVAILABLE = 9,
|
||||
EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM = 10,
|
||||
EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM2 = 11,
|
||||
EQUIP_ERR_NO_EQUIPMENT_SLOT_AVAILABLE2 = 12,
|
||||
EQUIP_ERR_CANT_EQUIP_WITH_TWOHANDED = 13,
|
||||
EQUIP_ERR_CANT_DUAL_WIELD = 14,
|
||||
EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG = 15,
|
||||
EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG2 = 16,
|
||||
EQUIP_ERR_CANT_CARRY_MORE_OF_THIS = 17,
|
||||
EQUIP_ERR_NO_EQUIPMENT_SLOT_AVAILABLE3 = 18,
|
||||
EQUIP_ERR_ITEM_CANT_STACK = 19,
|
||||
EQUIP_ERR_ITEM_CANT_BE_EQUIPPED = 20,
|
||||
EQUIP_ERR_ITEMS_CANT_BE_SWAPPED = 21,
|
||||
EQUIP_ERR_SLOT_IS_EMPTY = 22,
|
||||
EQUIP_ERR_ITEM_NOT_FOUND = 23,
|
||||
EQUIP_ERR_CANT_DROP_SOULBOUND = 24,
|
||||
EQUIP_ERR_OUT_OF_RANGE = 25,
|
||||
EQUIP_ERR_TRIED_TO_SPLIT_MORE_THAN_COUNT = 26,
|
||||
EQUIP_ERR_COULDNT_SPLIT_ITEMS = 27,
|
||||
EQUIP_ERR_MISSING_REAGENT = 28,
|
||||
EQUIP_ERR_NOT_ENOUGH_MONEY = 29,
|
||||
EQUIP_ERR_NOT_A_BAG = 30,
|
||||
EQUIP_ERR_CAN_ONLY_DO_WITH_EMPTY_BAGS = 31,
|
||||
EQUIP_ERR_DONT_OWN_THAT_ITEM = 32,
|
||||
EQUIP_ERR_CAN_EQUIP_ONLY1_QUIVER = 33,
|
||||
EQUIP_ERR_MUST_PURCHASE_THAT_BAG_SLOT = 34,
|
||||
EQUIP_ERR_TOO_FAR_AWAY_FROM_BANK = 35,
|
||||
EQUIP_ERR_ITEM_LOCKED = 36,
|
||||
EQUIP_ERR_YOU_ARE_STUNNED = 37,
|
||||
EQUIP_ERR_YOU_ARE_DEAD = 38,
|
||||
EQUIP_ERR_CANT_DO_RIGHT_NOW = 39,
|
||||
EQUIP_ERR_BAG_FULL2 = 40,
|
||||
EQUIP_ERR_CAN_EQUIP_ONLY1_QUIVER2 = 41,
|
||||
EQUIP_ERR_CAN_EQUIP_ONLY1_AMMOPOUCH = 42,
|
||||
EQUIP_ERR_STACKABLE_CANT_BE_WRAPPED = 43,
|
||||
EQUIP_ERR_EQUIPPED_CANT_BE_WRAPPED = 44,
|
||||
EQUIP_ERR_WRAPPED_CANT_BE_WRAPPED = 45,
|
||||
EQUIP_ERR_BOUND_CANT_BE_WRAPPED = 46,
|
||||
EQUIP_ERR_UNIQUE_CANT_BE_WRAPPED = 47,
|
||||
EQUIP_ERR_BAGS_CANT_BE_WRAPPED = 48,
|
||||
EQUIP_ERR_ALREADY_LOOTED = 49,
|
||||
EQUIP_ERR_INVENTORY_FULL = 50,
|
||||
EQUIP_ERR_BANK_FULL = 51,
|
||||
EQUIP_ERR_ITEM_IS_CURRENTLY_SOLD_OUT = 52,
|
||||
EQUIP_ERR_BAG_FULL3 = 53,
|
||||
EQUIP_ERR_ITEM_NOT_FOUND2 = 54,
|
||||
EQUIP_ERR_ITEM_CANT_STACK2 = 55,
|
||||
EQUIP_ERR_BAG_FULL4 = 56,
|
||||
EQUIP_ERR_ITEM_SOLD_OUT = 57,
|
||||
EQUIP_ERR_OBJECT_IS_BUSY = 58,
|
||||
EQUIP_ERR_NONE = 59,
|
||||
EQUIP_ERR_CANT_DO_IN_COMBAT = 60,
|
||||
EQUIP_CANT_DO_WHILE_DISARMED = 61,
|
||||
EQUIP_ERR_BAG_FULL6 = 62,
|
||||
EQUIP_ITEM_RANK_NOT_ENOUGH = 63,
|
||||
EQUIP_ITEM_REPUTATION_NOT_ENOUGH = 64,
|
||||
EQUIP_MORE_THAN1_SPECIAL_BAG = 65
|
||||
};
|
||||
|
||||
enum BuyFailure
|
||||
{
|
||||
BUY_ERR_CANT_FIND_ITEM = 0,
|
||||
BUY_ERR_ITEM_ALREADY_SOLD = 1,
|
||||
BUY_ERR_NOT_ENOUGHT_MONEY = 2,
|
||||
BUY_ERR_SELLER_DONT_LIKE_YOU = 4,
|
||||
BUY_ERR_DISTANCE_TOO_FAR = 5,
|
||||
BUY_ERR_CANT_CARRY_MORE = 8,
|
||||
BUY_ERR_LEVEL_REQUIRE = 11,
|
||||
BUY_ERR_REPUTATION_REQUIRE = 12
|
||||
};
|
||||
|
||||
enum SellFailure
|
||||
{
|
||||
SELL_ERR_CANT_FIND_ITEM = 1,
|
||||
SELL_ERR_CANT_SELL_ITEM = 2,
|
||||
SELL_ERR_CANT_FIND_VENDOR = 3
|
||||
};
|
||||
|
||||
enum ITEM_STAT_TYPE
|
||||
{
|
||||
ITEM_STAT_POWER = 0,
|
||||
ITEM_STAT_HEALTH = 1,
|
||||
ITEM_STAT_UNKNOWN = 2,
|
||||
ITEM_STAT_AGILITY = 3,
|
||||
ITEM_STAT_STRENGTH = 4,
|
||||
ITEM_STAT_INTELLECT = 5,
|
||||
ITEM_STAT_SPIRIT = 6,
|
||||
ITEM_STAT_STAMINA = 7
|
||||
};
|
||||
|
||||
enum ITEM_DAMAGE_TYPE
|
||||
{
|
||||
NORMAL_DAMAGE = 0,
|
||||
HOLY_DAMAGE = 1,
|
||||
FIRE_DAMAGE = 2,
|
||||
NATURE_DAMAGE = 3,
|
||||
FROST_DAMAGE = 4,
|
||||
SHADOW_DAMAGE = 5,
|
||||
ARCANE_DAMAGE = 6
|
||||
};
|
||||
|
||||
enum ITEM_SPELLTRIGGER_TYPE
|
||||
{
|
||||
USE = 0,
|
||||
ON_EQUIP = 1,
|
||||
CHANCE_ON_HIT = 2,
|
||||
SOULSTONE = 4
|
||||
};
|
||||
|
||||
enum ITEM_BONDING_TYPE
|
||||
{
|
||||
NO_BIND = 0,
|
||||
BIND_WHEN_PICKED_UP = 1,
|
||||
BIND_WHEN_EQUIPED = 2,
|
||||
BIND_WHEN_USE = 3,
|
||||
//TODO: Better name these
|
||||
QUEST_ITEM = 4,
|
||||
QUEST_ITEM1 = 5
|
||||
};
|
||||
|
||||
// masks for ITEM_FIELD_FLAGS field
|
||||
enum ITEM_FLAGS
|
||||
{
|
||||
ITEM_FLAGS_BINDED = 1
|
||||
};
|
||||
|
||||
enum BAG_FAMILY
|
||||
{
|
||||
BAG_FAMILY_NONE = 0,
|
||||
BAG_FAMILY_ARROWS = 1,
|
||||
BAG_FAMILY_BULLETS = 2,
|
||||
BAG_FAMILY_SOUL_SHARDS = 3,
|
||||
//BAG_FAMILY_UNK1 = 4,
|
||||
//BAG_FAMILY_UNK1 = 5,
|
||||
BAG_FAMILY_HERBS = 6,
|
||||
BAG_FAMILY_ENCHANTING_SUPP = 7,
|
||||
BAG_FAMILY_ENGINEERING_SUPP = 8,
|
||||
BAG_FAMILY_KEYS = 9,
|
||||
BAG_FAMILY_GEMS = 10,
|
||||
//BAG_FAMILY_UNK3 = 11,
|
||||
BAG_FAMILY_MINING_SUPP = 12
|
||||
};
|
||||
|
||||
enum INVENTORY_TYPES
|
||||
{
|
||||
INVTYPE_NON_EQUIP = 0,
|
||||
INVTYPE_HEAD = 1,
|
||||
INVTYPE_NECK = 2,
|
||||
INVTYPE_SHOULDERS = 3,
|
||||
INVTYPE_BODY = 4,
|
||||
INVTYPE_CHEST = 5,
|
||||
INVTYPE_WAIST = 6,
|
||||
INVTYPE_LEGS = 7,
|
||||
INVTYPE_FEET = 8,
|
||||
INVTYPE_WRISTS = 9,
|
||||
INVTYPE_HANDS = 10,
|
||||
INVTYPE_FINGER = 11,
|
||||
INVTYPE_TRINKET = 12,
|
||||
INVTYPE_WEAPON = 13,
|
||||
INVTYPE_SHIELD = 14,
|
||||
INVTYPE_RANGED = 15,
|
||||
INVTYPE_CLOAK = 16,
|
||||
INVTYPE_2HWEAPON = 17,
|
||||
INVTYPE_BAG = 18,
|
||||
INVTYPE_TABARD = 19,
|
||||
INVTYPE_ROBE = 20,
|
||||
INVTYPE_WEAPONMAINHAND = 21,
|
||||
INVTYPE_WEAPONOFFHAND = 22,
|
||||
INVTYPE_HOLDABLE = 23,
|
||||
INVTYPE_AMMO = 24,
|
||||
INVTYPE_THROWN = 25,
|
||||
INVTYPE_RANGEDRIGHT = 26,
|
||||
INVTYPE_SLOT_ITEM = 27,
|
||||
INVTYPE_RELIC = 28,
|
||||
NUM_INVENTORY_TYPES = 29
|
||||
};
|
||||
|
||||
enum INVENTORY_CLASS
|
||||
{
|
||||
ITEM_CLASS_CONSUMABLE = 0,
|
||||
ITEM_CLASS_CONTAINER = 1,
|
||||
ITEM_CLASS_WEAPON = 2,
|
||||
ITEM_CLASS_JEWELRY = 3,
|
||||
ITEM_CLASS_ARMOR = 4,
|
||||
ITEM_CLASS_REAGENT = 5,
|
||||
ITEM_CLASS_PROJECTILE = 6,
|
||||
ITEM_CLASS_TRADE_GOODS = 7,
|
||||
ITEM_CLASS_GENERIC = 8,
|
||||
ITEM_CLASS_BOOK = 9,
|
||||
ITEM_CLASS_MONEY = 10,
|
||||
ITEM_CLASS_QUIVER = 11,
|
||||
ITEM_CLASS_QUEST = 12,
|
||||
ITEM_CLASS_KEY = 13,
|
||||
ITEM_CLASS_PERMANENT = 14,
|
||||
ITEM_CLASS_JUNK = 15
|
||||
};
|
||||
|
||||
// Client understand only 0 subclass for ITEM_CLASS_CONSUMABLE
|
||||
// but this value used in code as implementation workaround
|
||||
enum ITEM_SUBCLASS_CONSUMABLE
|
||||
{
|
||||
ITEM_SUBCLASS_POTION = 1,
|
||||
ITEM_SUBCLASS_ELIXIR = 2,
|
||||
ITEM_SUBCLASS_FLASK = 3,
|
||||
ITEM_SUBCLASS_SCROLL = 4,
|
||||
ITEM_SUBCLASS_FOOD = 5,
|
||||
ITEM_SUBCLASS_ITEM_ENHANCEMENT = 6,
|
||||
ITEM_SUBCLASS_BANDAGE = 7
|
||||
};
|
||||
|
||||
enum ITEM_SUBCLASS_CONTAINER
|
||||
{
|
||||
ITEM_SUBCLASS_CONTAINER = 0,
|
||||
ITEM_SUBCLASS_SOUL_CONTAINER = 1,
|
||||
ITEM_SUBCLASS_HERB_CONTAINER = 2,
|
||||
ITEM_SUBCLASS_ENCHANTING_CONTAINER = 3,
|
||||
ITEM_SUBCLASS_ENGINEERING_CONTAINER = 4,
|
||||
ITEM_SUBCLASS_GEM_CONTAINER = 5,
|
||||
ITEM_SUBCLASS_MINING_CONTAINER = 6,
|
||||
ITEM_SUBCLASS_LEATHERWORKING_CONTAINER = 7
|
||||
};
|
||||
|
||||
enum INVENTORY_SUBCLASS_WEAPON
|
||||
{
|
||||
ITEM_SUBCLASS_WEAPON_AXE = 0,
|
||||
ITEM_SUBCLASS_WEAPON_AXE2 = 1,
|
||||
ITEM_SUBCLASS_WEAPON_BOW = 2,
|
||||
ITEM_SUBCLASS_WEAPON_GUN = 3,
|
||||
ITEM_SUBCLASS_WEAPON_MACE = 4,
|
||||
ITEM_SUBCLASS_WEAPON_MACE2 = 5,
|
||||
ITEM_SUBCLASS_WEAPON_POLEARM = 6,
|
||||
ITEM_SUBCLASS_WEAPON_SWORD = 7,
|
||||
ITEM_SUBCLASS_WEAPON_SWORD2 = 8,
|
||||
ITEM_SUBCLASS_WEAPON_obsolete = 9,
|
||||
ITEM_SUBCLASS_WEAPON_STAFF = 10,
|
||||
ITEM_SUBCLASS_WEAPON_EXOTIC = 11,
|
||||
ITEM_SUBCLASS_WEAPON_EXOTIC2 = 12,
|
||||
ITEM_SUBCLASS_WEAPON_UNARMED = 13,
|
||||
ITEM_SUBCLASS_WEAPON_GENERIC = 14,
|
||||
ITEM_SUBCLASS_WEAPON_DAGGER = 15,
|
||||
ITEM_SUBCLASS_WEAPON_THROWN = 16,
|
||||
ITEM_SUBCLASS_WEAPON_SPEAR = 17,
|
||||
ITEM_SUBCLASS_WEAPON_CROSSBOW = 18,
|
||||
ITEM_SUBCLASS_WEAPON_WAND = 19,
|
||||
ITEM_SUBCLASS_WEAPON_FISHING_POLE = 20
|
||||
};
|
||||
|
||||
enum ITEM_SUBCLASS_ARMOR
|
||||
{
|
||||
ITEM_SUBCLASS_ARMOR_GENERIC = 0,
|
||||
ITEM_SUBCLASS_ARMOR_CLOTH = 1,
|
||||
ITEM_SUBCLASS_ARMOR_LEATHER = 2,
|
||||
ITEM_SUBCLASS_ARMOR_MAIL = 3,
|
||||
ITEM_SUBCLASS_ARMOR_PLATE = 4,
|
||||
ITEM_SUBCLASS_ARMOR_BUCKLER = 5,
|
||||
ITEM_SUBCLASS_ARMOR_SHIELD = 6
|
||||
};
|
||||
|
||||
enum ITEM_SUBCLASS_PROJECTILE
|
||||
{
|
||||
ITEM_SUBCLASS_ARROW = 2,
|
||||
ITEM_SUBCLASS_BULLET = 3
|
||||
};
|
||||
|
||||
enum ITEM_SUBCLASS_TRADE_GOODS
|
||||
{
|
||||
ITEM_SUBCLASS_TRADE_GOODS = 0,
|
||||
ITEM_SUBCLASS_PARTS = 1,
|
||||
ITEM_SUBCLASS_EXPLOSIVES = 2,
|
||||
ITEM_SUBCLASS_DEVICES = 3,
|
||||
ITEM_SUBCLASS_JEWELCRAFTING = 4,
|
||||
ITEM_SUBCLASS_CLOTH = 5,
|
||||
ITEM_SUBCLASS_LEATHER = 6,
|
||||
ITEM_SUBCLASS_METAL_STONE = 7,
|
||||
ITEM_SUBCLASS_MEAT = 8,
|
||||
ITEM_SUBCLASS_HERB = 9,
|
||||
ITEM_SUBCLASS_ELEMENTAZL = 10,
|
||||
ITEM_SUBCLASS_TRADE_GOODS_OTHER = 11,
|
||||
ITEM_SUBCLASS_ENCHANTING = 12
|
||||
};
|
||||
|
||||
enum ITEM_SUBCLASS_BOOK
|
||||
{
|
||||
ITEM_SUBCLASS_BOOK = 0,
|
||||
ITEM_SUBCLASS_LEATHERWORKING_PATTERN = 1,
|
||||
ITEM_SUBCLASS_TAILORING_PATTERN = 2,
|
||||
ITEM_SUBCLASS_ENGINEERING_SCHEMATIC = 3,
|
||||
ITEM_SUBCLASS_COOKING_RECIPE = 5,
|
||||
ITEM_SUBCLASS_ALCHEMY_RECIPE = 6,
|
||||
ITEM_SUBCLASS_FIRST_AID_MANUAL = 7,
|
||||
ITEM_SUBCLASS_ENCHANTING_FORMULA = 8,
|
||||
ITEM_SUBCLASS_FISHING_MANUAL = 9
|
||||
};
|
||||
|
||||
enum ITEM_SUBCLASS_QUIVER
|
||||
{
|
||||
ITEM_SUBCLASS_QUIVER = 2,
|
||||
ITEM_SUBCLASS_AMMO_POUCH = 3
|
||||
};
|
||||
|
||||
struct _ItemStat
|
||||
{
|
||||
uint32 ItemStatType;
|
||||
uint32 ItemStatValue;
|
||||
|
||||
};
|
||||
|
||||
struct _ItemSpell
|
||||
{
|
||||
uint32 SpellId;
|
||||
uint32 SpellTrigger;
|
||||
uint32 SpellCharges;
|
||||
uint32 SpellCooldown;
|
||||
uint32 SpellCategory;
|
||||
uint32 SpellCategoryCooldown;
|
||||
|
||||
};
|
||||
|
||||
struct _ItemSocket
|
||||
{
|
||||
uint32 Color;
|
||||
uint32 Content;
|
||||
};
|
||||
|
||||
struct _ItemDamage
|
||||
{
|
||||
float DamageMin;
|
||||
float DamageMax;
|
||||
uint32 DamageType;
|
||||
|
||||
};
|
||||
|
||||
struct ItemProto
|
||||
{
|
||||
uint32 Id;
|
||||
uint32 Class;
|
||||
uint32 SubClass;
|
||||
std::string Name;
|
||||
uint32 DisplayInfoID;
|
||||
uint32 Quality;
|
||||
uint32 Flags;
|
||||
uint32 BuyCount;
|
||||
uint32 BuyPrice;
|
||||
uint32 SellPrice;
|
||||
uint32 InventoryType;
|
||||
uint32 AllowableClass;
|
||||
uint32 AllowableRace;
|
||||
uint32 ItemLevel;
|
||||
uint32 RequiredLevel;
|
||||
uint32 RequiredSkill;
|
||||
uint32 RequiredSkillRank;
|
||||
uint32 RequiredSpell;
|
||||
uint32 RequiredHonorRank;
|
||||
uint32 RequiredCityRank;
|
||||
uint32 RequiredReputationFaction;
|
||||
uint32 RequiredReputationRank;
|
||||
uint32 MaxCount;
|
||||
uint32 Stackable;
|
||||
uint32 ContainerSlots;
|
||||
_ItemStat ItemStat[10];
|
||||
_ItemDamage Damage[5];
|
||||
uint32 Armor;
|
||||
uint32 HolyRes;
|
||||
uint32 FireRes;
|
||||
uint32 NatureRes;
|
||||
uint32 FrostRes;
|
||||
uint32 ShadowRes;
|
||||
uint32 ArcaneRes;
|
||||
uint32 Delay;
|
||||
uint32 Ammo_type;
|
||||
float RangedModRange;
|
||||
_ItemSpell Spells[5];
|
||||
uint32 Bonding;
|
||||
std::string Description;
|
||||
uint32 PageText;
|
||||
uint32 LanguageID;
|
||||
uint32 PageMaterial;
|
||||
uint32 StartQuest;
|
||||
uint32 LockID;
|
||||
uint32 Material;
|
||||
uint32 Sheath;
|
||||
uint32 Extra;
|
||||
uint32 Unk1;
|
||||
uint32 Block;
|
||||
uint32 ItemSet;
|
||||
uint32 MaxDurability;
|
||||
uint32 Area;
|
||||
uint32 Map;
|
||||
uint32 BagFamily;
|
||||
uint32 TotemCategory;
|
||||
_ItemSocket Socket[3];
|
||||
uint32 socketBonus;
|
||||
uint32 GemProperties;
|
||||
uint32 ExtendedCost;
|
||||
uint32 RequiredArenaRank;
|
||||
uint32 RequiredDisenchantSkill;
|
||||
float ArmorDamageModifier;
|
||||
};
|
||||
|
||||
class Item : public Object
|
||||
{
|
||||
public:
|
||||
Item();
|
||||
void Create(uint64);
|
||||
uint8 GetSlot(void) { return _slot; }
|
||||
void SetSlot(uint8 nr) { _slot = nr; }
|
||||
uint32 GetEntry() const { return GetUInt32Value(OBJECT_FIELD_ENTRY); }
|
||||
uint32 GetCount() const { return GetUInt32Value(ITEM_FIELD_STACK_COUNT); }
|
||||
Bag *GetBag(void) { return _bag; }
|
||||
bool IsInBag() const { return _bag != NULL; }
|
||||
|
||||
protected:
|
||||
uint8 _slot;
|
||||
Bag *_bag;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
#ifndef _ITEM_H
|
||||
#define _ITEM_H
|
||||
|
||||
#include "common.h"
|
||||
#include "Object.h"
|
||||
|
||||
class Bag;
|
||||
|
||||
enum InventoryChangeFailure
|
||||
{
|
||||
EQUIP_ERR_OK = 0,
|
||||
EQUIP_ERR_YOU_MUST_REACH_LEVEL_N = 1,
|
||||
EQUIP_ERR_SKILL_ISNT_HIGH_ENOUGH = 2,
|
||||
EQUIP_ERR_ITEM_DOESNT_GO_TO_SLOT = 3,
|
||||
EQUIP_ERR_BAG_FULL = 4,
|
||||
EQUIP_ERR_NONEMPTY_BAG_OVER_OTHER_BAG = 5,
|
||||
EQUIP_ERR_CANT_TRADE_EQUIP_BAGS = 6,
|
||||
EQUIP_ERR_ONLY_AMMO_CAN_GO_HERE = 7,
|
||||
EQUIP_ERR_NO_REQUIRED_PROFICIENCY = 8,
|
||||
EQUIP_ERR_NO_EQUIPMENT_SLOT_AVAILABLE = 9,
|
||||
EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM = 10,
|
||||
EQUIP_ERR_YOU_CAN_NEVER_USE_THAT_ITEM2 = 11,
|
||||
EQUIP_ERR_NO_EQUIPMENT_SLOT_AVAILABLE2 = 12,
|
||||
EQUIP_ERR_CANT_EQUIP_WITH_TWOHANDED = 13,
|
||||
EQUIP_ERR_CANT_DUAL_WIELD = 14,
|
||||
EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG = 15,
|
||||
EQUIP_ERR_ITEM_DOESNT_GO_INTO_BAG2 = 16,
|
||||
EQUIP_ERR_CANT_CARRY_MORE_OF_THIS = 17,
|
||||
EQUIP_ERR_NO_EQUIPMENT_SLOT_AVAILABLE3 = 18,
|
||||
EQUIP_ERR_ITEM_CANT_STACK = 19,
|
||||
EQUIP_ERR_ITEM_CANT_BE_EQUIPPED = 20,
|
||||
EQUIP_ERR_ITEMS_CANT_BE_SWAPPED = 21,
|
||||
EQUIP_ERR_SLOT_IS_EMPTY = 22,
|
||||
EQUIP_ERR_ITEM_NOT_FOUND = 23,
|
||||
EQUIP_ERR_CANT_DROP_SOULBOUND = 24,
|
||||
EQUIP_ERR_OUT_OF_RANGE = 25,
|
||||
EQUIP_ERR_TRIED_TO_SPLIT_MORE_THAN_COUNT = 26,
|
||||
EQUIP_ERR_COULDNT_SPLIT_ITEMS = 27,
|
||||
EQUIP_ERR_MISSING_REAGENT = 28,
|
||||
EQUIP_ERR_NOT_ENOUGH_MONEY = 29,
|
||||
EQUIP_ERR_NOT_A_BAG = 30,
|
||||
EQUIP_ERR_CAN_ONLY_DO_WITH_EMPTY_BAGS = 31,
|
||||
EQUIP_ERR_DONT_OWN_THAT_ITEM = 32,
|
||||
EQUIP_ERR_CAN_EQUIP_ONLY1_QUIVER = 33,
|
||||
EQUIP_ERR_MUST_PURCHASE_THAT_BAG_SLOT = 34,
|
||||
EQUIP_ERR_TOO_FAR_AWAY_FROM_BANK = 35,
|
||||
EQUIP_ERR_ITEM_LOCKED = 36,
|
||||
EQUIP_ERR_YOU_ARE_STUNNED = 37,
|
||||
EQUIP_ERR_YOU_ARE_DEAD = 38,
|
||||
EQUIP_ERR_CANT_DO_RIGHT_NOW = 39,
|
||||
EQUIP_ERR_BAG_FULL2 = 40,
|
||||
EQUIP_ERR_CAN_EQUIP_ONLY1_QUIVER2 = 41,
|
||||
EQUIP_ERR_CAN_EQUIP_ONLY1_AMMOPOUCH = 42,
|
||||
EQUIP_ERR_STACKABLE_CANT_BE_WRAPPED = 43,
|
||||
EQUIP_ERR_EQUIPPED_CANT_BE_WRAPPED = 44,
|
||||
EQUIP_ERR_WRAPPED_CANT_BE_WRAPPED = 45,
|
||||
EQUIP_ERR_BOUND_CANT_BE_WRAPPED = 46,
|
||||
EQUIP_ERR_UNIQUE_CANT_BE_WRAPPED = 47,
|
||||
EQUIP_ERR_BAGS_CANT_BE_WRAPPED = 48,
|
||||
EQUIP_ERR_ALREADY_LOOTED = 49,
|
||||
EQUIP_ERR_INVENTORY_FULL = 50,
|
||||
EQUIP_ERR_BANK_FULL = 51,
|
||||
EQUIP_ERR_ITEM_IS_CURRENTLY_SOLD_OUT = 52,
|
||||
EQUIP_ERR_BAG_FULL3 = 53,
|
||||
EQUIP_ERR_ITEM_NOT_FOUND2 = 54,
|
||||
EQUIP_ERR_ITEM_CANT_STACK2 = 55,
|
||||
EQUIP_ERR_BAG_FULL4 = 56,
|
||||
EQUIP_ERR_ITEM_SOLD_OUT = 57,
|
||||
EQUIP_ERR_OBJECT_IS_BUSY = 58,
|
||||
EQUIP_ERR_NONE = 59,
|
||||
EQUIP_ERR_CANT_DO_IN_COMBAT = 60,
|
||||
EQUIP_CANT_DO_WHILE_DISARMED = 61,
|
||||
EQUIP_ERR_BAG_FULL6 = 62,
|
||||
EQUIP_ITEM_RANK_NOT_ENOUGH = 63,
|
||||
EQUIP_ITEM_REPUTATION_NOT_ENOUGH = 64,
|
||||
EQUIP_MORE_THAN1_SPECIAL_BAG = 65
|
||||
};
|
||||
|
||||
enum BuyFailure
|
||||
{
|
||||
BUY_ERR_CANT_FIND_ITEM = 0,
|
||||
BUY_ERR_ITEM_ALREADY_SOLD = 1,
|
||||
BUY_ERR_NOT_ENOUGHT_MONEY = 2,
|
||||
BUY_ERR_SELLER_DONT_LIKE_YOU = 4,
|
||||
BUY_ERR_DISTANCE_TOO_FAR = 5,
|
||||
BUY_ERR_CANT_CARRY_MORE = 8,
|
||||
BUY_ERR_LEVEL_REQUIRE = 11,
|
||||
BUY_ERR_REPUTATION_REQUIRE = 12
|
||||
};
|
||||
|
||||
enum SellFailure
|
||||
{
|
||||
SELL_ERR_CANT_FIND_ITEM = 1,
|
||||
SELL_ERR_CANT_SELL_ITEM = 2,
|
||||
SELL_ERR_CANT_FIND_VENDOR = 3
|
||||
};
|
||||
|
||||
enum ITEM_STAT_TYPE
|
||||
{
|
||||
ITEM_STAT_POWER = 0,
|
||||
ITEM_STAT_HEALTH = 1,
|
||||
ITEM_STAT_UNKNOWN = 2,
|
||||
ITEM_STAT_AGILITY = 3,
|
||||
ITEM_STAT_STRENGTH = 4,
|
||||
ITEM_STAT_INTELLECT = 5,
|
||||
ITEM_STAT_SPIRIT = 6,
|
||||
ITEM_STAT_STAMINA = 7
|
||||
};
|
||||
|
||||
enum ITEM_DAMAGE_TYPE
|
||||
{
|
||||
NORMAL_DAMAGE = 0,
|
||||
HOLY_DAMAGE = 1,
|
||||
FIRE_DAMAGE = 2,
|
||||
NATURE_DAMAGE = 3,
|
||||
FROST_DAMAGE = 4,
|
||||
SHADOW_DAMAGE = 5,
|
||||
ARCANE_DAMAGE = 6
|
||||
};
|
||||
|
||||
enum ITEM_SPELLTRIGGER_TYPE
|
||||
{
|
||||
USE = 0,
|
||||
ON_EQUIP = 1,
|
||||
CHANCE_ON_HIT = 2,
|
||||
SOULSTONE = 4
|
||||
};
|
||||
|
||||
enum ITEM_BONDING_TYPE
|
||||
{
|
||||
NO_BIND = 0,
|
||||
BIND_WHEN_PICKED_UP = 1,
|
||||
BIND_WHEN_EQUIPED = 2,
|
||||
BIND_WHEN_USE = 3,
|
||||
//TODO: Better name these
|
||||
QUEST_ITEM = 4,
|
||||
QUEST_ITEM1 = 5
|
||||
};
|
||||
|
||||
// masks for ITEM_FIELD_FLAGS field
|
||||
enum ITEM_FLAGS
|
||||
{
|
||||
ITEM_FLAGS_BINDED = 1
|
||||
};
|
||||
|
||||
enum BAG_FAMILY
|
||||
{
|
||||
BAG_FAMILY_NONE = 0,
|
||||
BAG_FAMILY_ARROWS = 1,
|
||||
BAG_FAMILY_BULLETS = 2,
|
||||
BAG_FAMILY_SOUL_SHARDS = 3,
|
||||
//BAG_FAMILY_UNK1 = 4,
|
||||
//BAG_FAMILY_UNK1 = 5,
|
||||
BAG_FAMILY_HERBS = 6,
|
||||
BAG_FAMILY_ENCHANTING_SUPP = 7,
|
||||
BAG_FAMILY_ENGINEERING_SUPP = 8,
|
||||
BAG_FAMILY_KEYS = 9,
|
||||
BAG_FAMILY_GEMS = 10,
|
||||
//BAG_FAMILY_UNK3 = 11,
|
||||
BAG_FAMILY_MINING_SUPP = 12
|
||||
};
|
||||
|
||||
enum INVENTORY_TYPES
|
||||
{
|
||||
INVTYPE_NON_EQUIP = 0,
|
||||
INVTYPE_HEAD = 1,
|
||||
INVTYPE_NECK = 2,
|
||||
INVTYPE_SHOULDERS = 3,
|
||||
INVTYPE_BODY = 4,
|
||||
INVTYPE_CHEST = 5,
|
||||
INVTYPE_WAIST = 6,
|
||||
INVTYPE_LEGS = 7,
|
||||
INVTYPE_FEET = 8,
|
||||
INVTYPE_WRISTS = 9,
|
||||
INVTYPE_HANDS = 10,
|
||||
INVTYPE_FINGER = 11,
|
||||
INVTYPE_TRINKET = 12,
|
||||
INVTYPE_WEAPON = 13,
|
||||
INVTYPE_SHIELD = 14,
|
||||
INVTYPE_RANGED = 15,
|
||||
INVTYPE_CLOAK = 16,
|
||||
INVTYPE_2HWEAPON = 17,
|
||||
INVTYPE_BAG = 18,
|
||||
INVTYPE_TABARD = 19,
|
||||
INVTYPE_ROBE = 20,
|
||||
INVTYPE_WEAPONMAINHAND = 21,
|
||||
INVTYPE_WEAPONOFFHAND = 22,
|
||||
INVTYPE_HOLDABLE = 23,
|
||||
INVTYPE_AMMO = 24,
|
||||
INVTYPE_THROWN = 25,
|
||||
INVTYPE_RANGEDRIGHT = 26,
|
||||
INVTYPE_SLOT_ITEM = 27,
|
||||
INVTYPE_RELIC = 28,
|
||||
NUM_INVENTORY_TYPES = 29
|
||||
};
|
||||
|
||||
enum INVENTORY_CLASS
|
||||
{
|
||||
ITEM_CLASS_CONSUMABLE = 0,
|
||||
ITEM_CLASS_CONTAINER = 1,
|
||||
ITEM_CLASS_WEAPON = 2,
|
||||
ITEM_CLASS_JEWELRY = 3,
|
||||
ITEM_CLASS_ARMOR = 4,
|
||||
ITEM_CLASS_REAGENT = 5,
|
||||
ITEM_CLASS_PROJECTILE = 6,
|
||||
ITEM_CLASS_TRADE_GOODS = 7,
|
||||
ITEM_CLASS_GENERIC = 8,
|
||||
ITEM_CLASS_BOOK = 9,
|
||||
ITEM_CLASS_MONEY = 10,
|
||||
ITEM_CLASS_QUIVER = 11,
|
||||
ITEM_CLASS_QUEST = 12,
|
||||
ITEM_CLASS_KEY = 13,
|
||||
ITEM_CLASS_PERMANENT = 14,
|
||||
ITEM_CLASS_JUNK = 15
|
||||
};
|
||||
|
||||
// Client understand only 0 subclass for ITEM_CLASS_CONSUMABLE
|
||||
// but this value used in code as implementation workaround
|
||||
enum ITEM_SUBCLASS_CONSUMABLE
|
||||
{
|
||||
ITEM_SUBCLASS_POTION = 1,
|
||||
ITEM_SUBCLASS_ELIXIR = 2,
|
||||
ITEM_SUBCLASS_FLASK = 3,
|
||||
ITEM_SUBCLASS_SCROLL = 4,
|
||||
ITEM_SUBCLASS_FOOD = 5,
|
||||
ITEM_SUBCLASS_ITEM_ENHANCEMENT = 6,
|
||||
ITEM_SUBCLASS_BANDAGE = 7
|
||||
};
|
||||
|
||||
enum ITEM_SUBCLASS_CONTAINER
|
||||
{
|
||||
ITEM_SUBCLASS_CONTAINER = 0,
|
||||
ITEM_SUBCLASS_SOUL_CONTAINER = 1,
|
||||
ITEM_SUBCLASS_HERB_CONTAINER = 2,
|
||||
ITEM_SUBCLASS_ENCHANTING_CONTAINER = 3,
|
||||
ITEM_SUBCLASS_ENGINEERING_CONTAINER = 4,
|
||||
ITEM_SUBCLASS_GEM_CONTAINER = 5,
|
||||
ITEM_SUBCLASS_MINING_CONTAINER = 6,
|
||||
ITEM_SUBCLASS_LEATHERWORKING_CONTAINER = 7
|
||||
};
|
||||
|
||||
enum INVENTORY_SUBCLASS_WEAPON
|
||||
{
|
||||
ITEM_SUBCLASS_WEAPON_AXE = 0,
|
||||
ITEM_SUBCLASS_WEAPON_AXE2 = 1,
|
||||
ITEM_SUBCLASS_WEAPON_BOW = 2,
|
||||
ITEM_SUBCLASS_WEAPON_GUN = 3,
|
||||
ITEM_SUBCLASS_WEAPON_MACE = 4,
|
||||
ITEM_SUBCLASS_WEAPON_MACE2 = 5,
|
||||
ITEM_SUBCLASS_WEAPON_POLEARM = 6,
|
||||
ITEM_SUBCLASS_WEAPON_SWORD = 7,
|
||||
ITEM_SUBCLASS_WEAPON_SWORD2 = 8,
|
||||
ITEM_SUBCLASS_WEAPON_obsolete = 9,
|
||||
ITEM_SUBCLASS_WEAPON_STAFF = 10,
|
||||
ITEM_SUBCLASS_WEAPON_EXOTIC = 11,
|
||||
ITEM_SUBCLASS_WEAPON_EXOTIC2 = 12,
|
||||
ITEM_SUBCLASS_WEAPON_UNARMED = 13,
|
||||
ITEM_SUBCLASS_WEAPON_GENERIC = 14,
|
||||
ITEM_SUBCLASS_WEAPON_DAGGER = 15,
|
||||
ITEM_SUBCLASS_WEAPON_THROWN = 16,
|
||||
ITEM_SUBCLASS_WEAPON_SPEAR = 17,
|
||||
ITEM_SUBCLASS_WEAPON_CROSSBOW = 18,
|
||||
ITEM_SUBCLASS_WEAPON_WAND = 19,
|
||||
ITEM_SUBCLASS_WEAPON_FISHING_POLE = 20
|
||||
};
|
||||
|
||||
enum ITEM_SUBCLASS_ARMOR
|
||||
{
|
||||
ITEM_SUBCLASS_ARMOR_GENERIC = 0,
|
||||
ITEM_SUBCLASS_ARMOR_CLOTH = 1,
|
||||
ITEM_SUBCLASS_ARMOR_LEATHER = 2,
|
||||
ITEM_SUBCLASS_ARMOR_MAIL = 3,
|
||||
ITEM_SUBCLASS_ARMOR_PLATE = 4,
|
||||
ITEM_SUBCLASS_ARMOR_BUCKLER = 5,
|
||||
ITEM_SUBCLASS_ARMOR_SHIELD = 6
|
||||
};
|
||||
|
||||
enum ITEM_SUBCLASS_PROJECTILE
|
||||
{
|
||||
ITEM_SUBCLASS_ARROW = 2,
|
||||
ITEM_SUBCLASS_BULLET = 3
|
||||
};
|
||||
|
||||
enum ITEM_SUBCLASS_TRADE_GOODS
|
||||
{
|
||||
ITEM_SUBCLASS_TRADE_GOODS = 0,
|
||||
ITEM_SUBCLASS_PARTS = 1,
|
||||
ITEM_SUBCLASS_EXPLOSIVES = 2,
|
||||
ITEM_SUBCLASS_DEVICES = 3,
|
||||
ITEM_SUBCLASS_JEWELCRAFTING = 4,
|
||||
ITEM_SUBCLASS_CLOTH = 5,
|
||||
ITEM_SUBCLASS_LEATHER = 6,
|
||||
ITEM_SUBCLASS_METAL_STONE = 7,
|
||||
ITEM_SUBCLASS_MEAT = 8,
|
||||
ITEM_SUBCLASS_HERB = 9,
|
||||
ITEM_SUBCLASS_ELEMENTAZL = 10,
|
||||
ITEM_SUBCLASS_TRADE_GOODS_OTHER = 11,
|
||||
ITEM_SUBCLASS_ENCHANTING = 12
|
||||
};
|
||||
|
||||
enum ITEM_SUBCLASS_BOOK
|
||||
{
|
||||
ITEM_SUBCLASS_BOOK = 0,
|
||||
ITEM_SUBCLASS_LEATHERWORKING_PATTERN = 1,
|
||||
ITEM_SUBCLASS_TAILORING_PATTERN = 2,
|
||||
ITEM_SUBCLASS_ENGINEERING_SCHEMATIC = 3,
|
||||
ITEM_SUBCLASS_COOKING_RECIPE = 5,
|
||||
ITEM_SUBCLASS_ALCHEMY_RECIPE = 6,
|
||||
ITEM_SUBCLASS_FIRST_AID_MANUAL = 7,
|
||||
ITEM_SUBCLASS_ENCHANTING_FORMULA = 8,
|
||||
ITEM_SUBCLASS_FISHING_MANUAL = 9
|
||||
};
|
||||
|
||||
enum ITEM_SUBCLASS_QUIVER
|
||||
{
|
||||
ITEM_SUBCLASS_QUIVER = 2,
|
||||
ITEM_SUBCLASS_AMMO_POUCH = 3
|
||||
};
|
||||
|
||||
struct _ItemStat
|
||||
{
|
||||
uint32 ItemStatType;
|
||||
uint32 ItemStatValue;
|
||||
|
||||
};
|
||||
|
||||
struct _ItemSpell
|
||||
{
|
||||
uint32 SpellId;
|
||||
uint32 SpellTrigger;
|
||||
uint32 SpellCharges;
|
||||
uint32 SpellCooldown;
|
||||
uint32 SpellCategory;
|
||||
uint32 SpellCategoryCooldown;
|
||||
|
||||
};
|
||||
|
||||
struct _ItemSocket
|
||||
{
|
||||
uint32 Color;
|
||||
uint32 Content;
|
||||
};
|
||||
|
||||
struct _ItemDamage
|
||||
{
|
||||
float DamageMin;
|
||||
float DamageMax;
|
||||
uint32 DamageType;
|
||||
|
||||
};
|
||||
|
||||
struct ItemProto
|
||||
{
|
||||
uint32 Id;
|
||||
uint32 Class;
|
||||
uint32 SubClass;
|
||||
std::string Name;
|
||||
uint32 DisplayInfoID;
|
||||
uint32 Quality;
|
||||
uint32 Flags;
|
||||
uint32 BuyCount;
|
||||
uint32 BuyPrice;
|
||||
uint32 SellPrice;
|
||||
uint32 InventoryType;
|
||||
uint32 AllowableClass;
|
||||
uint32 AllowableRace;
|
||||
uint32 ItemLevel;
|
||||
uint32 RequiredLevel;
|
||||
uint32 RequiredSkill;
|
||||
uint32 RequiredSkillRank;
|
||||
uint32 RequiredSpell;
|
||||
uint32 RequiredHonorRank;
|
||||
uint32 RequiredCityRank;
|
||||
uint32 RequiredReputationFaction;
|
||||
uint32 RequiredReputationRank;
|
||||
uint32 MaxCount;
|
||||
uint32 Stackable;
|
||||
uint32 ContainerSlots;
|
||||
_ItemStat ItemStat[10];
|
||||
_ItemDamage Damage[5];
|
||||
uint32 Armor;
|
||||
uint32 HolyRes;
|
||||
uint32 FireRes;
|
||||
uint32 NatureRes;
|
||||
uint32 FrostRes;
|
||||
uint32 ShadowRes;
|
||||
uint32 ArcaneRes;
|
||||
uint32 Delay;
|
||||
uint32 Ammo_type;
|
||||
float RangedModRange;
|
||||
_ItemSpell Spells[5];
|
||||
uint32 Bonding;
|
||||
std::string Description;
|
||||
uint32 PageText;
|
||||
uint32 LanguageID;
|
||||
uint32 PageMaterial;
|
||||
uint32 StartQuest;
|
||||
uint32 LockID;
|
||||
uint32 Material;
|
||||
uint32 Sheath;
|
||||
uint32 Extra;
|
||||
uint32 Unk1;
|
||||
uint32 Block;
|
||||
uint32 ItemSet;
|
||||
uint32 MaxDurability;
|
||||
uint32 Area;
|
||||
uint32 Map;
|
||||
uint32 BagFamily;
|
||||
uint32 TotemCategory;
|
||||
_ItemSocket Socket[3];
|
||||
uint32 socketBonus;
|
||||
uint32 GemProperties;
|
||||
uint32 ExtendedCost;
|
||||
uint32 RequiredArenaRank;
|
||||
uint32 RequiredDisenchantSkill;
|
||||
float ArmorDamageModifier;
|
||||
};
|
||||
|
||||
class Item : public Object
|
||||
{
|
||||
public:
|
||||
Item();
|
||||
void Create(uint64);
|
||||
uint8 GetSlot(void) { return _slot; }
|
||||
void SetSlot(uint8 nr) { _slot = nr; }
|
||||
uint32 GetEntry() const { return GetUInt32Value(OBJECT_FIELD_ENTRY); }
|
||||
uint32 GetCount() const { return GetUInt32Value(ITEM_FIELD_STACK_COUNT); }
|
||||
Bag *GetBag(void) { return _bag; }
|
||||
bool IsInBag() const { return _bag != NULL; }
|
||||
|
||||
protected:
|
||||
uint8 _slot;
|
||||
Bag *_bag;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,181 +1,181 @@
|
||||
#include "common.h"
|
||||
#include "log.h"
|
||||
#include "MapTile.h"
|
||||
#include "MapMgr.h"
|
||||
|
||||
MapMgr::MapMgr()
|
||||
{
|
||||
DEBUG(logdebug("Creating MapMgr with TILESIZE=%.3f CHUNKSIZE=%.3f UNITSIZE=%.3f",TILESIZE,CHUNKSIZE,UNITSIZE));
|
||||
_tiles = new MapTileStorage();
|
||||
_gridx = _gridy = _mapid = (-1);
|
||||
_mapsLoaded = false;
|
||||
}
|
||||
|
||||
MapMgr::~MapMgr()
|
||||
{
|
||||
Flush();
|
||||
delete _tiles;
|
||||
}
|
||||
|
||||
void MapMgr::Update(float x, float y, uint32 m)
|
||||
{
|
||||
if(m != _mapid)
|
||||
{
|
||||
Flush(); // we teleported to a new map, drop all loaded maps
|
||||
WDTFile *wdt = new WDTFile();
|
||||
char buf[100];
|
||||
sprintf(buf,"data/maps/%u.wdt",m);
|
||||
if(!wdt->Load(buf))
|
||||
{
|
||||
logerror("MAPMGR: Could not load WDT file '%s'",buf);
|
||||
}
|
||||
_tiles->ImportTileMap(wdt);
|
||||
delete wdt;
|
||||
_mapid = m;
|
||||
_gridx = _gridy = (-1); // must load tiles now
|
||||
}
|
||||
GridCoordPair gcoords = GetTransformGridCoordPair(x,y);
|
||||
if(gcoords.x != _gridx || gcoords.y != _gridy)
|
||||
{
|
||||
_gridx = gcoords.x;
|
||||
_gridy = gcoords.y;
|
||||
_LoadNearTiles(_gridx,_gridy,m);
|
||||
_UnloadOldTiles();
|
||||
}
|
||||
}
|
||||
|
||||
void MapMgr::Flush(void)
|
||||
{
|
||||
_mapsLoaded = false;
|
||||
for(uint32 i = 0; i < 4096; i++)
|
||||
_tiles->UnloadMapTile(i);
|
||||
logdebug("MAPMGR: Flushed all maps");
|
||||
}
|
||||
|
||||
void MapMgr::_LoadNearTiles(uint32 gx, uint32 gy, uint32 m)
|
||||
{
|
||||
logdebug("MAPMGR: Loading near tiles for (%u, %u) map %u",gx,gy,m);
|
||||
for(uint32 v = gy-1; v <= gy+1; v++)
|
||||
{
|
||||
for(uint32 h = gx-1; h <= gx+1; h++)
|
||||
{
|
||||
_LoadTile(h,v,m);
|
||||
}
|
||||
}
|
||||
_mapsLoaded = true;
|
||||
}
|
||||
|
||||
void MapMgr::_LoadTile(uint32 gx, uint32 gy, uint32 m)
|
||||
{
|
||||
if(!_tiles->TileExists(gx,gy))
|
||||
{
|
||||
logerror("MAPMGR: Not loading MapTile (%u, %u) map %u, no entry in WDT tile map",gx,gy,m);
|
||||
return;
|
||||
}
|
||||
|
||||
if( !_tiles->GetTile(gx,gy) )
|
||||
{
|
||||
ADTFile *adt = new ADTFile();
|
||||
char buf[300];
|
||||
sprintf(buf,"data/maps/%u_%u_%u.adt",m,gx,gy);
|
||||
if(adt->Load(buf))
|
||||
{
|
||||
logdebug("MAPMGR: Loaded ADT '%s'",buf);
|
||||
MapTile *tile = new MapTile();
|
||||
tile->ImportFromADT(adt);
|
||||
_tiles->SetTile(tile,gx,gy);
|
||||
logdebug("MAPMGR: Imported MapTile (%u, %u) for map %u",gx,gy,m);
|
||||
}
|
||||
else
|
||||
{
|
||||
logerror("MAPMGR: Loading ADT '%s' failed!",buf);
|
||||
}
|
||||
delete adt;
|
||||
}
|
||||
else
|
||||
{
|
||||
logdebug("MAPMGR: No need to load MapTile (%u, %u) map %u",gx,gy,m);
|
||||
}
|
||||
}
|
||||
|
||||
void MapMgr::_UnloadOldTiles(void)
|
||||
{
|
||||
for(uint32 gy=0; gy<64; gy++)
|
||||
{
|
||||
for(uint32 gx=0; gx<64; gx++)
|
||||
{
|
||||
if( (_gridx < gx-1 || _gridx > gx+1) && (_gridy < gy-1 || _gridy > gy+1) )
|
||||
{
|
||||
if(_tiles->GetTile(gx,gy))
|
||||
{
|
||||
logdebug("MAPMGR: Unloading old MapTile (%u, %u) map %u",gx,gy,_mapid);
|
||||
_tiles->UnloadMapTile(gx,gy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Using forceLoad is VERY ineffective here, because the tile is removed again after the next Update() call!
|
||||
MapTile *MapMgr::GetTile(uint32 xg, uint32 yg, bool forceLoad)
|
||||
{
|
||||
MapTile *tile = _tiles->GetTile(xg,yg);
|
||||
if(!tile)
|
||||
{
|
||||
_LoadTile(xg,yg,_mapid);
|
||||
tile = _tiles->GetTile(xg,yg);
|
||||
}
|
||||
return tile;
|
||||
}
|
||||
|
||||
MapTile *MapMgr::GetCurrentTile(void)
|
||||
{
|
||||
return GetTile(_gridx,_gridy);
|
||||
}
|
||||
|
||||
MapTile *MapMgr::GetNearTile(int32 xoffs, int32 yoffs)
|
||||
{
|
||||
return GetTile(_gridx + xoffs, _gridy + yoffs);
|
||||
}
|
||||
|
||||
uint32 MapMgr::GetGridCoord(float f)
|
||||
{
|
||||
return (ZEROPOINT - f) / TILESIZE;
|
||||
}
|
||||
|
||||
GridCoordPair MapMgr::GetTransformGridCoordPair(float x, float y)
|
||||
{
|
||||
return GridCoordPair(GetGridCoord(x), GetGridCoord(y));
|
||||
}
|
||||
|
||||
uint32 MapMgr::GetLoadedMapsCount(void)
|
||||
{
|
||||
uint32 counter = 0;
|
||||
for(uint32 i = 0; i < 4096; i++)
|
||||
{
|
||||
if(_tiles->GetTile(i))
|
||||
{
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
return counter;
|
||||
}
|
||||
|
||||
float MapMgr::GetZ(float x, float y)
|
||||
{
|
||||
return -99999.0f; // for now return lowest possible number, GetZ() will be implemented correctly later
|
||||
/* GridCoordPair gcoords = GetTransformGridCoordPair(x,y);
|
||||
MapTile *tile = _tiles->GetTile(gcoords.x,gcoords.y);
|
||||
if(tile)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
tile->DebugDumpToFile();
|
||||
logdebug("DEBUG: tile dumped");
|
||||
#endif
|
||||
return tile->GetZ(x,y);
|
||||
}
|
||||
|
||||
logerror("MapMgr::GetZ() called for not loaded MapTile (%u, %u) for (%f, %f)",gcoords.x,gcoords.y,x,y);
|
||||
return 0;*/
|
||||
}
|
||||
|
||||
#include "common.h"
|
||||
#include "log.h"
|
||||
#include "MapTile.h"
|
||||
#include "MapMgr.h"
|
||||
|
||||
MapMgr::MapMgr()
|
||||
{
|
||||
DEBUG(logdebug("Creating MapMgr with TILESIZE=%.3f CHUNKSIZE=%.3f UNITSIZE=%.3f",TILESIZE,CHUNKSIZE,UNITSIZE));
|
||||
_tiles = new MapTileStorage();
|
||||
_gridx = _gridy = _mapid = (-1);
|
||||
_mapsLoaded = false;
|
||||
}
|
||||
|
||||
MapMgr::~MapMgr()
|
||||
{
|
||||
Flush();
|
||||
delete _tiles;
|
||||
}
|
||||
|
||||
void MapMgr::Update(float x, float y, uint32 m)
|
||||
{
|
||||
if(m != _mapid)
|
||||
{
|
||||
Flush(); // we teleported to a new map, drop all loaded maps
|
||||
WDTFile *wdt = new WDTFile();
|
||||
char buf[100];
|
||||
sprintf(buf,"data/maps/%u.wdt",m);
|
||||
if(!wdt->Load(buf))
|
||||
{
|
||||
logerror("MAPMGR: Could not load WDT file '%s'",buf);
|
||||
}
|
||||
_tiles->ImportTileMap(wdt);
|
||||
delete wdt;
|
||||
_mapid = m;
|
||||
_gridx = _gridy = (-1); // must load tiles now
|
||||
}
|
||||
GridCoordPair gcoords = GetTransformGridCoordPair(x,y);
|
||||
if(gcoords.x != _gridx || gcoords.y != _gridy)
|
||||
{
|
||||
_gridx = gcoords.x;
|
||||
_gridy = gcoords.y;
|
||||
_LoadNearTiles(_gridx,_gridy,m);
|
||||
_UnloadOldTiles();
|
||||
}
|
||||
}
|
||||
|
||||
void MapMgr::Flush(void)
|
||||
{
|
||||
_mapsLoaded = false;
|
||||
for(uint32 i = 0; i < 4096; i++)
|
||||
_tiles->UnloadMapTile(i);
|
||||
logdebug("MAPMGR: Flushed all maps");
|
||||
}
|
||||
|
||||
void MapMgr::_LoadNearTiles(uint32 gx, uint32 gy, uint32 m)
|
||||
{
|
||||
logdebug("MAPMGR: Loading near tiles for (%u, %u) map %u",gx,gy,m);
|
||||
for(uint32 v = gy-1; v <= gy+1; v++)
|
||||
{
|
||||
for(uint32 h = gx-1; h <= gx+1; h++)
|
||||
{
|
||||
_LoadTile(h,v,m);
|
||||
}
|
||||
}
|
||||
_mapsLoaded = true;
|
||||
}
|
||||
|
||||
void MapMgr::_LoadTile(uint32 gx, uint32 gy, uint32 m)
|
||||
{
|
||||
if(!_tiles->TileExists(gx,gy))
|
||||
{
|
||||
logerror("MAPMGR: Not loading MapTile (%u, %u) map %u, no entry in WDT tile map",gx,gy,m);
|
||||
return;
|
||||
}
|
||||
|
||||
if( !_tiles->GetTile(gx,gy) )
|
||||
{
|
||||
ADTFile *adt = new ADTFile();
|
||||
char buf[300];
|
||||
sprintf(buf,"data/maps/%u_%u_%u.adt",m,gx,gy);
|
||||
if(adt->Load(buf))
|
||||
{
|
||||
logdebug("MAPMGR: Loaded ADT '%s'",buf);
|
||||
MapTile *tile = new MapTile();
|
||||
tile->ImportFromADT(adt);
|
||||
_tiles->SetTile(tile,gx,gy);
|
||||
logdebug("MAPMGR: Imported MapTile (%u, %u) for map %u",gx,gy,m);
|
||||
}
|
||||
else
|
||||
{
|
||||
logerror("MAPMGR: Loading ADT '%s' failed!",buf);
|
||||
}
|
||||
delete adt;
|
||||
}
|
||||
else
|
||||
{
|
||||
logdebug("MAPMGR: No need to load MapTile (%u, %u) map %u",gx,gy,m);
|
||||
}
|
||||
}
|
||||
|
||||
void MapMgr::_UnloadOldTiles(void)
|
||||
{
|
||||
for(uint32 gy=0; gy<64; gy++)
|
||||
{
|
||||
for(uint32 gx=0; gx<64; gx++)
|
||||
{
|
||||
if( (_gridx < gx-1 || _gridx > gx+1) && (_gridy < gy-1 || _gridy > gy+1) )
|
||||
{
|
||||
if(_tiles->GetTile(gx,gy))
|
||||
{
|
||||
logdebug("MAPMGR: Unloading old MapTile (%u, %u) map %u",gx,gy,_mapid);
|
||||
_tiles->UnloadMapTile(gx,gy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Using forceLoad is VERY ineffective here, because the tile is removed again after the next Update() call!
|
||||
MapTile *MapMgr::GetTile(uint32 xg, uint32 yg, bool forceLoad)
|
||||
{
|
||||
MapTile *tile = _tiles->GetTile(xg,yg);
|
||||
if(!tile)
|
||||
{
|
||||
_LoadTile(xg,yg,_mapid);
|
||||
tile = _tiles->GetTile(xg,yg);
|
||||
}
|
||||
return tile;
|
||||
}
|
||||
|
||||
MapTile *MapMgr::GetCurrentTile(void)
|
||||
{
|
||||
return GetTile(_gridx,_gridy);
|
||||
}
|
||||
|
||||
MapTile *MapMgr::GetNearTile(int32 xoffs, int32 yoffs)
|
||||
{
|
||||
return GetTile(_gridx + xoffs, _gridy + yoffs);
|
||||
}
|
||||
|
||||
uint32 MapMgr::GetGridCoord(float f)
|
||||
{
|
||||
return (ZEROPOINT - f) / TILESIZE;
|
||||
}
|
||||
|
||||
GridCoordPair MapMgr::GetTransformGridCoordPair(float x, float y)
|
||||
{
|
||||
return GridCoordPair(GetGridCoord(x), GetGridCoord(y));
|
||||
}
|
||||
|
||||
uint32 MapMgr::GetLoadedMapsCount(void)
|
||||
{
|
||||
uint32 counter = 0;
|
||||
for(uint32 i = 0; i < 4096; i++)
|
||||
{
|
||||
if(_tiles->GetTile(i))
|
||||
{
|
||||
counter++;
|
||||
}
|
||||
}
|
||||
return counter;
|
||||
}
|
||||
|
||||
float MapMgr::GetZ(float x, float y)
|
||||
{
|
||||
return -99999.0f; // for now return lowest possible number, GetZ() will be implemented correctly later
|
||||
/* GridCoordPair gcoords = GetTransformGridCoordPair(x,y);
|
||||
MapTile *tile = _tiles->GetTile(gcoords.x,gcoords.y);
|
||||
if(tile)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
tile->DebugDumpToFile();
|
||||
logdebug("DEBUG: tile dumped");
|
||||
#endif
|
||||
return tile->GetZ(x,y);
|
||||
}
|
||||
|
||||
logerror("MapMgr::GetZ() called for not loaded MapTile (%u, %u) for (%f, %f)",gcoords.x,gcoords.y,x,y);
|
||||
return 0;*/
|
||||
}
|
||||
|
||||
|
||||
@ -1,171 +1,171 @@
|
||||
#include "PseuWoW.h"
|
||||
#include "WorldSession.h"
|
||||
#include "World.h"
|
||||
#include "MovementMgr.h"
|
||||
#include "Player.h"
|
||||
|
||||
MovementMgr::MovementMgr()
|
||||
{
|
||||
_moveFlags = 0;
|
||||
_instance = NULL;
|
||||
_optime = 0;
|
||||
_updatetime = 0;
|
||||
}
|
||||
|
||||
MovementMgr::~MovementMgr()
|
||||
{
|
||||
}
|
||||
|
||||
void MovementMgr::SetInstance(PseuInstance *inst)
|
||||
{
|
||||
_movemode = MOVEMODE_MANUAL;
|
||||
_instance = inst;
|
||||
_mychar = inst->GetWSession()->GetMyChar();
|
||||
}
|
||||
|
||||
void MovementMgr::_BuildPacket(uint16 opcode)
|
||||
{
|
||||
WorldPacket wp(opcode,4+1+4+12); // it can be larger, if we are juming, on transport or swimming
|
||||
wp << _moveFlags;
|
||||
wp << (uint8)0; // unk
|
||||
wp << getMSTime();
|
||||
wp << _mychar->GetPosition();
|
||||
// TODO: transport not yet handled/done
|
||||
if(_moveFlags & MOVEMENTFLAG_ONTRANSPORT)
|
||||
{
|
||||
wp << (uint64)0; // transport guid
|
||||
wp << WorldPosition(); // transport position
|
||||
wp << getMSTime(); // transport time (??)
|
||||
}
|
||||
// TODO: swimming not yet done
|
||||
if(_moveFlags & MOVEMENTFLAG_SWIMMING)
|
||||
{
|
||||
wp << (float)0; // angle; 1.55=looking up, -1.55=looking down, 0=looking forward
|
||||
}
|
||||
wp << (uint32)0; // last fall time (also used when jumping)
|
||||
// TODO: jumping not yet done
|
||||
// TODO: spline not yet done
|
||||
|
||||
|
||||
_optime = getMSTime();
|
||||
|
||||
}
|
||||
|
||||
void MovementMgr::Update(bool calcpos)
|
||||
{
|
||||
uint32 curtime = getMSTime();
|
||||
uint32 timediff = curtime - _updatetime;
|
||||
_updatetime = curtime;
|
||||
|
||||
if(_movemode == MOVEMODE_AUTO)
|
||||
{
|
||||
WorldPosition& pos = _mychar->GetPosition();
|
||||
float turnspeed = _mychar->GetSpeed(MOVE_TURN) / 1000.0f * timediff;
|
||||
float runspeed = _mychar->GetSpeed(MOVE_RUN) / 1000.0f * timediff;
|
||||
float movespeed = runspeed; // or use walkspeed, depending on setting. for now use only runspeed
|
||||
// TODO: calc other speeds as soon as implemented
|
||||
|
||||
/*
|
||||
if(_moveFlags & MOVEMENTFLAG_FORWARD)
|
||||
{
|
||||
pos.x += movespeed * sin(pos.o);
|
||||
pos.y += movespeed * cos(pos.o);
|
||||
}
|
||||
// ...
|
||||
if(_moveFlags & MOVEMENTFLAG_LEFT)
|
||||
{
|
||||
pos.o -= turnspeed;
|
||||
}
|
||||
if(_moveFlags & MOVEMENTFLAG_RIGHT)
|
||||
{
|
||||
pos.o += turnspeed;
|
||||
}
|
||||
if(pos.o < 0)
|
||||
pos.o += 2 * M_PI;
|
||||
else if(pos.o > 2 * M_PI)
|
||||
pos.o -= 2 * M_PI;
|
||||
|
||||
pos.z = _instance->GetWSession()->GetWorld()->GetPosZ(pos.x,pos.y);
|
||||
*/
|
||||
// ^ It should look like this later on, but its not finished, and formulas are not tested.
|
||||
// see it as some future plans that need a lot of finetuning ;)
|
||||
}
|
||||
|
||||
// if we are moving, and 500ms have passed, send an heartbeat packet
|
||||
if( (_moveFlags & MOVEMENTFLAG_ANY_MOVE) && _optime + MOVE_HEARTBEAT_DELAY < getMSTime())
|
||||
{
|
||||
_BuildPacket(MSG_MOVE_HEARTBEAT);
|
||||
}
|
||||
|
||||
// TODO: apply gravity, handle falling, swimming, etc.
|
||||
}
|
||||
|
||||
void MovementMgr::MoveStop(void)
|
||||
{
|
||||
_moveFlags &= ~(MOVEMENTFLAG_ANY_MOVE);
|
||||
Update(false);
|
||||
_BuildPacket(MSG_MOVE_STOP);
|
||||
}
|
||||
|
||||
void MovementMgr::MoveStartForward(void)
|
||||
{
|
||||
_moveFlags |= MOVEMENTFLAG_FORWARD;
|
||||
_moveFlags &= ~MOVEMENTFLAG_BACKWARD;
|
||||
Update(false);
|
||||
_BuildPacket(MSG_MOVE_START_FORWARD);
|
||||
}
|
||||
|
||||
void MovementMgr::MoveStartBackward(void)
|
||||
{
|
||||
_moveFlags |= MOVEMENTFLAG_BACKWARD;
|
||||
_moveFlags &= ~MOVEMENTFLAG_FORWARD;
|
||||
Update(false);
|
||||
_BuildPacket(MSG_MOVE_START_BACKWARD);
|
||||
}
|
||||
|
||||
void MovementMgr::MoveStartStrafeLeft(void)
|
||||
{
|
||||
_moveFlags |= MOVEMENTFLAG_STRAFE_LEFT;
|
||||
_moveFlags &= ~MOVEMENTFLAG_STRAFE_RIGHT;
|
||||
Update(false);
|
||||
_BuildPacket(MSG_MOVE_START_STRAFE_LEFT);
|
||||
}
|
||||
|
||||
void MovementMgr::MoveStartStrafeRight(void)
|
||||
{
|
||||
_moveFlags |= MOVEMENTFLAG_STRAFE_RIGHT;
|
||||
_moveFlags &= ~MOVEMENTFLAG_STRAFE_LEFT;
|
||||
Update(false);
|
||||
_BuildPacket(MSG_MOVE_START_STRAFE_RIGHT);
|
||||
}
|
||||
|
||||
void MovementMgr::MoveStartTurnLeft(void)
|
||||
{
|
||||
_moveFlags |= MOVEMENTFLAG_LEFT;
|
||||
_moveFlags &= ~MOVEMENTFLAG_RIGHT;
|
||||
Update(false);
|
||||
_BuildPacket(MSG_MOVE_START_TURN_LEFT);
|
||||
}
|
||||
|
||||
void MovementMgr::MoveStartTurnRight(void)
|
||||
{
|
||||
_moveFlags |= MOVEMENTFLAG_RIGHT;
|
||||
_moveFlags &= ~MOVEMENTFLAG_LEFT;
|
||||
Update(false);
|
||||
_BuildPacket(MSG_MOVE_START_TURN_RIGHT);
|
||||
}
|
||||
|
||||
void MovementMgr::MoveStopTurn(void)
|
||||
{
|
||||
_moveFlags &= ~(MOVEMENTFLAG_LEFT | MOVEMENTFLAG_RIGHT);
|
||||
Update(false);
|
||||
_BuildPacket(MSG_MOVE_STOP_TURN);
|
||||
}
|
||||
|
||||
void MovementMgr::MoveSetFacing(float o)
|
||||
{
|
||||
_mychar->SetPosition(_mychar->GetX(), _mychar->GetY(), _mychar->GetZ(), o);
|
||||
Update(true);
|
||||
_BuildPacket(MSG_MOVE_SET_FACING);
|
||||
}
|
||||
|
||||
#include "PseuWoW.h"
|
||||
#include "WorldSession.h"
|
||||
#include "World.h"
|
||||
#include "MovementMgr.h"
|
||||
#include "Player.h"
|
||||
|
||||
MovementMgr::MovementMgr()
|
||||
{
|
||||
_moveFlags = 0;
|
||||
_instance = NULL;
|
||||
_optime = 0;
|
||||
_updatetime = 0;
|
||||
}
|
||||
|
||||
MovementMgr::~MovementMgr()
|
||||
{
|
||||
}
|
||||
|
||||
void MovementMgr::SetInstance(PseuInstance *inst)
|
||||
{
|
||||
_movemode = MOVEMODE_MANUAL;
|
||||
_instance = inst;
|
||||
_mychar = inst->GetWSession()->GetMyChar();
|
||||
}
|
||||
|
||||
void MovementMgr::_BuildPacket(uint16 opcode)
|
||||
{
|
||||
WorldPacket wp(opcode,4+1+4+12); // it can be larger, if we are juming, on transport or swimming
|
||||
wp << _moveFlags;
|
||||
wp << (uint8)0; // unk
|
||||
wp << getMSTime();
|
||||
wp << _mychar->GetPosition();
|
||||
// TODO: transport not yet handled/done
|
||||
if(_moveFlags & MOVEMENTFLAG_ONTRANSPORT)
|
||||
{
|
||||
wp << (uint64)0; // transport guid
|
||||
wp << WorldPosition(); // transport position
|
||||
wp << getMSTime(); // transport time (??)
|
||||
}
|
||||
// TODO: swimming not yet done
|
||||
if(_moveFlags & MOVEMENTFLAG_SWIMMING)
|
||||
{
|
||||
wp << (float)0; // angle; 1.55=looking up, -1.55=looking down, 0=looking forward
|
||||
}
|
||||
wp << (uint32)0; // last fall time (also used when jumping)
|
||||
// TODO: jumping not yet done
|
||||
// TODO: spline not yet done
|
||||
|
||||
|
||||
_optime = getMSTime();
|
||||
|
||||
}
|
||||
|
||||
void MovementMgr::Update(bool calcpos)
|
||||
{
|
||||
uint32 curtime = getMSTime();
|
||||
uint32 timediff = curtime - _updatetime;
|
||||
_updatetime = curtime;
|
||||
|
||||
if(_movemode == MOVEMODE_AUTO)
|
||||
{
|
||||
WorldPosition& pos = _mychar->GetPosition();
|
||||
float turnspeed = _mychar->GetSpeed(MOVE_TURN) / 1000.0f * timediff;
|
||||
float runspeed = _mychar->GetSpeed(MOVE_RUN) / 1000.0f * timediff;
|
||||
float movespeed = runspeed; // or use walkspeed, depending on setting. for now use only runspeed
|
||||
// TODO: calc other speeds as soon as implemented
|
||||
|
||||
/*
|
||||
if(_moveFlags & MOVEMENTFLAG_FORWARD)
|
||||
{
|
||||
pos.x += movespeed * sin(pos.o);
|
||||
pos.y += movespeed * cos(pos.o);
|
||||
}
|
||||
// ...
|
||||
if(_moveFlags & MOVEMENTFLAG_LEFT)
|
||||
{
|
||||
pos.o -= turnspeed;
|
||||
}
|
||||
if(_moveFlags & MOVEMENTFLAG_RIGHT)
|
||||
{
|
||||
pos.o += turnspeed;
|
||||
}
|
||||
if(pos.o < 0)
|
||||
pos.o += 2 * M_PI;
|
||||
else if(pos.o > 2 * M_PI)
|
||||
pos.o -= 2 * M_PI;
|
||||
|
||||
pos.z = _instance->GetWSession()->GetWorld()->GetPosZ(pos.x,pos.y);
|
||||
*/
|
||||
// ^ It should look like this later on, but its not finished, and formulas are not tested.
|
||||
// see it as some future plans that need a lot of finetuning ;)
|
||||
}
|
||||
|
||||
// if we are moving, and 500ms have passed, send an heartbeat packet
|
||||
if( (_moveFlags & MOVEMENTFLAG_ANY_MOVE) && _optime + MOVE_HEARTBEAT_DELAY < getMSTime())
|
||||
{
|
||||
_BuildPacket(MSG_MOVE_HEARTBEAT);
|
||||
}
|
||||
|
||||
// TODO: apply gravity, handle falling, swimming, etc.
|
||||
}
|
||||
|
||||
void MovementMgr::MoveStop(void)
|
||||
{
|
||||
_moveFlags &= ~(MOVEMENTFLAG_ANY_MOVE);
|
||||
Update(false);
|
||||
_BuildPacket(MSG_MOVE_STOP);
|
||||
}
|
||||
|
||||
void MovementMgr::MoveStartForward(void)
|
||||
{
|
||||
_moveFlags |= MOVEMENTFLAG_FORWARD;
|
||||
_moveFlags &= ~MOVEMENTFLAG_BACKWARD;
|
||||
Update(false);
|
||||
_BuildPacket(MSG_MOVE_START_FORWARD);
|
||||
}
|
||||
|
||||
void MovementMgr::MoveStartBackward(void)
|
||||
{
|
||||
_moveFlags |= MOVEMENTFLAG_BACKWARD;
|
||||
_moveFlags &= ~MOVEMENTFLAG_FORWARD;
|
||||
Update(false);
|
||||
_BuildPacket(MSG_MOVE_START_BACKWARD);
|
||||
}
|
||||
|
||||
void MovementMgr::MoveStartStrafeLeft(void)
|
||||
{
|
||||
_moveFlags |= MOVEMENTFLAG_STRAFE_LEFT;
|
||||
_moveFlags &= ~MOVEMENTFLAG_STRAFE_RIGHT;
|
||||
Update(false);
|
||||
_BuildPacket(MSG_MOVE_START_STRAFE_LEFT);
|
||||
}
|
||||
|
||||
void MovementMgr::MoveStartStrafeRight(void)
|
||||
{
|
||||
_moveFlags |= MOVEMENTFLAG_STRAFE_RIGHT;
|
||||
_moveFlags &= ~MOVEMENTFLAG_STRAFE_LEFT;
|
||||
Update(false);
|
||||
_BuildPacket(MSG_MOVE_START_STRAFE_RIGHT);
|
||||
}
|
||||
|
||||
void MovementMgr::MoveStartTurnLeft(void)
|
||||
{
|
||||
_moveFlags |= MOVEMENTFLAG_LEFT;
|
||||
_moveFlags &= ~MOVEMENTFLAG_RIGHT;
|
||||
Update(false);
|
||||
_BuildPacket(MSG_MOVE_START_TURN_LEFT);
|
||||
}
|
||||
|
||||
void MovementMgr::MoveStartTurnRight(void)
|
||||
{
|
||||
_moveFlags |= MOVEMENTFLAG_RIGHT;
|
||||
_moveFlags &= ~MOVEMENTFLAG_LEFT;
|
||||
Update(false);
|
||||
_BuildPacket(MSG_MOVE_START_TURN_RIGHT);
|
||||
}
|
||||
|
||||
void MovementMgr::MoveStopTurn(void)
|
||||
{
|
||||
_moveFlags &= ~(MOVEMENTFLAG_LEFT | MOVEMENTFLAG_RIGHT);
|
||||
Update(false);
|
||||
_BuildPacket(MSG_MOVE_STOP_TURN);
|
||||
}
|
||||
|
||||
void MovementMgr::MoveSetFacing(float o)
|
||||
{
|
||||
_mychar->SetPosition(_mychar->GetX(), _mychar->GetY(), _mychar->GetZ(), o);
|
||||
Update(true);
|
||||
_BuildPacket(MSG_MOVE_SET_FACING);
|
||||
}
|
||||
|
||||
|
||||
@ -1,85 +1,85 @@
|
||||
#ifndef MOVEMENTMGR_H
|
||||
#define MOVEMENTMGR_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define MOVE_HEARTBEAT_DELAY 500
|
||||
|
||||
enum MovementFlags
|
||||
{
|
||||
MOVEMENTFLAG_NONE = 0x00000000,
|
||||
MOVEMENTFLAG_FORWARD = 0x00000001,
|
||||
MOVEMENTFLAG_BACKWARD = 0x00000002,
|
||||
MOVEMENTFLAG_STRAFE_LEFT = 0x00000004,
|
||||
MOVEMENTFLAG_STRAFE_RIGHT = 0x00000008,
|
||||
MOVEMENTFLAG_LEFT = 0x00000010,
|
||||
MOVEMENTFLAG_RIGHT = 0x00000020,
|
||||
MOVEMENTFLAG_PITCH_UP = 0x00000040,
|
||||
MOVEMENTFLAG_PITCH_DOWN = 0x00000080,
|
||||
MOVEMENTFLAG_WALK = 0x00000100,
|
||||
MOVEMENTFLAG_ONTRANSPORT = 0x00000200,
|
||||
MOVEMENTFLAG_UNK1 = 0x00000400,
|
||||
MOVEMENTFLAG_FLY_UNK1 = 0x00000800,
|
||||
MOVEMENTFLAG_JUMPING = 0x00001000,
|
||||
MOVEMENTFLAG_UNK4 = 0x00002000,
|
||||
MOVEMENTFLAG_FALLING = 0x00004000,
|
||||
// 0x8000, 0x10000, 0x20000, 0x40000, 0x80000, 0x100000
|
||||
MOVEMENTFLAG_SWIMMING = 0x00200000, // appears with fly flag also
|
||||
MOVEMENTFLAG_FLY_UP = 0x00400000,
|
||||
MOVEMENTFLAG_CAN_FLY = 0x00800000,
|
||||
MOVEMENTFLAG_FLYING = 0x01000000,
|
||||
MOVEMENTFLAG_UNK5 = 0x02000000,
|
||||
MOVEMENTFLAG_SPLINE = 0x04000000, // probably wrong name
|
||||
MOVEMENTFLAG_SPLINE2 = 0x08000000,
|
||||
MOVEMENTFLAG_WATERWALKING = 0x10000000,
|
||||
MOVEMENTFLAG_SAFE_FALL = 0x20000000, // active rogue safe fall spell (passive)
|
||||
MOVEMENTFLAG_UNK3 = 0x40000000,
|
||||
|
||||
// custom flags
|
||||
MOVEMENTFLAG_ANY_MOVE = (MOVEMENTFLAG_BACKWARD | MOVEMENTFLAG_FORWARD | MOVEMENTFLAG_STRAFE_LEFT | MOVEMENTFLAG_STRAFE_RIGHT
|
||||
| MOVEMENTFLAG_LEFT | MOVEMENTFLAG_RIGHT)
|
||||
};
|
||||
|
||||
enum MoveModes
|
||||
{
|
||||
MOVEMODE_AUTO, // CPU controlling movement, MyCharacter must be updated
|
||||
MOVEMODE_MANUAL, // user controlling movement, MyCharacter is updated by the GUI already
|
||||
};
|
||||
|
||||
class PseuInstance;
|
||||
class MyCharacter;
|
||||
|
||||
|
||||
class MovementMgr
|
||||
{
|
||||
public:
|
||||
MovementMgr();
|
||||
~MovementMgr();
|
||||
void SetInstance(PseuInstance*);
|
||||
inline void SetMoveMode(uint8 mode) { _movemode = mode; }
|
||||
void Update(bool);
|
||||
void MoveStartForward(void);
|
||||
void MoveStartBackward(void);
|
||||
void MoveStop(void);
|
||||
void MoveStartStrafeLeft(void);
|
||||
void MoveStartStrafeRight(void);
|
||||
void MoveStartTurnLeft(void);
|
||||
void MoveStartTurnRight(void);
|
||||
void MoveStopTurn(void);
|
||||
void MoveFallLand(void);
|
||||
void MoveSetFacing(float);
|
||||
|
||||
private:
|
||||
void _BuildPacket(uint16);
|
||||
PseuInstance *_instance;
|
||||
MyCharacter *_mychar;
|
||||
uint32 _moveFlags; // server relevant flags (move forward/backward/swim/fly/jump/etc)
|
||||
uint32 _updatetime; // timeMS of last update cycle
|
||||
uint32 _optime; // timeMS when last opcode was sent
|
||||
uint8 _movemode; // automatic or manual
|
||||
UnitMoveType _movetype; // index used for speed selection
|
||||
|
||||
|
||||
};
|
||||
|
||||
#ifndef MOVEMENTMGR_H
|
||||
#define MOVEMENTMGR_H
|
||||
|
||||
#include "common.h"
|
||||
|
||||
#define MOVE_HEARTBEAT_DELAY 500
|
||||
|
||||
enum MovementFlags
|
||||
{
|
||||
MOVEMENTFLAG_NONE = 0x00000000,
|
||||
MOVEMENTFLAG_FORWARD = 0x00000001,
|
||||
MOVEMENTFLAG_BACKWARD = 0x00000002,
|
||||
MOVEMENTFLAG_STRAFE_LEFT = 0x00000004,
|
||||
MOVEMENTFLAG_STRAFE_RIGHT = 0x00000008,
|
||||
MOVEMENTFLAG_LEFT = 0x00000010,
|
||||
MOVEMENTFLAG_RIGHT = 0x00000020,
|
||||
MOVEMENTFLAG_PITCH_UP = 0x00000040,
|
||||
MOVEMENTFLAG_PITCH_DOWN = 0x00000080,
|
||||
MOVEMENTFLAG_WALK = 0x00000100,
|
||||
MOVEMENTFLAG_ONTRANSPORT = 0x00000200,
|
||||
MOVEMENTFLAG_UNK1 = 0x00000400,
|
||||
MOVEMENTFLAG_FLY_UNK1 = 0x00000800,
|
||||
MOVEMENTFLAG_JUMPING = 0x00001000,
|
||||
MOVEMENTFLAG_UNK4 = 0x00002000,
|
||||
MOVEMENTFLAG_FALLING = 0x00004000,
|
||||
// 0x8000, 0x10000, 0x20000, 0x40000, 0x80000, 0x100000
|
||||
MOVEMENTFLAG_SWIMMING = 0x00200000, // appears with fly flag also
|
||||
MOVEMENTFLAG_FLY_UP = 0x00400000,
|
||||
MOVEMENTFLAG_CAN_FLY = 0x00800000,
|
||||
MOVEMENTFLAG_FLYING = 0x01000000,
|
||||
MOVEMENTFLAG_UNK5 = 0x02000000,
|
||||
MOVEMENTFLAG_SPLINE = 0x04000000, // probably wrong name
|
||||
MOVEMENTFLAG_SPLINE2 = 0x08000000,
|
||||
MOVEMENTFLAG_WATERWALKING = 0x10000000,
|
||||
MOVEMENTFLAG_SAFE_FALL = 0x20000000, // active rogue safe fall spell (passive)
|
||||
MOVEMENTFLAG_UNK3 = 0x40000000,
|
||||
|
||||
// custom flags
|
||||
MOVEMENTFLAG_ANY_MOVE = (MOVEMENTFLAG_BACKWARD | MOVEMENTFLAG_FORWARD | MOVEMENTFLAG_STRAFE_LEFT | MOVEMENTFLAG_STRAFE_RIGHT
|
||||
| MOVEMENTFLAG_LEFT | MOVEMENTFLAG_RIGHT)
|
||||
};
|
||||
|
||||
enum MoveModes
|
||||
{
|
||||
MOVEMODE_AUTO, // CPU controlling movement, MyCharacter must be updated
|
||||
MOVEMODE_MANUAL, // user controlling movement, MyCharacter is updated by the GUI already
|
||||
};
|
||||
|
||||
class PseuInstance;
|
||||
class MyCharacter;
|
||||
|
||||
|
||||
class MovementMgr
|
||||
{
|
||||
public:
|
||||
MovementMgr();
|
||||
~MovementMgr();
|
||||
void SetInstance(PseuInstance*);
|
||||
inline void SetMoveMode(uint8 mode) { _movemode = mode; }
|
||||
void Update(bool);
|
||||
void MoveStartForward(void);
|
||||
void MoveStartBackward(void);
|
||||
void MoveStop(void);
|
||||
void MoveStartStrafeLeft(void);
|
||||
void MoveStartStrafeRight(void);
|
||||
void MoveStartTurnLeft(void);
|
||||
void MoveStartTurnRight(void);
|
||||
void MoveStopTurn(void);
|
||||
void MoveFallLand(void);
|
||||
void MoveSetFacing(float);
|
||||
|
||||
private:
|
||||
void _BuildPacket(uint16);
|
||||
PseuInstance *_instance;
|
||||
MyCharacter *_mychar;
|
||||
uint32 _moveFlags; // server relevant flags (move forward/backward/swim/fly/jump/etc)
|
||||
uint32 _updatetime; // timeMS of last update cycle
|
||||
uint32 _optime; // timeMS when last opcode was sent
|
||||
uint8 _movemode; // automatic or manual
|
||||
UnitMoveType _movetype; // index used for speed selection
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
@ -1,153 +1,153 @@
|
||||
#include "common.h"
|
||||
#include "log.h"
|
||||
#include "PseuWoW.h"
|
||||
#include "ObjMgr.h"
|
||||
#include "GUI/PseuGUI.h"
|
||||
|
||||
ObjMgr::ObjMgr()
|
||||
{
|
||||
DEBUG(logdebug("DEBUG: ObjMgr created"));
|
||||
}
|
||||
|
||||
ObjMgr::~ObjMgr()
|
||||
{
|
||||
RemoveAll();
|
||||
}
|
||||
|
||||
void ObjMgr::SetInstance(PseuInstance *i)
|
||||
{
|
||||
_instance = i;
|
||||
DEBUG(logdebug("DEBUG: ObjMgr instance set to 0x%X",i));
|
||||
}
|
||||
|
||||
void ObjMgr::RemoveAll(void)
|
||||
{
|
||||
for(ItemProtoMap::iterator i = _iproto.begin(); i!=_iproto.end(); i++)
|
||||
{
|
||||
delete i->second;
|
||||
}
|
||||
for(CreatureTemplateMap::iterator i = _creature_templ.begin(); i!=_creature_templ.end(); i++)
|
||||
{
|
||||
delete i->second;
|
||||
}
|
||||
while(_obj.size())
|
||||
{
|
||||
Remove(_obj.begin()->first);
|
||||
}
|
||||
}
|
||||
|
||||
void ObjMgr::Remove(uint64 guid)
|
||||
{
|
||||
Object *o = GetObj(guid);
|
||||
if(o)
|
||||
{
|
||||
PseuGUI *gui = _instance->GetGUI();
|
||||
if(gui)
|
||||
gui->NotifyObjectDeletion(guid); // we have a gui, which must delete linked DrawObject
|
||||
_obj.erase(guid); // now delete the obj from the mgr
|
||||
delete o; // and delete the obj itself
|
||||
}
|
||||
else
|
||||
{
|
||||
_obj.erase(guid);
|
||||
logcustom(2,LRED,"ObjMgr::Remove("I64FMT") - not existing",guid);
|
||||
}
|
||||
}
|
||||
|
||||
// -- Object part --
|
||||
|
||||
void ObjMgr::Add(Object *o)
|
||||
{
|
||||
_obj[o->GetGUID()] = o;
|
||||
|
||||
PseuGUI *gui = _instance->GetGUI();
|
||||
if(gui)
|
||||
gui->NotifyObjectCreation(o);
|
||||
}
|
||||
|
||||
Object *ObjMgr::GetObj(uint64 guid)
|
||||
{
|
||||
if(!guid)
|
||||
return NULL;
|
||||
for(ObjectMap::iterator i = _obj.begin(); i!=_obj.end(); i++)
|
||||
if(i->second->GetGUID() == guid)
|
||||
return i->second;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// iterate over all objects and assign a name to all matching the entry and typeid
|
||||
uint32 ObjMgr::AssignNameToObj(uint32 entry, uint8 type, std::string name)
|
||||
{
|
||||
uint32 changed = 0;
|
||||
for(ObjectMap::iterator it = _obj.begin(); it != _obj.end(); it++)
|
||||
{
|
||||
if(it->second->GetEntry() && (it->second->GetTypeId() == type))
|
||||
{
|
||||
it->second->SetName(name);
|
||||
changed++;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
// -- Item part --
|
||||
|
||||
void ObjMgr::Add(ItemProto *proto)
|
||||
{
|
||||
_iproto[proto->Id] = proto;
|
||||
}
|
||||
|
||||
ItemProto *ObjMgr::GetItemProto(uint32 entry)
|
||||
{
|
||||
ItemProtoMap::iterator it = _iproto.find(entry);
|
||||
if(it != _iproto.end())
|
||||
return it->second;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ObjMgr::AddNonexistentItem(uint32 id)
|
||||
{
|
||||
_noitem.insert(id);
|
||||
}
|
||||
|
||||
bool ObjMgr::ItemNonExistent(uint32 id)
|
||||
{
|
||||
return _noitem.find(id) != _noitem.end();
|
||||
}
|
||||
|
||||
// -- Creature part --
|
||||
|
||||
void ObjMgr::Add(CreatureTemplate *cr)
|
||||
{
|
||||
_creature_templ[cr->entry] = cr;
|
||||
}
|
||||
|
||||
CreatureTemplate *ObjMgr::GetCreatureTemplate(uint32 entry)
|
||||
{
|
||||
CreatureTemplateMap::iterator it = _creature_templ.find(entry);
|
||||
if(it != _creature_templ.end())
|
||||
return it->second;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ObjMgr::AddNonexistentCreature(uint32 id)
|
||||
{
|
||||
_nocreature.insert(id);
|
||||
}
|
||||
|
||||
bool ObjMgr::CreatureNonExistent(uint32 id)
|
||||
{
|
||||
return _nocreature.find(id) != _nocreature.end();
|
||||
}
|
||||
|
||||
// -- misc part --
|
||||
|
||||
void ObjMgr::AddRequestedPlayerGUID(uint32 loguid)
|
||||
{
|
||||
_reqpnames.insert(loguid);
|
||||
}
|
||||
|
||||
bool ObjMgr::IsRequestedPlayerGUID(uint32 loguid)
|
||||
{
|
||||
return _reqpnames.find(loguid) != _reqpnames.end();
|
||||
}
|
||||
#include "common.h"
|
||||
#include "log.h"
|
||||
#include "PseuWoW.h"
|
||||
#include "ObjMgr.h"
|
||||
#include "GUI/PseuGUI.h"
|
||||
|
||||
ObjMgr::ObjMgr()
|
||||
{
|
||||
DEBUG(logdebug("DEBUG: ObjMgr created"));
|
||||
}
|
||||
|
||||
ObjMgr::~ObjMgr()
|
||||
{
|
||||
RemoveAll();
|
||||
}
|
||||
|
||||
void ObjMgr::SetInstance(PseuInstance *i)
|
||||
{
|
||||
_instance = i;
|
||||
DEBUG(logdebug("DEBUG: ObjMgr instance set to 0x%X",i));
|
||||
}
|
||||
|
||||
void ObjMgr::RemoveAll(void)
|
||||
{
|
||||
for(ItemProtoMap::iterator i = _iproto.begin(); i!=_iproto.end(); i++)
|
||||
{
|
||||
delete i->second;
|
||||
}
|
||||
for(CreatureTemplateMap::iterator i = _creature_templ.begin(); i!=_creature_templ.end(); i++)
|
||||
{
|
||||
delete i->second;
|
||||
}
|
||||
while(_obj.size())
|
||||
{
|
||||
Remove(_obj.begin()->first);
|
||||
}
|
||||
}
|
||||
|
||||
void ObjMgr::Remove(uint64 guid)
|
||||
{
|
||||
Object *o = GetObj(guid);
|
||||
if(o)
|
||||
{
|
||||
PseuGUI *gui = _instance->GetGUI();
|
||||
if(gui)
|
||||
gui->NotifyObjectDeletion(guid); // we have a gui, which must delete linked DrawObject
|
||||
_obj.erase(guid); // now delete the obj from the mgr
|
||||
delete o; // and delete the obj itself
|
||||
}
|
||||
else
|
||||
{
|
||||
_obj.erase(guid);
|
||||
logcustom(2,LRED,"ObjMgr::Remove("I64FMT") - not existing",guid);
|
||||
}
|
||||
}
|
||||
|
||||
// -- Object part --
|
||||
|
||||
void ObjMgr::Add(Object *o)
|
||||
{
|
||||
_obj[o->GetGUID()] = o;
|
||||
|
||||
PseuGUI *gui = _instance->GetGUI();
|
||||
if(gui)
|
||||
gui->NotifyObjectCreation(o);
|
||||
}
|
||||
|
||||
Object *ObjMgr::GetObj(uint64 guid)
|
||||
{
|
||||
if(!guid)
|
||||
return NULL;
|
||||
for(ObjectMap::iterator i = _obj.begin(); i!=_obj.end(); i++)
|
||||
if(i->second->GetGUID() == guid)
|
||||
return i->second;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// iterate over all objects and assign a name to all matching the entry and typeid
|
||||
uint32 ObjMgr::AssignNameToObj(uint32 entry, uint8 type, std::string name)
|
||||
{
|
||||
uint32 changed = 0;
|
||||
for(ObjectMap::iterator it = _obj.begin(); it != _obj.end(); it++)
|
||||
{
|
||||
if(it->second->GetEntry() && (it->second->GetTypeId() == type))
|
||||
{
|
||||
it->second->SetName(name);
|
||||
changed++;
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
// -- Item part --
|
||||
|
||||
void ObjMgr::Add(ItemProto *proto)
|
||||
{
|
||||
_iproto[proto->Id] = proto;
|
||||
}
|
||||
|
||||
ItemProto *ObjMgr::GetItemProto(uint32 entry)
|
||||
{
|
||||
ItemProtoMap::iterator it = _iproto.find(entry);
|
||||
if(it != _iproto.end())
|
||||
return it->second;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ObjMgr::AddNonexistentItem(uint32 id)
|
||||
{
|
||||
_noitem.insert(id);
|
||||
}
|
||||
|
||||
bool ObjMgr::ItemNonExistent(uint32 id)
|
||||
{
|
||||
return _noitem.find(id) != _noitem.end();
|
||||
}
|
||||
|
||||
// -- Creature part --
|
||||
|
||||
void ObjMgr::Add(CreatureTemplate *cr)
|
||||
{
|
||||
_creature_templ[cr->entry] = cr;
|
||||
}
|
||||
|
||||
CreatureTemplate *ObjMgr::GetCreatureTemplate(uint32 entry)
|
||||
{
|
||||
CreatureTemplateMap::iterator it = _creature_templ.find(entry);
|
||||
if(it != _creature_templ.end())
|
||||
return it->second;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void ObjMgr::AddNonexistentCreature(uint32 id)
|
||||
{
|
||||
_nocreature.insert(id);
|
||||
}
|
||||
|
||||
bool ObjMgr::CreatureNonExistent(uint32 id)
|
||||
{
|
||||
return _nocreature.find(id) != _nocreature.end();
|
||||
}
|
||||
|
||||
// -- misc part --
|
||||
|
||||
void ObjMgr::AddRequestedPlayerGUID(uint32 loguid)
|
||||
{
|
||||
_reqpnames.insert(loguid);
|
||||
}
|
||||
|
||||
bool ObjMgr::IsRequestedPlayerGUID(uint32 loguid)
|
||||
{
|
||||
return _reqpnames.find(loguid) != _reqpnames.end();
|
||||
}
|
||||
|
||||
@ -1,177 +1,177 @@
|
||||
#ifndef _OBJECT_H
|
||||
#define _OBJECT_H
|
||||
|
||||
#include "UpdateFields.h"
|
||||
#include "ObjectDefines.h"
|
||||
#include "common.h"
|
||||
#include "HelperDefs.h"
|
||||
#include "World.h"
|
||||
|
||||
enum TYPE
|
||||
{
|
||||
TYPE_OBJECT = 1,
|
||||
TYPE_ITEM = 2,
|
||||
TYPE_CONTAINER = 6, // a container is ALWAYS an item!
|
||||
TYPE_UNIT = 8,
|
||||
TYPE_PLAYER = 16,
|
||||
TYPE_GAMEOBJECT = 32,
|
||||
TYPE_DYNAMICOBJECT = 64,
|
||||
TYPE_CORPSE = 128,
|
||||
TYPE_AIGROUP = 256,
|
||||
TYPE_AREATRIGGER = 512
|
||||
};
|
||||
|
||||
enum TYPEID
|
||||
{
|
||||
TYPEID_OBJECT = 0,
|
||||
TYPEID_ITEM = 1,
|
||||
TYPEID_CONTAINER = 2,
|
||||
TYPEID_UNIT = 3,
|
||||
TYPEID_PLAYER = 4,
|
||||
TYPEID_GAMEOBJECT = 5,
|
||||
TYPEID_DYNAMICOBJECT = 6,
|
||||
TYPEID_CORPSE = 7,
|
||||
TYPEID_AIGROUP = 8,
|
||||
TYPEID_AREATRIGGER = 9
|
||||
};
|
||||
|
||||
class Object
|
||||
{
|
||||
public:
|
||||
virtual ~Object();
|
||||
inline const uint64 GetGUID() const { return GetUInt64Value(0); }
|
||||
inline const uint32 GetGUIDLow() const { return GetUInt32Value(0); }
|
||||
inline const uint32 GetGUIDHigh() const { return GetUInt32Value(1); }
|
||||
inline uint32 GetEntry() const { return GetUInt32Value(OBJECT_FIELD_ENTRY); }
|
||||
inline uint16 GetValuesCount(void) { return _valuescount; }
|
||||
|
||||
inline const uint8 GetTypeId() { return _typeid; }
|
||||
inline const uint8 GetTypeMask() { return _type; }
|
||||
inline bool IsType(uint8 mask) { return (mask & _type) ? true : false; }
|
||||
inline bool IsPlayer(void) { return _typeid == TYPEID_PLAYER; } // specific
|
||||
inline bool IsUnit(void) { return _type & TYPE_UNIT; } // generic (unit = creature or player)
|
||||
inline bool IsCreature(void) { return IsUnit() && !IsPlayer(); } // specific
|
||||
inline bool IsItem(void) { return _type & TYPE_ITEM; } // generic (item or container)
|
||||
inline bool IsContainer(void) { return _typeid == TYPEID_CONTAINER; } // specific
|
||||
inline bool IsCorpse(void) { return _typeid == TYPEID_CORPSE; } // specific
|
||||
inline bool IsDynObject(void) { return _typeid == TYPEID_DYNAMICOBJECT; } // specific
|
||||
inline bool IsWorldObject(void) { return _type & (TYPE_PLAYER | TYPE_UNIT | TYPE_CORPSE | TYPE_DYNAMICOBJECT | TYPE_GAMEOBJECT); }
|
||||
inline const uint32 GetUInt32Value( uint16 index ) const
|
||||
{
|
||||
return _uint32values[ index ];
|
||||
}
|
||||
|
||||
inline const uint64 GetUInt64Value( uint16 index ) const
|
||||
{
|
||||
return *((uint64*)&(_uint32values[ index ]));
|
||||
}
|
||||
|
||||
inline bool HasFlag( uint16 index, uint32 flag ) const
|
||||
{
|
||||
return (_uint32values[ index ] & flag) != 0;
|
||||
}
|
||||
inline const float GetFloatValue( uint16 index ) const
|
||||
{
|
||||
return _floatvalues[ index ];
|
||||
}
|
||||
inline void SetFloatValue( uint16 index, float value )
|
||||
{
|
||||
_floatvalues[ index ] = value;
|
||||
}
|
||||
inline void SetUInt32Value( uint16 index, uint32 value )
|
||||
{
|
||||
_uint32values[ index ] = value;
|
||||
}
|
||||
|
||||
inline void SetName(std::string name) { _name = name; }
|
||||
inline std::string GetName(void) { return _name; }
|
||||
|
||||
inline float GetObjectSize() const
|
||||
{
|
||||
return ( _valuescount > UNIT_FIELD_BOUNDINGRADIUS ) ? _floatvalues[UNIT_FIELD_BOUNDINGRADIUS] : 0.39f;
|
||||
}
|
||||
|
||||
void Create(uint64 guid);
|
||||
|
||||
protected:
|
||||
Object();
|
||||
void _InitValues(void);
|
||||
|
||||
uint16 _valuescount;
|
||||
union
|
||||
{
|
||||
uint32 *_uint32values;
|
||||
float *_floatvalues;
|
||||
};
|
||||
uint8 _type;
|
||||
uint8 _typeid;
|
||||
std::string _name;
|
||||
};
|
||||
|
||||
class WorldObject : public Object
|
||||
{
|
||||
public:
|
||||
virtual ~WorldObject ( ) {}
|
||||
void SetPosition(float x, float y, float z, float o, uint16 _map);
|
||||
void SetPosition(float x, float y, float z, float o);
|
||||
inline void SetPosition(WorldPosition& wp) { _wpos = wp; }
|
||||
inline void SetPosition(WorldPosition& wp, uint16 mapid) { SetPosition(wp); _m = mapid; }
|
||||
inline WorldPosition GetPosition(void) {return _wpos; }
|
||||
inline float GetX(void) { return _wpos.x; }
|
||||
inline float GetY(void) { return _wpos.y; }
|
||||
inline float GetZ(void) { return _wpos.z; }
|
||||
inline float GetO(void) { return _wpos.o; }
|
||||
float GetDistance(WorldObject *obj);
|
||||
float GetDistance2d(float x, float y);
|
||||
float GetDistance(float x, float y, float z);
|
||||
float GetDistance2d(WorldObject *obj);
|
||||
float GetDistanceZ(WorldObject *obj);
|
||||
|
||||
protected:
|
||||
WorldObject();
|
||||
WorldPosition _wpos; // coords, orientation
|
||||
uint16 _m; // map
|
||||
|
||||
};
|
||||
|
||||
inline uint32 GetValuesCountByTypeId(uint8 tid)
|
||||
{
|
||||
switch(tid)
|
||||
{
|
||||
case TYPEID_OBJECT: return OBJECT_END;
|
||||
case TYPEID_UNIT: return UNIT_END;
|
||||
case TYPEID_PLAYER: return PLAYER_END;
|
||||
case TYPEID_ITEM: return ITEM_END;
|
||||
case TYPEID_CONTAINER: return CONTAINER_END;
|
||||
case TYPEID_GAMEOBJECT: return GAMEOBJECT_END;
|
||||
case TYPEID_DYNAMICOBJECT: return DYNAMICOBJECT_END;
|
||||
case TYPEID_CORPSE: return CORPSE_END;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline uint8 GetTypeIdByGuid(uint64 guid)
|
||||
{
|
||||
switch(GUID_HIPART(guid))
|
||||
{
|
||||
case HIGHGUID_PLAYER:
|
||||
return TYPEID_PLAYER;
|
||||
case HIGHGUID_CORPSE:
|
||||
case HIGHGUID_PLAYER_CORPSE: // not sure
|
||||
return TYPEID_CORPSE;
|
||||
case HIGHGUID_ITEM: // == HIGHGUID_CONTAINER
|
||||
return TYPEID_ITEM;
|
||||
case HIGHGUID_DYNAMICOBJECT:
|
||||
return TYPEID_DYNAMICOBJECT;
|
||||
case HIGHGUID_GAMEOBJECT:
|
||||
case HIGHGUID_TRANSPORT: // not sure
|
||||
return TYPEID_GAMEOBJECT;
|
||||
case HIGHGUID_UNIT:
|
||||
return TYPEID_UNIT;
|
||||
}
|
||||
return TYPEID_OBJECT;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
#ifndef _OBJECT_H
|
||||
#define _OBJECT_H
|
||||
|
||||
#include "UpdateFields.h"
|
||||
#include "ObjectDefines.h"
|
||||
#include "common.h"
|
||||
#include "HelperDefs.h"
|
||||
#include "World.h"
|
||||
|
||||
enum TYPE
|
||||
{
|
||||
TYPE_OBJECT = 1,
|
||||
TYPE_ITEM = 2,
|
||||
TYPE_CONTAINER = 6, // a container is ALWAYS an item!
|
||||
TYPE_UNIT = 8,
|
||||
TYPE_PLAYER = 16,
|
||||
TYPE_GAMEOBJECT = 32,
|
||||
TYPE_DYNAMICOBJECT = 64,
|
||||
TYPE_CORPSE = 128,
|
||||
TYPE_AIGROUP = 256,
|
||||
TYPE_AREATRIGGER = 512
|
||||
};
|
||||
|
||||
enum TYPEID
|
||||
{
|
||||
TYPEID_OBJECT = 0,
|
||||
TYPEID_ITEM = 1,
|
||||
TYPEID_CONTAINER = 2,
|
||||
TYPEID_UNIT = 3,
|
||||
TYPEID_PLAYER = 4,
|
||||
TYPEID_GAMEOBJECT = 5,
|
||||
TYPEID_DYNAMICOBJECT = 6,
|
||||
TYPEID_CORPSE = 7,
|
||||
TYPEID_AIGROUP = 8,
|
||||
TYPEID_AREATRIGGER = 9
|
||||
};
|
||||
|
||||
class Object
|
||||
{
|
||||
public:
|
||||
virtual ~Object();
|
||||
inline const uint64 GetGUID() const { return GetUInt64Value(0); }
|
||||
inline const uint32 GetGUIDLow() const { return GetUInt32Value(0); }
|
||||
inline const uint32 GetGUIDHigh() const { return GetUInt32Value(1); }
|
||||
inline uint32 GetEntry() const { return GetUInt32Value(OBJECT_FIELD_ENTRY); }
|
||||
inline uint16 GetValuesCount(void) { return _valuescount; }
|
||||
|
||||
inline const uint8 GetTypeId() { return _typeid; }
|
||||
inline const uint8 GetTypeMask() { return _type; }
|
||||
inline bool IsType(uint8 mask) { return (mask & _type) ? true : false; }
|
||||
inline bool IsPlayer(void) { return _typeid == TYPEID_PLAYER; } // specific
|
||||
inline bool IsUnit(void) { return _type & TYPE_UNIT; } // generic (unit = creature or player)
|
||||
inline bool IsCreature(void) { return IsUnit() && !IsPlayer(); } // specific
|
||||
inline bool IsItem(void) { return _type & TYPE_ITEM; } // generic (item or container)
|
||||
inline bool IsContainer(void) { return _typeid == TYPEID_CONTAINER; } // specific
|
||||
inline bool IsCorpse(void) { return _typeid == TYPEID_CORPSE; } // specific
|
||||
inline bool IsDynObject(void) { return _typeid == TYPEID_DYNAMICOBJECT; } // specific
|
||||
inline bool IsWorldObject(void) { return _type & (TYPE_PLAYER | TYPE_UNIT | TYPE_CORPSE | TYPE_DYNAMICOBJECT | TYPE_GAMEOBJECT); }
|
||||
inline const uint32 GetUInt32Value( uint16 index ) const
|
||||
{
|
||||
return _uint32values[ index ];
|
||||
}
|
||||
|
||||
inline const uint64 GetUInt64Value( uint16 index ) const
|
||||
{
|
||||
return *((uint64*)&(_uint32values[ index ]));
|
||||
}
|
||||
|
||||
inline bool HasFlag( uint16 index, uint32 flag ) const
|
||||
{
|
||||
return (_uint32values[ index ] & flag) != 0;
|
||||
}
|
||||
inline const float GetFloatValue( uint16 index ) const
|
||||
{
|
||||
return _floatvalues[ index ];
|
||||
}
|
||||
inline void SetFloatValue( uint16 index, float value )
|
||||
{
|
||||
_floatvalues[ index ] = value;
|
||||
}
|
||||
inline void SetUInt32Value( uint16 index, uint32 value )
|
||||
{
|
||||
_uint32values[ index ] = value;
|
||||
}
|
||||
|
||||
inline void SetName(std::string name) { _name = name; }
|
||||
inline std::string GetName(void) { return _name; }
|
||||
|
||||
inline float GetObjectSize() const
|
||||
{
|
||||
return ( _valuescount > UNIT_FIELD_BOUNDINGRADIUS ) ? _floatvalues[UNIT_FIELD_BOUNDINGRADIUS] : 0.39f;
|
||||
}
|
||||
|
||||
void Create(uint64 guid);
|
||||
|
||||
protected:
|
||||
Object();
|
||||
void _InitValues(void);
|
||||
|
||||
uint16 _valuescount;
|
||||
union
|
||||
{
|
||||
uint32 *_uint32values;
|
||||
float *_floatvalues;
|
||||
};
|
||||
uint8 _type;
|
||||
uint8 _typeid;
|
||||
std::string _name;
|
||||
};
|
||||
|
||||
class WorldObject : public Object
|
||||
{
|
||||
public:
|
||||
virtual ~WorldObject ( ) {}
|
||||
void SetPosition(float x, float y, float z, float o, uint16 _map);
|
||||
void SetPosition(float x, float y, float z, float o);
|
||||
inline void SetPosition(WorldPosition& wp) { _wpos = wp; }
|
||||
inline void SetPosition(WorldPosition& wp, uint16 mapid) { SetPosition(wp); _m = mapid; }
|
||||
inline WorldPosition GetPosition(void) {return _wpos; }
|
||||
inline float GetX(void) { return _wpos.x; }
|
||||
inline float GetY(void) { return _wpos.y; }
|
||||
inline float GetZ(void) { return _wpos.z; }
|
||||
inline float GetO(void) { return _wpos.o; }
|
||||
float GetDistance(WorldObject *obj);
|
||||
float GetDistance2d(float x, float y);
|
||||
float GetDistance(float x, float y, float z);
|
||||
float GetDistance2d(WorldObject *obj);
|
||||
float GetDistanceZ(WorldObject *obj);
|
||||
|
||||
protected:
|
||||
WorldObject();
|
||||
WorldPosition _wpos; // coords, orientation
|
||||
uint16 _m; // map
|
||||
|
||||
};
|
||||
|
||||
inline uint32 GetValuesCountByTypeId(uint8 tid)
|
||||
{
|
||||
switch(tid)
|
||||
{
|
||||
case TYPEID_OBJECT: return OBJECT_END;
|
||||
case TYPEID_UNIT: return UNIT_END;
|
||||
case TYPEID_PLAYER: return PLAYER_END;
|
||||
case TYPEID_ITEM: return ITEM_END;
|
||||
case TYPEID_CONTAINER: return CONTAINER_END;
|
||||
case TYPEID_GAMEOBJECT: return GAMEOBJECT_END;
|
||||
case TYPEID_DYNAMICOBJECT: return DYNAMICOBJECT_END;
|
||||
case TYPEID_CORPSE: return CORPSE_END;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
inline uint8 GetTypeIdByGuid(uint64 guid)
|
||||
{
|
||||
switch(GUID_HIPART(guid))
|
||||
{
|
||||
case HIGHGUID_PLAYER:
|
||||
return TYPEID_PLAYER;
|
||||
case HIGHGUID_CORPSE:
|
||||
case HIGHGUID_PLAYER_CORPSE: // not sure
|
||||
return TYPEID_CORPSE;
|
||||
case HIGHGUID_ITEM: // == HIGHGUID_CONTAINER
|
||||
return TYPEID_ITEM;
|
||||
case HIGHGUID_DYNAMICOBJECT:
|
||||
return TYPEID_DYNAMICOBJECT;
|
||||
case HIGHGUID_GAMEOBJECT:
|
||||
case HIGHGUID_TRANSPORT: // not sure
|
||||
return TYPEID_GAMEOBJECT;
|
||||
case HIGHGUID_UNIT:
|
||||
return TYPEID_UNIT;
|
||||
}
|
||||
return TYPEID_OBJECT;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -1,21 +1,21 @@
|
||||
#include "common.h"
|
||||
#include "Unit.h"
|
||||
|
||||
Unit::Unit() : WorldObject()
|
||||
{
|
||||
_type |= TYPE_UNIT;
|
||||
_typeid = TYPEID_UNIT;
|
||||
_valuescount = UNIT_END;
|
||||
}
|
||||
|
||||
void Unit::Create(uint64 guid)
|
||||
{
|
||||
Object::Create(guid);
|
||||
}
|
||||
|
||||
uint8 Unit::GetGender(void)
|
||||
{
|
||||
uint32 temp = GetUInt32Value(UNIT_FIELD_BYTES_0);
|
||||
return ((uint8*)&temp)[2];
|
||||
}
|
||||
|
||||
#include "common.h"
|
||||
#include "Unit.h"
|
||||
|
||||
Unit::Unit() : WorldObject()
|
||||
{
|
||||
_type |= TYPE_UNIT;
|
||||
_typeid = TYPEID_UNIT;
|
||||
_valuescount = UNIT_END;
|
||||
}
|
||||
|
||||
void Unit::Create(uint64 guid)
|
||||
{
|
||||
Object::Create(guid);
|
||||
}
|
||||
|
||||
uint8 Unit::GetGender(void)
|
||||
{
|
||||
uint32 temp = GetUInt32Value(UNIT_FIELD_BYTES_0);
|
||||
return ((uint8*)&temp)[2];
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,34 +1,34 @@
|
||||
#ifndef _UPDATEDATA_H
|
||||
#define _UPDATEDATA_H
|
||||
|
||||
enum OBJECT_UPDATE_TYPE
|
||||
{
|
||||
UPDATETYPE_VALUES = 0,
|
||||
UPDATETYPE_MOVEMENT = 1,
|
||||
UPDATETYPE_CREATE_OBJECT = 2,
|
||||
UPDATETYPE_CREATE_OBJECT2 = 3,
|
||||
UPDATETYPE_OUT_OF_RANGE_OBJECTS = 4,
|
||||
UPDATETYPE_NEAR_OBJECTS = 5
|
||||
};
|
||||
|
||||
enum OBJECT_UPDATE_FLAGS
|
||||
{
|
||||
UPDATEFLAG_SELF = 0x01,
|
||||
UPDATEFLAG_TRANSPORT = 0x02,
|
||||
UPDATEFLAG_FULLGUID = 0x04,
|
||||
UPDATEFLAG_HIGHGUID = 0x08,
|
||||
UPDATEFLAG_ALL = 0x10,
|
||||
UPDATEFLAG_LIVING = 0x20,
|
||||
UPDATEFLAG_HASPOSITION = 0x40
|
||||
};
|
||||
|
||||
// not sure about those flags, mangos hasnt a description for it either
|
||||
enum FLAGS2_UPDATE_FLAGS
|
||||
{
|
||||
FLAGS2_TRANSPORT = 0x200,
|
||||
FLAGS2_SPIRITHEALER = 0x10000000,
|
||||
};
|
||||
|
||||
bool IsFloatField(uint8, uint32);
|
||||
|
||||
#ifndef _UPDATEDATA_H
|
||||
#define _UPDATEDATA_H
|
||||
|
||||
enum OBJECT_UPDATE_TYPE
|
||||
{
|
||||
UPDATETYPE_VALUES = 0,
|
||||
UPDATETYPE_MOVEMENT = 1,
|
||||
UPDATETYPE_CREATE_OBJECT = 2,
|
||||
UPDATETYPE_CREATE_OBJECT2 = 3,
|
||||
UPDATETYPE_OUT_OF_RANGE_OBJECTS = 4,
|
||||
UPDATETYPE_NEAR_OBJECTS = 5
|
||||
};
|
||||
|
||||
enum OBJECT_UPDATE_FLAGS
|
||||
{
|
||||
UPDATEFLAG_SELF = 0x01,
|
||||
UPDATEFLAG_TRANSPORT = 0x02,
|
||||
UPDATEFLAG_FULLGUID = 0x04,
|
||||
UPDATEFLAG_HIGHGUID = 0x08,
|
||||
UPDATEFLAG_ALL = 0x10,
|
||||
UPDATEFLAG_LIVING = 0x20,
|
||||
UPDATEFLAG_HASPOSITION = 0x40
|
||||
};
|
||||
|
||||
// not sure about those flags, mangos hasnt a description for it either
|
||||
enum FLAGS2_UPDATE_FLAGS
|
||||
{
|
||||
FLAGS2_TRANSPORT = 0x200,
|
||||
FLAGS2_SPIRITHEALER = 0x10000000,
|
||||
};
|
||||
|
||||
bool IsFloatField(uint8, uint32);
|
||||
|
||||
#endif
|
||||
@ -1,469 +1,469 @@
|
||||
/*
|
||||
* Copyright (C) 2005,2006,2007 MaNGOS <http://www.mangosproject.org/>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _UPDATEFIELDS_AUTO_H
|
||||
#define _UPDATEFIELDS_AUTO_H
|
||||
|
||||
// Auto generated for version 0, 3, 2, 7655
|
||||
|
||||
enum EObjectFields
|
||||
{
|
||||
OBJECT_FIELD_GUID = 0x0000, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
OBJECT_FIELD_TYPE = 0x0002, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
OBJECT_FIELD_ENTRY = 0x0003, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
OBJECT_FIELD_SCALE_X = 0x0004, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
OBJECT_FIELD_PADDING = 0x0005, // Size: 1, Type: INT, Flags: NONE
|
||||
OBJECT_END = 0x0006,
|
||||
};
|
||||
|
||||
enum EItemFields
|
||||
{
|
||||
ITEM_FIELD_OWNER = OBJECT_END + 0x0000, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
ITEM_FIELD_CONTAINED = OBJECT_END + 0x0002, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
ITEM_FIELD_CREATOR = OBJECT_END + 0x0004, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
ITEM_FIELD_GIFTCREATOR = OBJECT_END + 0x0006, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
ITEM_FIELD_STACK_COUNT = OBJECT_END + 0x0008, // Size: 1, Type: INT, Flags: OWNER_ONLY, UNK2
|
||||
ITEM_FIELD_DURATION = OBJECT_END + 0x0009, // Size: 1, Type: INT, Flags: OWNER_ONLY, UNK2
|
||||
ITEM_FIELD_SPELL_CHARGES = OBJECT_END + 0x000A, // Size: 5, Type: INT, Flags: OWNER_ONLY, UNK2
|
||||
ITEM_FIELD_FLAGS = OBJECT_END + 0x000F, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
ITEM_FIELD_ENCHANTMENT = OBJECT_END + 0x0010, // Size: 33, Type: INT, Flags: PUBLIC
|
||||
ITEM_FIELD_PROPERTY_SEED = OBJECT_END + 0x0031, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
|
||||
// custom
|
||||
ITEM_FIELD_SUFFIX_FACTOR = ITEM_FIELD_PROPERTY_SEED,
|
||||
|
||||
ITEM_FIELD_RANDOM_PROPERTIES_ID = OBJECT_END + 0x0032, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
ITEM_FIELD_ITEM_TEXT_ID = OBJECT_END + 0x0033, // Size: 1, Type: INT, Flags: OWNER_ONLY
|
||||
ITEM_FIELD_DURABILITY = OBJECT_END + 0x0034, // Size: 1, Type: INT, Flags: OWNER_ONLY, UNK2
|
||||
ITEM_FIELD_MAXDURABILITY = OBJECT_END + 0x0035, // Size: 1, Type: INT, Flags: OWNER_ONLY, UNK2
|
||||
ITEM_END = OBJECT_END + 0x0036,
|
||||
};
|
||||
|
||||
enum EContainerFields
|
||||
{
|
||||
CONTAINER_FIELD_NUM_SLOTS = ITEM_END + 0x0000, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
CONTAINER_ALIGN_PAD = ITEM_END + 0x0001, // Size: 1, Type: BYTES, Flags: NONE
|
||||
CONTAINER_FIELD_SLOT_1 = ITEM_END + 0x0002, // Size: 72, Type: LONG, Flags: PUBLIC
|
||||
CONTAINER_END = ITEM_END + 0x004A,
|
||||
};
|
||||
|
||||
enum EUnitFields
|
||||
{
|
||||
UNIT_FIELD_CHARM = OBJECT_END + 0x0000, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
UNIT_FIELD_SUMMON = OBJECT_END + 0x0002, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
UNIT_FIELD_CHARMEDBY = OBJECT_END + 0x0004, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
UNIT_FIELD_SUMMONEDBY = OBJECT_END + 0x0006, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
UNIT_FIELD_CREATEDBY = OBJECT_END + 0x0008, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
UNIT_FIELD_TARGET = OBJECT_END + 0x000A, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
UNIT_FIELD_PERSUADED = OBJECT_END + 0x000C, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
UNIT_FIELD_CHANNEL_OBJECT = OBJECT_END + 0x000E, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
UNIT_FIELD_HEALTH = OBJECT_END + 0x0010, // Size: 1, Type: INT, Flags: DYNAMIC
|
||||
UNIT_FIELD_POWER1 = OBJECT_END + 0x0011, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_POWER2 = OBJECT_END + 0x0012, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_POWER3 = OBJECT_END + 0x0013, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_POWER4 = OBJECT_END + 0x0014, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_POWER5 = OBJECT_END + 0x0015, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_MAXHEALTH = OBJECT_END + 0x0016, // Size: 1, Type: INT, Flags: DYNAMIC
|
||||
UNIT_FIELD_MAXPOWER1 = OBJECT_END + 0x0017, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_MAXPOWER2 = OBJECT_END + 0x0018, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_MAXPOWER3 = OBJECT_END + 0x0019, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_MAXPOWER4 = OBJECT_END + 0x001A, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_MAXPOWER5 = OBJECT_END + 0x001B, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_LEVEL = OBJECT_END + 0x001C, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_FACTIONTEMPLATE = OBJECT_END + 0x001D, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_BYTES_0 = OBJECT_END + 0x001E, // Size: 1, Type: BYTES, Flags: PUBLIC
|
||||
UNIT_VIRTUAL_ITEM_SLOT_DISPLAY = OBJECT_END + 0x001F, // Size: 3, Type: INT, Flags: PUBLIC
|
||||
UNIT_VIRTUAL_ITEM_INFO = OBJECT_END + 0x0022, // Size: 6, Type: BYTES, Flags: PUBLIC
|
||||
UNIT_FIELD_FLAGS = OBJECT_END + 0x0028, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_FLAGS_2 = OBJECT_END + 0x0029, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_AURA = OBJECT_END + 0x002A, // Size: 56, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_AURAFLAGS = OBJECT_END + 0x0062, // Size: 14, Type: BYTES, Flags: PUBLIC
|
||||
UNIT_FIELD_AURALEVELS = OBJECT_END + 0x0070, // Size: 14, Type: BYTES, Flags: PUBLIC
|
||||
UNIT_FIELD_AURAAPPLICATIONS = OBJECT_END + 0x007E, // Size: 14, Type: BYTES, Flags: PUBLIC
|
||||
UNIT_FIELD_AURASTATE = OBJECT_END + 0x008C, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_BASEATTACKTIME = OBJECT_END + 0x008D, // Size: 2, Type: INT, Flags: PUBLIC
|
||||
|
||||
// custom
|
||||
UNIT_FIELD_OFFHANDATTACKTIME = UNIT_FIELD_BASEATTACKTIME + 1,
|
||||
|
||||
UNIT_FIELD_RANGEDATTACKTIME = OBJECT_END + 0x008F, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
UNIT_FIELD_BOUNDINGRADIUS = OBJECT_END + 0x0090, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
UNIT_FIELD_COMBATREACH = OBJECT_END + 0x0091, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
UNIT_FIELD_DISPLAYID = OBJECT_END + 0x0092, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_NATIVEDISPLAYID = OBJECT_END + 0x0093, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_MOUNTDISPLAYID = OBJECT_END + 0x0094, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_MINDAMAGE = OBJECT_END + 0x0095, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY, UNK3
|
||||
UNIT_FIELD_MAXDAMAGE = OBJECT_END + 0x0096, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY, UNK3
|
||||
UNIT_FIELD_MINOFFHANDDAMAGE = OBJECT_END + 0x0097, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY, UNK3
|
||||
UNIT_FIELD_MAXOFFHANDDAMAGE = OBJECT_END + 0x0098, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY, UNK3
|
||||
UNIT_FIELD_BYTES_1 = OBJECT_END + 0x0099, // Size: 1, Type: BYTES, Flags: PUBLIC
|
||||
UNIT_FIELD_PETNUMBER = OBJECT_END + 0x009A, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_PET_NAME_TIMESTAMP = OBJECT_END + 0x009B, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_PETEXPERIENCE = OBJECT_END + 0x009C, // Size: 1, Type: INT, Flags: OWNER_ONLY
|
||||
UNIT_FIELD_PETNEXTLEVELEXP = OBJECT_END + 0x009D, // Size: 1, Type: INT, Flags: OWNER_ONLY
|
||||
UNIT_DYNAMIC_FLAGS = OBJECT_END + 0x009E, // Size: 1, Type: INT, Flags: DYNAMIC
|
||||
UNIT_CHANNEL_SPELL = OBJECT_END + 0x009F, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_MOD_CAST_SPEED = OBJECT_END + 0x00A0, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
UNIT_CREATED_BY_SPELL = OBJECT_END + 0x00A1, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_NPC_FLAGS = OBJECT_END + 0x00A2, // Size: 1, Type: INT, Flags: DYNAMIC
|
||||
UNIT_NPC_EMOTESTATE = OBJECT_END + 0x00A3, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_TRAINING_POINTS = OBJECT_END + 0x00A4, // Size: 1, Type: TWO_SHORT, Flags: OWNER_ONLY
|
||||
UNIT_FIELD_STAT0 = OBJECT_END + 0x00A5, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_STAT1 = OBJECT_END + 0x00A6, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_STAT2 = OBJECT_END + 0x00A7, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_STAT3 = OBJECT_END + 0x00A8, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_STAT4 = OBJECT_END + 0x00A9, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_POSSTAT0 = OBJECT_END + 0x00AA, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_POSSTAT1 = OBJECT_END + 0x00AB, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_POSSTAT2 = OBJECT_END + 0x00AC, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_POSSTAT3 = OBJECT_END + 0x00AD, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_POSSTAT4 = OBJECT_END + 0x00AE, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_NEGSTAT0 = OBJECT_END + 0x00AF, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_NEGSTAT1 = OBJECT_END + 0x00B0, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_NEGSTAT2 = OBJECT_END + 0x00B1, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_NEGSTAT3 = OBJECT_END + 0x00B2, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_NEGSTAT4 = OBJECT_END + 0x00B3, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_RESISTANCES = OBJECT_END + 0x00B4, // Size: 7, Type: INT, Flags: PRIVATE, OWNER_ONLY, UNK3
|
||||
UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE = OBJECT_END + 0x00BB, // Size: 7, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE = OBJECT_END + 0x00C2, // Size: 7, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_BASE_MANA = OBJECT_END + 0x00C9, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_BASE_HEALTH = OBJECT_END + 0x00CA, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_BYTES_2 = OBJECT_END + 0x00CB, // Size: 1, Type: BYTES, Flags: PUBLIC
|
||||
UNIT_FIELD_ATTACK_POWER = OBJECT_END + 0x00CC, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_ATTACK_POWER_MODS = OBJECT_END + 0x00CD, // Size: 1, Type: TWO_SHORT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_ATTACK_POWER_MULTIPLIER = OBJECT_END + 0x00CE, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_RANGED_ATTACK_POWER = OBJECT_END + 0x00CF, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_RANGED_ATTACK_POWER_MODS = OBJECT_END + 0x00D0, // Size: 1, Type: TWO_SHORT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER = OBJECT_END + 0x00D1, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_MINRANGEDDAMAGE = OBJECT_END + 0x00D2, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_MAXRANGEDDAMAGE = OBJECT_END + 0x00D3, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_POWER_COST_MODIFIER = OBJECT_END + 0x00D4, // Size: 7, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_POWER_COST_MULTIPLIER = OBJECT_END + 0x00DB, // Size: 7, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_END = OBJECT_END + 0x00E2,
|
||||
|
||||
PLAYER_DUEL_ARBITER = UNIT_END + 0x0000, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_FLAGS = UNIT_END + 0x0002, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_GUILDID = UNIT_END + 0x0003, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_GUILDRANK = UNIT_END + 0x0004, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_BYTES = UNIT_END + 0x0005, // Size: 1, Type: BYTES, Flags: PUBLIC
|
||||
PLAYER_BYTES_2 = UNIT_END + 0x0006, // Size: 1, Type: BYTES, Flags: PUBLIC
|
||||
PLAYER_BYTES_3 = UNIT_END + 0x0007, // Size: 1, Type: BYTES, Flags: PUBLIC
|
||||
PLAYER_DUEL_TEAM = UNIT_END + 0x0008, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_GUILD_TIMESTAMP = UNIT_END + 0x0009, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_QUEST_LOG_1_1 = UNIT_END + 0x000A, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_1_2 = UNIT_END + 0x000B, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_2_1 = UNIT_END + 0x000D, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_2_2 = UNIT_END + 0x000E, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_3_1 = UNIT_END + 0x0010, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_3_2 = UNIT_END + 0x0011, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_4_1 = UNIT_END + 0x0013, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_4_2 = UNIT_END + 0x0014, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_5_1 = UNIT_END + 0x0016, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_5_2 = UNIT_END + 0x0017, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_6_1 = UNIT_END + 0x0019, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_6_2 = UNIT_END + 0x001A, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_7_1 = UNIT_END + 0x001C, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_7_2 = UNIT_END + 0x001D, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_8_1 = UNIT_END + 0x001F, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_8_2 = UNIT_END + 0x0020, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_9_1 = UNIT_END + 0x0022, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_9_2 = UNIT_END + 0x0023, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_10_1 = UNIT_END + 0x0025, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_10_2 = UNIT_END + 0x0026, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_11_1 = UNIT_END + 0x0028, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_11_2 = UNIT_END + 0x0029, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_12_1 = UNIT_END + 0x002B, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_12_2 = UNIT_END + 0x002C, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_13_1 = UNIT_END + 0x002E, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_13_2 = UNIT_END + 0x002F, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_14_1 = UNIT_END + 0x0031, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_14_2 = UNIT_END + 0x0032, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_15_1 = UNIT_END + 0x0034, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_15_2 = UNIT_END + 0x0035, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_16_1 = UNIT_END + 0x0037, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_16_2 = UNIT_END + 0x0038, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_17_1 = UNIT_END + 0x003A, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_17_2 = UNIT_END + 0x003B, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_18_1 = UNIT_END + 0x003D, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_18_2 = UNIT_END + 0x003E, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_19_1 = UNIT_END + 0x0040, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_19_2 = UNIT_END + 0x0041, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_20_1 = UNIT_END + 0x0043, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_20_2 = UNIT_END + 0x0044, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_21_1 = UNIT_END + 0x0046, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_21_2 = UNIT_END + 0x0047, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_22_1 = UNIT_END + 0x0049, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_22_2 = UNIT_END + 0x004A, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_23_1 = UNIT_END + 0x004C, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_23_2 = UNIT_END + 0x004D, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_24_1 = UNIT_END + 0x004F, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_24_2 = UNIT_END + 0x0050, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_25_1 = UNIT_END + 0x0052, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_25_2 = UNIT_END + 0x0053, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_VISIBLE_ITEM_1_CREATOR = UNIT_END + 0x0055, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_1_0 = UNIT_END + 0x0057, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_1_PROPERTIES = UNIT_END + 0x0063, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_1_PAD = UNIT_END + 0x0064, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_2_CREATOR = UNIT_END + 0x0065, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_2_0 = UNIT_END + 0x0067, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_2_PROPERTIES = UNIT_END + 0x0073, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_2_PAD = UNIT_END + 0x0074, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_3_CREATOR = UNIT_END + 0x0075, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_3_0 = UNIT_END + 0x0077, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_3_PROPERTIES = UNIT_END + 0x0083, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_3_PAD = UNIT_END + 0x0084, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_4_CREATOR = UNIT_END + 0x0085, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_4_0 = UNIT_END + 0x0087, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_4_PROPERTIES = UNIT_END + 0x0093, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_4_PAD = UNIT_END + 0x0094, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_5_CREATOR = UNIT_END + 0x0095, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_5_0 = UNIT_END + 0x0097, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_5_PROPERTIES = UNIT_END + 0x00A3, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_5_PAD = UNIT_END + 0x00A4, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_6_CREATOR = UNIT_END + 0x00A5, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_6_0 = UNIT_END + 0x00A7, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_6_PROPERTIES = UNIT_END + 0x00B3, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_6_PAD = UNIT_END + 0x00B4, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_7_CREATOR = UNIT_END + 0x00B5, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_7_0 = UNIT_END + 0x00B7, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_7_PROPERTIES = UNIT_END + 0x00C3, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_7_PAD = UNIT_END + 0x00C4, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_8_CREATOR = UNIT_END + 0x00C5, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_8_0 = UNIT_END + 0x00C7, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_8_PROPERTIES = UNIT_END + 0x00D3, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_8_PAD = UNIT_END + 0x00D4, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_9_CREATOR = UNIT_END + 0x00D5, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_9_0 = UNIT_END + 0x00D7, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_9_PROPERTIES = UNIT_END + 0x00E3, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_9_PAD = UNIT_END + 0x00E4, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_10_CREATOR = UNIT_END + 0x00E5, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_10_0 = UNIT_END + 0x00E7, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_10_PROPERTIES = UNIT_END + 0x00F3, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_10_PAD = UNIT_END + 0x00F4, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_11_CREATOR = UNIT_END + 0x00F5, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_11_0 = UNIT_END + 0x00F7, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_11_PROPERTIES = UNIT_END + 0x0103, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_11_PAD = UNIT_END + 0x0104, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_12_CREATOR = UNIT_END + 0x0105, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_12_0 = UNIT_END + 0x0107, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_12_PROPERTIES = UNIT_END + 0x0113, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_12_PAD = UNIT_END + 0x0114, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_13_CREATOR = UNIT_END + 0x0115, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_13_0 = UNIT_END + 0x0117, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_13_PROPERTIES = UNIT_END + 0x0123, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_13_PAD = UNIT_END + 0x0124, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_14_CREATOR = UNIT_END + 0x0125, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_14_0 = UNIT_END + 0x0127, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_14_PROPERTIES = UNIT_END + 0x0133, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_14_PAD = UNIT_END + 0x0134, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_15_CREATOR = UNIT_END + 0x0135, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_15_0 = UNIT_END + 0x0137, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_15_PROPERTIES = UNIT_END + 0x0143, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_15_PAD = UNIT_END + 0x0144, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_16_CREATOR = UNIT_END + 0x0145, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_16_0 = UNIT_END + 0x0147, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_16_PROPERTIES = UNIT_END + 0x0153, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_16_PAD = UNIT_END + 0x0154, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_17_CREATOR = UNIT_END + 0x0155, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_17_0 = UNIT_END + 0x0157, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_17_PROPERTIES = UNIT_END + 0x0163, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_17_PAD = UNIT_END + 0x0164, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_18_CREATOR = UNIT_END + 0x0165, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_18_0 = UNIT_END + 0x0167, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_18_PROPERTIES = UNIT_END + 0x0173, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_18_PAD = UNIT_END + 0x0174, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_19_CREATOR = UNIT_END + 0x0175, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_19_0 = UNIT_END + 0x0177, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_19_PROPERTIES = UNIT_END + 0x0183, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_19_PAD = UNIT_END + 0x0184, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_CHOSEN_TITLE = UNIT_END + 0x0185, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_FIELD_INV_SLOT_HEAD = UNIT_END + 0x0186, // Size: 46, Type: LONG, Flags: PRIVATE
|
||||
PLAYER_FIELD_PACK_SLOT_1 = UNIT_END + 0x01B4, // Size: 32, Type: LONG, Flags: PRIVATE
|
||||
PLAYER_FIELD_BANK_SLOT_1 = UNIT_END + 0x01D4, // Size: 56, Type: LONG, Flags: PRIVATE
|
||||
PLAYER_FIELD_BANKBAG_SLOT_1 = UNIT_END + 0x020C, // Size: 14, Type: LONG, Flags: PRIVATE
|
||||
PLAYER_FIELD_VENDORBUYBACK_SLOT_1 = UNIT_END + 0x021A, // Size: 24, Type: LONG, Flags: PRIVATE
|
||||
PLAYER_FIELD_KEYRING_SLOT_1 = UNIT_END + 0x0232, // Size: 64, Type: LONG, Flags: PRIVATE
|
||||
PLAYER_FARSIGHT = UNIT_END + 0x0272, // Size: 2, Type: LONG, Flags: PRIVATE
|
||||
PLAYER__FIELD_KNOWN_TITLES = UNIT_END + 0x0274, // Size: 2, Type: LONG, Flags: PRIVATE
|
||||
PLAYER_XP = UNIT_END + 0x0276, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_NEXT_LEVEL_XP = UNIT_END + 0x0277, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_SKILL_INFO_1_1 = UNIT_END + 0x0278, // Size: 384, Type: TWO_SHORT, Flags: PRIVATE
|
||||
PLAYER_CHARACTER_POINTS1 = UNIT_END + 0x03F8, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_CHARACTER_POINTS2 = UNIT_END + 0x03F9, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_TRACK_CREATURES = UNIT_END + 0x03FA, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_TRACK_RESOURCES = UNIT_END + 0x03FB, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_BLOCK_PERCENTAGE = UNIT_END + 0x03FC, // Size: 1, Type: FLOAT, Flags: PRIVATE
|
||||
PLAYER_DODGE_PERCENTAGE = UNIT_END + 0x03FD, // Size: 1, Type: FLOAT, Flags: PRIVATE
|
||||
PLAYER_PARRY_PERCENTAGE = UNIT_END + 0x03FE, // Size: 1, Type: FLOAT, Flags: PRIVATE
|
||||
PLAYER_EXPERTISE = UNIT_END + 0x03FF, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_CRIT_PERCENTAGE = UNIT_END + 0x0400, // Size: 1, Type: FLOAT, Flags: PRIVATE
|
||||
PLAYER_RANGED_CRIT_PERCENTAGE = UNIT_END + 0x0401, // Size: 1, Type: FLOAT, Flags: PRIVATE
|
||||
PLAYER_OFFHAND_CRIT_PERCENTAGE = UNIT_END + 0x0402, // Size: 1, Type: FLOAT, Flags: PRIVATE
|
||||
PLAYER_SPELL_CRIT_PERCENTAGE1 = UNIT_END + 0x0403, // Size: 7, Type: FLOAT, Flags: PRIVATE
|
||||
|
||||
// custom
|
||||
PLAYER_HOLY_SPELL_CRIT_PERCENTAGE = PLAYER_SPELL_CRIT_PERCENTAGE1+1,
|
||||
PLAYER_FIRE_SPELL_CRIT_PERCENTAGE = PLAYER_SPELL_CRIT_PERCENTAGE1+2,
|
||||
PLAYER_NATURE_SPELL_CRIT_PERCENTAGE = PLAYER_SPELL_CRIT_PERCENTAGE1+3,
|
||||
PLAYER_FROST_SPELL_CRIT_PERCENTAGE = PLAYER_SPELL_CRIT_PERCENTAGE1+4,
|
||||
PLAYER_SHADOW_SPELL_CRIT_PERCENTAGE = PLAYER_SPELL_CRIT_PERCENTAGE1+5,
|
||||
PLAYER_ARCANE_SPELL_CRIT_PERCENTAGE = PLAYER_SPELL_CRIT_PERCENTAGE1+6,
|
||||
|
||||
PLAYER_SHIELD_BLOCK = UNIT_END + 0x040A, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_EXPLORED_ZONES_1 = UNIT_END + 0x040B, // Size: 64, Type: BYTES, Flags: PRIVATE
|
||||
PLAYER_REST_STATE_EXPERIENCE = UNIT_END + 0x044B, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_COINAGE = UNIT_END + 0x044C, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_MOD_DAMAGE_DONE_POS = UNIT_END + 0x044D, // Size: 7, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_MOD_DAMAGE_DONE_NEG = UNIT_END + 0x0454, // Size: 7, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_MOD_DAMAGE_DONE_PCT = UNIT_END + 0x045B, // Size: 7, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_MOD_HEALING_DONE_POS = UNIT_END + 0x0462, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_MOD_TARGET_RESISTANCE = UNIT_END + 0x0463, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_BYTES = UNIT_END + 0x0464, // Size: 1, Type: BYTES, Flags: PRIVATE
|
||||
PLAYER_AMMO_ID = UNIT_END + 0x0465, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_SELF_RES_SPELL = UNIT_END + 0x0466, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_PVP_MEDALS = UNIT_END + 0x0467, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_BUYBACK_PRICE_1 = UNIT_END + 0x0468, // Size: 12, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_BUYBACK_TIMESTAMP_1 = UNIT_END + 0x0474, // Size: 12, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_KILLS = UNIT_END + 0x0480, // Size: 1, Type: TWO_SHORT, Flags: PRIVATE
|
||||
PLAYER_FIELD_TODAY_CONTRIBUTION = UNIT_END + 0x0481, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_YESTERDAY_CONTRIBUTION = UNIT_END + 0x0482, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_LIFETIME_HONORBALE_KILLS = UNIT_END + 0x0483, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_BYTES2 = UNIT_END + 0x0484, // Size: 1, Type: BYTES, Flags: PRIVATE
|
||||
PLAYER_FIELD_WATCHED_FACTION_INDEX = UNIT_END + 0x0485, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_COMBAT_RATING_1 = UNIT_END + 0x0486, // Size: 24, Type: INT, Flags: PRIVATE
|
||||
|
||||
// custom // client names:
|
||||
// CR_WEAPON_SKILL
|
||||
PLAYER_FIELD_ALL_WEAPONS_SKILL_RATING = PLAYER_FIELD_COMBAT_RATING_1,
|
||||
// CR_DEFENSE_SKILL
|
||||
PLAYER_FIELD_DEFENCE_RATING = PLAYER_FIELD_COMBAT_RATING_1+1,
|
||||
// CR_DODGE
|
||||
PLAYER_FIELD_DODGE_RATING = PLAYER_FIELD_COMBAT_RATING_1+2,
|
||||
// CR_PARRY
|
||||
PLAYER_FIELD_PARRY_RATING = PLAYER_FIELD_COMBAT_RATING_1+3,
|
||||
// CR_BLOCK
|
||||
PLAYER_FIELD_BLOCK_RATING = PLAYER_FIELD_COMBAT_RATING_1+4,
|
||||
// CR_HIT_MELEE
|
||||
PLAYER_FIELD_MELEE_HIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+5,
|
||||
// CR_HIT_RANGED
|
||||
PLAYER_FIELD_RANGED_HIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+6,
|
||||
// CR_HIT_SPELL
|
||||
PLAYER_FIELD_SPELL_HIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+7,
|
||||
// CR_CRIT_MELEE
|
||||
PLAYER_FIELD_MELEE_CRIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+8,
|
||||
// CR_CRIT_RANGED
|
||||
PLAYER_FIELD_RANGED_CRIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+9,
|
||||
// CR_CRIT_SPELL
|
||||
PLAYER_FIELD_SPELL_CRIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+10,
|
||||
// CR_HIT_TAKEN_MELEE
|
||||
PLAYER_FIELD_HIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+11,
|
||||
// CR_HIT_TAKEN_RANGED
|
||||
PLAYER_FIELD_CRIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+12,
|
||||
// CR_HIT_TAKEN_SPELL
|
||||
PLAYER_FIELD_UNK3_RATING = PLAYER_FIELD_COMBAT_RATING_1+13,
|
||||
// CR_CRIT_TAKEN_MELEE
|
||||
PLAYER_FIELD_UNK4_RATING = PLAYER_FIELD_COMBAT_RATING_1+14,
|
||||
// CR_CRIT_TAKEN_RANGED
|
||||
PLAYER_FIELD_UNK5_RATING = PLAYER_FIELD_COMBAT_RATING_1+15,
|
||||
// CR_CRIT_TAKEN_SPELL
|
||||
PLAYER_FIELD_RESILIENCE_RATING = PLAYER_FIELD_COMBAT_RATING_1+16,
|
||||
// CR_HASTE_MELEE
|
||||
PLAYER_FIELD_MELEE_HASTE_RATING = PLAYER_FIELD_COMBAT_RATING_1+17,
|
||||
// CR_HASTE_RANGED
|
||||
PLAYER_FIELD_RANGED_HASTE_RATING = PLAYER_FIELD_COMBAT_RATING_1+18,
|
||||
// CR_HASTE_SPELL
|
||||
PLAYER_FIELD_SPELL_HASTE_RATING = PLAYER_FIELD_COMBAT_RATING_1+19,
|
||||
// CR_WEAPON_SKILL_MAINHAND
|
||||
PLAYER_FIELD_MELEE_WEAPON_SKILL_RATING = PLAYER_FIELD_COMBAT_RATING_1+20,
|
||||
// CR_WEAPON_SKILL_OFFHAND
|
||||
PLAYER_FIELD_OFFHAND_WEAPON_SKILL_RATING = PLAYER_FIELD_COMBAT_RATING_1+21,
|
||||
// CR_WEAPON_SKILL_RANGED
|
||||
PLAYER_FIELD_RANGED_WEAPON_SKILL_RATING = PLAYER_FIELD_COMBAT_RATING_1+22,
|
||||
// CR_EXPERTISE
|
||||
PLAYER_FIELD_EXPERTISE_RATING = PLAYER_FIELD_COMBAT_RATING_1+23,
|
||||
|
||||
PLAYER_FIELD_ARENA_TEAM_INFO_1_1 = UNIT_END + 0x049E, // Size: 18, Type: INT, Flags: PRIVATE
|
||||
|
||||
// custom
|
||||
PLAYER_FIELD_ARENA_TEAM_ID_2v2 = PLAYER_FIELD_ARENA_TEAM_INFO_1_1,
|
||||
PLAYER_FIELD_ARENA_TEAM_ID_3v3 = PLAYER_FIELD_ARENA_TEAM_INFO_1_1+6,
|
||||
PLAYER_FIELD_ARENA_TEAM_ID_5v5 = PLAYER_FIELD_ARENA_TEAM_INFO_1_1+12,
|
||||
|
||||
PLAYER_FIELD_HONOR_CURRENCY = UNIT_END + 0x04B0, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_ARENA_CURRENCY = UNIT_END + 0x04B1, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_MOD_MANA_REGEN = UNIT_END + 0x04B2, // Size: 1, Type: FLOAT, Flags: PRIVATE
|
||||
PLAYER_FIELD_MOD_MANA_REGEN_INTERRUPT = UNIT_END + 0x04B3, // Size: 1, Type: FLOAT, Flags: PRIVATE
|
||||
PLAYER_FIELD_MAX_LEVEL = UNIT_END + 0x04B4, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_DAILY_QUESTS_1 = UNIT_END + 0x04B5, // Size: 10, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_PADDING = UNIT_END + 0x04BF, // Size: 1, Type: INT, Flags: NONE
|
||||
PLAYER_END = UNIT_END + 0x04C0,
|
||||
};
|
||||
|
||||
enum EGameObjectFields
|
||||
{
|
||||
OBJECT_FIELD_CREATED_BY = OBJECT_END + 0x0000, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
GAMEOBJECT_DISPLAYID = OBJECT_END + 0x0002, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
GAMEOBJECT_FLAGS = OBJECT_END + 0x0003, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
GAMEOBJECT_ROTATION = OBJECT_END + 0x0004, // Size: 4, Type: FLOAT, Flags: PUBLIC
|
||||
GAMEOBJECT_STATE = OBJECT_END + 0x0008, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
GAMEOBJECT_POS_X = OBJECT_END + 0x0009, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
GAMEOBJECT_POS_Y = OBJECT_END + 0x000A, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
GAMEOBJECT_POS_Z = OBJECT_END + 0x000B, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
GAMEOBJECT_FACING = OBJECT_END + 0x000C, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
GAMEOBJECT_DYN_FLAGS = OBJECT_END + 0x000D, // Size: 1, Type: INT, Flags: DYNAMIC
|
||||
GAMEOBJECT_FACTION = OBJECT_END + 0x000E, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
GAMEOBJECT_TYPE_ID = OBJECT_END + 0x000F, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
GAMEOBJECT_LEVEL = OBJECT_END + 0x0010, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
GAMEOBJECT_ARTKIT = OBJECT_END + 0x0011, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
GAMEOBJECT_ANIMPROGRESS = OBJECT_END + 0x0012, // Size: 1, Type: INT, Flags: DYNAMIC
|
||||
GAMEOBJECT_PADDING = OBJECT_END + 0x0013, // Size: 1, Type: INT, Flags: NONE
|
||||
GAMEOBJECT_END = OBJECT_END + 0x0014,
|
||||
};
|
||||
|
||||
enum EDynamicObjectFields
|
||||
{
|
||||
DYNAMICOBJECT_CASTER = OBJECT_END + 0x0000, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
DYNAMICOBJECT_BYTES = OBJECT_END + 0x0002, // Size: 1, Type: BYTES, Flags: PUBLIC
|
||||
DYNAMICOBJECT_SPELLID = OBJECT_END + 0x0003, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
DYNAMICOBJECT_RADIUS = OBJECT_END + 0x0004, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
DYNAMICOBJECT_POS_X = OBJECT_END + 0x0005, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
DYNAMICOBJECT_POS_Y = OBJECT_END + 0x0006, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
DYNAMICOBJECT_POS_Z = OBJECT_END + 0x0007, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
DYNAMICOBJECT_FACING = OBJECT_END + 0x0008, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
DYNAMICOBJECT_PAD = OBJECT_END + 0x0009, // Size: 1, Type: BYTES, Flags: PUBLIC
|
||||
DYNAMICOBJECT_END = OBJECT_END + 0x000A,
|
||||
};
|
||||
|
||||
enum ECorpseFields
|
||||
{
|
||||
CORPSE_FIELD_OWNER = OBJECT_END + 0x0000, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
CORPSE_FIELD_FACING = OBJECT_END + 0x0002, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
CORPSE_FIELD_POS_X = OBJECT_END + 0x0003, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
CORPSE_FIELD_POS_Y = OBJECT_END + 0x0004, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
CORPSE_FIELD_POS_Z = OBJECT_END + 0x0005, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
CORPSE_FIELD_DISPLAY_ID = OBJECT_END + 0x0006, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
CORPSE_FIELD_ITEM = OBJECT_END + 0x0007, // Size: 19, Type: INT, Flags: PUBLIC
|
||||
CORPSE_FIELD_BYTES_1 = OBJECT_END + 0x001A, // Size: 1, Type: BYTES, Flags: PUBLIC
|
||||
CORPSE_FIELD_BYTES_2 = OBJECT_END + 0x001B, // Size: 1, Type: BYTES, Flags: PUBLIC
|
||||
CORPSE_FIELD_GUILD = OBJECT_END + 0x001C, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
CORPSE_FIELD_FLAGS = OBJECT_END + 0x001D, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
CORPSE_FIELD_DYNAMIC_FLAGS = OBJECT_END + 0x001E, // Size: 1, Type: INT, Flags: DYNAMIC
|
||||
CORPSE_FIELD_PAD = OBJECT_END + 0x001F, // Size: 1, Type: INT, Flags: NONE
|
||||
CORPSE_END = OBJECT_END + 0x0020,
|
||||
};
|
||||
#endif
|
||||
/*
|
||||
* Copyright (C) 2005,2006,2007 MaNGOS <http://www.mangosproject.org/>
|
||||
*
|
||||
* 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 2 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, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifndef _UPDATEFIELDS_AUTO_H
|
||||
#define _UPDATEFIELDS_AUTO_H
|
||||
|
||||
// Auto generated for version 0, 3, 2, 7655
|
||||
|
||||
enum EObjectFields
|
||||
{
|
||||
OBJECT_FIELD_GUID = 0x0000, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
OBJECT_FIELD_TYPE = 0x0002, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
OBJECT_FIELD_ENTRY = 0x0003, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
OBJECT_FIELD_SCALE_X = 0x0004, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
OBJECT_FIELD_PADDING = 0x0005, // Size: 1, Type: INT, Flags: NONE
|
||||
OBJECT_END = 0x0006,
|
||||
};
|
||||
|
||||
enum EItemFields
|
||||
{
|
||||
ITEM_FIELD_OWNER = OBJECT_END + 0x0000, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
ITEM_FIELD_CONTAINED = OBJECT_END + 0x0002, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
ITEM_FIELD_CREATOR = OBJECT_END + 0x0004, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
ITEM_FIELD_GIFTCREATOR = OBJECT_END + 0x0006, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
ITEM_FIELD_STACK_COUNT = OBJECT_END + 0x0008, // Size: 1, Type: INT, Flags: OWNER_ONLY, UNK2
|
||||
ITEM_FIELD_DURATION = OBJECT_END + 0x0009, // Size: 1, Type: INT, Flags: OWNER_ONLY, UNK2
|
||||
ITEM_FIELD_SPELL_CHARGES = OBJECT_END + 0x000A, // Size: 5, Type: INT, Flags: OWNER_ONLY, UNK2
|
||||
ITEM_FIELD_FLAGS = OBJECT_END + 0x000F, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
ITEM_FIELD_ENCHANTMENT = OBJECT_END + 0x0010, // Size: 33, Type: INT, Flags: PUBLIC
|
||||
ITEM_FIELD_PROPERTY_SEED = OBJECT_END + 0x0031, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
|
||||
// custom
|
||||
ITEM_FIELD_SUFFIX_FACTOR = ITEM_FIELD_PROPERTY_SEED,
|
||||
|
||||
ITEM_FIELD_RANDOM_PROPERTIES_ID = OBJECT_END + 0x0032, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
ITEM_FIELD_ITEM_TEXT_ID = OBJECT_END + 0x0033, // Size: 1, Type: INT, Flags: OWNER_ONLY
|
||||
ITEM_FIELD_DURABILITY = OBJECT_END + 0x0034, // Size: 1, Type: INT, Flags: OWNER_ONLY, UNK2
|
||||
ITEM_FIELD_MAXDURABILITY = OBJECT_END + 0x0035, // Size: 1, Type: INT, Flags: OWNER_ONLY, UNK2
|
||||
ITEM_END = OBJECT_END + 0x0036,
|
||||
};
|
||||
|
||||
enum EContainerFields
|
||||
{
|
||||
CONTAINER_FIELD_NUM_SLOTS = ITEM_END + 0x0000, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
CONTAINER_ALIGN_PAD = ITEM_END + 0x0001, // Size: 1, Type: BYTES, Flags: NONE
|
||||
CONTAINER_FIELD_SLOT_1 = ITEM_END + 0x0002, // Size: 72, Type: LONG, Flags: PUBLIC
|
||||
CONTAINER_END = ITEM_END + 0x004A,
|
||||
};
|
||||
|
||||
enum EUnitFields
|
||||
{
|
||||
UNIT_FIELD_CHARM = OBJECT_END + 0x0000, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
UNIT_FIELD_SUMMON = OBJECT_END + 0x0002, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
UNIT_FIELD_CHARMEDBY = OBJECT_END + 0x0004, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
UNIT_FIELD_SUMMONEDBY = OBJECT_END + 0x0006, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
UNIT_FIELD_CREATEDBY = OBJECT_END + 0x0008, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
UNIT_FIELD_TARGET = OBJECT_END + 0x000A, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
UNIT_FIELD_PERSUADED = OBJECT_END + 0x000C, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
UNIT_FIELD_CHANNEL_OBJECT = OBJECT_END + 0x000E, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
UNIT_FIELD_HEALTH = OBJECT_END + 0x0010, // Size: 1, Type: INT, Flags: DYNAMIC
|
||||
UNIT_FIELD_POWER1 = OBJECT_END + 0x0011, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_POWER2 = OBJECT_END + 0x0012, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_POWER3 = OBJECT_END + 0x0013, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_POWER4 = OBJECT_END + 0x0014, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_POWER5 = OBJECT_END + 0x0015, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_MAXHEALTH = OBJECT_END + 0x0016, // Size: 1, Type: INT, Flags: DYNAMIC
|
||||
UNIT_FIELD_MAXPOWER1 = OBJECT_END + 0x0017, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_MAXPOWER2 = OBJECT_END + 0x0018, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_MAXPOWER3 = OBJECT_END + 0x0019, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_MAXPOWER4 = OBJECT_END + 0x001A, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_MAXPOWER5 = OBJECT_END + 0x001B, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_LEVEL = OBJECT_END + 0x001C, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_FACTIONTEMPLATE = OBJECT_END + 0x001D, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_BYTES_0 = OBJECT_END + 0x001E, // Size: 1, Type: BYTES, Flags: PUBLIC
|
||||
UNIT_VIRTUAL_ITEM_SLOT_DISPLAY = OBJECT_END + 0x001F, // Size: 3, Type: INT, Flags: PUBLIC
|
||||
UNIT_VIRTUAL_ITEM_INFO = OBJECT_END + 0x0022, // Size: 6, Type: BYTES, Flags: PUBLIC
|
||||
UNIT_FIELD_FLAGS = OBJECT_END + 0x0028, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_FLAGS_2 = OBJECT_END + 0x0029, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_AURA = OBJECT_END + 0x002A, // Size: 56, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_AURAFLAGS = OBJECT_END + 0x0062, // Size: 14, Type: BYTES, Flags: PUBLIC
|
||||
UNIT_FIELD_AURALEVELS = OBJECT_END + 0x0070, // Size: 14, Type: BYTES, Flags: PUBLIC
|
||||
UNIT_FIELD_AURAAPPLICATIONS = OBJECT_END + 0x007E, // Size: 14, Type: BYTES, Flags: PUBLIC
|
||||
UNIT_FIELD_AURASTATE = OBJECT_END + 0x008C, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_BASEATTACKTIME = OBJECT_END + 0x008D, // Size: 2, Type: INT, Flags: PUBLIC
|
||||
|
||||
// custom
|
||||
UNIT_FIELD_OFFHANDATTACKTIME = UNIT_FIELD_BASEATTACKTIME + 1,
|
||||
|
||||
UNIT_FIELD_RANGEDATTACKTIME = OBJECT_END + 0x008F, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
UNIT_FIELD_BOUNDINGRADIUS = OBJECT_END + 0x0090, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
UNIT_FIELD_COMBATREACH = OBJECT_END + 0x0091, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
UNIT_FIELD_DISPLAYID = OBJECT_END + 0x0092, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_NATIVEDISPLAYID = OBJECT_END + 0x0093, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_MOUNTDISPLAYID = OBJECT_END + 0x0094, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_MINDAMAGE = OBJECT_END + 0x0095, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY, UNK3
|
||||
UNIT_FIELD_MAXDAMAGE = OBJECT_END + 0x0096, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY, UNK3
|
||||
UNIT_FIELD_MINOFFHANDDAMAGE = OBJECT_END + 0x0097, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY, UNK3
|
||||
UNIT_FIELD_MAXOFFHANDDAMAGE = OBJECT_END + 0x0098, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY, UNK3
|
||||
UNIT_FIELD_BYTES_1 = OBJECT_END + 0x0099, // Size: 1, Type: BYTES, Flags: PUBLIC
|
||||
UNIT_FIELD_PETNUMBER = OBJECT_END + 0x009A, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_PET_NAME_TIMESTAMP = OBJECT_END + 0x009B, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_FIELD_PETEXPERIENCE = OBJECT_END + 0x009C, // Size: 1, Type: INT, Flags: OWNER_ONLY
|
||||
UNIT_FIELD_PETNEXTLEVELEXP = OBJECT_END + 0x009D, // Size: 1, Type: INT, Flags: OWNER_ONLY
|
||||
UNIT_DYNAMIC_FLAGS = OBJECT_END + 0x009E, // Size: 1, Type: INT, Flags: DYNAMIC
|
||||
UNIT_CHANNEL_SPELL = OBJECT_END + 0x009F, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_MOD_CAST_SPEED = OBJECT_END + 0x00A0, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
UNIT_CREATED_BY_SPELL = OBJECT_END + 0x00A1, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_NPC_FLAGS = OBJECT_END + 0x00A2, // Size: 1, Type: INT, Flags: DYNAMIC
|
||||
UNIT_NPC_EMOTESTATE = OBJECT_END + 0x00A3, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
UNIT_TRAINING_POINTS = OBJECT_END + 0x00A4, // Size: 1, Type: TWO_SHORT, Flags: OWNER_ONLY
|
||||
UNIT_FIELD_STAT0 = OBJECT_END + 0x00A5, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_STAT1 = OBJECT_END + 0x00A6, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_STAT2 = OBJECT_END + 0x00A7, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_STAT3 = OBJECT_END + 0x00A8, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_STAT4 = OBJECT_END + 0x00A9, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_POSSTAT0 = OBJECT_END + 0x00AA, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_POSSTAT1 = OBJECT_END + 0x00AB, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_POSSTAT2 = OBJECT_END + 0x00AC, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_POSSTAT3 = OBJECT_END + 0x00AD, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_POSSTAT4 = OBJECT_END + 0x00AE, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_NEGSTAT0 = OBJECT_END + 0x00AF, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_NEGSTAT1 = OBJECT_END + 0x00B0, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_NEGSTAT2 = OBJECT_END + 0x00B1, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_NEGSTAT3 = OBJECT_END + 0x00B2, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_NEGSTAT4 = OBJECT_END + 0x00B3, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_RESISTANCES = OBJECT_END + 0x00B4, // Size: 7, Type: INT, Flags: PRIVATE, OWNER_ONLY, UNK3
|
||||
UNIT_FIELD_RESISTANCEBUFFMODSPOSITIVE = OBJECT_END + 0x00BB, // Size: 7, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_RESISTANCEBUFFMODSNEGATIVE = OBJECT_END + 0x00C2, // Size: 7, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_BASE_MANA = OBJECT_END + 0x00C9, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_BASE_HEALTH = OBJECT_END + 0x00CA, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_BYTES_2 = OBJECT_END + 0x00CB, // Size: 1, Type: BYTES, Flags: PUBLIC
|
||||
UNIT_FIELD_ATTACK_POWER = OBJECT_END + 0x00CC, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_ATTACK_POWER_MODS = OBJECT_END + 0x00CD, // Size: 1, Type: TWO_SHORT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_ATTACK_POWER_MULTIPLIER = OBJECT_END + 0x00CE, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_RANGED_ATTACK_POWER = OBJECT_END + 0x00CF, // Size: 1, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_RANGED_ATTACK_POWER_MODS = OBJECT_END + 0x00D0, // Size: 1, Type: TWO_SHORT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER = OBJECT_END + 0x00D1, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_MINRANGEDDAMAGE = OBJECT_END + 0x00D2, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_MAXRANGEDDAMAGE = OBJECT_END + 0x00D3, // Size: 1, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_POWER_COST_MODIFIER = OBJECT_END + 0x00D4, // Size: 7, Type: INT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_FIELD_POWER_COST_MULTIPLIER = OBJECT_END + 0x00DB, // Size: 7, Type: FLOAT, Flags: PRIVATE, OWNER_ONLY
|
||||
UNIT_END = OBJECT_END + 0x00E2,
|
||||
|
||||
PLAYER_DUEL_ARBITER = UNIT_END + 0x0000, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_FLAGS = UNIT_END + 0x0002, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_GUILDID = UNIT_END + 0x0003, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_GUILDRANK = UNIT_END + 0x0004, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_BYTES = UNIT_END + 0x0005, // Size: 1, Type: BYTES, Flags: PUBLIC
|
||||
PLAYER_BYTES_2 = UNIT_END + 0x0006, // Size: 1, Type: BYTES, Flags: PUBLIC
|
||||
PLAYER_BYTES_3 = UNIT_END + 0x0007, // Size: 1, Type: BYTES, Flags: PUBLIC
|
||||
PLAYER_DUEL_TEAM = UNIT_END + 0x0008, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_GUILD_TIMESTAMP = UNIT_END + 0x0009, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_QUEST_LOG_1_1 = UNIT_END + 0x000A, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_1_2 = UNIT_END + 0x000B, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_2_1 = UNIT_END + 0x000D, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_2_2 = UNIT_END + 0x000E, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_3_1 = UNIT_END + 0x0010, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_3_2 = UNIT_END + 0x0011, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_4_1 = UNIT_END + 0x0013, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_4_2 = UNIT_END + 0x0014, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_5_1 = UNIT_END + 0x0016, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_5_2 = UNIT_END + 0x0017, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_6_1 = UNIT_END + 0x0019, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_6_2 = UNIT_END + 0x001A, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_7_1 = UNIT_END + 0x001C, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_7_2 = UNIT_END + 0x001D, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_8_1 = UNIT_END + 0x001F, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_8_2 = UNIT_END + 0x0020, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_9_1 = UNIT_END + 0x0022, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_9_2 = UNIT_END + 0x0023, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_10_1 = UNIT_END + 0x0025, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_10_2 = UNIT_END + 0x0026, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_11_1 = UNIT_END + 0x0028, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_11_2 = UNIT_END + 0x0029, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_12_1 = UNIT_END + 0x002B, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_12_2 = UNIT_END + 0x002C, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_13_1 = UNIT_END + 0x002E, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_13_2 = UNIT_END + 0x002F, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_14_1 = UNIT_END + 0x0031, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_14_2 = UNIT_END + 0x0032, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_15_1 = UNIT_END + 0x0034, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_15_2 = UNIT_END + 0x0035, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_16_1 = UNIT_END + 0x0037, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_16_2 = UNIT_END + 0x0038, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_17_1 = UNIT_END + 0x003A, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_17_2 = UNIT_END + 0x003B, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_18_1 = UNIT_END + 0x003D, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_18_2 = UNIT_END + 0x003E, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_19_1 = UNIT_END + 0x0040, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_19_2 = UNIT_END + 0x0041, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_20_1 = UNIT_END + 0x0043, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_20_2 = UNIT_END + 0x0044, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_21_1 = UNIT_END + 0x0046, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_21_2 = UNIT_END + 0x0047, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_22_1 = UNIT_END + 0x0049, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_22_2 = UNIT_END + 0x004A, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_23_1 = UNIT_END + 0x004C, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_23_2 = UNIT_END + 0x004D, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_24_1 = UNIT_END + 0x004F, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_24_2 = UNIT_END + 0x0050, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_QUEST_LOG_25_1 = UNIT_END + 0x0052, // Size: 1, Type: INT, Flags: GROUP_ONLY
|
||||
PLAYER_QUEST_LOG_25_2 = UNIT_END + 0x0053, // Size: 2, Type: INT, Flags: PRIVATE
|
||||
PLAYER_VISIBLE_ITEM_1_CREATOR = UNIT_END + 0x0055, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_1_0 = UNIT_END + 0x0057, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_1_PROPERTIES = UNIT_END + 0x0063, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_1_PAD = UNIT_END + 0x0064, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_2_CREATOR = UNIT_END + 0x0065, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_2_0 = UNIT_END + 0x0067, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_2_PROPERTIES = UNIT_END + 0x0073, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_2_PAD = UNIT_END + 0x0074, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_3_CREATOR = UNIT_END + 0x0075, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_3_0 = UNIT_END + 0x0077, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_3_PROPERTIES = UNIT_END + 0x0083, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_3_PAD = UNIT_END + 0x0084, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_4_CREATOR = UNIT_END + 0x0085, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_4_0 = UNIT_END + 0x0087, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_4_PROPERTIES = UNIT_END + 0x0093, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_4_PAD = UNIT_END + 0x0094, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_5_CREATOR = UNIT_END + 0x0095, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_5_0 = UNIT_END + 0x0097, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_5_PROPERTIES = UNIT_END + 0x00A3, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_5_PAD = UNIT_END + 0x00A4, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_6_CREATOR = UNIT_END + 0x00A5, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_6_0 = UNIT_END + 0x00A7, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_6_PROPERTIES = UNIT_END + 0x00B3, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_6_PAD = UNIT_END + 0x00B4, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_7_CREATOR = UNIT_END + 0x00B5, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_7_0 = UNIT_END + 0x00B7, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_7_PROPERTIES = UNIT_END + 0x00C3, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_7_PAD = UNIT_END + 0x00C4, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_8_CREATOR = UNIT_END + 0x00C5, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_8_0 = UNIT_END + 0x00C7, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_8_PROPERTIES = UNIT_END + 0x00D3, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_8_PAD = UNIT_END + 0x00D4, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_9_CREATOR = UNIT_END + 0x00D5, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_9_0 = UNIT_END + 0x00D7, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_9_PROPERTIES = UNIT_END + 0x00E3, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_9_PAD = UNIT_END + 0x00E4, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_10_CREATOR = UNIT_END + 0x00E5, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_10_0 = UNIT_END + 0x00E7, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_10_PROPERTIES = UNIT_END + 0x00F3, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_10_PAD = UNIT_END + 0x00F4, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_11_CREATOR = UNIT_END + 0x00F5, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_11_0 = UNIT_END + 0x00F7, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_11_PROPERTIES = UNIT_END + 0x0103, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_11_PAD = UNIT_END + 0x0104, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_12_CREATOR = UNIT_END + 0x0105, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_12_0 = UNIT_END + 0x0107, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_12_PROPERTIES = UNIT_END + 0x0113, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_12_PAD = UNIT_END + 0x0114, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_13_CREATOR = UNIT_END + 0x0115, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_13_0 = UNIT_END + 0x0117, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_13_PROPERTIES = UNIT_END + 0x0123, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_13_PAD = UNIT_END + 0x0124, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_14_CREATOR = UNIT_END + 0x0125, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_14_0 = UNIT_END + 0x0127, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_14_PROPERTIES = UNIT_END + 0x0133, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_14_PAD = UNIT_END + 0x0134, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_15_CREATOR = UNIT_END + 0x0135, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_15_0 = UNIT_END + 0x0137, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_15_PROPERTIES = UNIT_END + 0x0143, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_15_PAD = UNIT_END + 0x0144, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_16_CREATOR = UNIT_END + 0x0145, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_16_0 = UNIT_END + 0x0147, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_16_PROPERTIES = UNIT_END + 0x0153, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_16_PAD = UNIT_END + 0x0154, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_17_CREATOR = UNIT_END + 0x0155, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_17_0 = UNIT_END + 0x0157, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_17_PROPERTIES = UNIT_END + 0x0163, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_17_PAD = UNIT_END + 0x0164, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_18_CREATOR = UNIT_END + 0x0165, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_18_0 = UNIT_END + 0x0167, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_18_PROPERTIES = UNIT_END + 0x0173, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_18_PAD = UNIT_END + 0x0174, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_19_CREATOR = UNIT_END + 0x0175, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_19_0 = UNIT_END + 0x0177, // Size: 12, Type: INT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_19_PROPERTIES = UNIT_END + 0x0183, // Size: 1, Type: TWO_SHORT, Flags: PUBLIC
|
||||
PLAYER_VISIBLE_ITEM_19_PAD = UNIT_END + 0x0184, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_CHOSEN_TITLE = UNIT_END + 0x0185, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
PLAYER_FIELD_INV_SLOT_HEAD = UNIT_END + 0x0186, // Size: 46, Type: LONG, Flags: PRIVATE
|
||||
PLAYER_FIELD_PACK_SLOT_1 = UNIT_END + 0x01B4, // Size: 32, Type: LONG, Flags: PRIVATE
|
||||
PLAYER_FIELD_BANK_SLOT_1 = UNIT_END + 0x01D4, // Size: 56, Type: LONG, Flags: PRIVATE
|
||||
PLAYER_FIELD_BANKBAG_SLOT_1 = UNIT_END + 0x020C, // Size: 14, Type: LONG, Flags: PRIVATE
|
||||
PLAYER_FIELD_VENDORBUYBACK_SLOT_1 = UNIT_END + 0x021A, // Size: 24, Type: LONG, Flags: PRIVATE
|
||||
PLAYER_FIELD_KEYRING_SLOT_1 = UNIT_END + 0x0232, // Size: 64, Type: LONG, Flags: PRIVATE
|
||||
PLAYER_FARSIGHT = UNIT_END + 0x0272, // Size: 2, Type: LONG, Flags: PRIVATE
|
||||
PLAYER__FIELD_KNOWN_TITLES = UNIT_END + 0x0274, // Size: 2, Type: LONG, Flags: PRIVATE
|
||||
PLAYER_XP = UNIT_END + 0x0276, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_NEXT_LEVEL_XP = UNIT_END + 0x0277, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_SKILL_INFO_1_1 = UNIT_END + 0x0278, // Size: 384, Type: TWO_SHORT, Flags: PRIVATE
|
||||
PLAYER_CHARACTER_POINTS1 = UNIT_END + 0x03F8, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_CHARACTER_POINTS2 = UNIT_END + 0x03F9, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_TRACK_CREATURES = UNIT_END + 0x03FA, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_TRACK_RESOURCES = UNIT_END + 0x03FB, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_BLOCK_PERCENTAGE = UNIT_END + 0x03FC, // Size: 1, Type: FLOAT, Flags: PRIVATE
|
||||
PLAYER_DODGE_PERCENTAGE = UNIT_END + 0x03FD, // Size: 1, Type: FLOAT, Flags: PRIVATE
|
||||
PLAYER_PARRY_PERCENTAGE = UNIT_END + 0x03FE, // Size: 1, Type: FLOAT, Flags: PRIVATE
|
||||
PLAYER_EXPERTISE = UNIT_END + 0x03FF, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_CRIT_PERCENTAGE = UNIT_END + 0x0400, // Size: 1, Type: FLOAT, Flags: PRIVATE
|
||||
PLAYER_RANGED_CRIT_PERCENTAGE = UNIT_END + 0x0401, // Size: 1, Type: FLOAT, Flags: PRIVATE
|
||||
PLAYER_OFFHAND_CRIT_PERCENTAGE = UNIT_END + 0x0402, // Size: 1, Type: FLOAT, Flags: PRIVATE
|
||||
PLAYER_SPELL_CRIT_PERCENTAGE1 = UNIT_END + 0x0403, // Size: 7, Type: FLOAT, Flags: PRIVATE
|
||||
|
||||
// custom
|
||||
PLAYER_HOLY_SPELL_CRIT_PERCENTAGE = PLAYER_SPELL_CRIT_PERCENTAGE1+1,
|
||||
PLAYER_FIRE_SPELL_CRIT_PERCENTAGE = PLAYER_SPELL_CRIT_PERCENTAGE1+2,
|
||||
PLAYER_NATURE_SPELL_CRIT_PERCENTAGE = PLAYER_SPELL_CRIT_PERCENTAGE1+3,
|
||||
PLAYER_FROST_SPELL_CRIT_PERCENTAGE = PLAYER_SPELL_CRIT_PERCENTAGE1+4,
|
||||
PLAYER_SHADOW_SPELL_CRIT_PERCENTAGE = PLAYER_SPELL_CRIT_PERCENTAGE1+5,
|
||||
PLAYER_ARCANE_SPELL_CRIT_PERCENTAGE = PLAYER_SPELL_CRIT_PERCENTAGE1+6,
|
||||
|
||||
PLAYER_SHIELD_BLOCK = UNIT_END + 0x040A, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_EXPLORED_ZONES_1 = UNIT_END + 0x040B, // Size: 64, Type: BYTES, Flags: PRIVATE
|
||||
PLAYER_REST_STATE_EXPERIENCE = UNIT_END + 0x044B, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_COINAGE = UNIT_END + 0x044C, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_MOD_DAMAGE_DONE_POS = UNIT_END + 0x044D, // Size: 7, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_MOD_DAMAGE_DONE_NEG = UNIT_END + 0x0454, // Size: 7, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_MOD_DAMAGE_DONE_PCT = UNIT_END + 0x045B, // Size: 7, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_MOD_HEALING_DONE_POS = UNIT_END + 0x0462, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_MOD_TARGET_RESISTANCE = UNIT_END + 0x0463, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_BYTES = UNIT_END + 0x0464, // Size: 1, Type: BYTES, Flags: PRIVATE
|
||||
PLAYER_AMMO_ID = UNIT_END + 0x0465, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_SELF_RES_SPELL = UNIT_END + 0x0466, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_PVP_MEDALS = UNIT_END + 0x0467, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_BUYBACK_PRICE_1 = UNIT_END + 0x0468, // Size: 12, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_BUYBACK_TIMESTAMP_1 = UNIT_END + 0x0474, // Size: 12, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_KILLS = UNIT_END + 0x0480, // Size: 1, Type: TWO_SHORT, Flags: PRIVATE
|
||||
PLAYER_FIELD_TODAY_CONTRIBUTION = UNIT_END + 0x0481, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_YESTERDAY_CONTRIBUTION = UNIT_END + 0x0482, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_LIFETIME_HONORBALE_KILLS = UNIT_END + 0x0483, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_BYTES2 = UNIT_END + 0x0484, // Size: 1, Type: BYTES, Flags: PRIVATE
|
||||
PLAYER_FIELD_WATCHED_FACTION_INDEX = UNIT_END + 0x0485, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_COMBAT_RATING_1 = UNIT_END + 0x0486, // Size: 24, Type: INT, Flags: PRIVATE
|
||||
|
||||
// custom // client names:
|
||||
// CR_WEAPON_SKILL
|
||||
PLAYER_FIELD_ALL_WEAPONS_SKILL_RATING = PLAYER_FIELD_COMBAT_RATING_1,
|
||||
// CR_DEFENSE_SKILL
|
||||
PLAYER_FIELD_DEFENCE_RATING = PLAYER_FIELD_COMBAT_RATING_1+1,
|
||||
// CR_DODGE
|
||||
PLAYER_FIELD_DODGE_RATING = PLAYER_FIELD_COMBAT_RATING_1+2,
|
||||
// CR_PARRY
|
||||
PLAYER_FIELD_PARRY_RATING = PLAYER_FIELD_COMBAT_RATING_1+3,
|
||||
// CR_BLOCK
|
||||
PLAYER_FIELD_BLOCK_RATING = PLAYER_FIELD_COMBAT_RATING_1+4,
|
||||
// CR_HIT_MELEE
|
||||
PLAYER_FIELD_MELEE_HIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+5,
|
||||
// CR_HIT_RANGED
|
||||
PLAYER_FIELD_RANGED_HIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+6,
|
||||
// CR_HIT_SPELL
|
||||
PLAYER_FIELD_SPELL_HIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+7,
|
||||
// CR_CRIT_MELEE
|
||||
PLAYER_FIELD_MELEE_CRIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+8,
|
||||
// CR_CRIT_RANGED
|
||||
PLAYER_FIELD_RANGED_CRIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+9,
|
||||
// CR_CRIT_SPELL
|
||||
PLAYER_FIELD_SPELL_CRIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+10,
|
||||
// CR_HIT_TAKEN_MELEE
|
||||
PLAYER_FIELD_HIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+11,
|
||||
// CR_HIT_TAKEN_RANGED
|
||||
PLAYER_FIELD_CRIT_RATING = PLAYER_FIELD_COMBAT_RATING_1+12,
|
||||
// CR_HIT_TAKEN_SPELL
|
||||
PLAYER_FIELD_UNK3_RATING = PLAYER_FIELD_COMBAT_RATING_1+13,
|
||||
// CR_CRIT_TAKEN_MELEE
|
||||
PLAYER_FIELD_UNK4_RATING = PLAYER_FIELD_COMBAT_RATING_1+14,
|
||||
// CR_CRIT_TAKEN_RANGED
|
||||
PLAYER_FIELD_UNK5_RATING = PLAYER_FIELD_COMBAT_RATING_1+15,
|
||||
// CR_CRIT_TAKEN_SPELL
|
||||
PLAYER_FIELD_RESILIENCE_RATING = PLAYER_FIELD_COMBAT_RATING_1+16,
|
||||
// CR_HASTE_MELEE
|
||||
PLAYER_FIELD_MELEE_HASTE_RATING = PLAYER_FIELD_COMBAT_RATING_1+17,
|
||||
// CR_HASTE_RANGED
|
||||
PLAYER_FIELD_RANGED_HASTE_RATING = PLAYER_FIELD_COMBAT_RATING_1+18,
|
||||
// CR_HASTE_SPELL
|
||||
PLAYER_FIELD_SPELL_HASTE_RATING = PLAYER_FIELD_COMBAT_RATING_1+19,
|
||||
// CR_WEAPON_SKILL_MAINHAND
|
||||
PLAYER_FIELD_MELEE_WEAPON_SKILL_RATING = PLAYER_FIELD_COMBAT_RATING_1+20,
|
||||
// CR_WEAPON_SKILL_OFFHAND
|
||||
PLAYER_FIELD_OFFHAND_WEAPON_SKILL_RATING = PLAYER_FIELD_COMBAT_RATING_1+21,
|
||||
// CR_WEAPON_SKILL_RANGED
|
||||
PLAYER_FIELD_RANGED_WEAPON_SKILL_RATING = PLAYER_FIELD_COMBAT_RATING_1+22,
|
||||
// CR_EXPERTISE
|
||||
PLAYER_FIELD_EXPERTISE_RATING = PLAYER_FIELD_COMBAT_RATING_1+23,
|
||||
|
||||
PLAYER_FIELD_ARENA_TEAM_INFO_1_1 = UNIT_END + 0x049E, // Size: 18, Type: INT, Flags: PRIVATE
|
||||
|
||||
// custom
|
||||
PLAYER_FIELD_ARENA_TEAM_ID_2v2 = PLAYER_FIELD_ARENA_TEAM_INFO_1_1,
|
||||
PLAYER_FIELD_ARENA_TEAM_ID_3v3 = PLAYER_FIELD_ARENA_TEAM_INFO_1_1+6,
|
||||
PLAYER_FIELD_ARENA_TEAM_ID_5v5 = PLAYER_FIELD_ARENA_TEAM_INFO_1_1+12,
|
||||
|
||||
PLAYER_FIELD_HONOR_CURRENCY = UNIT_END + 0x04B0, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_ARENA_CURRENCY = UNIT_END + 0x04B1, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_MOD_MANA_REGEN = UNIT_END + 0x04B2, // Size: 1, Type: FLOAT, Flags: PRIVATE
|
||||
PLAYER_FIELD_MOD_MANA_REGEN_INTERRUPT = UNIT_END + 0x04B3, // Size: 1, Type: FLOAT, Flags: PRIVATE
|
||||
PLAYER_FIELD_MAX_LEVEL = UNIT_END + 0x04B4, // Size: 1, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_DAILY_QUESTS_1 = UNIT_END + 0x04B5, // Size: 10, Type: INT, Flags: PRIVATE
|
||||
PLAYER_FIELD_PADDING = UNIT_END + 0x04BF, // Size: 1, Type: INT, Flags: NONE
|
||||
PLAYER_END = UNIT_END + 0x04C0,
|
||||
};
|
||||
|
||||
enum EGameObjectFields
|
||||
{
|
||||
OBJECT_FIELD_CREATED_BY = OBJECT_END + 0x0000, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
GAMEOBJECT_DISPLAYID = OBJECT_END + 0x0002, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
GAMEOBJECT_FLAGS = OBJECT_END + 0x0003, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
GAMEOBJECT_ROTATION = OBJECT_END + 0x0004, // Size: 4, Type: FLOAT, Flags: PUBLIC
|
||||
GAMEOBJECT_STATE = OBJECT_END + 0x0008, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
GAMEOBJECT_POS_X = OBJECT_END + 0x0009, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
GAMEOBJECT_POS_Y = OBJECT_END + 0x000A, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
GAMEOBJECT_POS_Z = OBJECT_END + 0x000B, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
GAMEOBJECT_FACING = OBJECT_END + 0x000C, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
GAMEOBJECT_DYN_FLAGS = OBJECT_END + 0x000D, // Size: 1, Type: INT, Flags: DYNAMIC
|
||||
GAMEOBJECT_FACTION = OBJECT_END + 0x000E, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
GAMEOBJECT_TYPE_ID = OBJECT_END + 0x000F, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
GAMEOBJECT_LEVEL = OBJECT_END + 0x0010, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
GAMEOBJECT_ARTKIT = OBJECT_END + 0x0011, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
GAMEOBJECT_ANIMPROGRESS = OBJECT_END + 0x0012, // Size: 1, Type: INT, Flags: DYNAMIC
|
||||
GAMEOBJECT_PADDING = OBJECT_END + 0x0013, // Size: 1, Type: INT, Flags: NONE
|
||||
GAMEOBJECT_END = OBJECT_END + 0x0014,
|
||||
};
|
||||
|
||||
enum EDynamicObjectFields
|
||||
{
|
||||
DYNAMICOBJECT_CASTER = OBJECT_END + 0x0000, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
DYNAMICOBJECT_BYTES = OBJECT_END + 0x0002, // Size: 1, Type: BYTES, Flags: PUBLIC
|
||||
DYNAMICOBJECT_SPELLID = OBJECT_END + 0x0003, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
DYNAMICOBJECT_RADIUS = OBJECT_END + 0x0004, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
DYNAMICOBJECT_POS_X = OBJECT_END + 0x0005, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
DYNAMICOBJECT_POS_Y = OBJECT_END + 0x0006, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
DYNAMICOBJECT_POS_Z = OBJECT_END + 0x0007, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
DYNAMICOBJECT_FACING = OBJECT_END + 0x0008, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
DYNAMICOBJECT_PAD = OBJECT_END + 0x0009, // Size: 1, Type: BYTES, Flags: PUBLIC
|
||||
DYNAMICOBJECT_END = OBJECT_END + 0x000A,
|
||||
};
|
||||
|
||||
enum ECorpseFields
|
||||
{
|
||||
CORPSE_FIELD_OWNER = OBJECT_END + 0x0000, // Size: 2, Type: LONG, Flags: PUBLIC
|
||||
CORPSE_FIELD_FACING = OBJECT_END + 0x0002, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
CORPSE_FIELD_POS_X = OBJECT_END + 0x0003, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
CORPSE_FIELD_POS_Y = OBJECT_END + 0x0004, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
CORPSE_FIELD_POS_Z = OBJECT_END + 0x0005, // Size: 1, Type: FLOAT, Flags: PUBLIC
|
||||
CORPSE_FIELD_DISPLAY_ID = OBJECT_END + 0x0006, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
CORPSE_FIELD_ITEM = OBJECT_END + 0x0007, // Size: 19, Type: INT, Flags: PUBLIC
|
||||
CORPSE_FIELD_BYTES_1 = OBJECT_END + 0x001A, // Size: 1, Type: BYTES, Flags: PUBLIC
|
||||
CORPSE_FIELD_BYTES_2 = OBJECT_END + 0x001B, // Size: 1, Type: BYTES, Flags: PUBLIC
|
||||
CORPSE_FIELD_GUILD = OBJECT_END + 0x001C, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
CORPSE_FIELD_FLAGS = OBJECT_END + 0x001D, // Size: 1, Type: INT, Flags: PUBLIC
|
||||
CORPSE_FIELD_DYNAMIC_FLAGS = OBJECT_END + 0x001E, // Size: 1, Type: INT, Flags: DYNAMIC
|
||||
CORPSE_FIELD_PAD = OBJECT_END + 0x001F, // Size: 1, Type: INT, Flags: NONE
|
||||
CORPSE_END = OBJECT_END + 0x0020,
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -1,74 +1,74 @@
|
||||
#include "common.h"
|
||||
#include "MapMgr.h"
|
||||
#include "WorldSession.h"
|
||||
#include "World.h"
|
||||
|
||||
World::World(WorldSession *s)
|
||||
{
|
||||
_session = s;
|
||||
_mapId = -1;
|
||||
_mapmgr = NULL;
|
||||
if(_session->GetInstance()->GetConf()->useMaps)
|
||||
_mapmgr = new MapMgr();
|
||||
}
|
||||
|
||||
World::~World()
|
||||
{
|
||||
Clear();
|
||||
if(_mapmgr)
|
||||
delete _mapmgr;
|
||||
}
|
||||
|
||||
// called on SMSG_NEW_WORLD
|
||||
void World::Clear(void)
|
||||
{
|
||||
if(_mapmgr)
|
||||
{
|
||||
_mapmgr->Flush();
|
||||
}
|
||||
// TODO: clear WorldStates (-> SMSG_INIT_WORLD_STATES ?) and everything else thats required
|
||||
}
|
||||
|
||||
|
||||
void World::Update(void)
|
||||
{
|
||||
if(_mapId == uint32(-1)) // to prevent unexpected behaviour
|
||||
return;
|
||||
|
||||
if(_mapmgr)
|
||||
{
|
||||
_mapmgr->Update(_x,_y,_mapId);
|
||||
}
|
||||
|
||||
// some debug code for testing...
|
||||
/*if(_mapmgr && _x != _lastx || _y != _lasty)
|
||||
{
|
||||
logdetail("WORLD: relocation, to x=%f y=%f, calculated z=%f",_x,_y,this->GetPosZ(_x,_y));
|
||||
_lastx = _x;
|
||||
_lasty = _y;
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
void World::UpdatePos(float x, float y, uint32 m)
|
||||
{
|
||||
_mapId = m;
|
||||
UpdatePos(x,y);
|
||||
}
|
||||
|
||||
void World::UpdatePos(float x, float y)
|
||||
{
|
||||
_x = x;
|
||||
_y = y;
|
||||
Update();
|
||||
}
|
||||
|
||||
float World::GetPosZ(float x, float y)
|
||||
{
|
||||
if(_mapmgr)
|
||||
return _mapmgr->GetZ(x,y);
|
||||
|
||||
logdebug("WORLD: GetPosZ() called, but no MapMgr exists (do you really use maps?)");
|
||||
return 0;
|
||||
}
|
||||
#include "common.h"
|
||||
#include "MapMgr.h"
|
||||
#include "WorldSession.h"
|
||||
#include "World.h"
|
||||
|
||||
World::World(WorldSession *s)
|
||||
{
|
||||
_session = s;
|
||||
_mapId = -1;
|
||||
_mapmgr = NULL;
|
||||
if(_session->GetInstance()->GetConf()->useMaps)
|
||||
_mapmgr = new MapMgr();
|
||||
}
|
||||
|
||||
World::~World()
|
||||
{
|
||||
Clear();
|
||||
if(_mapmgr)
|
||||
delete _mapmgr;
|
||||
}
|
||||
|
||||
// called on SMSG_NEW_WORLD
|
||||
void World::Clear(void)
|
||||
{
|
||||
if(_mapmgr)
|
||||
{
|
||||
_mapmgr->Flush();
|
||||
}
|
||||
// TODO: clear WorldStates (-> SMSG_INIT_WORLD_STATES ?) and everything else thats required
|
||||
}
|
||||
|
||||
|
||||
void World::Update(void)
|
||||
{
|
||||
if(_mapId == uint32(-1)) // to prevent unexpected behaviour
|
||||
return;
|
||||
|
||||
if(_mapmgr)
|
||||
{
|
||||
_mapmgr->Update(_x,_y,_mapId);
|
||||
}
|
||||
|
||||
// some debug code for testing...
|
||||
/*if(_mapmgr && _x != _lastx || _y != _lasty)
|
||||
{
|
||||
logdetail("WORLD: relocation, to x=%f y=%f, calculated z=%f",_x,_y,this->GetPosZ(_x,_y));
|
||||
_lastx = _x;
|
||||
_lasty = _y;
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
void World::UpdatePos(float x, float y, uint32 m)
|
||||
{
|
||||
_mapId = m;
|
||||
UpdatePos(x,y);
|
||||
}
|
||||
|
||||
void World::UpdatePos(float x, float y)
|
||||
{
|
||||
_x = x;
|
||||
_y = y;
|
||||
Update();
|
||||
}
|
||||
|
||||
float World::GetPosZ(float x, float y)
|
||||
{
|
||||
if(_mapmgr)
|
||||
return _mapmgr->GetZ(x,y);
|
||||
|
||||
logdebug("WORLD: GetPosZ() called, but no MapMgr exists (do you really use maps?)");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -1,52 +1,52 @@
|
||||
#ifndef WORLD_H
|
||||
#define WORLD_H
|
||||
|
||||
class WorldSession;
|
||||
class MapMgr;
|
||||
|
||||
struct WorldPosition
|
||||
{
|
||||
WorldPosition() : x(0.0f), y(0.0f), z(0.0f), o(0.0f) {};
|
||||
WorldPosition(float px, float py) : x(px), y(py), z(0.0f), o(0.0f) {};
|
||||
WorldPosition(float px, float py, float pz) : x(px), y(py), z(pz), o(0.0f) {};
|
||||
WorldPosition(float px, float py, float pz, float po) : x(px), y(py), z(pz), o(po) {};
|
||||
float x,y,z,o;
|
||||
};
|
||||
|
||||
inline ByteBuffer& operator<<(ByteBuffer& bb, WorldPosition& p)
|
||||
{
|
||||
bb << p.x << p.y << p.z << p.o;
|
||||
return bb;
|
||||
}
|
||||
inline ByteBuffer& operator>>(ByteBuffer& bb, WorldPosition& p)
|
||||
{
|
||||
bb >> p.x >> p.y >> p.z >> p.o;
|
||||
return bb;
|
||||
}
|
||||
|
||||
// used as interface for movement, map data,
|
||||
class World
|
||||
{
|
||||
public:
|
||||
World(WorldSession*);
|
||||
~World();
|
||||
|
||||
inline uint32 GetMapId(void) { return _mapId; }
|
||||
inline WorldSession *GetSession(void) { return _session; }
|
||||
void Clear(void);
|
||||
void Update(void);
|
||||
void UpdatePos(float,float,uint32);
|
||||
void UpdatePos(float,float);
|
||||
float GetPosZ(float x, float y);
|
||||
inline MapMgr *GetMapMgr(void) { return _mapmgr; }
|
||||
|
||||
private:
|
||||
WorldSession *_session;
|
||||
MapMgr *_mapmgr;
|
||||
uint32 _mapId;
|
||||
float _x,_y;
|
||||
float _lastx,_lasty;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef WORLD_H
|
||||
#define WORLD_H
|
||||
|
||||
class WorldSession;
|
||||
class MapMgr;
|
||||
|
||||
struct WorldPosition
|
||||
{
|
||||
WorldPosition() : x(0.0f), y(0.0f), z(0.0f), o(0.0f) {};
|
||||
WorldPosition(float px, float py) : x(px), y(py), z(0.0f), o(0.0f) {};
|
||||
WorldPosition(float px, float py, float pz) : x(px), y(py), z(pz), o(0.0f) {};
|
||||
WorldPosition(float px, float py, float pz, float po) : x(px), y(py), z(pz), o(po) {};
|
||||
float x,y,z,o;
|
||||
};
|
||||
|
||||
inline ByteBuffer& operator<<(ByteBuffer& bb, WorldPosition& p)
|
||||
{
|
||||
bb << p.x << p.y << p.z << p.o;
|
||||
return bb;
|
||||
}
|
||||
inline ByteBuffer& operator>>(ByteBuffer& bb, WorldPosition& p)
|
||||
{
|
||||
bb >> p.x >> p.y >> p.z >> p.o;
|
||||
return bb;
|
||||
}
|
||||
|
||||
// used as interface for movement, map data,
|
||||
class World
|
||||
{
|
||||
public:
|
||||
World(WorldSession*);
|
||||
~World();
|
||||
|
||||
inline uint32 GetMapId(void) { return _mapId; }
|
||||
inline WorldSession *GetSession(void) { return _session; }
|
||||
void Clear(void);
|
||||
void Update(void);
|
||||
void UpdatePos(float,float,uint32);
|
||||
void UpdatePos(float,float);
|
||||
float GetPosZ(float x, float y);
|
||||
inline MapMgr *GetMapMgr(void) { return _mapmgr; }
|
||||
|
||||
private:
|
||||
WorldSession *_session;
|
||||
MapMgr *_mapmgr;
|
||||
uint32 _mapId;
|
||||
float _x,_y;
|
||||
float _lastx,_lasty;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,19 +1,19 @@
|
||||
|
||||
#include "WorldPacket.h"
|
||||
|
||||
|
||||
uint64 WorldPacket::GetPackedGuid(void)
|
||||
{
|
||||
uint8 mask;
|
||||
*this >> mask;
|
||||
uint64 guid=0;
|
||||
for(uint8 i=0;i<8;i++)
|
||||
{
|
||||
if(mask & (1<<i) )
|
||||
{
|
||||
*this >> ((uint8*)&guid)[i];
|
||||
}
|
||||
}
|
||||
return guid;
|
||||
}
|
||||
|
||||
|
||||
#include "WorldPacket.h"
|
||||
|
||||
|
||||
uint64 WorldPacket::GetPackedGuid(void)
|
||||
{
|
||||
uint8 mask;
|
||||
*this >> mask;
|
||||
uint64 guid=0;
|
||||
for(uint8 i=0;i<8;i++)
|
||||
{
|
||||
if(mask & (1<<i) )
|
||||
{
|
||||
*this >> ((uint8*)&guid)[i];
|
||||
}
|
||||
}
|
||||
return guid;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -1,162 +1,162 @@
|
||||
#ifndef _WORLDSESSION_H
|
||||
#define _WORLDSESSION_H
|
||||
|
||||
#include <deque>
|
||||
#include <bitset>
|
||||
|
||||
#include "common.h"
|
||||
#include "PseuWoW.h"
|
||||
#include "Network/SocketHandler.h"
|
||||
#include "Player.h"
|
||||
#include "Auth/AuthCrypt.h"
|
||||
#include "SharedDefines.h"
|
||||
#include "ObjMgr.h"
|
||||
#include "CacheHandler.h"
|
||||
#include "Opcodes.h"
|
||||
|
||||
class WorldSocket;
|
||||
class WorldPacket;
|
||||
class Channel;
|
||||
class RealmSession;
|
||||
struct OpcodeHandler;
|
||||
class World;
|
||||
|
||||
struct WhoListEntry
|
||||
{
|
||||
std::string name;
|
||||
std::string gname;
|
||||
uint32 level;
|
||||
uint32 classId;
|
||||
uint32 raceId;
|
||||
uint32 zoneId;
|
||||
};
|
||||
|
||||
struct DelayedWorldPacket
|
||||
{
|
||||
DelayedWorldPacket() { pkt = NULL; when = clock(); }
|
||||
DelayedWorldPacket(WorldPacket *p, uint32 ms) { pkt = p; when = ms + clock(); }
|
||||
WorldPacket *pkt;
|
||||
clock_t when;
|
||||
};
|
||||
|
||||
typedef std::vector<WhoListEntry> WhoList;
|
||||
typedef std::deque<DelayedWorldPacket> DelayedPacketQueue;
|
||||
|
||||
class WorldSession
|
||||
{
|
||||
friend class Channel;
|
||||
|
||||
public:
|
||||
WorldSession(PseuInstance *i);
|
||||
~WorldSession();
|
||||
void Init(void);
|
||||
|
||||
inline PseuInstance *GetInstance(void) { return _instance; }
|
||||
inline SCPDatabaseMgr& GetDBMgr(void) { return GetInstance()->dbmgr; }
|
||||
|
||||
void AddToPktQueue(WorldPacket *pkt);
|
||||
void Update(void);
|
||||
void Start(void);
|
||||
inline bool MustDie(void) { return _mustdie; }
|
||||
void SetMustDie(void);
|
||||
void SendWorldPacket(WorldPacket&);
|
||||
inline bool InWorld(void) { return _logged; }
|
||||
inline uint32 GetLagMS(void) { return _lag_ms; }
|
||||
|
||||
void SetTarget(uint64 guid);
|
||||
inline uint64 GetTarget(void) { return GetMyChar() ? GetMyChar()->GetTarget() : 0; }
|
||||
inline uint64 GetGuid(void) { return _myGUID; }
|
||||
inline Channel *GetChannels(void) { return _channels; }
|
||||
inline MyCharacter *GetMyChar(void) { ASSERT(_myGUID > 0); return (MyCharacter*)objmgr.GetObj(_myGUID); }
|
||||
inline World *GetWorld(void) { return _world; }
|
||||
|
||||
std::string GetOrRequestPlayerName(uint64);
|
||||
|
||||
|
||||
// CMSGConstructor
|
||||
void SendChatMessage(uint32 type, uint32 lang, std::string msg, std::string to="");
|
||||
void SendQueryPlayerName(uint64 guid);
|
||||
void SendPing(uint32);
|
||||
void SendEmote(uint32);
|
||||
void SendQueryItem(uint32 id, uint64 guid = 0);
|
||||
void SendSetSelection(uint64);
|
||||
void SendCastSpell(uint32 spellid, bool nocheck=false);
|
||||
void SendWhoListRequest(uint32 minlvl=0, uint32 maxlvl=100, uint32 racemask=-1, uint32 classmask=-1, std::string name="", std::string guildname="", std::vector<uint32> *zonelist=NULL, std::vector<std::string> *strlist=NULL);
|
||||
void SendQueryCreature(uint32 entry, uint64 guid = 0);
|
||||
|
||||
void HandleWorldPacket(WorldPacket*);
|
||||
|
||||
inline void DisableOpcode(uint16 opcode) { _disabledOpcodes[opcode] = true; }
|
||||
inline void EnableOpcode(uint16 opcode) { _disabledOpcodes[opcode] = false; }
|
||||
inline bool IsOpcodeDisabled(uint16 opcode) { return _disabledOpcodes[opcode]; }
|
||||
|
||||
PlayerNameCache plrNameCache;
|
||||
ObjMgr objmgr;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
OpcodeHandler *_GetOpcodeHandlerTable(void) const;
|
||||
|
||||
// Helpers
|
||||
void _OnEnterWorld(void); // = login
|
||||
void _OnLeaveWorld(void); // = logout
|
||||
void _DoTimedActions(void);
|
||||
void _DelayWorldPacket(WorldPacket&, uint32);
|
||||
void _HandleDelayedPackets(void);
|
||||
|
||||
// Opcode Handlers
|
||||
void _HandleAuthChallengeOpcode(WorldPacket& recvPacket);
|
||||
void _HandleAuthResponseOpcode(WorldPacket& recvPacket);
|
||||
void _HandleCharEnumOpcode(WorldPacket& recvPacket);
|
||||
void _HandleSetProficiencyOpcode(WorldPacket& recvPacket);
|
||||
void _HandleAccountDataMD5Opcode(WorldPacket& recvPacket);
|
||||
void _HandleMessageChatOpcode(WorldPacket& recvPacket);
|
||||
void _HandleNameQueryResponseOpcode(WorldPacket& recvPacket);
|
||||
void _HandleMovementOpcode(WorldPacket& recvPacket);
|
||||
void _HandlePongOpcode(WorldPacket& recvPacket);
|
||||
void _HandleTradeStatusOpcode(WorldPacket& recvPacket);
|
||||
void _HandleGroupInviteOpcode(WorldPacket& recvPacket);
|
||||
void _HandleTelePortAckOpcode(WorldPacket& recvPacket);
|
||||
void _HandleChannelNotifyOpcode(WorldPacket& recvPacket);
|
||||
void _HandleCastResultOpcode(WorldPacket& recvPacket);
|
||||
void _HandleCastSuccessOpcode(WorldPacket& recvPacket);
|
||||
void _HandleCompressedUpdateObjectOpcode(WorldPacket& recvPacket);
|
||||
void _HandleUpdateObjectOpcode(WorldPacket& recvPacket);
|
||||
void _HandleItemQuerySingleResponseOpcode(WorldPacket& recvPacket);
|
||||
void _HandleDestroyObjectOpcode(WorldPacket& recvPacket);
|
||||
void _HandleInitialSpellsOpcode(WorldPacket& recvPacket);
|
||||
void _HandleLearnedSpellOpcode(WorldPacket& recvPacket);
|
||||
void _HandleRemovedSpellOpcode(WorldPacket& recvPacket);
|
||||
void _HandleChannelListOpcode(WorldPacket& recvPacket);
|
||||
void _HandleEmoteOpcode(WorldPacket& recvPacket);
|
||||
void _HandleTextEmoteOpcode(WorldPacket& recvPacket);
|
||||
void _HandleNewWorldOpcode(WorldPacket& recvPacket);
|
||||
void _HandleLoginVerifyWorldOpcode(WorldPacket& recvPacket);
|
||||
void _HandleMotdOpcode(WorldPacket& recvPacket);
|
||||
void _HandleNotificationOpcode(WorldPacket& recvPacket);
|
||||
void _HandleWhoOpcode(WorldPacket& recvPacket);
|
||||
void _HandleCreatureQueryResponseOpcode(WorldPacket& recvPacket);
|
||||
|
||||
// helper functions to keep SMSG_(COMPRESSED_)UPDATE_OBJECT easy to handle
|
||||
void _MovementUpdate(uint8 objtypeid, uint64 guid, WorldPacket& recvPacket); // Helper for _HandleUpdateObjectOpcode
|
||||
void _ValuesUpdate(uint64 uguid, WorldPacket& recvPacket); // ...
|
||||
void _QueryObjectInfo(uint64 guid);
|
||||
|
||||
void _LoadCache(void);
|
||||
|
||||
PseuInstance *_instance;
|
||||
WorldSocket *_socket;
|
||||
ZThread::LockedQueue<WorldPacket*,ZThread::FastMutex> pktQueue;
|
||||
DelayedPacketQueue delayedPktQueue;
|
||||
bool _logged,_mustdie; // world status
|
||||
SocketHandler _sh; // handles the WorldSocket
|
||||
Channel *_channels;
|
||||
uint64 _myGUID;
|
||||
World *_world;
|
||||
WhoList _whoList;
|
||||
uint32 _lag_ms;
|
||||
std::bitset<MAX_OPCODE_ID> _disabledOpcodes;
|
||||
};
|
||||
|
||||
#endif
|
||||
#ifndef _WORLDSESSION_H
|
||||
#define _WORLDSESSION_H
|
||||
|
||||
#include <deque>
|
||||
#include <bitset>
|
||||
|
||||
#include "common.h"
|
||||
#include "PseuWoW.h"
|
||||
#include "Network/SocketHandler.h"
|
||||
#include "Player.h"
|
||||
#include "Auth/AuthCrypt.h"
|
||||
#include "SharedDefines.h"
|
||||
#include "ObjMgr.h"
|
||||
#include "CacheHandler.h"
|
||||
#include "Opcodes.h"
|
||||
|
||||
class WorldSocket;
|
||||
class WorldPacket;
|
||||
class Channel;
|
||||
class RealmSession;
|
||||
struct OpcodeHandler;
|
||||
class World;
|
||||
|
||||
struct WhoListEntry
|
||||
{
|
||||
std::string name;
|
||||
std::string gname;
|
||||
uint32 level;
|
||||
uint32 classId;
|
||||
uint32 raceId;
|
||||
uint32 zoneId;
|
||||
};
|
||||
|
||||
struct DelayedWorldPacket
|
||||
{
|
||||
DelayedWorldPacket() { pkt = NULL; when = clock(); }
|
||||
DelayedWorldPacket(WorldPacket *p, uint32 ms) { pkt = p; when = ms + clock(); }
|
||||
WorldPacket *pkt;
|
||||
clock_t when;
|
||||
};
|
||||
|
||||
typedef std::vector<WhoListEntry> WhoList;
|
||||
typedef std::deque<DelayedWorldPacket> DelayedPacketQueue;
|
||||
|
||||
class WorldSession
|
||||
{
|
||||
friend class Channel;
|
||||
|
||||
public:
|
||||
WorldSession(PseuInstance *i);
|
||||
~WorldSession();
|
||||
void Init(void);
|
||||
|
||||
inline PseuInstance *GetInstance(void) { return _instance; }
|
||||
inline SCPDatabaseMgr& GetDBMgr(void) { return GetInstance()->dbmgr; }
|
||||
|
||||
void AddToPktQueue(WorldPacket *pkt);
|
||||
void Update(void);
|
||||
void Start(void);
|
||||
inline bool MustDie(void) { return _mustdie; }
|
||||
void SetMustDie(void);
|
||||
void SendWorldPacket(WorldPacket&);
|
||||
inline bool InWorld(void) { return _logged; }
|
||||
inline uint32 GetLagMS(void) { return _lag_ms; }
|
||||
|
||||
void SetTarget(uint64 guid);
|
||||
inline uint64 GetTarget(void) { return GetMyChar() ? GetMyChar()->GetTarget() : 0; }
|
||||
inline uint64 GetGuid(void) { return _myGUID; }
|
||||
inline Channel *GetChannels(void) { return _channels; }
|
||||
inline MyCharacter *GetMyChar(void) { ASSERT(_myGUID > 0); return (MyCharacter*)objmgr.GetObj(_myGUID); }
|
||||
inline World *GetWorld(void) { return _world; }
|
||||
|
||||
std::string GetOrRequestPlayerName(uint64);
|
||||
|
||||
|
||||
// CMSGConstructor
|
||||
void SendChatMessage(uint32 type, uint32 lang, std::string msg, std::string to="");
|
||||
void SendQueryPlayerName(uint64 guid);
|
||||
void SendPing(uint32);
|
||||
void SendEmote(uint32);
|
||||
void SendQueryItem(uint32 id, uint64 guid = 0);
|
||||
void SendSetSelection(uint64);
|
||||
void SendCastSpell(uint32 spellid, bool nocheck=false);
|
||||
void SendWhoListRequest(uint32 minlvl=0, uint32 maxlvl=100, uint32 racemask=-1, uint32 classmask=-1, std::string name="", std::string guildname="", std::vector<uint32> *zonelist=NULL, std::vector<std::string> *strlist=NULL);
|
||||
void SendQueryCreature(uint32 entry, uint64 guid = 0);
|
||||
|
||||
void HandleWorldPacket(WorldPacket*);
|
||||
|
||||
inline void DisableOpcode(uint16 opcode) { _disabledOpcodes[opcode] = true; }
|
||||
inline void EnableOpcode(uint16 opcode) { _disabledOpcodes[opcode] = false; }
|
||||
inline bool IsOpcodeDisabled(uint16 opcode) { return _disabledOpcodes[opcode]; }
|
||||
|
||||
PlayerNameCache plrNameCache;
|
||||
ObjMgr objmgr;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
OpcodeHandler *_GetOpcodeHandlerTable(void) const;
|
||||
|
||||
// Helpers
|
||||
void _OnEnterWorld(void); // = login
|
||||
void _OnLeaveWorld(void); // = logout
|
||||
void _DoTimedActions(void);
|
||||
void _DelayWorldPacket(WorldPacket&, uint32);
|
||||
void _HandleDelayedPackets(void);
|
||||
|
||||
// Opcode Handlers
|
||||
void _HandleAuthChallengeOpcode(WorldPacket& recvPacket);
|
||||
void _HandleAuthResponseOpcode(WorldPacket& recvPacket);
|
||||
void _HandleCharEnumOpcode(WorldPacket& recvPacket);
|
||||
void _HandleSetProficiencyOpcode(WorldPacket& recvPacket);
|
||||
void _HandleAccountDataMD5Opcode(WorldPacket& recvPacket);
|
||||
void _HandleMessageChatOpcode(WorldPacket& recvPacket);
|
||||
void _HandleNameQueryResponseOpcode(WorldPacket& recvPacket);
|
||||
void _HandleMovementOpcode(WorldPacket& recvPacket);
|
||||
void _HandlePongOpcode(WorldPacket& recvPacket);
|
||||
void _HandleTradeStatusOpcode(WorldPacket& recvPacket);
|
||||
void _HandleGroupInviteOpcode(WorldPacket& recvPacket);
|
||||
void _HandleTelePortAckOpcode(WorldPacket& recvPacket);
|
||||
void _HandleChannelNotifyOpcode(WorldPacket& recvPacket);
|
||||
void _HandleCastResultOpcode(WorldPacket& recvPacket);
|
||||
void _HandleCastSuccessOpcode(WorldPacket& recvPacket);
|
||||
void _HandleCompressedUpdateObjectOpcode(WorldPacket& recvPacket);
|
||||
void _HandleUpdateObjectOpcode(WorldPacket& recvPacket);
|
||||
void _HandleItemQuerySingleResponseOpcode(WorldPacket& recvPacket);
|
||||
void _HandleDestroyObjectOpcode(WorldPacket& recvPacket);
|
||||
void _HandleInitialSpellsOpcode(WorldPacket& recvPacket);
|
||||
void _HandleLearnedSpellOpcode(WorldPacket& recvPacket);
|
||||
void _HandleRemovedSpellOpcode(WorldPacket& recvPacket);
|
||||
void _HandleChannelListOpcode(WorldPacket& recvPacket);
|
||||
void _HandleEmoteOpcode(WorldPacket& recvPacket);
|
||||
void _HandleTextEmoteOpcode(WorldPacket& recvPacket);
|
||||
void _HandleNewWorldOpcode(WorldPacket& recvPacket);
|
||||
void _HandleLoginVerifyWorldOpcode(WorldPacket& recvPacket);
|
||||
void _HandleMotdOpcode(WorldPacket& recvPacket);
|
||||
void _HandleNotificationOpcode(WorldPacket& recvPacket);
|
||||
void _HandleWhoOpcode(WorldPacket& recvPacket);
|
||||
void _HandleCreatureQueryResponseOpcode(WorldPacket& recvPacket);
|
||||
|
||||
// helper functions to keep SMSG_(COMPRESSED_)UPDATE_OBJECT easy to handle
|
||||
void _MovementUpdate(uint8 objtypeid, uint64 guid, WorldPacket& recvPacket); // Helper for _HandleUpdateObjectOpcode
|
||||
void _ValuesUpdate(uint64 uguid, WorldPacket& recvPacket); // ...
|
||||
void _QueryObjectInfo(uint64 guid);
|
||||
|
||||
void _LoadCache(void);
|
||||
|
||||
PseuInstance *_instance;
|
||||
WorldSocket *_socket;
|
||||
ZThread::LockedQueue<WorldPacket*,ZThread::FastMutex> pktQueue;
|
||||
DelayedPacketQueue delayedPktQueue;
|
||||
bool _logged,_mustdie; // world status
|
||||
SocketHandler _sh; // handles the WorldSocket
|
||||
Channel *_channels;
|
||||
uint64 _myGUID;
|
||||
World *_world;
|
||||
WhoList _whoList;
|
||||
uint32 _lag_ms;
|
||||
std::bitset<MAX_OPCODE_ID> _disabledOpcodes;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,130 +1,130 @@
|
||||
|
||||
#include "WorldPacket.h"
|
||||
#include "WorldSession.h"
|
||||
#include "WorldSocket.h"
|
||||
#include "Opcodes.h"
|
||||
|
||||
WorldSocket::WorldSocket(SocketHandler &h, WorldSession *s) : TcpSocket(h)
|
||||
{
|
||||
_session = s;
|
||||
_gothdr = false;
|
||||
_ok=false;
|
||||
}
|
||||
|
||||
bool WorldSocket::IsOk(void)
|
||||
{
|
||||
return _ok;
|
||||
}
|
||||
|
||||
void WorldSocket::OnConnect()
|
||||
{
|
||||
log("Connected to world server.");
|
||||
_ok = true;
|
||||
}
|
||||
|
||||
void WorldSocket::OnConnectFailed()
|
||||
{
|
||||
logerror("Connecting to World Server failed!");
|
||||
_ok = false;
|
||||
}
|
||||
|
||||
void WorldSocket::OnDelete()
|
||||
{
|
||||
log("Connection to world server has been closed.");
|
||||
_ok = false;
|
||||
_session->SetMustDie(); // recreate the session if needed
|
||||
}
|
||||
|
||||
void WorldSocket::OnException()
|
||||
{
|
||||
if(_ok)
|
||||
{
|
||||
logerror("WorldSocket::OnException()");
|
||||
_ok = false;
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSocket::OnRead()
|
||||
{
|
||||
TcpSocket::OnRead();
|
||||
if(!ibuf.GetLength())
|
||||
{
|
||||
this->CloseAndDelete();
|
||||
return;
|
||||
}
|
||||
while(ibuf.GetLength() > 0) // when all packets from the current ibuf are transformed into WorldPackets the remaining len will be zero
|
||||
{
|
||||
|
||||
if(_gothdr) // already got header, this packet has to be the data part
|
||||
{
|
||||
ASSERT(_remaining > 0); // case pktsize==0 is handled below
|
||||
if(ibuf.GetLength() < _remaining)
|
||||
{
|
||||
DEBUG(logdebug("Delaying WorldPacket generation, bufsize is %u but should be >= %u",ibuf.GetLength(),_remaining));
|
||||
break;
|
||||
}
|
||||
_gothdr=false;
|
||||
WorldPacket *wp = new WorldPacket(_remaining);
|
||||
wp->resize(_remaining);
|
||||
ibuf.Read((char*)wp->contents(),_remaining);
|
||||
wp->SetOpcode(_opcode);
|
||||
GetSession()->AddToPktQueue(wp);
|
||||
}
|
||||
else // no pending header stored, so this packet must be a header
|
||||
{
|
||||
if(ibuf.GetLength() < sizeof(ServerPktHeader))
|
||||
{
|
||||
DEBUG(logdebug("Delaying header reading, bufsize is %u but should be >= %u",ibuf.GetLength(),sizeof(ServerPktHeader)));
|
||||
break;
|
||||
}
|
||||
ServerPktHeader hdr;
|
||||
ibuf.Read((char*)&hdr,sizeof(ServerPktHeader));
|
||||
_crypt.DecryptRecv((uint8*)&hdr,sizeof(ServerPktHeader));
|
||||
_remaining = ntohs(hdr.size)-2;
|
||||
_opcode = hdr.cmd;
|
||||
if(_opcode > MAX_OPCODE_ID) // no opcode has yet a number over 1000
|
||||
{
|
||||
logcritical("CRYPT ERROR: opcode=%u, remain=%u",_opcode,_remaining); // this should never be the case!
|
||||
GetSession()->GetInstance()->SetError(); // no way to recover the crypt, must exit
|
||||
// if the crypt gets messy its hardly possible to recover it, especially if we dont know
|
||||
// the lentgh of the following data part
|
||||
// TODO: invent some way how to recover the crypt (reconnect?)
|
||||
return;
|
||||
}
|
||||
|
||||
// the header is fine, now check if there are more data
|
||||
if(_remaining == 0) // this is a packet with no data (like CMSG_NULL_ACTION)
|
||||
{
|
||||
WorldPacket *wp = new WorldPacket;
|
||||
wp->SetOpcode(_opcode);
|
||||
GetSession()->AddToPktQueue(wp);
|
||||
}
|
||||
else // there is a data part to fetch
|
||||
{
|
||||
_gothdr=true; // only got the header, next packet will contain the data
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSocket::SendWorldPacket(WorldPacket &pkt)
|
||||
{
|
||||
if(!_ok)
|
||||
return;
|
||||
ClientPktHeader hdr;
|
||||
memset(&hdr,0,sizeof(ClientPktHeader));
|
||||
hdr.size = ntohs(pkt.size()+4);
|
||||
hdr.cmd = pkt.GetOpcode();
|
||||
_crypt.EncryptSend((uint8*)&hdr, 6);
|
||||
ByteBuffer final(pkt.size()+6);
|
||||
final.append((uint8*)&hdr,sizeof(ClientPktHeader));
|
||||
if(pkt.size())
|
||||
final.append(pkt.contents(),pkt.size());
|
||||
SendBuf((char*)final.contents(),final.size());
|
||||
}
|
||||
|
||||
void WorldSocket::InitCrypt(uint8 *key,uint32 len)
|
||||
{
|
||||
_crypt.SetKey(key,len);
|
||||
_crypt.Init();
|
||||
}
|
||||
|
||||
#include "WorldPacket.h"
|
||||
#include "WorldSession.h"
|
||||
#include "WorldSocket.h"
|
||||
#include "Opcodes.h"
|
||||
|
||||
WorldSocket::WorldSocket(SocketHandler &h, WorldSession *s) : TcpSocket(h)
|
||||
{
|
||||
_session = s;
|
||||
_gothdr = false;
|
||||
_ok=false;
|
||||
}
|
||||
|
||||
bool WorldSocket::IsOk(void)
|
||||
{
|
||||
return _ok;
|
||||
}
|
||||
|
||||
void WorldSocket::OnConnect()
|
||||
{
|
||||
log("Connected to world server.");
|
||||
_ok = true;
|
||||
}
|
||||
|
||||
void WorldSocket::OnConnectFailed()
|
||||
{
|
||||
logerror("Connecting to World Server failed!");
|
||||
_ok = false;
|
||||
}
|
||||
|
||||
void WorldSocket::OnDelete()
|
||||
{
|
||||
log("Connection to world server has been closed.");
|
||||
_ok = false;
|
||||
_session->SetMustDie(); // recreate the session if needed
|
||||
}
|
||||
|
||||
void WorldSocket::OnException()
|
||||
{
|
||||
if(_ok)
|
||||
{
|
||||
logerror("WorldSocket::OnException()");
|
||||
_ok = false;
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSocket::OnRead()
|
||||
{
|
||||
TcpSocket::OnRead();
|
||||
if(!ibuf.GetLength())
|
||||
{
|
||||
this->CloseAndDelete();
|
||||
return;
|
||||
}
|
||||
while(ibuf.GetLength() > 0) // when all packets from the current ibuf are transformed into WorldPackets the remaining len will be zero
|
||||
{
|
||||
|
||||
if(_gothdr) // already got header, this packet has to be the data part
|
||||
{
|
||||
ASSERT(_remaining > 0); // case pktsize==0 is handled below
|
||||
if(ibuf.GetLength() < _remaining)
|
||||
{
|
||||
DEBUG(logdebug("Delaying WorldPacket generation, bufsize is %u but should be >= %u",ibuf.GetLength(),_remaining));
|
||||
break;
|
||||
}
|
||||
_gothdr=false;
|
||||
WorldPacket *wp = new WorldPacket(_remaining);
|
||||
wp->resize(_remaining);
|
||||
ibuf.Read((char*)wp->contents(),_remaining);
|
||||
wp->SetOpcode(_opcode);
|
||||
GetSession()->AddToPktQueue(wp);
|
||||
}
|
||||
else // no pending header stored, so this packet must be a header
|
||||
{
|
||||
if(ibuf.GetLength() < sizeof(ServerPktHeader))
|
||||
{
|
||||
DEBUG(logdebug("Delaying header reading, bufsize is %u but should be >= %u",ibuf.GetLength(),sizeof(ServerPktHeader)));
|
||||
break;
|
||||
}
|
||||
ServerPktHeader hdr;
|
||||
ibuf.Read((char*)&hdr,sizeof(ServerPktHeader));
|
||||
_crypt.DecryptRecv((uint8*)&hdr,sizeof(ServerPktHeader));
|
||||
_remaining = ntohs(hdr.size)-2;
|
||||
_opcode = hdr.cmd;
|
||||
if(_opcode > MAX_OPCODE_ID) // no opcode has yet a number over 1000
|
||||
{
|
||||
logcritical("CRYPT ERROR: opcode=%u, remain=%u",_opcode,_remaining); // this should never be the case!
|
||||
GetSession()->GetInstance()->SetError(); // no way to recover the crypt, must exit
|
||||
// if the crypt gets messy its hardly possible to recover it, especially if we dont know
|
||||
// the lentgh of the following data part
|
||||
// TODO: invent some way how to recover the crypt (reconnect?)
|
||||
return;
|
||||
}
|
||||
|
||||
// the header is fine, now check if there are more data
|
||||
if(_remaining == 0) // this is a packet with no data (like CMSG_NULL_ACTION)
|
||||
{
|
||||
WorldPacket *wp = new WorldPacket;
|
||||
wp->SetOpcode(_opcode);
|
||||
GetSession()->AddToPktQueue(wp);
|
||||
}
|
||||
else // there is a data part to fetch
|
||||
{
|
||||
_gothdr=true; // only got the header, next packet will contain the data
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WorldSocket::SendWorldPacket(WorldPacket &pkt)
|
||||
{
|
||||
if(!_ok)
|
||||
return;
|
||||
ClientPktHeader hdr;
|
||||
memset(&hdr,0,sizeof(ClientPktHeader));
|
||||
hdr.size = ntohs(pkt.size()+4);
|
||||
hdr.cmd = pkt.GetOpcode();
|
||||
_crypt.EncryptSend((uint8*)&hdr, 6);
|
||||
ByteBuffer final(pkt.size()+6);
|
||||
final.append((uint8*)&hdr,sizeof(ClientPktHeader));
|
||||
if(pkt.size())
|
||||
final.append(pkt.contents(),pkt.size());
|
||||
SendBuf((char*)final.contents(),final.size());
|
||||
}
|
||||
|
||||
void WorldSocket::InitCrypt(uint8 *key,uint32 len)
|
||||
{
|
||||
_crypt.SetKey(key,len);
|
||||
_crypt.Init();
|
||||
}
|
||||
|
||||
@ -1,61 +1,61 @@
|
||||
//******************************************************************************
|
||||
// Here are all codes used in Logon Server.
|
||||
//==============================================================================
|
||||
#ifndef _LOGONCODES_H
|
||||
#define _LOGONCODES_H
|
||||
//==============================================================================
|
||||
//#include "OurDefs.h"
|
||||
//==============================================================================
|
||||
// wow's codes:
|
||||
enum EClientCommand
|
||||
// dumped from wow.exe 1.8.0
|
||||
// 0x007F86A8: table of
|
||||
// <int32 code, int32 pstr, int32 pproc, int32 0>
|
||||
// switch: 005999A7 cmp byte ptr [ecx],dl
|
||||
{
|
||||
CMD_AUTH_LOGON_CHALLENGE = 0x00, // client
|
||||
CMD_AUTH_LOGON_PROOF = 0x01, // client
|
||||
CMD_AUTH_RECONNECT_CHALLENGE = 0x02, // client
|
||||
CMD_AUTH_RECONNECT_PROOF = 0x03, // client
|
||||
CMD_REALM_LIST = 0x10, // client
|
||||
CMD_XFER_INITIATE = 0x30, // client? from server
|
||||
CMD_XFER_DATA = 0x31, // client? from server
|
||||
CMD_XFER_ACCEPT = 0x32, // not official name, from client
|
||||
CMD_XFER_RESUME = 0x33, // not official name, from client
|
||||
CMD_XFER_CANCEL = 0x34, // not official name, from client
|
||||
|
||||
// unknown:
|
||||
CMD_GRUNT_AUTH_CHALLENGE = 0x00, // server
|
||||
CMD_GRUNT_AUTH_VERIFY = 0x02, // server
|
||||
CMD_GRUNT_CONN_PING = 0x10, // server
|
||||
CMD_GRUNT_CONN_PONG = 0x11, // server
|
||||
CMD_GRUNT_HELLO = 0x20, // server
|
||||
CMD_GRUNT_PROVESESSION = 0x21, // server
|
||||
CMD_GRUNT_KICK = 0x24, // server
|
||||
};
|
||||
//------------------------------------------------------------------------------
|
||||
enum ELoginErrorCode
|
||||
// dumped from wow.exe 1.8.0
|
||||
// 00591E9D mov eax,dword ptr [ebp+8]
|
||||
// eax - code, name in stack after exiting from current funk
|
||||
{
|
||||
// LOGIN_STATE_FAILED:
|
||||
|
||||
LOGIN_FAILED = 1, // 2, B, C, D // "Unable to connect"
|
||||
LOGIN_BANNED = 3, // "This World of Warcraft account has been closed and is no longer in service -- Please check the registered email address of this account for further information."; -- This is the error message players get when trying to log in with a banned account.
|
||||
LOGIN_UNKNOWN_ACCOUNT = 4, // 5 // "The information you have entered is not valid. Please check the spelling of the account name and password. If you need help in retrieving a lost or stolen password and account, see www.worldofwarcraft.com for more information.";
|
||||
LOGIN_ALREADYONLINE = 6, // "This account is already logged into World of Warcraft. Please check the spelling and try again.";
|
||||
LOGIN_NOTIME = 7, // "You have used up your prepaid time for this account. Please purchase more to continue playing";
|
||||
LOGIN_DBBUSY = 8, // "Could not log in to World of Warcraft at this time. Please try again later.";
|
||||
LOGIN_BADVERSION = 9, // "Unable to validate game version. This may be caused by file corruption or the interference of another program. Please visit www.blizzard.com/support/wow/ for more information and possible solutions to this issue.";
|
||||
LOGIN_PARENTALCONTROL = 0xF, // "17"="LOGIN_PARENTALCONTROL" // "Access to this account has been blocked by parental controls. Your settings may be changed in your account preferences at http://www.worldofwarcraft.com.";
|
||||
|
||||
// LOGIN_STATE_AUTHENTICATED:
|
||||
LOGIN_OK = 0, // E
|
||||
|
||||
// LOGIN_STATE_DOWNLOADFILE, LOGIN_OK
|
||||
LOGIN_DOWNLOADFILE = 0xA, // not official name
|
||||
};
|
||||
//==============================================================================
|
||||
#endif // _LOGONCODES_H
|
||||
//******************************************************************************
|
||||
//******************************************************************************
|
||||
// Here are all codes used in Logon Server.
|
||||
//==============================================================================
|
||||
#ifndef _LOGONCODES_H
|
||||
#define _LOGONCODES_H
|
||||
//==============================================================================
|
||||
//#include "OurDefs.h"
|
||||
//==============================================================================
|
||||
// wow's codes:
|
||||
enum EClientCommand
|
||||
// dumped from wow.exe 1.8.0
|
||||
// 0x007F86A8: table of
|
||||
// <int32 code, int32 pstr, int32 pproc, int32 0>
|
||||
// switch: 005999A7 cmp byte ptr [ecx],dl
|
||||
{
|
||||
CMD_AUTH_LOGON_CHALLENGE = 0x00, // client
|
||||
CMD_AUTH_LOGON_PROOF = 0x01, // client
|
||||
CMD_AUTH_RECONNECT_CHALLENGE = 0x02, // client
|
||||
CMD_AUTH_RECONNECT_PROOF = 0x03, // client
|
||||
CMD_REALM_LIST = 0x10, // client
|
||||
CMD_XFER_INITIATE = 0x30, // client? from server
|
||||
CMD_XFER_DATA = 0x31, // client? from server
|
||||
CMD_XFER_ACCEPT = 0x32, // not official name, from client
|
||||
CMD_XFER_RESUME = 0x33, // not official name, from client
|
||||
CMD_XFER_CANCEL = 0x34, // not official name, from client
|
||||
|
||||
// unknown:
|
||||
CMD_GRUNT_AUTH_CHALLENGE = 0x00, // server
|
||||
CMD_GRUNT_AUTH_VERIFY = 0x02, // server
|
||||
CMD_GRUNT_CONN_PING = 0x10, // server
|
||||
CMD_GRUNT_CONN_PONG = 0x11, // server
|
||||
CMD_GRUNT_HELLO = 0x20, // server
|
||||
CMD_GRUNT_PROVESESSION = 0x21, // server
|
||||
CMD_GRUNT_KICK = 0x24, // server
|
||||
};
|
||||
//------------------------------------------------------------------------------
|
||||
enum ELoginErrorCode
|
||||
// dumped from wow.exe 1.8.0
|
||||
// 00591E9D mov eax,dword ptr [ebp+8]
|
||||
// eax - code, name in stack after exiting from current funk
|
||||
{
|
||||
// LOGIN_STATE_FAILED:
|
||||
|
||||
LOGIN_FAILED = 1, // 2, B, C, D // "Unable to connect"
|
||||
LOGIN_BANNED = 3, // "This World of Warcraft account has been closed and is no longer in service -- Please check the registered email address of this account for further information."; -- This is the error message players get when trying to log in with a banned account.
|
||||
LOGIN_UNKNOWN_ACCOUNT = 4, // 5 // "The information you have entered is not valid. Please check the spelling of the account name and password. If you need help in retrieving a lost or stolen password and account, see www.worldofwarcraft.com for more information.";
|
||||
LOGIN_ALREADYONLINE = 6, // "This account is already logged into World of Warcraft. Please check the spelling and try again.";
|
||||
LOGIN_NOTIME = 7, // "You have used up your prepaid time for this account. Please purchase more to continue playing";
|
||||
LOGIN_DBBUSY = 8, // "Could not log in to World of Warcraft at this time. Please try again later.";
|
||||
LOGIN_BADVERSION = 9, // "Unable to validate game version. This may be caused by file corruption or the interference of another program. Please visit www.blizzard.com/support/wow/ for more information and possible solutions to this issue.";
|
||||
LOGIN_PARENTALCONTROL = 0xF, // "17"="LOGIN_PARENTALCONTROL" // "Access to this account has been blocked by parental controls. Your settings may be changed in your account preferences at http://www.worldofwarcraft.com.";
|
||||
|
||||
// LOGIN_STATE_AUTHENTICATED:
|
||||
LOGIN_OK = 0, // E
|
||||
|
||||
// LOGIN_STATE_DOWNLOADFILE, LOGIN_OK
|
||||
LOGIN_DOWNLOADFILE = 0xA, // not official name
|
||||
};
|
||||
//==============================================================================
|
||||
#endif // _LOGONCODES_H
|
||||
//******************************************************************************
|
||||
|
||||
@ -1,193 +1,193 @@
|
||||
//******************************************************************************
|
||||
// Here are all packets to and from Logon Server.
|
||||
//==============================================================================
|
||||
#ifndef _LOGONPACKETS_H
|
||||
#define _LOGONPACKETS_H
|
||||
//==============================================================================
|
||||
#include "../Shared/OurDefs.h"
|
||||
#include <openssl/md5.h>
|
||||
//==============================================================================
|
||||
#pragma pack(push, 1)
|
||||
//==============================================================================
|
||||
// Challenge:
|
||||
struct SClientLogonChallenge
|
||||
{
|
||||
uint8 cmd; // OP code = CMD_AUTH_LOGON_CHALLENGE
|
||||
uint8 error0x02; // 0x02
|
||||
uint16 size; // size of the rest of packet, without this part
|
||||
uint8 gamename[4]; // "WoW"
|
||||
uint8 version[2]; // 0x01 08 00 -> (1.8.0)
|
||||
uint16 build; // 0x7F12 -> 4735
|
||||
uint8 platform[3]; // 68x\0 -> "x86"
|
||||
uint8 os[3]; // niW\0 -> "Win"
|
||||
uint8 localization[4];// BGne -> 'enGB'
|
||||
uint32 timezone_bias; // 0x78 00 00 00
|
||||
uint8 ip[4]; // client ip: 0x7F 00 00 01
|
||||
uint8 acclen; // length of account name (without zero-char)
|
||||
uint8 *acc; // upcased account name (without zero-char)
|
||||
};
|
||||
struct SClientLogonChallenge_Header // just for usability
|
||||
{
|
||||
uint8 cmd; // OP code = CMD_AUTH_LOGON_CHALLENGE
|
||||
uint8 error; // 0x02
|
||||
uint16 size; // size of the rest of packet, without this part
|
||||
};
|
||||
struct SClientReconnectChallenge // == SClientChallenge
|
||||
{
|
||||
uint8 cmd; // OP code = 02 = CMD_AUTH_RECONNECT_CHALLENGE
|
||||
uint8 error; // 0x02
|
||||
uint16 size; // size of the rest of packet, without this part
|
||||
uint8 gamename[4]; // "WoW"
|
||||
uint8 version[2]; // 0x01 08 00 -> (1.8.0)
|
||||
uint16 build; // 0x7F12 -> 4735
|
||||
uint8 platform[4]; // 68x\0 -> "x86"
|
||||
uint8 os[4]; // niW\0 -> "Win"
|
||||
uint8 country[4]; // BGne -> 'enGB'
|
||||
uint32 timezone_bias; // 0x78 00 00 00
|
||||
uint8 ip[4]; // client ip: 0x7F 00 00 01
|
||||
uint8 acclen; // length of account name (without zero-char)
|
||||
uint8 *acc; // upcased account name (without zero-char)
|
||||
};
|
||||
struct SServerLogonChallenge_Err
|
||||
{
|
||||
uint8 cmd; // 0x00 -> OPcode = CMD_AUTH_LOGON_CHALLENGE ? CMD_GRUNT_AUTH_CHALLENGE
|
||||
uint8 error; // one of SServerChallenge_ErrorCodes codes
|
||||
};
|
||||
struct SServerLogonChallenge_Ok
|
||||
// Variables:
|
||||
// X := SHA1( salt || SHA1(upper(acc:pass)) )
|
||||
// b[20] := random server's secret
|
||||
// K := 3
|
||||
// salt[32] := random
|
||||
// N := 89 4B 64 5E - 89 E1 53 5B - BD AD 5B 8B - 29 06 50 53
|
||||
// 08 01 B1 8E - BF BF 5E 8F - AB 3C 82 87 - 2A 3E 9B B7
|
||||
// g[1] := 7
|
||||
//
|
||||
// Calculations:
|
||||
// Verifier := g^(~x) mod ~N
|
||||
// B := ~( K*V + g^(~b) mod ~N )
|
||||
{
|
||||
uint8 cmd; // 0x00 -> OPcode = CMD_AUTH_LOGON_CHALLENGE ? CMD_GRUNT_AUTH_CHALLENGE
|
||||
uint8 error; // 0 -> ok = LOGIN_OK
|
||||
uint8 unk1; // 0x00
|
||||
|
||||
uint8 B[32]; // calculated by server
|
||||
|
||||
uint8 g_len; // 0x01
|
||||
uint8 g[1]; // 0x07 (const)
|
||||
|
||||
uint8 N_len; // 0x20
|
||||
uint8 N[32]; // const
|
||||
|
||||
uint8 salt[32]; // random
|
||||
uint8 unk2[16]; //1: BA 79 D4 8D - BF FC BF AD - 8C B4 EC B3 - 75 C5 96 05
|
||||
//2: 0F EB C2 82 - 28 C2 BC E4 - A6 31 30 C7 - 9F 6D 72 76
|
||||
};
|
||||
//------------------------------------------------------------------------------
|
||||
// Proof:
|
||||
struct SClientLogonProof
|
||||
{
|
||||
uint8 cmd; // 0x01 -> OPcode = CMD_AUTH_LOGON_PROOF
|
||||
uint8 A[32]; // calculated by client
|
||||
uint8 M1[20]; //
|
||||
uint8 crc_hash[20]; //
|
||||
uint8 number_of_keys; // 0x00
|
||||
};
|
||||
struct SClientReconnectProof // == SClientProof
|
||||
{
|
||||
uint8 cmd; // 0x01 -> OPcode = CMD_AUTH_RECONNECT_PROOF
|
||||
uint8 A[32]; // calculated by client
|
||||
uint8 M1[20]; //
|
||||
uint8 crc_hash[20]; //
|
||||
uint8 number_of_keys; // 0x00
|
||||
};
|
||||
struct SServerLogonProof_Err
|
||||
// Variables:
|
||||
// U := SHA1(A || B)
|
||||
//
|
||||
// Calculations:
|
||||
// S := ~( ( (V^(~U))*(~A) ) ^ (~b) mod ~N )
|
||||
// hS0 := SHA1 ( S[0] || S[2] || ... || S[20] )
|
||||
// hS1 := SHA1 ( S[1] || S[3] || ... || S[19] )
|
||||
// SS := hS0[0] || hS1[0] || hS0[1] || ... || hS1[10]
|
||||
// M1 := SHA1( (SHA1(N) xor SHA1(G)) || SHA1(upper(acc)) || salt || A || B || SS )
|
||||
{
|
||||
uint8 cmd; // 0x01 -> OPcode = CMD_AUTH_LOGON_PROOF
|
||||
uint8 error; // 0x04 -> password is incorrect = LOGIN_UNKNOWN_ACCOUNT
|
||||
};
|
||||
struct SServerLogonProof_Ok
|
||||
// M2 := SHA1(A || M1 || SS)
|
||||
{
|
||||
uint8 cmd; // 0x01 -> OPcode = CMD_AUTH_LOGON_PROOF
|
||||
uint8 error; // 0x00 -> ok
|
||||
uint8 M2[20]; // calculated by server
|
||||
uint32 unk; // 0x00 00 00 00
|
||||
};
|
||||
//------------------------------------------------------------------------------
|
||||
// Realm:
|
||||
struct SClientRealmList
|
||||
{
|
||||
uint8 cmd; // OP code = CMD_REALM_LIST
|
||||
uint32 unknown; // 0x00 00 00 00
|
||||
};
|
||||
struct SServerRealmList // for info only - variable size
|
||||
{
|
||||
uint8 cmd; // OP code = CMD_REALM_LIST
|
||||
uint16 size; // size of the rest of packet, without this part
|
||||
uint32 unknown; // 0x00 00 00 00
|
||||
uint8 count; // quantity of realms
|
||||
struct SRealmInfo
|
||||
{
|
||||
uint32 icon; // icon near realm
|
||||
uint8 color; // color of record
|
||||
char *name; // Text zero terminated name of Realm
|
||||
char *addr_port; // Text zero terminated address of Realm ("ip:port")
|
||||
float population; // 1.6 -> population value. lower == lower population and vice versa
|
||||
uint8 chars_here; // number of characters on this server
|
||||
uint8 timezone; // timezone
|
||||
uint8 unknown; //
|
||||
} * realms;
|
||||
uint8 unknown1; // 0x2A unknown
|
||||
uint8 unknown2; // 0x00 unknown
|
||||
};
|
||||
struct SServerRealmList_Header
|
||||
{
|
||||
uint8 cmd; // OP code = CMD_REALM_LIST
|
||||
uint16 size; // size of the rest of packet, without this part
|
||||
};
|
||||
//------------------------------------------------------------------------------
|
||||
// Xref:
|
||||
struct SServerXferInitiate
|
||||
{
|
||||
uint8 cmd; // 0x30 -> OPcode = CMD_XFER_INITIATE
|
||||
uint8 typelen; // 0x05 -> sizeof(Patch)
|
||||
uint8 typestr[5]; // 'Patch'
|
||||
uint32 size; // 0x34 C4 0D 00 = 902,196 byte (180->181 enGB)
|
||||
uint32 unk; // 0x0 always
|
||||
uint8 md5[MD5_DIGEST_LENGTH]; // md5 checksum of file
|
||||
};
|
||||
struct SServerXferData
|
||||
{
|
||||
uint8 cmd; // 0x31 -> OPcode = CMD_XFER_DATA
|
||||
uint16 blocksize; // 0xDC 05 -> 1500 (max block)
|
||||
uint8 buf[1500]; // block
|
||||
};
|
||||
struct SClientXferAccept
|
||||
{
|
||||
uint8 cmd; // 0x32 -> OPcode = CMD_XFER_ACCEPT
|
||||
};
|
||||
struct SClientXferResume
|
||||
{
|
||||
uint8 cmd; // 0x33 -> OPcode = CMD_XFER_RESUME
|
||||
uint32 start; // will continue at
|
||||
uint32 unknown; //
|
||||
};
|
||||
struct SClientXferCancel
|
||||
{
|
||||
uint8 cmd; // 0x34 -> OPcode = CMD_XFER_CANCEL
|
||||
};
|
||||
//==============================================================================
|
||||
#pragma pack(pop)
|
||||
//==============================================================================
|
||||
#endif // _LOGONPACKETS_H
|
||||
//******************************************************************************
|
||||
//******************************************************************************
|
||||
// Here are all packets to and from Logon Server.
|
||||
//==============================================================================
|
||||
#ifndef _LOGONPACKETS_H
|
||||
#define _LOGONPACKETS_H
|
||||
//==============================================================================
|
||||
#include "../Shared/OurDefs.h"
|
||||
#include <openssl/md5.h>
|
||||
//==============================================================================
|
||||
#pragma pack(push, 1)
|
||||
//==============================================================================
|
||||
// Challenge:
|
||||
struct SClientLogonChallenge
|
||||
{
|
||||
uint8 cmd; // OP code = CMD_AUTH_LOGON_CHALLENGE
|
||||
uint8 error0x02; // 0x02
|
||||
uint16 size; // size of the rest of packet, without this part
|
||||
uint8 gamename[4]; // "WoW"
|
||||
uint8 version[2]; // 0x01 08 00 -> (1.8.0)
|
||||
uint16 build; // 0x7F12 -> 4735
|
||||
uint8 platform[3]; // 68x\0 -> "x86"
|
||||
uint8 os[3]; // niW\0 -> "Win"
|
||||
uint8 localization[4];// BGne -> 'enGB'
|
||||
uint32 timezone_bias; // 0x78 00 00 00
|
||||
uint8 ip[4]; // client ip: 0x7F 00 00 01
|
||||
uint8 acclen; // length of account name (without zero-char)
|
||||
uint8 *acc; // upcased account name (without zero-char)
|
||||
};
|
||||
struct SClientLogonChallenge_Header // just for usability
|
||||
{
|
||||
uint8 cmd; // OP code = CMD_AUTH_LOGON_CHALLENGE
|
||||
uint8 error; // 0x02
|
||||
uint16 size; // size of the rest of packet, without this part
|
||||
};
|
||||
struct SClientReconnectChallenge // == SClientChallenge
|
||||
{
|
||||
uint8 cmd; // OP code = 02 = CMD_AUTH_RECONNECT_CHALLENGE
|
||||
uint8 error; // 0x02
|
||||
uint16 size; // size of the rest of packet, without this part
|
||||
uint8 gamename[4]; // "WoW"
|
||||
uint8 version[2]; // 0x01 08 00 -> (1.8.0)
|
||||
uint16 build; // 0x7F12 -> 4735
|
||||
uint8 platform[4]; // 68x\0 -> "x86"
|
||||
uint8 os[4]; // niW\0 -> "Win"
|
||||
uint8 country[4]; // BGne -> 'enGB'
|
||||
uint32 timezone_bias; // 0x78 00 00 00
|
||||
uint8 ip[4]; // client ip: 0x7F 00 00 01
|
||||
uint8 acclen; // length of account name (without zero-char)
|
||||
uint8 *acc; // upcased account name (without zero-char)
|
||||
};
|
||||
struct SServerLogonChallenge_Err
|
||||
{
|
||||
uint8 cmd; // 0x00 -> OPcode = CMD_AUTH_LOGON_CHALLENGE ? CMD_GRUNT_AUTH_CHALLENGE
|
||||
uint8 error; // one of SServerChallenge_ErrorCodes codes
|
||||
};
|
||||
struct SServerLogonChallenge_Ok
|
||||
// Variables:
|
||||
// X := SHA1( salt || SHA1(upper(acc:pass)) )
|
||||
// b[20] := random server's secret
|
||||
// K := 3
|
||||
// salt[32] := random
|
||||
// N := 89 4B 64 5E - 89 E1 53 5B - BD AD 5B 8B - 29 06 50 53
|
||||
// 08 01 B1 8E - BF BF 5E 8F - AB 3C 82 87 - 2A 3E 9B B7
|
||||
// g[1] := 7
|
||||
//
|
||||
// Calculations:
|
||||
// Verifier := g^(~x) mod ~N
|
||||
// B := ~( K*V + g^(~b) mod ~N )
|
||||
{
|
||||
uint8 cmd; // 0x00 -> OPcode = CMD_AUTH_LOGON_CHALLENGE ? CMD_GRUNT_AUTH_CHALLENGE
|
||||
uint8 error; // 0 -> ok = LOGIN_OK
|
||||
uint8 unk1; // 0x00
|
||||
|
||||
uint8 B[32]; // calculated by server
|
||||
|
||||
uint8 g_len; // 0x01
|
||||
uint8 g[1]; // 0x07 (const)
|
||||
|
||||
uint8 N_len; // 0x20
|
||||
uint8 N[32]; // const
|
||||
|
||||
uint8 salt[32]; // random
|
||||
uint8 unk2[16]; //1: BA 79 D4 8D - BF FC BF AD - 8C B4 EC B3 - 75 C5 96 05
|
||||
//2: 0F EB C2 82 - 28 C2 BC E4 - A6 31 30 C7 - 9F 6D 72 76
|
||||
};
|
||||
//------------------------------------------------------------------------------
|
||||
// Proof:
|
||||
struct SClientLogonProof
|
||||
{
|
||||
uint8 cmd; // 0x01 -> OPcode = CMD_AUTH_LOGON_PROOF
|
||||
uint8 A[32]; // calculated by client
|
||||
uint8 M1[20]; //
|
||||
uint8 crc_hash[20]; //
|
||||
uint8 number_of_keys; // 0x00
|
||||
};
|
||||
struct SClientReconnectProof // == SClientProof
|
||||
{
|
||||
uint8 cmd; // 0x01 -> OPcode = CMD_AUTH_RECONNECT_PROOF
|
||||
uint8 A[32]; // calculated by client
|
||||
uint8 M1[20]; //
|
||||
uint8 crc_hash[20]; //
|
||||
uint8 number_of_keys; // 0x00
|
||||
};
|
||||
struct SServerLogonProof_Err
|
||||
// Variables:
|
||||
// U := SHA1(A || B)
|
||||
//
|
||||
// Calculations:
|
||||
// S := ~( ( (V^(~U))*(~A) ) ^ (~b) mod ~N )
|
||||
// hS0 := SHA1 ( S[0] || S[2] || ... || S[20] )
|
||||
// hS1 := SHA1 ( S[1] || S[3] || ... || S[19] )
|
||||
// SS := hS0[0] || hS1[0] || hS0[1] || ... || hS1[10]
|
||||
// M1 := SHA1( (SHA1(N) xor SHA1(G)) || SHA1(upper(acc)) || salt || A || B || SS )
|
||||
{
|
||||
uint8 cmd; // 0x01 -> OPcode = CMD_AUTH_LOGON_PROOF
|
||||
uint8 error; // 0x04 -> password is incorrect = LOGIN_UNKNOWN_ACCOUNT
|
||||
};
|
||||
struct SServerLogonProof_Ok
|
||||
// M2 := SHA1(A || M1 || SS)
|
||||
{
|
||||
uint8 cmd; // 0x01 -> OPcode = CMD_AUTH_LOGON_PROOF
|
||||
uint8 error; // 0x00 -> ok
|
||||
uint8 M2[20]; // calculated by server
|
||||
uint32 unk; // 0x00 00 00 00
|
||||
};
|
||||
//------------------------------------------------------------------------------
|
||||
// Realm:
|
||||
struct SClientRealmList
|
||||
{
|
||||
uint8 cmd; // OP code = CMD_REALM_LIST
|
||||
uint32 unknown; // 0x00 00 00 00
|
||||
};
|
||||
struct SServerRealmList // for info only - variable size
|
||||
{
|
||||
uint8 cmd; // OP code = CMD_REALM_LIST
|
||||
uint16 size; // size of the rest of packet, without this part
|
||||
uint32 unknown; // 0x00 00 00 00
|
||||
uint8 count; // quantity of realms
|
||||
struct SRealmInfo
|
||||
{
|
||||
uint32 icon; // icon near realm
|
||||
uint8 color; // color of record
|
||||
char *name; // Text zero terminated name of Realm
|
||||
char *addr_port; // Text zero terminated address of Realm ("ip:port")
|
||||
float population; // 1.6 -> population value. lower == lower population and vice versa
|
||||
uint8 chars_here; // number of characters on this server
|
||||
uint8 timezone; // timezone
|
||||
uint8 unknown; //
|
||||
} * realms;
|
||||
uint8 unknown1; // 0x2A unknown
|
||||
uint8 unknown2; // 0x00 unknown
|
||||
};
|
||||
struct SServerRealmList_Header
|
||||
{
|
||||
uint8 cmd; // OP code = CMD_REALM_LIST
|
||||
uint16 size; // size of the rest of packet, without this part
|
||||
};
|
||||
//------------------------------------------------------------------------------
|
||||
// Xref:
|
||||
struct SServerXferInitiate
|
||||
{
|
||||
uint8 cmd; // 0x30 -> OPcode = CMD_XFER_INITIATE
|
||||
uint8 typelen; // 0x05 -> sizeof(Patch)
|
||||
uint8 typestr[5]; // 'Patch'
|
||||
uint32 size; // 0x34 C4 0D 00 = 902,196 byte (180->181 enGB)
|
||||
uint32 unk; // 0x0 always
|
||||
uint8 md5[MD5_DIGEST_LENGTH]; // md5 checksum of file
|
||||
};
|
||||
struct SServerXferData
|
||||
{
|
||||
uint8 cmd; // 0x31 -> OPcode = CMD_XFER_DATA
|
||||
uint16 blocksize; // 0xDC 05 -> 1500 (max block)
|
||||
uint8 buf[1500]; // block
|
||||
};
|
||||
struct SClientXferAccept
|
||||
{
|
||||
uint8 cmd; // 0x32 -> OPcode = CMD_XFER_ACCEPT
|
||||
};
|
||||
struct SClientXferResume
|
||||
{
|
||||
uint8 cmd; // 0x33 -> OPcode = CMD_XFER_RESUME
|
||||
uint32 start; // will continue at
|
||||
uint32 unknown; //
|
||||
};
|
||||
struct SClientXferCancel
|
||||
{
|
||||
uint8 cmd; // 0x34 -> OPcode = CMD_XFER_CANCEL
|
||||
};
|
||||
//==============================================================================
|
||||
#pragma pack(pop)
|
||||
//==============================================================================
|
||||
#endif // _LOGONPACKETS_H
|
||||
//******************************************************************************
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user