PageRenderTime 48ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/Python/xAgeSDLIntRespList.py

https://bitbucket.org/cwalther/moulscript-dlanor
Python | 137 lines | 78 code | 7 blank | 52 comment | 1 complexity | 132173ce562902eb6b1b28816c4cca22 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-3.0
  1. """ *==LICENSE==*
  2. CyanWorlds.com Engine - MMOG client, server and tools
  3. Copyright (C) 2011 Cyan Worlds, Inc.
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>.
  14. Additional permissions under GNU GPL version 3 section 7
  15. If you modify this Program, or any covered work, by linking or
  16. combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
  17. NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
  18. JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
  19. (or a modified version of those libraries),
  20. containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
  21. PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
  22. JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
  23. licensors of this Program grant you additional
  24. permission to convey the resulting work. Corresponding Source for a
  25. non-source form of such a combination shall include the source code for
  26. the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
  27. work.
  28. You can contact Cyan Worlds, Inc. by email legal@cyan.com
  29. or by snail mail at:
  30. Cyan Worlds, Inc.
  31. 14617 N Newport Hwy
  32. Mead, WA 99021
  33. *==LICENSE==* """
  34. """
  35. Module: xAgeSDLIntRespList.py
  36. Age: Global
  37. Date: March, 2003
  38. Author: Adam Van Ornum
  39. """
  40. from Plasma import *
  41. from PlasmaTypes import *
  42. import re
  43. # define the attributes that will be entered in max1
  44. #NOTE: The Responder name format string should be the name of the responder with a %d somewhere in there
  45. # that will specify which responder runs at the received state. All of the responders
  46. # must be named similarly (like below).
  47. # I.E: Three responders named Resp01, Resp02, Resp03 so the format string would be "Resp0%d"
  48. stringSDLVarName = ptAttribString(1,"Age SDL Variable")
  49. respList = ptAttribResponderList(2,"ResponderList",byObject=1)
  50. stringFormat = ptAttribString(3,"Responder name format string")
  51. intMaxState = ptAttribInt(4,"Max state value",2)
  52. boolStartFF = ptAttribBoolean(5,"F-Forward on start",0)
  53. boolVltMgrFF = ptAttribBoolean(6,"F-Forward on VM notify", 1)
  54. intDefault = ptAttribInt(7,"Default setting",0)
  55. class xAgeSDLIntRespList(ptResponder):
  56. def __init__(self):
  57. ptModifier.__init__(self)
  58. self.id = 5307
  59. self.version = 2
  60. print "__init__xAgeSDLIntRespList v.", self.version
  61. def OnFirstUpdate(self):
  62. if type(stringSDLVarName.value) != type("") or stringSDLVarName.value == "":
  63. PtDebugPrint("ERROR: xAgeSDLIntRespList.OnFirstUpdate():\tERROR: missing SDL var name in max file")
  64. pass
  65. elif type(stringFormat.value) != type("") or stringFormat.value == "":
  66. PtDebugPrint("ERROR: xAgeSDLIntRespList.OnFirstUpdate():\tERROR: missing responder name format string in max file")
  67. pass
  68. def OnServerInitComplete(self):
  69. ageSDL = PtGetAgeSDL()
  70. PtDebugPrint("DEBUG: xAgeSDLIntRespList.OnServerInitComplete:\tProcessing")
  71. ageSDL.setNotify(self.key,stringSDLVarName.value,0.0)
  72. try:
  73. SDLvalue = ageSDL[stringSDLVarName.value][0]
  74. except:
  75. PtDebugPrint("ERROR: xAgeSDLIntShowHide.OnServerInitComplete():\tERROR: age sdl read failed, SDLvalue = %d by default. stringSDLVarName = %s" % (intDefault.value,stringSDLVarName.value))
  76. SDLvalue = intDefault.value
  77. #regexp = re.compile(".*_%s" % (stringFormat.value % SDLvalue))
  78. respName = (stringFormat.value % SDLvalue)
  79. if 0 <= SDLvalue <= intMaxState.value:
  80. for key in respList.byObject.keys():
  81. #match = regexp.search(key)
  82. if key == respName:#match:
  83. PtDebugPrint("DEBUG: xAgeSDLIntRespList.OnServerInitComplete:\tRunning responder - %s" % (stringFormat.value % SDLvalue))
  84. #respList.run(self.key,avatar=None,objectName=match.group(),fastforward=boolStartFF.value)
  85. respList.run(self.key,avatar=None,objectName=respName,fastforward=boolStartFF.value)
  86. break
  87. def OnSDLNotify(self,VARname,SDLname,PlayerID,tag):
  88. if VARname != stringSDLVarName.value:
  89. return
  90. ageSDL = PtGetAgeSDL()
  91. # is state change from player or vault manager?
  92. if PlayerID: # non-zero means it's a player
  93. objAvatar = ptSceneobject(PtGetAvatarKeyFromClientID(PlayerID),self.key)
  94. fastforward = 0
  95. else: # invalid player aka Vault Manager
  96. objAvatar = None
  97. fastforward = boolVltMgrFF.value # we need to skip any one-shots
  98. if tag == "fastforward":
  99. objAvatar = None
  100. fastforward = 1
  101. PtDebugPrint("DEBUG: xAgeSDLIntRespList.OnSDLNotify():\tnotification from PlayerID: %d" % (PlayerID))
  102. SDLvalue = ageSDL[stringSDLVarName.value][0]
  103. PtDebugPrint("DEBUG: xAgeSDLIntRespList.OnSDLNotify received: %s = %d" % (VARname, SDLvalue))
  104. #regexp = re.compile(".*_%s" % (stringFormat.value % SDLvalue))
  105. respName = (stringFormat.value % SDLvalue)
  106. if 0 <= SDLvalue <= intMaxState.value:
  107. for key in respList.byObject.keys():
  108. #match = regexp.search(key)
  109. if key == respName:#match:
  110. PtDebugPrint("DEBUG: xAgeSDLIntRespList.OnSDLNotify:\tRunning responder - %s" % (stringFormat.value % SDLvalue))
  111. #respList.run(self.key,avatar=objAvatar,objectName=match.group(),fastforward=fastforward)
  112. respList.run(self.key,avatar=objAvatar,objectName=respName,fastforward=fastforward)
  113. break