2
3
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-14 02:27:40 -04:00

Fix line endings and tabs

This commit is contained in:
Branan Purvine-Riley
2011-04-11 16:27:55 -07:00
parent d4250e19b5
commit 908aaeb6f6
2738 changed files with 702562 additions and 702562 deletions

View File

@ -1,354 +1,354 @@
include_directories(../../CoreLib)
include_directories(../../FeatureLib)
include_directories(../../NucleusLib)
include_directories(../../NucleusLib/inc)
include_directories(../../PubUtilLib)
include_directories(../../)
include_directories(${PYTHON_INCLUDE_DIR})
include_directories(${OPENAL_INCLUDE_DIR})
include_directories(${OPENSSL_INCLUDE_DIR})
set(pfPython_SOURCES
cyAccountManagement.cpp
cyAnimation.cpp
cyAvatar.cpp
cyCamera.cpp
cyDraw.cpp
cyInputInterface.cpp
cyMisc.cpp
cyParticleSys.cpp
cyPhysics.cpp
cyPythonInterface.cpp
plPythonFileMod.cpp
plPythonPack.cpp
plPythonSDLModifier.cpp
pyAgeInfoStruct.cpp
pyAgeLinkStruct.cpp
pyAgeVault.cpp
pyAlarm.cpp
pyAudioControl.cpp
pyCCRMgr.cpp
pyCluster.cpp
pyColor.cpp
pyCritterBrain.cpp
pyDniCoordinates.cpp
pyDniInfoSource.cpp
pyDrawControl.cpp
pyDynamicText.cpp
pyEnum.cpp
pyGameScore.cpp
pyGeometry3.cpp
pyGrassShader.cpp
pyGUIControl.cpp
pyGUIControlButton.cpp
pyGUIControlCheckBox.cpp
pyGUIControlClickMap.cpp
pyGUIControlDragBar.cpp
pyGUIControlDraggable.cpp
pyGUIControlDynamicText.cpp
pyGUIControlEditBox.cpp
pyGUIControlListBox.cpp
pyGUIControlMultiLineEdit.cpp
pyGUIControlRadioGroup.cpp
pyGUIControlTextBox.cpp
pyGUIControlValue.cpp
pyGUIDialog.cpp
pyGUIPopUpMenu.cpp
pyGUISkin.cpp
pyImage.cpp
pyJournalBook.cpp
pyKey.cpp
pyKeyMap.cpp
pyMarkerMgr.cpp
pyMatrix44.cpp
pyMoviePlayer.cpp
pyNetLinkingMgr.cpp
pyNetServerSessionInfo.cpp
pyNotify.cpp
pyPlayer.cpp
pySceneObject.cpp
pyScoreMgr.cpp
pySDL.cpp
pySpawnPointInfo.cpp
pyStatusLog.cpp
pyStream.cpp
pySwimCurrentInterface.cpp
pyVault.cpp
pyVaultAgeInfoListNode.cpp
pyVaultAgeInfoNode.cpp
pyVaultAgeLinkNode.cpp
pyVaultChronicleNode.cpp
pyVaultFolderNode.cpp
pyVaultImageNode.cpp
pyVaultMarkerGameNode.cpp
pyVaultNode.cpp
pyVaultNodeRef.cpp
pyVaultPlayerInfoListNode.cpp
pyVaultPlayerInfoNode.cpp
pyVaultPlayerNode.cpp
pyVaultSDLNode.cpp
pyVaultSystemNode.cpp
pyVaultTextNoteNode.cpp
pyWaveSet.cpp
)
set(pfPython_HEADERS
cyAccountManagement.h
cyAnimation.h
cyAvatar.h
cyCamera.h
cyDraw.h
cyInputInterface.h
cyMisc.h
cyParticleSys.h
cyPhysics.h
cyPythonInterface.h
pfPythonCreatable.h
plPythonFileMod.h
plPythonHelpers.h
plPythonPack.h
plPythonParameter.h
plPythonSDLModifier.h
pyAgeInfoStruct.h
pyAgeLinkStruct.h
pyAgeVault.h
pyAlarm.h
pyAudioControl.h
pyCCRMgr.h
pyCluster.h
pyColor.h
pyCritterBrain.h
pyDniCoordinates.h
pyDniInfoSource.h
pyDrawControl.h
pyDynamicText.h
pyEnum.h
pyGameScore.h
pyGeometry3.h
pyGrassShader.h
pyGUIControl.h
pyGUIControlButton.h
pyGUIControlCheckBox.h
pyGUIControlClickMap.h
pyGUIControlDragBar.h
pyGUIControlDraggable.h
pyGUIControlDynamicText.h
pyGUIControlEditBox.h
pyGUIControlListBox.h
pyGUIControlMultiLineEdit.h
pyGUIControlRadioGroup.h
pyGUIControlTextBox.h
pyGUIControlValue.h
pyGUIDialog.h
pyGUIPopUpMenu.h
pyGUISkin.h
pyImage.h
pyJournalBook.h
pyKey.h
pyKeyMap.h
pyMarkerMgr.h
pyMatrix44.h
pyMoviePlayer.h
pyNetLinkingMgr.h
pyNetServerSessionInfo.h
pyNotify.h
pyPlayer.h
pySceneObject.h
pyScoreMgr.h
pySDL.h
pySpawnPointInfo.h
pyStatusLog.h
pyStream.h
pySwimCurrentInterface.h
pyVault.h
pyVaultAgeInfoListNode.h
pyVaultAgeInfoNode.h
pyVaultAgeLinkNode.h
pyVaultChronicleNode.h
pyVaultFolderNode.h
pyVaultImageNode.h
pyVaultMarkerGameNode.h
pyVaultNode.h
pyVaultNodeRef.h
pyVaultPlayerInfoListNode.h
pyVaultPlayerInfoNode.h
pyVaultPlayerNode.h
pyVaultSDLNode.h
pyVaultSystemNode.h
pyVaultTextNoteNode.h
pyWaveSet.h
)
set(pfPython_GLUE
cyAccountManagementGlue.cpp
cyAnimationGlue.cpp
cyAvatarGlue.cpp
cyCameraGlue.cpp
cyDrawGlue.cpp
cyInputInterfaceGlue.cpp
cyMiscGlue.cpp
cyMiscGlue2.cpp
cyMiscGlue3.cpp
cyMiscGlue4.cpp
cyParticleSysGlue.cpp
cyPhysicsGlue.cpp
plPythonSDLModifierGlue.cpp
pyAgeInfoStructGlue.cpp
pyAgeLinkStructGlue.cpp
pyAgeVaultGlue.cpp
pyAudioControlGlue.cpp
pyCCRMgrGlue.cpp
pyCCRMgrGlue2.cpp
pyClusterGlue.cpp
pyColorGlue.cpp
pyCritterBrainGlue.cpp
pyDniCoordinatesGlue.cpp
pyDniInfoSourceGlue.cpp
pyDrawControlGlue.cpp
pyDynamicTextGlue.cpp
pyGameScoreGlue.cpp
pyGeometry3Glue.cpp
pyGlueHelpers.h
pyGrassShaderGlue.cpp
pyGUIControlButtonGlue.cpp
pyGUIControlCheckBoxGlue.cpp
pyGUIControlClickMapGlue.cpp
pyGUIControlDragBarGlue.cpp
pyGUIControlDraggableGlue.cpp
pyGUIControlDynamicTextGlue.cpp
pyGUIControlEditBoxGlue.cpp
pyGUIControlGlue.cpp
pyGUIControlListBoxGlue.cpp
pyGUIControlMultiLineEditGlue.cpp
pyGUIControlRadioGroupGlue.cpp
pyGUIControlTextBoxGlue.cpp
pyGUIControlValueGlue.cpp
pyGUIDialogGlue.cpp
pyGUIPopUpMenuGlue.cpp
pyGUISkinGlue.cpp
pyImageGlue.cpp
pyJournalBookGlue.cpp
pyKeyGlue.cpp
pyKeyMapGlue.cpp
pyMarkerMgrGlue.cpp
pyMatrix44Glue.cpp
pyMoviePlayerGlue.cpp
pyNetLinkingMgrGlue.cpp
pyNetServerSessionInfoGlue.cpp
pyNotifyGlue.cpp
pyPlayerGlue.cpp
pySceneObjectGlue.cpp
pyScoreMgrGlue.cpp
pySDLGlue.cpp
pySpawnPointInfoGlue.cpp
pyStatusLogGlue.cpp
pyStreamGlue.cpp
pySwimCurrentInterfaceGlue.cpp
pyVaultAgeInfoListNodeGlue.cpp
pyVaultAgeInfoNodeGlue.cpp
pyVaultAgeLinkNodeGlue.cpp
pyVaultChronicleNodeGlue.cpp
pyVaultFolderNodeGlue.cpp
pyVaultGlue.cpp
pyVaultImageNodeGlue.cpp
pyVaultMarkerGameNodeGlue.cpp
pyVaultNodeGlue.cpp
pyVaultNodeRefGlue.cpp
pyVaultPlayerInfoListNodeGlue.cpp
pyVaultPlayerInfoNodeGlue.cpp
pyVaultPlayerNodeGlue.cpp
pyVaultSDLNodeGlue.cpp
pyVaultSystemNodeGlue.cpp
pyVaultTextNoteNodeGlue.cpp
pyWaveSetGlue.cpp
)
set(pfPython_GAME_GLUE
Games/pyGameCli.cpp
Games/pyGameCli.h
Games/pyGameCliGlue.cpp
Games/pyGameCliMsg.cpp
Games/pyGameCliMsg.h
Games/pyGameCliMsgGlue.cpp
Games/pyGameMgrMsg.cpp
Games/pyGameMgrMsg.h
Games/pyGameMgrMsg.cpp
Games/pyGameMgrMsgGlue.cpp
)
set(pfPython_TTT
Games/TicTacToe/pyTTTGame.cpp
Games/TicTacToe/pyTTTGame.h
Games/TicTacToe/pyTTTGameGlue.cpp
Games/TicTacToe/pyTTTMsg.cpp
Games/TicTacToe/pyTTTMsg.h
Games/TicTacToe/pyTTTMsgGlue.cpp
)
set(pfPython_HEEK
Games/Heek/pyHeekGame.cpp
Games/Heek/pyHeekGame.h
Games/Heek/pyHeekGameGlue.cpp
Games/Heek/pyHeekMsg.cpp
Games/Heek/pyHeekMsg.h
Games/Heek/pyHeekMsgGlue.cpp
)
set(pfPython_MARKER
Games/Marker/pyMarkerGame.cpp
Games/Marker/pyMarkerGame.h
Games/Marker/pyMarkerGameGlue.cpp
Games/Marker/pyMarkerMsg.cpp
Games/Marker/pyMarkerMsg.h
Games/Marker/pyMarkerMsgGlue.cpp
)
set(pfPython_BSPIRAL
Games/BlueSpiral/pyBlueSpiralGame.cpp
Games/BlueSpiral/pyBlueSpiralGame.h
Games/BlueSpiral/pyBlueSpiralGameGlue.cpp
Games/BlueSpiral/pyBlueSpiralMsg.cpp
Games/BlueSpiral/pyBlueSpiralMsg.h
Games/BlueSpiral/pyBlueSpiralMsgGlue.cpp
)
set(pfPython_WALL
Games/ClimbingWall/pyClimbingWallGame.cpp
Games/ClimbingWall/pyClimbingWallGame.h
Games/ClimbingWall/pyClimbingWallGameGlue.cpp
Games/ClimbingWall/pyClimbingWallMsg.cpp
Games/ClimbingWall/pyClimbingWallMsg.h
Games/ClimbingWall/pyClimbingWallMsgGlue.cpp
)
set(pfPython_VSYNC
Games/VarSync/pyVarSyncGame.cpp
Games/VarSync/pyVarSyncGame.h
Games/VarSync/pyVarSyncGameGlue.cpp
Games/VarSync/pyVarSyncMsg.cpp
Games/VarSync/pyVarSyncMsg.h
Games/VarSync/pyVarSyncMsgGlue.cpp
)
set(pfPython_GAMES
${pfPython_TTT}
${pfPython_HEEK}
${pfPython_MARKER}
${pfPython_BSPIRAL}
${pfPython_WALL}
${pfPython_VSYNC}
)
add_library(pfPython STATIC ${pfPython_SOURCES} ${pfPython_HEADERS} ${pfPython_GLUE} ${pfPython_GAME_GLUE} ${pfPython_GAMES})
source_group("Source Files" FILES ${pfPython_SOURCES})
source_group("Header Files" FILES ${pfPython_HEADERS})
source_group("Glue Files" FILES ${pfPython_GLUE})
source_group("Game Glue" FILES ${pfPython_GAME_GLUE})
source_group("Game Glue\\TicTacToe" FILES ${pfPython_TTT})
source_group("Game Glue\\Heek" FILES ${pfPython_HEEK})
source_group("Game Glue\\Marker" FILES ${pfPython_MARKER})
source_group("Game Glue\\BlueSpiral" FILES ${pfPython_BSPIRAL})
source_group("Game Glue\\ClimbingWall" FILES ${pfPython_WALL})
source_group("Game Glue\\VarSync" FILES ${pfPython_VSYNC})
include_directories(../../CoreLib)
include_directories(../../FeatureLib)
include_directories(../../NucleusLib)
include_directories(../../NucleusLib/inc)
include_directories(../../PubUtilLib)
include_directories(../../)
include_directories(${PYTHON_INCLUDE_DIR})
include_directories(${OPENAL_INCLUDE_DIR})
include_directories(${OPENSSL_INCLUDE_DIR})
set(pfPython_SOURCES
cyAccountManagement.cpp
cyAnimation.cpp
cyAvatar.cpp
cyCamera.cpp
cyDraw.cpp
cyInputInterface.cpp
cyMisc.cpp
cyParticleSys.cpp
cyPhysics.cpp
cyPythonInterface.cpp
plPythonFileMod.cpp
plPythonPack.cpp
plPythonSDLModifier.cpp
pyAgeInfoStruct.cpp
pyAgeLinkStruct.cpp
pyAgeVault.cpp
pyAlarm.cpp
pyAudioControl.cpp
pyCCRMgr.cpp
pyCluster.cpp
pyColor.cpp
pyCritterBrain.cpp
pyDniCoordinates.cpp
pyDniInfoSource.cpp
pyDrawControl.cpp
pyDynamicText.cpp
pyEnum.cpp
pyGameScore.cpp
pyGeometry3.cpp
pyGrassShader.cpp
pyGUIControl.cpp
pyGUIControlButton.cpp
pyGUIControlCheckBox.cpp
pyGUIControlClickMap.cpp
pyGUIControlDragBar.cpp
pyGUIControlDraggable.cpp
pyGUIControlDynamicText.cpp
pyGUIControlEditBox.cpp
pyGUIControlListBox.cpp
pyGUIControlMultiLineEdit.cpp
pyGUIControlRadioGroup.cpp
pyGUIControlTextBox.cpp
pyGUIControlValue.cpp
pyGUIDialog.cpp
pyGUIPopUpMenu.cpp
pyGUISkin.cpp
pyImage.cpp
pyJournalBook.cpp
pyKey.cpp
pyKeyMap.cpp
pyMarkerMgr.cpp
pyMatrix44.cpp
pyMoviePlayer.cpp
pyNetLinkingMgr.cpp
pyNetServerSessionInfo.cpp
pyNotify.cpp
pyPlayer.cpp
pySceneObject.cpp
pyScoreMgr.cpp
pySDL.cpp
pySpawnPointInfo.cpp
pyStatusLog.cpp
pyStream.cpp
pySwimCurrentInterface.cpp
pyVault.cpp
pyVaultAgeInfoListNode.cpp
pyVaultAgeInfoNode.cpp
pyVaultAgeLinkNode.cpp
pyVaultChronicleNode.cpp
pyVaultFolderNode.cpp
pyVaultImageNode.cpp
pyVaultMarkerGameNode.cpp
pyVaultNode.cpp
pyVaultNodeRef.cpp
pyVaultPlayerInfoListNode.cpp
pyVaultPlayerInfoNode.cpp
pyVaultPlayerNode.cpp
pyVaultSDLNode.cpp
pyVaultSystemNode.cpp
pyVaultTextNoteNode.cpp
pyWaveSet.cpp
)
set(pfPython_HEADERS
cyAccountManagement.h
cyAnimation.h
cyAvatar.h
cyCamera.h
cyDraw.h
cyInputInterface.h
cyMisc.h
cyParticleSys.h
cyPhysics.h
cyPythonInterface.h
pfPythonCreatable.h
plPythonFileMod.h
plPythonHelpers.h
plPythonPack.h
plPythonParameter.h
plPythonSDLModifier.h
pyAgeInfoStruct.h
pyAgeLinkStruct.h
pyAgeVault.h
pyAlarm.h
pyAudioControl.h
pyCCRMgr.h
pyCluster.h
pyColor.h
pyCritterBrain.h
pyDniCoordinates.h
pyDniInfoSource.h
pyDrawControl.h
pyDynamicText.h
pyEnum.h
pyGameScore.h
pyGeometry3.h
pyGrassShader.h
pyGUIControl.h
pyGUIControlButton.h
pyGUIControlCheckBox.h
pyGUIControlClickMap.h
pyGUIControlDragBar.h
pyGUIControlDraggable.h
pyGUIControlDynamicText.h
pyGUIControlEditBox.h
pyGUIControlListBox.h
pyGUIControlMultiLineEdit.h
pyGUIControlRadioGroup.h
pyGUIControlTextBox.h
pyGUIControlValue.h
pyGUIDialog.h
pyGUIPopUpMenu.h
pyGUISkin.h
pyImage.h
pyJournalBook.h
pyKey.h
pyKeyMap.h
pyMarkerMgr.h
pyMatrix44.h
pyMoviePlayer.h
pyNetLinkingMgr.h
pyNetServerSessionInfo.h
pyNotify.h
pyPlayer.h
pySceneObject.h
pyScoreMgr.h
pySDL.h
pySpawnPointInfo.h
pyStatusLog.h
pyStream.h
pySwimCurrentInterface.h
pyVault.h
pyVaultAgeInfoListNode.h
pyVaultAgeInfoNode.h
pyVaultAgeLinkNode.h
pyVaultChronicleNode.h
pyVaultFolderNode.h
pyVaultImageNode.h
pyVaultMarkerGameNode.h
pyVaultNode.h
pyVaultNodeRef.h
pyVaultPlayerInfoListNode.h
pyVaultPlayerInfoNode.h
pyVaultPlayerNode.h
pyVaultSDLNode.h
pyVaultSystemNode.h
pyVaultTextNoteNode.h
pyWaveSet.h
)
set(pfPython_GLUE
cyAccountManagementGlue.cpp
cyAnimationGlue.cpp
cyAvatarGlue.cpp
cyCameraGlue.cpp
cyDrawGlue.cpp
cyInputInterfaceGlue.cpp
cyMiscGlue.cpp
cyMiscGlue2.cpp
cyMiscGlue3.cpp
cyMiscGlue4.cpp
cyParticleSysGlue.cpp
cyPhysicsGlue.cpp
plPythonSDLModifierGlue.cpp
pyAgeInfoStructGlue.cpp
pyAgeLinkStructGlue.cpp
pyAgeVaultGlue.cpp
pyAudioControlGlue.cpp
pyCCRMgrGlue.cpp
pyCCRMgrGlue2.cpp
pyClusterGlue.cpp
pyColorGlue.cpp
pyCritterBrainGlue.cpp
pyDniCoordinatesGlue.cpp
pyDniInfoSourceGlue.cpp
pyDrawControlGlue.cpp
pyDynamicTextGlue.cpp
pyGameScoreGlue.cpp
pyGeometry3Glue.cpp
pyGlueHelpers.h
pyGrassShaderGlue.cpp
pyGUIControlButtonGlue.cpp
pyGUIControlCheckBoxGlue.cpp
pyGUIControlClickMapGlue.cpp
pyGUIControlDragBarGlue.cpp
pyGUIControlDraggableGlue.cpp
pyGUIControlDynamicTextGlue.cpp
pyGUIControlEditBoxGlue.cpp
pyGUIControlGlue.cpp
pyGUIControlListBoxGlue.cpp
pyGUIControlMultiLineEditGlue.cpp
pyGUIControlRadioGroupGlue.cpp
pyGUIControlTextBoxGlue.cpp
pyGUIControlValueGlue.cpp
pyGUIDialogGlue.cpp
pyGUIPopUpMenuGlue.cpp
pyGUISkinGlue.cpp
pyImageGlue.cpp
pyJournalBookGlue.cpp
pyKeyGlue.cpp
pyKeyMapGlue.cpp
pyMarkerMgrGlue.cpp
pyMatrix44Glue.cpp
pyMoviePlayerGlue.cpp
pyNetLinkingMgrGlue.cpp
pyNetServerSessionInfoGlue.cpp
pyNotifyGlue.cpp
pyPlayerGlue.cpp
pySceneObjectGlue.cpp
pyScoreMgrGlue.cpp
pySDLGlue.cpp
pySpawnPointInfoGlue.cpp
pyStatusLogGlue.cpp
pyStreamGlue.cpp
pySwimCurrentInterfaceGlue.cpp
pyVaultAgeInfoListNodeGlue.cpp
pyVaultAgeInfoNodeGlue.cpp
pyVaultAgeLinkNodeGlue.cpp
pyVaultChronicleNodeGlue.cpp
pyVaultFolderNodeGlue.cpp
pyVaultGlue.cpp
pyVaultImageNodeGlue.cpp
pyVaultMarkerGameNodeGlue.cpp
pyVaultNodeGlue.cpp
pyVaultNodeRefGlue.cpp
pyVaultPlayerInfoListNodeGlue.cpp
pyVaultPlayerInfoNodeGlue.cpp
pyVaultPlayerNodeGlue.cpp
pyVaultSDLNodeGlue.cpp
pyVaultSystemNodeGlue.cpp
pyVaultTextNoteNodeGlue.cpp
pyWaveSetGlue.cpp
)
set(pfPython_GAME_GLUE
Games/pyGameCli.cpp
Games/pyGameCli.h
Games/pyGameCliGlue.cpp
Games/pyGameCliMsg.cpp
Games/pyGameCliMsg.h
Games/pyGameCliMsgGlue.cpp
Games/pyGameMgrMsg.cpp
Games/pyGameMgrMsg.h
Games/pyGameMgrMsg.cpp
Games/pyGameMgrMsgGlue.cpp
)
set(pfPython_TTT
Games/TicTacToe/pyTTTGame.cpp
Games/TicTacToe/pyTTTGame.h
Games/TicTacToe/pyTTTGameGlue.cpp
Games/TicTacToe/pyTTTMsg.cpp
Games/TicTacToe/pyTTTMsg.h
Games/TicTacToe/pyTTTMsgGlue.cpp
)
set(pfPython_HEEK
Games/Heek/pyHeekGame.cpp
Games/Heek/pyHeekGame.h
Games/Heek/pyHeekGameGlue.cpp
Games/Heek/pyHeekMsg.cpp
Games/Heek/pyHeekMsg.h
Games/Heek/pyHeekMsgGlue.cpp
)
set(pfPython_MARKER
Games/Marker/pyMarkerGame.cpp
Games/Marker/pyMarkerGame.h
Games/Marker/pyMarkerGameGlue.cpp
Games/Marker/pyMarkerMsg.cpp
Games/Marker/pyMarkerMsg.h
Games/Marker/pyMarkerMsgGlue.cpp
)
set(pfPython_BSPIRAL
Games/BlueSpiral/pyBlueSpiralGame.cpp
Games/BlueSpiral/pyBlueSpiralGame.h
Games/BlueSpiral/pyBlueSpiralGameGlue.cpp
Games/BlueSpiral/pyBlueSpiralMsg.cpp
Games/BlueSpiral/pyBlueSpiralMsg.h
Games/BlueSpiral/pyBlueSpiralMsgGlue.cpp
)
set(pfPython_WALL
Games/ClimbingWall/pyClimbingWallGame.cpp
Games/ClimbingWall/pyClimbingWallGame.h
Games/ClimbingWall/pyClimbingWallGameGlue.cpp
Games/ClimbingWall/pyClimbingWallMsg.cpp
Games/ClimbingWall/pyClimbingWallMsg.h
Games/ClimbingWall/pyClimbingWallMsgGlue.cpp
)
set(pfPython_VSYNC
Games/VarSync/pyVarSyncGame.cpp
Games/VarSync/pyVarSyncGame.h
Games/VarSync/pyVarSyncGameGlue.cpp
Games/VarSync/pyVarSyncMsg.cpp
Games/VarSync/pyVarSyncMsg.h
Games/VarSync/pyVarSyncMsgGlue.cpp
)
set(pfPython_GAMES
${pfPython_TTT}
${pfPython_HEEK}
${pfPython_MARKER}
${pfPython_BSPIRAL}
${pfPython_WALL}
${pfPython_VSYNC}
)
add_library(pfPython STATIC ${pfPython_SOURCES} ${pfPython_HEADERS} ${pfPython_GLUE} ${pfPython_GAME_GLUE} ${pfPython_GAMES})
source_group("Source Files" FILES ${pfPython_SOURCES})
source_group("Header Files" FILES ${pfPython_HEADERS})
source_group("Glue Files" FILES ${pfPython_GLUE})
source_group("Game Glue" FILES ${pfPython_GAME_GLUE})
source_group("Game Glue\\TicTacToe" FILES ${pfPython_TTT})
source_group("Game Glue\\Heek" FILES ${pfPython_HEEK})
source_group("Game Glue\\Marker" FILES ${pfPython_MARKER})
source_group("Game Glue\\BlueSpiral" FILES ${pfPython_BSPIRAL})
source_group("Game Glue\\ClimbingWall" FILES ${pfPython_WALL})
source_group("Game Glue\\VarSync" FILES ${pfPython_VSYNC})

View File

@ -1,69 +1,69 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyBlueSpiralGame.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base BlueSpiral game client class
//
pyBlueSpiralGame::pyBlueSpiralGame(): pyGameCli() {}
pyBlueSpiralGame::pyBlueSpiralGame(pfGameCli* client): pyGameCli(client)
{
if (client && (client->GetGameTypeId() != kGameTypeId_BlueSpiral))
gameClient = nil; // wrong type, just clear it out
}
bool pyBlueSpiralGame::IsBlueSpiralGame(std::wstring guid)
{
Uuid gameUuid(guid.c_str());
return gameUuid == kGameTypeId_BlueSpiral;
}
void pyBlueSpiralGame::JoinCommonBlueSpiralGame(pyKey& callbackKey, unsigned gameID)
{
BlueSpiral_CreateParam init;
pfGameMgr::GetInstance()->JoinCommonGame(callbackKey.getKey(), kGameTypeId_BlueSpiral, gameID, sizeof(init), &init);
}
void pyBlueSpiralGame::StartGame()
{
if (gameClient)
{
pfGmBlueSpiral* blueSpiral = pfGmBlueSpiral::ConvertNoRef(gameClient);
blueSpiral->StartGame();
}
}
void pyBlueSpiralGame::HitCloth(int clothNum)
{
if (gameClient)
{
pfGmBlueSpiral* blueSpiral = pfGmBlueSpiral::ConvertNoRef(gameClient);
blueSpiral->HitCloth(clothNum);
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyBlueSpiralGame.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base BlueSpiral game client class
//
pyBlueSpiralGame::pyBlueSpiralGame(): pyGameCli() {}
pyBlueSpiralGame::pyBlueSpiralGame(pfGameCli* client): pyGameCli(client)
{
if (client && (client->GetGameTypeId() != kGameTypeId_BlueSpiral))
gameClient = nil; // wrong type, just clear it out
}
bool pyBlueSpiralGame::IsBlueSpiralGame(std::wstring guid)
{
Uuid gameUuid(guid.c_str());
return gameUuid == kGameTypeId_BlueSpiral;
}
void pyBlueSpiralGame::JoinCommonBlueSpiralGame(pyKey& callbackKey, unsigned gameID)
{
BlueSpiral_CreateParam init;
pfGameMgr::GetInstance()->JoinCommonGame(callbackKey.getKey(), kGameTypeId_BlueSpiral, gameID, sizeof(init), &init);
}
void pyBlueSpiralGame::StartGame()
{
if (gameClient)
{
pfGmBlueSpiral* blueSpiral = pfGmBlueSpiral::ConvertNoRef(gameClient);
blueSpiral->StartGame();
}
}
void pyBlueSpiralGame::HitCloth(int clothNum)
{
if (gameClient)
{
pfGmBlueSpiral* blueSpiral = pfGmBlueSpiral::ConvertNoRef(gameClient);
blueSpiral->HitCloth(clothNum);
}
}

View File

@ -1,66 +1,66 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyBlueSpiralGame_h
#define pyBlueSpiralGame_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: pyBlueSpiralGame
//
// PURPOSE: Class wrapper for the BlueSpiral game client
//
#include "pfGameMgr/pfGameMgr.h"
#include <python.h>
#include "../../pyGlueHelpers.h"
#include "../pyGameCli.h"
#include "../../pyKey.h"
class pyBlueSpiralGame : public pyGameCli
{
protected:
pyBlueSpiralGame();
pyBlueSpiralGame(pfGameCli* client);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptBlueSpiralGame);
static PyObject* New(pfGameCli* client);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyBlueSpiralGame object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyBlueSpiralGame); // converts a PyObject to a pyBlueSpiralGame (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaMethods(std::vector<PyMethodDef>& methods);
static bool IsBlueSpiralGame(std::wstring guid);
static void JoinCommonBlueSpiralGame(pyKey& callbackKey, unsigned gameID);
void StartGame();
void HitCloth(int clothNum);
};
#endif // pyBlueSpiralGame_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyBlueSpiralGame_h
#define pyBlueSpiralGame_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: pyBlueSpiralGame
//
// PURPOSE: Class wrapper for the BlueSpiral game client
//
#include "pfGameMgr/pfGameMgr.h"
#include <python.h>
#include "../../pyGlueHelpers.h"
#include "../pyGameCli.h"
#include "../../pyKey.h"
class pyBlueSpiralGame : public pyGameCli
{
protected:
pyBlueSpiralGame();
pyBlueSpiralGame(pfGameCli* client);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptBlueSpiralGame);
static PyObject* New(pfGameCli* client);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyBlueSpiralGame object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyBlueSpiralGame); // converts a PyObject to a pyBlueSpiralGame (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaMethods(std::vector<PyMethodDef>& methods);
static bool IsBlueSpiralGame(std::wstring guid);
static void JoinCommonBlueSpiralGame(pyKey& callbackKey, unsigned gameID);
void StartGame();
void HitCloth(int clothNum);
};
#endif // pyBlueSpiralGame_h

View File

@ -1,142 +1,142 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyBlueSpiralGame.h"
#include <python.h>
#include "../../pyEnum.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base BlueSpiral game client class
//
PYTHON_CLASS_DEFINITION(ptBlueSpiralGame, pyBlueSpiralGame);
PYTHON_DEFAULT_NEW_DEFINITION(ptBlueSpiralGame, pyBlueSpiralGame)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptBlueSpiralGame)
PYTHON_NO_INIT_DEFINITION(ptBlueSpiralGame)
PYTHON_GLOBAL_METHOD_DEFINITION(PtIsBlueSpiralGame, args, "Params: typeID\nReturns true if the specifed typeID (guid as a string) is a BlueSpiral game")
{
PyObject* textObj;
if (!PyArg_ParseTuple(args, "O", &textObj))
{
PyErr_SetString(PyExc_TypeError, "PtIsBlueSpiralGame expects a unicode string");
PYTHON_RETURN_ERROR;
}
if (PyUnicode_Check(textObj))
{
int strLen = PyUnicode_GetSize(textObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)textObj, text, strLen);
text[strLen] = L'\0';
bool retVal = pyBlueSpiralGame::IsBlueSpiralGame(text);
delete [] text;
PYTHON_RETURN_BOOL(retVal);
}
else if (PyString_Check(textObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(textObj);
wchar_t* wText = hsStringToWString(text);
bool retVal = pyBlueSpiralGame::IsBlueSpiralGame(wText);
delete [] wText;
PYTHON_RETURN_BOOL(retVal);
}
else
{
PyErr_SetString(PyExc_TypeError, "PtIsBlueSpiralGame expects a unicode string");
PYTHON_RETURN_ERROR;
}
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtJoinCommonBlueSpiralGame, args, "Params: callbackKey, gameID\nJoins a common BlueSpiral game with the specified ID. If one doesn't exist, it creates it")
{
PyObject* callbackObj = NULL;
int gameID = 0;
if (!PyArg_ParseTuple(args, "Oi", &callbackObj, &gameID))
{
PyErr_SetString(PyExc_TypeError, "PtJoinCommonBlueSpiralGame expects a ptKey and an integer");
PYTHON_RETURN_ERROR;
}
if (!pyKey::Check(callbackObj))
{
PyErr_SetString(PyExc_TypeError, "PtJoinCommonBlueSpiralGame expects a ptKey and an integer");
PYTHON_RETURN_ERROR;
}
pyKey* key = pyKey::ConvertFrom(callbackObj);
pyBlueSpiralGame::JoinCommonBlueSpiralGame(*key, gameID);
PYTHON_RETURN_NONE;
}
PYTHON_BASIC_METHOD_DEFINITION(ptBlueSpiralGame, startGame, StartGame)
PYTHON_METHOD_DEFINITION(ptBlueSpiralGame, hitCloth, args)
{
int clothNum = 0;
if (!PyArg_ParseTuple(args, "i", &clothNum))
{
PyErr_SetString(PyExc_TypeError, "hitCloth expects one integer");
PYTHON_RETURN_ERROR;
}
self->fThis->HitCloth(clothNum);
PYTHON_RETURN_NONE;
}
PYTHON_START_METHODS_TABLE(ptBlueSpiralGame)
PYTHON_BASIC_METHOD(ptBlueSpiralGame, startGame, "Starts a new game"),
PYTHON_METHOD(ptBlueSpiralGame, hitCloth, "Params: clothNum\nTells the server you hit the specified cloth"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptBlueSpiralGame, pyGameCli, "Game client for the BlueSpiral game");
// required functions for PyObject interoperability
PyObject* pyBlueSpiralGame::New(pfGameCli* client)
{
ptBlueSpiralGame *newObj = (ptBlueSpiralGame*)ptBlueSpiralGame_type.tp_new(&ptBlueSpiralGame_type, NULL, NULL);
if (client && (client->GetGameTypeId() == kGameTypeId_BlueSpiral))
newObj->fThis->gameClient = client;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptBlueSpiralGame, pyBlueSpiralGame)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptBlueSpiralGame, pyBlueSpiralGame)
// Module and method definitions
void pyBlueSpiralGame::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptBlueSpiralGame);
PYTHON_CLASS_IMPORT_END(m);
}
void pyBlueSpiralGame::AddPlasmaMethods(std::vector<PyMethodDef>& methods)
{
PYTHON_GLOBAL_METHOD(methods, PtIsBlueSpiralGame);
PYTHON_GLOBAL_METHOD(methods, PtJoinCommonBlueSpiralGame);
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyBlueSpiralGame.h"
#include <python.h>
#include "../../pyEnum.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base BlueSpiral game client class
//
PYTHON_CLASS_DEFINITION(ptBlueSpiralGame, pyBlueSpiralGame);
PYTHON_DEFAULT_NEW_DEFINITION(ptBlueSpiralGame, pyBlueSpiralGame)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptBlueSpiralGame)
PYTHON_NO_INIT_DEFINITION(ptBlueSpiralGame)
PYTHON_GLOBAL_METHOD_DEFINITION(PtIsBlueSpiralGame, args, "Params: typeID\nReturns true if the specifed typeID (guid as a string) is a BlueSpiral game")
{
PyObject* textObj;
if (!PyArg_ParseTuple(args, "O", &textObj))
{
PyErr_SetString(PyExc_TypeError, "PtIsBlueSpiralGame expects a unicode string");
PYTHON_RETURN_ERROR;
}
if (PyUnicode_Check(textObj))
{
int strLen = PyUnicode_GetSize(textObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)textObj, text, strLen);
text[strLen] = L'\0';
bool retVal = pyBlueSpiralGame::IsBlueSpiralGame(text);
delete [] text;
PYTHON_RETURN_BOOL(retVal);
}
else if (PyString_Check(textObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(textObj);
wchar_t* wText = hsStringToWString(text);
bool retVal = pyBlueSpiralGame::IsBlueSpiralGame(wText);
delete [] wText;
PYTHON_RETURN_BOOL(retVal);
}
else
{
PyErr_SetString(PyExc_TypeError, "PtIsBlueSpiralGame expects a unicode string");
PYTHON_RETURN_ERROR;
}
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtJoinCommonBlueSpiralGame, args, "Params: callbackKey, gameID\nJoins a common BlueSpiral game with the specified ID. If one doesn't exist, it creates it")
{
PyObject* callbackObj = NULL;
int gameID = 0;
if (!PyArg_ParseTuple(args, "Oi", &callbackObj, &gameID))
{
PyErr_SetString(PyExc_TypeError, "PtJoinCommonBlueSpiralGame expects a ptKey and an integer");
PYTHON_RETURN_ERROR;
}
if (!pyKey::Check(callbackObj))
{
PyErr_SetString(PyExc_TypeError, "PtJoinCommonBlueSpiralGame expects a ptKey and an integer");
PYTHON_RETURN_ERROR;
}
pyKey* key = pyKey::ConvertFrom(callbackObj);
pyBlueSpiralGame::JoinCommonBlueSpiralGame(*key, gameID);
PYTHON_RETURN_NONE;
}
PYTHON_BASIC_METHOD_DEFINITION(ptBlueSpiralGame, startGame, StartGame)
PYTHON_METHOD_DEFINITION(ptBlueSpiralGame, hitCloth, args)
{
int clothNum = 0;
if (!PyArg_ParseTuple(args, "i", &clothNum))
{
PyErr_SetString(PyExc_TypeError, "hitCloth expects one integer");
PYTHON_RETURN_ERROR;
}
self->fThis->HitCloth(clothNum);
PYTHON_RETURN_NONE;
}
PYTHON_START_METHODS_TABLE(ptBlueSpiralGame)
PYTHON_BASIC_METHOD(ptBlueSpiralGame, startGame, "Starts a new game"),
PYTHON_METHOD(ptBlueSpiralGame, hitCloth, "Params: clothNum\nTells the server you hit the specified cloth"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptBlueSpiralGame, pyGameCli, "Game client for the BlueSpiral game");
// required functions for PyObject interoperability
PyObject* pyBlueSpiralGame::New(pfGameCli* client)
{
ptBlueSpiralGame *newObj = (ptBlueSpiralGame*)ptBlueSpiralGame_type.tp_new(&ptBlueSpiralGame_type, NULL, NULL);
if (client && (client->GetGameTypeId() == kGameTypeId_BlueSpiral))
newObj->fThis->gameClient = client;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptBlueSpiralGame, pyBlueSpiralGame)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptBlueSpiralGame, pyBlueSpiralGame)
// Module and method definitions
void pyBlueSpiralGame::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptBlueSpiralGame);
PYTHON_CLASS_IMPORT_END(m);
}
void pyBlueSpiralGame::AddPlasmaMethods(std::vector<PyMethodDef>& methods)
{
PYTHON_GLOBAL_METHOD(methods, PtIsBlueSpiralGame);
PYTHON_GLOBAL_METHOD(methods, PtJoinCommonBlueSpiralGame);
}

View File

@ -1,139 +1,139 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyBlueSpiralMsg.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base BlueSpiral msg class
//
pyBlueSpiralMsg::pyBlueSpiralMsg(): pyGameCliMsg() {}
pyBlueSpiralMsg::pyBlueSpiralMsg(pfGameCliMsg* msg): pyGameCliMsg(msg)
{
if (message && (message->gameCli->GetGameTypeId() != kGameTypeId_BlueSpiral))
message = nil; // wrong type, just clear it out
}
int pyBlueSpiralMsg::GetBlueSpiralMsgType() const
{
if (message)
return message->netMsg->messageId;
return -1;
}
PyObject* pyBlueSpiralMsg::UpcastToFinalBlueSpiralMsg() const
{
if (!message)
PYTHON_RETURN_NONE;
switch (message->netMsg->messageId)
{
case kSrv2Cli_BlueSpiral_ClothOrder:
return pyBlueSpiralClothOrderMsg::New(message);
case kSrv2Cli_BlueSpiral_SuccessfulHit:
return pyBlueSpiralSuccessfulHitMsg::New(message);
case kSrv2Cli_BlueSpiral_GameWon:
return pyBlueSpiralGameWonMsg::New(message);
case kSrv2Cli_BlueSpiral_GameOver:
return pyBlueSpiralGameOverMsg::New(message);
case kSrv2Cli_BlueSpiral_GameStarted:
return pyBlueSpiralGameStartedMsg::New(message);
default:
PYTHON_RETURN_NONE;
}
}
///////////////////////////////////////////////////////////////////////////////
//
// The different messages we can receive
//
pyBlueSpiralClothOrderMsg::pyBlueSpiralClothOrderMsg(): pyBlueSpiralMsg() {}
pyBlueSpiralClothOrderMsg::pyBlueSpiralClothOrderMsg(pfGameCliMsg* msg): pyBlueSpiralMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_BlueSpiral_ClothOrder))
message = nil; // wrong type, just clear it out
}
std::vector<int> pyBlueSpiralClothOrderMsg::Order()
{
std::vector<int> retVal;
if (message)
{
const Srv2Cli_BlueSpiral_ClothOrder* gmMsg = (const Srv2Cli_BlueSpiral_ClothOrder*)message->netMsg;
for (int i = 0; i < arrsize(gmMsg->order); ++i)
retVal.push_back(gmMsg->order[i]);
}
return retVal;
}
///////////////////////////////////////////////////////////////////////////////
pyBlueSpiralSuccessfulHitMsg::pyBlueSpiralSuccessfulHitMsg(): pyBlueSpiralMsg() {}
pyBlueSpiralSuccessfulHitMsg::pyBlueSpiralSuccessfulHitMsg(pfGameCliMsg* msg): pyBlueSpiralMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_BlueSpiral_SuccessfulHit))
message = nil; // wrong type, just clear it out
}
///////////////////////////////////////////////////////////////////////////////
pyBlueSpiralGameWonMsg::pyBlueSpiralGameWonMsg(): pyBlueSpiralMsg() {}
pyBlueSpiralGameWonMsg::pyBlueSpiralGameWonMsg(pfGameCliMsg* msg): pyBlueSpiralMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_BlueSpiral_GameWon))
message = nil; // wrong type, just clear it out
}
///////////////////////////////////////////////////////////////////////////////
pyBlueSpiralGameOverMsg::pyBlueSpiralGameOverMsg(): pyBlueSpiralMsg() {}
pyBlueSpiralGameOverMsg::pyBlueSpiralGameOverMsg(pfGameCliMsg* msg): pyBlueSpiralMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_BlueSpiral_GameOver))
message = nil; // wrong type, just clear it out
}
///////////////////////////////////////////////////////////////////////////////
pyBlueSpiralGameStartedMsg::pyBlueSpiralGameStartedMsg(): pyBlueSpiralMsg() {}
pyBlueSpiralGameStartedMsg::pyBlueSpiralGameStartedMsg(pfGameCliMsg* msg): pyBlueSpiralMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_BlueSpiral_GameStarted))
message = nil; // wrong type, just clear it out
}
bool pyBlueSpiralGameStartedMsg::StartSpin()
{
if (message)
{
const Srv2Cli_BlueSpiral_GameStarted* gmMsg = (const Srv2Cli_BlueSpiral_GameStarted*)message->netMsg;
return gmMsg->startSpin;
}
return false;
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyBlueSpiralMsg.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base BlueSpiral msg class
//
pyBlueSpiralMsg::pyBlueSpiralMsg(): pyGameCliMsg() {}
pyBlueSpiralMsg::pyBlueSpiralMsg(pfGameCliMsg* msg): pyGameCliMsg(msg)
{
if (message && (message->gameCli->GetGameTypeId() != kGameTypeId_BlueSpiral))
message = nil; // wrong type, just clear it out
}
int pyBlueSpiralMsg::GetBlueSpiralMsgType() const
{
if (message)
return message->netMsg->messageId;
return -1;
}
PyObject* pyBlueSpiralMsg::UpcastToFinalBlueSpiralMsg() const
{
if (!message)
PYTHON_RETURN_NONE;
switch (message->netMsg->messageId)
{
case kSrv2Cli_BlueSpiral_ClothOrder:
return pyBlueSpiralClothOrderMsg::New(message);
case kSrv2Cli_BlueSpiral_SuccessfulHit:
return pyBlueSpiralSuccessfulHitMsg::New(message);
case kSrv2Cli_BlueSpiral_GameWon:
return pyBlueSpiralGameWonMsg::New(message);
case kSrv2Cli_BlueSpiral_GameOver:
return pyBlueSpiralGameOverMsg::New(message);
case kSrv2Cli_BlueSpiral_GameStarted:
return pyBlueSpiralGameStartedMsg::New(message);
default:
PYTHON_RETURN_NONE;
}
}
///////////////////////////////////////////////////////////////////////////////
//
// The different messages we can receive
//
pyBlueSpiralClothOrderMsg::pyBlueSpiralClothOrderMsg(): pyBlueSpiralMsg() {}
pyBlueSpiralClothOrderMsg::pyBlueSpiralClothOrderMsg(pfGameCliMsg* msg): pyBlueSpiralMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_BlueSpiral_ClothOrder))
message = nil; // wrong type, just clear it out
}
std::vector<int> pyBlueSpiralClothOrderMsg::Order()
{
std::vector<int> retVal;
if (message)
{
const Srv2Cli_BlueSpiral_ClothOrder* gmMsg = (const Srv2Cli_BlueSpiral_ClothOrder*)message->netMsg;
for (int i = 0; i < arrsize(gmMsg->order); ++i)
retVal.push_back(gmMsg->order[i]);
}
return retVal;
}
///////////////////////////////////////////////////////////////////////////////
pyBlueSpiralSuccessfulHitMsg::pyBlueSpiralSuccessfulHitMsg(): pyBlueSpiralMsg() {}
pyBlueSpiralSuccessfulHitMsg::pyBlueSpiralSuccessfulHitMsg(pfGameCliMsg* msg): pyBlueSpiralMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_BlueSpiral_SuccessfulHit))
message = nil; // wrong type, just clear it out
}
///////////////////////////////////////////////////////////////////////////////
pyBlueSpiralGameWonMsg::pyBlueSpiralGameWonMsg(): pyBlueSpiralMsg() {}
pyBlueSpiralGameWonMsg::pyBlueSpiralGameWonMsg(pfGameCliMsg* msg): pyBlueSpiralMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_BlueSpiral_GameWon))
message = nil; // wrong type, just clear it out
}
///////////////////////////////////////////////////////////////////////////////
pyBlueSpiralGameOverMsg::pyBlueSpiralGameOverMsg(): pyBlueSpiralMsg() {}
pyBlueSpiralGameOverMsg::pyBlueSpiralGameOverMsg(pfGameCliMsg* msg): pyBlueSpiralMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_BlueSpiral_GameOver))
message = nil; // wrong type, just clear it out
}
///////////////////////////////////////////////////////////////////////////////
pyBlueSpiralGameStartedMsg::pyBlueSpiralGameStartedMsg(): pyBlueSpiralMsg() {}
pyBlueSpiralGameStartedMsg::pyBlueSpiralGameStartedMsg(pfGameCliMsg* msg): pyBlueSpiralMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_BlueSpiral_GameStarted))
message = nil; // wrong type, just clear it out
}
bool pyBlueSpiralGameStartedMsg::StartSpin()
{
if (message)
{
const Srv2Cli_BlueSpiral_GameStarted* gmMsg = (const Srv2Cli_BlueSpiral_GameStarted*)message->netMsg;
return gmMsg->startSpin;
}
return false;
}

View File

@ -1,153 +1,153 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyBlueSpiralMsg_h
#define pyBlueSpiralMsg_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: pyBlueSpiralMsg
//
// PURPOSE: Class wrapper for BlueSpiral game messages
//
#include "pfGameMgr/pfGameMgr.h"
#include <python.h>
#include "../../pyGlueHelpers.h"
#include "../pyGameCliMsg.h"
class pyBlueSpiralMsg : public pyGameCliMsg
{
protected:
pyBlueSpiralMsg();
pyBlueSpiralMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_EXPOSE_TYPE; // so we can subclass
PYTHON_CLASS_NEW_FRIEND(ptBlueSpiralMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyBlueSpiralMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyBlueSpiralMsg); // converts a PyObject to a pyBlueSpiralMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaConstantsClasses(PyObject* m);
int GetBlueSpiralMsgType() const;
PyObject* UpcastToFinalBlueSpiralMsg() const; // returns this message as the blue spiral message it is
};
///////////////////////////////////////////////////////////////////////////////
class pyBlueSpiralClothOrderMsg : public pyBlueSpiralMsg
{
protected:
pyBlueSpiralClothOrderMsg();
pyBlueSpiralClothOrderMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptBlueSpiralClothOrderMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyBlueSpiralClothOrderMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyBlueSpiralClothOrderMsg); // converts a PyObject to a pyBlueSpiralClothOrderMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
std::vector<int> Order();
};
///////////////////////////////////////////////////////////////////////////////
class pyBlueSpiralSuccessfulHitMsg : public pyBlueSpiralMsg
{
protected:
pyBlueSpiralSuccessfulHitMsg();
pyBlueSpiralSuccessfulHitMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptBlueSpiralSuccessfulHitMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyBlueSpiralSuccessfulHitMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyBlueSpiralSuccessfulHitMsg); // converts a PyObject to a pyBlueSpiralSuccessfulHitMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
};
///////////////////////////////////////////////////////////////////////////////
class pyBlueSpiralGameWonMsg : public pyBlueSpiralMsg
{
protected:
pyBlueSpiralGameWonMsg();
pyBlueSpiralGameWonMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptBlueSpiralGameWonMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyBlueSpiralGameWonMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyBlueSpiralGameWonMsg); // converts a PyObject to a pyBlueSpiralGameWonMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
};
///////////////////////////////////////////////////////////////////////////////
class pyBlueSpiralGameOverMsg : public pyBlueSpiralMsg
{
protected:
pyBlueSpiralGameOverMsg();
pyBlueSpiralGameOverMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptBlueSpiralGameOverMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyBlueSpiralGameOverMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyBlueSpiralGameOverMsg); // converts a PyObject to a pyBlueSpiralGameOverMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
};
///////////////////////////////////////////////////////////////////////////////
class pyBlueSpiralGameStartedMsg : public pyBlueSpiralMsg
{
protected:
pyBlueSpiralGameStartedMsg();
pyBlueSpiralGameStartedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptBlueSpiralGameStartedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyBlueSpiralGameStartedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyBlueSpiralGameStartedMsg); // converts a PyObject to a pyBlueSpiralGameStartedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
bool StartSpin();
};
#endif // pyBlueSpiralMsg_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyBlueSpiralMsg_h
#define pyBlueSpiralMsg_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: pyBlueSpiralMsg
//
// PURPOSE: Class wrapper for BlueSpiral game messages
//
#include "pfGameMgr/pfGameMgr.h"
#include <python.h>
#include "../../pyGlueHelpers.h"
#include "../pyGameCliMsg.h"
class pyBlueSpiralMsg : public pyGameCliMsg
{
protected:
pyBlueSpiralMsg();
pyBlueSpiralMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_EXPOSE_TYPE; // so we can subclass
PYTHON_CLASS_NEW_FRIEND(ptBlueSpiralMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyBlueSpiralMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyBlueSpiralMsg); // converts a PyObject to a pyBlueSpiralMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaConstantsClasses(PyObject* m);
int GetBlueSpiralMsgType() const;
PyObject* UpcastToFinalBlueSpiralMsg() const; // returns this message as the blue spiral message it is
};
///////////////////////////////////////////////////////////////////////////////
class pyBlueSpiralClothOrderMsg : public pyBlueSpiralMsg
{
protected:
pyBlueSpiralClothOrderMsg();
pyBlueSpiralClothOrderMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptBlueSpiralClothOrderMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyBlueSpiralClothOrderMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyBlueSpiralClothOrderMsg); // converts a PyObject to a pyBlueSpiralClothOrderMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
std::vector<int> Order();
};
///////////////////////////////////////////////////////////////////////////////
class pyBlueSpiralSuccessfulHitMsg : public pyBlueSpiralMsg
{
protected:
pyBlueSpiralSuccessfulHitMsg();
pyBlueSpiralSuccessfulHitMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptBlueSpiralSuccessfulHitMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyBlueSpiralSuccessfulHitMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyBlueSpiralSuccessfulHitMsg); // converts a PyObject to a pyBlueSpiralSuccessfulHitMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
};
///////////////////////////////////////////////////////////////////////////////
class pyBlueSpiralGameWonMsg : public pyBlueSpiralMsg
{
protected:
pyBlueSpiralGameWonMsg();
pyBlueSpiralGameWonMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptBlueSpiralGameWonMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyBlueSpiralGameWonMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyBlueSpiralGameWonMsg); // converts a PyObject to a pyBlueSpiralGameWonMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
};
///////////////////////////////////////////////////////////////////////////////
class pyBlueSpiralGameOverMsg : public pyBlueSpiralMsg
{
protected:
pyBlueSpiralGameOverMsg();
pyBlueSpiralGameOverMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptBlueSpiralGameOverMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyBlueSpiralGameOverMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyBlueSpiralGameOverMsg); // converts a PyObject to a pyBlueSpiralGameOverMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
};
///////////////////////////////////////////////////////////////////////////////
class pyBlueSpiralGameStartedMsg : public pyBlueSpiralMsg
{
protected:
pyBlueSpiralGameStartedMsg();
pyBlueSpiralGameStartedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptBlueSpiralGameStartedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyBlueSpiralGameStartedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyBlueSpiralGameStartedMsg); // converts a PyObject to a pyBlueSpiralGameStartedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
bool StartSpin();
};
#endif // pyBlueSpiralMsg_h

View File

@ -1,281 +1,281 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyBlueSpiralMsg.h"
#include "../../pyEnum.h"
#include <python.h>
///////////////////////////////////////////////////////////////////////////////
//
// Base TTT msg class
//
PYTHON_CLASS_DEFINITION(ptBlueSpiralMsg, pyBlueSpiralMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptBlueSpiralMsg, pyBlueSpiralMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptBlueSpiralMsg)
PYTHON_NO_INIT_DEFINITION(ptBlueSpiralMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptBlueSpiralMsg, getBlueSpiralMsgType)
{
return PyInt_FromLong(self->fThis->GetBlueSpiralMsgType());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptBlueSpiralMsg, upcastToFinalBlueSpiralMsg)
{
return self->fThis->UpcastToFinalBlueSpiralMsg();
}
PYTHON_START_METHODS_TABLE(ptBlueSpiralMsg)
PYTHON_METHOD_NOARGS(ptBlueSpiralMsg, getBlueSpiralMsgType, "Returns the type of the BlueSpiral message (see PtBlueSpiralMsgTypes)"),
PYTHON_METHOD_NOARGS(ptBlueSpiralMsg, upcastToFinalBlueSpiralMsg, "Returns this message as the BlueSpiral message it really is"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptBlueSpiralMsg, pyGameCliMsg, "Base class for BlueSpiral game messages");
PYTHON_EXPOSE_TYPE_DEFINITION(ptBlueSpiralMsg, pyBlueSpiralMsg);
// required functions for PyObject interoperability
PyObject* pyBlueSpiralMsg::New(pfGameCliMsg* msg)
{
ptBlueSpiralMsg *newObj = (ptBlueSpiralMsg*)ptBlueSpiralMsg_type.tp_new(&ptBlueSpiralMsg_type, NULL, NULL);
if (msg && (msg->gameCli->GetGameTypeId() == kGameTypeId_BlueSpiral))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptBlueSpiralMsg, pyBlueSpiralMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptBlueSpiralMsg, pyBlueSpiralMsg)
// Module and method definitions
void pyBlueSpiralMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptBlueSpiralMsg);
PYTHON_CLASS_IMPORT_END(m);
}
void pyBlueSpiralMsg::AddPlasmaConstantsClasses(PyObject* m)
{
PYTHON_ENUM_START(PtBlueSpiralMsgTypes);
PYTHON_ENUM_ELEMENT(PtBlueSpiralMsgTypes, kBlueSpiralClothOrder, kSrv2Cli_BlueSpiral_ClothOrder);
PYTHON_ENUM_ELEMENT(PtBlueSpiralMsgTypes, kBlueSpiralSuccessfulHit, kSrv2Cli_BlueSpiral_SuccessfulHit);
PYTHON_ENUM_ELEMENT(PtBlueSpiralMsgTypes, kBlueSpiralGameWon, kSrv2Cli_BlueSpiral_GameWon);
PYTHON_ENUM_ELEMENT(PtBlueSpiralMsgTypes, kBlueSpiralGameOver, kSrv2Cli_BlueSpiral_GameOver);
PYTHON_ENUM_ELEMENT(PtBlueSpiralMsgTypes, kBlueSpiralGameStarted, kSrv2Cli_BlueSpiral_GameStarted);
PYTHON_ENUM_END(m, PtBlueSpiralMsgTypes);
}
///////////////////////////////////////////////////////////////////////////////
//
// Game client message subclasses
//
PYTHON_CLASS_DEFINITION(ptBlueSpiralClothOrderMsg, pyBlueSpiralClothOrderMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptBlueSpiralClothOrderMsg, pyBlueSpiralClothOrderMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptBlueSpiralClothOrderMsg)
PYTHON_NO_INIT_DEFINITION(ptBlueSpiralClothOrderMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptBlueSpiralClothOrderMsg, order)
{
std::vector<int> order = self->fThis->Order();
PyObject* retVal = PyList_New(order.size());
for (unsigned i = 0; i < order.size(); ++i)
PyList_SetItem(retVal, i, PyInt_FromLong(order[i]));
return retVal;
}
PYTHON_START_METHODS_TABLE(ptBlueSpiralClothOrderMsg)
PYTHON_METHOD_NOARGS(ptBlueSpiralClothOrderMsg, order, "Returns a list of numbers indicating the correct order to hit the clothes in"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptBlueSpiralClothOrderMsg, pyBlueSpiralMsg, "BlueSpiral message received when the game is started and the cloth order is set");
// required functions for PyObject interoperability
PyObject* pyBlueSpiralClothOrderMsg::New(pfGameCliMsg* msg)
{
ptBlueSpiralClothOrderMsg *newObj = (ptBlueSpiralClothOrderMsg*)ptBlueSpiralClothOrderMsg_type.tp_new(&ptBlueSpiralClothOrderMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_BlueSpiral_ClothOrder))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptBlueSpiralClothOrderMsg, pyBlueSpiralClothOrderMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptBlueSpiralClothOrderMsg, pyBlueSpiralClothOrderMsg)
// Module and method definitions
void pyBlueSpiralClothOrderMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptBlueSpiralClothOrderMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptBlueSpiralSuccessfulHitMsg, pyBlueSpiralSuccessfulHitMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptBlueSpiralSuccessfulHitMsg, pyBlueSpiralSuccessfulHitMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptBlueSpiralSuccessfulHitMsg)
PYTHON_NO_INIT_DEFINITION(ptBlueSpiralSuccessfulHitMsg)
PYTHON_START_METHODS_TABLE(ptBlueSpiralSuccessfulHitMsg)
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptBlueSpiralSuccessfulHitMsg, pyBlueSpiralMsg, "BlueSpiral message received when a cloth is hit in the correct order");
// required functions for PyObject interoperability
PyObject* pyBlueSpiralSuccessfulHitMsg::New(pfGameCliMsg* msg)
{
ptBlueSpiralSuccessfulHitMsg *newObj = (ptBlueSpiralSuccessfulHitMsg*)ptBlueSpiralSuccessfulHitMsg_type.tp_new(&ptBlueSpiralSuccessfulHitMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_BlueSpiral_SuccessfulHit))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptBlueSpiralSuccessfulHitMsg, pyBlueSpiralSuccessfulHitMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptBlueSpiralSuccessfulHitMsg, pyBlueSpiralSuccessfulHitMsg)
// Module and method definitions
void pyBlueSpiralSuccessfulHitMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptBlueSpiralSuccessfulHitMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptBlueSpiralGameWonMsg, pyBlueSpiralGameWonMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptBlueSpiralGameWonMsg, pyBlueSpiralGameWonMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptBlueSpiralGameWonMsg)
PYTHON_NO_INIT_DEFINITION(ptBlueSpiralGameWonMsg)
PYTHON_START_METHODS_TABLE(ptBlueSpiralGameWonMsg)
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptBlueSpiralGameWonMsg, pyBlueSpiralMsg, "BlueSpiral message received when the last cloth is successfully hit");
// required functions for PyObject interoperability
PyObject* pyBlueSpiralGameWonMsg::New(pfGameCliMsg* msg)
{
ptBlueSpiralGameWonMsg *newObj = (ptBlueSpiralGameWonMsg*)ptBlueSpiralGameWonMsg_type.tp_new(&ptBlueSpiralGameWonMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_BlueSpiral_GameWon))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptBlueSpiralGameWonMsg, pyBlueSpiralGameWonMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptBlueSpiralGameWonMsg, pyBlueSpiralGameWonMsg)
// Module and method definitions
void pyBlueSpiralGameWonMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptBlueSpiralGameWonMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptBlueSpiralGameOverMsg, pyBlueSpiralGameOverMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptBlueSpiralGameOverMsg, pyBlueSpiralGameOverMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptBlueSpiralGameOverMsg)
PYTHON_NO_INIT_DEFINITION(ptBlueSpiralGameOverMsg)
PYTHON_START_METHODS_TABLE(ptBlueSpiralGameOverMsg)
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptBlueSpiralGameOverMsg, pyBlueSpiralMsg, "BlueSpiral message received when the timer runs out, someone hits the wrong cloth, or the game is restarted (before a game start msg in that last case)");
// required functions for PyObject interoperability
PyObject* pyBlueSpiralGameOverMsg::New(pfGameCliMsg* msg)
{
ptBlueSpiralGameOverMsg *newObj = (ptBlueSpiralGameOverMsg*)ptBlueSpiralGameOverMsg_type.tp_new(&ptBlueSpiralGameOverMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_BlueSpiral_GameOver))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptBlueSpiralGameOverMsg, pyBlueSpiralGameOverMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptBlueSpiralGameOverMsg, pyBlueSpiralGameOverMsg)
// Module and method definitions
void pyBlueSpiralGameOverMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptBlueSpiralGameOverMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptBlueSpiralGameStartedMsg, pyBlueSpiralGameStartedMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptBlueSpiralGameStartedMsg, pyBlueSpiralGameStartedMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptBlueSpiralGameStartedMsg)
PYTHON_NO_INIT_DEFINITION(ptBlueSpiralGameStartedMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptBlueSpiralGameStartedMsg, startSpin)
{
PYTHON_RETURN_BOOL(self->fThis->StartSpin());
}
PYTHON_START_METHODS_TABLE(ptBlueSpiralGameStartedMsg)
PYTHON_METHOD_NOARGS(ptBlueSpiralGameStartedMsg, startSpin, "Returns true if you are supposed to start spinning the door thingy"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptBlueSpiralGameStartedMsg, pyBlueSpiralMsg, "BlueSpiral message received when someone starts the game (or when you join a game that is running)");
// required functions for PyObject interoperability
PyObject* pyBlueSpiralGameStartedMsg::New(pfGameCliMsg* msg)
{
ptBlueSpiralGameStartedMsg *newObj = (ptBlueSpiralGameStartedMsg*)ptBlueSpiralGameStartedMsg_type.tp_new(&ptBlueSpiralGameStartedMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_BlueSpiral_GameStarted))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptBlueSpiralGameStartedMsg, pyBlueSpiralGameStartedMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptBlueSpiralGameStartedMsg, pyBlueSpiralGameStartedMsg)
// Module and method definitions
void pyBlueSpiralGameStartedMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptBlueSpiralGameStartedMsg);
PYTHON_CLASS_IMPORT_END(m);
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyBlueSpiralMsg.h"
#include "../../pyEnum.h"
#include <python.h>
///////////////////////////////////////////////////////////////////////////////
//
// Base TTT msg class
//
PYTHON_CLASS_DEFINITION(ptBlueSpiralMsg, pyBlueSpiralMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptBlueSpiralMsg, pyBlueSpiralMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptBlueSpiralMsg)
PYTHON_NO_INIT_DEFINITION(ptBlueSpiralMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptBlueSpiralMsg, getBlueSpiralMsgType)
{
return PyInt_FromLong(self->fThis->GetBlueSpiralMsgType());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptBlueSpiralMsg, upcastToFinalBlueSpiralMsg)
{
return self->fThis->UpcastToFinalBlueSpiralMsg();
}
PYTHON_START_METHODS_TABLE(ptBlueSpiralMsg)
PYTHON_METHOD_NOARGS(ptBlueSpiralMsg, getBlueSpiralMsgType, "Returns the type of the BlueSpiral message (see PtBlueSpiralMsgTypes)"),
PYTHON_METHOD_NOARGS(ptBlueSpiralMsg, upcastToFinalBlueSpiralMsg, "Returns this message as the BlueSpiral message it really is"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptBlueSpiralMsg, pyGameCliMsg, "Base class for BlueSpiral game messages");
PYTHON_EXPOSE_TYPE_DEFINITION(ptBlueSpiralMsg, pyBlueSpiralMsg);
// required functions for PyObject interoperability
PyObject* pyBlueSpiralMsg::New(pfGameCliMsg* msg)
{
ptBlueSpiralMsg *newObj = (ptBlueSpiralMsg*)ptBlueSpiralMsg_type.tp_new(&ptBlueSpiralMsg_type, NULL, NULL);
if (msg && (msg->gameCli->GetGameTypeId() == kGameTypeId_BlueSpiral))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptBlueSpiralMsg, pyBlueSpiralMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptBlueSpiralMsg, pyBlueSpiralMsg)
// Module and method definitions
void pyBlueSpiralMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptBlueSpiralMsg);
PYTHON_CLASS_IMPORT_END(m);
}
void pyBlueSpiralMsg::AddPlasmaConstantsClasses(PyObject* m)
{
PYTHON_ENUM_START(PtBlueSpiralMsgTypes);
PYTHON_ENUM_ELEMENT(PtBlueSpiralMsgTypes, kBlueSpiralClothOrder, kSrv2Cli_BlueSpiral_ClothOrder);
PYTHON_ENUM_ELEMENT(PtBlueSpiralMsgTypes, kBlueSpiralSuccessfulHit, kSrv2Cli_BlueSpiral_SuccessfulHit);
PYTHON_ENUM_ELEMENT(PtBlueSpiralMsgTypes, kBlueSpiralGameWon, kSrv2Cli_BlueSpiral_GameWon);
PYTHON_ENUM_ELEMENT(PtBlueSpiralMsgTypes, kBlueSpiralGameOver, kSrv2Cli_BlueSpiral_GameOver);
PYTHON_ENUM_ELEMENT(PtBlueSpiralMsgTypes, kBlueSpiralGameStarted, kSrv2Cli_BlueSpiral_GameStarted);
PYTHON_ENUM_END(m, PtBlueSpiralMsgTypes);
}
///////////////////////////////////////////////////////////////////////////////
//
// Game client message subclasses
//
PYTHON_CLASS_DEFINITION(ptBlueSpiralClothOrderMsg, pyBlueSpiralClothOrderMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptBlueSpiralClothOrderMsg, pyBlueSpiralClothOrderMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptBlueSpiralClothOrderMsg)
PYTHON_NO_INIT_DEFINITION(ptBlueSpiralClothOrderMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptBlueSpiralClothOrderMsg, order)
{
std::vector<int> order = self->fThis->Order();
PyObject* retVal = PyList_New(order.size());
for (unsigned i = 0; i < order.size(); ++i)
PyList_SetItem(retVal, i, PyInt_FromLong(order[i]));
return retVal;
}
PYTHON_START_METHODS_TABLE(ptBlueSpiralClothOrderMsg)
PYTHON_METHOD_NOARGS(ptBlueSpiralClothOrderMsg, order, "Returns a list of numbers indicating the correct order to hit the clothes in"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptBlueSpiralClothOrderMsg, pyBlueSpiralMsg, "BlueSpiral message received when the game is started and the cloth order is set");
// required functions for PyObject interoperability
PyObject* pyBlueSpiralClothOrderMsg::New(pfGameCliMsg* msg)
{
ptBlueSpiralClothOrderMsg *newObj = (ptBlueSpiralClothOrderMsg*)ptBlueSpiralClothOrderMsg_type.tp_new(&ptBlueSpiralClothOrderMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_BlueSpiral_ClothOrder))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptBlueSpiralClothOrderMsg, pyBlueSpiralClothOrderMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptBlueSpiralClothOrderMsg, pyBlueSpiralClothOrderMsg)
// Module and method definitions
void pyBlueSpiralClothOrderMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptBlueSpiralClothOrderMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptBlueSpiralSuccessfulHitMsg, pyBlueSpiralSuccessfulHitMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptBlueSpiralSuccessfulHitMsg, pyBlueSpiralSuccessfulHitMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptBlueSpiralSuccessfulHitMsg)
PYTHON_NO_INIT_DEFINITION(ptBlueSpiralSuccessfulHitMsg)
PYTHON_START_METHODS_TABLE(ptBlueSpiralSuccessfulHitMsg)
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptBlueSpiralSuccessfulHitMsg, pyBlueSpiralMsg, "BlueSpiral message received when a cloth is hit in the correct order");
// required functions for PyObject interoperability
PyObject* pyBlueSpiralSuccessfulHitMsg::New(pfGameCliMsg* msg)
{
ptBlueSpiralSuccessfulHitMsg *newObj = (ptBlueSpiralSuccessfulHitMsg*)ptBlueSpiralSuccessfulHitMsg_type.tp_new(&ptBlueSpiralSuccessfulHitMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_BlueSpiral_SuccessfulHit))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptBlueSpiralSuccessfulHitMsg, pyBlueSpiralSuccessfulHitMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptBlueSpiralSuccessfulHitMsg, pyBlueSpiralSuccessfulHitMsg)
// Module and method definitions
void pyBlueSpiralSuccessfulHitMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptBlueSpiralSuccessfulHitMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptBlueSpiralGameWonMsg, pyBlueSpiralGameWonMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptBlueSpiralGameWonMsg, pyBlueSpiralGameWonMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptBlueSpiralGameWonMsg)
PYTHON_NO_INIT_DEFINITION(ptBlueSpiralGameWonMsg)
PYTHON_START_METHODS_TABLE(ptBlueSpiralGameWonMsg)
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptBlueSpiralGameWonMsg, pyBlueSpiralMsg, "BlueSpiral message received when the last cloth is successfully hit");
// required functions for PyObject interoperability
PyObject* pyBlueSpiralGameWonMsg::New(pfGameCliMsg* msg)
{
ptBlueSpiralGameWonMsg *newObj = (ptBlueSpiralGameWonMsg*)ptBlueSpiralGameWonMsg_type.tp_new(&ptBlueSpiralGameWonMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_BlueSpiral_GameWon))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptBlueSpiralGameWonMsg, pyBlueSpiralGameWonMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptBlueSpiralGameWonMsg, pyBlueSpiralGameWonMsg)
// Module and method definitions
void pyBlueSpiralGameWonMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptBlueSpiralGameWonMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptBlueSpiralGameOverMsg, pyBlueSpiralGameOverMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptBlueSpiralGameOverMsg, pyBlueSpiralGameOverMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptBlueSpiralGameOverMsg)
PYTHON_NO_INIT_DEFINITION(ptBlueSpiralGameOverMsg)
PYTHON_START_METHODS_TABLE(ptBlueSpiralGameOverMsg)
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptBlueSpiralGameOverMsg, pyBlueSpiralMsg, "BlueSpiral message received when the timer runs out, someone hits the wrong cloth, or the game is restarted (before a game start msg in that last case)");
// required functions for PyObject interoperability
PyObject* pyBlueSpiralGameOverMsg::New(pfGameCliMsg* msg)
{
ptBlueSpiralGameOverMsg *newObj = (ptBlueSpiralGameOverMsg*)ptBlueSpiralGameOverMsg_type.tp_new(&ptBlueSpiralGameOverMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_BlueSpiral_GameOver))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptBlueSpiralGameOverMsg, pyBlueSpiralGameOverMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptBlueSpiralGameOverMsg, pyBlueSpiralGameOverMsg)
// Module and method definitions
void pyBlueSpiralGameOverMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptBlueSpiralGameOverMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptBlueSpiralGameStartedMsg, pyBlueSpiralGameStartedMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptBlueSpiralGameStartedMsg, pyBlueSpiralGameStartedMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptBlueSpiralGameStartedMsg)
PYTHON_NO_INIT_DEFINITION(ptBlueSpiralGameStartedMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptBlueSpiralGameStartedMsg, startSpin)
{
PYTHON_RETURN_BOOL(self->fThis->StartSpin());
}
PYTHON_START_METHODS_TABLE(ptBlueSpiralGameStartedMsg)
PYTHON_METHOD_NOARGS(ptBlueSpiralGameStartedMsg, startSpin, "Returns true if you are supposed to start spinning the door thingy"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptBlueSpiralGameStartedMsg, pyBlueSpiralMsg, "BlueSpiral message received when someone starts the game (or when you join a game that is running)");
// required functions for PyObject interoperability
PyObject* pyBlueSpiralGameStartedMsg::New(pfGameCliMsg* msg)
{
ptBlueSpiralGameStartedMsg *newObj = (ptBlueSpiralGameStartedMsg*)ptBlueSpiralGameStartedMsg_type.tp_new(&ptBlueSpiralGameStartedMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_BlueSpiral_GameStarted))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptBlueSpiralGameStartedMsg, pyBlueSpiralGameStartedMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptBlueSpiralGameStartedMsg, pyBlueSpiralGameStartedMsg)
// Module and method definitions
void pyBlueSpiralGameStartedMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptBlueSpiralGameStartedMsg);
PYTHON_CLASS_IMPORT_END(m);
}

View File

@ -1,114 +1,114 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyClimbingWallGame.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base climbing wall game client class
//
pyClimbingWallGame::pyClimbingWallGame(): pyGameCli() {}
pyClimbingWallGame::pyClimbingWallGame(pfGameCli* client): pyGameCli(client)
{
if (client && (client->GetGameTypeId() != kGameTypeId_ClimbingWall))
gameClient = nil; // wrong type, just clear it out
}
bool pyClimbingWallGame::IsClimbingWallGame(std::wstring guid)
{
Uuid gameUuid(guid.c_str());
return gameUuid == kGameTypeId_ClimbingWall;
}
void pyClimbingWallGame::JoinCommonClimbingWallGame(pyKey& callbackKey, unsigned gameID)
{
ClimbingWall_CreateParam init;
pfGameMgr::GetInstance()->JoinCommonGame(callbackKey.getKey(), kGameTypeId_ClimbingWall, gameID, sizeof(init), &init);
}
void pyClimbingWallGame::ChangeNumBlockers(int amountToAdjust)
{
if (gameClient)
{
pfGmClimbingWall* climbingWall = pfGmClimbingWall::ConvertNoRef(gameClient);
climbingWall->ChangeNumBlockers(amountToAdjust);
}
}
void pyClimbingWallGame::Ready(unsigned readyType, unsigned teamNumber)
{
if (gameClient)
{
pfGmClimbingWall* climbingWall = pfGmClimbingWall::ConvertNoRef(gameClient);
climbingWall->Ready(readyType, teamNumber);
}
}
void pyClimbingWallGame::ChangeBlocker(unsigned teamNumber, unsigned blockerNumber, bool added)
{
if (gameClient)
{
pfGmClimbingWall* climbingWall = pfGmClimbingWall::ConvertNoRef(gameClient);
climbingWall->ChangeBlocker(teamNumber, blockerNumber, added);
}
}
void pyClimbingWallGame::Reset()
{
if (gameClient)
{
pfGmClimbingWall* climbingWall = pfGmClimbingWall::ConvertNoRef(gameClient);
climbingWall->Reset();
}
}
void pyClimbingWallGame::PlayerEntered(unsigned teamNumber)
{
if (gameClient)
{
pfGmClimbingWall* climbingWall = pfGmClimbingWall::ConvertNoRef(gameClient);
climbingWall->PlayerEntered(teamNumber);
}
}
void pyClimbingWallGame::FinishedGame()
{
if (gameClient)
{
pfGmClimbingWall* climbingWall = pfGmClimbingWall::ConvertNoRef(gameClient);
climbingWall->FinishedGame();
}
}
void pyClimbingWallGame::Panic()
{
if (gameClient)
{
pfGmClimbingWall* climbingWall = pfGmClimbingWall::ConvertNoRef(gameClient);
climbingWall->Panic();
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyClimbingWallGame.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base climbing wall game client class
//
pyClimbingWallGame::pyClimbingWallGame(): pyGameCli() {}
pyClimbingWallGame::pyClimbingWallGame(pfGameCli* client): pyGameCli(client)
{
if (client && (client->GetGameTypeId() != kGameTypeId_ClimbingWall))
gameClient = nil; // wrong type, just clear it out
}
bool pyClimbingWallGame::IsClimbingWallGame(std::wstring guid)
{
Uuid gameUuid(guid.c_str());
return gameUuid == kGameTypeId_ClimbingWall;
}
void pyClimbingWallGame::JoinCommonClimbingWallGame(pyKey& callbackKey, unsigned gameID)
{
ClimbingWall_CreateParam init;
pfGameMgr::GetInstance()->JoinCommonGame(callbackKey.getKey(), kGameTypeId_ClimbingWall, gameID, sizeof(init), &init);
}
void pyClimbingWallGame::ChangeNumBlockers(int amountToAdjust)
{
if (gameClient)
{
pfGmClimbingWall* climbingWall = pfGmClimbingWall::ConvertNoRef(gameClient);
climbingWall->ChangeNumBlockers(amountToAdjust);
}
}
void pyClimbingWallGame::Ready(unsigned readyType, unsigned teamNumber)
{
if (gameClient)
{
pfGmClimbingWall* climbingWall = pfGmClimbingWall::ConvertNoRef(gameClient);
climbingWall->Ready(readyType, teamNumber);
}
}
void pyClimbingWallGame::ChangeBlocker(unsigned teamNumber, unsigned blockerNumber, bool added)
{
if (gameClient)
{
pfGmClimbingWall* climbingWall = pfGmClimbingWall::ConvertNoRef(gameClient);
climbingWall->ChangeBlocker(teamNumber, blockerNumber, added);
}
}
void pyClimbingWallGame::Reset()
{
if (gameClient)
{
pfGmClimbingWall* climbingWall = pfGmClimbingWall::ConvertNoRef(gameClient);
climbingWall->Reset();
}
}
void pyClimbingWallGame::PlayerEntered(unsigned teamNumber)
{
if (gameClient)
{
pfGmClimbingWall* climbingWall = pfGmClimbingWall::ConvertNoRef(gameClient);
climbingWall->PlayerEntered(teamNumber);
}
}
void pyClimbingWallGame::FinishedGame()
{
if (gameClient)
{
pfGmClimbingWall* climbingWall = pfGmClimbingWall::ConvertNoRef(gameClient);
climbingWall->FinishedGame();
}
}
void pyClimbingWallGame::Panic()
{
if (gameClient)
{
pfGmClimbingWall* climbingWall = pfGmClimbingWall::ConvertNoRef(gameClient);
climbingWall->Panic();
}
}

View File

@ -1,72 +1,72 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyClimbingWallGame_h
#define pyClimbingWallGame_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: pyClimbingWallGame
//
// PURPOSE: Class wrapper for the climbing wall game client
//
#include "pfGameMgr/pfGameMgr.h"
#include <python.h>
#include "../../pyGlueHelpers.h"
#include "../pyGameCli.h"
#include "../../pyKey.h"
class pyClimbingWallGame : public pyGameCli
{
protected:
pyClimbingWallGame();
pyClimbingWallGame(pfGameCli* client);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptClimbingWallGame);
static PyObject* New(pfGameCli* client);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyClimbingWallGame object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyClimbingWallGame); // converts a PyObject to a pyClimbingWallGame (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaMethods(std::vector<PyMethodDef>& methods);
static void AddPlasmaConstantsClasses(PyObject* m);
static bool IsClimbingWallGame(std::wstring guid);
static void JoinCommonClimbingWallGame(pyKey& callbackKey, unsigned gameID);
void ChangeNumBlockers(int amountToAdjust);
void Ready(unsigned readyType, unsigned teamNumber);
void ChangeBlocker(unsigned teamNumber, unsigned blockerNumber, bool added);
void Reset();
void PlayerEntered(unsigned teamNumber);
void FinishedGame();
void Panic();
};
#endif // pyClimbingWallGame_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyClimbingWallGame_h
#define pyClimbingWallGame_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: pyClimbingWallGame
//
// PURPOSE: Class wrapper for the climbing wall game client
//
#include "pfGameMgr/pfGameMgr.h"
#include <python.h>
#include "../../pyGlueHelpers.h"
#include "../pyGameCli.h"
#include "../../pyKey.h"
class pyClimbingWallGame : public pyGameCli
{
protected:
pyClimbingWallGame();
pyClimbingWallGame(pfGameCli* client);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptClimbingWallGame);
static PyObject* New(pfGameCli* client);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyClimbingWallGame object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyClimbingWallGame); // converts a PyObject to a pyClimbingWallGame (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaMethods(std::vector<PyMethodDef>& methods);
static void AddPlasmaConstantsClasses(PyObject* m);
static bool IsClimbingWallGame(std::wstring guid);
static void JoinCommonClimbingWallGame(pyKey& callbackKey, unsigned gameID);
void ChangeNumBlockers(int amountToAdjust);
void Ready(unsigned readyType, unsigned teamNumber);
void ChangeBlocker(unsigned teamNumber, unsigned blockerNumber, bool added);
void Reset();
void PlayerEntered(unsigned teamNumber);
void FinishedGame();
void Panic();
};
#endif // pyClimbingWallGame_h

View File

@ -1,196 +1,196 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyClimbingWallGame.h"
#include <python.h>
#include "../../pyEnum.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base climbing wall game client class
//
PYTHON_CLASS_DEFINITION(ptClimbingWallGame, pyClimbingWallGame);
PYTHON_DEFAULT_NEW_DEFINITION(ptClimbingWallGame, pyClimbingWallGame)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptClimbingWallGame)
PYTHON_NO_INIT_DEFINITION(ptClimbingWallGame)
PYTHON_GLOBAL_METHOD_DEFINITION(PtIsClimbingWallGame, args, "Params: typeID\nReturns true if the specifed typeID (guid as a string) is a ClimbingWall game")
{
PyObject* textObj;
if (!PyArg_ParseTuple(args, "O", &textObj))
{
PyErr_SetString(PyExc_TypeError, "PtIsClimbingWallGame expects a unicode string");
PYTHON_RETURN_ERROR;
}
if (PyUnicode_Check(textObj))
{
int strLen = PyUnicode_GetSize(textObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)textObj, text, strLen);
text[strLen] = L'\0';
bool retVal = pyClimbingWallGame::IsClimbingWallGame(text);
delete [] text;
PYTHON_RETURN_BOOL(retVal);
}
else if (PyString_Check(textObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(textObj);
wchar_t* wText = hsStringToWString(text);
bool retVal = pyClimbingWallGame::IsClimbingWallGame(wText);
delete [] wText;
PYTHON_RETURN_BOOL(retVal);
}
else
{
PyErr_SetString(PyExc_TypeError, "PtIsClimbingWallGame expects a unicode string");
PYTHON_RETURN_ERROR;
}
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtJoinCommonClimbingWallGame, args, "Params: callbackKey, gameID\nJoins a common ClimbingWall game with the specified ID. If one doesn't exist, it creates it")
{
PyObject* callbackObj = NULL;
int gameID = 0;
if (!PyArg_ParseTuple(args, "Oii", &callbackObj, &gameID))
{
PyErr_SetString(PyExc_TypeError, "PtJoinCommonClimbingWallGame expects a ptKey and an integer");
PYTHON_RETURN_ERROR;
}
if (!pyKey::Check(callbackObj))
{
PyErr_SetString(PyExc_TypeError, "PtJoinCommonClimbingWallGame expects a ptKey and an integer");
PYTHON_RETURN_ERROR;
}
pyKey* key = pyKey::ConvertFrom(callbackObj);
pyClimbingWallGame::JoinCommonClimbingWallGame(*key, gameID);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptClimbingWallGame, changeNumBlockers, args)
{
int amountToAdjust;
if (!PyArg_ParseTuple(args, "i", &amountToAdjust))
{
PyErr_SetString(PyExc_TypeError, "changeNumBlockers expects an integer");
PYTHON_RETURN_ERROR;
}
self->fThis->ChangeNumBlockers(amountToAdjust);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptClimbingWallGame, ready, args)
{
int readyType, teamNumber;
if (!PyArg_ParseTuple(args, "ii", &readyType, &teamNumber))
{
PyErr_SetString(PyExc_TypeError, "ready expects two integers");
PYTHON_RETURN_ERROR;
}
self->fThis->Ready((unsigned)readyType, (unsigned)teamNumber);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptClimbingWallGame, changeBlocker, args)
{
int teamNumber, blockerNumber;
char added;
if (!PyArg_ParseTuple(args, "iib", &teamNumber, &blockerNumber, &added))
{
PyErr_SetString(PyExc_TypeError, "changeBlocker expects two integers and a boolean");
PYTHON_RETURN_ERROR;
}
self->fThis->ChangeBlocker(teamNumber, blockerNumber, added != 0);
PYTHON_RETURN_NONE;
}
PYTHON_BASIC_METHOD_DEFINITION(ptClimbingWallGame, reset, Reset)
PYTHON_METHOD_DEFINITION(ptClimbingWallGame, playerEntered, args)
{
int teamNumber;
if (!PyArg_ParseTuple(args, "i", &teamNumber))
{
PyErr_SetString(PyExc_TypeError, "playerEntered expects an integer");
PYTHON_RETURN_ERROR;
}
self->fThis->PlayerEntered(teamNumber);
PYTHON_RETURN_NONE;
}
PYTHON_BASIC_METHOD_DEFINITION(ptClimbingWallGame, finishedGame, FinishedGame)
PYTHON_BASIC_METHOD_DEFINITION(ptClimbingWallGame, panic, Panic)
PYTHON_START_METHODS_TABLE(ptClimbingWallGame)
PYTHON_METHOD(ptClimbingWallGame, changeNumBlockers, "Params: amountToAdjust\nAdjusts the number of blockers we are playing with"),
PYTHON_METHOD(ptClimbingWallGame, ready, "Params: readyType, teamNumber\nMarks the specified team as ready for the specified type (See PtClimbingWallReadyTypes)"),
PYTHON_METHOD(ptClimbingWallGame, changeBlocker, "Params: teamNumber, blockerNumber, added\nChanges the specified marker's state for the specified team"),
PYTHON_BASIC_METHOD(ptClimbingWallGame, reset, "Attempts to reset the game's control panel"),
PYTHON_METHOD(ptClimbingWallGame, playerEntered, "Params: teamNumber\nTells the server that you are trying to play the game for the specified team"),
PYTHON_BASIC_METHOD(ptClimbingWallGame, finishedGame, "Tells the server you reached the top of the wall"),
PYTHON_BASIC_METHOD(ptClimbingWallGame, panic, "Tells the server you are panicking and want your blockers reset"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptClimbingWallGame, pyGameCli, "Game client for the ClimbingWall game");
// required functions for PyObject interoperability
PyObject* pyClimbingWallGame::New(pfGameCli* client)
{
ptClimbingWallGame *newObj = (ptClimbingWallGame*)ptClimbingWallGame_type.tp_new(&ptClimbingWallGame_type, NULL, NULL);
if (client && (client->GetGameTypeId() == kGameTypeId_ClimbingWall))
newObj->fThis->gameClient = client;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptClimbingWallGame, pyClimbingWallGame)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptClimbingWallGame, pyClimbingWallGame)
// Module and method definitions
void pyClimbingWallGame::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptClimbingWallGame);
PYTHON_CLASS_IMPORT_END(m);
}
void pyClimbingWallGame::AddPlasmaMethods(std::vector<PyMethodDef>& methods)
{
PYTHON_GLOBAL_METHOD(methods, PtIsClimbingWallGame);
PYTHON_GLOBAL_METHOD(methods, PtJoinCommonClimbingWallGame);
}
void pyClimbingWallGame::AddPlasmaConstantsClasses(PyObject* m)
{
PYTHON_ENUM_START(PtClimbingWallReadyTypes);
PYTHON_ENUM_ELEMENT(PtClimbingWallReadyTypes, kClimbingWallReadyNumBlockers, kClimbingWallReadyNumBlockers);
PYTHON_ENUM_ELEMENT(PtClimbingWallReadyTypes, kClimbingWallReadyBlockers, kClimbingWallReadyBlockers);
PYTHON_ENUM_END(m, PtClimbingWallReadyTypes);
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyClimbingWallGame.h"
#include <python.h>
#include "../../pyEnum.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base climbing wall game client class
//
PYTHON_CLASS_DEFINITION(ptClimbingWallGame, pyClimbingWallGame);
PYTHON_DEFAULT_NEW_DEFINITION(ptClimbingWallGame, pyClimbingWallGame)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptClimbingWallGame)
PYTHON_NO_INIT_DEFINITION(ptClimbingWallGame)
PYTHON_GLOBAL_METHOD_DEFINITION(PtIsClimbingWallGame, args, "Params: typeID\nReturns true if the specifed typeID (guid as a string) is a ClimbingWall game")
{
PyObject* textObj;
if (!PyArg_ParseTuple(args, "O", &textObj))
{
PyErr_SetString(PyExc_TypeError, "PtIsClimbingWallGame expects a unicode string");
PYTHON_RETURN_ERROR;
}
if (PyUnicode_Check(textObj))
{
int strLen = PyUnicode_GetSize(textObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)textObj, text, strLen);
text[strLen] = L'\0';
bool retVal = pyClimbingWallGame::IsClimbingWallGame(text);
delete [] text;
PYTHON_RETURN_BOOL(retVal);
}
else if (PyString_Check(textObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(textObj);
wchar_t* wText = hsStringToWString(text);
bool retVal = pyClimbingWallGame::IsClimbingWallGame(wText);
delete [] wText;
PYTHON_RETURN_BOOL(retVal);
}
else
{
PyErr_SetString(PyExc_TypeError, "PtIsClimbingWallGame expects a unicode string");
PYTHON_RETURN_ERROR;
}
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtJoinCommonClimbingWallGame, args, "Params: callbackKey, gameID\nJoins a common ClimbingWall game with the specified ID. If one doesn't exist, it creates it")
{
PyObject* callbackObj = NULL;
int gameID = 0;
if (!PyArg_ParseTuple(args, "Oii", &callbackObj, &gameID))
{
PyErr_SetString(PyExc_TypeError, "PtJoinCommonClimbingWallGame expects a ptKey and an integer");
PYTHON_RETURN_ERROR;
}
if (!pyKey::Check(callbackObj))
{
PyErr_SetString(PyExc_TypeError, "PtJoinCommonClimbingWallGame expects a ptKey and an integer");
PYTHON_RETURN_ERROR;
}
pyKey* key = pyKey::ConvertFrom(callbackObj);
pyClimbingWallGame::JoinCommonClimbingWallGame(*key, gameID);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptClimbingWallGame, changeNumBlockers, args)
{
int amountToAdjust;
if (!PyArg_ParseTuple(args, "i", &amountToAdjust))
{
PyErr_SetString(PyExc_TypeError, "changeNumBlockers expects an integer");
PYTHON_RETURN_ERROR;
}
self->fThis->ChangeNumBlockers(amountToAdjust);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptClimbingWallGame, ready, args)
{
int readyType, teamNumber;
if (!PyArg_ParseTuple(args, "ii", &readyType, &teamNumber))
{
PyErr_SetString(PyExc_TypeError, "ready expects two integers");
PYTHON_RETURN_ERROR;
}
self->fThis->Ready((unsigned)readyType, (unsigned)teamNumber);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptClimbingWallGame, changeBlocker, args)
{
int teamNumber, blockerNumber;
char added;
if (!PyArg_ParseTuple(args, "iib", &teamNumber, &blockerNumber, &added))
{
PyErr_SetString(PyExc_TypeError, "changeBlocker expects two integers and a boolean");
PYTHON_RETURN_ERROR;
}
self->fThis->ChangeBlocker(teamNumber, blockerNumber, added != 0);
PYTHON_RETURN_NONE;
}
PYTHON_BASIC_METHOD_DEFINITION(ptClimbingWallGame, reset, Reset)
PYTHON_METHOD_DEFINITION(ptClimbingWallGame, playerEntered, args)
{
int teamNumber;
if (!PyArg_ParseTuple(args, "i", &teamNumber))
{
PyErr_SetString(PyExc_TypeError, "playerEntered expects an integer");
PYTHON_RETURN_ERROR;
}
self->fThis->PlayerEntered(teamNumber);
PYTHON_RETURN_NONE;
}
PYTHON_BASIC_METHOD_DEFINITION(ptClimbingWallGame, finishedGame, FinishedGame)
PYTHON_BASIC_METHOD_DEFINITION(ptClimbingWallGame, panic, Panic)
PYTHON_START_METHODS_TABLE(ptClimbingWallGame)
PYTHON_METHOD(ptClimbingWallGame, changeNumBlockers, "Params: amountToAdjust\nAdjusts the number of blockers we are playing with"),
PYTHON_METHOD(ptClimbingWallGame, ready, "Params: readyType, teamNumber\nMarks the specified team as ready for the specified type (See PtClimbingWallReadyTypes)"),
PYTHON_METHOD(ptClimbingWallGame, changeBlocker, "Params: teamNumber, blockerNumber, added\nChanges the specified marker's state for the specified team"),
PYTHON_BASIC_METHOD(ptClimbingWallGame, reset, "Attempts to reset the game's control panel"),
PYTHON_METHOD(ptClimbingWallGame, playerEntered, "Params: teamNumber\nTells the server that you are trying to play the game for the specified team"),
PYTHON_BASIC_METHOD(ptClimbingWallGame, finishedGame, "Tells the server you reached the top of the wall"),
PYTHON_BASIC_METHOD(ptClimbingWallGame, panic, "Tells the server you are panicking and want your blockers reset"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptClimbingWallGame, pyGameCli, "Game client for the ClimbingWall game");
// required functions for PyObject interoperability
PyObject* pyClimbingWallGame::New(pfGameCli* client)
{
ptClimbingWallGame *newObj = (ptClimbingWallGame*)ptClimbingWallGame_type.tp_new(&ptClimbingWallGame_type, NULL, NULL);
if (client && (client->GetGameTypeId() == kGameTypeId_ClimbingWall))
newObj->fThis->gameClient = client;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptClimbingWallGame, pyClimbingWallGame)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptClimbingWallGame, pyClimbingWallGame)
// Module and method definitions
void pyClimbingWallGame::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptClimbingWallGame);
PYTHON_CLASS_IMPORT_END(m);
}
void pyClimbingWallGame::AddPlasmaMethods(std::vector<PyMethodDef>& methods)
{
PYTHON_GLOBAL_METHOD(methods, PtIsClimbingWallGame);
PYTHON_GLOBAL_METHOD(methods, PtJoinCommonClimbingWallGame);
}
void pyClimbingWallGame::AddPlasmaConstantsClasses(PyObject* m)
{
PYTHON_ENUM_START(PtClimbingWallReadyTypes);
PYTHON_ENUM_ELEMENT(PtClimbingWallReadyTypes, kClimbingWallReadyNumBlockers, kClimbingWallReadyNumBlockers);
PYTHON_ENUM_ELEMENT(PtClimbingWallReadyTypes, kClimbingWallReadyBlockers, kClimbingWallReadyBlockers);
PYTHON_ENUM_END(m, PtClimbingWallReadyTypes);
}

View File

@ -1,308 +1,308 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyClimbingWallMsg.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base climbing wall msg class
//
pyClimbingWallMsg::pyClimbingWallMsg(): pyGameCliMsg() {}
pyClimbingWallMsg::pyClimbingWallMsg(pfGameCliMsg* msg): pyGameCliMsg(msg)
{
if (message && (message->gameCli->GetGameTypeId() != kGameTypeId_ClimbingWall))
message = nil; // wrong type, just clear it out
}
int pyClimbingWallMsg::GetClimbingWallMsgType() const
{
if (message)
return message->netMsg->messageId;
return -1;
}
PyObject* pyClimbingWallMsg::UpcastToFinalClimbingWallMsg() const
{
if (!message)
PYTHON_RETURN_NONE;
switch (message->netMsg->messageId)
{
case kSrv2Cli_ClimbingWall_NumBlockersChanged:
return pyClimbingWallNumBlockersChangedMsg::New(message);
case kSrv2Cli_ClimbingWall_Ready:
return pyClimbingWallReadyMsg::New(message);
case kSrv2Cli_ClimbingWall_BlockersChanged:
return pyClimbingWallBlockersChangedMsg::New(message);
case kSrv2Cli_ClimbingWall_PlayerEntered:
return pyClimbingWallPlayerEnteredMsg::New(message);
case kSrv2Cli_ClimbingWall_SuitMachineLocked:
return pyClimbingWallSuitMachineLockedMsg::New(message);
case kSrv2Cli_ClimbingWall_GameOver:
return pyClimbingWallGameOverMsg::New(message);
default:
PYTHON_RETURN_NONE;
}
}
///////////////////////////////////////////////////////////////////////////////
//
// The different messages we can receive
//
pyClimbingWallNumBlockersChangedMsg::pyClimbingWallNumBlockersChangedMsg(): pyClimbingWallMsg() {}
pyClimbingWallNumBlockersChangedMsg::pyClimbingWallNumBlockersChangedMsg(pfGameCliMsg* msg): pyClimbingWallMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_ClimbingWall_NumBlockersChanged))
message = nil; // wrong type, just clear it out
}
int pyClimbingWallNumBlockersChangedMsg::NewBlockerCount() const
{
if (message)
{
const Srv2Cli_ClimbingWall_NumBlockersChanged* gmMsg = (const Srv2Cli_ClimbingWall_NumBlockersChanged*)message->netMsg;
return gmMsg->newBlockerCount;
}
return 0;
}
bool pyClimbingWallNumBlockersChangedMsg::LocalOnly() const
{
if (message)
{
const Srv2Cli_ClimbingWall_Ready* gmMsg = (const Srv2Cli_ClimbingWall_Ready*)message->netMsg;
return gmMsg->localOnly;
}
return true; // safe-guard so we don't screw up other's state if the python does something stupid
}
///////////////////////////////////////////////////////////////////////////////
pyClimbingWallReadyMsg::pyClimbingWallReadyMsg(): pyClimbingWallMsg() {}
pyClimbingWallReadyMsg::pyClimbingWallReadyMsg(pfGameCliMsg* msg): pyClimbingWallMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_ClimbingWall_Ready))
message = nil; // wrong type, just clear it out
}
int pyClimbingWallReadyMsg::ReadyType() const
{
if (message)
{
const Srv2Cli_ClimbingWall_Ready* gmMsg = (const Srv2Cli_ClimbingWall_Ready*)message->netMsg;
return gmMsg->readyType;
}
return 0;
}
bool pyClimbingWallReadyMsg::Team1Ready() const
{
if (message)
{
const Srv2Cli_ClimbingWall_Ready* gmMsg = (const Srv2Cli_ClimbingWall_Ready*)message->netMsg;
return gmMsg->team1Ready;
}
return false;
}
bool pyClimbingWallReadyMsg::Team2Ready() const
{
if (message)
{
const Srv2Cli_ClimbingWall_Ready* gmMsg = (const Srv2Cli_ClimbingWall_Ready*)message->netMsg;
return gmMsg->team2Ready;
}
return false;
}
bool pyClimbingWallReadyMsg::LocalOnly() const
{
if (message)
{
const Srv2Cli_ClimbingWall_Ready* gmMsg = (const Srv2Cli_ClimbingWall_Ready*)message->netMsg;
return gmMsg->localOnly;
}
return true; // safe-guard so we don't screw up other's state if the python does something stupid
}
///////////////////////////////////////////////////////////////////////////////
pyClimbingWallBlockersChangedMsg::pyClimbingWallBlockersChangedMsg(): pyClimbingWallMsg() {}
pyClimbingWallBlockersChangedMsg::pyClimbingWallBlockersChangedMsg(pfGameCliMsg* msg): pyClimbingWallMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_ClimbingWall_BlockersChanged))
message = nil; // wrong type, just clear it out
}
int pyClimbingWallBlockersChangedMsg::TeamNumber() const
{
if (message)
{
const Srv2Cli_ClimbingWall_BlockersChanged* gmMsg = (const Srv2Cli_ClimbingWall_BlockersChanged*)message->netMsg;
return gmMsg->teamNumber;
}
return 0;
}
std::vector<int> pyClimbingWallBlockersChangedMsg::BlockersSet() const
{
std::vector<int> retVal;
if (message)
{
const Srv2Cli_ClimbingWall_BlockersChanged* gmMsg = (const Srv2Cli_ClimbingWall_BlockersChanged*)message->netMsg;
for (unsigned i = 0; i < kClimbingWallMaxBlockers; ++i)
{
if (gmMsg->blockersSet[i] != kClimbingWallNoBlocker)
retVal.push_back(gmMsg->blockersSet[i]);
}
}
return retVal;
}
bool pyClimbingWallBlockersChangedMsg::LocalOnly() const
{
if (message)
{
const Srv2Cli_ClimbingWall_BlockersChanged* gmMsg = (const Srv2Cli_ClimbingWall_BlockersChanged*)message->netMsg;
return gmMsg->localOnly;
}
return true; // safe-guard so we don't screw up other's state if the python does something stupid
}
///////////////////////////////////////////////////////////////////////////////
pyClimbingWallPlayerEnteredMsg::pyClimbingWallPlayerEnteredMsg(): pyClimbingWallMsg() {}
pyClimbingWallPlayerEnteredMsg::pyClimbingWallPlayerEnteredMsg(pfGameCliMsg* msg): pyClimbingWallMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_ClimbingWall_PlayerEntered))
message = nil; // wrong type, just clear it out
}
///////////////////////////////////////////////////////////////////////////////
pyClimbingWallSuitMachineLockedMsg::pyClimbingWallSuitMachineLockedMsg(): pyClimbingWallMsg() {}
pyClimbingWallSuitMachineLockedMsg::pyClimbingWallSuitMachineLockedMsg(pfGameCliMsg* msg): pyClimbingWallMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_ClimbingWall_SuitMachineLocked))
message = nil; // wrong type, just clear it out
}
bool pyClimbingWallSuitMachineLockedMsg::Team1MachineLocked() const
{
if (message)
{
const Srv2Cli_ClimbingWall_SuitMachineLocked* gmMsg = (const Srv2Cli_ClimbingWall_SuitMachineLocked*)message->netMsg;
return gmMsg->team1MachineLocked;
}
return true; // err on the side of caution
}
bool pyClimbingWallSuitMachineLockedMsg::Team2MachineLocked() const
{
if (message)
{
const Srv2Cli_ClimbingWall_SuitMachineLocked* gmMsg = (const Srv2Cli_ClimbingWall_SuitMachineLocked*)message->netMsg;
return gmMsg->team2MachineLocked;
}
return true; // err on the side of caution
}
bool pyClimbingWallSuitMachineLockedMsg::LocalOnly() const
{
if (message)
{
const Srv2Cli_ClimbingWall_SuitMachineLocked* gmMsg = (const Srv2Cli_ClimbingWall_SuitMachineLocked*)message->netMsg;
return gmMsg->localOnly;
}
return true; // safe-guard so we don't screw up other's state if the python does something stupid
}
///////////////////////////////////////////////////////////////////////////////
pyClimbingWallGameOverMsg::pyClimbingWallGameOverMsg(): pyClimbingWallMsg() {}
pyClimbingWallGameOverMsg::pyClimbingWallGameOverMsg(pfGameCliMsg* msg): pyClimbingWallMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_ClimbingWall_GameOver))
message = nil; // wrong type, just clear it out
}
int pyClimbingWallGameOverMsg::TeamWon() const
{
if (message)
{
const Srv2Cli_ClimbingWall_GameOver* gmMsg = (const Srv2Cli_ClimbingWall_GameOver*)message->netMsg;
return gmMsg->teamWon;
}
return 0;
}
std::vector<int> pyClimbingWallGameOverMsg::Team1Blockers() const
{
std::vector<int> retVal;
if (message)
{
const Srv2Cli_ClimbingWall_GameOver* gmMsg = (const Srv2Cli_ClimbingWall_GameOver*)message->netMsg;
for (unsigned i = 0; i < kClimbingWallMaxBlockers; ++i)
{
if (gmMsg->team1Blockers[i] != kClimbingWallNoBlocker)
retVal.push_back(gmMsg->team1Blockers[i]);
}
}
return retVal;
}
std::vector<int> pyClimbingWallGameOverMsg::Team2Blockers() const
{
std::vector<int> retVal;
if (message)
{
const Srv2Cli_ClimbingWall_GameOver* gmMsg = (const Srv2Cli_ClimbingWall_GameOver*)message->netMsg;
for (unsigned i = 0; i < kClimbingWallMaxBlockers; ++i)
{
if (gmMsg->team2Blockers[i] != kClimbingWallNoBlocker)
retVal.push_back(gmMsg->team2Blockers[i]);
}
}
return retVal;
}
bool pyClimbingWallGameOverMsg::LocalOnly() const
{
if (message)
{
const Srv2Cli_ClimbingWall_GameOver* gmMsg = (const Srv2Cli_ClimbingWall_GameOver*)message->netMsg;
return gmMsg->localOnly;
}
return true; // safe-guard so we don't screw up other's state if the python does something stupid
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyClimbingWallMsg.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base climbing wall msg class
//
pyClimbingWallMsg::pyClimbingWallMsg(): pyGameCliMsg() {}
pyClimbingWallMsg::pyClimbingWallMsg(pfGameCliMsg* msg): pyGameCliMsg(msg)
{
if (message && (message->gameCli->GetGameTypeId() != kGameTypeId_ClimbingWall))
message = nil; // wrong type, just clear it out
}
int pyClimbingWallMsg::GetClimbingWallMsgType() const
{
if (message)
return message->netMsg->messageId;
return -1;
}
PyObject* pyClimbingWallMsg::UpcastToFinalClimbingWallMsg() const
{
if (!message)
PYTHON_RETURN_NONE;
switch (message->netMsg->messageId)
{
case kSrv2Cli_ClimbingWall_NumBlockersChanged:
return pyClimbingWallNumBlockersChangedMsg::New(message);
case kSrv2Cli_ClimbingWall_Ready:
return pyClimbingWallReadyMsg::New(message);
case kSrv2Cli_ClimbingWall_BlockersChanged:
return pyClimbingWallBlockersChangedMsg::New(message);
case kSrv2Cli_ClimbingWall_PlayerEntered:
return pyClimbingWallPlayerEnteredMsg::New(message);
case kSrv2Cli_ClimbingWall_SuitMachineLocked:
return pyClimbingWallSuitMachineLockedMsg::New(message);
case kSrv2Cli_ClimbingWall_GameOver:
return pyClimbingWallGameOverMsg::New(message);
default:
PYTHON_RETURN_NONE;
}
}
///////////////////////////////////////////////////////////////////////////////
//
// The different messages we can receive
//
pyClimbingWallNumBlockersChangedMsg::pyClimbingWallNumBlockersChangedMsg(): pyClimbingWallMsg() {}
pyClimbingWallNumBlockersChangedMsg::pyClimbingWallNumBlockersChangedMsg(pfGameCliMsg* msg): pyClimbingWallMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_ClimbingWall_NumBlockersChanged))
message = nil; // wrong type, just clear it out
}
int pyClimbingWallNumBlockersChangedMsg::NewBlockerCount() const
{
if (message)
{
const Srv2Cli_ClimbingWall_NumBlockersChanged* gmMsg = (const Srv2Cli_ClimbingWall_NumBlockersChanged*)message->netMsg;
return gmMsg->newBlockerCount;
}
return 0;
}
bool pyClimbingWallNumBlockersChangedMsg::LocalOnly() const
{
if (message)
{
const Srv2Cli_ClimbingWall_Ready* gmMsg = (const Srv2Cli_ClimbingWall_Ready*)message->netMsg;
return gmMsg->localOnly;
}
return true; // safe-guard so we don't screw up other's state if the python does something stupid
}
///////////////////////////////////////////////////////////////////////////////
pyClimbingWallReadyMsg::pyClimbingWallReadyMsg(): pyClimbingWallMsg() {}
pyClimbingWallReadyMsg::pyClimbingWallReadyMsg(pfGameCliMsg* msg): pyClimbingWallMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_ClimbingWall_Ready))
message = nil; // wrong type, just clear it out
}
int pyClimbingWallReadyMsg::ReadyType() const
{
if (message)
{
const Srv2Cli_ClimbingWall_Ready* gmMsg = (const Srv2Cli_ClimbingWall_Ready*)message->netMsg;
return gmMsg->readyType;
}
return 0;
}
bool pyClimbingWallReadyMsg::Team1Ready() const
{
if (message)
{
const Srv2Cli_ClimbingWall_Ready* gmMsg = (const Srv2Cli_ClimbingWall_Ready*)message->netMsg;
return gmMsg->team1Ready;
}
return false;
}
bool pyClimbingWallReadyMsg::Team2Ready() const
{
if (message)
{
const Srv2Cli_ClimbingWall_Ready* gmMsg = (const Srv2Cli_ClimbingWall_Ready*)message->netMsg;
return gmMsg->team2Ready;
}
return false;
}
bool pyClimbingWallReadyMsg::LocalOnly() const
{
if (message)
{
const Srv2Cli_ClimbingWall_Ready* gmMsg = (const Srv2Cli_ClimbingWall_Ready*)message->netMsg;
return gmMsg->localOnly;
}
return true; // safe-guard so we don't screw up other's state if the python does something stupid
}
///////////////////////////////////////////////////////////////////////////////
pyClimbingWallBlockersChangedMsg::pyClimbingWallBlockersChangedMsg(): pyClimbingWallMsg() {}
pyClimbingWallBlockersChangedMsg::pyClimbingWallBlockersChangedMsg(pfGameCliMsg* msg): pyClimbingWallMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_ClimbingWall_BlockersChanged))
message = nil; // wrong type, just clear it out
}
int pyClimbingWallBlockersChangedMsg::TeamNumber() const
{
if (message)
{
const Srv2Cli_ClimbingWall_BlockersChanged* gmMsg = (const Srv2Cli_ClimbingWall_BlockersChanged*)message->netMsg;
return gmMsg->teamNumber;
}
return 0;
}
std::vector<int> pyClimbingWallBlockersChangedMsg::BlockersSet() const
{
std::vector<int> retVal;
if (message)
{
const Srv2Cli_ClimbingWall_BlockersChanged* gmMsg = (const Srv2Cli_ClimbingWall_BlockersChanged*)message->netMsg;
for (unsigned i = 0; i < kClimbingWallMaxBlockers; ++i)
{
if (gmMsg->blockersSet[i] != kClimbingWallNoBlocker)
retVal.push_back(gmMsg->blockersSet[i]);
}
}
return retVal;
}
bool pyClimbingWallBlockersChangedMsg::LocalOnly() const
{
if (message)
{
const Srv2Cli_ClimbingWall_BlockersChanged* gmMsg = (const Srv2Cli_ClimbingWall_BlockersChanged*)message->netMsg;
return gmMsg->localOnly;
}
return true; // safe-guard so we don't screw up other's state if the python does something stupid
}
///////////////////////////////////////////////////////////////////////////////
pyClimbingWallPlayerEnteredMsg::pyClimbingWallPlayerEnteredMsg(): pyClimbingWallMsg() {}
pyClimbingWallPlayerEnteredMsg::pyClimbingWallPlayerEnteredMsg(pfGameCliMsg* msg): pyClimbingWallMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_ClimbingWall_PlayerEntered))
message = nil; // wrong type, just clear it out
}
///////////////////////////////////////////////////////////////////////////////
pyClimbingWallSuitMachineLockedMsg::pyClimbingWallSuitMachineLockedMsg(): pyClimbingWallMsg() {}
pyClimbingWallSuitMachineLockedMsg::pyClimbingWallSuitMachineLockedMsg(pfGameCliMsg* msg): pyClimbingWallMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_ClimbingWall_SuitMachineLocked))
message = nil; // wrong type, just clear it out
}
bool pyClimbingWallSuitMachineLockedMsg::Team1MachineLocked() const
{
if (message)
{
const Srv2Cli_ClimbingWall_SuitMachineLocked* gmMsg = (const Srv2Cli_ClimbingWall_SuitMachineLocked*)message->netMsg;
return gmMsg->team1MachineLocked;
}
return true; // err on the side of caution
}
bool pyClimbingWallSuitMachineLockedMsg::Team2MachineLocked() const
{
if (message)
{
const Srv2Cli_ClimbingWall_SuitMachineLocked* gmMsg = (const Srv2Cli_ClimbingWall_SuitMachineLocked*)message->netMsg;
return gmMsg->team2MachineLocked;
}
return true; // err on the side of caution
}
bool pyClimbingWallSuitMachineLockedMsg::LocalOnly() const
{
if (message)
{
const Srv2Cli_ClimbingWall_SuitMachineLocked* gmMsg = (const Srv2Cli_ClimbingWall_SuitMachineLocked*)message->netMsg;
return gmMsg->localOnly;
}
return true; // safe-guard so we don't screw up other's state if the python does something stupid
}
///////////////////////////////////////////////////////////////////////////////
pyClimbingWallGameOverMsg::pyClimbingWallGameOverMsg(): pyClimbingWallMsg() {}
pyClimbingWallGameOverMsg::pyClimbingWallGameOverMsg(pfGameCliMsg* msg): pyClimbingWallMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_ClimbingWall_GameOver))
message = nil; // wrong type, just clear it out
}
int pyClimbingWallGameOverMsg::TeamWon() const
{
if (message)
{
const Srv2Cli_ClimbingWall_GameOver* gmMsg = (const Srv2Cli_ClimbingWall_GameOver*)message->netMsg;
return gmMsg->teamWon;
}
return 0;
}
std::vector<int> pyClimbingWallGameOverMsg::Team1Blockers() const
{
std::vector<int> retVal;
if (message)
{
const Srv2Cli_ClimbingWall_GameOver* gmMsg = (const Srv2Cli_ClimbingWall_GameOver*)message->netMsg;
for (unsigned i = 0; i < kClimbingWallMaxBlockers; ++i)
{
if (gmMsg->team1Blockers[i] != kClimbingWallNoBlocker)
retVal.push_back(gmMsg->team1Blockers[i]);
}
}
return retVal;
}
std::vector<int> pyClimbingWallGameOverMsg::Team2Blockers() const
{
std::vector<int> retVal;
if (message)
{
const Srv2Cli_ClimbingWall_GameOver* gmMsg = (const Srv2Cli_ClimbingWall_GameOver*)message->netMsg;
for (unsigned i = 0; i < kClimbingWallMaxBlockers; ++i)
{
if (gmMsg->team2Blockers[i] != kClimbingWallNoBlocker)
retVal.push_back(gmMsg->team2Blockers[i]);
}
}
return retVal;
}
bool pyClimbingWallGameOverMsg::LocalOnly() const
{
if (message)
{
const Srv2Cli_ClimbingWall_GameOver* gmMsg = (const Srv2Cli_ClimbingWall_GameOver*)message->netMsg;
return gmMsg->localOnly;
}
return true; // safe-guard so we don't screw up other's state if the python does something stupid
}

View File

@ -1,187 +1,187 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyClimbingWallMsg_h
#define pyClimbingWallMsg_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: pyClimbingWallMsg
//
// PURPOSE: Class wrapper for ClimbingWall game messages
//
#include "pfGameMgr/pfGameMgr.h"
#include <python.h>
#include "../../pyGlueHelpers.h"
#include "../pyGameCliMsg.h"
class pyClimbingWallMsg : public pyGameCliMsg
{
protected:
pyClimbingWallMsg();
pyClimbingWallMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_EXPOSE_TYPE; // so we can subclass
PYTHON_CLASS_NEW_FRIEND(ptClimbingWallMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyClimbingWallMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyClimbingWallMsg); // converts a PyObject to a pyClimbingWallMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaConstantsClasses(PyObject* m);
int GetClimbingWallMsgType() const;
PyObject* UpcastToFinalClimbingWallMsg() const; // returns the climbing wall message that this really is
};
///////////////////////////////////////////////////////////////////////////////
class pyClimbingWallNumBlockersChangedMsg : public pyClimbingWallMsg
{
protected:
pyClimbingWallNumBlockersChangedMsg();
pyClimbingWallNumBlockersChangedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptClimbingWallNumBlockersChangedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyClimbingWallNumBlockersChangedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyClimbingWallNumBlockersChangedMsg); // converts a PyObject to a pyClimbingWallNumBlockersChangedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
int NewBlockerCount() const;
bool LocalOnly() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyClimbingWallReadyMsg : public pyClimbingWallMsg
{
protected:
pyClimbingWallReadyMsg();
pyClimbingWallReadyMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptClimbingWallReadyMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyClimbingWallReadyMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyClimbingWallReadyMsg); // converts a PyObject to a pyClimbingWallReadyMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
int ReadyType() const;
bool Team1Ready() const;
bool Team2Ready() const;
bool LocalOnly() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyClimbingWallBlockersChangedMsg : public pyClimbingWallMsg
{
protected:
pyClimbingWallBlockersChangedMsg();
pyClimbingWallBlockersChangedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptClimbingWallBlockersChangedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyClimbingWallBlockersChangedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyClimbingWallBlockersChangedMsg); // converts a PyObject to a pyClimbingWallBlockersChangedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
int TeamNumber() const;
std::vector<int> BlockersSet() const;
bool LocalOnly() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyClimbingWallPlayerEnteredMsg : public pyClimbingWallMsg
{
protected:
pyClimbingWallPlayerEnteredMsg();
pyClimbingWallPlayerEnteredMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptClimbingWallPlayerEnteredMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyClimbingWallPlayerEnteredMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyClimbingWallPlayerEnteredMsg); // converts a PyObject to a pyClimbingWallPlayerEnteredMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
};
///////////////////////////////////////////////////////////////////////////////
class pyClimbingWallSuitMachineLockedMsg : public pyClimbingWallMsg
{
protected:
pyClimbingWallSuitMachineLockedMsg();
pyClimbingWallSuitMachineLockedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptClimbingWallSuitMachineLockedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyClimbingWallSuitMachineLockedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyClimbingWallSuitMachineLockedMsg); // converts a PyObject to a pyClimbingWallSuitMachineLockedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
bool Team1MachineLocked() const;
bool Team2MachineLocked() const;
bool LocalOnly() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyClimbingWallGameOverMsg : public pyClimbingWallMsg
{
protected:
pyClimbingWallGameOverMsg();
pyClimbingWallGameOverMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptClimbingWallGameOverMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyClimbingWallGameOverMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyClimbingWallGameOverMsg); // converts a PyObject to a pyClimbingWallGameOverMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
int TeamWon() const;
std::vector<int> Team1Blockers() const;
std::vector<int> Team2Blockers() const;
bool LocalOnly() const;
};
#endif // pyClimbingWallMsg_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyClimbingWallMsg_h
#define pyClimbingWallMsg_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: pyClimbingWallMsg
//
// PURPOSE: Class wrapper for ClimbingWall game messages
//
#include "pfGameMgr/pfGameMgr.h"
#include <python.h>
#include "../../pyGlueHelpers.h"
#include "../pyGameCliMsg.h"
class pyClimbingWallMsg : public pyGameCliMsg
{
protected:
pyClimbingWallMsg();
pyClimbingWallMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_EXPOSE_TYPE; // so we can subclass
PYTHON_CLASS_NEW_FRIEND(ptClimbingWallMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyClimbingWallMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyClimbingWallMsg); // converts a PyObject to a pyClimbingWallMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaConstantsClasses(PyObject* m);
int GetClimbingWallMsgType() const;
PyObject* UpcastToFinalClimbingWallMsg() const; // returns the climbing wall message that this really is
};
///////////////////////////////////////////////////////////////////////////////
class pyClimbingWallNumBlockersChangedMsg : public pyClimbingWallMsg
{
protected:
pyClimbingWallNumBlockersChangedMsg();
pyClimbingWallNumBlockersChangedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptClimbingWallNumBlockersChangedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyClimbingWallNumBlockersChangedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyClimbingWallNumBlockersChangedMsg); // converts a PyObject to a pyClimbingWallNumBlockersChangedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
int NewBlockerCount() const;
bool LocalOnly() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyClimbingWallReadyMsg : public pyClimbingWallMsg
{
protected:
pyClimbingWallReadyMsg();
pyClimbingWallReadyMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptClimbingWallReadyMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyClimbingWallReadyMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyClimbingWallReadyMsg); // converts a PyObject to a pyClimbingWallReadyMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
int ReadyType() const;
bool Team1Ready() const;
bool Team2Ready() const;
bool LocalOnly() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyClimbingWallBlockersChangedMsg : public pyClimbingWallMsg
{
protected:
pyClimbingWallBlockersChangedMsg();
pyClimbingWallBlockersChangedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptClimbingWallBlockersChangedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyClimbingWallBlockersChangedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyClimbingWallBlockersChangedMsg); // converts a PyObject to a pyClimbingWallBlockersChangedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
int TeamNumber() const;
std::vector<int> BlockersSet() const;
bool LocalOnly() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyClimbingWallPlayerEnteredMsg : public pyClimbingWallMsg
{
protected:
pyClimbingWallPlayerEnteredMsg();
pyClimbingWallPlayerEnteredMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptClimbingWallPlayerEnteredMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyClimbingWallPlayerEnteredMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyClimbingWallPlayerEnteredMsg); // converts a PyObject to a pyClimbingWallPlayerEnteredMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
};
///////////////////////////////////////////////////////////////////////////////
class pyClimbingWallSuitMachineLockedMsg : public pyClimbingWallMsg
{
protected:
pyClimbingWallSuitMachineLockedMsg();
pyClimbingWallSuitMachineLockedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptClimbingWallSuitMachineLockedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyClimbingWallSuitMachineLockedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyClimbingWallSuitMachineLockedMsg); // converts a PyObject to a pyClimbingWallSuitMachineLockedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
bool Team1MachineLocked() const;
bool Team2MachineLocked() const;
bool LocalOnly() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyClimbingWallGameOverMsg : public pyClimbingWallMsg
{
protected:
pyClimbingWallGameOverMsg();
pyClimbingWallGameOverMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptClimbingWallGameOverMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyClimbingWallGameOverMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyClimbingWallGameOverMsg); // converts a PyObject to a pyClimbingWallGameOverMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
int TeamWon() const;
std::vector<int> Team1Blockers() const;
std::vector<int> Team2Blockers() const;
bool LocalOnly() const;
};
#endif // pyClimbingWallMsg_h

View File

@ -1,413 +1,413 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyClimbingWallMsg.h"
#include "../../pyEnum.h"
#include <python.h>
///////////////////////////////////////////////////////////////////////////////
//
// Base climbing wall msg class
//
PYTHON_CLASS_DEFINITION(ptClimbingWallMsg, pyClimbingWallMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptClimbingWallMsg, pyClimbingWallMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptClimbingWallMsg)
PYTHON_NO_INIT_DEFINITION(ptClimbingWallMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallMsg, getClimbingWallMsgType)
{
return PyInt_FromLong(self->fThis->GetClimbingWallMsgType());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallMsg, upcastToFinalClimbingWallMsg)
{
return self->fThis->UpcastToFinalClimbingWallMsg();
}
PYTHON_START_METHODS_TABLE(ptClimbingWallMsg)
PYTHON_METHOD_NOARGS(ptClimbingWallMsg, getClimbingWallMsgType, "Returns the type of the ClimbingWall message (see PtClimbingWallMsgTypes)"),
PYTHON_METHOD_NOARGS(ptClimbingWallMsg, upcastToFinalClimbingWallMsg, "Returns this message as the ClimbingWall msg it is"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptClimbingWallMsg, pyGameCliMsg, "Base class for ClimbingWall game messages");
PYTHON_EXPOSE_TYPE_DEFINITION(ptClimbingWallMsg, pyClimbingWallMsg);
// required functions for PyObject interoperability
PyObject* pyClimbingWallMsg::New(pfGameCliMsg* msg)
{
ptClimbingWallMsg *newObj = (ptClimbingWallMsg*)ptClimbingWallMsg_type.tp_new(&ptClimbingWallMsg_type, NULL, NULL);
if (msg && (msg->gameCli->GetGameTypeId() == kGameTypeId_ClimbingWall))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptClimbingWallMsg, pyClimbingWallMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptClimbingWallMsg, pyClimbingWallMsg)
// Module and method definitions
void pyClimbingWallMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptClimbingWallMsg);
PYTHON_CLASS_IMPORT_END(m);
}
void pyClimbingWallMsg::AddPlasmaConstantsClasses(PyObject* m)
{
PYTHON_ENUM_START(PtClimbingWallMsgTypes);
PYTHON_ENUM_ELEMENT(PtClimbingWallMsgTypes, kClimbingWallNumBlockersChanged, kSrv2Cli_ClimbingWall_NumBlockersChanged);
PYTHON_ENUM_ELEMENT(PtClimbingWallMsgTypes, kClimbingWallReadyMsg, kSrv2Cli_ClimbingWall_Ready);
PYTHON_ENUM_ELEMENT(PtClimbingWallMsgTypes, kClimbingWallBlockersChanged, kSrv2Cli_ClimbingWall_BlockersChanged);
PYTHON_ENUM_ELEMENT(PtClimbingWallMsgTypes, kClimbingWallPlayerEntered, kSrv2Cli_ClimbingWall_PlayerEntered);
PYTHON_ENUM_ELEMENT(PtClimbingWallMsgTypes, kClimbingWallSuitMachineLocked, kSrv2Cli_ClimbingWall_SuitMachineLocked);
PYTHON_ENUM_ELEMENT(PtClimbingWallMsgTypes, kClimbingWallGameOver, kSrv2Cli_ClimbingWall_GameOver);
PYTHON_ENUM_END(m, PtClimbingWallMsgTypes);
}
///////////////////////////////////////////////////////////////////////////////
//
// Game client message subclasses
//
PYTHON_CLASS_DEFINITION(ptClimbingWallNumBlockersChangedMsg, pyClimbingWallNumBlockersChangedMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptClimbingWallNumBlockersChangedMsg, pyClimbingWallNumBlockersChangedMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptClimbingWallNumBlockersChangedMsg)
PYTHON_NO_INIT_DEFINITION(ptClimbingWallNumBlockersChangedMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallNumBlockersChangedMsg, newBlockerCount)
{
return PyInt_FromLong((long)self->fThis->NewBlockerCount());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallNumBlockersChangedMsg, localOnly)
{
PYTHON_RETURN_BOOL(self->fThis->LocalOnly());
}
PYTHON_START_METHODS_TABLE(ptClimbingWallNumBlockersChangedMsg)
PYTHON_METHOD_NOARGS(ptClimbingWallNumBlockersChangedMsg, newBlockerCount, "Returns the number of blockers this game is current running with"),
PYTHON_METHOD_NOARGS(ptClimbingWallNumBlockersChangedMsg, localOnly, "Returns true if we are only supposed to adjust our stuff locally, and not net-prop it"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptClimbingWallNumBlockersChangedMsg, pyClimbingWallMsg, "ClimbingWall message received when the number of blockers is changed");
// required functions for PyObject interoperability
PyObject* pyClimbingWallNumBlockersChangedMsg::New(pfGameCliMsg* msg)
{
ptClimbingWallNumBlockersChangedMsg *newObj = (ptClimbingWallNumBlockersChangedMsg*)ptClimbingWallNumBlockersChangedMsg_type.tp_new(&ptClimbingWallNumBlockersChangedMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_ClimbingWall_NumBlockersChanged))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptClimbingWallNumBlockersChangedMsg, pyClimbingWallNumBlockersChangedMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptClimbingWallNumBlockersChangedMsg, pyClimbingWallNumBlockersChangedMsg)
// Module and method definitions
void pyClimbingWallNumBlockersChangedMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptClimbingWallNumBlockersChangedMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptClimbingWallReadyMsg, pyClimbingWallReadyMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptClimbingWallReadyMsg, pyClimbingWallReadyMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptClimbingWallReadyMsg)
PYTHON_NO_INIT_DEFINITION(ptClimbingWallReadyMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallReadyMsg, readyType)
{
return PyInt_FromLong((long)self->fThis->ReadyType());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallReadyMsg, team1Ready)
{
PYTHON_RETURN_BOOL(self->fThis->Team1Ready());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallReadyMsg, team2Ready)
{
PYTHON_RETURN_BOOL(self->fThis->Team2Ready());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallReadyMsg, localOnly)
{
PYTHON_RETURN_BOOL(self->fThis->LocalOnly());
}
PYTHON_START_METHODS_TABLE(ptClimbingWallReadyMsg)
PYTHON_METHOD_NOARGS(ptClimbingWallReadyMsg, readyType, "The type of ready message this represents (see PtClimbingWallReadyTypes)"),
PYTHON_METHOD_NOARGS(ptClimbingWallReadyMsg, team1Ready, "Whether team 1 is ready or not"),
PYTHON_METHOD_NOARGS(ptClimbingWallReadyMsg, team2Ready, "Whether team 2 is ready or not"),
PYTHON_METHOD_NOARGS(ptClimbingWallReadyMsg, localOnly, "Returns true if we are only supposed to adjust our stuff locally, and not net-prop it"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptClimbingWallReadyMsg, pyClimbingWallMsg, "ClimbingWall message received when the ready state of the teams is changed");
// required functions for PyObject interoperability
PyObject* pyClimbingWallReadyMsg::New(pfGameCliMsg* msg)
{
ptClimbingWallReadyMsg *newObj = (ptClimbingWallReadyMsg*)ptClimbingWallReadyMsg_type.tp_new(&ptClimbingWallReadyMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_ClimbingWall_Ready))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptClimbingWallReadyMsg, pyClimbingWallReadyMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptClimbingWallReadyMsg, pyClimbingWallReadyMsg)
// Module and method definitions
void pyClimbingWallReadyMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptClimbingWallReadyMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptClimbingWallBlockersChangedMsg, pyClimbingWallBlockersChangedMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptClimbingWallBlockersChangedMsg, pyClimbingWallBlockersChangedMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptClimbingWallBlockersChangedMsg)
PYTHON_NO_INIT_DEFINITION(ptClimbingWallBlockersChangedMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallBlockersChangedMsg, teamNumber)
{
return PyInt_FromLong((long)self->fThis->TeamNumber());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallBlockersChangedMsg, blockersSet)
{
std::vector<int> blockers = self->fThis->BlockersSet();
PyObject* retVal = PyList_New(blockers.size());
for (unsigned i = 0; i < blockers.size(); ++i)
PyList_SetItem(retVal, i, PyInt_FromLong(blockers[i])); // steals the ref
return retVal;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallBlockersChangedMsg, localOnly)
{
PYTHON_RETURN_BOOL(self->fThis->LocalOnly());
}
PYTHON_START_METHODS_TABLE(ptClimbingWallBlockersChangedMsg)
PYTHON_METHOD_NOARGS(ptClimbingWallBlockersChangedMsg, teamNumber, "The team that this message is for"),
PYTHON_METHOD_NOARGS(ptClimbingWallBlockersChangedMsg, blockersSet, "Returns an array of blocker indicies denoting which blockers are set"),
PYTHON_METHOD_NOARGS(ptClimbingWallBlockersChangedMsg, localOnly, "Returns true if we are only supposed to adjust our stuff locally, and not net-prop it"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptClimbingWallBlockersChangedMsg, pyClimbingWallMsg, "ClimbingWall message received when the blocker state changes");
// required functions for PyObject interoperability
PyObject* pyClimbingWallBlockersChangedMsg::New(pfGameCliMsg* msg)
{
ptClimbingWallBlockersChangedMsg *newObj = (ptClimbingWallBlockersChangedMsg*)ptClimbingWallBlockersChangedMsg_type.tp_new(&ptClimbingWallBlockersChangedMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_ClimbingWall_BlockersChanged))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptClimbingWallBlockersChangedMsg, pyClimbingWallBlockersChangedMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptClimbingWallBlockersChangedMsg, pyClimbingWallBlockersChangedMsg)
// Module and method definitions
void pyClimbingWallBlockersChangedMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptClimbingWallBlockersChangedMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptClimbingWallPlayerEnteredMsg, pyClimbingWallPlayerEnteredMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptClimbingWallPlayerEnteredMsg, pyClimbingWallPlayerEnteredMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptClimbingWallPlayerEnteredMsg)
PYTHON_NO_INIT_DEFINITION(ptClimbingWallPlayerEnteredMsg)
PYTHON_START_METHODS_TABLE(ptClimbingWallPlayerEnteredMsg)
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptClimbingWallPlayerEnteredMsg, pyClimbingWallMsg, "ClimbingWall message received when you successfully enter the suit machine");
// required functions for PyObject interoperability
PyObject* pyClimbingWallPlayerEnteredMsg::New(pfGameCliMsg* msg)
{
ptClimbingWallPlayerEnteredMsg *newObj = (ptClimbingWallPlayerEnteredMsg*)ptClimbingWallPlayerEnteredMsg_type.tp_new(&ptClimbingWallPlayerEnteredMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_ClimbingWall_PlayerEntered))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptClimbingWallPlayerEnteredMsg, pyClimbingWallPlayerEnteredMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptClimbingWallPlayerEnteredMsg, pyClimbingWallPlayerEnteredMsg)
// Module and method definitions
void pyClimbingWallPlayerEnteredMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptClimbingWallPlayerEnteredMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptClimbingWallSuitMachineLockedMsg, pyClimbingWallSuitMachineLockedMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptClimbingWallSuitMachineLockedMsg, pyClimbingWallSuitMachineLockedMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptClimbingWallSuitMachineLockedMsg)
PYTHON_NO_INIT_DEFINITION(ptClimbingWallSuitMachineLockedMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallSuitMachineLockedMsg, team1MachineLocked)
{
PYTHON_RETURN_BOOL(self->fThis->Team1MachineLocked());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallSuitMachineLockedMsg, team2MachineLocked)
{
PYTHON_RETURN_BOOL(self->fThis->Team2MachineLocked());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallSuitMachineLockedMsg, localOnly)
{
PYTHON_RETURN_BOOL(self->fThis->LocalOnly());
}
PYTHON_START_METHODS_TABLE(ptClimbingWallSuitMachineLockedMsg)
PYTHON_METHOD_NOARGS(ptClimbingWallSuitMachineLockedMsg, team1MachineLocked, "Whether team 1's suit machine is locked or not"),
PYTHON_METHOD_NOARGS(ptClimbingWallSuitMachineLockedMsg, team2MachineLocked, "Whether team 2's suit machine is locked or not"),
PYTHON_METHOD_NOARGS(ptClimbingWallSuitMachineLockedMsg, localOnly, "Returns true if we are only supposed to adjust our stuff locally, and not net-prop it"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptClimbingWallSuitMachineLockedMsg, pyClimbingWallMsg, "ClimbingWall message received when the locked state of the suit machines is changed");
// required functions for PyObject interoperability
PyObject* pyClimbingWallSuitMachineLockedMsg::New(pfGameCliMsg* msg)
{
ptClimbingWallSuitMachineLockedMsg *newObj = (ptClimbingWallSuitMachineLockedMsg*)ptClimbingWallSuitMachineLockedMsg_type.tp_new(&ptClimbingWallSuitMachineLockedMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_ClimbingWall_SuitMachineLocked))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptClimbingWallSuitMachineLockedMsg, pyClimbingWallSuitMachineLockedMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptClimbingWallSuitMachineLockedMsg, pyClimbingWallSuitMachineLockedMsg)
// Module and method definitions
void pyClimbingWallSuitMachineLockedMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptClimbingWallSuitMachineLockedMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptClimbingWallGameOverMsg, pyClimbingWallGameOverMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptClimbingWallGameOverMsg, pyClimbingWallGameOverMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptClimbingWallGameOverMsg)
PYTHON_NO_INIT_DEFINITION(ptClimbingWallGameOverMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallGameOverMsg, teamWon)
{
return PyInt_FromLong((long)self->fThis->TeamWon());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallGameOverMsg, team1Blockers)
{
std::vector<int> blockers = self->fThis->Team1Blockers();
PyObject* retVal = PyList_New(blockers.size());
for (unsigned i = 0; i < blockers.size(); ++i)
PyList_SetItem(retVal, i, PyInt_FromLong(blockers[i])); // steals the ref
return retVal;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallGameOverMsg, team2Blockers)
{
std::vector<int> blockers = self->fThis->Team2Blockers();
PyObject* retVal = PyList_New(blockers.size());
for (unsigned i = 0; i < blockers.size(); ++i)
PyList_SetItem(retVal, i, PyInt_FromLong(blockers[i])); // steals the ref
return retVal;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallGameOverMsg, localOnly)
{
PYTHON_RETURN_BOOL(self->fThis->LocalOnly());
}
PYTHON_START_METHODS_TABLE(ptClimbingWallGameOverMsg)
PYTHON_METHOD_NOARGS(ptClimbingWallGameOverMsg, teamWon, "The team that won the game"),
PYTHON_METHOD_NOARGS(ptClimbingWallGameOverMsg, team1Blockers, "Returns an array of blocker indicies denoting which blockers team 1 set"),
PYTHON_METHOD_NOARGS(ptClimbingWallGameOverMsg, team2Blockers, "Returns an array of blocker indicies denoting which blockers team 2 set"),
PYTHON_METHOD_NOARGS(ptClimbingWallGameOverMsg, localOnly, "Returns true if we are only supposed to adjust our stuff locally, and not net-prop it"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptClimbingWallGameOverMsg, pyClimbingWallMsg, "ClimbingWall message received when the game is over");
// required functions for PyObject interoperability
PyObject* pyClimbingWallGameOverMsg::New(pfGameCliMsg* msg)
{
ptClimbingWallGameOverMsg *newObj = (ptClimbingWallGameOverMsg*)ptClimbingWallGameOverMsg_type.tp_new(&ptClimbingWallGameOverMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_ClimbingWall_GameOver))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptClimbingWallGameOverMsg, pyClimbingWallGameOverMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptClimbingWallGameOverMsg, pyClimbingWallGameOverMsg)
// Module and method definitions
void pyClimbingWallGameOverMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptClimbingWallGameOverMsg);
PYTHON_CLASS_IMPORT_END(m);
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyClimbingWallMsg.h"
#include "../../pyEnum.h"
#include <python.h>
///////////////////////////////////////////////////////////////////////////////
//
// Base climbing wall msg class
//
PYTHON_CLASS_DEFINITION(ptClimbingWallMsg, pyClimbingWallMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptClimbingWallMsg, pyClimbingWallMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptClimbingWallMsg)
PYTHON_NO_INIT_DEFINITION(ptClimbingWallMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallMsg, getClimbingWallMsgType)
{
return PyInt_FromLong(self->fThis->GetClimbingWallMsgType());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallMsg, upcastToFinalClimbingWallMsg)
{
return self->fThis->UpcastToFinalClimbingWallMsg();
}
PYTHON_START_METHODS_TABLE(ptClimbingWallMsg)
PYTHON_METHOD_NOARGS(ptClimbingWallMsg, getClimbingWallMsgType, "Returns the type of the ClimbingWall message (see PtClimbingWallMsgTypes)"),
PYTHON_METHOD_NOARGS(ptClimbingWallMsg, upcastToFinalClimbingWallMsg, "Returns this message as the ClimbingWall msg it is"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptClimbingWallMsg, pyGameCliMsg, "Base class for ClimbingWall game messages");
PYTHON_EXPOSE_TYPE_DEFINITION(ptClimbingWallMsg, pyClimbingWallMsg);
// required functions for PyObject interoperability
PyObject* pyClimbingWallMsg::New(pfGameCliMsg* msg)
{
ptClimbingWallMsg *newObj = (ptClimbingWallMsg*)ptClimbingWallMsg_type.tp_new(&ptClimbingWallMsg_type, NULL, NULL);
if (msg && (msg->gameCli->GetGameTypeId() == kGameTypeId_ClimbingWall))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptClimbingWallMsg, pyClimbingWallMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptClimbingWallMsg, pyClimbingWallMsg)
// Module and method definitions
void pyClimbingWallMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptClimbingWallMsg);
PYTHON_CLASS_IMPORT_END(m);
}
void pyClimbingWallMsg::AddPlasmaConstantsClasses(PyObject* m)
{
PYTHON_ENUM_START(PtClimbingWallMsgTypes);
PYTHON_ENUM_ELEMENT(PtClimbingWallMsgTypes, kClimbingWallNumBlockersChanged, kSrv2Cli_ClimbingWall_NumBlockersChanged);
PYTHON_ENUM_ELEMENT(PtClimbingWallMsgTypes, kClimbingWallReadyMsg, kSrv2Cli_ClimbingWall_Ready);
PYTHON_ENUM_ELEMENT(PtClimbingWallMsgTypes, kClimbingWallBlockersChanged, kSrv2Cli_ClimbingWall_BlockersChanged);
PYTHON_ENUM_ELEMENT(PtClimbingWallMsgTypes, kClimbingWallPlayerEntered, kSrv2Cli_ClimbingWall_PlayerEntered);
PYTHON_ENUM_ELEMENT(PtClimbingWallMsgTypes, kClimbingWallSuitMachineLocked, kSrv2Cli_ClimbingWall_SuitMachineLocked);
PYTHON_ENUM_ELEMENT(PtClimbingWallMsgTypes, kClimbingWallGameOver, kSrv2Cli_ClimbingWall_GameOver);
PYTHON_ENUM_END(m, PtClimbingWallMsgTypes);
}
///////////////////////////////////////////////////////////////////////////////
//
// Game client message subclasses
//
PYTHON_CLASS_DEFINITION(ptClimbingWallNumBlockersChangedMsg, pyClimbingWallNumBlockersChangedMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptClimbingWallNumBlockersChangedMsg, pyClimbingWallNumBlockersChangedMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptClimbingWallNumBlockersChangedMsg)
PYTHON_NO_INIT_DEFINITION(ptClimbingWallNumBlockersChangedMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallNumBlockersChangedMsg, newBlockerCount)
{
return PyInt_FromLong((long)self->fThis->NewBlockerCount());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallNumBlockersChangedMsg, localOnly)
{
PYTHON_RETURN_BOOL(self->fThis->LocalOnly());
}
PYTHON_START_METHODS_TABLE(ptClimbingWallNumBlockersChangedMsg)
PYTHON_METHOD_NOARGS(ptClimbingWallNumBlockersChangedMsg, newBlockerCount, "Returns the number of blockers this game is current running with"),
PYTHON_METHOD_NOARGS(ptClimbingWallNumBlockersChangedMsg, localOnly, "Returns true if we are only supposed to adjust our stuff locally, and not net-prop it"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptClimbingWallNumBlockersChangedMsg, pyClimbingWallMsg, "ClimbingWall message received when the number of blockers is changed");
// required functions for PyObject interoperability
PyObject* pyClimbingWallNumBlockersChangedMsg::New(pfGameCliMsg* msg)
{
ptClimbingWallNumBlockersChangedMsg *newObj = (ptClimbingWallNumBlockersChangedMsg*)ptClimbingWallNumBlockersChangedMsg_type.tp_new(&ptClimbingWallNumBlockersChangedMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_ClimbingWall_NumBlockersChanged))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptClimbingWallNumBlockersChangedMsg, pyClimbingWallNumBlockersChangedMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptClimbingWallNumBlockersChangedMsg, pyClimbingWallNumBlockersChangedMsg)
// Module and method definitions
void pyClimbingWallNumBlockersChangedMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptClimbingWallNumBlockersChangedMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptClimbingWallReadyMsg, pyClimbingWallReadyMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptClimbingWallReadyMsg, pyClimbingWallReadyMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptClimbingWallReadyMsg)
PYTHON_NO_INIT_DEFINITION(ptClimbingWallReadyMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallReadyMsg, readyType)
{
return PyInt_FromLong((long)self->fThis->ReadyType());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallReadyMsg, team1Ready)
{
PYTHON_RETURN_BOOL(self->fThis->Team1Ready());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallReadyMsg, team2Ready)
{
PYTHON_RETURN_BOOL(self->fThis->Team2Ready());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallReadyMsg, localOnly)
{
PYTHON_RETURN_BOOL(self->fThis->LocalOnly());
}
PYTHON_START_METHODS_TABLE(ptClimbingWallReadyMsg)
PYTHON_METHOD_NOARGS(ptClimbingWallReadyMsg, readyType, "The type of ready message this represents (see PtClimbingWallReadyTypes)"),
PYTHON_METHOD_NOARGS(ptClimbingWallReadyMsg, team1Ready, "Whether team 1 is ready or not"),
PYTHON_METHOD_NOARGS(ptClimbingWallReadyMsg, team2Ready, "Whether team 2 is ready or not"),
PYTHON_METHOD_NOARGS(ptClimbingWallReadyMsg, localOnly, "Returns true if we are only supposed to adjust our stuff locally, and not net-prop it"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptClimbingWallReadyMsg, pyClimbingWallMsg, "ClimbingWall message received when the ready state of the teams is changed");
// required functions for PyObject interoperability
PyObject* pyClimbingWallReadyMsg::New(pfGameCliMsg* msg)
{
ptClimbingWallReadyMsg *newObj = (ptClimbingWallReadyMsg*)ptClimbingWallReadyMsg_type.tp_new(&ptClimbingWallReadyMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_ClimbingWall_Ready))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptClimbingWallReadyMsg, pyClimbingWallReadyMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptClimbingWallReadyMsg, pyClimbingWallReadyMsg)
// Module and method definitions
void pyClimbingWallReadyMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptClimbingWallReadyMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptClimbingWallBlockersChangedMsg, pyClimbingWallBlockersChangedMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptClimbingWallBlockersChangedMsg, pyClimbingWallBlockersChangedMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptClimbingWallBlockersChangedMsg)
PYTHON_NO_INIT_DEFINITION(ptClimbingWallBlockersChangedMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallBlockersChangedMsg, teamNumber)
{
return PyInt_FromLong((long)self->fThis->TeamNumber());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallBlockersChangedMsg, blockersSet)
{
std::vector<int> blockers = self->fThis->BlockersSet();
PyObject* retVal = PyList_New(blockers.size());
for (unsigned i = 0; i < blockers.size(); ++i)
PyList_SetItem(retVal, i, PyInt_FromLong(blockers[i])); // steals the ref
return retVal;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallBlockersChangedMsg, localOnly)
{
PYTHON_RETURN_BOOL(self->fThis->LocalOnly());
}
PYTHON_START_METHODS_TABLE(ptClimbingWallBlockersChangedMsg)
PYTHON_METHOD_NOARGS(ptClimbingWallBlockersChangedMsg, teamNumber, "The team that this message is for"),
PYTHON_METHOD_NOARGS(ptClimbingWallBlockersChangedMsg, blockersSet, "Returns an array of blocker indicies denoting which blockers are set"),
PYTHON_METHOD_NOARGS(ptClimbingWallBlockersChangedMsg, localOnly, "Returns true if we are only supposed to adjust our stuff locally, and not net-prop it"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptClimbingWallBlockersChangedMsg, pyClimbingWallMsg, "ClimbingWall message received when the blocker state changes");
// required functions for PyObject interoperability
PyObject* pyClimbingWallBlockersChangedMsg::New(pfGameCliMsg* msg)
{
ptClimbingWallBlockersChangedMsg *newObj = (ptClimbingWallBlockersChangedMsg*)ptClimbingWallBlockersChangedMsg_type.tp_new(&ptClimbingWallBlockersChangedMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_ClimbingWall_BlockersChanged))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptClimbingWallBlockersChangedMsg, pyClimbingWallBlockersChangedMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptClimbingWallBlockersChangedMsg, pyClimbingWallBlockersChangedMsg)
// Module and method definitions
void pyClimbingWallBlockersChangedMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptClimbingWallBlockersChangedMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptClimbingWallPlayerEnteredMsg, pyClimbingWallPlayerEnteredMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptClimbingWallPlayerEnteredMsg, pyClimbingWallPlayerEnteredMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptClimbingWallPlayerEnteredMsg)
PYTHON_NO_INIT_DEFINITION(ptClimbingWallPlayerEnteredMsg)
PYTHON_START_METHODS_TABLE(ptClimbingWallPlayerEnteredMsg)
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptClimbingWallPlayerEnteredMsg, pyClimbingWallMsg, "ClimbingWall message received when you successfully enter the suit machine");
// required functions for PyObject interoperability
PyObject* pyClimbingWallPlayerEnteredMsg::New(pfGameCliMsg* msg)
{
ptClimbingWallPlayerEnteredMsg *newObj = (ptClimbingWallPlayerEnteredMsg*)ptClimbingWallPlayerEnteredMsg_type.tp_new(&ptClimbingWallPlayerEnteredMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_ClimbingWall_PlayerEntered))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptClimbingWallPlayerEnteredMsg, pyClimbingWallPlayerEnteredMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptClimbingWallPlayerEnteredMsg, pyClimbingWallPlayerEnteredMsg)
// Module and method definitions
void pyClimbingWallPlayerEnteredMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptClimbingWallPlayerEnteredMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptClimbingWallSuitMachineLockedMsg, pyClimbingWallSuitMachineLockedMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptClimbingWallSuitMachineLockedMsg, pyClimbingWallSuitMachineLockedMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptClimbingWallSuitMachineLockedMsg)
PYTHON_NO_INIT_DEFINITION(ptClimbingWallSuitMachineLockedMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallSuitMachineLockedMsg, team1MachineLocked)
{
PYTHON_RETURN_BOOL(self->fThis->Team1MachineLocked());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallSuitMachineLockedMsg, team2MachineLocked)
{
PYTHON_RETURN_BOOL(self->fThis->Team2MachineLocked());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallSuitMachineLockedMsg, localOnly)
{
PYTHON_RETURN_BOOL(self->fThis->LocalOnly());
}
PYTHON_START_METHODS_TABLE(ptClimbingWallSuitMachineLockedMsg)
PYTHON_METHOD_NOARGS(ptClimbingWallSuitMachineLockedMsg, team1MachineLocked, "Whether team 1's suit machine is locked or not"),
PYTHON_METHOD_NOARGS(ptClimbingWallSuitMachineLockedMsg, team2MachineLocked, "Whether team 2's suit machine is locked or not"),
PYTHON_METHOD_NOARGS(ptClimbingWallSuitMachineLockedMsg, localOnly, "Returns true if we are only supposed to adjust our stuff locally, and not net-prop it"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptClimbingWallSuitMachineLockedMsg, pyClimbingWallMsg, "ClimbingWall message received when the locked state of the suit machines is changed");
// required functions for PyObject interoperability
PyObject* pyClimbingWallSuitMachineLockedMsg::New(pfGameCliMsg* msg)
{
ptClimbingWallSuitMachineLockedMsg *newObj = (ptClimbingWallSuitMachineLockedMsg*)ptClimbingWallSuitMachineLockedMsg_type.tp_new(&ptClimbingWallSuitMachineLockedMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_ClimbingWall_SuitMachineLocked))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptClimbingWallSuitMachineLockedMsg, pyClimbingWallSuitMachineLockedMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptClimbingWallSuitMachineLockedMsg, pyClimbingWallSuitMachineLockedMsg)
// Module and method definitions
void pyClimbingWallSuitMachineLockedMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptClimbingWallSuitMachineLockedMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptClimbingWallGameOverMsg, pyClimbingWallGameOverMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptClimbingWallGameOverMsg, pyClimbingWallGameOverMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptClimbingWallGameOverMsg)
PYTHON_NO_INIT_DEFINITION(ptClimbingWallGameOverMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallGameOverMsg, teamWon)
{
return PyInt_FromLong((long)self->fThis->TeamWon());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallGameOverMsg, team1Blockers)
{
std::vector<int> blockers = self->fThis->Team1Blockers();
PyObject* retVal = PyList_New(blockers.size());
for (unsigned i = 0; i < blockers.size(); ++i)
PyList_SetItem(retVal, i, PyInt_FromLong(blockers[i])); // steals the ref
return retVal;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallGameOverMsg, team2Blockers)
{
std::vector<int> blockers = self->fThis->Team2Blockers();
PyObject* retVal = PyList_New(blockers.size());
for (unsigned i = 0; i < blockers.size(); ++i)
PyList_SetItem(retVal, i, PyInt_FromLong(blockers[i])); // steals the ref
return retVal;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptClimbingWallGameOverMsg, localOnly)
{
PYTHON_RETURN_BOOL(self->fThis->LocalOnly());
}
PYTHON_START_METHODS_TABLE(ptClimbingWallGameOverMsg)
PYTHON_METHOD_NOARGS(ptClimbingWallGameOverMsg, teamWon, "The team that won the game"),
PYTHON_METHOD_NOARGS(ptClimbingWallGameOverMsg, team1Blockers, "Returns an array of blocker indicies denoting which blockers team 1 set"),
PYTHON_METHOD_NOARGS(ptClimbingWallGameOverMsg, team2Blockers, "Returns an array of blocker indicies denoting which blockers team 2 set"),
PYTHON_METHOD_NOARGS(ptClimbingWallGameOverMsg, localOnly, "Returns true if we are only supposed to adjust our stuff locally, and not net-prop it"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptClimbingWallGameOverMsg, pyClimbingWallMsg, "ClimbingWall message received when the game is over");
// required functions for PyObject interoperability
PyObject* pyClimbingWallGameOverMsg::New(pfGameCliMsg* msg)
{
ptClimbingWallGameOverMsg *newObj = (ptClimbingWallGameOverMsg*)ptClimbingWallGameOverMsg_type.tp_new(&ptClimbingWallGameOverMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_ClimbingWall_GameOver))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptClimbingWallGameOverMsg, pyClimbingWallGameOverMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptClimbingWallGameOverMsg, pyClimbingWallGameOverMsg)
// Module and method definitions
void pyClimbingWallGameOverMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptClimbingWallGameOverMsg);
PYTHON_CLASS_IMPORT_END(m);
}

View File

@ -1,86 +1,86 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyHeekGame.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base Heek game client class
//
pyHeekGame::pyHeekGame(): pyGameCli() {}
pyHeekGame::pyHeekGame(pfGameCli* client): pyGameCli(client)
{
if (client && (client->GetGameTypeId() != kGameTypeId_Heek))
gameClient = nil; // wrong type, just clear it out
}
bool pyHeekGame::IsHeekGame(std::wstring guid)
{
Uuid gameUuid(guid.c_str());
return gameUuid == kGameTypeId_Heek;
}
void pyHeekGame::JoinCommonHeekGame(pyKey& callbackKey, unsigned gameID)
{
pfGameMgr::GetInstance()->JoinCommonGame(callbackKey.getKey(), kGameTypeId_Heek, gameID, 0, NULL);
}
void pyHeekGame::PlayGame(int position, UInt32 points, std::wstring name)
{
if (gameClient)
{
pfGmHeek* heek = pfGmHeek::ConvertNoRef(gameClient);
heek->PlayGame((unsigned)position, (dword)points, name.c_str());
}
}
void pyHeekGame::LeaveGame()
{
if (gameClient)
{
pfGmHeek* heek = pfGmHeek::ConvertNoRef(gameClient);
heek->LeaveGame();
}
}
void pyHeekGame::Choose(int choice)
{
if (gameClient)
{
pfGmHeek* heek = pfGmHeek::ConvertNoRef(gameClient);
heek->Choose((EHeekChoice)choice);
}
}
void pyHeekGame::SequenceFinished(int seq)
{
if (gameClient)
{
pfGmHeek* heek = pfGmHeek::ConvertNoRef(gameClient);
heek->SequenceFinished((EHeekSeqFinished)seq);
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyHeekGame.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base Heek game client class
//
pyHeekGame::pyHeekGame(): pyGameCli() {}
pyHeekGame::pyHeekGame(pfGameCli* client): pyGameCli(client)
{
if (client && (client->GetGameTypeId() != kGameTypeId_Heek))
gameClient = nil; // wrong type, just clear it out
}
bool pyHeekGame::IsHeekGame(std::wstring guid)
{
Uuid gameUuid(guid.c_str());
return gameUuid == kGameTypeId_Heek;
}
void pyHeekGame::JoinCommonHeekGame(pyKey& callbackKey, unsigned gameID)
{
pfGameMgr::GetInstance()->JoinCommonGame(callbackKey.getKey(), kGameTypeId_Heek, gameID, 0, NULL);
}
void pyHeekGame::PlayGame(int position, UInt32 points, std::wstring name)
{
if (gameClient)
{
pfGmHeek* heek = pfGmHeek::ConvertNoRef(gameClient);
heek->PlayGame((unsigned)position, (dword)points, name.c_str());
}
}
void pyHeekGame::LeaveGame()
{
if (gameClient)
{
pfGmHeek* heek = pfGmHeek::ConvertNoRef(gameClient);
heek->LeaveGame();
}
}
void pyHeekGame::Choose(int choice)
{
if (gameClient)
{
pfGmHeek* heek = pfGmHeek::ConvertNoRef(gameClient);
heek->Choose((EHeekChoice)choice);
}
}
void pyHeekGame::SequenceFinished(int seq)
{
if (gameClient)
{
pfGmHeek* heek = pfGmHeek::ConvertNoRef(gameClient);
heek->SequenceFinished((EHeekSeqFinished)seq);
}
}

View File

@ -1,69 +1,69 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyHeekGame_h
#define pyHeekGame_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: pyHeekGame
//
// PURPOSE: Class wrapper for the Heek game client
//
#include "pfGameMgr/pfGameMgr.h"
#include <python.h>
#include "../../pyGlueHelpers.h"
#include "../pyGameCli.h"
#include "../../pyKey.h"
class pyHeekGame : public pyGameCli
{
protected:
pyHeekGame();
pyHeekGame(pfGameCli* client);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptHeekGame);
static PyObject* New(pfGameCli* client);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekGame object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekGame); // converts a PyObject to a pyHeekGame (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaConstantsClasses(PyObject* m);
static void AddPlasmaMethods(std::vector<PyMethodDef>& methods);
static bool IsHeekGame(std::wstring guid);
static void JoinCommonHeekGame(pyKey& callbackKey, unsigned gameID);
void PlayGame(int position, UInt32 points, std::wstring name);
void LeaveGame();
void Choose(int choice);
void SequenceFinished(int seq);
};
#endif // pyHeekGame_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyHeekGame_h
#define pyHeekGame_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: pyHeekGame
//
// PURPOSE: Class wrapper for the Heek game client
//
#include "pfGameMgr/pfGameMgr.h"
#include <python.h>
#include "../../pyGlueHelpers.h"
#include "../pyGameCli.h"
#include "../../pyKey.h"
class pyHeekGame : public pyGameCli
{
protected:
pyHeekGame();
pyHeekGame(pfGameCli* client);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptHeekGame);
static PyObject* New(pfGameCli* client);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekGame object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekGame); // converts a PyObject to a pyHeekGame (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaConstantsClasses(PyObject* m);
static void AddPlasmaMethods(std::vector<PyMethodDef>& methods);
static bool IsHeekGame(std::wstring guid);
static void JoinCommonHeekGame(pyKey& callbackKey, unsigned gameID);
void PlayGame(int position, UInt32 points, std::wstring name);
void LeaveGame();
void Choose(int choice);
void SequenceFinished(int seq);
};
#endif // pyHeekGame_h

View File

@ -1,207 +1,207 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyHeekGame.h"
#include <python.h>
#include "../../pyEnum.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base Heek game client class
//
PYTHON_CLASS_DEFINITION(ptHeekGame, pyHeekGame);
PYTHON_DEFAULT_NEW_DEFINITION(ptHeekGame, pyHeekGame)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptHeekGame)
PYTHON_NO_INIT_DEFINITION(ptHeekGame)
PYTHON_GLOBAL_METHOD_DEFINITION(PtIsHeekGame, args, "Params: typeID\nReturns true if the specifed typeID (guid as a string) is a Heek game")
{
PyObject* textObj;
if (!PyArg_ParseTuple(args, "O", &textObj))
{
PyErr_SetString(PyExc_TypeError, "PtIsHeekGame expects a unicode string");
PYTHON_RETURN_ERROR;
}
if (PyUnicode_Check(textObj))
{
int strLen = PyUnicode_GetSize(textObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)textObj, text, strLen);
text[strLen] = L'\0';
bool retVal = pyHeekGame::IsHeekGame(text);
delete [] text;
PYTHON_RETURN_BOOL(retVal);
}
else if (PyString_Check(textObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(textObj);
wchar_t* wText = hsStringToWString(text);
bool retVal = pyHeekGame::IsHeekGame(wText);
delete [] wText;
PYTHON_RETURN_BOOL(retVal);
}
else
{
PyErr_SetString(PyExc_TypeError, "PtIsHeekGame expects a unicode string");
PYTHON_RETURN_ERROR;
}
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtJoinCommonHeekGame, args, "Params: callbackKey, gameID\nJoins a common Heek game with the specified ID. If one doesn't exist, it creates it")
{
PyObject* callbackObj = NULL;
int gameID = 0;
if (!PyArg_ParseTuple(args, "Oi", &callbackObj, &gameID))
{
PyErr_SetString(PyExc_TypeError, "PtJoinCommonHeekGame expects a ptKey and an integer");
PYTHON_RETURN_ERROR;
}
if (!pyKey::Check(callbackObj))
{
PyErr_SetString(PyExc_TypeError, "PtJoinCommonHeekGame expects a ptKey and an integer");
PYTHON_RETURN_ERROR;
}
pyKey* key = pyKey::ConvertFrom(callbackObj);
pyHeekGame::JoinCommonHeekGame(*key, gameID);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptHeekGame, playGame, args)
{
int position = 0;
long points = 0;
PyObject* textObj = NULL;
if (!PyArg_ParseTuple(args,"ilO", &position, &points, &textObj))
{
PyErr_SetString(PyExc_TypeError, "playGame expects an int, a long, and a unicode string");
PYTHON_RETURN_ERROR;
}
if (PyUnicode_Check(textObj))
{
int strLen = PyUnicode_GetSize(textObj);
wchar_t* temp = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)textObj, temp, strLen);
temp[strLen] = L'\0';
self->fThis->PlayGame(position, points, temp);
delete [] temp;
PYTHON_RETURN_NONE;
}
else if (PyString_Check(textObj))
{
// we'll allow this, just in case something goes weird
char* temp = PyString_AsString(textObj);
wchar_t* wTemp = hsStringToWString(temp);
self->fThis->PlayGame(position, points, wTemp);
delete [] wTemp;
PYTHON_RETURN_NONE;
}
else
{
PyErr_SetString(PyExc_TypeError, "playGame expects an int, a long, and a unicode string");
PYTHON_RETURN_ERROR;
}
}
PYTHON_BASIC_METHOD_DEFINITION(ptHeekGame, leaveGame, LeaveGame)
PYTHON_METHOD_DEFINITION(ptHeekGame, choose, args)
{
int choice = 0;
if (!PyArg_ParseTuple(args, "i", &choice))
{
PyErr_SetString(PyExc_TypeError, "choose expects an int");
PYTHON_RETURN_ERROR;
}
self->fThis->Choose(choice);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptHeekGame, sequenceFinished, args)
{
int seq = 0;
if (!PyArg_ParseTuple(args, "i", &seq))
{
PyErr_SetString(PyExc_TypeError, "sequenceFinished expects an int");
PYTHON_RETURN_ERROR;
}
self->fThis->SequenceFinished(seq);
PYTHON_RETURN_NONE;
}
PYTHON_START_METHODS_TABLE(ptHeekGame)
PYTHON_METHOD(ptHeekGame, playGame, "Params: position, points, name\nRequests to start playing the game in the specified position"),
PYTHON_BASIC_METHOD(ptHeekGame, leaveGame, "Leaves this game (puts us into \"observer\" mode"),
PYTHON_METHOD(ptHeekGame, choose, "Params: choice\nMakes the specified move (see PtHeekGameChoice)"),
PYTHON_METHOD(ptHeekGame, sequenceFinished, "Params: sequence\nTells the server that the specified animation finished (see PtHeekGameSeq)"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptHeekGame, pyGameCli, "Game client for the Heek game");
// required functions for PyObject interoperability
PyObject* pyHeekGame::New(pfGameCli* client)
{
ptHeekGame *newObj = (ptHeekGame*)ptHeekGame_type.tp_new(&ptHeekGame_type, NULL, NULL);
if (client && (client->GetGameTypeId() == kGameTypeId_Heek))
newObj->fThis->gameClient = client;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptHeekGame, pyHeekGame)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptHeekGame, pyHeekGame)
// Module and method definitions
void pyHeekGame::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptHeekGame);
PYTHON_CLASS_IMPORT_END(m);
}
void pyHeekGame::AddPlasmaConstantsClasses(PyObject* m)
{
PYTHON_ENUM_START(PtHeekGameChoice);
PYTHON_ENUM_ELEMENT(PtHeekGameChoice, kHeekGameChoiceRock, kHeekRock);
PYTHON_ENUM_ELEMENT(PtHeekGameChoice, kHeekGameChoicePaper, kHeekPaper);
PYTHON_ENUM_ELEMENT(PtHeekGameChoice, kHeekGameChoiceScissors, kHeekScissors);
PYTHON_ENUM_END(m, PtHeekGameChoice);
PYTHON_ENUM_START(PtHeekGameSeq);
PYTHON_ENUM_ELEMENT(PtHeekGameSeq, kHeekGameSeqCountdown, kHeekCountdownSeq);
PYTHON_ENUM_ELEMENT(PtHeekGameSeq, kHeekGameSeqChoiceAnim, kHeekChoiceAnimSeq);
PYTHON_ENUM_ELEMENT(PtHeekGameSeq, kHeekGameSeqGameWinAnim, kHeekGameWinAnimSeq);
PYTHON_ENUM_END(m, PtHeekGameSeq);
}
void pyHeekGame::AddPlasmaMethods(std::vector<PyMethodDef>& methods)
{
PYTHON_GLOBAL_METHOD(methods, PtIsHeekGame);
PYTHON_GLOBAL_METHOD(methods, PtJoinCommonHeekGame);
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyHeekGame.h"
#include <python.h>
#include "../../pyEnum.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base Heek game client class
//
PYTHON_CLASS_DEFINITION(ptHeekGame, pyHeekGame);
PYTHON_DEFAULT_NEW_DEFINITION(ptHeekGame, pyHeekGame)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptHeekGame)
PYTHON_NO_INIT_DEFINITION(ptHeekGame)
PYTHON_GLOBAL_METHOD_DEFINITION(PtIsHeekGame, args, "Params: typeID\nReturns true if the specifed typeID (guid as a string) is a Heek game")
{
PyObject* textObj;
if (!PyArg_ParseTuple(args, "O", &textObj))
{
PyErr_SetString(PyExc_TypeError, "PtIsHeekGame expects a unicode string");
PYTHON_RETURN_ERROR;
}
if (PyUnicode_Check(textObj))
{
int strLen = PyUnicode_GetSize(textObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)textObj, text, strLen);
text[strLen] = L'\0';
bool retVal = pyHeekGame::IsHeekGame(text);
delete [] text;
PYTHON_RETURN_BOOL(retVal);
}
else if (PyString_Check(textObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(textObj);
wchar_t* wText = hsStringToWString(text);
bool retVal = pyHeekGame::IsHeekGame(wText);
delete [] wText;
PYTHON_RETURN_BOOL(retVal);
}
else
{
PyErr_SetString(PyExc_TypeError, "PtIsHeekGame expects a unicode string");
PYTHON_RETURN_ERROR;
}
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtJoinCommonHeekGame, args, "Params: callbackKey, gameID\nJoins a common Heek game with the specified ID. If one doesn't exist, it creates it")
{
PyObject* callbackObj = NULL;
int gameID = 0;
if (!PyArg_ParseTuple(args, "Oi", &callbackObj, &gameID))
{
PyErr_SetString(PyExc_TypeError, "PtJoinCommonHeekGame expects a ptKey and an integer");
PYTHON_RETURN_ERROR;
}
if (!pyKey::Check(callbackObj))
{
PyErr_SetString(PyExc_TypeError, "PtJoinCommonHeekGame expects a ptKey and an integer");
PYTHON_RETURN_ERROR;
}
pyKey* key = pyKey::ConvertFrom(callbackObj);
pyHeekGame::JoinCommonHeekGame(*key, gameID);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptHeekGame, playGame, args)
{
int position = 0;
long points = 0;
PyObject* textObj = NULL;
if (!PyArg_ParseTuple(args,"ilO", &position, &points, &textObj))
{
PyErr_SetString(PyExc_TypeError, "playGame expects an int, a long, and a unicode string");
PYTHON_RETURN_ERROR;
}
if (PyUnicode_Check(textObj))
{
int strLen = PyUnicode_GetSize(textObj);
wchar_t* temp = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)textObj, temp, strLen);
temp[strLen] = L'\0';
self->fThis->PlayGame(position, points, temp);
delete [] temp;
PYTHON_RETURN_NONE;
}
else if (PyString_Check(textObj))
{
// we'll allow this, just in case something goes weird
char* temp = PyString_AsString(textObj);
wchar_t* wTemp = hsStringToWString(temp);
self->fThis->PlayGame(position, points, wTemp);
delete [] wTemp;
PYTHON_RETURN_NONE;
}
else
{
PyErr_SetString(PyExc_TypeError, "playGame expects an int, a long, and a unicode string");
PYTHON_RETURN_ERROR;
}
}
PYTHON_BASIC_METHOD_DEFINITION(ptHeekGame, leaveGame, LeaveGame)
PYTHON_METHOD_DEFINITION(ptHeekGame, choose, args)
{
int choice = 0;
if (!PyArg_ParseTuple(args, "i", &choice))
{
PyErr_SetString(PyExc_TypeError, "choose expects an int");
PYTHON_RETURN_ERROR;
}
self->fThis->Choose(choice);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptHeekGame, sequenceFinished, args)
{
int seq = 0;
if (!PyArg_ParseTuple(args, "i", &seq))
{
PyErr_SetString(PyExc_TypeError, "sequenceFinished expects an int");
PYTHON_RETURN_ERROR;
}
self->fThis->SequenceFinished(seq);
PYTHON_RETURN_NONE;
}
PYTHON_START_METHODS_TABLE(ptHeekGame)
PYTHON_METHOD(ptHeekGame, playGame, "Params: position, points, name\nRequests to start playing the game in the specified position"),
PYTHON_BASIC_METHOD(ptHeekGame, leaveGame, "Leaves this game (puts us into \"observer\" mode"),
PYTHON_METHOD(ptHeekGame, choose, "Params: choice\nMakes the specified move (see PtHeekGameChoice)"),
PYTHON_METHOD(ptHeekGame, sequenceFinished, "Params: sequence\nTells the server that the specified animation finished (see PtHeekGameSeq)"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptHeekGame, pyGameCli, "Game client for the Heek game");
// required functions for PyObject interoperability
PyObject* pyHeekGame::New(pfGameCli* client)
{
ptHeekGame *newObj = (ptHeekGame*)ptHeekGame_type.tp_new(&ptHeekGame_type, NULL, NULL);
if (client && (client->GetGameTypeId() == kGameTypeId_Heek))
newObj->fThis->gameClient = client;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptHeekGame, pyHeekGame)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptHeekGame, pyHeekGame)
// Module and method definitions
void pyHeekGame::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptHeekGame);
PYTHON_CLASS_IMPORT_END(m);
}
void pyHeekGame::AddPlasmaConstantsClasses(PyObject* m)
{
PYTHON_ENUM_START(PtHeekGameChoice);
PYTHON_ENUM_ELEMENT(PtHeekGameChoice, kHeekGameChoiceRock, kHeekRock);
PYTHON_ENUM_ELEMENT(PtHeekGameChoice, kHeekGameChoicePaper, kHeekPaper);
PYTHON_ENUM_ELEMENT(PtHeekGameChoice, kHeekGameChoiceScissors, kHeekScissors);
PYTHON_ENUM_END(m, PtHeekGameChoice);
PYTHON_ENUM_START(PtHeekGameSeq);
PYTHON_ENUM_ELEMENT(PtHeekGameSeq, kHeekGameSeqCountdown, kHeekCountdownSeq);
PYTHON_ENUM_ELEMENT(PtHeekGameSeq, kHeekGameSeqChoiceAnim, kHeekChoiceAnimSeq);
PYTHON_ENUM_ELEMENT(PtHeekGameSeq, kHeekGameSeqGameWinAnim, kHeekGameWinAnimSeq);
PYTHON_ENUM_END(m, PtHeekGameSeq);
}
void pyHeekGame::AddPlasmaMethods(std::vector<PyMethodDef>& methods)
{
PYTHON_GLOBAL_METHOD(methods, PtIsHeekGame);
PYTHON_GLOBAL_METHOD(methods, PtJoinCommonHeekGame);
}

View File

@ -1,386 +1,386 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyHeekMsg.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base Heek msg class
//
pyHeekMsg::pyHeekMsg(): pyGameCliMsg() {}
pyHeekMsg::pyHeekMsg(pfGameCliMsg* msg): pyGameCliMsg(msg)
{
if (message && (message->gameCli->GetGameTypeId() != kGameTypeId_Heek))
message = nil; // wrong type, just clear it out
}
int pyHeekMsg::GetHeekMsgType() const
{
if (message)
return message->netMsg->messageId;
return -1;
}
PyObject* pyHeekMsg::UpcastToFinalHeekMsg() const
{
if (!message)
PYTHON_RETURN_NONE;
switch (message->netMsg->messageId)
{
case kSrv2Cli_Heek_PlayGame:
return pyHeekPlayGameMsg::New(message);
case kSrv2Cli_Heek_Goodbye:
return pyHeekGoodbyeMsg::New(message);
case kSrv2Cli_Heek_Welcome:
return pyHeekWelcomeMsg::New(message);
case kSrv2Cli_Heek_Drop:
return pyHeekDropMsg::New(message);
case kSrv2Cli_Heek_Setup:
return pyHeekSetupMsg::New(message);
case kSrv2Cli_Heek_LightState:
return pyHeekLightStateMsg::New(message);
case kSrv2Cli_Heek_InterfaceState:
return pyHeekInterfaceStateMsg::New(message);
case kSrv2Cli_Heek_CountdownState:
return pyHeekCountdownStateMsg::New(message);
case kSrv2Cli_Heek_WinLose:
return pyHeekWinLoseMsg::New(message);
case kSrv2Cli_Heek_GameWin:
return pyHeekGameWinMsg::New(message);
case kSrv2Cli_Heek_PointUpdate:
return pyHeekPointUpdateMsg::New(message);
default:
PYTHON_RETURN_NONE;
}
}
///////////////////////////////////////////////////////////////////////////////
//
// The different messages we can receive
//
pyHeekPlayGameMsg::pyHeekPlayGameMsg(): pyHeekMsg() {}
pyHeekPlayGameMsg::pyHeekPlayGameMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_PlayGame))
message = nil; // wrong type, just clear it out
}
bool pyHeekPlayGameMsg::IsPlaying() const
{
if (message)
{
const Srv2Cli_Heek_PlayGame* gmMsg = (const Srv2Cli_Heek_PlayGame*)message->netMsg;
return gmMsg->isPlaying;
}
return false;
}
bool pyHeekPlayGameMsg::IsSinglePlayer() const
{
if (message)
{
const Srv2Cli_Heek_PlayGame* gmMsg = (const Srv2Cli_Heek_PlayGame*)message->netMsg;
return gmMsg->isSinglePlayer;
}
return false;
}
bool pyHeekPlayGameMsg::EnableButtons() const
{
if (message)
{
const Srv2Cli_Heek_PlayGame* gmMsg = (const Srv2Cli_Heek_PlayGame*)message->netMsg;
return gmMsg->enableButtons;
}
return false;
}
///////////////////////////////////////////////////////////////////////////////
pyHeekGoodbyeMsg::pyHeekGoodbyeMsg(): pyHeekMsg() {}
pyHeekGoodbyeMsg::pyHeekGoodbyeMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_Goodbye))
message = nil; // wrong type, just clear it out
}
///////////////////////////////////////////////////////////////////////////////
pyHeekWelcomeMsg::pyHeekWelcomeMsg(): pyHeekMsg() {}
pyHeekWelcomeMsg::pyHeekWelcomeMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_Welcome))
message = nil; // wrong type, just clear it out
}
unsigned long pyHeekWelcomeMsg::Points() const
{
if (message)
{
const Srv2Cli_Heek_Welcome* gmMsg = (const Srv2Cli_Heek_Welcome*)message->netMsg;
return gmMsg->points;
}
return 0;
}
unsigned long pyHeekWelcomeMsg::Rank() const
{
if (message)
{
const Srv2Cli_Heek_Welcome* gmMsg = (const Srv2Cli_Heek_Welcome*)message->netMsg;
return gmMsg->rank;
}
return 0;
}
std::wstring pyHeekWelcomeMsg::Name() const
{
if (message)
{
const Srv2Cli_Heek_Welcome* gmMsg = (const Srv2Cli_Heek_Welcome*)message->netMsg;
return gmMsg->name;
}
return L"";
}
///////////////////////////////////////////////////////////////////////////////
pyHeekDropMsg::pyHeekDropMsg(): pyHeekMsg() {}
pyHeekDropMsg::pyHeekDropMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_Drop))
message = nil; // wrong type, just clear it out
}
int pyHeekDropMsg::Position() const
{
if (message)
{
const Srv2Cli_Heek_Drop* gmMsg = (const Srv2Cli_Heek_Drop*)message->netMsg;
return gmMsg->position;
}
return -1;
}
///////////////////////////////////////////////////////////////////////////////
pyHeekSetupMsg::pyHeekSetupMsg(): pyHeekMsg() {}
pyHeekSetupMsg::pyHeekSetupMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_Welcome))
message = nil; // wrong type, just clear it out
}
int pyHeekSetupMsg::Position() const
{
if (message)
{
const Srv2Cli_Heek_Setup* gmMsg = (const Srv2Cli_Heek_Setup*)message->netMsg;
return gmMsg->position;
}
return -1;
}
bool pyHeekSetupMsg::ButtonState() const
{
if (message)
{
const Srv2Cli_Heek_Setup* gmMsg = (const Srv2Cli_Heek_Setup*)message->netMsg;
return gmMsg->buttonState;
}
return false;
}
std::vector<bool> pyHeekSetupMsg::LightOn() const
{
std::vector<bool> retVal;
if (message)
{
const Srv2Cli_Heek_Setup* gmMsg = (const Srv2Cli_Heek_Setup*)message->netMsg;
int numLights = arrsize(gmMsg->lightOn);
for (int i = 0; i < numLights; ++i)
retVal.push_back(gmMsg->lightOn[i]);
return retVal;
}
return retVal;
}
///////////////////////////////////////////////////////////////////////////////
pyHeekLightStateMsg::pyHeekLightStateMsg(): pyHeekMsg() {}
pyHeekLightStateMsg::pyHeekLightStateMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_LightState))
message = nil; // wrong type, just clear it out
}
int pyHeekLightStateMsg::LightNum() const
{
if (message)
{
const Srv2Cli_Heek_LightState* gmMsg = (const Srv2Cli_Heek_LightState*)message->netMsg;
return gmMsg->lightNum;
}
return -1;
}
int pyHeekLightStateMsg::State() const
{
if (message)
{
const Srv2Cli_Heek_LightState* gmMsg = (const Srv2Cli_Heek_LightState*)message->netMsg;
return gmMsg->state;
}
return -1;
}
///////////////////////////////////////////////////////////////////////////////
pyHeekInterfaceStateMsg::pyHeekInterfaceStateMsg(): pyHeekMsg() {}
pyHeekInterfaceStateMsg::pyHeekInterfaceStateMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_InterfaceState))
message = nil; // wrong type, just clear it out
}
bool pyHeekInterfaceStateMsg::ButtonsEnabled() const
{
if (message)
{
const Srv2Cli_Heek_InterfaceState* gmMsg = (const Srv2Cli_Heek_InterfaceState*)message->netMsg;
return gmMsg->buttonsEnabled;
}
return false;
}
///////////////////////////////////////////////////////////////////////////////
pyHeekCountdownStateMsg::pyHeekCountdownStateMsg(): pyHeekMsg() {}
pyHeekCountdownStateMsg::pyHeekCountdownStateMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_CountdownState))
message = nil; // wrong type, just clear it out
}
int pyHeekCountdownStateMsg::State() const
{
if (message)
{
const Srv2Cli_Heek_CountdownState* gmMsg = (const Srv2Cli_Heek_CountdownState*)message->netMsg;
return gmMsg->state;
}
return false;
}
///////////////////////////////////////////////////////////////////////////////
pyHeekWinLoseMsg::pyHeekWinLoseMsg(): pyHeekMsg() {}
pyHeekWinLoseMsg::pyHeekWinLoseMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_WinLose))
message = nil; // wrong type, just clear it out
}
bool pyHeekWinLoseMsg::Win() const
{
if (message)
{
const Srv2Cli_Heek_WinLose* gmMsg = (const Srv2Cli_Heek_WinLose*)message->netMsg;
return gmMsg->win;
}
return false;
}
int pyHeekWinLoseMsg::Choice() const
{
if (message)
{
const Srv2Cli_Heek_WinLose* gmMsg = (const Srv2Cli_Heek_WinLose*)message->netMsg;
return gmMsg->choice;
}
return -1;
}
///////////////////////////////////////////////////////////////////////////////
pyHeekGameWinMsg::pyHeekGameWinMsg(): pyHeekMsg() {}
pyHeekGameWinMsg::pyHeekGameWinMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_GameWin))
message = nil; // wrong type, just clear it out
}
int pyHeekGameWinMsg::Choice() const
{
if (message)
{
const Srv2Cli_Heek_GameWin* gmMsg = (const Srv2Cli_Heek_GameWin*)message->netMsg;
return gmMsg->choice;
}
return -1;
}
///////////////////////////////////////////////////////////////////////////////
pyHeekPointUpdateMsg::pyHeekPointUpdateMsg(): pyHeekMsg() {}
pyHeekPointUpdateMsg::pyHeekPointUpdateMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_PointUpdate))
message = nil; // wrong type, just clear it out
}
bool pyHeekPointUpdateMsg::DisplayUpdate() const
{
if (message)
{
const Srv2Cli_Heek_PointUpdate* gmMsg = (const Srv2Cli_Heek_PointUpdate*)message->netMsg;
return gmMsg->displayUpdate;
}
return false;
}
unsigned long pyHeekPointUpdateMsg::Points() const
{
if (message)
{
const Srv2Cli_Heek_PointUpdate* gmMsg = (const Srv2Cli_Heek_PointUpdate*)message->netMsg;
return gmMsg->points;
}
return 0;
}
unsigned long pyHeekPointUpdateMsg::Rank() const
{
if (message)
{
const Srv2Cli_Heek_PointUpdate* gmMsg = (const Srv2Cli_Heek_PointUpdate*)message->netMsg;
return gmMsg->rank;
}
return 0;
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyHeekMsg.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base Heek msg class
//
pyHeekMsg::pyHeekMsg(): pyGameCliMsg() {}
pyHeekMsg::pyHeekMsg(pfGameCliMsg* msg): pyGameCliMsg(msg)
{
if (message && (message->gameCli->GetGameTypeId() != kGameTypeId_Heek))
message = nil; // wrong type, just clear it out
}
int pyHeekMsg::GetHeekMsgType() const
{
if (message)
return message->netMsg->messageId;
return -1;
}
PyObject* pyHeekMsg::UpcastToFinalHeekMsg() const
{
if (!message)
PYTHON_RETURN_NONE;
switch (message->netMsg->messageId)
{
case kSrv2Cli_Heek_PlayGame:
return pyHeekPlayGameMsg::New(message);
case kSrv2Cli_Heek_Goodbye:
return pyHeekGoodbyeMsg::New(message);
case kSrv2Cli_Heek_Welcome:
return pyHeekWelcomeMsg::New(message);
case kSrv2Cli_Heek_Drop:
return pyHeekDropMsg::New(message);
case kSrv2Cli_Heek_Setup:
return pyHeekSetupMsg::New(message);
case kSrv2Cli_Heek_LightState:
return pyHeekLightStateMsg::New(message);
case kSrv2Cli_Heek_InterfaceState:
return pyHeekInterfaceStateMsg::New(message);
case kSrv2Cli_Heek_CountdownState:
return pyHeekCountdownStateMsg::New(message);
case kSrv2Cli_Heek_WinLose:
return pyHeekWinLoseMsg::New(message);
case kSrv2Cli_Heek_GameWin:
return pyHeekGameWinMsg::New(message);
case kSrv2Cli_Heek_PointUpdate:
return pyHeekPointUpdateMsg::New(message);
default:
PYTHON_RETURN_NONE;
}
}
///////////////////////////////////////////////////////////////////////////////
//
// The different messages we can receive
//
pyHeekPlayGameMsg::pyHeekPlayGameMsg(): pyHeekMsg() {}
pyHeekPlayGameMsg::pyHeekPlayGameMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_PlayGame))
message = nil; // wrong type, just clear it out
}
bool pyHeekPlayGameMsg::IsPlaying() const
{
if (message)
{
const Srv2Cli_Heek_PlayGame* gmMsg = (const Srv2Cli_Heek_PlayGame*)message->netMsg;
return gmMsg->isPlaying;
}
return false;
}
bool pyHeekPlayGameMsg::IsSinglePlayer() const
{
if (message)
{
const Srv2Cli_Heek_PlayGame* gmMsg = (const Srv2Cli_Heek_PlayGame*)message->netMsg;
return gmMsg->isSinglePlayer;
}
return false;
}
bool pyHeekPlayGameMsg::EnableButtons() const
{
if (message)
{
const Srv2Cli_Heek_PlayGame* gmMsg = (const Srv2Cli_Heek_PlayGame*)message->netMsg;
return gmMsg->enableButtons;
}
return false;
}
///////////////////////////////////////////////////////////////////////////////
pyHeekGoodbyeMsg::pyHeekGoodbyeMsg(): pyHeekMsg() {}
pyHeekGoodbyeMsg::pyHeekGoodbyeMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_Goodbye))
message = nil; // wrong type, just clear it out
}
///////////////////////////////////////////////////////////////////////////////
pyHeekWelcomeMsg::pyHeekWelcomeMsg(): pyHeekMsg() {}
pyHeekWelcomeMsg::pyHeekWelcomeMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_Welcome))
message = nil; // wrong type, just clear it out
}
unsigned long pyHeekWelcomeMsg::Points() const
{
if (message)
{
const Srv2Cli_Heek_Welcome* gmMsg = (const Srv2Cli_Heek_Welcome*)message->netMsg;
return gmMsg->points;
}
return 0;
}
unsigned long pyHeekWelcomeMsg::Rank() const
{
if (message)
{
const Srv2Cli_Heek_Welcome* gmMsg = (const Srv2Cli_Heek_Welcome*)message->netMsg;
return gmMsg->rank;
}
return 0;
}
std::wstring pyHeekWelcomeMsg::Name() const
{
if (message)
{
const Srv2Cli_Heek_Welcome* gmMsg = (const Srv2Cli_Heek_Welcome*)message->netMsg;
return gmMsg->name;
}
return L"";
}
///////////////////////////////////////////////////////////////////////////////
pyHeekDropMsg::pyHeekDropMsg(): pyHeekMsg() {}
pyHeekDropMsg::pyHeekDropMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_Drop))
message = nil; // wrong type, just clear it out
}
int pyHeekDropMsg::Position() const
{
if (message)
{
const Srv2Cli_Heek_Drop* gmMsg = (const Srv2Cli_Heek_Drop*)message->netMsg;
return gmMsg->position;
}
return -1;
}
///////////////////////////////////////////////////////////////////////////////
pyHeekSetupMsg::pyHeekSetupMsg(): pyHeekMsg() {}
pyHeekSetupMsg::pyHeekSetupMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_Welcome))
message = nil; // wrong type, just clear it out
}
int pyHeekSetupMsg::Position() const
{
if (message)
{
const Srv2Cli_Heek_Setup* gmMsg = (const Srv2Cli_Heek_Setup*)message->netMsg;
return gmMsg->position;
}
return -1;
}
bool pyHeekSetupMsg::ButtonState() const
{
if (message)
{
const Srv2Cli_Heek_Setup* gmMsg = (const Srv2Cli_Heek_Setup*)message->netMsg;
return gmMsg->buttonState;
}
return false;
}
std::vector<bool> pyHeekSetupMsg::LightOn() const
{
std::vector<bool> retVal;
if (message)
{
const Srv2Cli_Heek_Setup* gmMsg = (const Srv2Cli_Heek_Setup*)message->netMsg;
int numLights = arrsize(gmMsg->lightOn);
for (int i = 0; i < numLights; ++i)
retVal.push_back(gmMsg->lightOn[i]);
return retVal;
}
return retVal;
}
///////////////////////////////////////////////////////////////////////////////
pyHeekLightStateMsg::pyHeekLightStateMsg(): pyHeekMsg() {}
pyHeekLightStateMsg::pyHeekLightStateMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_LightState))
message = nil; // wrong type, just clear it out
}
int pyHeekLightStateMsg::LightNum() const
{
if (message)
{
const Srv2Cli_Heek_LightState* gmMsg = (const Srv2Cli_Heek_LightState*)message->netMsg;
return gmMsg->lightNum;
}
return -1;
}
int pyHeekLightStateMsg::State() const
{
if (message)
{
const Srv2Cli_Heek_LightState* gmMsg = (const Srv2Cli_Heek_LightState*)message->netMsg;
return gmMsg->state;
}
return -1;
}
///////////////////////////////////////////////////////////////////////////////
pyHeekInterfaceStateMsg::pyHeekInterfaceStateMsg(): pyHeekMsg() {}
pyHeekInterfaceStateMsg::pyHeekInterfaceStateMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_InterfaceState))
message = nil; // wrong type, just clear it out
}
bool pyHeekInterfaceStateMsg::ButtonsEnabled() const
{
if (message)
{
const Srv2Cli_Heek_InterfaceState* gmMsg = (const Srv2Cli_Heek_InterfaceState*)message->netMsg;
return gmMsg->buttonsEnabled;
}
return false;
}
///////////////////////////////////////////////////////////////////////////////
pyHeekCountdownStateMsg::pyHeekCountdownStateMsg(): pyHeekMsg() {}
pyHeekCountdownStateMsg::pyHeekCountdownStateMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_CountdownState))
message = nil; // wrong type, just clear it out
}
int pyHeekCountdownStateMsg::State() const
{
if (message)
{
const Srv2Cli_Heek_CountdownState* gmMsg = (const Srv2Cli_Heek_CountdownState*)message->netMsg;
return gmMsg->state;
}
return false;
}
///////////////////////////////////////////////////////////////////////////////
pyHeekWinLoseMsg::pyHeekWinLoseMsg(): pyHeekMsg() {}
pyHeekWinLoseMsg::pyHeekWinLoseMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_WinLose))
message = nil; // wrong type, just clear it out
}
bool pyHeekWinLoseMsg::Win() const
{
if (message)
{
const Srv2Cli_Heek_WinLose* gmMsg = (const Srv2Cli_Heek_WinLose*)message->netMsg;
return gmMsg->win;
}
return false;
}
int pyHeekWinLoseMsg::Choice() const
{
if (message)
{
const Srv2Cli_Heek_WinLose* gmMsg = (const Srv2Cli_Heek_WinLose*)message->netMsg;
return gmMsg->choice;
}
return -1;
}
///////////////////////////////////////////////////////////////////////////////
pyHeekGameWinMsg::pyHeekGameWinMsg(): pyHeekMsg() {}
pyHeekGameWinMsg::pyHeekGameWinMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_GameWin))
message = nil; // wrong type, just clear it out
}
int pyHeekGameWinMsg::Choice() const
{
if (message)
{
const Srv2Cli_Heek_GameWin* gmMsg = (const Srv2Cli_Heek_GameWin*)message->netMsg;
return gmMsg->choice;
}
return -1;
}
///////////////////////////////////////////////////////////////////////////////
pyHeekPointUpdateMsg::pyHeekPointUpdateMsg(): pyHeekMsg() {}
pyHeekPointUpdateMsg::pyHeekPointUpdateMsg(pfGameCliMsg* msg): pyHeekMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Heek_PointUpdate))
message = nil; // wrong type, just clear it out
}
bool pyHeekPointUpdateMsg::DisplayUpdate() const
{
if (message)
{
const Srv2Cli_Heek_PointUpdate* gmMsg = (const Srv2Cli_Heek_PointUpdate*)message->netMsg;
return gmMsg->displayUpdate;
}
return false;
}
unsigned long pyHeekPointUpdateMsg::Points() const
{
if (message)
{
const Srv2Cli_Heek_PointUpdate* gmMsg = (const Srv2Cli_Heek_PointUpdate*)message->netMsg;
return gmMsg->points;
}
return 0;
}
unsigned long pyHeekPointUpdateMsg::Rank() const
{
if (message)
{
const Srv2Cli_Heek_PointUpdate* gmMsg = (const Srv2Cli_Heek_PointUpdate*)message->netMsg;
return gmMsg->rank;
}
return 0;
}

View File

@ -1,283 +1,283 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyHeekMsg_h
#define pyHeekMsg_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: pyHeekMsg
//
// PURPOSE: Class wrapper for Heek game messages
//
#include "pfGameMgr/pfGameMgr.h"
#include <python.h>
#include "../../pyGlueHelpers.h"
#include "../pyGameCliMsg.h"
class pyHeekMsg : public pyGameCliMsg
{
protected:
pyHeekMsg();
pyHeekMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_EXPOSE_TYPE; // so we can subclass
PYTHON_CLASS_NEW_FRIEND(ptHeekMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekMsg); // converts a PyObject to a pyHeekMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaConstantsClasses(PyObject* m);
int GetHeekMsgType() const;
PyObject* UpcastToFinalHeekMsg() const; // returns the heek message this really is
};
///////////////////////////////////////////////////////////////////////////////
class pyHeekPlayGameMsg : public pyHeekMsg
{
protected:
pyHeekPlayGameMsg();
pyHeekPlayGameMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptHeekPlayGameMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekPlayGameMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekPlayGameMsg); // converts a PyObject to a pyHeekPlayGameMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
bool IsPlaying() const;
bool IsSinglePlayer() const;
bool EnableButtons() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyHeekGoodbyeMsg : public pyHeekMsg
{
protected:
pyHeekGoodbyeMsg();
pyHeekGoodbyeMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptHeekGoodbyeMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekGoodbyeMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekGoodbyeMsg); // converts a PyObject to a pyHeekGoodbyeMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
};
///////////////////////////////////////////////////////////////////////////////
class pyHeekWelcomeMsg : public pyHeekMsg
{
protected:
pyHeekWelcomeMsg();
pyHeekWelcomeMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptHeekWelcomeMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekWelcomeMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekWelcomeMsg); // converts a PyObject to a pyHeekWelcomeMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
unsigned long Points() const;
unsigned long Rank() const;
std::wstring Name() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyHeekDropMsg : public pyHeekMsg
{
protected:
pyHeekDropMsg();
pyHeekDropMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptHeekDropMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekDropMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekDropMsg); // converts a PyObject to a pyHeekDropMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
int Position() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyHeekSetupMsg : public pyHeekMsg
{
protected:
pyHeekSetupMsg();
pyHeekSetupMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptHeekSetupMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekSetupMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekSetupMsg); // converts a PyObject to a pyHeekSetupMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
int Position() const;
bool ButtonState() const;
std::vector<bool> LightOn() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyHeekLightStateMsg : public pyHeekMsg
{
protected:
pyHeekLightStateMsg();
pyHeekLightStateMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptHeekLightStateMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekLightStateMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekLightStateMsg); // converts a PyObject to a pyHeekLightStateMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaConstantsClasses(PyObject* m);
int LightNum() const;
int State() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyHeekInterfaceStateMsg : public pyHeekMsg
{
protected:
pyHeekInterfaceStateMsg();
pyHeekInterfaceStateMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptHeekInterfaceStateMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekInterfaceStateMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekInterfaceStateMsg); // converts a PyObject to a pyHeekInterfaceStateMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
bool ButtonsEnabled() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyHeekCountdownStateMsg : public pyHeekMsg
{
protected:
pyHeekCountdownStateMsg();
pyHeekCountdownStateMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptHeekCountdownStateMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekCountdownStateMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekCountdownStateMsg); // converts a PyObject to a pyHeekCountdownStateMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaConstantsClasses(PyObject* m);
int State() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyHeekWinLoseMsg : public pyHeekMsg
{
protected:
pyHeekWinLoseMsg();
pyHeekWinLoseMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptHeekWinLoseMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekWinLoseMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekWinLoseMsg); // converts a PyObject to a pyHeekWinLoseMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
bool Win() const;
int Choice() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyHeekGameWinMsg : public pyHeekMsg
{
protected:
pyHeekGameWinMsg();
pyHeekGameWinMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptHeekGameWinMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekGameWinMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekGameWinMsg); // converts a PyObject to a pyHeekGameWinMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
int Choice() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyHeekPointUpdateMsg : public pyHeekMsg
{
protected:
pyHeekPointUpdateMsg();
pyHeekPointUpdateMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptHeekPointUpdateMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekPointUpdateMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekPointUpdateMsg); // converts a PyObject to a pyHeekPointUpdateMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
bool DisplayUpdate() const;
unsigned long Points() const;
unsigned long Rank() const;
};
#endif // pyHeekMsg_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyHeekMsg_h
#define pyHeekMsg_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: pyHeekMsg
//
// PURPOSE: Class wrapper for Heek game messages
//
#include "pfGameMgr/pfGameMgr.h"
#include <python.h>
#include "../../pyGlueHelpers.h"
#include "../pyGameCliMsg.h"
class pyHeekMsg : public pyGameCliMsg
{
protected:
pyHeekMsg();
pyHeekMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_EXPOSE_TYPE; // so we can subclass
PYTHON_CLASS_NEW_FRIEND(ptHeekMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekMsg); // converts a PyObject to a pyHeekMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaConstantsClasses(PyObject* m);
int GetHeekMsgType() const;
PyObject* UpcastToFinalHeekMsg() const; // returns the heek message this really is
};
///////////////////////////////////////////////////////////////////////////////
class pyHeekPlayGameMsg : public pyHeekMsg
{
protected:
pyHeekPlayGameMsg();
pyHeekPlayGameMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptHeekPlayGameMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekPlayGameMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekPlayGameMsg); // converts a PyObject to a pyHeekPlayGameMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
bool IsPlaying() const;
bool IsSinglePlayer() const;
bool EnableButtons() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyHeekGoodbyeMsg : public pyHeekMsg
{
protected:
pyHeekGoodbyeMsg();
pyHeekGoodbyeMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptHeekGoodbyeMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekGoodbyeMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekGoodbyeMsg); // converts a PyObject to a pyHeekGoodbyeMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
};
///////////////////////////////////////////////////////////////////////////////
class pyHeekWelcomeMsg : public pyHeekMsg
{
protected:
pyHeekWelcomeMsg();
pyHeekWelcomeMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptHeekWelcomeMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekWelcomeMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekWelcomeMsg); // converts a PyObject to a pyHeekWelcomeMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
unsigned long Points() const;
unsigned long Rank() const;
std::wstring Name() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyHeekDropMsg : public pyHeekMsg
{
protected:
pyHeekDropMsg();
pyHeekDropMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptHeekDropMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekDropMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekDropMsg); // converts a PyObject to a pyHeekDropMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
int Position() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyHeekSetupMsg : public pyHeekMsg
{
protected:
pyHeekSetupMsg();
pyHeekSetupMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptHeekSetupMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekSetupMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekSetupMsg); // converts a PyObject to a pyHeekSetupMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
int Position() const;
bool ButtonState() const;
std::vector<bool> LightOn() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyHeekLightStateMsg : public pyHeekMsg
{
protected:
pyHeekLightStateMsg();
pyHeekLightStateMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptHeekLightStateMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekLightStateMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekLightStateMsg); // converts a PyObject to a pyHeekLightStateMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaConstantsClasses(PyObject* m);
int LightNum() const;
int State() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyHeekInterfaceStateMsg : public pyHeekMsg
{
protected:
pyHeekInterfaceStateMsg();
pyHeekInterfaceStateMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptHeekInterfaceStateMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekInterfaceStateMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekInterfaceStateMsg); // converts a PyObject to a pyHeekInterfaceStateMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
bool ButtonsEnabled() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyHeekCountdownStateMsg : public pyHeekMsg
{
protected:
pyHeekCountdownStateMsg();
pyHeekCountdownStateMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptHeekCountdownStateMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekCountdownStateMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekCountdownStateMsg); // converts a PyObject to a pyHeekCountdownStateMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaConstantsClasses(PyObject* m);
int State() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyHeekWinLoseMsg : public pyHeekMsg
{
protected:
pyHeekWinLoseMsg();
pyHeekWinLoseMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptHeekWinLoseMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekWinLoseMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekWinLoseMsg); // converts a PyObject to a pyHeekWinLoseMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
bool Win() const;
int Choice() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyHeekGameWinMsg : public pyHeekMsg
{
protected:
pyHeekGameWinMsg();
pyHeekGameWinMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptHeekGameWinMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekGameWinMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekGameWinMsg); // converts a PyObject to a pyHeekGameWinMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
int Choice() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyHeekPointUpdateMsg : public pyHeekMsg
{
protected:
pyHeekPointUpdateMsg();
pyHeekPointUpdateMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptHeekPointUpdateMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyHeekPointUpdateMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyHeekPointUpdateMsg); // converts a PyObject to a pyHeekPointUpdateMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
bool DisplayUpdate() const;
unsigned long Points() const;
unsigned long Rank() const;
};
#endif // pyHeekMsg_h

File diff suppressed because it is too large Load Diff

View File

@ -1,145 +1,145 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyMarkerGame.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base Marker game client class
//
pyMarkerGame::pyMarkerGame(): pyGameCli() {}
pyMarkerGame::pyMarkerGame(pfGameCli* client): pyGameCli(client)
{
if (client && (client->GetGameTypeId() != kGameTypeId_Marker))
gameClient = nil; // wrong type, just clear it out
}
bool pyMarkerGame::IsMarkerGame(std::wstring guid)
{
Uuid gameUuid(guid.c_str());
return gameUuid == kGameTypeId_Marker;
}
void pyMarkerGame::CreateMarkerGame(pyKey& callbackKey, unsigned gameType, std::wstring gameName, unsigned long timeLimit, std::wstring templateId)
{
Marker_CreateParam init;
init.gameType = gameType;
StrCopy(init.gameName, gameName.c_str(), arrsize(init.gameName));
init.timeLimit = timeLimit;
StrCopy(init.templateID, templateId.c_str(), arrsize(init.templateID));
pfGameMgr::GetInstance()->CreateGame(callbackKey.getKey(), kGameTypeId_Marker, 0, sizeof(init), &init);
}
void pyMarkerGame::StartGame()
{
if (gameClient)
{
pfGmMarker* marker = pfGmMarker::ConvertNoRef(gameClient);
marker->StartGame();
}
}
void pyMarkerGame::PauseGame()
{
if (gameClient)
{
pfGmMarker* marker = pfGmMarker::ConvertNoRef(gameClient);
marker->PauseGame();
}
}
void pyMarkerGame::ResetGame()
{
if (gameClient)
{
pfGmMarker* marker = pfGmMarker::ConvertNoRef(gameClient);
marker->ResetGame();
}
}
void pyMarkerGame::ChangeGameName(std::wstring newName)
{
if (gameClient)
{
pfGmMarker* marker = pfGmMarker::ConvertNoRef(gameClient);
marker->ChangeGameName(newName.c_str());
}
}
void pyMarkerGame::ChangeTimeLimit(unsigned long timeLimit)
{
if (gameClient)
{
pfGmMarker* marker = pfGmMarker::ConvertNoRef(gameClient);
marker->ChangeTimeLimit(timeLimit);
}
}
void pyMarkerGame::DeleteGame()
{
if (gameClient)
{
pfGmMarker* marker = pfGmMarker::ConvertNoRef(gameClient);
marker->DeleteGame();
}
}
void pyMarkerGame::AddMarker(double x, double y, double z, std::wstring name, std::wstring age)
{
if (gameClient)
{
pfGmMarker* marker = pfGmMarker::ConvertNoRef(gameClient);
marker->AddMarker(x, y, z, name.c_str(), age.c_str());
}
}
void pyMarkerGame::DeleteMarker(unsigned long markerId)
{
if (gameClient)
{
pfGmMarker* marker = pfGmMarker::ConvertNoRef(gameClient);
marker->DeleteMarker(markerId);
}
}
void pyMarkerGame::ChangeMarkerName(unsigned long markerId, std::wstring newName)
{
if (gameClient)
{
pfGmMarker* marker = pfGmMarker::ConvertNoRef(gameClient);
marker->ChangeMarkerName(markerId, newName.c_str());
}
}
void pyMarkerGame::CaptureMarker(unsigned long markerId)
{
if (gameClient)
{
pfGmMarker* marker = pfGmMarker::ConvertNoRef(gameClient);
marker->CaptureMarker(markerId);
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyMarkerGame.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base Marker game client class
//
pyMarkerGame::pyMarkerGame(): pyGameCli() {}
pyMarkerGame::pyMarkerGame(pfGameCli* client): pyGameCli(client)
{
if (client && (client->GetGameTypeId() != kGameTypeId_Marker))
gameClient = nil; // wrong type, just clear it out
}
bool pyMarkerGame::IsMarkerGame(std::wstring guid)
{
Uuid gameUuid(guid.c_str());
return gameUuid == kGameTypeId_Marker;
}
void pyMarkerGame::CreateMarkerGame(pyKey& callbackKey, unsigned gameType, std::wstring gameName, unsigned long timeLimit, std::wstring templateId)
{
Marker_CreateParam init;
init.gameType = gameType;
StrCopy(init.gameName, gameName.c_str(), arrsize(init.gameName));
init.timeLimit = timeLimit;
StrCopy(init.templateID, templateId.c_str(), arrsize(init.templateID));
pfGameMgr::GetInstance()->CreateGame(callbackKey.getKey(), kGameTypeId_Marker, 0, sizeof(init), &init);
}
void pyMarkerGame::StartGame()
{
if (gameClient)
{
pfGmMarker* marker = pfGmMarker::ConvertNoRef(gameClient);
marker->StartGame();
}
}
void pyMarkerGame::PauseGame()
{
if (gameClient)
{
pfGmMarker* marker = pfGmMarker::ConvertNoRef(gameClient);
marker->PauseGame();
}
}
void pyMarkerGame::ResetGame()
{
if (gameClient)
{
pfGmMarker* marker = pfGmMarker::ConvertNoRef(gameClient);
marker->ResetGame();
}
}
void pyMarkerGame::ChangeGameName(std::wstring newName)
{
if (gameClient)
{
pfGmMarker* marker = pfGmMarker::ConvertNoRef(gameClient);
marker->ChangeGameName(newName.c_str());
}
}
void pyMarkerGame::ChangeTimeLimit(unsigned long timeLimit)
{
if (gameClient)
{
pfGmMarker* marker = pfGmMarker::ConvertNoRef(gameClient);
marker->ChangeTimeLimit(timeLimit);
}
}
void pyMarkerGame::DeleteGame()
{
if (gameClient)
{
pfGmMarker* marker = pfGmMarker::ConvertNoRef(gameClient);
marker->DeleteGame();
}
}
void pyMarkerGame::AddMarker(double x, double y, double z, std::wstring name, std::wstring age)
{
if (gameClient)
{
pfGmMarker* marker = pfGmMarker::ConvertNoRef(gameClient);
marker->AddMarker(x, y, z, name.c_str(), age.c_str());
}
}
void pyMarkerGame::DeleteMarker(unsigned long markerId)
{
if (gameClient)
{
pfGmMarker* marker = pfGmMarker::ConvertNoRef(gameClient);
marker->DeleteMarker(markerId);
}
}
void pyMarkerGame::ChangeMarkerName(unsigned long markerId, std::wstring newName)
{
if (gameClient)
{
pfGmMarker* marker = pfGmMarker::ConvertNoRef(gameClient);
marker->ChangeMarkerName(markerId, newName.c_str());
}
}
void pyMarkerGame::CaptureMarker(unsigned long markerId)
{
if (gameClient)
{
pfGmMarker* marker = pfGmMarker::ConvertNoRef(gameClient);
marker->CaptureMarker(markerId);
}
}

View File

@ -1,75 +1,75 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyMarkerGame_h
#define pyMarkerGame_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: pyMarkerGame
//
// PURPOSE: Class wrapper for the Marker game client
//
#include "pfGameMgr/pfGameMgr.h"
#include <python.h>
#include "../../pyGlueHelpers.h"
#include "../pyGameCli.h"
#include "../../pyKey.h"
class pyMarkerGame : public pyGameCli
{
protected:
pyMarkerGame();
pyMarkerGame(pfGameCli* client);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMarkerGame);
static PyObject* New(pfGameCli* client);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a ptMarkerGame object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerGame); // converts a PyObject to a pyMarkerGame (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaConstantsClasses(PyObject* m);
static void AddPlasmaMethods(std::vector<PyMethodDef>& methods);
static bool IsMarkerGame(std::wstring guid);
static void CreateMarkerGame(pyKey& callbackKey, unsigned gameType, std::wstring gameName, unsigned long timeLimit, std::wstring templateId);
void StartGame();
void PauseGame();
void ResetGame();
void ChangeGameName(std::wstring newName);
void ChangeTimeLimit(unsigned long timeLimit);
void DeleteGame();
void AddMarker(double x, double y, double z, std::wstring name, std::wstring age);
void DeleteMarker(unsigned long markerId);
void ChangeMarkerName(unsigned long markerId, std::wstring newName);
void CaptureMarker(unsigned long markerId);
};
#endif // pyMarkerGame_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyMarkerGame_h
#define pyMarkerGame_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: pyMarkerGame
//
// PURPOSE: Class wrapper for the Marker game client
//
#include "pfGameMgr/pfGameMgr.h"
#include <python.h>
#include "../../pyGlueHelpers.h"
#include "../pyGameCli.h"
#include "../../pyKey.h"
class pyMarkerGame : public pyGameCli
{
protected:
pyMarkerGame();
pyMarkerGame(pfGameCli* client);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMarkerGame);
static PyObject* New(pfGameCli* client);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a ptMarkerGame object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerGame); // converts a PyObject to a pyMarkerGame (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaConstantsClasses(PyObject* m);
static void AddPlasmaMethods(std::vector<PyMethodDef>& methods);
static bool IsMarkerGame(std::wstring guid);
static void CreateMarkerGame(pyKey& callbackKey, unsigned gameType, std::wstring gameName, unsigned long timeLimit, std::wstring templateId);
void StartGame();
void PauseGame();
void ResetGame();
void ChangeGameName(std::wstring newName);
void ChangeTimeLimit(unsigned long timeLimit);
void DeleteGame();
void AddMarker(double x, double y, double z, std::wstring name, std::wstring age);
void DeleteMarker(unsigned long markerId);
void ChangeMarkerName(unsigned long markerId, std::wstring newName);
void CaptureMarker(unsigned long markerId);
};
#endif // pyMarkerGame_h

View File

@ -1,381 +1,381 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyMarkerGame.h"
#include <python.h>
#include "../../pyEnum.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base TTT game client class
//
PYTHON_CLASS_DEFINITION(ptMarkerGame, pyMarkerGame);
PYTHON_DEFAULT_NEW_DEFINITION(ptMarkerGame, pyMarkerGame)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptMarkerGame)
PYTHON_NO_INIT_DEFINITION(ptMarkerGame)
PYTHON_GLOBAL_METHOD_DEFINITION(PtIsMarkerGame, args, "Params: typeID\nReturns true if the specifed typeID (guid as a string) is a Marker game")
{
PyObject* textObj;
if (!PyArg_ParseTuple(args, "O", &textObj))
{
PyErr_SetString(PyExc_TypeError, "PtIsMarkerGame expects a unicode string");
PYTHON_RETURN_ERROR;
}
if (PyUnicode_Check(textObj))
{
int strLen = PyUnicode_GetSize(textObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)textObj, text, strLen);
text[strLen] = L'\0';
bool retVal = pyMarkerGame::IsMarkerGame(text);
delete [] text;
PYTHON_RETURN_BOOL(retVal);
}
else if (PyString_Check(textObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(textObj);
wchar_t* wText = hsStringToWString(text);
bool retVal = pyMarkerGame::IsMarkerGame(wText);
delete [] wText;
PYTHON_RETURN_BOOL(retVal);
}
else
{
PyErr_SetString(PyExc_TypeError, "PtIsMarkerGame expects a unicode string");
PYTHON_RETURN_ERROR;
}
}
PYTHON_GLOBAL_METHOD_DEFINITION_WKEY(PtCreateMarkerGame, args, keywords, "Params: callbackKey, gameType, gameName = \"\", timeLimit = 0, templateId = \"\"\n"
"Creates a new Marker game with the specified callback key, game type (from PtMarkerGameTypes), time limit (in ms), and template id (guid string)")
{
char *kwlist[] = {"callbackKey", "gameType", "gameName", "timeLimit", "templateId", NULL};
PyObject* callbackObj = NULL;
unsigned int gameType = 0;
PyObject* gameNameObj = NULL;
unsigned long timeLimit = 0;
PyObject* templateIdObj = NULL;
if (!PyArg_ParseTupleAndKeywords(args, keywords, "OI|OkO", kwlist, &callbackObj, &gameType, &gameNameObj, &timeLimit, &templateIdObj))
{
PyErr_SetString(PyExc_TypeError, "PtCreateMarkerGame expects a ptKey, unsigned int, and optionally a string, an unsigned long, and another string");
PYTHON_RETURN_ERROR;
}
if (!pyKey::Check(callbackObj))
{
PyErr_SetString(PyExc_TypeError, "PtCreateMarkerGame expects a ptKey, unsigned int, and optionally a string, an unsigned long, and another string");
PYTHON_RETURN_ERROR;
}
pyKey* key = pyKey::ConvertFrom(callbackObj);
std::wstring name = L"";
std::wstring templateId = L"";
if (gameNameObj != NULL)
{
if (PyUnicode_Check(gameNameObj))
{
int strLen = PyUnicode_GetSize(gameNameObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)gameNameObj, text, strLen);
text[strLen] = L'\0';
name = text;
delete [] text;
}
else if (PyString_Check(gameNameObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(gameNameObj);
wchar_t* wText = hsStringToWString(text);
name = wText;
delete [] wText;
}
else
{
PyErr_SetString(PyExc_TypeError, "PtCreateMarkerGame expects a ptKey, unsigned int, and optionally a string, an unsigned long, and another string");
PYTHON_RETURN_ERROR;
}
}
if (templateIdObj != NULL)
{
if (PyUnicode_Check(templateIdObj))
{
int strLen = PyUnicode_GetSize(templateIdObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)templateIdObj, text, strLen);
text[strLen] = L'\0';
templateId = text;
delete [] text;
}
else if (PyString_Check(templateIdObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(templateIdObj);
wchar_t* wText = hsStringToWString(text);
templateId = wText;
delete [] wText;
}
else
{
PyErr_SetString(PyExc_TypeError, "PtCreateMarkerGame expects a ptKey, unsigned int, and optionally a string, an unsigned long, and another string");
PYTHON_RETURN_ERROR;
}
}
pyMarkerGame::CreateMarkerGame(*key, gameType, name, timeLimit, templateId);
PYTHON_RETURN_NONE;
}
PYTHON_BASIC_METHOD_DEFINITION(ptMarkerGame, startGame, StartGame)
PYTHON_BASIC_METHOD_DEFINITION(ptMarkerGame, pauseGame, PauseGame)
PYTHON_BASIC_METHOD_DEFINITION(ptMarkerGame, resetGame, ResetGame)
PYTHON_METHOD_DEFINITION(ptMarkerGame, changeGameName, args)
{
PyObject* textObj;
if (!PyArg_ParseTuple(args, "O", &textObj))
{
PyErr_SetString(PyExc_TypeError, "changeGameName expects a unicode string");
PYTHON_RETURN_ERROR;
}
if (PyUnicode_Check(textObj))
{
int strLen = PyUnicode_GetSize(textObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)textObj, text, strLen);
text[strLen] = L'\0';
self->fThis->ChangeGameName(text);
delete [] text;
PYTHON_RETURN_NONE;
}
else if (PyString_Check(textObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(textObj);
wchar_t* wText = hsStringToWString(text);
self->fThis->ChangeGameName(wText);
delete [] wText;
PYTHON_RETURN_NONE;
}
else
{
PyErr_SetString(PyExc_TypeError, "changeGameName expects a unicode string");
PYTHON_RETURN_ERROR;
}
}
PYTHON_METHOD_DEFINITION(ptMarkerGame, changeTimeLimit, args)
{
unsigned long timeLimit;
if (!PyArg_ParseTuple(args, "k", &timeLimit))
{
PyErr_SetString(PyExc_TypeError, "changeTimeLimit expects an unsigned long");
PYTHON_RETURN_ERROR;
}
self->fThis->ChangeTimeLimit(timeLimit);
PYTHON_RETURN_NONE;
}
PYTHON_BASIC_METHOD_DEFINITION(ptMarkerGame, deleteGame, DeleteGame)
PYTHON_METHOD_DEFINITION_WKEY(ptMarkerGame, addMarker, args, keywords)
{
char *kwlist[] = {"x", "y", "z", "name", "age", NULL};
double x, y, z;
PyObject* nameObj = NULL;
PyObject* ageObj = NULL;
if (!PyArg_ParseTupleAndKeywords(args, keywords, "ddd|OO", kwlist, &x, &y, &z, &nameObj, &ageObj))
{
PyErr_SetString(PyExc_TypeError, "addMarker expects three doubles, and optionally two strings");
PYTHON_RETURN_ERROR;
}
std::wstring name = L"";
std::wstring age = L"";
if (nameObj != NULL)
{
if (PyUnicode_Check(nameObj))
{
int strLen = PyUnicode_GetSize(nameObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)nameObj, text, strLen);
text[strLen] = L'\0';
name = text;
delete [] text;
}
else if (PyString_Check(nameObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(nameObj);
wchar_t* wText = hsStringToWString(text);
name = wText;
delete [] wText;
}
else
{
PyErr_SetString(PyExc_TypeError, "addMarker expects three doubles, and optionally two strings");
PYTHON_RETURN_ERROR;
}
}
if (ageObj != NULL)
{
if (PyUnicode_Check(ageObj))
{
int strLen = PyUnicode_GetSize(ageObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)ageObj, text, strLen);
text[strLen] = L'\0';
age = text;
delete [] text;
}
else if (PyString_Check(ageObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(ageObj);
wchar_t* wText = hsStringToWString(text);
age = wText;
delete [] wText;
}
else
{
PyErr_SetString(PyExc_TypeError, "addMarker expects three doubles, and optionally two strings");
PYTHON_RETURN_ERROR;
}
}
self->fThis->AddMarker(x, y, z, name, age);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptMarkerGame, deleteMarker, args)
{
unsigned long markerId;
if (!PyArg_ParseTuple(args, "k", &markerId))
{
PyErr_SetString(PyExc_TypeError, "deleteMarker expects an unsigned long");
PYTHON_RETURN_ERROR;
}
self->fThis->DeleteMarker(markerId);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptMarkerGame, changeMarkerName, args)
{
unsigned long markerId;
PyObject* nameObj = NULL;
if (!PyArg_ParseTuple(args, "kO", &markerId, &nameObj))
{
PyErr_SetString(PyExc_TypeError, "changeMarkerName expects an unsigned long and a string");
PYTHON_RETURN_ERROR;
}
if (PyUnicode_Check(nameObj))
{
int strLen = PyUnicode_GetSize(nameObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)nameObj, text, strLen);
text[strLen] = L'\0';
self->fThis->ChangeMarkerName(markerId, text);
delete [] text;
PYTHON_RETURN_NONE;
}
else if (PyString_Check(nameObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(nameObj);
wchar_t* wText = hsStringToWString(text);
self->fThis->ChangeMarkerName(markerId, wText);
delete [] wText;
PYTHON_RETURN_NONE;
}
else
{
PyErr_SetString(PyExc_TypeError, "changeMarkerName expects an unsigned long and a string");
PYTHON_RETURN_ERROR;
}
}
PYTHON_METHOD_DEFINITION(ptMarkerGame, captureMarker, args)
{
unsigned long markerId;
if (!PyArg_ParseTuple(args, "k", &markerId))
{
PyErr_SetString(PyExc_TypeError, "captureMarker expects an unsigned long");
PYTHON_RETURN_ERROR;
}
self->fThis->CaptureMarker(markerId);
PYTHON_RETURN_NONE;
}
PYTHON_START_METHODS_TABLE(ptMarkerGame)
PYTHON_BASIC_METHOD(ptMarkerGame, startGame, "Starts the game. Won't work on MP games if you're not the owner/creator"),
PYTHON_BASIC_METHOD(ptMarkerGame, pauseGame, "Pauses the game. Won't work on MP games if you're not the owner/creator"),
PYTHON_BASIC_METHOD(ptMarkerGame, resetGame, "Resets the game. Won't work on MP games if you're not the owner/creator"),
PYTHON_METHOD(ptMarkerGame, changeGameName, "Params: newName\nChanges the name of the game. Won't work if you're not the game owner/creator"),
PYTHON_METHOD(ptMarkerGame, changeTimeLimit, "Params: newTimeLimit\nChanges the time limit on the game (in ms). Won't work if you're not the game owner/creator, or if it's a quest game"),
PYTHON_BASIC_METHOD(ptMarkerGame, deleteGame, "Tells the server to delete the game. Won't work if you're not the game owner/creator"),
PYTHON_METHOD_WKEY(ptMarkerGame, addMarker, "Params: x, y, z, name = \"\", age = \"\"\nAdds a marker to the game. Age is ignored in a non-quest game. Won't work if you're not the owner/creator"),
PYTHON_METHOD(ptMarkerGame, deleteMarker, "Params: markerId\nDeletes the specified marker from the game. Won't work if you're not the game owner/creator"),
PYTHON_METHOD(ptMarkerGame, changeMarkerName, "Params: markerId, newName\nChanges the name of the specified marker. Won't work if you're not the game owner/creator"),
PYTHON_METHOD(ptMarkerGame, captureMarker, "Params: markerId\nCaptures the specified marker"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptMarkerGame, pyGameCli, "Game client for the Marker game");
// required functions for PyObject interoperability
PyObject* pyMarkerGame::New(pfGameCli* client)
{
ptMarkerGame *newObj = (ptMarkerGame*)ptMarkerGame_type.tp_new(&ptMarkerGame_type, NULL, NULL);
if (client && (client->GetGameTypeId() == kGameTypeId_Marker))
newObj->fThis->gameClient = client;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptMarkerGame, pyMarkerGame)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptMarkerGame, pyMarkerGame)
// Module and method definitions
void pyMarkerGame::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptMarkerGame);
PYTHON_CLASS_IMPORT_END(m);
}
void pyMarkerGame::AddPlasmaConstantsClasses(PyObject* m)
{
PYTHON_ENUM_START(PtMarkerGameTypes);
PYTHON_ENUM_ELEMENT(PtMarkerGameTypes, kMarkerGameQuest, kMarkerGameQuest);
PYTHON_ENUM_ELEMENT(PtMarkerGameTypes, kMarkerGameCGZ, kMarkerGameCGZ);
PYTHON_ENUM_ELEMENT(PtMarkerGameTypes, kMarkerGameCapture, kMarkerGameCapture);
PYTHON_ENUM_ELEMENT(PtMarkerGameTypes, kMarkerGameCaptureAndHold, kMarkerGameCaptureAndHold);
PYTHON_ENUM_END(m, PtMarkerGameTypes);
}
void pyMarkerGame::AddPlasmaMethods(std::vector<PyMethodDef>& methods)
{
PYTHON_GLOBAL_METHOD(methods, PtIsMarkerGame);
PYTHON_GLOBAL_METHOD_WKEY(methods, PtCreateMarkerGame);
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyMarkerGame.h"
#include <python.h>
#include "../../pyEnum.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base TTT game client class
//
PYTHON_CLASS_DEFINITION(ptMarkerGame, pyMarkerGame);
PYTHON_DEFAULT_NEW_DEFINITION(ptMarkerGame, pyMarkerGame)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptMarkerGame)
PYTHON_NO_INIT_DEFINITION(ptMarkerGame)
PYTHON_GLOBAL_METHOD_DEFINITION(PtIsMarkerGame, args, "Params: typeID\nReturns true if the specifed typeID (guid as a string) is a Marker game")
{
PyObject* textObj;
if (!PyArg_ParseTuple(args, "O", &textObj))
{
PyErr_SetString(PyExc_TypeError, "PtIsMarkerGame expects a unicode string");
PYTHON_RETURN_ERROR;
}
if (PyUnicode_Check(textObj))
{
int strLen = PyUnicode_GetSize(textObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)textObj, text, strLen);
text[strLen] = L'\0';
bool retVal = pyMarkerGame::IsMarkerGame(text);
delete [] text;
PYTHON_RETURN_BOOL(retVal);
}
else if (PyString_Check(textObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(textObj);
wchar_t* wText = hsStringToWString(text);
bool retVal = pyMarkerGame::IsMarkerGame(wText);
delete [] wText;
PYTHON_RETURN_BOOL(retVal);
}
else
{
PyErr_SetString(PyExc_TypeError, "PtIsMarkerGame expects a unicode string");
PYTHON_RETURN_ERROR;
}
}
PYTHON_GLOBAL_METHOD_DEFINITION_WKEY(PtCreateMarkerGame, args, keywords, "Params: callbackKey, gameType, gameName = \"\", timeLimit = 0, templateId = \"\"\n"
"Creates a new Marker game with the specified callback key, game type (from PtMarkerGameTypes), time limit (in ms), and template id (guid string)")
{
char *kwlist[] = {"callbackKey", "gameType", "gameName", "timeLimit", "templateId", NULL};
PyObject* callbackObj = NULL;
unsigned int gameType = 0;
PyObject* gameNameObj = NULL;
unsigned long timeLimit = 0;
PyObject* templateIdObj = NULL;
if (!PyArg_ParseTupleAndKeywords(args, keywords, "OI|OkO", kwlist, &callbackObj, &gameType, &gameNameObj, &timeLimit, &templateIdObj))
{
PyErr_SetString(PyExc_TypeError, "PtCreateMarkerGame expects a ptKey, unsigned int, and optionally a string, an unsigned long, and another string");
PYTHON_RETURN_ERROR;
}
if (!pyKey::Check(callbackObj))
{
PyErr_SetString(PyExc_TypeError, "PtCreateMarkerGame expects a ptKey, unsigned int, and optionally a string, an unsigned long, and another string");
PYTHON_RETURN_ERROR;
}
pyKey* key = pyKey::ConvertFrom(callbackObj);
std::wstring name = L"";
std::wstring templateId = L"";
if (gameNameObj != NULL)
{
if (PyUnicode_Check(gameNameObj))
{
int strLen = PyUnicode_GetSize(gameNameObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)gameNameObj, text, strLen);
text[strLen] = L'\0';
name = text;
delete [] text;
}
else if (PyString_Check(gameNameObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(gameNameObj);
wchar_t* wText = hsStringToWString(text);
name = wText;
delete [] wText;
}
else
{
PyErr_SetString(PyExc_TypeError, "PtCreateMarkerGame expects a ptKey, unsigned int, and optionally a string, an unsigned long, and another string");
PYTHON_RETURN_ERROR;
}
}
if (templateIdObj != NULL)
{
if (PyUnicode_Check(templateIdObj))
{
int strLen = PyUnicode_GetSize(templateIdObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)templateIdObj, text, strLen);
text[strLen] = L'\0';
templateId = text;
delete [] text;
}
else if (PyString_Check(templateIdObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(templateIdObj);
wchar_t* wText = hsStringToWString(text);
templateId = wText;
delete [] wText;
}
else
{
PyErr_SetString(PyExc_TypeError, "PtCreateMarkerGame expects a ptKey, unsigned int, and optionally a string, an unsigned long, and another string");
PYTHON_RETURN_ERROR;
}
}
pyMarkerGame::CreateMarkerGame(*key, gameType, name, timeLimit, templateId);
PYTHON_RETURN_NONE;
}
PYTHON_BASIC_METHOD_DEFINITION(ptMarkerGame, startGame, StartGame)
PYTHON_BASIC_METHOD_DEFINITION(ptMarkerGame, pauseGame, PauseGame)
PYTHON_BASIC_METHOD_DEFINITION(ptMarkerGame, resetGame, ResetGame)
PYTHON_METHOD_DEFINITION(ptMarkerGame, changeGameName, args)
{
PyObject* textObj;
if (!PyArg_ParseTuple(args, "O", &textObj))
{
PyErr_SetString(PyExc_TypeError, "changeGameName expects a unicode string");
PYTHON_RETURN_ERROR;
}
if (PyUnicode_Check(textObj))
{
int strLen = PyUnicode_GetSize(textObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)textObj, text, strLen);
text[strLen] = L'\0';
self->fThis->ChangeGameName(text);
delete [] text;
PYTHON_RETURN_NONE;
}
else if (PyString_Check(textObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(textObj);
wchar_t* wText = hsStringToWString(text);
self->fThis->ChangeGameName(wText);
delete [] wText;
PYTHON_RETURN_NONE;
}
else
{
PyErr_SetString(PyExc_TypeError, "changeGameName expects a unicode string");
PYTHON_RETURN_ERROR;
}
}
PYTHON_METHOD_DEFINITION(ptMarkerGame, changeTimeLimit, args)
{
unsigned long timeLimit;
if (!PyArg_ParseTuple(args, "k", &timeLimit))
{
PyErr_SetString(PyExc_TypeError, "changeTimeLimit expects an unsigned long");
PYTHON_RETURN_ERROR;
}
self->fThis->ChangeTimeLimit(timeLimit);
PYTHON_RETURN_NONE;
}
PYTHON_BASIC_METHOD_DEFINITION(ptMarkerGame, deleteGame, DeleteGame)
PYTHON_METHOD_DEFINITION_WKEY(ptMarkerGame, addMarker, args, keywords)
{
char *kwlist[] = {"x", "y", "z", "name", "age", NULL};
double x, y, z;
PyObject* nameObj = NULL;
PyObject* ageObj = NULL;
if (!PyArg_ParseTupleAndKeywords(args, keywords, "ddd|OO", kwlist, &x, &y, &z, &nameObj, &ageObj))
{
PyErr_SetString(PyExc_TypeError, "addMarker expects three doubles, and optionally two strings");
PYTHON_RETURN_ERROR;
}
std::wstring name = L"";
std::wstring age = L"";
if (nameObj != NULL)
{
if (PyUnicode_Check(nameObj))
{
int strLen = PyUnicode_GetSize(nameObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)nameObj, text, strLen);
text[strLen] = L'\0';
name = text;
delete [] text;
}
else if (PyString_Check(nameObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(nameObj);
wchar_t* wText = hsStringToWString(text);
name = wText;
delete [] wText;
}
else
{
PyErr_SetString(PyExc_TypeError, "addMarker expects three doubles, and optionally two strings");
PYTHON_RETURN_ERROR;
}
}
if (ageObj != NULL)
{
if (PyUnicode_Check(ageObj))
{
int strLen = PyUnicode_GetSize(ageObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)ageObj, text, strLen);
text[strLen] = L'\0';
age = text;
delete [] text;
}
else if (PyString_Check(ageObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(ageObj);
wchar_t* wText = hsStringToWString(text);
age = wText;
delete [] wText;
}
else
{
PyErr_SetString(PyExc_TypeError, "addMarker expects three doubles, and optionally two strings");
PYTHON_RETURN_ERROR;
}
}
self->fThis->AddMarker(x, y, z, name, age);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptMarkerGame, deleteMarker, args)
{
unsigned long markerId;
if (!PyArg_ParseTuple(args, "k", &markerId))
{
PyErr_SetString(PyExc_TypeError, "deleteMarker expects an unsigned long");
PYTHON_RETURN_ERROR;
}
self->fThis->DeleteMarker(markerId);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptMarkerGame, changeMarkerName, args)
{
unsigned long markerId;
PyObject* nameObj = NULL;
if (!PyArg_ParseTuple(args, "kO", &markerId, &nameObj))
{
PyErr_SetString(PyExc_TypeError, "changeMarkerName expects an unsigned long and a string");
PYTHON_RETURN_ERROR;
}
if (PyUnicode_Check(nameObj))
{
int strLen = PyUnicode_GetSize(nameObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)nameObj, text, strLen);
text[strLen] = L'\0';
self->fThis->ChangeMarkerName(markerId, text);
delete [] text;
PYTHON_RETURN_NONE;
}
else if (PyString_Check(nameObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(nameObj);
wchar_t* wText = hsStringToWString(text);
self->fThis->ChangeMarkerName(markerId, wText);
delete [] wText;
PYTHON_RETURN_NONE;
}
else
{
PyErr_SetString(PyExc_TypeError, "changeMarkerName expects an unsigned long and a string");
PYTHON_RETURN_ERROR;
}
}
PYTHON_METHOD_DEFINITION(ptMarkerGame, captureMarker, args)
{
unsigned long markerId;
if (!PyArg_ParseTuple(args, "k", &markerId))
{
PyErr_SetString(PyExc_TypeError, "captureMarker expects an unsigned long");
PYTHON_RETURN_ERROR;
}
self->fThis->CaptureMarker(markerId);
PYTHON_RETURN_NONE;
}
PYTHON_START_METHODS_TABLE(ptMarkerGame)
PYTHON_BASIC_METHOD(ptMarkerGame, startGame, "Starts the game. Won't work on MP games if you're not the owner/creator"),
PYTHON_BASIC_METHOD(ptMarkerGame, pauseGame, "Pauses the game. Won't work on MP games if you're not the owner/creator"),
PYTHON_BASIC_METHOD(ptMarkerGame, resetGame, "Resets the game. Won't work on MP games if you're not the owner/creator"),
PYTHON_METHOD(ptMarkerGame, changeGameName, "Params: newName\nChanges the name of the game. Won't work if you're not the game owner/creator"),
PYTHON_METHOD(ptMarkerGame, changeTimeLimit, "Params: newTimeLimit\nChanges the time limit on the game (in ms). Won't work if you're not the game owner/creator, or if it's a quest game"),
PYTHON_BASIC_METHOD(ptMarkerGame, deleteGame, "Tells the server to delete the game. Won't work if you're not the game owner/creator"),
PYTHON_METHOD_WKEY(ptMarkerGame, addMarker, "Params: x, y, z, name = \"\", age = \"\"\nAdds a marker to the game. Age is ignored in a non-quest game. Won't work if you're not the owner/creator"),
PYTHON_METHOD(ptMarkerGame, deleteMarker, "Params: markerId\nDeletes the specified marker from the game. Won't work if you're not the game owner/creator"),
PYTHON_METHOD(ptMarkerGame, changeMarkerName, "Params: markerId, newName\nChanges the name of the specified marker. Won't work if you're not the game owner/creator"),
PYTHON_METHOD(ptMarkerGame, captureMarker, "Params: markerId\nCaptures the specified marker"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptMarkerGame, pyGameCli, "Game client for the Marker game");
// required functions for PyObject interoperability
PyObject* pyMarkerGame::New(pfGameCli* client)
{
ptMarkerGame *newObj = (ptMarkerGame*)ptMarkerGame_type.tp_new(&ptMarkerGame_type, NULL, NULL);
if (client && (client->GetGameTypeId() == kGameTypeId_Marker))
newObj->fThis->gameClient = client;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptMarkerGame, pyMarkerGame)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptMarkerGame, pyMarkerGame)
// Module and method definitions
void pyMarkerGame::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptMarkerGame);
PYTHON_CLASS_IMPORT_END(m);
}
void pyMarkerGame::AddPlasmaConstantsClasses(PyObject* m)
{
PYTHON_ENUM_START(PtMarkerGameTypes);
PYTHON_ENUM_ELEMENT(PtMarkerGameTypes, kMarkerGameQuest, kMarkerGameQuest);
PYTHON_ENUM_ELEMENT(PtMarkerGameTypes, kMarkerGameCGZ, kMarkerGameCGZ);
PYTHON_ENUM_ELEMENT(PtMarkerGameTypes, kMarkerGameCapture, kMarkerGameCapture);
PYTHON_ENUM_ELEMENT(PtMarkerGameTypes, kMarkerGameCaptureAndHold, kMarkerGameCaptureAndHold);
PYTHON_ENUM_END(m, PtMarkerGameTypes);
}
void pyMarkerGame::AddPlasmaMethods(std::vector<PyMethodDef>& methods)
{
PYTHON_GLOBAL_METHOD(methods, PtIsMarkerGame);
PYTHON_GLOBAL_METHOD_WKEY(methods, PtCreateMarkerGame);
}

View File

@ -1,408 +1,408 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyMarkerMsg.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base Marker msg class
//
pyMarkerMsg::pyMarkerMsg(): pyGameCliMsg() {}
pyMarkerMsg::pyMarkerMsg(pfGameCliMsg* msg): pyGameCliMsg(msg)
{
if (message && (message->gameCli->GetGameTypeId() != kGameTypeId_Marker))
message = nil; // wrong type, just clear it out
}
int pyMarkerMsg::GetMarkerMsgType() const
{
if (message)
return message->netMsg->messageId;
return -1;
}
PyObject* pyMarkerMsg::UpcastToFinalMarkerMsg() const
{
if (!message)
PYTHON_RETURN_NONE;
switch (message->netMsg->messageId)
{
case kSrv2Cli_Marker_TemplateCreated:
return pyMarkerTemplateCreatedMsg::New(message);
case kSrv2Cli_Marker_TeamAssigned:
return pyMarkerTeamAssignedMsg::New(message);
case kSrv2Cli_Marker_GameType:
return pyMarkerGameTypeMsg::New(message);
case kSrv2Cli_Marker_GameStarted:
return pyMarkerGameStartedMsg::New(message);
case kSrv2Cli_Marker_GamePaused:
return pyMarkerGamePausedMsg::New(message);
case kSrv2Cli_Marker_GameReset:
return pyMarkerGameResetMsg::New(message);
case kSrv2Cli_Marker_GameOver:
return pyMarkerGameOverMsg::New(message);
case kSrv2Cli_Marker_GameNameChanged:
return pyMarkerGameNameChangedMsg::New(message);
case kSrv2Cli_Marker_TimeLimitChanged:
return pyMarkerTimeLimitChangedMsg::New(message);
case kSrv2Cli_Marker_GameDeleted:
return pyMarkerGameDeletedMsg::New(message);
case kSrv2Cli_Marker_MarkerAdded:
return pyMarkerMarkerAddedMsg::New(message);
case kSrv2Cli_Marker_MarkerDeleted:
return pyMarkerMarkerDeletedMsg::New(message);
case kSrv2Cli_Marker_MarkerNameChanged:
return pyMarkerMarkerNameChangedMsg::New(message);
case kSrv2Cli_Marker_MarkerCaptured:
return pyMarkerMarkerCapturedMsg::New(message);
default:
PYTHON_RETURN_NONE;
}
}
///////////////////////////////////////////////////////////////////////////////
//
// The different messages we can receive
//
pyMarkerTemplateCreatedMsg::pyMarkerTemplateCreatedMsg(): pyMarkerMsg() {}
pyMarkerTemplateCreatedMsg::pyMarkerTemplateCreatedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_TemplateCreated))
message = nil; // wrong type, just clear it out
}
std::wstring pyMarkerTemplateCreatedMsg::TemplateID() const
{
if (message)
{
const Srv2Cli_Marker_TemplateCreated* gmMsg = (const Srv2Cli_Marker_TemplateCreated*)message->netMsg;
return gmMsg->templateID;
}
return L"";
}
///////////////////////////////////////////////////////////////////////////////
pyMarkerTeamAssignedMsg::pyMarkerTeamAssignedMsg(): pyMarkerMsg() {}
pyMarkerTeamAssignedMsg::pyMarkerTeamAssignedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_TeamAssigned))
message = nil; // wrong type, just clear it out
}
int pyMarkerTeamAssignedMsg::TeamNumber() const
{
if (message)
{
const Srv2Cli_Marker_TeamAssigned* gmMsg = (const Srv2Cli_Marker_TeamAssigned*)message->netMsg;
return gmMsg->teamNumber;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
pyMarkerGameTypeMsg::pyMarkerGameTypeMsg(): pyMarkerMsg() {}
pyMarkerGameTypeMsg::pyMarkerGameTypeMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_GameType))
message = nil; // wrong type, just clear it out
}
int pyMarkerGameTypeMsg::GameType() const
{
if (message)
{
const Srv2Cli_Marker_GameType* gmMsg = (const Srv2Cli_Marker_GameType*)message->netMsg;
return gmMsg->gameType;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
pyMarkerGameStartedMsg::pyMarkerGameStartedMsg(): pyMarkerMsg() {}
pyMarkerGameStartedMsg::pyMarkerGameStartedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_GameStarted))
message = nil; // wrong type, just clear it out
}
///////////////////////////////////////////////////////////////////////////////
pyMarkerGamePausedMsg::pyMarkerGamePausedMsg(): pyMarkerMsg() {}
pyMarkerGamePausedMsg::pyMarkerGamePausedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_GamePaused))
message = nil; // wrong type, just clear it out
}
unsigned long pyMarkerGamePausedMsg::TimeLeft() const
{
if (message)
{
const Srv2Cli_Marker_GamePaused* gmMsg = (const Srv2Cli_Marker_GamePaused*)message->netMsg;
return gmMsg->timeLeft;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
pyMarkerGameResetMsg::pyMarkerGameResetMsg(): pyMarkerMsg() {}
pyMarkerGameResetMsg::pyMarkerGameResetMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_GameReset))
message = nil; // wrong type, just clear it out
}
///////////////////////////////////////////////////////////////////////////////
pyMarkerGameOverMsg::pyMarkerGameOverMsg(): pyMarkerMsg() {}
pyMarkerGameOverMsg::pyMarkerGameOverMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_GameOver))
message = nil; // wrong type, just clear it out
}
///////////////////////////////////////////////////////////////////////////////
pyMarkerGameNameChangedMsg::pyMarkerGameNameChangedMsg(): pyMarkerMsg() {}
pyMarkerGameNameChangedMsg::pyMarkerGameNameChangedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_GameNameChanged))
message = nil; // wrong type, just clear it out
}
std::wstring pyMarkerGameNameChangedMsg::Name() const
{
if (message)
{
const Srv2Cli_Marker_GameNameChanged* gmMsg = (const Srv2Cli_Marker_GameNameChanged*)message->netMsg;
return gmMsg->newName;
}
return L"";
}
///////////////////////////////////////////////////////////////////////////////
pyMarkerTimeLimitChangedMsg::pyMarkerTimeLimitChangedMsg(): pyMarkerMsg() {}
pyMarkerTimeLimitChangedMsg::pyMarkerTimeLimitChangedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_TimeLimitChanged))
message = nil; // wrong type, just clear it out
}
unsigned long pyMarkerTimeLimitChangedMsg::TimeLimit() const
{
if (message)
{
const Srv2Cli_Marker_TimeLimitChanged* gmMsg = (const Srv2Cli_Marker_TimeLimitChanged*)message->netMsg;
return gmMsg->newTimeLimit;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
pyMarkerGameDeletedMsg::pyMarkerGameDeletedMsg(): pyMarkerMsg() {}
pyMarkerGameDeletedMsg::pyMarkerGameDeletedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_GameDeleted))
message = nil; // wrong type, just clear it out
}
bool pyMarkerGameDeletedMsg::Failed() const
{
if (message)
{
const Srv2Cli_Marker_GameDeleted* gmMsg = (const Srv2Cli_Marker_GameDeleted*)message->netMsg;
return gmMsg->failed;
}
return true; // assume it failed if we have a problem
}
///////////////////////////////////////////////////////////////////////////////
pyMarkerMarkerAddedMsg::pyMarkerMarkerAddedMsg(): pyMarkerMsg() {}
pyMarkerMarkerAddedMsg::pyMarkerMarkerAddedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_MarkerAdded))
message = nil; // wrong type, just clear it out
}
double pyMarkerMarkerAddedMsg::X() const
{
if (message)
{
const Srv2Cli_Marker_MarkerAdded* gmMsg = (const Srv2Cli_Marker_MarkerAdded*)message->netMsg;
return gmMsg->x;
}
return 0;
}
double pyMarkerMarkerAddedMsg::Y() const
{
if (message)
{
const Srv2Cli_Marker_MarkerAdded* gmMsg = (const Srv2Cli_Marker_MarkerAdded*)message->netMsg;
return gmMsg->y;
}
return 0;
}
double pyMarkerMarkerAddedMsg::Z() const
{
if (message)
{
const Srv2Cli_Marker_MarkerAdded* gmMsg = (const Srv2Cli_Marker_MarkerAdded*)message->netMsg;
return gmMsg->z;
}
return 0;
}
unsigned long pyMarkerMarkerAddedMsg::MarkerId() const
{
if (message)
{
const Srv2Cli_Marker_MarkerAdded* gmMsg = (const Srv2Cli_Marker_MarkerAdded*)message->netMsg;
return gmMsg->markerID;
}
return 0;
}
std::wstring pyMarkerMarkerAddedMsg::Name() const
{
if (message)
{
const Srv2Cli_Marker_MarkerAdded* gmMsg = (const Srv2Cli_Marker_MarkerAdded*)message->netMsg;
return gmMsg->name;
}
return L"";
}
std::wstring pyMarkerMarkerAddedMsg::Age() const
{
if (message)
{
const Srv2Cli_Marker_MarkerAdded* gmMsg = (const Srv2Cli_Marker_MarkerAdded*)message->netMsg;
return gmMsg->age;
}
return L"";
}
///////////////////////////////////////////////////////////////////////////////
pyMarkerMarkerDeletedMsg::pyMarkerMarkerDeletedMsg(): pyMarkerMsg() {}
pyMarkerMarkerDeletedMsg::pyMarkerMarkerDeletedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_MarkerDeleted))
message = nil; // wrong type, just clear it out
}
unsigned long pyMarkerMarkerDeletedMsg::MarkerId() const
{
if (message)
{
const Srv2Cli_Marker_MarkerDeleted* gmMsg = (const Srv2Cli_Marker_MarkerDeleted*)message->netMsg;
return gmMsg->markerID;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
pyMarkerMarkerNameChangedMsg::pyMarkerMarkerNameChangedMsg(): pyMarkerMsg() {}
pyMarkerMarkerNameChangedMsg::pyMarkerMarkerNameChangedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_MarkerNameChanged))
message = nil; // wrong type, just clear it out
}
unsigned long pyMarkerMarkerNameChangedMsg::MarkerId() const
{
if (message)
{
const Srv2Cli_Marker_MarkerNameChanged* gmMsg = (const Srv2Cli_Marker_MarkerNameChanged*)message->netMsg;
return gmMsg->markerID;
}
return 0;
}
std::wstring pyMarkerMarkerNameChangedMsg::Name() const
{
if (message)
{
const Srv2Cli_Marker_MarkerNameChanged* gmMsg = (const Srv2Cli_Marker_MarkerNameChanged*)message->netMsg;
return gmMsg->newName;
}
return L"";
}
///////////////////////////////////////////////////////////////////////////////
pyMarkerMarkerCapturedMsg::pyMarkerMarkerCapturedMsg(): pyMarkerMsg() {}
pyMarkerMarkerCapturedMsg::pyMarkerMarkerCapturedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_MarkerCaptured))
message = nil; // wrong type, just clear it out
}
unsigned long pyMarkerMarkerCapturedMsg::MarkerId() const
{
if (message)
{
const Srv2Cli_Marker_MarkerCaptured* gmMsg = (const Srv2Cli_Marker_MarkerCaptured*)message->netMsg;
return gmMsg->markerID;
}
return 0;
}
unsigned int pyMarkerMarkerCapturedMsg::Team() const
{
if (message)
{
const Srv2Cli_Marker_MarkerCaptured* gmMsg = (const Srv2Cli_Marker_MarkerCaptured*)message->netMsg;
return gmMsg->team;
}
return 0;
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyMarkerMsg.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base Marker msg class
//
pyMarkerMsg::pyMarkerMsg(): pyGameCliMsg() {}
pyMarkerMsg::pyMarkerMsg(pfGameCliMsg* msg): pyGameCliMsg(msg)
{
if (message && (message->gameCli->GetGameTypeId() != kGameTypeId_Marker))
message = nil; // wrong type, just clear it out
}
int pyMarkerMsg::GetMarkerMsgType() const
{
if (message)
return message->netMsg->messageId;
return -1;
}
PyObject* pyMarkerMsg::UpcastToFinalMarkerMsg() const
{
if (!message)
PYTHON_RETURN_NONE;
switch (message->netMsg->messageId)
{
case kSrv2Cli_Marker_TemplateCreated:
return pyMarkerTemplateCreatedMsg::New(message);
case kSrv2Cli_Marker_TeamAssigned:
return pyMarkerTeamAssignedMsg::New(message);
case kSrv2Cli_Marker_GameType:
return pyMarkerGameTypeMsg::New(message);
case kSrv2Cli_Marker_GameStarted:
return pyMarkerGameStartedMsg::New(message);
case kSrv2Cli_Marker_GamePaused:
return pyMarkerGamePausedMsg::New(message);
case kSrv2Cli_Marker_GameReset:
return pyMarkerGameResetMsg::New(message);
case kSrv2Cli_Marker_GameOver:
return pyMarkerGameOverMsg::New(message);
case kSrv2Cli_Marker_GameNameChanged:
return pyMarkerGameNameChangedMsg::New(message);
case kSrv2Cli_Marker_TimeLimitChanged:
return pyMarkerTimeLimitChangedMsg::New(message);
case kSrv2Cli_Marker_GameDeleted:
return pyMarkerGameDeletedMsg::New(message);
case kSrv2Cli_Marker_MarkerAdded:
return pyMarkerMarkerAddedMsg::New(message);
case kSrv2Cli_Marker_MarkerDeleted:
return pyMarkerMarkerDeletedMsg::New(message);
case kSrv2Cli_Marker_MarkerNameChanged:
return pyMarkerMarkerNameChangedMsg::New(message);
case kSrv2Cli_Marker_MarkerCaptured:
return pyMarkerMarkerCapturedMsg::New(message);
default:
PYTHON_RETURN_NONE;
}
}
///////////////////////////////////////////////////////////////////////////////
//
// The different messages we can receive
//
pyMarkerTemplateCreatedMsg::pyMarkerTemplateCreatedMsg(): pyMarkerMsg() {}
pyMarkerTemplateCreatedMsg::pyMarkerTemplateCreatedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_TemplateCreated))
message = nil; // wrong type, just clear it out
}
std::wstring pyMarkerTemplateCreatedMsg::TemplateID() const
{
if (message)
{
const Srv2Cli_Marker_TemplateCreated* gmMsg = (const Srv2Cli_Marker_TemplateCreated*)message->netMsg;
return gmMsg->templateID;
}
return L"";
}
///////////////////////////////////////////////////////////////////////////////
pyMarkerTeamAssignedMsg::pyMarkerTeamAssignedMsg(): pyMarkerMsg() {}
pyMarkerTeamAssignedMsg::pyMarkerTeamAssignedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_TeamAssigned))
message = nil; // wrong type, just clear it out
}
int pyMarkerTeamAssignedMsg::TeamNumber() const
{
if (message)
{
const Srv2Cli_Marker_TeamAssigned* gmMsg = (const Srv2Cli_Marker_TeamAssigned*)message->netMsg;
return gmMsg->teamNumber;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
pyMarkerGameTypeMsg::pyMarkerGameTypeMsg(): pyMarkerMsg() {}
pyMarkerGameTypeMsg::pyMarkerGameTypeMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_GameType))
message = nil; // wrong type, just clear it out
}
int pyMarkerGameTypeMsg::GameType() const
{
if (message)
{
const Srv2Cli_Marker_GameType* gmMsg = (const Srv2Cli_Marker_GameType*)message->netMsg;
return gmMsg->gameType;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
pyMarkerGameStartedMsg::pyMarkerGameStartedMsg(): pyMarkerMsg() {}
pyMarkerGameStartedMsg::pyMarkerGameStartedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_GameStarted))
message = nil; // wrong type, just clear it out
}
///////////////////////////////////////////////////////////////////////////////
pyMarkerGamePausedMsg::pyMarkerGamePausedMsg(): pyMarkerMsg() {}
pyMarkerGamePausedMsg::pyMarkerGamePausedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_GamePaused))
message = nil; // wrong type, just clear it out
}
unsigned long pyMarkerGamePausedMsg::TimeLeft() const
{
if (message)
{
const Srv2Cli_Marker_GamePaused* gmMsg = (const Srv2Cli_Marker_GamePaused*)message->netMsg;
return gmMsg->timeLeft;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
pyMarkerGameResetMsg::pyMarkerGameResetMsg(): pyMarkerMsg() {}
pyMarkerGameResetMsg::pyMarkerGameResetMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_GameReset))
message = nil; // wrong type, just clear it out
}
///////////////////////////////////////////////////////////////////////////////
pyMarkerGameOverMsg::pyMarkerGameOverMsg(): pyMarkerMsg() {}
pyMarkerGameOverMsg::pyMarkerGameOverMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_GameOver))
message = nil; // wrong type, just clear it out
}
///////////////////////////////////////////////////////////////////////////////
pyMarkerGameNameChangedMsg::pyMarkerGameNameChangedMsg(): pyMarkerMsg() {}
pyMarkerGameNameChangedMsg::pyMarkerGameNameChangedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_GameNameChanged))
message = nil; // wrong type, just clear it out
}
std::wstring pyMarkerGameNameChangedMsg::Name() const
{
if (message)
{
const Srv2Cli_Marker_GameNameChanged* gmMsg = (const Srv2Cli_Marker_GameNameChanged*)message->netMsg;
return gmMsg->newName;
}
return L"";
}
///////////////////////////////////////////////////////////////////////////////
pyMarkerTimeLimitChangedMsg::pyMarkerTimeLimitChangedMsg(): pyMarkerMsg() {}
pyMarkerTimeLimitChangedMsg::pyMarkerTimeLimitChangedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_TimeLimitChanged))
message = nil; // wrong type, just clear it out
}
unsigned long pyMarkerTimeLimitChangedMsg::TimeLimit() const
{
if (message)
{
const Srv2Cli_Marker_TimeLimitChanged* gmMsg = (const Srv2Cli_Marker_TimeLimitChanged*)message->netMsg;
return gmMsg->newTimeLimit;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
pyMarkerGameDeletedMsg::pyMarkerGameDeletedMsg(): pyMarkerMsg() {}
pyMarkerGameDeletedMsg::pyMarkerGameDeletedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_GameDeleted))
message = nil; // wrong type, just clear it out
}
bool pyMarkerGameDeletedMsg::Failed() const
{
if (message)
{
const Srv2Cli_Marker_GameDeleted* gmMsg = (const Srv2Cli_Marker_GameDeleted*)message->netMsg;
return gmMsg->failed;
}
return true; // assume it failed if we have a problem
}
///////////////////////////////////////////////////////////////////////////////
pyMarkerMarkerAddedMsg::pyMarkerMarkerAddedMsg(): pyMarkerMsg() {}
pyMarkerMarkerAddedMsg::pyMarkerMarkerAddedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_MarkerAdded))
message = nil; // wrong type, just clear it out
}
double pyMarkerMarkerAddedMsg::X() const
{
if (message)
{
const Srv2Cli_Marker_MarkerAdded* gmMsg = (const Srv2Cli_Marker_MarkerAdded*)message->netMsg;
return gmMsg->x;
}
return 0;
}
double pyMarkerMarkerAddedMsg::Y() const
{
if (message)
{
const Srv2Cli_Marker_MarkerAdded* gmMsg = (const Srv2Cli_Marker_MarkerAdded*)message->netMsg;
return gmMsg->y;
}
return 0;
}
double pyMarkerMarkerAddedMsg::Z() const
{
if (message)
{
const Srv2Cli_Marker_MarkerAdded* gmMsg = (const Srv2Cli_Marker_MarkerAdded*)message->netMsg;
return gmMsg->z;
}
return 0;
}
unsigned long pyMarkerMarkerAddedMsg::MarkerId() const
{
if (message)
{
const Srv2Cli_Marker_MarkerAdded* gmMsg = (const Srv2Cli_Marker_MarkerAdded*)message->netMsg;
return gmMsg->markerID;
}
return 0;
}
std::wstring pyMarkerMarkerAddedMsg::Name() const
{
if (message)
{
const Srv2Cli_Marker_MarkerAdded* gmMsg = (const Srv2Cli_Marker_MarkerAdded*)message->netMsg;
return gmMsg->name;
}
return L"";
}
std::wstring pyMarkerMarkerAddedMsg::Age() const
{
if (message)
{
const Srv2Cli_Marker_MarkerAdded* gmMsg = (const Srv2Cli_Marker_MarkerAdded*)message->netMsg;
return gmMsg->age;
}
return L"";
}
///////////////////////////////////////////////////////////////////////////////
pyMarkerMarkerDeletedMsg::pyMarkerMarkerDeletedMsg(): pyMarkerMsg() {}
pyMarkerMarkerDeletedMsg::pyMarkerMarkerDeletedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_MarkerDeleted))
message = nil; // wrong type, just clear it out
}
unsigned long pyMarkerMarkerDeletedMsg::MarkerId() const
{
if (message)
{
const Srv2Cli_Marker_MarkerDeleted* gmMsg = (const Srv2Cli_Marker_MarkerDeleted*)message->netMsg;
return gmMsg->markerID;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
pyMarkerMarkerNameChangedMsg::pyMarkerMarkerNameChangedMsg(): pyMarkerMsg() {}
pyMarkerMarkerNameChangedMsg::pyMarkerMarkerNameChangedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_MarkerNameChanged))
message = nil; // wrong type, just clear it out
}
unsigned long pyMarkerMarkerNameChangedMsg::MarkerId() const
{
if (message)
{
const Srv2Cli_Marker_MarkerNameChanged* gmMsg = (const Srv2Cli_Marker_MarkerNameChanged*)message->netMsg;
return gmMsg->markerID;
}
return 0;
}
std::wstring pyMarkerMarkerNameChangedMsg::Name() const
{
if (message)
{
const Srv2Cli_Marker_MarkerNameChanged* gmMsg = (const Srv2Cli_Marker_MarkerNameChanged*)message->netMsg;
return gmMsg->newName;
}
return L"";
}
///////////////////////////////////////////////////////////////////////////////
pyMarkerMarkerCapturedMsg::pyMarkerMarkerCapturedMsg(): pyMarkerMsg() {}
pyMarkerMarkerCapturedMsg::pyMarkerMarkerCapturedMsg(pfGameCliMsg* msg): pyMarkerMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Marker_MarkerCaptured))
message = nil; // wrong type, just clear it out
}
unsigned long pyMarkerMarkerCapturedMsg::MarkerId() const
{
if (message)
{
const Srv2Cli_Marker_MarkerCaptured* gmMsg = (const Srv2Cli_Marker_MarkerCaptured*)message->netMsg;
return gmMsg->markerID;
}
return 0;
}
unsigned int pyMarkerMarkerCapturedMsg::Team() const
{
if (message)
{
const Srv2Cli_Marker_MarkerCaptured* gmMsg = (const Srv2Cli_Marker_MarkerCaptured*)message->netMsg;
return gmMsg->team;
}
return 0;
}

View File

@ -1,331 +1,331 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyMarkerMsg_h
#define pyMarkerMsg_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: pyMarkerMsg
//
// PURPOSE: Class wrapper for Marker game messages
//
#include "pfGameMgr/pfGameMgr.h"
#include <python.h>
#include "../../pyGlueHelpers.h"
#include "../pyGameCliMsg.h"
class pyMarkerMsg : public pyGameCliMsg
{
protected:
pyMarkerMsg();
pyMarkerMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_EXPOSE_TYPE; // so we can subclass
PYTHON_CLASS_NEW_FRIEND(ptMarkerMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerMsg); // converts a PyObject to a pyMarkerMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaConstantsClasses(PyObject* m);
int GetMarkerMsgType() const;
PyObject* UpcastToFinalMarkerMsg() const; // returns this message as the marker message it really is
};
///////////////////////////////////////////////////////////////////////////////
class pyMarkerTemplateCreatedMsg : public pyMarkerMsg
{
protected:
pyMarkerTemplateCreatedMsg();
pyMarkerTemplateCreatedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMarkerTemplateCreatedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerTemplateCreatedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerTemplateCreatedMsg); // converts a PyObject to a pyMarkerTemplateCreatedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
std::wstring TemplateID() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyMarkerTeamAssignedMsg : public pyMarkerMsg
{
protected:
pyMarkerTeamAssignedMsg();
pyMarkerTeamAssignedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMarkerTeamAssignedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerTeamAssignedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerTeamAssignedMsg); // converts a PyObject to a pyMarkerTeamAssignedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
int TeamNumber() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyMarkerGameTypeMsg : public pyMarkerMsg
{
protected:
pyMarkerGameTypeMsg();
pyMarkerGameTypeMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMarkerGameTypeMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerGameTypeMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerGameTypeMsg); // converts a PyObject to a pyMarkerGameTypeMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
int GameType() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyMarkerGameStartedMsg : public pyMarkerMsg
{
protected:
pyMarkerGameStartedMsg();
pyMarkerGameStartedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMarkerGameStartedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerGameStartedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerGameStartedMsg); // converts a PyObject to a pyMarkerGameStartedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
};
///////////////////////////////////////////////////////////////////////////////
class pyMarkerGamePausedMsg : public pyMarkerMsg
{
protected:
pyMarkerGamePausedMsg();
pyMarkerGamePausedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMarkerGamePausedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerGamePausedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerGamePausedMsg); // converts a PyObject to a pyMarkerGamePausedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
unsigned long TimeLeft() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyMarkerGameResetMsg : public pyMarkerMsg
{
protected:
pyMarkerGameResetMsg();
pyMarkerGameResetMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMarkerGameResetMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerGameResetMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerGameResetMsg); // converts a PyObject to a pyMarkerGameResetMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
};
///////////////////////////////////////////////////////////////////////////////
class pyMarkerGameOverMsg : public pyMarkerMsg
{
protected:
pyMarkerGameOverMsg();
pyMarkerGameOverMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMarkerGameOverMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerGameOverMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerGameOverMsg); // converts a PyObject to a pyMarkerGameOverMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
};
///////////////////////////////////////////////////////////////////////////////
class pyMarkerGameNameChangedMsg : public pyMarkerMsg
{
protected:
pyMarkerGameNameChangedMsg();
pyMarkerGameNameChangedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMarkerGameNameChangedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerGameNameChangedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerGameNameChangedMsg); // converts a PyObject to a pyMarkerGameNameChangedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
std::wstring Name() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyMarkerTimeLimitChangedMsg : public pyMarkerMsg
{
protected:
pyMarkerTimeLimitChangedMsg();
pyMarkerTimeLimitChangedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMarkerTimeLimitChangedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerTimeLimitChangedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerTimeLimitChangedMsg); // converts a PyObject to a pyMarkerTimeLimitChangedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
unsigned long TimeLimit() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyMarkerGameDeletedMsg : public pyMarkerMsg
{
protected:
pyMarkerGameDeletedMsg();
pyMarkerGameDeletedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMarkerGameDeletedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerGameDeletedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerGameDeletedMsg); // converts a PyObject to a pyMarkerGameDeletedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
bool Failed() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyMarkerMarkerAddedMsg : public pyMarkerMsg
{
protected:
pyMarkerMarkerAddedMsg();
pyMarkerMarkerAddedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMarkerMarkerAddedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerMarkerAddedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerMarkerAddedMsg); // converts a PyObject to a pyMarkerMarkerAddedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
double X() const;
double Y() const;
double Z() const;
unsigned long MarkerId() const;
std::wstring Name() const;
std::wstring Age() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyMarkerMarkerDeletedMsg : public pyMarkerMsg
{
protected:
pyMarkerMarkerDeletedMsg();
pyMarkerMarkerDeletedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMarkerMarkerDeletedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerMarkerDeletedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerMarkerDeletedMsg); // converts a PyObject to a pyMarkerMarkerDeletedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
unsigned long MarkerId() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyMarkerMarkerNameChangedMsg : public pyMarkerMsg
{
protected:
pyMarkerMarkerNameChangedMsg();
pyMarkerMarkerNameChangedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMarkerMarkerNameChangedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerMarkerNameChangedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerMarkerNameChangedMsg); // converts a PyObject to a pyMarkerMarkerNameChangedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
unsigned long MarkerId() const;
std::wstring Name() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyMarkerMarkerCapturedMsg : public pyMarkerMsg
{
protected:
pyMarkerMarkerCapturedMsg();
pyMarkerMarkerCapturedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMarkerMarkerCapturedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerMarkerCapturedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerMarkerCapturedMsg); // converts a PyObject to a pyMarkerMarkerCapturedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
unsigned long MarkerId() const;
unsigned int Team() const;
};
#endif // pyMarkerMsg_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyMarkerMsg_h
#define pyMarkerMsg_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: pyMarkerMsg
//
// PURPOSE: Class wrapper for Marker game messages
//
#include "pfGameMgr/pfGameMgr.h"
#include <python.h>
#include "../../pyGlueHelpers.h"
#include "../pyGameCliMsg.h"
class pyMarkerMsg : public pyGameCliMsg
{
protected:
pyMarkerMsg();
pyMarkerMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_EXPOSE_TYPE; // so we can subclass
PYTHON_CLASS_NEW_FRIEND(ptMarkerMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerMsg); // converts a PyObject to a pyMarkerMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaConstantsClasses(PyObject* m);
int GetMarkerMsgType() const;
PyObject* UpcastToFinalMarkerMsg() const; // returns this message as the marker message it really is
};
///////////////////////////////////////////////////////////////////////////////
class pyMarkerTemplateCreatedMsg : public pyMarkerMsg
{
protected:
pyMarkerTemplateCreatedMsg();
pyMarkerTemplateCreatedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMarkerTemplateCreatedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerTemplateCreatedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerTemplateCreatedMsg); // converts a PyObject to a pyMarkerTemplateCreatedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
std::wstring TemplateID() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyMarkerTeamAssignedMsg : public pyMarkerMsg
{
protected:
pyMarkerTeamAssignedMsg();
pyMarkerTeamAssignedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMarkerTeamAssignedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerTeamAssignedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerTeamAssignedMsg); // converts a PyObject to a pyMarkerTeamAssignedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
int TeamNumber() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyMarkerGameTypeMsg : public pyMarkerMsg
{
protected:
pyMarkerGameTypeMsg();
pyMarkerGameTypeMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMarkerGameTypeMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerGameTypeMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerGameTypeMsg); // converts a PyObject to a pyMarkerGameTypeMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
int GameType() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyMarkerGameStartedMsg : public pyMarkerMsg
{
protected:
pyMarkerGameStartedMsg();
pyMarkerGameStartedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMarkerGameStartedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerGameStartedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerGameStartedMsg); // converts a PyObject to a pyMarkerGameStartedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
};
///////////////////////////////////////////////////////////////////////////////
class pyMarkerGamePausedMsg : public pyMarkerMsg
{
protected:
pyMarkerGamePausedMsg();
pyMarkerGamePausedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMarkerGamePausedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerGamePausedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerGamePausedMsg); // converts a PyObject to a pyMarkerGamePausedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
unsigned long TimeLeft() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyMarkerGameResetMsg : public pyMarkerMsg
{
protected:
pyMarkerGameResetMsg();
pyMarkerGameResetMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMarkerGameResetMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerGameResetMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerGameResetMsg); // converts a PyObject to a pyMarkerGameResetMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
};
///////////////////////////////////////////////////////////////////////////////
class pyMarkerGameOverMsg : public pyMarkerMsg
{
protected:
pyMarkerGameOverMsg();
pyMarkerGameOverMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMarkerGameOverMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerGameOverMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerGameOverMsg); // converts a PyObject to a pyMarkerGameOverMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
};
///////////////////////////////////////////////////////////////////////////////
class pyMarkerGameNameChangedMsg : public pyMarkerMsg
{
protected:
pyMarkerGameNameChangedMsg();
pyMarkerGameNameChangedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMarkerGameNameChangedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerGameNameChangedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerGameNameChangedMsg); // converts a PyObject to a pyMarkerGameNameChangedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
std::wstring Name() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyMarkerTimeLimitChangedMsg : public pyMarkerMsg
{
protected:
pyMarkerTimeLimitChangedMsg();
pyMarkerTimeLimitChangedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMarkerTimeLimitChangedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerTimeLimitChangedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerTimeLimitChangedMsg); // converts a PyObject to a pyMarkerTimeLimitChangedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
unsigned long TimeLimit() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyMarkerGameDeletedMsg : public pyMarkerMsg
{
protected:
pyMarkerGameDeletedMsg();
pyMarkerGameDeletedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMarkerGameDeletedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerGameDeletedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerGameDeletedMsg); // converts a PyObject to a pyMarkerGameDeletedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
bool Failed() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyMarkerMarkerAddedMsg : public pyMarkerMsg
{
protected:
pyMarkerMarkerAddedMsg();
pyMarkerMarkerAddedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMarkerMarkerAddedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerMarkerAddedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerMarkerAddedMsg); // converts a PyObject to a pyMarkerMarkerAddedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
double X() const;
double Y() const;
double Z() const;
unsigned long MarkerId() const;
std::wstring Name() const;
std::wstring Age() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyMarkerMarkerDeletedMsg : public pyMarkerMsg
{
protected:
pyMarkerMarkerDeletedMsg();
pyMarkerMarkerDeletedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMarkerMarkerDeletedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerMarkerDeletedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerMarkerDeletedMsg); // converts a PyObject to a pyMarkerMarkerDeletedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
unsigned long MarkerId() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyMarkerMarkerNameChangedMsg : public pyMarkerMsg
{
protected:
pyMarkerMarkerNameChangedMsg();
pyMarkerMarkerNameChangedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMarkerMarkerNameChangedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerMarkerNameChangedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerMarkerNameChangedMsg); // converts a PyObject to a pyMarkerMarkerNameChangedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
unsigned long MarkerId() const;
std::wstring Name() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyMarkerMarkerCapturedMsg : public pyMarkerMsg
{
protected:
pyMarkerMarkerCapturedMsg();
pyMarkerMarkerCapturedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptMarkerMarkerCapturedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyMarkerMarkerCapturedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyMarkerMarkerCapturedMsg); // converts a PyObject to a pyMarkerMarkerCapturedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
unsigned long MarkerId() const;
unsigned int Team() const;
};
#endif // pyMarkerMsg_h

View File

@ -1,77 +1,77 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyTTTGame.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base TTT game client class
//
pyTTTGame::pyTTTGame(): pyGameCli() {}
pyTTTGame::pyTTTGame(pfGameCli* client): pyGameCli(client)
{
if (client && (client->GetGameTypeId() != kGameTypeId_TicTacToe))
gameClient = nil; // wrong type, just clear it out
}
bool pyTTTGame::IsTTTGame(std::wstring guid)
{
Uuid gameUuid(guid.c_str());
return gameUuid == kGameTypeId_TicTacToe;
}
void pyTTTGame::CreateTTTGame(pyKey& callbackKey, unsigned numPlayers)
{
TTT_CreateParam init;
init.playerCount = numPlayers;
pfGameMgr::GetInstance()->CreateGame(callbackKey.getKey(), kGameTypeId_TicTacToe, 0, sizeof(init), &init);
}
void pyTTTGame::JoinCommonTTTGame(pyKey& callbackKey, unsigned gameID, unsigned numPlayers)
{
TTT_CreateParam init;
init.playerCount = numPlayers;
pfGameMgr::GetInstance()->JoinCommonGame(callbackKey.getKey(), kGameTypeId_TicTacToe, gameID, sizeof(init), &init);
}
void pyTTTGame::MakeMove(unsigned row, unsigned col)
{
if (gameClient)
{
pfGmTicTacToe* ttt = pfGmTicTacToe::ConvertNoRef(gameClient);
ttt->MakeMove(row, col);
}
}
void pyTTTGame::ShowBoard()
{
if (gameClient)
{
pfGmTicTacToe* ttt = pfGmTicTacToe::ConvertNoRef(gameClient);
ttt->ShowBoard();
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyTTTGame.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base TTT game client class
//
pyTTTGame::pyTTTGame(): pyGameCli() {}
pyTTTGame::pyTTTGame(pfGameCli* client): pyGameCli(client)
{
if (client && (client->GetGameTypeId() != kGameTypeId_TicTacToe))
gameClient = nil; // wrong type, just clear it out
}
bool pyTTTGame::IsTTTGame(std::wstring guid)
{
Uuid gameUuid(guid.c_str());
return gameUuid == kGameTypeId_TicTacToe;
}
void pyTTTGame::CreateTTTGame(pyKey& callbackKey, unsigned numPlayers)
{
TTT_CreateParam init;
init.playerCount = numPlayers;
pfGameMgr::GetInstance()->CreateGame(callbackKey.getKey(), kGameTypeId_TicTacToe, 0, sizeof(init), &init);
}
void pyTTTGame::JoinCommonTTTGame(pyKey& callbackKey, unsigned gameID, unsigned numPlayers)
{
TTT_CreateParam init;
init.playerCount = numPlayers;
pfGameMgr::GetInstance()->JoinCommonGame(callbackKey.getKey(), kGameTypeId_TicTacToe, gameID, sizeof(init), &init);
}
void pyTTTGame::MakeMove(unsigned row, unsigned col)
{
if (gameClient)
{
pfGmTicTacToe* ttt = pfGmTicTacToe::ConvertNoRef(gameClient);
ttt->MakeMove(row, col);
}
}
void pyTTTGame::ShowBoard()
{
if (gameClient)
{
pfGmTicTacToe* ttt = pfGmTicTacToe::ConvertNoRef(gameClient);
ttt->ShowBoard();
}
}

View File

@ -1,68 +1,68 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyTTTGame_h
#define pyTTTGame_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: pyTTTGame
//
// PURPOSE: Class wrapper for the TTT game client
//
#include "pfGameMgr/pfGameMgr.h"
#include <python.h>
#include "../../pyGlueHelpers.h"
#include "../pyGameCli.h"
#include "../../pyKey.h"
class pyTTTGame : public pyGameCli
{
protected:
pyTTTGame();
pyTTTGame(pfGameCli* client);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptTTTGame);
static PyObject* New(pfGameCli* client);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyTTTGame object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyTTTGame); // converts a PyObject to a pyTTTGame (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaConstantsClasses(PyObject* m);
static void AddPlasmaMethods(std::vector<PyMethodDef>& methods);
static bool IsTTTGame(std::wstring guid);
static void CreateTTTGame(pyKey& callbackKey, unsigned numPlayers);
static void JoinCommonTTTGame(pyKey& callbackKey, unsigned gameID, unsigned numPlayers);
void MakeMove(unsigned row, unsigned col);
void ShowBoard();
};
#endif // pyTTTGame_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyTTTGame_h
#define pyTTTGame_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: pyTTTGame
//
// PURPOSE: Class wrapper for the TTT game client
//
#include "pfGameMgr/pfGameMgr.h"
#include <python.h>
#include "../../pyGlueHelpers.h"
#include "../pyGameCli.h"
#include "../../pyKey.h"
class pyTTTGame : public pyGameCli
{
protected:
pyTTTGame();
pyTTTGame(pfGameCli* client);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptTTTGame);
static PyObject* New(pfGameCli* client);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyTTTGame object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyTTTGame); // converts a PyObject to a pyTTTGame (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaConstantsClasses(PyObject* m);
static void AddPlasmaMethods(std::vector<PyMethodDef>& methods);
static bool IsTTTGame(std::wstring guid);
static void CreateTTTGame(pyKey& callbackKey, unsigned numPlayers);
static void JoinCommonTTTGame(pyKey& callbackKey, unsigned gameID, unsigned numPlayers);
void MakeMove(unsigned row, unsigned col);
void ShowBoard();
};
#endif // pyTTTGame_h

View File

@ -1,172 +1,172 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyTTTGame.h"
#include <python.h>
#include "../../pyEnum.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base TTT game client class
//
PYTHON_CLASS_DEFINITION(ptTTTGame, pyTTTGame);
PYTHON_DEFAULT_NEW_DEFINITION(ptTTTGame, pyTTTGame)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptTTTGame)
PYTHON_NO_INIT_DEFINITION(ptTTTGame)
PYTHON_GLOBAL_METHOD_DEFINITION(PtIsTTTGame, args, "Params: typeID\nReturns true if the specifed typeID (guid as a string) is a TicTacToe game")
{
PyObject* textObj;
if (!PyArg_ParseTuple(args, "O", &textObj))
{
PyErr_SetString(PyExc_TypeError, "PtIsTTTGame expects a unicode string");
PYTHON_RETURN_ERROR;
}
if (PyUnicode_Check(textObj))
{
int strLen = PyUnicode_GetSize(textObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)textObj, text, strLen);
text[strLen] = L'\0';
bool retVal = pyTTTGame::IsTTTGame(text);
delete [] text;
PYTHON_RETURN_BOOL(retVal);
}
else if (PyString_Check(textObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(textObj);
wchar_t* wText = hsStringToWString(text);
bool retVal = pyTTTGame::IsTTTGame(wText);
delete [] wText;
PYTHON_RETURN_BOOL(retVal);
}
else
{
PyErr_SetString(PyExc_TypeError, "PtIsTTTGame expects a unicode string");
PYTHON_RETURN_ERROR;
}
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtCreateTTTGame, args, "Params: callbackKey, numPlayers\nCreates a new TicTacToe game with the specified callback key and number of players (1 or 2)")
{
PyObject* callbackObj = NULL;
int numPlayers = 0;
if (!PyArg_ParseTuple(args, "Oi", &callbackObj, &numPlayers))
{
PyErr_SetString(PyExc_TypeError, "PtCreateTTTGame expects a ptKey and an integer");
PYTHON_RETURN_ERROR;
}
if (!pyKey::Check(callbackObj))
{
PyErr_SetString(PyExc_TypeError, "PtCreateTTTGame expects a ptKey and an integer");
PYTHON_RETURN_ERROR;
}
pyKey* key = pyKey::ConvertFrom(callbackObj);
pyTTTGame::CreateTTTGame(*key, numPlayers);
PYTHON_RETURN_NONE;
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtJoinCommonTTTGame, args, "Params: callbackKey, gameID, numPlayers\nJoins a common TicTacToe game with the specified ID. If one doesn't exist, it creates it with the specified number of players")
{
PyObject* callbackObj = NULL;
int gameID = 0, numPlayers = 0;
if (!PyArg_ParseTuple(args, "Oii", &callbackObj, &gameID, &numPlayers))
{
PyErr_SetString(PyExc_TypeError, "PtJoinCommonTTTGame expects a ptKey and two integers");
PYTHON_RETURN_ERROR;
}
if (!pyKey::Check(callbackObj))
{
PyErr_SetString(PyExc_TypeError, "PtJoinCommonTTTGame expects a ptKey and two integers");
PYTHON_RETURN_ERROR;
}
pyKey* key = pyKey::ConvertFrom(callbackObj);
pyTTTGame::JoinCommonTTTGame(*key, gameID, numPlayers);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptTTTGame, makeMove, args)
{
int row = 0, col = 0;
if (!PyArg_ParseTuple(args, "ii", &row, &col))
{
PyErr_SetString(PyExc_TypeError, "makeMove expects two integers");
PYTHON_RETURN_ERROR;
}
self->fThis->MakeMove(row, col);
PYTHON_RETURN_NONE;
}
PYTHON_BASIC_METHOD_DEFINITION(ptTTTGame, showBoard, ShowBoard)
PYTHON_START_METHODS_TABLE(ptTTTGame)
PYTHON_METHOD(ptTTTGame, makeMove, "Params: row, col\nMakes a move in the specified spot"),
PYTHON_BASIC_METHOD(ptTTTGame, showBoard, "Prints the current board layout to the console"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptTTTGame, pyGameCli, "Game client for the TicTacToe game");
// required functions for PyObject interoperability
PyObject* pyTTTGame::New(pfGameCli* client)
{
ptTTTGame *newObj = (ptTTTGame*)ptTTTGame_type.tp_new(&ptTTTGame_type, NULL, NULL);
if (client && (client->GetGameTypeId() == kGameTypeId_TicTacToe))
newObj->fThis->gameClient = client;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptTTTGame, pyTTTGame)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptTTTGame, pyTTTGame)
// Module and method definitions
void pyTTTGame::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptTTTGame);
PYTHON_CLASS_IMPORT_END(m);
}
void pyTTTGame::AddPlasmaConstantsClasses(PyObject* m)
{
PYTHON_ENUM_START(PtTTTGameResult);
PYTHON_ENUM_ELEMENT(PtTTTGameResult, kTTTGameResultWinner, kTTTGameResultWinner);
PYTHON_ENUM_ELEMENT(PtTTTGameResult, kTTTGameResultTied, kTTTGameResultTied);
PYTHON_ENUM_ELEMENT(PtTTTGameResult, kTTTGameResultGave, kTTTGameResultGave);
PYTHON_ENUM_ELEMENT(PtTTTGameResult, kTTTGameResultError, kTTTGameResultError);
PYTHON_ENUM_END(m, PtTTTGameResult);
}
void pyTTTGame::AddPlasmaMethods(std::vector<PyMethodDef>& methods)
{
PYTHON_GLOBAL_METHOD(methods, PtIsTTTGame);
PYTHON_GLOBAL_METHOD(methods, PtCreateTTTGame);
PYTHON_GLOBAL_METHOD(methods, PtJoinCommonTTTGame);
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyTTTGame.h"
#include <python.h>
#include "../../pyEnum.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base TTT game client class
//
PYTHON_CLASS_DEFINITION(ptTTTGame, pyTTTGame);
PYTHON_DEFAULT_NEW_DEFINITION(ptTTTGame, pyTTTGame)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptTTTGame)
PYTHON_NO_INIT_DEFINITION(ptTTTGame)
PYTHON_GLOBAL_METHOD_DEFINITION(PtIsTTTGame, args, "Params: typeID\nReturns true if the specifed typeID (guid as a string) is a TicTacToe game")
{
PyObject* textObj;
if (!PyArg_ParseTuple(args, "O", &textObj))
{
PyErr_SetString(PyExc_TypeError, "PtIsTTTGame expects a unicode string");
PYTHON_RETURN_ERROR;
}
if (PyUnicode_Check(textObj))
{
int strLen = PyUnicode_GetSize(textObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)textObj, text, strLen);
text[strLen] = L'\0';
bool retVal = pyTTTGame::IsTTTGame(text);
delete [] text;
PYTHON_RETURN_BOOL(retVal);
}
else if (PyString_Check(textObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(textObj);
wchar_t* wText = hsStringToWString(text);
bool retVal = pyTTTGame::IsTTTGame(wText);
delete [] wText;
PYTHON_RETURN_BOOL(retVal);
}
else
{
PyErr_SetString(PyExc_TypeError, "PtIsTTTGame expects a unicode string");
PYTHON_RETURN_ERROR;
}
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtCreateTTTGame, args, "Params: callbackKey, numPlayers\nCreates a new TicTacToe game with the specified callback key and number of players (1 or 2)")
{
PyObject* callbackObj = NULL;
int numPlayers = 0;
if (!PyArg_ParseTuple(args, "Oi", &callbackObj, &numPlayers))
{
PyErr_SetString(PyExc_TypeError, "PtCreateTTTGame expects a ptKey and an integer");
PYTHON_RETURN_ERROR;
}
if (!pyKey::Check(callbackObj))
{
PyErr_SetString(PyExc_TypeError, "PtCreateTTTGame expects a ptKey and an integer");
PYTHON_RETURN_ERROR;
}
pyKey* key = pyKey::ConvertFrom(callbackObj);
pyTTTGame::CreateTTTGame(*key, numPlayers);
PYTHON_RETURN_NONE;
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtJoinCommonTTTGame, args, "Params: callbackKey, gameID, numPlayers\nJoins a common TicTacToe game with the specified ID. If one doesn't exist, it creates it with the specified number of players")
{
PyObject* callbackObj = NULL;
int gameID = 0, numPlayers = 0;
if (!PyArg_ParseTuple(args, "Oii", &callbackObj, &gameID, &numPlayers))
{
PyErr_SetString(PyExc_TypeError, "PtJoinCommonTTTGame expects a ptKey and two integers");
PYTHON_RETURN_ERROR;
}
if (!pyKey::Check(callbackObj))
{
PyErr_SetString(PyExc_TypeError, "PtJoinCommonTTTGame expects a ptKey and two integers");
PYTHON_RETURN_ERROR;
}
pyKey* key = pyKey::ConvertFrom(callbackObj);
pyTTTGame::JoinCommonTTTGame(*key, gameID, numPlayers);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptTTTGame, makeMove, args)
{
int row = 0, col = 0;
if (!PyArg_ParseTuple(args, "ii", &row, &col))
{
PyErr_SetString(PyExc_TypeError, "makeMove expects two integers");
PYTHON_RETURN_ERROR;
}
self->fThis->MakeMove(row, col);
PYTHON_RETURN_NONE;
}
PYTHON_BASIC_METHOD_DEFINITION(ptTTTGame, showBoard, ShowBoard)
PYTHON_START_METHODS_TABLE(ptTTTGame)
PYTHON_METHOD(ptTTTGame, makeMove, "Params: row, col\nMakes a move in the specified spot"),
PYTHON_BASIC_METHOD(ptTTTGame, showBoard, "Prints the current board layout to the console"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptTTTGame, pyGameCli, "Game client for the TicTacToe game");
// required functions for PyObject interoperability
PyObject* pyTTTGame::New(pfGameCli* client)
{
ptTTTGame *newObj = (ptTTTGame*)ptTTTGame_type.tp_new(&ptTTTGame_type, NULL, NULL);
if (client && (client->GetGameTypeId() == kGameTypeId_TicTacToe))
newObj->fThis->gameClient = client;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptTTTGame, pyTTTGame)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptTTTGame, pyTTTGame)
// Module and method definitions
void pyTTTGame::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptTTTGame);
PYTHON_CLASS_IMPORT_END(m);
}
void pyTTTGame::AddPlasmaConstantsClasses(PyObject* m)
{
PYTHON_ENUM_START(PtTTTGameResult);
PYTHON_ENUM_ELEMENT(PtTTTGameResult, kTTTGameResultWinner, kTTTGameResultWinner);
PYTHON_ENUM_ELEMENT(PtTTTGameResult, kTTTGameResultTied, kTTTGameResultTied);
PYTHON_ENUM_ELEMENT(PtTTTGameResult, kTTTGameResultGave, kTTTGameResultGave);
PYTHON_ENUM_ELEMENT(PtTTTGameResult, kTTTGameResultError, kTTTGameResultError);
PYTHON_ENUM_END(m, PtTTTGameResult);
}
void pyTTTGame::AddPlasmaMethods(std::vector<PyMethodDef>& methods)
{
PYTHON_GLOBAL_METHOD(methods, PtIsTTTGame);
PYTHON_GLOBAL_METHOD(methods, PtCreateTTTGame);
PYTHON_GLOBAL_METHOD(methods, PtJoinCommonTTTGame);
}

View File

@ -1,155 +1,155 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyTTTMsg.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base TTT msg class
//
pyTTTMsg::pyTTTMsg(): pyGameCliMsg() {}
pyTTTMsg::pyTTTMsg(pfGameCliMsg* msg): pyGameCliMsg(msg)
{
if (message && (message->gameCli->GetGameTypeId() != kGameTypeId_TicTacToe))
message = nil; // wrong type, just clear it out
}
int pyTTTMsg::GetTTTMsgType() const
{
if (message)
return message->netMsg->messageId;
return -1;
}
PyObject* pyTTTMsg::UpcastToFinalTTTMsg() const
{
if (!message)
PYTHON_RETURN_NONE;
switch (message->netMsg->messageId)
{
case kSrv2Cli_TTT_GameStarted:
return pyTTTGameStartedMsg::New(message);
case kSrv2Cli_TTT_GameOver:
return pyTTTGameOverMsg::New(message);
case kSrv2Cli_TTT_MoveMade:
return pyTTTMoveMadeMsg::New(message);
default:
PYTHON_RETURN_NONE;
}
}
///////////////////////////////////////////////////////////////////////////////
//
// The different messages we can receive
//
pyTTTGameStartedMsg::pyTTTGameStartedMsg(): pyTTTMsg() {}
pyTTTGameStartedMsg::pyTTTGameStartedMsg(pfGameCliMsg* msg): pyTTTMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_TTT_GameStarted))
message = nil; // wrong type, just clear it out
}
bool pyTTTGameStartedMsg::YourTurn() const
{
if (message)
{
const Srv2Cli_TTT_GameStarted* gmMsg = (const Srv2Cli_TTT_GameStarted*)message->netMsg;
return gmMsg->yourTurn;
}
return false;
}
///////////////////////////////////////////////////////////////////////////////
pyTTTGameOverMsg::pyTTTGameOverMsg(): pyTTTMsg() {}
pyTTTGameOverMsg::pyTTTGameOverMsg(pfGameCliMsg* msg): pyTTTMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_TTT_GameOver))
message = nil; // wrong type, just clear it out
}
int pyTTTGameOverMsg::Result() const
{
if (message)
{
const Srv2Cli_TTT_GameOver* gmMsg = (const Srv2Cli_TTT_GameOver*)message->netMsg;
return gmMsg->result;
}
return false;
}
unsigned long pyTTTGameOverMsg::WinnerID() const
{
if (message)
{
const Srv2Cli_TTT_GameOver* gmMsg = (const Srv2Cli_TTT_GameOver*)message->netMsg;
return gmMsg->winnerId;
}
return false;
}
///////////////////////////////////////////////////////////////////////////////
pyTTTMoveMadeMsg::pyTTTMoveMadeMsg(): pyTTTMsg() {}
pyTTTMoveMadeMsg::pyTTTMoveMadeMsg(pfGameCliMsg* msg): pyTTTMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_TTT_MoveMade))
message = nil; // wrong type, just clear it out
}
unsigned long pyTTTMoveMadeMsg::PlayerID() const
{
if (message)
{
const Srv2Cli_TTT_MoveMade* gmMsg = (const Srv2Cli_TTT_MoveMade*)message->netMsg;
return gmMsg->playerId;
}
return false;
}
int pyTTTMoveMadeMsg::Row() const
{
if (message)
{
const Srv2Cli_TTT_MoveMade* gmMsg = (const Srv2Cli_TTT_MoveMade*)message->netMsg;
return gmMsg->row;
}
return false;
}
int pyTTTMoveMadeMsg::Col() const
{
if (message)
{
const Srv2Cli_TTT_MoveMade* gmMsg = (const Srv2Cli_TTT_MoveMade*)message->netMsg;
return gmMsg->col;
}
return false;
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyTTTMsg.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base TTT msg class
//
pyTTTMsg::pyTTTMsg(): pyGameCliMsg() {}
pyTTTMsg::pyTTTMsg(pfGameCliMsg* msg): pyGameCliMsg(msg)
{
if (message && (message->gameCli->GetGameTypeId() != kGameTypeId_TicTacToe))
message = nil; // wrong type, just clear it out
}
int pyTTTMsg::GetTTTMsgType() const
{
if (message)
return message->netMsg->messageId;
return -1;
}
PyObject* pyTTTMsg::UpcastToFinalTTTMsg() const
{
if (!message)
PYTHON_RETURN_NONE;
switch (message->netMsg->messageId)
{
case kSrv2Cli_TTT_GameStarted:
return pyTTTGameStartedMsg::New(message);
case kSrv2Cli_TTT_GameOver:
return pyTTTGameOverMsg::New(message);
case kSrv2Cli_TTT_MoveMade:
return pyTTTMoveMadeMsg::New(message);
default:
PYTHON_RETURN_NONE;
}
}
///////////////////////////////////////////////////////////////////////////////
//
// The different messages we can receive
//
pyTTTGameStartedMsg::pyTTTGameStartedMsg(): pyTTTMsg() {}
pyTTTGameStartedMsg::pyTTTGameStartedMsg(pfGameCliMsg* msg): pyTTTMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_TTT_GameStarted))
message = nil; // wrong type, just clear it out
}
bool pyTTTGameStartedMsg::YourTurn() const
{
if (message)
{
const Srv2Cli_TTT_GameStarted* gmMsg = (const Srv2Cli_TTT_GameStarted*)message->netMsg;
return gmMsg->yourTurn;
}
return false;
}
///////////////////////////////////////////////////////////////////////////////
pyTTTGameOverMsg::pyTTTGameOverMsg(): pyTTTMsg() {}
pyTTTGameOverMsg::pyTTTGameOverMsg(pfGameCliMsg* msg): pyTTTMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_TTT_GameOver))
message = nil; // wrong type, just clear it out
}
int pyTTTGameOverMsg::Result() const
{
if (message)
{
const Srv2Cli_TTT_GameOver* gmMsg = (const Srv2Cli_TTT_GameOver*)message->netMsg;
return gmMsg->result;
}
return false;
}
unsigned long pyTTTGameOverMsg::WinnerID() const
{
if (message)
{
const Srv2Cli_TTT_GameOver* gmMsg = (const Srv2Cli_TTT_GameOver*)message->netMsg;
return gmMsg->winnerId;
}
return false;
}
///////////////////////////////////////////////////////////////////////////////
pyTTTMoveMadeMsg::pyTTTMoveMadeMsg(): pyTTTMsg() {}
pyTTTMoveMadeMsg::pyTTTMoveMadeMsg(pfGameCliMsg* msg): pyTTTMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_TTT_MoveMade))
message = nil; // wrong type, just clear it out
}
unsigned long pyTTTMoveMadeMsg::PlayerID() const
{
if (message)
{
const Srv2Cli_TTT_MoveMade* gmMsg = (const Srv2Cli_TTT_MoveMade*)message->netMsg;
return gmMsg->playerId;
}
return false;
}
int pyTTTMoveMadeMsg::Row() const
{
if (message)
{
const Srv2Cli_TTT_MoveMade* gmMsg = (const Srv2Cli_TTT_MoveMade*)message->netMsg;
return gmMsg->row;
}
return false;
}
int pyTTTMoveMadeMsg::Col() const
{
if (message)
{
const Srv2Cli_TTT_MoveMade* gmMsg = (const Srv2Cli_TTT_MoveMade*)message->netMsg;
return gmMsg->col;
}
return false;
}

View File

@ -1,124 +1,124 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyTTTMsg_h
#define pyTTTMsg_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: pyTTTMsg
//
// PURPOSE: Class wrapper for TTT game messages
//
#include "pfGameMgr/pfGameMgr.h"
#include <python.h>
#include "../../pyGlueHelpers.h"
#include "../pyGameCliMsg.h"
class pyTTTMsg : public pyGameCliMsg
{
protected:
pyTTTMsg();
pyTTTMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_EXPOSE_TYPE; // so we can subclass
PYTHON_CLASS_NEW_FRIEND(ptTTTMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyTTTMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyTTTMsg); // converts a PyObject to a pyTTTMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaConstantsClasses(PyObject* m);
int GetTTTMsgType() const;
PyObject* UpcastToFinalTTTMsg() const; // returns the ttt message that this really is
};
///////////////////////////////////////////////////////////////////////////////
class pyTTTGameStartedMsg : public pyTTTMsg
{
protected:
pyTTTGameStartedMsg();
pyTTTGameStartedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptTTTGameStartedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyTTTGameStartedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyTTTGameStartedMsg); // converts a PyObject to a pyTTTGameStartedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
bool YourTurn() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyTTTGameOverMsg : public pyTTTMsg
{
protected:
pyTTTGameOverMsg();
pyTTTGameOverMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptTTTGameOverMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyTTTGameOverMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyTTTGameOverMsg); // converts a PyObject to a pyTTTGameOverMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
int Result() const;
unsigned long WinnerID() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyTTTMoveMadeMsg : public pyTTTMsg
{
protected:
pyTTTMoveMadeMsg();
pyTTTMoveMadeMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptTTTMoveMadeMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyTTTMoveMadeMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyTTTMoveMadeMsg); // converts a PyObject to a pyTTTMoveMadeMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
unsigned long PlayerID() const;
int Row() const;
int Col() const;
};
#endif // pyTTTMsg_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyTTTMsg_h
#define pyTTTMsg_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: pyTTTMsg
//
// PURPOSE: Class wrapper for TTT game messages
//
#include "pfGameMgr/pfGameMgr.h"
#include <python.h>
#include "../../pyGlueHelpers.h"
#include "../pyGameCliMsg.h"
class pyTTTMsg : public pyGameCliMsg
{
protected:
pyTTTMsg();
pyTTTMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_EXPOSE_TYPE; // so we can subclass
PYTHON_CLASS_NEW_FRIEND(ptTTTMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyTTTMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyTTTMsg); // converts a PyObject to a pyTTTMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaConstantsClasses(PyObject* m);
int GetTTTMsgType() const;
PyObject* UpcastToFinalTTTMsg() const; // returns the ttt message that this really is
};
///////////////////////////////////////////////////////////////////////////////
class pyTTTGameStartedMsg : public pyTTTMsg
{
protected:
pyTTTGameStartedMsg();
pyTTTGameStartedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptTTTGameStartedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyTTTGameStartedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyTTTGameStartedMsg); // converts a PyObject to a pyTTTGameStartedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
bool YourTurn() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyTTTGameOverMsg : public pyTTTMsg
{
protected:
pyTTTGameOverMsg();
pyTTTGameOverMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptTTTGameOverMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyTTTGameOverMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyTTTGameOverMsg); // converts a PyObject to a pyTTTGameOverMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
int Result() const;
unsigned long WinnerID() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyTTTMoveMadeMsg : public pyTTTMsg
{
protected:
pyTTTMoveMadeMsg();
pyTTTMoveMadeMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptTTTMoveMadeMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyTTTMoveMadeMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyTTTMoveMadeMsg); // converts a PyObject to a pyTTTMoveMadeMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
unsigned long PlayerID() const;
int Row() const;
int Col() const;
};
#endif // pyTTTMsg_h

View File

@ -1,231 +1,231 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyTTTMsg.h"
#include "../../pyEnum.h"
#include <python.h>
///////////////////////////////////////////////////////////////////////////////
//
// Base TTT msg class
//
PYTHON_CLASS_DEFINITION(ptTTTMsg, pyTTTMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptTTTMsg, pyTTTMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptTTTMsg)
PYTHON_NO_INIT_DEFINITION(ptTTTMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptTTTMsg, getTTTMsgType)
{
return PyInt_FromLong(self->fThis->GetTTTMsgType());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptTTTMsg, upcastToFinalTTTMsg)
{
return self->fThis->UpcastToFinalTTTMsg();
}
PYTHON_START_METHODS_TABLE(ptTTTMsg)
PYTHON_METHOD_NOARGS(ptTTTMsg, getTTTMsgType, "Returns the type of the TTT message (see PtTTTMsgTypes)"),
PYTHON_METHOD_NOARGS(ptTTTMsg, upcastToFinalTTTMsg, "Returns this message as the TTT msg it is"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptTTTMsg, pyGameCliMsg, "Base class for TicTacToe game messages");
PYTHON_EXPOSE_TYPE_DEFINITION(ptTTTMsg, pyTTTMsg);
// required functions for PyObject interoperability
PyObject* pyTTTMsg::New(pfGameCliMsg* msg)
{
ptTTTMsg *newObj = (ptTTTMsg*)ptTTTMsg_type.tp_new(&ptTTTMsg_type, NULL, NULL);
if (msg && (msg->gameCli->GetGameTypeId() == kGameTypeId_TicTacToe))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptTTTMsg, pyTTTMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptTTTMsg, pyTTTMsg)
// Module and method definitions
void pyTTTMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptTTTMsg);
PYTHON_CLASS_IMPORT_END(m);
}
void pyTTTMsg::AddPlasmaConstantsClasses(PyObject* m)
{
PYTHON_ENUM_START(PtTTTMsgTypes);
PYTHON_ENUM_ELEMENT(PtTTTMsgTypes, kTTTGameStarted, kSrv2Cli_TTT_GameStarted);
PYTHON_ENUM_ELEMENT(PtTTTMsgTypes, kTTTGameOver, kSrv2Cli_TTT_GameOver);
PYTHON_ENUM_ELEMENT(PtTTTMsgTypes, kTTTMoveMade, kSrv2Cli_TTT_MoveMade);
PYTHON_ENUM_END(m, PtTTTMsgTypes);
}
///////////////////////////////////////////////////////////////////////////////
//
// Game client message subclasses
//
PYTHON_CLASS_DEFINITION(ptTTTGameStartedMsg, pyTTTGameStartedMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptTTTGameStartedMsg, pyTTTGameStartedMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptTTTGameStartedMsg)
PYTHON_NO_INIT_DEFINITION(ptTTTGameStartedMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptTTTGameStartedMsg, yourTurn)
{
PYTHON_RETURN_BOOL(self->fThis->YourTurn());
}
PYTHON_START_METHODS_TABLE(ptTTTGameStartedMsg)
PYTHON_METHOD_NOARGS(ptTTTGameStartedMsg, yourTurn, "Returns true if you are the first player (and therefore it's your turn)"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptTTTGameStartedMsg, pyTTTMsg, "TicTacToe message received when the game is started");
// required functions for PyObject interoperability
PyObject* pyTTTGameStartedMsg::New(pfGameCliMsg* msg)
{
ptTTTGameStartedMsg *newObj = (ptTTTGameStartedMsg*)ptTTTGameStartedMsg_type.tp_new(&ptTTTGameStartedMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_TTT_GameStarted))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptTTTGameStartedMsg, pyTTTGameStartedMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptTTTGameStartedMsg, pyTTTGameStartedMsg)
// Module and method definitions
void pyTTTGameStartedMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptTTTGameStartedMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptTTTGameOverMsg, pyTTTGameOverMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptTTTGameOverMsg, pyTTTGameOverMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptTTTGameOverMsg)
PYTHON_NO_INIT_DEFINITION(ptTTTGameOverMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptTTTGameOverMsg, result)
{
return PyInt_FromLong(self->fThis->Result());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptTTTGameOverMsg, winnerID)
{
return PyLong_FromUnsignedLong(self->fThis->WinnerID());
}
PYTHON_START_METHODS_TABLE(ptTTTGameOverMsg)
PYTHON_METHOD_NOARGS(ptTTTGameOverMsg, result, "Returns the result of the game (see PtTTTGameResult)"),
PYTHON_METHOD_NOARGS(ptTTTGameOverMsg, winnerID, "Returns the winner's ID"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptTTTGameOverMsg, pyTTTMsg, "TicTacToe message received when the game is over");
// required functions for PyObject interoperability
PyObject* pyTTTGameOverMsg::New(pfGameCliMsg* msg)
{
ptTTTGameOverMsg *newObj = (ptTTTGameOverMsg*)ptTTTGameOverMsg_type.tp_new(&ptTTTGameOverMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_TTT_GameOver))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptTTTGameOverMsg, pyTTTGameOverMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptTTTGameOverMsg, pyTTTGameOverMsg)
// Module and method definitions
void pyTTTGameOverMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptTTTGameOverMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptTTTMoveMadeMsg, pyTTTMoveMadeMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptTTTMoveMadeMsg, pyTTTMoveMadeMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptTTTMoveMadeMsg)
PYTHON_NO_INIT_DEFINITION(ptTTTMoveMadeMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptTTTMoveMadeMsg, playerID)
{
return PyLong_FromUnsignedLong(self->fThis->PlayerID());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptTTTMoveMadeMsg, row)
{
return PyInt_FromLong(self->fThis->Row());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptTTTMoveMadeMsg, col)
{
return PyInt_FromLong(self->fThis->Col());
}
PYTHON_START_METHODS_TABLE(ptTTTMoveMadeMsg)
PYTHON_METHOD_NOARGS(ptTTTMoveMadeMsg, playerID, "Returns the the ID of the player that just moved"),
PYTHON_METHOD_NOARGS(ptTTTMoveMadeMsg, row, "Returns the row index of the move (1..3)"),
PYTHON_METHOD_NOARGS(ptTTTMoveMadeMsg, col, "Returns the col index of the move (1..3)"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptTTTMoveMadeMsg, pyTTTMsg, "TicTacToe message received when someone makes a move");
// required functions for PyObject interoperability
PyObject* pyTTTMoveMadeMsg::New(pfGameCliMsg* msg)
{
ptTTTMoveMadeMsg *newObj = (ptTTTMoveMadeMsg*)ptTTTMoveMadeMsg_type.tp_new(&ptTTTMoveMadeMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_TTT_MoveMade))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptTTTMoveMadeMsg, pyTTTMoveMadeMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptTTTMoveMadeMsg, pyTTTMoveMadeMsg)
// Module and method definitions
void pyTTTMoveMadeMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptTTTMoveMadeMsg);
PYTHON_CLASS_IMPORT_END(m);
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyTTTMsg.h"
#include "../../pyEnum.h"
#include <python.h>
///////////////////////////////////////////////////////////////////////////////
//
// Base TTT msg class
//
PYTHON_CLASS_DEFINITION(ptTTTMsg, pyTTTMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptTTTMsg, pyTTTMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptTTTMsg)
PYTHON_NO_INIT_DEFINITION(ptTTTMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptTTTMsg, getTTTMsgType)
{
return PyInt_FromLong(self->fThis->GetTTTMsgType());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptTTTMsg, upcastToFinalTTTMsg)
{
return self->fThis->UpcastToFinalTTTMsg();
}
PYTHON_START_METHODS_TABLE(ptTTTMsg)
PYTHON_METHOD_NOARGS(ptTTTMsg, getTTTMsgType, "Returns the type of the TTT message (see PtTTTMsgTypes)"),
PYTHON_METHOD_NOARGS(ptTTTMsg, upcastToFinalTTTMsg, "Returns this message as the TTT msg it is"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptTTTMsg, pyGameCliMsg, "Base class for TicTacToe game messages");
PYTHON_EXPOSE_TYPE_DEFINITION(ptTTTMsg, pyTTTMsg);
// required functions for PyObject interoperability
PyObject* pyTTTMsg::New(pfGameCliMsg* msg)
{
ptTTTMsg *newObj = (ptTTTMsg*)ptTTTMsg_type.tp_new(&ptTTTMsg_type, NULL, NULL);
if (msg && (msg->gameCli->GetGameTypeId() == kGameTypeId_TicTacToe))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptTTTMsg, pyTTTMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptTTTMsg, pyTTTMsg)
// Module and method definitions
void pyTTTMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptTTTMsg);
PYTHON_CLASS_IMPORT_END(m);
}
void pyTTTMsg::AddPlasmaConstantsClasses(PyObject* m)
{
PYTHON_ENUM_START(PtTTTMsgTypes);
PYTHON_ENUM_ELEMENT(PtTTTMsgTypes, kTTTGameStarted, kSrv2Cli_TTT_GameStarted);
PYTHON_ENUM_ELEMENT(PtTTTMsgTypes, kTTTGameOver, kSrv2Cli_TTT_GameOver);
PYTHON_ENUM_ELEMENT(PtTTTMsgTypes, kTTTMoveMade, kSrv2Cli_TTT_MoveMade);
PYTHON_ENUM_END(m, PtTTTMsgTypes);
}
///////////////////////////////////////////////////////////////////////////////
//
// Game client message subclasses
//
PYTHON_CLASS_DEFINITION(ptTTTGameStartedMsg, pyTTTGameStartedMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptTTTGameStartedMsg, pyTTTGameStartedMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptTTTGameStartedMsg)
PYTHON_NO_INIT_DEFINITION(ptTTTGameStartedMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptTTTGameStartedMsg, yourTurn)
{
PYTHON_RETURN_BOOL(self->fThis->YourTurn());
}
PYTHON_START_METHODS_TABLE(ptTTTGameStartedMsg)
PYTHON_METHOD_NOARGS(ptTTTGameStartedMsg, yourTurn, "Returns true if you are the first player (and therefore it's your turn)"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptTTTGameStartedMsg, pyTTTMsg, "TicTacToe message received when the game is started");
// required functions for PyObject interoperability
PyObject* pyTTTGameStartedMsg::New(pfGameCliMsg* msg)
{
ptTTTGameStartedMsg *newObj = (ptTTTGameStartedMsg*)ptTTTGameStartedMsg_type.tp_new(&ptTTTGameStartedMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_TTT_GameStarted))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptTTTGameStartedMsg, pyTTTGameStartedMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptTTTGameStartedMsg, pyTTTGameStartedMsg)
// Module and method definitions
void pyTTTGameStartedMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptTTTGameStartedMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptTTTGameOverMsg, pyTTTGameOverMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptTTTGameOverMsg, pyTTTGameOverMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptTTTGameOverMsg)
PYTHON_NO_INIT_DEFINITION(ptTTTGameOverMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptTTTGameOverMsg, result)
{
return PyInt_FromLong(self->fThis->Result());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptTTTGameOverMsg, winnerID)
{
return PyLong_FromUnsignedLong(self->fThis->WinnerID());
}
PYTHON_START_METHODS_TABLE(ptTTTGameOverMsg)
PYTHON_METHOD_NOARGS(ptTTTGameOverMsg, result, "Returns the result of the game (see PtTTTGameResult)"),
PYTHON_METHOD_NOARGS(ptTTTGameOverMsg, winnerID, "Returns the winner's ID"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptTTTGameOverMsg, pyTTTMsg, "TicTacToe message received when the game is over");
// required functions for PyObject interoperability
PyObject* pyTTTGameOverMsg::New(pfGameCliMsg* msg)
{
ptTTTGameOverMsg *newObj = (ptTTTGameOverMsg*)ptTTTGameOverMsg_type.tp_new(&ptTTTGameOverMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_TTT_GameOver))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptTTTGameOverMsg, pyTTTGameOverMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptTTTGameOverMsg, pyTTTGameOverMsg)
// Module and method definitions
void pyTTTGameOverMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptTTTGameOverMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptTTTMoveMadeMsg, pyTTTMoveMadeMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptTTTMoveMadeMsg, pyTTTMoveMadeMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptTTTMoveMadeMsg)
PYTHON_NO_INIT_DEFINITION(ptTTTMoveMadeMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptTTTMoveMadeMsg, playerID)
{
return PyLong_FromUnsignedLong(self->fThis->PlayerID());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptTTTMoveMadeMsg, row)
{
return PyInt_FromLong(self->fThis->Row());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptTTTMoveMadeMsg, col)
{
return PyInt_FromLong(self->fThis->Col());
}
PYTHON_START_METHODS_TABLE(ptTTTMoveMadeMsg)
PYTHON_METHOD_NOARGS(ptTTTMoveMadeMsg, playerID, "Returns the the ID of the player that just moved"),
PYTHON_METHOD_NOARGS(ptTTTMoveMadeMsg, row, "Returns the row index of the move (1..3)"),
PYTHON_METHOD_NOARGS(ptTTTMoveMadeMsg, col, "Returns the col index of the move (1..3)"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptTTTMoveMadeMsg, pyTTTMsg, "TicTacToe message received when someone makes a move");
// required functions for PyObject interoperability
PyObject* pyTTTMoveMadeMsg::New(pfGameCliMsg* msg)
{
ptTTTMoveMadeMsg *newObj = (ptTTTMoveMadeMsg*)ptTTTMoveMadeMsg_type.tp_new(&ptTTTMoveMadeMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_TTT_MoveMade))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptTTTMoveMadeMsg, pyTTTMoveMadeMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptTTTMoveMadeMsg, pyTTTMoveMadeMsg)
// Module and method definitions
void pyTTTMoveMadeMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptTTTMoveMadeMsg);
PYTHON_CLASS_IMPORT_END(m);
}

View File

@ -1,99 +1,99 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyVarSyncGame.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base VarSync game client class
//
const unsigned kGameId = 255; // random number that should be high enough to avoid collisions with other global games
pyVarSyncGame::pyVarSyncGame(): pyGameCli() {}
pyVarSyncGame::pyVarSyncGame(pfGameCli* client): pyGameCli(client)
{
if (client && (client->GetGameTypeId() != kGameTypeId_VarSync))
gameClient = nil; // wrong type, just clear it out
}
bool pyVarSyncGame::IsVarSyncGame(std::wstring guid)
{
Uuid gameUuid(guid.c_str());
return gameUuid == kGameTypeId_VarSync;
}
void pyVarSyncGame::JoinCommonVarSyncGame(pyKey& callbackKey)
{
// NOTE: We don't let the player specify the game ID, because there should only be one of these in an age, ever
VarSync_CreateParam init;
pfGameMgr::GetInstance()->JoinCommonGame(callbackKey.getKey(), kGameTypeId_VarSync, kGameId, sizeof(init), &init);
}
void pyVarSyncGame::SetStringVar(unsigned long id, std::wstring val)
{
if (gameClient)
{
pfGmVarSync* vsync = pfGmVarSync::ConvertNoRef(gameClient);
vsync->SetStringVar(id, val.c_str());
}
}
void pyVarSyncGame::SetNumericVar(unsigned long id, double val)
{
if (gameClient)
{
pfGmVarSync* vsync = pfGmVarSync::ConvertNoRef(gameClient);
vsync->SetNumericVar(id, val);
}
}
void pyVarSyncGame::RequestAllVars()
{
if (gameClient)
{
pfGmVarSync* vsync = pfGmVarSync::ConvertNoRef(gameClient);
vsync->RequestAllVars();
}
}
void pyVarSyncGame::CreateStringVar(std::wstring name, std::wstring val)
{
if (gameClient)
{
pfGmVarSync* vsync = pfGmVarSync::ConvertNoRef(gameClient);
vsync->CreateStringVar(name.c_str(), val.c_str());
}
}
void pyVarSyncGame::CreateNumericVar(std::wstring name, double val)
{
if (gameClient)
{
pfGmVarSync* vsync = pfGmVarSync::ConvertNoRef(gameClient);
vsync->CreateNumericVar(name.c_str(), val);
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyVarSyncGame.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base VarSync game client class
//
const unsigned kGameId = 255; // random number that should be high enough to avoid collisions with other global games
pyVarSyncGame::pyVarSyncGame(): pyGameCli() {}
pyVarSyncGame::pyVarSyncGame(pfGameCli* client): pyGameCli(client)
{
if (client && (client->GetGameTypeId() != kGameTypeId_VarSync))
gameClient = nil; // wrong type, just clear it out
}
bool pyVarSyncGame::IsVarSyncGame(std::wstring guid)
{
Uuid gameUuid(guid.c_str());
return gameUuid == kGameTypeId_VarSync;
}
void pyVarSyncGame::JoinCommonVarSyncGame(pyKey& callbackKey)
{
// NOTE: We don't let the player specify the game ID, because there should only be one of these in an age, ever
VarSync_CreateParam init;
pfGameMgr::GetInstance()->JoinCommonGame(callbackKey.getKey(), kGameTypeId_VarSync, kGameId, sizeof(init), &init);
}
void pyVarSyncGame::SetStringVar(unsigned long id, std::wstring val)
{
if (gameClient)
{
pfGmVarSync* vsync = pfGmVarSync::ConvertNoRef(gameClient);
vsync->SetStringVar(id, val.c_str());
}
}
void pyVarSyncGame::SetNumericVar(unsigned long id, double val)
{
if (gameClient)
{
pfGmVarSync* vsync = pfGmVarSync::ConvertNoRef(gameClient);
vsync->SetNumericVar(id, val);
}
}
void pyVarSyncGame::RequestAllVars()
{
if (gameClient)
{
pfGmVarSync* vsync = pfGmVarSync::ConvertNoRef(gameClient);
vsync->RequestAllVars();
}
}
void pyVarSyncGame::CreateStringVar(std::wstring name, std::wstring val)
{
if (gameClient)
{
pfGmVarSync* vsync = pfGmVarSync::ConvertNoRef(gameClient);
vsync->CreateStringVar(name.c_str(), val.c_str());
}
}
void pyVarSyncGame::CreateNumericVar(std::wstring name, double val)
{
if (gameClient)
{
pfGmVarSync* vsync = pfGmVarSync::ConvertNoRef(gameClient);
vsync->CreateNumericVar(name.c_str(), val);
}
}

View File

@ -1,69 +1,69 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyVarSyncGame_h
#define pyVarSyncGame_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: pyVarSyncGame
//
// PURPOSE: Class wrapper for the VarSync game client
//
#include "pfGameMgr/pfGameMgr.h"
#include <python.h>
#include "../../pyGlueHelpers.h"
#include "../pyGameCli.h"
#include "../../pyKey.h"
class pyVarSyncGame : public pyGameCli
{
protected:
pyVarSyncGame();
pyVarSyncGame(pfGameCli* client);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptVarSyncGame);
static PyObject* New(pfGameCli* client);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyVarSyncGame object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyVarSyncGame); // converts a PyObject to a pyVarSyncGame (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaMethods(std::vector<PyMethodDef>& methods);
static bool IsVarSyncGame(std::wstring guid);
static void JoinCommonVarSyncGame(pyKey& callbackKey);
void SetStringVar(unsigned long id, std::wstring val);
void SetNumericVar(unsigned long id, double val);
void RequestAllVars();
void CreateStringVar(std::wstring name, std::wstring val);
void CreateNumericVar(std::wstring name, double val);
};
#endif // pyVarSyncGame_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyVarSyncGame_h
#define pyVarSyncGame_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: pyVarSyncGame
//
// PURPOSE: Class wrapper for the VarSync game client
//
#include "pfGameMgr/pfGameMgr.h"
#include <python.h>
#include "../../pyGlueHelpers.h"
#include "../pyGameCli.h"
#include "../../pyKey.h"
class pyVarSyncGame : public pyGameCli
{
protected:
pyVarSyncGame();
pyVarSyncGame(pfGameCli* client);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptVarSyncGame);
static PyObject* New(pfGameCli* client);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyVarSyncGame object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyVarSyncGame); // converts a PyObject to a pyVarSyncGame (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaMethods(std::vector<PyMethodDef>& methods);
static bool IsVarSyncGame(std::wstring guid);
static void JoinCommonVarSyncGame(pyKey& callbackKey);
void SetStringVar(unsigned long id, std::wstring val);
void SetNumericVar(unsigned long id, double val);
void RequestAllVars();
void CreateStringVar(std::wstring name, std::wstring val);
void CreateNumericVar(std::wstring name, double val);
};
#endif // pyVarSyncGame_h

View File

@ -1,308 +1,308 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyVarSyncGame.h"
#include <python.h>
#include "../../pyEnum.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base VarSync game client class
//
PYTHON_CLASS_DEFINITION(ptVarSyncGame, pyVarSyncGame);
PYTHON_DEFAULT_NEW_DEFINITION(ptVarSyncGame, pyVarSyncGame)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptVarSyncGame)
PYTHON_NO_INIT_DEFINITION(ptVarSyncGame)
PYTHON_GLOBAL_METHOD_DEFINITION(PtIsVarSyncGame, args, "Params: typeID\nReturns true if the specifed typeID (guid as a string) is a VarSync game")
{
PyObject* textObj;
if (!PyArg_ParseTuple(args, "O", &textObj))
{
PyErr_SetString(PyExc_TypeError, "PtIsVarSyncGame expects a unicode string");
PYTHON_RETURN_ERROR;
}
if (PyUnicode_Check(textObj))
{
int strLen = PyUnicode_GetSize(textObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)textObj, text, strLen);
text[strLen] = L'\0';
bool retVal = pyVarSyncGame::IsVarSyncGame(text);
delete [] text;
PYTHON_RETURN_BOOL(retVal);
}
else if (PyString_Check(textObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(textObj);
wchar_t* wText = hsStringToWString(text);
bool retVal = pyVarSyncGame::IsVarSyncGame(wText);
delete [] wText;
PYTHON_RETURN_BOOL(retVal);
}
else
{
PyErr_SetString(PyExc_TypeError, "PtIsVarSyncGame expects a unicode string");
PYTHON_RETURN_ERROR;
}
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtJoinCommonVarSyncGame, args, "Params: callbackKey\nJoins the common VarSync game. If one doesn't exist, it creates it")
{
PyObject* callbackObj = NULL;
if (!PyArg_ParseTuple(args, "O", &callbackObj))
{
PyErr_SetString(PyExc_TypeError, "PtJoinCommonVarSyncGame expects a ptKey");
PYTHON_RETURN_ERROR;
}
if (!pyKey::Check(callbackObj))
{
PyErr_SetString(PyExc_TypeError, "PtJoinCommonVarSyncGame expects a ptKey");
PYTHON_RETURN_ERROR;
}
pyKey* key = pyKey::ConvertFrom(callbackObj);
pyVarSyncGame::JoinCommonVarSyncGame(*key);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptVarSyncGame, setStringVar, args)
{
unsigned long id;
PyObject* valueObj = NULL;
if (!PyArg_ParseTuple(args, "kO", &id, &valueObj))
{
PyErr_SetString(PyExc_TypeError, "setStringVar expects an unsigned long and a string");
PYTHON_RETURN_ERROR;
}
if (PyUnicode_Check(valueObj))
{
int strLen = PyUnicode_GetSize(valueObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)valueObj, text, strLen);
text[strLen] = L'\0';
self->fThis->SetStringVar(id, text);
delete [] text;
PYTHON_RETURN_NONE;
}
else if (PyString_Check(valueObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(valueObj);
wchar_t* wText = hsStringToWString(text);
self->fThis->SetStringVar(id, wText);
delete [] wText;
PYTHON_RETURN_NONE;
}
else
{
PyErr_SetString(PyExc_TypeError, "setStringVar expects an unsigned long and a string");
PYTHON_RETURN_ERROR;
}
}
PYTHON_METHOD_DEFINITION(ptVarSyncGame, setNumericVar, args)
{
unsigned long id;
PyObject* valueObj = NULL;
if (!PyArg_ParseTuple(args, "kO", &id, &valueObj))
{
PyErr_SetString(PyExc_TypeError, "setNumericVar expects an unsigned long and a number");
PYTHON_RETURN_ERROR;
}
double val = 0;
if (PyFloat_Check(valueObj))
val = PyFloat_AsDouble(valueObj);
else if (PyInt_Check(valueObj))
val = (double)PyInt_AsLong(valueObj);
else if (PyLong_Check(valueObj))
val = PyLong_AsDouble(valueObj);
else
{
PyErr_SetString(PyExc_TypeError, "setNumericVar expects an unsigned long and a number");
PYTHON_RETURN_ERROR;
}
self->fThis->SetNumericVar(id, val);
PYTHON_RETURN_NONE;
}
PYTHON_BASIC_METHOD_DEFINITION(ptVarSyncGame, requestAllVars, RequestAllVars)
PYTHON_METHOD_DEFINITION(ptVarSyncGame, createStringVar, args)
{
PyObject* varNameObj = NULL;
PyObject* valueObj = NULL;
if (!PyArg_ParseTuple(args, "OO", &varNameObj, &valueObj))
{
PyErr_SetString(PyExc_TypeError, "createStringVar expects two strings");
PYTHON_RETURN_ERROR;
}
std::wstring varName = L"";
if (PyUnicode_Check(varNameObj))
{
int strLen = PyUnicode_GetSize(varNameObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)varNameObj, text, strLen);
text[strLen] = L'\0';
varName = text;
delete [] text;
}
else if (PyString_Check(varNameObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(varNameObj);
wchar_t* wText = hsStringToWString(text);
varName = wText;
delete [] wText;
}
else
{
PyErr_SetString(PyExc_TypeError, "createStringVar expects two strings");
PYTHON_RETURN_ERROR;
}
std::wstring val = L"";
if (PyUnicode_Check(valueObj))
{
int strLen = PyUnicode_GetSize(valueObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)valueObj, text, strLen);
text[strLen] = L'\0';
val = text;
delete [] text;
}
else if (PyString_Check(valueObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(valueObj);
wchar_t* wText = hsStringToWString(text);
val = wText;
delete [] wText;
}
else
{
PyErr_SetString(PyExc_TypeError, "createStringVar expects two strings");
PYTHON_RETURN_ERROR;
}
self->fThis->CreateStringVar(varName, val);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptVarSyncGame, createNumericVar, args)
{
PyObject* varNameObj = NULL;
PyObject* valueObj = NULL;
if (!PyArg_ParseTuple(args, "OO", &varNameObj, &valueObj))
{
PyErr_SetString(PyExc_TypeError, "createNumericVar expects a string and a number");
PYTHON_RETURN_ERROR;
}
std::wstring varName = L"";
if (PyUnicode_Check(varNameObj))
{
int strLen = PyUnicode_GetSize(varNameObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)varNameObj, text, strLen);
text[strLen] = L'\0';
varName = text;
delete [] text;
}
else if (PyString_Check(varNameObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(varNameObj);
wchar_t* wText = hsStringToWString(text);
varName = wText;
delete [] wText;
}
else
{
PyErr_SetString(PyExc_TypeError, "createNumericVar expects a string and a number");
PYTHON_RETURN_ERROR;
}
double val = 0;
if (PyFloat_Check(valueObj))
val = PyFloat_AsDouble(valueObj);
else if (PyInt_Check(valueObj))
val = (double)PyInt_AsLong(valueObj);
else if (PyLong_Check(valueObj))
val = PyLong_AsDouble(valueObj);
else
{
PyErr_SetString(PyExc_TypeError, "createNumericVar expects a string and a number");
PYTHON_RETURN_ERROR;
}
self->fThis->CreateNumericVar(varName, val);
PYTHON_RETURN_NONE;
}
PYTHON_START_METHODS_TABLE(ptVarSyncGame)
PYTHON_METHOD(ptVarSyncGame, setStringVar, "Params: varID, value\nAttempts to set a string variable to the specified string (clipped to 255 chars)"),
PYTHON_METHOD(ptVarSyncGame, setNumericVar, "Params: varID, value\nAttempts to set a numeric variable to the specified number (clipped to double)"),
PYTHON_BASIC_METHOD(ptVarSyncGame, requestAllVars, "Requests all the vars the server knows about"),
PYTHON_METHOD(ptVarSyncGame, createStringVar, "Params: varName, value\nAttempts to create a new string variable and set it to the specified string (clipped to 255 chars)"),
PYTHON_METHOD(ptVarSyncGame, createNumericVar, "Params: varName, value\nAttempts to create a new numeric variable and set it to the specified number (clipped to double)"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptVarSyncGame, pyGameCli, "Game client for the VarSync game");
// required functions for PyObject interoperability
PyObject* pyVarSyncGame::New(pfGameCli* client)
{
ptVarSyncGame *newObj = (ptVarSyncGame*)ptVarSyncGame_type.tp_new(&ptVarSyncGame_type, NULL, NULL);
if (client && (client->GetGameTypeId() == kGameTypeId_VarSync))
newObj->fThis->gameClient = client;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptVarSyncGame, pyVarSyncGame)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptVarSyncGame, pyVarSyncGame)
// Module and method definitions
void pyVarSyncGame::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptVarSyncGame);
PYTHON_CLASS_IMPORT_END(m);
}
void pyVarSyncGame::AddPlasmaMethods(std::vector<PyMethodDef>& methods)
{
PYTHON_GLOBAL_METHOD(methods, PtIsVarSyncGame);
PYTHON_GLOBAL_METHOD(methods, PtJoinCommonVarSyncGame);
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyVarSyncGame.h"
#include <python.h>
#include "../../pyEnum.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base VarSync game client class
//
PYTHON_CLASS_DEFINITION(ptVarSyncGame, pyVarSyncGame);
PYTHON_DEFAULT_NEW_DEFINITION(ptVarSyncGame, pyVarSyncGame)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptVarSyncGame)
PYTHON_NO_INIT_DEFINITION(ptVarSyncGame)
PYTHON_GLOBAL_METHOD_DEFINITION(PtIsVarSyncGame, args, "Params: typeID\nReturns true if the specifed typeID (guid as a string) is a VarSync game")
{
PyObject* textObj;
if (!PyArg_ParseTuple(args, "O", &textObj))
{
PyErr_SetString(PyExc_TypeError, "PtIsVarSyncGame expects a unicode string");
PYTHON_RETURN_ERROR;
}
if (PyUnicode_Check(textObj))
{
int strLen = PyUnicode_GetSize(textObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)textObj, text, strLen);
text[strLen] = L'\0';
bool retVal = pyVarSyncGame::IsVarSyncGame(text);
delete [] text;
PYTHON_RETURN_BOOL(retVal);
}
else if (PyString_Check(textObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(textObj);
wchar_t* wText = hsStringToWString(text);
bool retVal = pyVarSyncGame::IsVarSyncGame(wText);
delete [] wText;
PYTHON_RETURN_BOOL(retVal);
}
else
{
PyErr_SetString(PyExc_TypeError, "PtIsVarSyncGame expects a unicode string");
PYTHON_RETURN_ERROR;
}
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtJoinCommonVarSyncGame, args, "Params: callbackKey\nJoins the common VarSync game. If one doesn't exist, it creates it")
{
PyObject* callbackObj = NULL;
if (!PyArg_ParseTuple(args, "O", &callbackObj))
{
PyErr_SetString(PyExc_TypeError, "PtJoinCommonVarSyncGame expects a ptKey");
PYTHON_RETURN_ERROR;
}
if (!pyKey::Check(callbackObj))
{
PyErr_SetString(PyExc_TypeError, "PtJoinCommonVarSyncGame expects a ptKey");
PYTHON_RETURN_ERROR;
}
pyKey* key = pyKey::ConvertFrom(callbackObj);
pyVarSyncGame::JoinCommonVarSyncGame(*key);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptVarSyncGame, setStringVar, args)
{
unsigned long id;
PyObject* valueObj = NULL;
if (!PyArg_ParseTuple(args, "kO", &id, &valueObj))
{
PyErr_SetString(PyExc_TypeError, "setStringVar expects an unsigned long and a string");
PYTHON_RETURN_ERROR;
}
if (PyUnicode_Check(valueObj))
{
int strLen = PyUnicode_GetSize(valueObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)valueObj, text, strLen);
text[strLen] = L'\0';
self->fThis->SetStringVar(id, text);
delete [] text;
PYTHON_RETURN_NONE;
}
else if (PyString_Check(valueObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(valueObj);
wchar_t* wText = hsStringToWString(text);
self->fThis->SetStringVar(id, wText);
delete [] wText;
PYTHON_RETURN_NONE;
}
else
{
PyErr_SetString(PyExc_TypeError, "setStringVar expects an unsigned long and a string");
PYTHON_RETURN_ERROR;
}
}
PYTHON_METHOD_DEFINITION(ptVarSyncGame, setNumericVar, args)
{
unsigned long id;
PyObject* valueObj = NULL;
if (!PyArg_ParseTuple(args, "kO", &id, &valueObj))
{
PyErr_SetString(PyExc_TypeError, "setNumericVar expects an unsigned long and a number");
PYTHON_RETURN_ERROR;
}
double val = 0;
if (PyFloat_Check(valueObj))
val = PyFloat_AsDouble(valueObj);
else if (PyInt_Check(valueObj))
val = (double)PyInt_AsLong(valueObj);
else if (PyLong_Check(valueObj))
val = PyLong_AsDouble(valueObj);
else
{
PyErr_SetString(PyExc_TypeError, "setNumericVar expects an unsigned long and a number");
PYTHON_RETURN_ERROR;
}
self->fThis->SetNumericVar(id, val);
PYTHON_RETURN_NONE;
}
PYTHON_BASIC_METHOD_DEFINITION(ptVarSyncGame, requestAllVars, RequestAllVars)
PYTHON_METHOD_DEFINITION(ptVarSyncGame, createStringVar, args)
{
PyObject* varNameObj = NULL;
PyObject* valueObj = NULL;
if (!PyArg_ParseTuple(args, "OO", &varNameObj, &valueObj))
{
PyErr_SetString(PyExc_TypeError, "createStringVar expects two strings");
PYTHON_RETURN_ERROR;
}
std::wstring varName = L"";
if (PyUnicode_Check(varNameObj))
{
int strLen = PyUnicode_GetSize(varNameObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)varNameObj, text, strLen);
text[strLen] = L'\0';
varName = text;
delete [] text;
}
else if (PyString_Check(varNameObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(varNameObj);
wchar_t* wText = hsStringToWString(text);
varName = wText;
delete [] wText;
}
else
{
PyErr_SetString(PyExc_TypeError, "createStringVar expects two strings");
PYTHON_RETURN_ERROR;
}
std::wstring val = L"";
if (PyUnicode_Check(valueObj))
{
int strLen = PyUnicode_GetSize(valueObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)valueObj, text, strLen);
text[strLen] = L'\0';
val = text;
delete [] text;
}
else if (PyString_Check(valueObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(valueObj);
wchar_t* wText = hsStringToWString(text);
val = wText;
delete [] wText;
}
else
{
PyErr_SetString(PyExc_TypeError, "createStringVar expects two strings");
PYTHON_RETURN_ERROR;
}
self->fThis->CreateStringVar(varName, val);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptVarSyncGame, createNumericVar, args)
{
PyObject* varNameObj = NULL;
PyObject* valueObj = NULL;
if (!PyArg_ParseTuple(args, "OO", &varNameObj, &valueObj))
{
PyErr_SetString(PyExc_TypeError, "createNumericVar expects a string and a number");
PYTHON_RETURN_ERROR;
}
std::wstring varName = L"";
if (PyUnicode_Check(varNameObj))
{
int strLen = PyUnicode_GetSize(varNameObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)varNameObj, text, strLen);
text[strLen] = L'\0';
varName = text;
delete [] text;
}
else if (PyString_Check(varNameObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(varNameObj);
wchar_t* wText = hsStringToWString(text);
varName = wText;
delete [] wText;
}
else
{
PyErr_SetString(PyExc_TypeError, "createNumericVar expects a string and a number");
PYTHON_RETURN_ERROR;
}
double val = 0;
if (PyFloat_Check(valueObj))
val = PyFloat_AsDouble(valueObj);
else if (PyInt_Check(valueObj))
val = (double)PyInt_AsLong(valueObj);
else if (PyLong_Check(valueObj))
val = PyLong_AsDouble(valueObj);
else
{
PyErr_SetString(PyExc_TypeError, "createNumericVar expects a string and a number");
PYTHON_RETURN_ERROR;
}
self->fThis->CreateNumericVar(varName, val);
PYTHON_RETURN_NONE;
}
PYTHON_START_METHODS_TABLE(ptVarSyncGame)
PYTHON_METHOD(ptVarSyncGame, setStringVar, "Params: varID, value\nAttempts to set a string variable to the specified string (clipped to 255 chars)"),
PYTHON_METHOD(ptVarSyncGame, setNumericVar, "Params: varID, value\nAttempts to set a numeric variable to the specified number (clipped to double)"),
PYTHON_BASIC_METHOD(ptVarSyncGame, requestAllVars, "Requests all the vars the server knows about"),
PYTHON_METHOD(ptVarSyncGame, createStringVar, "Params: varName, value\nAttempts to create a new string variable and set it to the specified string (clipped to 255 chars)"),
PYTHON_METHOD(ptVarSyncGame, createNumericVar, "Params: varName, value\nAttempts to create a new numeric variable and set it to the specified number (clipped to double)"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptVarSyncGame, pyGameCli, "Game client for the VarSync game");
// required functions for PyObject interoperability
PyObject* pyVarSyncGame::New(pfGameCli* client)
{
ptVarSyncGame *newObj = (ptVarSyncGame*)ptVarSyncGame_type.tp_new(&ptVarSyncGame_type, NULL, NULL);
if (client && (client->GetGameTypeId() == kGameTypeId_VarSync))
newObj->fThis->gameClient = client;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptVarSyncGame, pyVarSyncGame)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptVarSyncGame, pyVarSyncGame)
// Module and method definitions
void pyVarSyncGame::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptVarSyncGame);
PYTHON_CLASS_IMPORT_END(m);
}
void pyVarSyncGame::AddPlasmaMethods(std::vector<PyMethodDef>& methods)
{
PYTHON_GLOBAL_METHOD(methods, PtIsVarSyncGame);
PYTHON_GLOBAL_METHOD(methods, PtJoinCommonVarSyncGame);
}

View File

@ -1,217 +1,217 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyVarSyncMsg.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base VarSync msg class
//
pyVarSyncMsg::pyVarSyncMsg(): pyGameCliMsg() {}
pyVarSyncMsg::pyVarSyncMsg(pfGameCliMsg* msg): pyGameCliMsg(msg)
{
if (message && (message->gameCli->GetGameTypeId() != kGameTypeId_VarSync))
message = nil; // wrong type, just clear it out
}
int pyVarSyncMsg::GetVarSyncMsgType() const
{
if (message)
return message->netMsg->messageId;
return -1;
}
PyObject* pyVarSyncMsg::UpcastToFinalVarSyncMsg() const
{
if (!message)
PYTHON_RETURN_NONE;
switch (message->netMsg->messageId)
{
case kSrv2Cli_VarSync_StringVarChanged:
return pyVarSyncStringVarChangedMsg::New(message);
case kSrv2Cli_VarSync_NumericVarChanged:
return pyVarSyncNumericVarChangedMsg::New(message);
case kSrv2Cli_VarSync_AllVarsSent:
return pyVarSyncAllVarsSentMsg::New(message);
case kSrv2Cli_VarSync_StringVarCreated:
return pyVarSyncStringVarCreatedMsg::New(message);
case kSrv2Cli_VarSync_NumericVarCreated:
return pyVarSyncNumericVarCreatedMsg::New(message);
default:
PYTHON_RETURN_NONE;
}
}
///////////////////////////////////////////////////////////////////////////////
//
// The different messages we can receive
//
pyVarSyncStringVarChangedMsg::pyVarSyncStringVarChangedMsg(): pyVarSyncMsg() {}
pyVarSyncStringVarChangedMsg::pyVarSyncStringVarChangedMsg(pfGameCliMsg* msg): pyVarSyncMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_VarSync_StringVarChanged))
message = nil; // wrong type, just clear it out
}
unsigned long pyVarSyncStringVarChangedMsg::ID() const
{
if (message)
{
const Srv2Cli_VarSync_StringVarChanged* gmMsg = (const Srv2Cli_VarSync_StringVarChanged*)message->netMsg;
return gmMsg->varID;
}
return 0;
}
std::wstring pyVarSyncStringVarChangedMsg::Value() const
{
if (message)
{
const Srv2Cli_VarSync_StringVarChanged* gmMsg = (const Srv2Cli_VarSync_StringVarChanged*)message->netMsg;
return gmMsg->varValue;
}
return L"";
}
///////////////////////////////////////////////////////////////////////////////
pyVarSyncNumericVarChangedMsg::pyVarSyncNumericVarChangedMsg(): pyVarSyncMsg() {}
pyVarSyncNumericVarChangedMsg::pyVarSyncNumericVarChangedMsg(pfGameCliMsg* msg): pyVarSyncMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_VarSync_NumericVarChanged))
message = nil; // wrong type, just clear it out
}
unsigned long pyVarSyncNumericVarChangedMsg::ID() const
{
if (message)
{
const Srv2Cli_VarSync_NumericVarChanged* gmMsg = (const Srv2Cli_VarSync_NumericVarChanged*)message->netMsg;
return gmMsg->varID;
}
return 0;
}
double pyVarSyncNumericVarChangedMsg::Value() const
{
if (message)
{
const Srv2Cli_VarSync_NumericVarChanged* gmMsg = (const Srv2Cli_VarSync_NumericVarChanged*)message->netMsg;
return gmMsg->varValue;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
pyVarSyncAllVarsSentMsg::pyVarSyncAllVarsSentMsg(): pyVarSyncMsg() {}
pyVarSyncAllVarsSentMsg::pyVarSyncAllVarsSentMsg(pfGameCliMsg* msg): pyVarSyncMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_VarSync_AllVarsSent))
message = nil; // wrong type, just clear it out
}
///////////////////////////////////////////////////////////////////////////////
pyVarSyncStringVarCreatedMsg::pyVarSyncStringVarCreatedMsg(): pyVarSyncMsg() {}
pyVarSyncStringVarCreatedMsg::pyVarSyncStringVarCreatedMsg(pfGameCliMsg* msg): pyVarSyncMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_VarSync_StringVarCreated))
message = nil; // wrong type, just clear it out
}
std::wstring pyVarSyncStringVarCreatedMsg::Name() const
{
if (message)
{
const Srv2Cli_VarSync_StringVarCreated* gmMsg = (const Srv2Cli_VarSync_StringVarCreated*)message->netMsg;
return gmMsg->varName;
}
return L"";
}
unsigned long pyVarSyncStringVarCreatedMsg::ID() const
{
if (message)
{
const Srv2Cli_VarSync_StringVarCreated* gmMsg = (const Srv2Cli_VarSync_StringVarCreated*)message->netMsg;
return gmMsg->varID;
}
return 0;
}
std::wstring pyVarSyncStringVarCreatedMsg::Value() const
{
if (message)
{
const Srv2Cli_VarSync_StringVarCreated* gmMsg = (const Srv2Cli_VarSync_StringVarCreated*)message->netMsg;
return gmMsg->varValue;
}
return L"";
}
///////////////////////////////////////////////////////////////////////////////
pyVarSyncNumericVarCreatedMsg::pyVarSyncNumericVarCreatedMsg(): pyVarSyncMsg() {}
pyVarSyncNumericVarCreatedMsg::pyVarSyncNumericVarCreatedMsg(pfGameCliMsg* msg): pyVarSyncMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_VarSync_NumericVarCreated))
message = nil; // wrong type, just clear it out
}
std::wstring pyVarSyncNumericVarCreatedMsg::Name() const
{
if (message)
{
const Srv2Cli_VarSync_NumericVarCreated* gmMsg = (const Srv2Cli_VarSync_NumericVarCreated*)message->netMsg;
return gmMsg->varName;
}
return L"";
}
unsigned long pyVarSyncNumericVarCreatedMsg::ID() const
{
if (message)
{
const Srv2Cli_VarSync_NumericVarCreated* gmMsg = (const Srv2Cli_VarSync_NumericVarCreated*)message->netMsg;
return gmMsg->varID;
}
return 0;
}
double pyVarSyncNumericVarCreatedMsg::Value() const
{
if (message)
{
const Srv2Cli_VarSync_NumericVarCreated* gmMsg = (const Srv2Cli_VarSync_NumericVarCreated*)message->netMsg;
return gmMsg->varValue;
}
return 0;
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyVarSyncMsg.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base VarSync msg class
//
pyVarSyncMsg::pyVarSyncMsg(): pyGameCliMsg() {}
pyVarSyncMsg::pyVarSyncMsg(pfGameCliMsg* msg): pyGameCliMsg(msg)
{
if (message && (message->gameCli->GetGameTypeId() != kGameTypeId_VarSync))
message = nil; // wrong type, just clear it out
}
int pyVarSyncMsg::GetVarSyncMsgType() const
{
if (message)
return message->netMsg->messageId;
return -1;
}
PyObject* pyVarSyncMsg::UpcastToFinalVarSyncMsg() const
{
if (!message)
PYTHON_RETURN_NONE;
switch (message->netMsg->messageId)
{
case kSrv2Cli_VarSync_StringVarChanged:
return pyVarSyncStringVarChangedMsg::New(message);
case kSrv2Cli_VarSync_NumericVarChanged:
return pyVarSyncNumericVarChangedMsg::New(message);
case kSrv2Cli_VarSync_AllVarsSent:
return pyVarSyncAllVarsSentMsg::New(message);
case kSrv2Cli_VarSync_StringVarCreated:
return pyVarSyncStringVarCreatedMsg::New(message);
case kSrv2Cli_VarSync_NumericVarCreated:
return pyVarSyncNumericVarCreatedMsg::New(message);
default:
PYTHON_RETURN_NONE;
}
}
///////////////////////////////////////////////////////////////////////////////
//
// The different messages we can receive
//
pyVarSyncStringVarChangedMsg::pyVarSyncStringVarChangedMsg(): pyVarSyncMsg() {}
pyVarSyncStringVarChangedMsg::pyVarSyncStringVarChangedMsg(pfGameCliMsg* msg): pyVarSyncMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_VarSync_StringVarChanged))
message = nil; // wrong type, just clear it out
}
unsigned long pyVarSyncStringVarChangedMsg::ID() const
{
if (message)
{
const Srv2Cli_VarSync_StringVarChanged* gmMsg = (const Srv2Cli_VarSync_StringVarChanged*)message->netMsg;
return gmMsg->varID;
}
return 0;
}
std::wstring pyVarSyncStringVarChangedMsg::Value() const
{
if (message)
{
const Srv2Cli_VarSync_StringVarChanged* gmMsg = (const Srv2Cli_VarSync_StringVarChanged*)message->netMsg;
return gmMsg->varValue;
}
return L"";
}
///////////////////////////////////////////////////////////////////////////////
pyVarSyncNumericVarChangedMsg::pyVarSyncNumericVarChangedMsg(): pyVarSyncMsg() {}
pyVarSyncNumericVarChangedMsg::pyVarSyncNumericVarChangedMsg(pfGameCliMsg* msg): pyVarSyncMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_VarSync_NumericVarChanged))
message = nil; // wrong type, just clear it out
}
unsigned long pyVarSyncNumericVarChangedMsg::ID() const
{
if (message)
{
const Srv2Cli_VarSync_NumericVarChanged* gmMsg = (const Srv2Cli_VarSync_NumericVarChanged*)message->netMsg;
return gmMsg->varID;
}
return 0;
}
double pyVarSyncNumericVarChangedMsg::Value() const
{
if (message)
{
const Srv2Cli_VarSync_NumericVarChanged* gmMsg = (const Srv2Cli_VarSync_NumericVarChanged*)message->netMsg;
return gmMsg->varValue;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
pyVarSyncAllVarsSentMsg::pyVarSyncAllVarsSentMsg(): pyVarSyncMsg() {}
pyVarSyncAllVarsSentMsg::pyVarSyncAllVarsSentMsg(pfGameCliMsg* msg): pyVarSyncMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_VarSync_AllVarsSent))
message = nil; // wrong type, just clear it out
}
///////////////////////////////////////////////////////////////////////////////
pyVarSyncStringVarCreatedMsg::pyVarSyncStringVarCreatedMsg(): pyVarSyncMsg() {}
pyVarSyncStringVarCreatedMsg::pyVarSyncStringVarCreatedMsg(pfGameCliMsg* msg): pyVarSyncMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_VarSync_StringVarCreated))
message = nil; // wrong type, just clear it out
}
std::wstring pyVarSyncStringVarCreatedMsg::Name() const
{
if (message)
{
const Srv2Cli_VarSync_StringVarCreated* gmMsg = (const Srv2Cli_VarSync_StringVarCreated*)message->netMsg;
return gmMsg->varName;
}
return L"";
}
unsigned long pyVarSyncStringVarCreatedMsg::ID() const
{
if (message)
{
const Srv2Cli_VarSync_StringVarCreated* gmMsg = (const Srv2Cli_VarSync_StringVarCreated*)message->netMsg;
return gmMsg->varID;
}
return 0;
}
std::wstring pyVarSyncStringVarCreatedMsg::Value() const
{
if (message)
{
const Srv2Cli_VarSync_StringVarCreated* gmMsg = (const Srv2Cli_VarSync_StringVarCreated*)message->netMsg;
return gmMsg->varValue;
}
return L"";
}
///////////////////////////////////////////////////////////////////////////////
pyVarSyncNumericVarCreatedMsg::pyVarSyncNumericVarCreatedMsg(): pyVarSyncMsg() {}
pyVarSyncNumericVarCreatedMsg::pyVarSyncNumericVarCreatedMsg(pfGameCliMsg* msg): pyVarSyncMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_VarSync_NumericVarCreated))
message = nil; // wrong type, just clear it out
}
std::wstring pyVarSyncNumericVarCreatedMsg::Name() const
{
if (message)
{
const Srv2Cli_VarSync_NumericVarCreated* gmMsg = (const Srv2Cli_VarSync_NumericVarCreated*)message->netMsg;
return gmMsg->varName;
}
return L"";
}
unsigned long pyVarSyncNumericVarCreatedMsg::ID() const
{
if (message)
{
const Srv2Cli_VarSync_NumericVarCreated* gmMsg = (const Srv2Cli_VarSync_NumericVarCreated*)message->netMsg;
return gmMsg->varID;
}
return 0;
}
double pyVarSyncNumericVarCreatedMsg::Value() const
{
if (message)
{
const Srv2Cli_VarSync_NumericVarCreated* gmMsg = (const Srv2Cli_VarSync_NumericVarCreated*)message->netMsg;
return gmMsg->varValue;
}
return 0;
}

View File

@ -1,163 +1,163 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyVarSyncMsg_h
#define pyVarSyncMsg_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: pyVarSyncMsg
//
// PURPOSE: Class wrapper for VarSync game messages
//
#include "pfGameMgr/pfGameMgr.h"
#include <python.h>
#include "../../pyGlueHelpers.h"
#include "../pyGameCliMsg.h"
class pyVarSyncMsg : public pyGameCliMsg
{
protected:
pyVarSyncMsg();
pyVarSyncMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_EXPOSE_TYPE; // so we can subclass
PYTHON_CLASS_NEW_FRIEND(ptVarSyncMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyVarSyncMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyVarSyncMsg); // converts a PyObject to a pyVarSyncMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaConstantsClasses(PyObject* m);
int GetVarSyncMsgType() const;
PyObject* UpcastToFinalVarSyncMsg() const; // returns the VarSync message that this really is
};
///////////////////////////////////////////////////////////////////////////////
class pyVarSyncStringVarChangedMsg : public pyVarSyncMsg
{
protected:
pyVarSyncStringVarChangedMsg();
pyVarSyncStringVarChangedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptVarSyncStringVarChangedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyVarSyncStringVarChangedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyVarSyncStringVarChangedMsg); // converts a PyObject to a pyVarSyncStringVarChangedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
unsigned long ID() const;
std::wstring Value() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyVarSyncNumericVarChangedMsg : public pyVarSyncMsg
{
protected:
pyVarSyncNumericVarChangedMsg();
pyVarSyncNumericVarChangedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptVarSyncNumericVarChangedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyVarSyncNumericVarChangedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyVarSyncNumericVarChangedMsg); // converts a PyObject to a pyVarSyncNumericVarChangedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
unsigned long ID() const;
double Value() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyVarSyncAllVarsSentMsg : public pyVarSyncMsg
{
protected:
pyVarSyncAllVarsSentMsg();
pyVarSyncAllVarsSentMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptVarSyncAllVarsSentMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyVarSyncAllVarsSentMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyVarSyncAllVarsSentMsg); // converts a PyObject to a pyVarSyncAllVarsSentMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
};
///////////////////////////////////////////////////////////////////////////////
class pyVarSyncStringVarCreatedMsg : public pyVarSyncMsg
{
protected:
pyVarSyncStringVarCreatedMsg();
pyVarSyncStringVarCreatedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptVarSyncStringVarCreatedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyVarSyncStringVarCreatedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyVarSyncStringVarCreatedMsg); // converts a PyObject to a pyVarSyncStringVarCreatedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
std::wstring Name() const;
unsigned long ID() const;
std::wstring Value() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyVarSyncNumericVarCreatedMsg : public pyVarSyncMsg
{
protected:
pyVarSyncNumericVarCreatedMsg();
pyVarSyncNumericVarCreatedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptVarSyncNumericVarCreatedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyVarSyncNumericVarCreatedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyVarSyncNumericVarCreatedMsg); // converts a PyObject to a pyVarSyncNumericVarCreatedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
std::wstring Name() const;
unsigned long ID() const;
double Value() const;
};
#endif // pyVarSyncMsg_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyVarSyncMsg_h
#define pyVarSyncMsg_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: pyVarSyncMsg
//
// PURPOSE: Class wrapper for VarSync game messages
//
#include "pfGameMgr/pfGameMgr.h"
#include <python.h>
#include "../../pyGlueHelpers.h"
#include "../pyGameCliMsg.h"
class pyVarSyncMsg : public pyGameCliMsg
{
protected:
pyVarSyncMsg();
pyVarSyncMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_EXPOSE_TYPE; // so we can subclass
PYTHON_CLASS_NEW_FRIEND(ptVarSyncMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyVarSyncMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyVarSyncMsg); // converts a PyObject to a pyVarSyncMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaConstantsClasses(PyObject* m);
int GetVarSyncMsgType() const;
PyObject* UpcastToFinalVarSyncMsg() const; // returns the VarSync message that this really is
};
///////////////////////////////////////////////////////////////////////////////
class pyVarSyncStringVarChangedMsg : public pyVarSyncMsg
{
protected:
pyVarSyncStringVarChangedMsg();
pyVarSyncStringVarChangedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptVarSyncStringVarChangedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyVarSyncStringVarChangedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyVarSyncStringVarChangedMsg); // converts a PyObject to a pyVarSyncStringVarChangedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
unsigned long ID() const;
std::wstring Value() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyVarSyncNumericVarChangedMsg : public pyVarSyncMsg
{
protected:
pyVarSyncNumericVarChangedMsg();
pyVarSyncNumericVarChangedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptVarSyncNumericVarChangedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyVarSyncNumericVarChangedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyVarSyncNumericVarChangedMsg); // converts a PyObject to a pyVarSyncNumericVarChangedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
unsigned long ID() const;
double Value() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyVarSyncAllVarsSentMsg : public pyVarSyncMsg
{
protected:
pyVarSyncAllVarsSentMsg();
pyVarSyncAllVarsSentMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptVarSyncAllVarsSentMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyVarSyncAllVarsSentMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyVarSyncAllVarsSentMsg); // converts a PyObject to a pyVarSyncAllVarsSentMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
};
///////////////////////////////////////////////////////////////////////////////
class pyVarSyncStringVarCreatedMsg : public pyVarSyncMsg
{
protected:
pyVarSyncStringVarCreatedMsg();
pyVarSyncStringVarCreatedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptVarSyncStringVarCreatedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyVarSyncStringVarCreatedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyVarSyncStringVarCreatedMsg); // converts a PyObject to a pyVarSyncStringVarCreatedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
std::wstring Name() const;
unsigned long ID() const;
std::wstring Value() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyVarSyncNumericVarCreatedMsg : public pyVarSyncMsg
{
protected:
pyVarSyncNumericVarCreatedMsg();
pyVarSyncNumericVarCreatedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptVarSyncNumericVarCreatedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyVarSyncNumericVarCreatedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyVarSyncNumericVarCreatedMsg); // converts a PyObject to a pyVarSyncNumericVarCreatedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
std::wstring Name() const;
unsigned long ID() const;
double Value() const;
};
#endif // pyVarSyncMsg_h

View File

@ -1,329 +1,329 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyVarSyncMsg.h"
#include "../../pyEnum.h"
#include <python.h>
///////////////////////////////////////////////////////////////////////////////
//
// Base VarSync msg class
//
PYTHON_CLASS_DEFINITION(ptVarSyncMsg, pyVarSyncMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptVarSyncMsg, pyVarSyncMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptVarSyncMsg)
PYTHON_NO_INIT_DEFINITION(ptVarSyncMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncMsg, getVarSyncMsgType)
{
return PyInt_FromLong(self->fThis->GetVarSyncMsgType());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncMsg, upcastToFinalVarSyncMsg)
{
return self->fThis->UpcastToFinalVarSyncMsg();
}
PYTHON_START_METHODS_TABLE(ptVarSyncMsg)
PYTHON_METHOD_NOARGS(ptVarSyncMsg, getVarSyncMsgType, "Returns the type of the VarSync message (see PtVarSyncMsgTypes)"),
PYTHON_METHOD_NOARGS(ptVarSyncMsg, upcastToFinalVarSyncMsg, "Returns this message as the VarSync msg it is"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptVarSyncMsg, pyGameCliMsg, "Base class for VarSync game messages");
PYTHON_EXPOSE_TYPE_DEFINITION(ptVarSyncMsg, pyVarSyncMsg);
// required functions for PyObject interoperability
PyObject* pyVarSyncMsg::New(pfGameCliMsg* msg)
{
ptVarSyncMsg *newObj = (ptVarSyncMsg*)ptVarSyncMsg_type.tp_new(&ptVarSyncMsg_type, NULL, NULL);
if (msg && (msg->gameCli->GetGameTypeId() == kGameTypeId_VarSync))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptVarSyncMsg, pyVarSyncMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptVarSyncMsg, pyVarSyncMsg)
// Module and method definitions
void pyVarSyncMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptVarSyncMsg);
PYTHON_CLASS_IMPORT_END(m);
}
void pyVarSyncMsg::AddPlasmaConstantsClasses(PyObject* m)
{
PYTHON_ENUM_START(PtVarSyncMsgTypes);
PYTHON_ENUM_ELEMENT(PtVarSyncMsgTypes, kVarSyncStringVarChanged, kSrv2Cli_VarSync_StringVarChanged);
PYTHON_ENUM_ELEMENT(PtVarSyncMsgTypes, kVarSyncNumericVarChanged, kSrv2Cli_VarSync_NumericVarChanged);
PYTHON_ENUM_ELEMENT(PtVarSyncMsgTypes, kVarSyncAllVarsSent, kSrv2Cli_VarSync_AllVarsSent);
PYTHON_ENUM_ELEMENT(PtVarSyncMsgTypes, kVarSyncStringVarCreated, kSrv2Cli_VarSync_StringVarCreated);
PYTHON_ENUM_ELEMENT(PtVarSyncMsgTypes, kVarSyncNumericVarCreated, kSrv2Cli_VarSync_NumericVarCreated);
PYTHON_ENUM_END(m, PtVarSyncMsgTypes);
}
///////////////////////////////////////////////////////////////////////////////
//
// Game client message subclasses
//
PYTHON_CLASS_DEFINITION(ptVarSyncStringVarChangedMsg, pyVarSyncStringVarChangedMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptVarSyncStringVarChangedMsg, pyVarSyncStringVarChangedMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptVarSyncStringVarChangedMsg)
PYTHON_NO_INIT_DEFINITION(ptVarSyncStringVarChangedMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncStringVarChangedMsg, id)
{
return PyLong_FromUnsignedLong(self->fThis->ID());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncStringVarChangedMsg, value)
{
std::wstring retVal = self->fThis->Value();
return PyUnicode_FromWideChar(retVal.c_str(), retVal.size());
}
PYTHON_START_METHODS_TABLE(ptVarSyncStringVarChangedMsg)
PYTHON_METHOD_NOARGS(ptVarSyncStringVarChangedMsg, id, "Returns the id of the var that changed"),
PYTHON_METHOD_NOARGS(ptVarSyncStringVarChangedMsg, value, "Returns the variable's new value"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptVarSyncStringVarChangedMsg, pyVarSyncMsg, "VarSync message received when a string variable's value changes");
// required functions for PyObject interoperability
PyObject* pyVarSyncStringVarChangedMsg::New(pfGameCliMsg* msg)
{
ptVarSyncStringVarChangedMsg *newObj = (ptVarSyncStringVarChangedMsg*)ptVarSyncStringVarChangedMsg_type.tp_new(&ptVarSyncStringVarChangedMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_VarSync_StringVarChanged))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptVarSyncStringVarChangedMsg, pyVarSyncStringVarChangedMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptVarSyncStringVarChangedMsg, pyVarSyncStringVarChangedMsg)
// Module and method definitions
void pyVarSyncStringVarChangedMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptVarSyncStringVarChangedMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptVarSyncNumericVarChangedMsg, pyVarSyncNumericVarChangedMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptVarSyncNumericVarChangedMsg, pyVarSyncNumericVarChangedMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptVarSyncNumericVarChangedMsg)
PYTHON_NO_INIT_DEFINITION(ptVarSyncNumericVarChangedMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncNumericVarChangedMsg, id)
{
return PyLong_FromUnsignedLong(self->fThis->ID());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncNumericVarChangedMsg, value)
{
return PyLong_FromDouble(self->fThis->Value());
}
PYTHON_START_METHODS_TABLE(ptVarSyncNumericVarChangedMsg)
PYTHON_METHOD_NOARGS(ptVarSyncNumericVarChangedMsg, id, "Returns the id of the var that changed"),
PYTHON_METHOD_NOARGS(ptVarSyncNumericVarChangedMsg, value, "Returns the variable's new value"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptVarSyncNumericVarChangedMsg, pyVarSyncMsg, "VarSync message received when a numeric variable's value changes");
// required functions for PyObject interoperability
PyObject* pyVarSyncNumericVarChangedMsg::New(pfGameCliMsg* msg)
{
ptVarSyncNumericVarChangedMsg *newObj = (ptVarSyncNumericVarChangedMsg*)ptVarSyncNumericVarChangedMsg_type.tp_new(&ptVarSyncNumericVarChangedMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_VarSync_NumericVarChanged))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptVarSyncNumericVarChangedMsg, pyVarSyncNumericVarChangedMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptVarSyncNumericVarChangedMsg, pyVarSyncNumericVarChangedMsg)
// Module and method definitions
void pyVarSyncNumericVarChangedMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptVarSyncNumericVarChangedMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptVarSyncAllVarsSentMsg, pyVarSyncAllVarsSentMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptVarSyncAllVarsSentMsg, pyVarSyncAllVarsSentMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptVarSyncAllVarsSentMsg)
PYTHON_NO_INIT_DEFINITION(ptVarSyncAllVarsSentMsg)
PYTHON_START_METHODS_TABLE(ptVarSyncAllVarsSentMsg)
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptVarSyncAllVarsSentMsg, pyVarSyncMsg, "VarSync message received after the last var is sent to you when you join the game, or request a list of vars");
// required functions for PyObject interoperability
PyObject* pyVarSyncAllVarsSentMsg::New(pfGameCliMsg* msg)
{
ptVarSyncAllVarsSentMsg *newObj = (ptVarSyncAllVarsSentMsg*)ptVarSyncAllVarsSentMsg_type.tp_new(&ptVarSyncAllVarsSentMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_VarSync_AllVarsSent))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptVarSyncAllVarsSentMsg, pyVarSyncAllVarsSentMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptVarSyncAllVarsSentMsg, pyVarSyncAllVarsSentMsg)
// Module and method definitions
void pyVarSyncAllVarsSentMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptVarSyncAllVarsSentMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptVarSyncStringVarCreatedMsg, pyVarSyncStringVarCreatedMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptVarSyncStringVarCreatedMsg, pyVarSyncStringVarCreatedMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptVarSyncStringVarCreatedMsg)
PYTHON_NO_INIT_DEFINITION(ptVarSyncStringVarCreatedMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncStringVarCreatedMsg, name)
{
std::wstring retVal = self->fThis->Name();
return PyUnicode_FromWideChar(retVal.c_str(), retVal.size());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncStringVarCreatedMsg, id)
{
return PyLong_FromUnsignedLong(self->fThis->ID());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncStringVarCreatedMsg, value)
{
std::wstring retVal = self->fThis->Value();
return PyUnicode_FromWideChar(retVal.c_str(), retVal.size());
}
PYTHON_START_METHODS_TABLE(ptVarSyncStringVarCreatedMsg)
PYTHON_METHOD_NOARGS(ptVarSyncStringVarCreatedMsg, name, "Returns the name of the var that was created"),
PYTHON_METHOD_NOARGS(ptVarSyncStringVarCreatedMsg, id, "Returns the id that was assigned to this variable"),
PYTHON_METHOD_NOARGS(ptVarSyncStringVarCreatedMsg, value, "Returns the variable's new value"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptVarSyncStringVarCreatedMsg, pyVarSyncMsg, "VarSync message received when a string variable is created and assigned an id");
// required functions for PyObject interoperability
PyObject* pyVarSyncStringVarCreatedMsg::New(pfGameCliMsg* msg)
{
ptVarSyncStringVarCreatedMsg *newObj = (ptVarSyncStringVarCreatedMsg*)ptVarSyncStringVarCreatedMsg_type.tp_new(&ptVarSyncStringVarCreatedMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_VarSync_StringVarCreated))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptVarSyncStringVarCreatedMsg, pyVarSyncStringVarCreatedMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptVarSyncStringVarCreatedMsg, pyVarSyncStringVarCreatedMsg)
// Module and method definitions
void pyVarSyncStringVarCreatedMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptVarSyncStringVarCreatedMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptVarSyncNumericVarCreatedMsg, pyVarSyncNumericVarCreatedMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptVarSyncNumericVarCreatedMsg, pyVarSyncNumericVarCreatedMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptVarSyncNumericVarCreatedMsg)
PYTHON_NO_INIT_DEFINITION(ptVarSyncNumericVarCreatedMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncNumericVarCreatedMsg, name)
{
std::wstring retVal = self->fThis->Name();
return PyUnicode_FromWideChar(retVal.c_str(), retVal.size());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncNumericVarCreatedMsg, id)
{
return PyLong_FromUnsignedLong(self->fThis->ID());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncNumericVarCreatedMsg, value)
{
return PyLong_FromDouble(self->fThis->Value());
}
PYTHON_START_METHODS_TABLE(ptVarSyncNumericVarCreatedMsg)
PYTHON_METHOD_NOARGS(ptVarSyncNumericVarCreatedMsg, name, "Returns the name of the var that was created"),
PYTHON_METHOD_NOARGS(ptVarSyncNumericVarCreatedMsg, id, "Returns the id assigned to this variable"),
PYTHON_METHOD_NOARGS(ptVarSyncNumericVarCreatedMsg, value, "Returns the variable's new value"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptVarSyncNumericVarCreatedMsg, pyVarSyncMsg, "VarSync message received when a numeric variable is created and assigned an id");
// required functions for PyObject interoperability
PyObject* pyVarSyncNumericVarCreatedMsg::New(pfGameCliMsg* msg)
{
ptVarSyncNumericVarCreatedMsg *newObj = (ptVarSyncNumericVarCreatedMsg*)ptVarSyncNumericVarCreatedMsg_type.tp_new(&ptVarSyncNumericVarCreatedMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_VarSync_NumericVarCreated))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptVarSyncNumericVarCreatedMsg, pyVarSyncNumericVarCreatedMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptVarSyncNumericVarCreatedMsg, pyVarSyncNumericVarCreatedMsg)
// Module and method definitions
void pyVarSyncNumericVarCreatedMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptVarSyncNumericVarCreatedMsg);
PYTHON_CLASS_IMPORT_END(m);
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyVarSyncMsg.h"
#include "../../pyEnum.h"
#include <python.h>
///////////////////////////////////////////////////////////////////////////////
//
// Base VarSync msg class
//
PYTHON_CLASS_DEFINITION(ptVarSyncMsg, pyVarSyncMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptVarSyncMsg, pyVarSyncMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptVarSyncMsg)
PYTHON_NO_INIT_DEFINITION(ptVarSyncMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncMsg, getVarSyncMsgType)
{
return PyInt_FromLong(self->fThis->GetVarSyncMsgType());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncMsg, upcastToFinalVarSyncMsg)
{
return self->fThis->UpcastToFinalVarSyncMsg();
}
PYTHON_START_METHODS_TABLE(ptVarSyncMsg)
PYTHON_METHOD_NOARGS(ptVarSyncMsg, getVarSyncMsgType, "Returns the type of the VarSync message (see PtVarSyncMsgTypes)"),
PYTHON_METHOD_NOARGS(ptVarSyncMsg, upcastToFinalVarSyncMsg, "Returns this message as the VarSync msg it is"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptVarSyncMsg, pyGameCliMsg, "Base class for VarSync game messages");
PYTHON_EXPOSE_TYPE_DEFINITION(ptVarSyncMsg, pyVarSyncMsg);
// required functions for PyObject interoperability
PyObject* pyVarSyncMsg::New(pfGameCliMsg* msg)
{
ptVarSyncMsg *newObj = (ptVarSyncMsg*)ptVarSyncMsg_type.tp_new(&ptVarSyncMsg_type, NULL, NULL);
if (msg && (msg->gameCli->GetGameTypeId() == kGameTypeId_VarSync))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptVarSyncMsg, pyVarSyncMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptVarSyncMsg, pyVarSyncMsg)
// Module and method definitions
void pyVarSyncMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptVarSyncMsg);
PYTHON_CLASS_IMPORT_END(m);
}
void pyVarSyncMsg::AddPlasmaConstantsClasses(PyObject* m)
{
PYTHON_ENUM_START(PtVarSyncMsgTypes);
PYTHON_ENUM_ELEMENT(PtVarSyncMsgTypes, kVarSyncStringVarChanged, kSrv2Cli_VarSync_StringVarChanged);
PYTHON_ENUM_ELEMENT(PtVarSyncMsgTypes, kVarSyncNumericVarChanged, kSrv2Cli_VarSync_NumericVarChanged);
PYTHON_ENUM_ELEMENT(PtVarSyncMsgTypes, kVarSyncAllVarsSent, kSrv2Cli_VarSync_AllVarsSent);
PYTHON_ENUM_ELEMENT(PtVarSyncMsgTypes, kVarSyncStringVarCreated, kSrv2Cli_VarSync_StringVarCreated);
PYTHON_ENUM_ELEMENT(PtVarSyncMsgTypes, kVarSyncNumericVarCreated, kSrv2Cli_VarSync_NumericVarCreated);
PYTHON_ENUM_END(m, PtVarSyncMsgTypes);
}
///////////////////////////////////////////////////////////////////////////////
//
// Game client message subclasses
//
PYTHON_CLASS_DEFINITION(ptVarSyncStringVarChangedMsg, pyVarSyncStringVarChangedMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptVarSyncStringVarChangedMsg, pyVarSyncStringVarChangedMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptVarSyncStringVarChangedMsg)
PYTHON_NO_INIT_DEFINITION(ptVarSyncStringVarChangedMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncStringVarChangedMsg, id)
{
return PyLong_FromUnsignedLong(self->fThis->ID());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncStringVarChangedMsg, value)
{
std::wstring retVal = self->fThis->Value();
return PyUnicode_FromWideChar(retVal.c_str(), retVal.size());
}
PYTHON_START_METHODS_TABLE(ptVarSyncStringVarChangedMsg)
PYTHON_METHOD_NOARGS(ptVarSyncStringVarChangedMsg, id, "Returns the id of the var that changed"),
PYTHON_METHOD_NOARGS(ptVarSyncStringVarChangedMsg, value, "Returns the variable's new value"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptVarSyncStringVarChangedMsg, pyVarSyncMsg, "VarSync message received when a string variable's value changes");
// required functions for PyObject interoperability
PyObject* pyVarSyncStringVarChangedMsg::New(pfGameCliMsg* msg)
{
ptVarSyncStringVarChangedMsg *newObj = (ptVarSyncStringVarChangedMsg*)ptVarSyncStringVarChangedMsg_type.tp_new(&ptVarSyncStringVarChangedMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_VarSync_StringVarChanged))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptVarSyncStringVarChangedMsg, pyVarSyncStringVarChangedMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptVarSyncStringVarChangedMsg, pyVarSyncStringVarChangedMsg)
// Module and method definitions
void pyVarSyncStringVarChangedMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptVarSyncStringVarChangedMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptVarSyncNumericVarChangedMsg, pyVarSyncNumericVarChangedMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptVarSyncNumericVarChangedMsg, pyVarSyncNumericVarChangedMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptVarSyncNumericVarChangedMsg)
PYTHON_NO_INIT_DEFINITION(ptVarSyncNumericVarChangedMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncNumericVarChangedMsg, id)
{
return PyLong_FromUnsignedLong(self->fThis->ID());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncNumericVarChangedMsg, value)
{
return PyLong_FromDouble(self->fThis->Value());
}
PYTHON_START_METHODS_TABLE(ptVarSyncNumericVarChangedMsg)
PYTHON_METHOD_NOARGS(ptVarSyncNumericVarChangedMsg, id, "Returns the id of the var that changed"),
PYTHON_METHOD_NOARGS(ptVarSyncNumericVarChangedMsg, value, "Returns the variable's new value"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptVarSyncNumericVarChangedMsg, pyVarSyncMsg, "VarSync message received when a numeric variable's value changes");
// required functions for PyObject interoperability
PyObject* pyVarSyncNumericVarChangedMsg::New(pfGameCliMsg* msg)
{
ptVarSyncNumericVarChangedMsg *newObj = (ptVarSyncNumericVarChangedMsg*)ptVarSyncNumericVarChangedMsg_type.tp_new(&ptVarSyncNumericVarChangedMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_VarSync_NumericVarChanged))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptVarSyncNumericVarChangedMsg, pyVarSyncNumericVarChangedMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptVarSyncNumericVarChangedMsg, pyVarSyncNumericVarChangedMsg)
// Module and method definitions
void pyVarSyncNumericVarChangedMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptVarSyncNumericVarChangedMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptVarSyncAllVarsSentMsg, pyVarSyncAllVarsSentMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptVarSyncAllVarsSentMsg, pyVarSyncAllVarsSentMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptVarSyncAllVarsSentMsg)
PYTHON_NO_INIT_DEFINITION(ptVarSyncAllVarsSentMsg)
PYTHON_START_METHODS_TABLE(ptVarSyncAllVarsSentMsg)
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptVarSyncAllVarsSentMsg, pyVarSyncMsg, "VarSync message received after the last var is sent to you when you join the game, or request a list of vars");
// required functions for PyObject interoperability
PyObject* pyVarSyncAllVarsSentMsg::New(pfGameCliMsg* msg)
{
ptVarSyncAllVarsSentMsg *newObj = (ptVarSyncAllVarsSentMsg*)ptVarSyncAllVarsSentMsg_type.tp_new(&ptVarSyncAllVarsSentMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_VarSync_AllVarsSent))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptVarSyncAllVarsSentMsg, pyVarSyncAllVarsSentMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptVarSyncAllVarsSentMsg, pyVarSyncAllVarsSentMsg)
// Module and method definitions
void pyVarSyncAllVarsSentMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptVarSyncAllVarsSentMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptVarSyncStringVarCreatedMsg, pyVarSyncStringVarCreatedMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptVarSyncStringVarCreatedMsg, pyVarSyncStringVarCreatedMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptVarSyncStringVarCreatedMsg)
PYTHON_NO_INIT_DEFINITION(ptVarSyncStringVarCreatedMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncStringVarCreatedMsg, name)
{
std::wstring retVal = self->fThis->Name();
return PyUnicode_FromWideChar(retVal.c_str(), retVal.size());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncStringVarCreatedMsg, id)
{
return PyLong_FromUnsignedLong(self->fThis->ID());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncStringVarCreatedMsg, value)
{
std::wstring retVal = self->fThis->Value();
return PyUnicode_FromWideChar(retVal.c_str(), retVal.size());
}
PYTHON_START_METHODS_TABLE(ptVarSyncStringVarCreatedMsg)
PYTHON_METHOD_NOARGS(ptVarSyncStringVarCreatedMsg, name, "Returns the name of the var that was created"),
PYTHON_METHOD_NOARGS(ptVarSyncStringVarCreatedMsg, id, "Returns the id that was assigned to this variable"),
PYTHON_METHOD_NOARGS(ptVarSyncStringVarCreatedMsg, value, "Returns the variable's new value"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptVarSyncStringVarCreatedMsg, pyVarSyncMsg, "VarSync message received when a string variable is created and assigned an id");
// required functions for PyObject interoperability
PyObject* pyVarSyncStringVarCreatedMsg::New(pfGameCliMsg* msg)
{
ptVarSyncStringVarCreatedMsg *newObj = (ptVarSyncStringVarCreatedMsg*)ptVarSyncStringVarCreatedMsg_type.tp_new(&ptVarSyncStringVarCreatedMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_VarSync_StringVarCreated))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptVarSyncStringVarCreatedMsg, pyVarSyncStringVarCreatedMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptVarSyncStringVarCreatedMsg, pyVarSyncStringVarCreatedMsg)
// Module and method definitions
void pyVarSyncStringVarCreatedMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptVarSyncStringVarCreatedMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptVarSyncNumericVarCreatedMsg, pyVarSyncNumericVarCreatedMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptVarSyncNumericVarCreatedMsg, pyVarSyncNumericVarCreatedMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptVarSyncNumericVarCreatedMsg)
PYTHON_NO_INIT_DEFINITION(ptVarSyncNumericVarCreatedMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncNumericVarCreatedMsg, name)
{
std::wstring retVal = self->fThis->Name();
return PyUnicode_FromWideChar(retVal.c_str(), retVal.size());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncNumericVarCreatedMsg, id)
{
return PyLong_FromUnsignedLong(self->fThis->ID());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptVarSyncNumericVarCreatedMsg, value)
{
return PyLong_FromDouble(self->fThis->Value());
}
PYTHON_START_METHODS_TABLE(ptVarSyncNumericVarCreatedMsg)
PYTHON_METHOD_NOARGS(ptVarSyncNumericVarCreatedMsg, name, "Returns the name of the var that was created"),
PYTHON_METHOD_NOARGS(ptVarSyncNumericVarCreatedMsg, id, "Returns the id assigned to this variable"),
PYTHON_METHOD_NOARGS(ptVarSyncNumericVarCreatedMsg, value, "Returns the variable's new value"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptVarSyncNumericVarCreatedMsg, pyVarSyncMsg, "VarSync message received when a numeric variable is created and assigned an id");
// required functions for PyObject interoperability
PyObject* pyVarSyncNumericVarCreatedMsg::New(pfGameCliMsg* msg)
{
ptVarSyncNumericVarCreatedMsg *newObj = (ptVarSyncNumericVarCreatedMsg*)ptVarSyncNumericVarCreatedMsg_type.tp_new(&ptVarSyncNumericVarCreatedMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_VarSync_NumericVarCreated))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptVarSyncNumericVarCreatedMsg, pyVarSyncNumericVarCreatedMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptVarSyncNumericVarCreatedMsg, pyVarSyncNumericVarCreatedMsg)
// Module and method definitions
void pyVarSyncNumericVarCreatedMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptVarSyncNumericVarCreatedMsg);
PYTHON_CLASS_IMPORT_END(m);
}

View File

@ -1,163 +1,163 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyGameCli.h"
#include "TicTacToe/pyTTTGame.h"
#include "Heek/pyHeekGame.h"
#include "Marker/pyMarkerGame.h"
#include "BlueSpiral/pyBlueSpiralGame.h"
#include "ClimbingWall/pyClimbingWallGame.h"
#include "VarSync/pyVarSyncGame.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base game client class
//
pyGameCli::pyGameCli(): gameClient(nil) {}
pyGameCli::pyGameCli(pfGameCli* client): gameClient(client) {}
std::vector<unsigned> pyGameCli::GetGameIDs()
{
ARRAY(unsigned) gameIDs;
std::vector<unsigned> retVal;
pfGameMgr::GetInstance()->GetGameIds(&gameIDs);
for (unsigned i = 0; i < gameIDs.Count(); ++i)
retVal.push_back(gameIDs[i]);
return retVal;
}
PyObject* pyGameCli::GetGameCli(unsigned gameID)
{
pfGameCli* client = pfGameMgr::GetInstance()->GetGameCli(gameID);
if (client)
return pyGameCli::New(client);
PYTHON_RETURN_NONE;
}
std::wstring pyGameCli::GetGameNameByTypeID(std::wstring typeID)
{
Uuid gameUuid(typeID.c_str());
return pfGameMgr::GetInstance()->GetGameNameByTypeId(gameUuid);
}
void pyGameCli::JoinGame(pyKey& callbackKey, unsigned gameID)
{
pfGameMgr::GetInstance()->JoinGame(callbackKey.getKey(), gameID);
}
unsigned pyGameCli::GameID() const
{
if (gameClient)
return gameClient->GetGameId();
return 0;
}
std::wstring pyGameCli::GameTypeID() const
{
if (gameClient)
{
wchar_t guidStr[256];
GuidToString(gameClient->GetGameTypeId(), guidStr, arrsize(guidStr));
return guidStr;
}
return L"";
}
std::wstring pyGameCli::Name() const
{
if (gameClient)
return gameClient->GetName();
return L"";
}
unsigned pyGameCli::PlayerCount() const
{
if (gameClient)
return gameClient->GetPlayerCount();
return 0;
}
void pyGameCli::InvitePlayer(unsigned playerID)
{
if (gameClient)
gameClient->InvitePlayer(playerID);
}
void pyGameCli::UninvitePlayer(unsigned playerID)
{
if (gameClient)
gameClient->UninvitePlayer(playerID);
}
void pyGameCli::LeaveGame()
{
if (gameClient)
gameClient->LeaveGame();
}
PyObject* pyGameCli::UpcastToTTTGame()
{
if (gameClient && (gameClient->GetGameTypeId() == kGameTypeId_TicTacToe))
return pyTTTGame::New(gameClient);
PYTHON_RETURN_NONE;
}
PyObject* pyGameCli::UpcastToHeekGame()
{
if (gameClient && (gameClient->GetGameTypeId() == kGameTypeId_Heek))
return pyHeekGame::New(gameClient);
PYTHON_RETURN_NONE;
}
PyObject* pyGameCli::UpcastToMarkerGame()
{
if (gameClient && (gameClient->GetGameTypeId() == kGameTypeId_Marker))
return pyMarkerGame::New(gameClient);
PYTHON_RETURN_NONE;
}
PyObject* pyGameCli::UpcastToBlueSpiralGame()
{
if (gameClient && (gameClient->GetGameTypeId() == kGameTypeId_BlueSpiral))
return pyBlueSpiralGame::New(gameClient);
PYTHON_RETURN_NONE;
}
PyObject* pyGameCli::UpcastToClimbingWallGame()
{
if (gameClient && (gameClient->GetGameTypeId() == kGameTypeId_ClimbingWall))
return pyClimbingWallGame::New(gameClient);
PYTHON_RETURN_NONE;
}
PyObject* pyGameCli::UpcastToVarSyncGame()
{
if (gameClient && (gameClient->GetGameTypeId() == kGameTypeId_VarSync))
return pyVarSyncGame::New(gameClient);
PYTHON_RETURN_NONE;
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyGameCli.h"
#include "TicTacToe/pyTTTGame.h"
#include "Heek/pyHeekGame.h"
#include "Marker/pyMarkerGame.h"
#include "BlueSpiral/pyBlueSpiralGame.h"
#include "ClimbingWall/pyClimbingWallGame.h"
#include "VarSync/pyVarSyncGame.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base game client class
//
pyGameCli::pyGameCli(): gameClient(nil) {}
pyGameCli::pyGameCli(pfGameCli* client): gameClient(client) {}
std::vector<unsigned> pyGameCli::GetGameIDs()
{
ARRAY(unsigned) gameIDs;
std::vector<unsigned> retVal;
pfGameMgr::GetInstance()->GetGameIds(&gameIDs);
for (unsigned i = 0; i < gameIDs.Count(); ++i)
retVal.push_back(gameIDs[i]);
return retVal;
}
PyObject* pyGameCli::GetGameCli(unsigned gameID)
{
pfGameCli* client = pfGameMgr::GetInstance()->GetGameCli(gameID);
if (client)
return pyGameCli::New(client);
PYTHON_RETURN_NONE;
}
std::wstring pyGameCli::GetGameNameByTypeID(std::wstring typeID)
{
Uuid gameUuid(typeID.c_str());
return pfGameMgr::GetInstance()->GetGameNameByTypeId(gameUuid);
}
void pyGameCli::JoinGame(pyKey& callbackKey, unsigned gameID)
{
pfGameMgr::GetInstance()->JoinGame(callbackKey.getKey(), gameID);
}
unsigned pyGameCli::GameID() const
{
if (gameClient)
return gameClient->GetGameId();
return 0;
}
std::wstring pyGameCli::GameTypeID() const
{
if (gameClient)
{
wchar_t guidStr[256];
GuidToString(gameClient->GetGameTypeId(), guidStr, arrsize(guidStr));
return guidStr;
}
return L"";
}
std::wstring pyGameCli::Name() const
{
if (gameClient)
return gameClient->GetName();
return L"";
}
unsigned pyGameCli::PlayerCount() const
{
if (gameClient)
return gameClient->GetPlayerCount();
return 0;
}
void pyGameCli::InvitePlayer(unsigned playerID)
{
if (gameClient)
gameClient->InvitePlayer(playerID);
}
void pyGameCli::UninvitePlayer(unsigned playerID)
{
if (gameClient)
gameClient->UninvitePlayer(playerID);
}
void pyGameCli::LeaveGame()
{
if (gameClient)
gameClient->LeaveGame();
}
PyObject* pyGameCli::UpcastToTTTGame()
{
if (gameClient && (gameClient->GetGameTypeId() == kGameTypeId_TicTacToe))
return pyTTTGame::New(gameClient);
PYTHON_RETURN_NONE;
}
PyObject* pyGameCli::UpcastToHeekGame()
{
if (gameClient && (gameClient->GetGameTypeId() == kGameTypeId_Heek))
return pyHeekGame::New(gameClient);
PYTHON_RETURN_NONE;
}
PyObject* pyGameCli::UpcastToMarkerGame()
{
if (gameClient && (gameClient->GetGameTypeId() == kGameTypeId_Marker))
return pyMarkerGame::New(gameClient);
PYTHON_RETURN_NONE;
}
PyObject* pyGameCli::UpcastToBlueSpiralGame()
{
if (gameClient && (gameClient->GetGameTypeId() == kGameTypeId_BlueSpiral))
return pyBlueSpiralGame::New(gameClient);
PYTHON_RETURN_NONE;
}
PyObject* pyGameCli::UpcastToClimbingWallGame()
{
if (gameClient && (gameClient->GetGameTypeId() == kGameTypeId_ClimbingWall))
return pyClimbingWallGame::New(gameClient);
PYTHON_RETURN_NONE;
}
PyObject* pyGameCli::UpcastToVarSyncGame()
{
if (gameClient && (gameClient->GetGameTypeId() == kGameTypeId_VarSync))
return pyVarSyncGame::New(gameClient);
PYTHON_RETURN_NONE;
}

View File

@ -1,84 +1,84 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyGameCli_h
#define pyGameCli_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: pyGameCli
//
// PURPOSE: Class wrapper for the game client base class
//
#include "pfGameMgr/pfGameMgr.h"
#include <python.h>
#include "../pyGlueHelpers.h"
#include "../pyKey.h"
class pyGameCli
{
protected:
pfGameCli* gameClient;
pyGameCli();
pyGameCli(pfGameCli* client);
public:
// required functions for PyObject interoperability
PYTHON_EXPOSE_TYPE; // so we can subclass
PYTHON_CLASS_NEW_FRIEND(ptGameCli);
static PyObject* New(pfGameCli* client);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameCli object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameCli); // converts a PyObject to a pyGameCli (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaMethods(std::vector<PyMethodDef>& methods);
static std::vector<unsigned> GetGameIDs();
static PyObject* GetGameCli(unsigned gameID); // returns a ptGameCli
static std::wstring GetGameNameByTypeID(std::wstring typeID);
static void JoinGame(pyKey& callbackKey, unsigned gameID);
unsigned GameID() const;
std::wstring GameTypeID() const;
std::wstring Name() const;
unsigned PlayerCount() const;
void InvitePlayer(unsigned playerID);
void UninvitePlayer(unsigned playerID);
void LeaveGame();
PyObject* UpcastToTTTGame(); // returns ptTTTGame
PyObject* UpcastToHeekGame(); // returns ptHeekGame
PyObject* UpcastToMarkerGame(); // returns ptMarkerGame
PyObject* UpcastToBlueSpiralGame(); // returns ptBlueSpiralGame
PyObject* UpcastToClimbingWallGame(); // returns ptClimbingWallGame
PyObject* UpcastToVarSyncGame(); // returns ptVarSyncGame
};
#endif // pyGameCli_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyGameCli_h
#define pyGameCli_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: pyGameCli
//
// PURPOSE: Class wrapper for the game client base class
//
#include "pfGameMgr/pfGameMgr.h"
#include <python.h>
#include "../pyGlueHelpers.h"
#include "../pyKey.h"
class pyGameCli
{
protected:
pfGameCli* gameClient;
pyGameCli();
pyGameCli(pfGameCli* client);
public:
// required functions for PyObject interoperability
PYTHON_EXPOSE_TYPE; // so we can subclass
PYTHON_CLASS_NEW_FRIEND(ptGameCli);
static PyObject* New(pfGameCli* client);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameCli object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameCli); // converts a PyObject to a pyGameCli (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaMethods(std::vector<PyMethodDef>& methods);
static std::vector<unsigned> GetGameIDs();
static PyObject* GetGameCli(unsigned gameID); // returns a ptGameCli
static std::wstring GetGameNameByTypeID(std::wstring typeID);
static void JoinGame(pyKey& callbackKey, unsigned gameID);
unsigned GameID() const;
std::wstring GameTypeID() const;
std::wstring Name() const;
unsigned PlayerCount() const;
void InvitePlayer(unsigned playerID);
void UninvitePlayer(unsigned playerID);
void LeaveGame();
PyObject* UpcastToTTTGame(); // returns ptTTTGame
PyObject* UpcastToHeekGame(); // returns ptHeekGame
PyObject* UpcastToMarkerGame(); // returns ptMarkerGame
PyObject* UpcastToBlueSpiralGame(); // returns ptBlueSpiralGame
PyObject* UpcastToClimbingWallGame(); // returns ptClimbingWallGame
PyObject* UpcastToVarSyncGame(); // returns ptVarSyncGame
};
#endif // pyGameCli_h

View File

@ -1,239 +1,239 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyGameCli.h"
#include "../pyEnum.h"
#include <python.h>
///////////////////////////////////////////////////////////////////////////////
//
// Base game client class
//
PYTHON_CLASS_DEFINITION(ptGameCli, pyGameCli);
PYTHON_DEFAULT_NEW_DEFINITION(ptGameCli, pyGameCli)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameCli)
PYTHON_NO_INIT_DEFINITION(ptGameCli)
PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetGameIDs, "Returns a list of game IDs that the player is currently joined to")
{
std::vector<unsigned> ids = pyGameCli::GetGameIDs();
PyObject* retVal = PyList_New(ids.size());
for (unsigned i = 0; i < ids.size(); ++i)
PyList_SetItem(retVal, i, PyInt_FromLong(ids[i]));
return retVal;
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtGetGameCli, args, "Params: gameID\nReturns a ptGameCli associated with the specified id")
{
int gameID = 0;
if (!PyArg_ParseTuple(args, "i", &gameID))
{
PyErr_SetString(PyExc_TypeError, "PtGetGameCli expects an integer");
PYTHON_RETURN_ERROR;
}
return pyGameCli::GetGameCli(gameID);
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtGetGameNameByTypeID, args, "Params: guid\nReturns the name of the game represented by guid passed in as a string")
{
PyObject* textObj;
if (!PyArg_ParseTuple(args, "O", &textObj))
{
PyErr_SetString(PyExc_TypeError, "PtGetGameNameByTypeID expects a unicode string");
PYTHON_RETURN_ERROR;
}
if (PyUnicode_Check(textObj))
{
int strLen = PyUnicode_GetSize(textObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)textObj, text, strLen);
text[strLen] = L'\0';
std::wstring retVal = pyGameCli::GetGameNameByTypeID(text);
delete [] text;
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
}
else if (PyString_Check(textObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(textObj);
wchar_t* wText = hsStringToWString(text);
std::wstring retVal = pyGameCli::GetGameNameByTypeID(wText);
delete [] wText;
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
}
else
{
PyErr_SetString(PyExc_TypeError, "PtGetGameNameByTypeID expects a unicode string");
PYTHON_RETURN_ERROR;
}
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtJoinGame, args, "Params: callbackKey, gameID\nSends a join request to the specified game. Messages are sent to the callback key")
{
PyObject* callbackObj = NULL;
int gameID = 0;
if (!PyArg_ParseTuple(args, "Oi", &callbackObj, &gameID))
{
PyErr_SetString(PyExc_TypeError, "PtJoinGame expects a ptKey and an integer");
PYTHON_RETURN_ERROR;
}
if (!pyKey::Check(callbackObj))
{
PyErr_SetString(PyExc_TypeError, "PtJoinGame expects a ptKey and an integer");
PYTHON_RETURN_ERROR;
}
pyKey* key = pyKey::ConvertFrom(callbackObj);
pyGameCli::JoinGame(*key, gameID);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, gameID)
{
return PyInt_FromLong(self->fThis->GameID());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, gameTypeID)
{
std::wstring retVal = self->fThis->GameTypeID();
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, name)
{
std::wstring retVal = self->fThis->Name();
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, playerCount)
{
return PyInt_FromLong(self->fThis->PlayerCount());
}
PYTHON_METHOD_DEFINITION(ptGameCli, invitePlayer, args)
{
int playerID = 0;
if (!PyArg_ParseTuple(args, "i", &playerID))
{
PyErr_SetString(PyExc_TypeError, "invitePlayer expects an unsigned int");
PYTHON_RETURN_ERROR;
}
self->fThis->InvitePlayer(playerID);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptGameCli, uninvitePlayer, args)
{
int playerID = 0;
if (!PyArg_ParseTuple(args, "i", &playerID))
{
PyErr_SetString(PyExc_TypeError, "uninvitePlayer expects an unsigned int");
PYTHON_RETURN_ERROR;
}
self->fThis->UninvitePlayer(playerID);
PYTHON_RETURN_NONE;
}
PYTHON_BASIC_METHOD_DEFINITION(ptGameCli, leaveGame, LeaveGame)
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, upcastToTTTGame)
{
return self->fThis->UpcastToTTTGame();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, upcastToHeekGame)
{
return self->fThis->UpcastToHeekGame();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, upcastToMarkerGame)
{
return self->fThis->UpcastToMarkerGame();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, upcastToBlueSpiralGame)
{
return self->fThis->UpcastToBlueSpiralGame();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, upcastToClimbingWallGame)
{
return self->fThis->UpcastToClimbingWallGame();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, upcastToVarSyncGame)
{
return self->fThis->UpcastToVarSyncGame();
}
PYTHON_START_METHODS_TABLE(ptGameCli)
PYTHON_METHOD_NOARGS(ptGameCli, gameID, "Returns the ID number for this game"),
PYTHON_METHOD_NOARGS(ptGameCli, gameTypeID, "Returns the game type ID for this game (as a guid string)"),
PYTHON_METHOD_NOARGS(ptGameCli, name, "Returns the name of the game"),
PYTHON_METHOD_NOARGS(ptGameCli, playerCount, "Returns the current number of players"),
PYTHON_METHOD(ptGameCli, invitePlayer, "Params: playerID\nInvites the specified player to join the game"),
PYTHON_METHOD(ptGameCli, uninvitePlayer, "Params: playerID\nRevokes the invitation for the specified player"),
PYTHON_BASIC_METHOD(ptGameCli, leaveGame, "Leaves this game"),
PYTHON_METHOD_NOARGS(ptGameCli, upcastToTTTGame, "Returns this game client as a ptTTTGame"),
PYTHON_METHOD_NOARGS(ptGameCli, upcastToHeekGame, "Returns this game client as a ptHeekGame"),
PYTHON_METHOD_NOARGS(ptGameCli, upcastToMarkerGame, "Returns this game client as a ptMarkerGame"),
PYTHON_METHOD_NOARGS(ptGameCli, upcastToBlueSpiralGame, "Returns this game client as a ptBlueSpiralGame"),
PYTHON_METHOD_NOARGS(ptGameCli, upcastToClimbingWallGame, "Returns this game client as a ptClimbingWallGame"),
PYTHON_METHOD_NOARGS(ptGameCli, upcastToVarSyncGame, "Returns this game client as a ptVarSyncGame"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE(ptGameCli, "Base class for all game client interfaces");
PYTHON_EXPOSE_TYPE_DEFINITION(ptGameCli, pyGameCli);
// required functions for PyObject interoperability
PyObject* pyGameCli::New(pfGameCli* client)
{
ptGameCli *newObj = (ptGameCli*)ptGameCli_type.tp_new(&ptGameCli_type, NULL, NULL);
newObj->fThis->gameClient = client;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptGameCli, pyGameCli)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameCli, pyGameCli)
// Module and method definitions
void pyGameCli::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptGameCli);
PYTHON_CLASS_IMPORT_END(m);
}
void pyGameCli::AddPlasmaMethods(std::vector<PyMethodDef>& methods)
{
PYTHON_GLOBAL_METHOD_NOARGS(methods, PtGetGameIDs);
PYTHON_GLOBAL_METHOD(methods, PtGetGameCli);
PYTHON_GLOBAL_METHOD(methods, PtGetGameNameByTypeID);
PYTHON_GLOBAL_METHOD(methods, PtJoinGame);
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyGameCli.h"
#include "../pyEnum.h"
#include <python.h>
///////////////////////////////////////////////////////////////////////////////
//
// Base game client class
//
PYTHON_CLASS_DEFINITION(ptGameCli, pyGameCli);
PYTHON_DEFAULT_NEW_DEFINITION(ptGameCli, pyGameCli)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameCli)
PYTHON_NO_INIT_DEFINITION(ptGameCli)
PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetGameIDs, "Returns a list of game IDs that the player is currently joined to")
{
std::vector<unsigned> ids = pyGameCli::GetGameIDs();
PyObject* retVal = PyList_New(ids.size());
for (unsigned i = 0; i < ids.size(); ++i)
PyList_SetItem(retVal, i, PyInt_FromLong(ids[i]));
return retVal;
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtGetGameCli, args, "Params: gameID\nReturns a ptGameCli associated with the specified id")
{
int gameID = 0;
if (!PyArg_ParseTuple(args, "i", &gameID))
{
PyErr_SetString(PyExc_TypeError, "PtGetGameCli expects an integer");
PYTHON_RETURN_ERROR;
}
return pyGameCli::GetGameCli(gameID);
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtGetGameNameByTypeID, args, "Params: guid\nReturns the name of the game represented by guid passed in as a string")
{
PyObject* textObj;
if (!PyArg_ParseTuple(args, "O", &textObj))
{
PyErr_SetString(PyExc_TypeError, "PtGetGameNameByTypeID expects a unicode string");
PYTHON_RETURN_ERROR;
}
if (PyUnicode_Check(textObj))
{
int strLen = PyUnicode_GetSize(textObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)textObj, text, strLen);
text[strLen] = L'\0';
std::wstring retVal = pyGameCli::GetGameNameByTypeID(text);
delete [] text;
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
}
else if (PyString_Check(textObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(textObj);
wchar_t* wText = hsStringToWString(text);
std::wstring retVal = pyGameCli::GetGameNameByTypeID(wText);
delete [] wText;
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
}
else
{
PyErr_SetString(PyExc_TypeError, "PtGetGameNameByTypeID expects a unicode string");
PYTHON_RETURN_ERROR;
}
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtJoinGame, args, "Params: callbackKey, gameID\nSends a join request to the specified game. Messages are sent to the callback key")
{
PyObject* callbackObj = NULL;
int gameID = 0;
if (!PyArg_ParseTuple(args, "Oi", &callbackObj, &gameID))
{
PyErr_SetString(PyExc_TypeError, "PtJoinGame expects a ptKey and an integer");
PYTHON_RETURN_ERROR;
}
if (!pyKey::Check(callbackObj))
{
PyErr_SetString(PyExc_TypeError, "PtJoinGame expects a ptKey and an integer");
PYTHON_RETURN_ERROR;
}
pyKey* key = pyKey::ConvertFrom(callbackObj);
pyGameCli::JoinGame(*key, gameID);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, gameID)
{
return PyInt_FromLong(self->fThis->GameID());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, gameTypeID)
{
std::wstring retVal = self->fThis->GameTypeID();
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, name)
{
std::wstring retVal = self->fThis->Name();
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, playerCount)
{
return PyInt_FromLong(self->fThis->PlayerCount());
}
PYTHON_METHOD_DEFINITION(ptGameCli, invitePlayer, args)
{
int playerID = 0;
if (!PyArg_ParseTuple(args, "i", &playerID))
{
PyErr_SetString(PyExc_TypeError, "invitePlayer expects an unsigned int");
PYTHON_RETURN_ERROR;
}
self->fThis->InvitePlayer(playerID);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptGameCli, uninvitePlayer, args)
{
int playerID = 0;
if (!PyArg_ParseTuple(args, "i", &playerID))
{
PyErr_SetString(PyExc_TypeError, "uninvitePlayer expects an unsigned int");
PYTHON_RETURN_ERROR;
}
self->fThis->UninvitePlayer(playerID);
PYTHON_RETURN_NONE;
}
PYTHON_BASIC_METHOD_DEFINITION(ptGameCli, leaveGame, LeaveGame)
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, upcastToTTTGame)
{
return self->fThis->UpcastToTTTGame();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, upcastToHeekGame)
{
return self->fThis->UpcastToHeekGame();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, upcastToMarkerGame)
{
return self->fThis->UpcastToMarkerGame();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, upcastToBlueSpiralGame)
{
return self->fThis->UpcastToBlueSpiralGame();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, upcastToClimbingWallGame)
{
return self->fThis->UpcastToClimbingWallGame();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCli, upcastToVarSyncGame)
{
return self->fThis->UpcastToVarSyncGame();
}
PYTHON_START_METHODS_TABLE(ptGameCli)
PYTHON_METHOD_NOARGS(ptGameCli, gameID, "Returns the ID number for this game"),
PYTHON_METHOD_NOARGS(ptGameCli, gameTypeID, "Returns the game type ID for this game (as a guid string)"),
PYTHON_METHOD_NOARGS(ptGameCli, name, "Returns the name of the game"),
PYTHON_METHOD_NOARGS(ptGameCli, playerCount, "Returns the current number of players"),
PYTHON_METHOD(ptGameCli, invitePlayer, "Params: playerID\nInvites the specified player to join the game"),
PYTHON_METHOD(ptGameCli, uninvitePlayer, "Params: playerID\nRevokes the invitation for the specified player"),
PYTHON_BASIC_METHOD(ptGameCli, leaveGame, "Leaves this game"),
PYTHON_METHOD_NOARGS(ptGameCli, upcastToTTTGame, "Returns this game client as a ptTTTGame"),
PYTHON_METHOD_NOARGS(ptGameCli, upcastToHeekGame, "Returns this game client as a ptHeekGame"),
PYTHON_METHOD_NOARGS(ptGameCli, upcastToMarkerGame, "Returns this game client as a ptMarkerGame"),
PYTHON_METHOD_NOARGS(ptGameCli, upcastToBlueSpiralGame, "Returns this game client as a ptBlueSpiralGame"),
PYTHON_METHOD_NOARGS(ptGameCli, upcastToClimbingWallGame, "Returns this game client as a ptClimbingWallGame"),
PYTHON_METHOD_NOARGS(ptGameCli, upcastToVarSyncGame, "Returns this game client as a ptVarSyncGame"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE(ptGameCli, "Base class for all game client interfaces");
PYTHON_EXPOSE_TYPE_DEFINITION(ptGameCli, pyGameCli);
// required functions for PyObject interoperability
PyObject* pyGameCli::New(pfGameCli* client)
{
ptGameCli *newObj = (ptGameCli*)ptGameCli_type.tp_new(&ptGameCli_type, NULL, NULL);
newObj->fThis->gameClient = client;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptGameCli, pyGameCli)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameCli, pyGameCli)
// Module and method definitions
void pyGameCli::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptGameCli);
PYTHON_CLASS_IMPORT_END(m);
}
void pyGameCli::AddPlasmaMethods(std::vector<PyMethodDef>& methods)
{
PYTHON_GLOBAL_METHOD_NOARGS(methods, PtGetGameIDs);
PYTHON_GLOBAL_METHOD(methods, PtGetGameCli);
PYTHON_GLOBAL_METHOD(methods, PtGetGameNameByTypeID);
PYTHON_GLOBAL_METHOD(methods, PtJoinGame);
}

View File

@ -1,226 +1,226 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyGameCliMsg.h"
#include "pyGameCli.h"
#include "TicTacToe\pyTTTMsg.h"
#include "Heek\pyHeekMsg.h"
#include "Marker\pyMarkerMsg.h"
#include "BlueSpiral\pyBlueSpiralMsg.h"
#include "ClimbingWall\pyClimbingWallMsg.h"
#include "VarSync/pyVarSyncMsg.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base game cli msg class
//
pyGameCliMsg::pyGameCliMsg(): message(nil) {}
pyGameCliMsg::pyGameCliMsg(pfGameCliMsg* msg): message(msg) {}
int pyGameCliMsg::GetType() const
{
if (message)
{
switch (message->netMsg->messageId)
{
case kSrv2Cli_Game_PlayerJoined:
case kSrv2Cli_Game_PlayerLeft:
case kSrv2Cli_Game_InviteFailed:
case kSrv2Cli_Game_OwnerChange:
return message->netMsg->messageId; // just return the type straight up
}
// if we get here, it's probably a game message, check the game guid
if (message->gameCli->GetGameTypeId() == kGameTypeId_TicTacToe)
return kPyGameCliTTTMsg;
if (message->gameCli->GetGameTypeId() == kGameTypeId_Heek)
return kPyGameCliHeekMsg;
if (message->gameCli->GetGameTypeId() == kGameTypeId_Marker)
return kPyGameCliMarkerMsg;
if (message->gameCli->GetGameTypeId() == kGameTypeId_BlueSpiral)
return kPyGameCliBlueSpiralMsg;
if (message->gameCli->GetGameTypeId() == kGameTypeId_ClimbingWall)
return kPyGameCliClimbingWallMsg;
if (message->gameCli->GetGameTypeId() == kGameTypeId_VarSync)
return kPyGameCliVarSyncMsg;
}
return -1;
}
PyObject* pyGameCliMsg::GetGameCli() const
{
if (message && (message->gameCli))
return pyGameCli::New(message->gameCli);
PYTHON_RETURN_NONE;
}
PyObject* pyGameCliMsg::UpcastToFinalGameCliMsg() const
{
if (!message)
PYTHON_RETURN_NONE;
switch (message->netMsg->messageId)
{
case kSrv2Cli_Game_PlayerJoined:
return pyGameCliPlayerJoinedMsg::New(message);
case kSrv2Cli_Game_PlayerLeft:
return pyGameCliPlayerLeftMsg::New(message);
case kSrv2Cli_Game_InviteFailed:
return pyGameCliInviteFailedMsg::New(message);
case kSrv2Cli_Game_OwnerChange:
return pyGameCliOwnerChangeMsg::New(message);
default:
PYTHON_RETURN_NONE;
}
}
PyObject* pyGameCliMsg::UpcastToGameMsg() const
{
if (!message)
PYTHON_RETURN_NONE;
const Uuid& gameTypeId = message->gameCli->GetGameTypeId();
if (gameTypeId == kGameTypeId_TicTacToe)
return pyTTTMsg::New(message);
else if (gameTypeId == kGameTypeId_Heek)
return pyHeekMsg::New(message);
else if (gameTypeId == kGameTypeId_Marker)
return pyMarkerMsg::New(message);
else if (gameTypeId == kGameTypeId_BlueSpiral)
return pyBlueSpiralMsg::New(message);
else if (gameTypeId == kGameTypeId_ClimbingWall)
return pyClimbingWallMsg::New(message);
else if (gameTypeId == kGameTypeId_VarSync)
return pyVarSyncMsg::New(message);
else
PYTHON_RETURN_NONE;
}
///////////////////////////////////////////////////////////////////////////////
//
// The different messages we can receive
//
pyGameCliPlayerJoinedMsg::pyGameCliPlayerJoinedMsg(): pyGameCliMsg() {}
pyGameCliPlayerJoinedMsg::pyGameCliPlayerJoinedMsg(pfGameCliMsg* msg): pyGameCliMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Game_PlayerJoined))
message = nil; // wrong type, just clear it out
}
unsigned long pyGameCliPlayerJoinedMsg::PlayerID() const
{
if (message)
{
const Srv2Cli_Game_PlayerJoined* gmMsg = (const Srv2Cli_Game_PlayerJoined*)message->netMsg;
return gmMsg->playerId;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
pyGameCliPlayerLeftMsg::pyGameCliPlayerLeftMsg(): pyGameCliMsg() {}
pyGameCliPlayerLeftMsg::pyGameCliPlayerLeftMsg(pfGameCliMsg* msg): pyGameCliMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Game_PlayerLeft))
message = nil; // wrong type, just clear it out
}
unsigned long pyGameCliPlayerLeftMsg::PlayerID() const
{
if (message)
{
const Srv2Cli_Game_PlayerLeft* gmMsg = (const Srv2Cli_Game_PlayerLeft*)message->netMsg;
return gmMsg->playerId;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
pyGameCliInviteFailedMsg::pyGameCliInviteFailedMsg(): pyGameCliMsg() {}
pyGameCliInviteFailedMsg::pyGameCliInviteFailedMsg(pfGameCliMsg* msg): pyGameCliMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Game_InviteFailed))
message = nil; // wrong type, just clear it out
}
unsigned long pyGameCliInviteFailedMsg::InviteeID() const
{
if (message)
{
const Srv2Cli_Game_InviteFailed* gmMsg = (const Srv2Cli_Game_InviteFailed*)message->netMsg;
return gmMsg->inviteeId;
}
return 0;
}
unsigned long pyGameCliInviteFailedMsg::OperationID() const
{
if (message)
{
const Srv2Cli_Game_InviteFailed* gmMsg = (const Srv2Cli_Game_InviteFailed*)message->netMsg;
return gmMsg->operationId;
}
return 0;
}
int pyGameCliInviteFailedMsg::Error() const
{
if (message)
{
const Srv2Cli_Game_InviteFailed* gmMsg = (const Srv2Cli_Game_InviteFailed*)message->netMsg;
return gmMsg->error;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
pyGameCliOwnerChangeMsg::pyGameCliOwnerChangeMsg(): pyGameCliMsg() {}
pyGameCliOwnerChangeMsg::pyGameCliOwnerChangeMsg(pfGameCliMsg* msg): pyGameCliMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Game_OwnerChange))
message = nil; // wrong type, just clear it out
}
unsigned long pyGameCliOwnerChangeMsg::OwnerID() const
{
if (message)
{
const Srv2Cli_Game_OwnerChange* gmMsg = (const Srv2Cli_Game_OwnerChange*)message->netMsg;
return gmMsg->ownerId;
}
return 0;
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyGameCliMsg.h"
#include "pyGameCli.h"
#include "TicTacToe\pyTTTMsg.h"
#include "Heek\pyHeekMsg.h"
#include "Marker\pyMarkerMsg.h"
#include "BlueSpiral\pyBlueSpiralMsg.h"
#include "ClimbingWall\pyClimbingWallMsg.h"
#include "VarSync/pyVarSyncMsg.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base game cli msg class
//
pyGameCliMsg::pyGameCliMsg(): message(nil) {}
pyGameCliMsg::pyGameCliMsg(pfGameCliMsg* msg): message(msg) {}
int pyGameCliMsg::GetType() const
{
if (message)
{
switch (message->netMsg->messageId)
{
case kSrv2Cli_Game_PlayerJoined:
case kSrv2Cli_Game_PlayerLeft:
case kSrv2Cli_Game_InviteFailed:
case kSrv2Cli_Game_OwnerChange:
return message->netMsg->messageId; // just return the type straight up
}
// if we get here, it's probably a game message, check the game guid
if (message->gameCli->GetGameTypeId() == kGameTypeId_TicTacToe)
return kPyGameCliTTTMsg;
if (message->gameCli->GetGameTypeId() == kGameTypeId_Heek)
return kPyGameCliHeekMsg;
if (message->gameCli->GetGameTypeId() == kGameTypeId_Marker)
return kPyGameCliMarkerMsg;
if (message->gameCli->GetGameTypeId() == kGameTypeId_BlueSpiral)
return kPyGameCliBlueSpiralMsg;
if (message->gameCli->GetGameTypeId() == kGameTypeId_ClimbingWall)
return kPyGameCliClimbingWallMsg;
if (message->gameCli->GetGameTypeId() == kGameTypeId_VarSync)
return kPyGameCliVarSyncMsg;
}
return -1;
}
PyObject* pyGameCliMsg::GetGameCli() const
{
if (message && (message->gameCli))
return pyGameCli::New(message->gameCli);
PYTHON_RETURN_NONE;
}
PyObject* pyGameCliMsg::UpcastToFinalGameCliMsg() const
{
if (!message)
PYTHON_RETURN_NONE;
switch (message->netMsg->messageId)
{
case kSrv2Cli_Game_PlayerJoined:
return pyGameCliPlayerJoinedMsg::New(message);
case kSrv2Cli_Game_PlayerLeft:
return pyGameCliPlayerLeftMsg::New(message);
case kSrv2Cli_Game_InviteFailed:
return pyGameCliInviteFailedMsg::New(message);
case kSrv2Cli_Game_OwnerChange:
return pyGameCliOwnerChangeMsg::New(message);
default:
PYTHON_RETURN_NONE;
}
}
PyObject* pyGameCliMsg::UpcastToGameMsg() const
{
if (!message)
PYTHON_RETURN_NONE;
const Uuid& gameTypeId = message->gameCli->GetGameTypeId();
if (gameTypeId == kGameTypeId_TicTacToe)
return pyTTTMsg::New(message);
else if (gameTypeId == kGameTypeId_Heek)
return pyHeekMsg::New(message);
else if (gameTypeId == kGameTypeId_Marker)
return pyMarkerMsg::New(message);
else if (gameTypeId == kGameTypeId_BlueSpiral)
return pyBlueSpiralMsg::New(message);
else if (gameTypeId == kGameTypeId_ClimbingWall)
return pyClimbingWallMsg::New(message);
else if (gameTypeId == kGameTypeId_VarSync)
return pyVarSyncMsg::New(message);
else
PYTHON_RETURN_NONE;
}
///////////////////////////////////////////////////////////////////////////////
//
// The different messages we can receive
//
pyGameCliPlayerJoinedMsg::pyGameCliPlayerJoinedMsg(): pyGameCliMsg() {}
pyGameCliPlayerJoinedMsg::pyGameCliPlayerJoinedMsg(pfGameCliMsg* msg): pyGameCliMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Game_PlayerJoined))
message = nil; // wrong type, just clear it out
}
unsigned long pyGameCliPlayerJoinedMsg::PlayerID() const
{
if (message)
{
const Srv2Cli_Game_PlayerJoined* gmMsg = (const Srv2Cli_Game_PlayerJoined*)message->netMsg;
return gmMsg->playerId;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
pyGameCliPlayerLeftMsg::pyGameCliPlayerLeftMsg(): pyGameCliMsg() {}
pyGameCliPlayerLeftMsg::pyGameCliPlayerLeftMsg(pfGameCliMsg* msg): pyGameCliMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Game_PlayerLeft))
message = nil; // wrong type, just clear it out
}
unsigned long pyGameCliPlayerLeftMsg::PlayerID() const
{
if (message)
{
const Srv2Cli_Game_PlayerLeft* gmMsg = (const Srv2Cli_Game_PlayerLeft*)message->netMsg;
return gmMsg->playerId;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
pyGameCliInviteFailedMsg::pyGameCliInviteFailedMsg(): pyGameCliMsg() {}
pyGameCliInviteFailedMsg::pyGameCliInviteFailedMsg(pfGameCliMsg* msg): pyGameCliMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Game_InviteFailed))
message = nil; // wrong type, just clear it out
}
unsigned long pyGameCliInviteFailedMsg::InviteeID() const
{
if (message)
{
const Srv2Cli_Game_InviteFailed* gmMsg = (const Srv2Cli_Game_InviteFailed*)message->netMsg;
return gmMsg->inviteeId;
}
return 0;
}
unsigned long pyGameCliInviteFailedMsg::OperationID() const
{
if (message)
{
const Srv2Cli_Game_InviteFailed* gmMsg = (const Srv2Cli_Game_InviteFailed*)message->netMsg;
return gmMsg->operationId;
}
return 0;
}
int pyGameCliInviteFailedMsg::Error() const
{
if (message)
{
const Srv2Cli_Game_InviteFailed* gmMsg = (const Srv2Cli_Game_InviteFailed*)message->netMsg;
return gmMsg->error;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
pyGameCliOwnerChangeMsg::pyGameCliOwnerChangeMsg(): pyGameCliMsg() {}
pyGameCliOwnerChangeMsg::pyGameCliOwnerChangeMsg(pfGameCliMsg* msg): pyGameCliMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_Game_OwnerChange))
message = nil; // wrong type, just clear it out
}
unsigned long pyGameCliOwnerChangeMsg::OwnerID() const
{
if (message)
{
const Srv2Cli_Game_OwnerChange* gmMsg = (const Srv2Cli_Game_OwnerChange*)message->netMsg;
return gmMsg->ownerId;
}
return 0;
}

View File

@ -1,161 +1,161 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyGameCliMsg_h
#define pyGameCliMsg_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: pyGameCliMsg
//
// PURPOSE: Class wrapper for game client messages
//
#include "pfGameMgr/pfGameMgr.h"
#include <python.h>
#include "../pyGlueHelpers.h"
class pyGameCliMsg
{
protected:
pfGameCliMsg* message;
pyGameCliMsg();
pyGameCliMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_EXPOSE_TYPE; // so we can subclass
PYTHON_CLASS_NEW_FRIEND(ptGameCliMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameCliMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameCliMsg); // converts a PyObject to a pyGameCliMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaConstantsClasses(PyObject* m);
int GetType() const;
PyObject* GetGameCli() const; // returns ptGameCli
PyObject* UpcastToFinalGameCliMsg() const; // returns it upcasted to player joined/left/invite/owner change message
PyObject* UpcastToGameMsg() const; // returns it upcasted to a game's message base class
// for convenience, we define our own message types, one message type for each game, so that we can have
// a "base class" for each game's messages. Anything under kCli2Srv_NumGameMsgIds keeps their normal type
// (and is exposed to python here), but anything above it has the message code look at the game type and
// return the "message type" indicating what game the message is from
enum pyGameCliMsgType
{
kPyGameCliMsgTypeStart = kCli2Srv_NumGameMsgIds,
kPyGameCliTTTMsg, // Tick Tack Toe game messages
kPyGameCliHeekMsg, // Heek game messages
kPyGameCliMarkerMsg, // Marker game messages
kPyGameCliBlueSpiralMsg, // Blue Spiral game messages
kPyGameCliClimbingWallMsg, // Climbing Wall game messages
kPyGameCliVarSyncMsg, // Var Sync game messages
};
};
///////////////////////////////////////////////////////////////////////////////
class pyGameCliPlayerJoinedMsg : public pyGameCliMsg
{
protected:
pyGameCliPlayerJoinedMsg();
pyGameCliPlayerJoinedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptGameCliPlayerJoinedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameCliPlayerJoinedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameCliPlayerJoinedMsg); // converts a PyObject to a pyGameCliPlayerJoinedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
unsigned long PlayerID() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyGameCliPlayerLeftMsg : public pyGameCliMsg
{
protected:
pyGameCliPlayerLeftMsg();
pyGameCliPlayerLeftMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptGameCliPlayerLeftMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameCliPlayerLeftMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameCliPlayerLeftMsg); // converts a PyObject to a pyGameCliPlayerLeftMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
unsigned long PlayerID() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyGameCliInviteFailedMsg : public pyGameCliMsg
{
protected:
pyGameCliInviteFailedMsg();
pyGameCliInviteFailedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptGameCliInviteFailedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameCliInviteFailedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameCliInviteFailedMsg); // converts a PyObject to a pyGameCliInviteFailedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaConstantsClasses(PyObject* m);
unsigned long InviteeID() const;
unsigned long OperationID() const;
int Error() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyGameCliOwnerChangeMsg : public pyGameCliMsg
{
protected:
pyGameCliOwnerChangeMsg();
pyGameCliOwnerChangeMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptGameCliOwnerChangeMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameCliOwnerChangeMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameCliOwnerChangeMsg); // converts a PyObject to a pyGameCliOwnerChangeMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
unsigned long OwnerID() const;
};
#endif // pyGameCliMsg_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyGameCliMsg_h
#define pyGameCliMsg_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: pyGameCliMsg
//
// PURPOSE: Class wrapper for game client messages
//
#include "pfGameMgr/pfGameMgr.h"
#include <python.h>
#include "../pyGlueHelpers.h"
class pyGameCliMsg
{
protected:
pfGameCliMsg* message;
pyGameCliMsg();
pyGameCliMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_EXPOSE_TYPE; // so we can subclass
PYTHON_CLASS_NEW_FRIEND(ptGameCliMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameCliMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameCliMsg); // converts a PyObject to a pyGameCliMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaConstantsClasses(PyObject* m);
int GetType() const;
PyObject* GetGameCli() const; // returns ptGameCli
PyObject* UpcastToFinalGameCliMsg() const; // returns it upcasted to player joined/left/invite/owner change message
PyObject* UpcastToGameMsg() const; // returns it upcasted to a game's message base class
// for convenience, we define our own message types, one message type for each game, so that we can have
// a "base class" for each game's messages. Anything under kCli2Srv_NumGameMsgIds keeps their normal type
// (and is exposed to python here), but anything above it has the message code look at the game type and
// return the "message type" indicating what game the message is from
enum pyGameCliMsgType
{
kPyGameCliMsgTypeStart = kCli2Srv_NumGameMsgIds,
kPyGameCliTTTMsg, // Tick Tack Toe game messages
kPyGameCliHeekMsg, // Heek game messages
kPyGameCliMarkerMsg, // Marker game messages
kPyGameCliBlueSpiralMsg, // Blue Spiral game messages
kPyGameCliClimbingWallMsg, // Climbing Wall game messages
kPyGameCliVarSyncMsg, // Var Sync game messages
};
};
///////////////////////////////////////////////////////////////////////////////
class pyGameCliPlayerJoinedMsg : public pyGameCliMsg
{
protected:
pyGameCliPlayerJoinedMsg();
pyGameCliPlayerJoinedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptGameCliPlayerJoinedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameCliPlayerJoinedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameCliPlayerJoinedMsg); // converts a PyObject to a pyGameCliPlayerJoinedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
unsigned long PlayerID() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyGameCliPlayerLeftMsg : public pyGameCliMsg
{
protected:
pyGameCliPlayerLeftMsg();
pyGameCliPlayerLeftMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptGameCliPlayerLeftMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameCliPlayerLeftMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameCliPlayerLeftMsg); // converts a PyObject to a pyGameCliPlayerLeftMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
unsigned long PlayerID() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyGameCliInviteFailedMsg : public pyGameCliMsg
{
protected:
pyGameCliInviteFailedMsg();
pyGameCliInviteFailedMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptGameCliInviteFailedMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameCliInviteFailedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameCliInviteFailedMsg); // converts a PyObject to a pyGameCliInviteFailedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaConstantsClasses(PyObject* m);
unsigned long InviteeID() const;
unsigned long OperationID() const;
int Error() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyGameCliOwnerChangeMsg : public pyGameCliMsg
{
protected:
pyGameCliOwnerChangeMsg();
pyGameCliOwnerChangeMsg(pfGameCliMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptGameCliOwnerChangeMsg);
static PyObject* New(pfGameCliMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameCliOwnerChangeMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameCliOwnerChangeMsg); // converts a PyObject to a pyGameCliOwnerChangeMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
unsigned long OwnerID() const;
};
#endif // pyGameCliMsg_h

View File

@ -1,297 +1,297 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyGameCliMsg.h"
#include "../pyEnum.h"
#include <python.h>
///////////////////////////////////////////////////////////////////////////////
//
// Base game client msg class
//
PYTHON_CLASS_DEFINITION(ptGameCliMsg, pyGameCliMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptGameCliMsg, pyGameCliMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameCliMsg)
PYTHON_NO_INIT_DEFINITION(ptGameCliMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCliMsg, getType)
{
return PyInt_FromLong(self->fThis->GetType());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCliMsg, getGameCli)
{
return self->fThis->GetGameCli();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCliMsg, upcastToFinalGameCliMsg)
{
return self->fThis->UpcastToFinalGameCliMsg();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCliMsg, upcastToGameMsg)
{
return self->fThis->UpcastToGameMsg();
}
PYTHON_START_METHODS_TABLE(ptGameCliMsg)
PYTHON_METHOD_NOARGS(ptGameCliMsg, getType, "Returns the type of the message (see PtGameCliMsgTypes)"),
PYTHON_METHOD_NOARGS(ptGameCliMsg, getGameCli, "Returns the game client associated with this message"),
PYTHON_METHOD_NOARGS(ptGameCliMsg, upcastToFinalGameCliMsg, "Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)"),
PYTHON_METHOD_NOARGS(ptGameCliMsg, upcastToGameMsg, "Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE(ptGameCliMsg, "Message from the game server from a game");
PYTHON_EXPOSE_TYPE_DEFINITION(ptGameCliMsg, pyGameCliMsg);
// required functions for PyObject interoperability
PyObject* pyGameCliMsg::New(pfGameCliMsg* msg)
{
ptGameCliMsg *newObj = (ptGameCliMsg*)ptGameCliMsg_type.tp_new(&ptGameCliMsg_type, NULL, NULL);
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptGameCliMsg, pyGameCliMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameCliMsg, pyGameCliMsg)
// Module and method definitions
void pyGameCliMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptGameCliMsg);
PYTHON_CLASS_IMPORT_END(m);
}
void pyGameCliMsg::AddPlasmaConstantsClasses(PyObject* m)
{
PYTHON_ENUM_START(PtGameCliMsgTypes);
PYTHON_ENUM_ELEMENT(PtGameCliMsgTypes, kGameCliPlayerJoinedMsg, kSrv2Cli_Game_PlayerJoined);
PYTHON_ENUM_ELEMENT(PtGameCliMsgTypes, kGameCliPlayerLeftMsg, kSrv2Cli_Game_PlayerLeft);
PYTHON_ENUM_ELEMENT(PtGameCliMsgTypes, kGameCliInviteFailedMsg, kSrv2Cli_Game_InviteFailed);
PYTHON_ENUM_ELEMENT(PtGameCliMsgTypes, kGameCliOwnerChangeMsg, kSrv2Cli_Game_OwnerChange);
PYTHON_ENUM_ELEMENT(PtGameCliMsgTypes, kGameCliTTTMsg, kPyGameCliTTTMsg);
PYTHON_ENUM_ELEMENT(PtGameCliMsgTypes, kGameCliHeekMsg, kPyGameCliHeekMsg);
PYTHON_ENUM_ELEMENT(PtGameCliMsgTypes, kGameCliMarkerMsg, kPyGameCliMarkerMsg);
PYTHON_ENUM_ELEMENT(PtGameCliMsgTypes, kGameCliBlueSpiralMsg, kPyGameCliBlueSpiralMsg);
PYTHON_ENUM_ELEMENT(PtGameCliMsgTypes, kGameCliClimbingWallMsg, kPyGameCliClimbingWallMsg);
PYTHON_ENUM_ELEMENT(PtGameCliMsgTypes, kGameCliVarSyncMsg, kPyGameCliVarSyncMsg);
PYTHON_ENUM_END(m, PtGameCliMsgTypes);
}
///////////////////////////////////////////////////////////////////////////////
//
// Game client message subclasses
//
PYTHON_CLASS_DEFINITION(ptGameCliPlayerJoinedMsg, pyGameCliPlayerJoinedMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptGameCliPlayerJoinedMsg, pyGameCliPlayerJoinedMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameCliPlayerJoinedMsg)
PYTHON_NO_INIT_DEFINITION(ptGameCliPlayerJoinedMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCliPlayerJoinedMsg, playerID)
{
return PyLong_FromUnsignedLong(self->fThis->PlayerID());
}
PYTHON_START_METHODS_TABLE(ptGameCliPlayerJoinedMsg)
PYTHON_METHOD_NOARGS(ptGameCliPlayerJoinedMsg, playerID, "Returns the player's ID number"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptGameCliPlayerJoinedMsg, pyGameCliMsg, "Game client message when a player joined message is received");
// required functions for PyObject interoperability
PyObject* pyGameCliPlayerJoinedMsg::New(pfGameCliMsg* msg)
{
ptGameCliPlayerJoinedMsg *newObj = (ptGameCliPlayerJoinedMsg*)ptGameCliPlayerJoinedMsg_type.tp_new(&ptGameCliPlayerJoinedMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_Game_PlayerJoined))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptGameCliPlayerJoinedMsg, pyGameCliPlayerJoinedMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameCliPlayerJoinedMsg, pyGameCliPlayerJoinedMsg)
// Module and method definitions
void pyGameCliPlayerJoinedMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptGameCliPlayerJoinedMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptGameCliPlayerLeftMsg, pyGameCliPlayerLeftMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptGameCliPlayerLeftMsg, pyGameCliPlayerLeftMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameCliPlayerLeftMsg)
PYTHON_NO_INIT_DEFINITION(ptGameCliPlayerLeftMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCliPlayerLeftMsg, playerID)
{
return PyLong_FromUnsignedLong(self->fThis->PlayerID());
}
PYTHON_START_METHODS_TABLE(ptGameCliPlayerLeftMsg)
PYTHON_METHOD_NOARGS(ptGameCliPlayerLeftMsg, playerID, "Returns the player's ID number"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptGameCliPlayerLeftMsg, pyGameCliMsg, "Game client message when a player left message is received");
// required functions for PyObject interoperability
PyObject* pyGameCliPlayerLeftMsg::New(pfGameCliMsg* msg)
{
ptGameCliPlayerLeftMsg *newObj = (ptGameCliPlayerLeftMsg*)ptGameCliPlayerLeftMsg_type.tp_new(&ptGameCliPlayerLeftMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_Game_PlayerLeft))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptGameCliPlayerLeftMsg, pyGameCliPlayerLeftMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameCliPlayerLeftMsg, pyGameCliPlayerLeftMsg)
// Module and method definitions
void pyGameCliPlayerLeftMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptGameCliPlayerLeftMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptGameCliInviteFailedMsg, pyGameCliInviteFailedMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptGameCliInviteFailedMsg, pyGameCliInviteFailedMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameCliInviteFailedMsg)
PYTHON_NO_INIT_DEFINITION(ptGameCliInviteFailedMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCliInviteFailedMsg, inviteeID)
{
return PyLong_FromUnsignedLong(self->fThis->InviteeID());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCliInviteFailedMsg, operationID)
{
return PyLong_FromUnsignedLong(self->fThis->OperationID());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCliInviteFailedMsg, error)
{
return PyLong_FromLong(self->fThis->Error());
}
PYTHON_START_METHODS_TABLE(ptGameCliInviteFailedMsg)
PYTHON_METHOD_NOARGS(ptGameCliInviteFailedMsg, inviteeID, "Returns the invitee's ID number"),
PYTHON_METHOD_NOARGS(ptGameCliInviteFailedMsg, operationID, "Returns the operation's ID number"),
PYTHON_METHOD_NOARGS(ptGameCliInviteFailedMsg, error, "Returns the error value (See PtGameCliInviteErrors)"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptGameCliInviteFailedMsg, pyGameCliMsg, "Game client message when an invite failed message is received");
// required functions for PyObject interoperability
PyObject* pyGameCliInviteFailedMsg::New(pfGameCliMsg* msg)
{
ptGameCliInviteFailedMsg *newObj = (ptGameCliInviteFailedMsg*)ptGameCliInviteFailedMsg_type.tp_new(&ptGameCliInviteFailedMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_Game_InviteFailed))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptGameCliInviteFailedMsg, pyGameCliInviteFailedMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameCliInviteFailedMsg, pyGameCliInviteFailedMsg)
// Module and method definitions
void pyGameCliInviteFailedMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptGameCliInviteFailedMsg);
PYTHON_CLASS_IMPORT_END(m);
}
void pyGameCliInviteFailedMsg::AddPlasmaConstantsClasses(PyObject* m)
{
PYTHON_ENUM_START(PtGameCliInviteErrors);
PYTHON_ENUM_ELEMENT(PtGameCliInviteErrors, kGameInviteSuccess, kGameInviteSuccess);
PYTHON_ENUM_ELEMENT(PtGameCliInviteErrors, kGameInviteErrNotOwner, kGameInviteErrNotOwner);
PYTHON_ENUM_ELEMENT(PtGameCliInviteErrors, kGameInviteErrAlreadyInvited, kGameInviteErrAlreadyInvited);
PYTHON_ENUM_ELEMENT(PtGameCliInviteErrors, kGameInviteErrAlreadyJoined, kGameInviteErrAlreadyJoined);
PYTHON_ENUM_ELEMENT(PtGameCliInviteErrors, kGameInviteErrGameStarted, kGameInviteErrGameStarted);
PYTHON_ENUM_ELEMENT(PtGameCliInviteErrors, kGameInviteErrGameOver, kGameInviteErrGameOver);
PYTHON_ENUM_ELEMENT(PtGameCliInviteErrors, kGameInviteErrGameFull, kGameInviteErrGameFull);
PYTHON_ENUM_ELEMENT(PtGameCliInviteErrors, kGameInviteErrNoJoin, kGameInviteErrNoJoin);
PYTHON_ENUM_END(m, PtGameCliInviteErrors);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptGameCliOwnerChangeMsg, pyGameCliOwnerChangeMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptGameCliOwnerChangeMsg, pyGameCliOwnerChangeMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameCliOwnerChangeMsg)
PYTHON_NO_INIT_DEFINITION(ptGameCliOwnerChangeMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCliOwnerChangeMsg, ownerID)
{
return PyLong_FromUnsignedLong(self->fThis->OwnerID());
}
PYTHON_START_METHODS_TABLE(ptGameCliOwnerChangeMsg)
PYTHON_METHOD_NOARGS(ptGameCliOwnerChangeMsg, ownerID, "Returns the owner's ID number"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptGameCliOwnerChangeMsg, pyGameCliMsg, "Game client message when a owner change message is received");
// required functions for PyObject interoperability
PyObject* pyGameCliOwnerChangeMsg::New(pfGameCliMsg* msg)
{
ptGameCliOwnerChangeMsg *newObj = (ptGameCliOwnerChangeMsg*)ptGameCliOwnerChangeMsg_type.tp_new(&ptGameCliOwnerChangeMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_Game_OwnerChange))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptGameCliOwnerChangeMsg, pyGameCliOwnerChangeMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameCliOwnerChangeMsg, pyGameCliOwnerChangeMsg)
// Module and method definitions
void pyGameCliOwnerChangeMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptGameCliOwnerChangeMsg);
PYTHON_CLASS_IMPORT_END(m);
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyGameCliMsg.h"
#include "../pyEnum.h"
#include <python.h>
///////////////////////////////////////////////////////////////////////////////
//
// Base game client msg class
//
PYTHON_CLASS_DEFINITION(ptGameCliMsg, pyGameCliMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptGameCliMsg, pyGameCliMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameCliMsg)
PYTHON_NO_INIT_DEFINITION(ptGameCliMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCliMsg, getType)
{
return PyInt_FromLong(self->fThis->GetType());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCliMsg, getGameCli)
{
return self->fThis->GetGameCli();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCliMsg, upcastToFinalGameCliMsg)
{
return self->fThis->UpcastToFinalGameCliMsg();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCliMsg, upcastToGameMsg)
{
return self->fThis->UpcastToGameMsg();
}
PYTHON_START_METHODS_TABLE(ptGameCliMsg)
PYTHON_METHOD_NOARGS(ptGameCliMsg, getType, "Returns the type of the message (see PtGameCliMsgTypes)"),
PYTHON_METHOD_NOARGS(ptGameCliMsg, getGameCli, "Returns the game client associated with this message"),
PYTHON_METHOD_NOARGS(ptGameCliMsg, upcastToFinalGameCliMsg, "Returns this message as the game client message it is (player joined, player left, invite failed, or owner change)"),
PYTHON_METHOD_NOARGS(ptGameCliMsg, upcastToGameMsg, "Returns this message as the base class of message for the game it is associated with (ttt, heek, marker, etc)"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE(ptGameCliMsg, "Message from the game server from a game");
PYTHON_EXPOSE_TYPE_DEFINITION(ptGameCliMsg, pyGameCliMsg);
// required functions for PyObject interoperability
PyObject* pyGameCliMsg::New(pfGameCliMsg* msg)
{
ptGameCliMsg *newObj = (ptGameCliMsg*)ptGameCliMsg_type.tp_new(&ptGameCliMsg_type, NULL, NULL);
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptGameCliMsg, pyGameCliMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameCliMsg, pyGameCliMsg)
// Module and method definitions
void pyGameCliMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptGameCliMsg);
PYTHON_CLASS_IMPORT_END(m);
}
void pyGameCliMsg::AddPlasmaConstantsClasses(PyObject* m)
{
PYTHON_ENUM_START(PtGameCliMsgTypes);
PYTHON_ENUM_ELEMENT(PtGameCliMsgTypes, kGameCliPlayerJoinedMsg, kSrv2Cli_Game_PlayerJoined);
PYTHON_ENUM_ELEMENT(PtGameCliMsgTypes, kGameCliPlayerLeftMsg, kSrv2Cli_Game_PlayerLeft);
PYTHON_ENUM_ELEMENT(PtGameCliMsgTypes, kGameCliInviteFailedMsg, kSrv2Cli_Game_InviteFailed);
PYTHON_ENUM_ELEMENT(PtGameCliMsgTypes, kGameCliOwnerChangeMsg, kSrv2Cli_Game_OwnerChange);
PYTHON_ENUM_ELEMENT(PtGameCliMsgTypes, kGameCliTTTMsg, kPyGameCliTTTMsg);
PYTHON_ENUM_ELEMENT(PtGameCliMsgTypes, kGameCliHeekMsg, kPyGameCliHeekMsg);
PYTHON_ENUM_ELEMENT(PtGameCliMsgTypes, kGameCliMarkerMsg, kPyGameCliMarkerMsg);
PYTHON_ENUM_ELEMENT(PtGameCliMsgTypes, kGameCliBlueSpiralMsg, kPyGameCliBlueSpiralMsg);
PYTHON_ENUM_ELEMENT(PtGameCliMsgTypes, kGameCliClimbingWallMsg, kPyGameCliClimbingWallMsg);
PYTHON_ENUM_ELEMENT(PtGameCliMsgTypes, kGameCliVarSyncMsg, kPyGameCliVarSyncMsg);
PYTHON_ENUM_END(m, PtGameCliMsgTypes);
}
///////////////////////////////////////////////////////////////////////////////
//
// Game client message subclasses
//
PYTHON_CLASS_DEFINITION(ptGameCliPlayerJoinedMsg, pyGameCliPlayerJoinedMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptGameCliPlayerJoinedMsg, pyGameCliPlayerJoinedMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameCliPlayerJoinedMsg)
PYTHON_NO_INIT_DEFINITION(ptGameCliPlayerJoinedMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCliPlayerJoinedMsg, playerID)
{
return PyLong_FromUnsignedLong(self->fThis->PlayerID());
}
PYTHON_START_METHODS_TABLE(ptGameCliPlayerJoinedMsg)
PYTHON_METHOD_NOARGS(ptGameCliPlayerJoinedMsg, playerID, "Returns the player's ID number"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptGameCliPlayerJoinedMsg, pyGameCliMsg, "Game client message when a player joined message is received");
// required functions for PyObject interoperability
PyObject* pyGameCliPlayerJoinedMsg::New(pfGameCliMsg* msg)
{
ptGameCliPlayerJoinedMsg *newObj = (ptGameCliPlayerJoinedMsg*)ptGameCliPlayerJoinedMsg_type.tp_new(&ptGameCliPlayerJoinedMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_Game_PlayerJoined))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptGameCliPlayerJoinedMsg, pyGameCliPlayerJoinedMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameCliPlayerJoinedMsg, pyGameCliPlayerJoinedMsg)
// Module and method definitions
void pyGameCliPlayerJoinedMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptGameCliPlayerJoinedMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptGameCliPlayerLeftMsg, pyGameCliPlayerLeftMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptGameCliPlayerLeftMsg, pyGameCliPlayerLeftMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameCliPlayerLeftMsg)
PYTHON_NO_INIT_DEFINITION(ptGameCliPlayerLeftMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCliPlayerLeftMsg, playerID)
{
return PyLong_FromUnsignedLong(self->fThis->PlayerID());
}
PYTHON_START_METHODS_TABLE(ptGameCliPlayerLeftMsg)
PYTHON_METHOD_NOARGS(ptGameCliPlayerLeftMsg, playerID, "Returns the player's ID number"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptGameCliPlayerLeftMsg, pyGameCliMsg, "Game client message when a player left message is received");
// required functions for PyObject interoperability
PyObject* pyGameCliPlayerLeftMsg::New(pfGameCliMsg* msg)
{
ptGameCliPlayerLeftMsg *newObj = (ptGameCliPlayerLeftMsg*)ptGameCliPlayerLeftMsg_type.tp_new(&ptGameCliPlayerLeftMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_Game_PlayerLeft))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptGameCliPlayerLeftMsg, pyGameCliPlayerLeftMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameCliPlayerLeftMsg, pyGameCliPlayerLeftMsg)
// Module and method definitions
void pyGameCliPlayerLeftMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptGameCliPlayerLeftMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptGameCliInviteFailedMsg, pyGameCliInviteFailedMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptGameCliInviteFailedMsg, pyGameCliInviteFailedMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameCliInviteFailedMsg)
PYTHON_NO_INIT_DEFINITION(ptGameCliInviteFailedMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCliInviteFailedMsg, inviteeID)
{
return PyLong_FromUnsignedLong(self->fThis->InviteeID());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCliInviteFailedMsg, operationID)
{
return PyLong_FromUnsignedLong(self->fThis->OperationID());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCliInviteFailedMsg, error)
{
return PyLong_FromLong(self->fThis->Error());
}
PYTHON_START_METHODS_TABLE(ptGameCliInviteFailedMsg)
PYTHON_METHOD_NOARGS(ptGameCliInviteFailedMsg, inviteeID, "Returns the invitee's ID number"),
PYTHON_METHOD_NOARGS(ptGameCliInviteFailedMsg, operationID, "Returns the operation's ID number"),
PYTHON_METHOD_NOARGS(ptGameCliInviteFailedMsg, error, "Returns the error value (See PtGameCliInviteErrors)"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptGameCliInviteFailedMsg, pyGameCliMsg, "Game client message when an invite failed message is received");
// required functions for PyObject interoperability
PyObject* pyGameCliInviteFailedMsg::New(pfGameCliMsg* msg)
{
ptGameCliInviteFailedMsg *newObj = (ptGameCliInviteFailedMsg*)ptGameCliInviteFailedMsg_type.tp_new(&ptGameCliInviteFailedMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_Game_InviteFailed))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptGameCliInviteFailedMsg, pyGameCliInviteFailedMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameCliInviteFailedMsg, pyGameCliInviteFailedMsg)
// Module and method definitions
void pyGameCliInviteFailedMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptGameCliInviteFailedMsg);
PYTHON_CLASS_IMPORT_END(m);
}
void pyGameCliInviteFailedMsg::AddPlasmaConstantsClasses(PyObject* m)
{
PYTHON_ENUM_START(PtGameCliInviteErrors);
PYTHON_ENUM_ELEMENT(PtGameCliInviteErrors, kGameInviteSuccess, kGameInviteSuccess);
PYTHON_ENUM_ELEMENT(PtGameCliInviteErrors, kGameInviteErrNotOwner, kGameInviteErrNotOwner);
PYTHON_ENUM_ELEMENT(PtGameCliInviteErrors, kGameInviteErrAlreadyInvited, kGameInviteErrAlreadyInvited);
PYTHON_ENUM_ELEMENT(PtGameCliInviteErrors, kGameInviteErrAlreadyJoined, kGameInviteErrAlreadyJoined);
PYTHON_ENUM_ELEMENT(PtGameCliInviteErrors, kGameInviteErrGameStarted, kGameInviteErrGameStarted);
PYTHON_ENUM_ELEMENT(PtGameCliInviteErrors, kGameInviteErrGameOver, kGameInviteErrGameOver);
PYTHON_ENUM_ELEMENT(PtGameCliInviteErrors, kGameInviteErrGameFull, kGameInviteErrGameFull);
PYTHON_ENUM_ELEMENT(PtGameCliInviteErrors, kGameInviteErrNoJoin, kGameInviteErrNoJoin);
PYTHON_ENUM_END(m, PtGameCliInviteErrors);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptGameCliOwnerChangeMsg, pyGameCliOwnerChangeMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptGameCliOwnerChangeMsg, pyGameCliOwnerChangeMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameCliOwnerChangeMsg)
PYTHON_NO_INIT_DEFINITION(ptGameCliOwnerChangeMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptGameCliOwnerChangeMsg, ownerID)
{
return PyLong_FromUnsignedLong(self->fThis->OwnerID());
}
PYTHON_START_METHODS_TABLE(ptGameCliOwnerChangeMsg)
PYTHON_METHOD_NOARGS(ptGameCliOwnerChangeMsg, ownerID, "Returns the owner's ID number"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptGameCliOwnerChangeMsg, pyGameCliMsg, "Game client message when a owner change message is received");
// required functions for PyObject interoperability
PyObject* pyGameCliOwnerChangeMsg::New(pfGameCliMsg* msg)
{
ptGameCliOwnerChangeMsg *newObj = (ptGameCliOwnerChangeMsg*)ptGameCliOwnerChangeMsg_type.tp_new(&ptGameCliOwnerChangeMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_Game_OwnerChange))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptGameCliOwnerChangeMsg, pyGameCliOwnerChangeMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameCliOwnerChangeMsg, pyGameCliOwnerChangeMsg)
// Module and method definitions
void pyGameCliOwnerChangeMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptGameCliOwnerChangeMsg);
PYTHON_CLASS_IMPORT_END(m);
}

View File

@ -1,146 +1,146 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyGameMgrMsg.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base game mgr msg class
//
pyGameMgrMsg::pyGameMgrMsg(): message(nil) {}
pyGameMgrMsg::pyGameMgrMsg(pfGameMgrMsg* msg): message(msg) {}
int pyGameMgrMsg::GetType() const
{
if (message)
return message->netMsg->messageId;
return -1;
}
PyObject* pyGameMgrMsg::UpcastToInviteReceivedMsg() const
{
if (!message)
PYTHON_RETURN_NONE;
if (message->netMsg->messageId != kSrv2Cli_GameMgr_InviteReceived)
PYTHON_RETURN_NONE;
return pyGameMgrInviteReceivedMsg::New(message);
}
PyObject* pyGameMgrMsg::UpcastToInviteRevokedMsg() const
{
if (!message)
PYTHON_RETURN_NONE;
if (message->netMsg->messageId != kSrv2Cli_GameMgr_InviteRevoked)
PYTHON_RETURN_NONE;
return pyGameMgrInviteRevokedMsg::New(message);
}
///////////////////////////////////////////////////////////////////////////////
//
// The different messages we can receive
//
pyGameMgrInviteReceivedMsg::pyGameMgrInviteReceivedMsg(): pyGameMgrMsg() {}
pyGameMgrInviteReceivedMsg::pyGameMgrInviteReceivedMsg(pfGameMgrMsg* msg): pyGameMgrMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_GameMgr_InviteReceived))
message = nil; // wrong type, just clear it out
}
unsigned long pyGameMgrInviteReceivedMsg::InviterID() const
{
if (message)
{
const Srv2Cli_GameMgr_InviteReceived* gmMsg = (const Srv2Cli_GameMgr_InviteReceived*)message->netMsg;
return gmMsg->inviterId;
}
return 0;
}
std::wstring pyGameMgrInviteReceivedMsg::GameTypeID() const
{
if (message)
{
const Srv2Cli_GameMgr_InviteReceived* gmMsg = (const Srv2Cli_GameMgr_InviteReceived*)message->netMsg;
wchar_t buffer[256];
GuidToString(gmMsg->gameTypeId, buffer, arrsize(buffer));
return buffer;
}
return L"";
}
unsigned long pyGameMgrInviteReceivedMsg::NewGameID() const
{
if (message)
{
const Srv2Cli_GameMgr_InviteReceived* gmMsg = (const Srv2Cli_GameMgr_InviteReceived*)message->netMsg;
return gmMsg->newGameId;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
pyGameMgrInviteRevokedMsg::pyGameMgrInviteRevokedMsg(): pyGameMgrMsg() {}
pyGameMgrInviteRevokedMsg::pyGameMgrInviteRevokedMsg(pfGameMgrMsg* msg): pyGameMgrMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_GameMgr_InviteRevoked))
message = nil; // wrong type, just clear it out
}
unsigned long pyGameMgrInviteRevokedMsg::InviterID() const
{
if (message)
{
const Srv2Cli_GameMgr_InviteRevoked* gmMsg = (const Srv2Cli_GameMgr_InviteRevoked*)message->netMsg;
return gmMsg->inviterId;
}
return 0;
}
std::wstring pyGameMgrInviteRevokedMsg::GameTypeID() const
{
if (message)
{
const Srv2Cli_GameMgr_InviteRevoked* gmMsg = (const Srv2Cli_GameMgr_InviteRevoked*)message->netMsg;
wchar_t buffer[256];
GuidToString(gmMsg->gameTypeId, buffer, arrsize(buffer));
return buffer;
}
return L"";
}
unsigned long pyGameMgrInviteRevokedMsg::NewGameID() const
{
if (message)
{
const Srv2Cli_GameMgr_InviteRevoked* gmMsg = (const Srv2Cli_GameMgr_InviteRevoked*)message->netMsg;
return gmMsg->newGameId;
}
return 0;
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyGameMgrMsg.h"
///////////////////////////////////////////////////////////////////////////////
//
// Base game mgr msg class
//
pyGameMgrMsg::pyGameMgrMsg(): message(nil) {}
pyGameMgrMsg::pyGameMgrMsg(pfGameMgrMsg* msg): message(msg) {}
int pyGameMgrMsg::GetType() const
{
if (message)
return message->netMsg->messageId;
return -1;
}
PyObject* pyGameMgrMsg::UpcastToInviteReceivedMsg() const
{
if (!message)
PYTHON_RETURN_NONE;
if (message->netMsg->messageId != kSrv2Cli_GameMgr_InviteReceived)
PYTHON_RETURN_NONE;
return pyGameMgrInviteReceivedMsg::New(message);
}
PyObject* pyGameMgrMsg::UpcastToInviteRevokedMsg() const
{
if (!message)
PYTHON_RETURN_NONE;
if (message->netMsg->messageId != kSrv2Cli_GameMgr_InviteRevoked)
PYTHON_RETURN_NONE;
return pyGameMgrInviteRevokedMsg::New(message);
}
///////////////////////////////////////////////////////////////////////////////
//
// The different messages we can receive
//
pyGameMgrInviteReceivedMsg::pyGameMgrInviteReceivedMsg(): pyGameMgrMsg() {}
pyGameMgrInviteReceivedMsg::pyGameMgrInviteReceivedMsg(pfGameMgrMsg* msg): pyGameMgrMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_GameMgr_InviteReceived))
message = nil; // wrong type, just clear it out
}
unsigned long pyGameMgrInviteReceivedMsg::InviterID() const
{
if (message)
{
const Srv2Cli_GameMgr_InviteReceived* gmMsg = (const Srv2Cli_GameMgr_InviteReceived*)message->netMsg;
return gmMsg->inviterId;
}
return 0;
}
std::wstring pyGameMgrInviteReceivedMsg::GameTypeID() const
{
if (message)
{
const Srv2Cli_GameMgr_InviteReceived* gmMsg = (const Srv2Cli_GameMgr_InviteReceived*)message->netMsg;
wchar_t buffer[256];
GuidToString(gmMsg->gameTypeId, buffer, arrsize(buffer));
return buffer;
}
return L"";
}
unsigned long pyGameMgrInviteReceivedMsg::NewGameID() const
{
if (message)
{
const Srv2Cli_GameMgr_InviteReceived* gmMsg = (const Srv2Cli_GameMgr_InviteReceived*)message->netMsg;
return gmMsg->newGameId;
}
return 0;
}
///////////////////////////////////////////////////////////////////////////////
pyGameMgrInviteRevokedMsg::pyGameMgrInviteRevokedMsg(): pyGameMgrMsg() {}
pyGameMgrInviteRevokedMsg::pyGameMgrInviteRevokedMsg(pfGameMgrMsg* msg): pyGameMgrMsg(msg)
{
if (message && (message->netMsg->messageId != kSrv2Cli_GameMgr_InviteRevoked))
message = nil; // wrong type, just clear it out
}
unsigned long pyGameMgrInviteRevokedMsg::InviterID() const
{
if (message)
{
const Srv2Cli_GameMgr_InviteRevoked* gmMsg = (const Srv2Cli_GameMgr_InviteRevoked*)message->netMsg;
return gmMsg->inviterId;
}
return 0;
}
std::wstring pyGameMgrInviteRevokedMsg::GameTypeID() const
{
if (message)
{
const Srv2Cli_GameMgr_InviteRevoked* gmMsg = (const Srv2Cli_GameMgr_InviteRevoked*)message->netMsg;
wchar_t buffer[256];
GuidToString(gmMsg->gameTypeId, buffer, arrsize(buffer));
return buffer;
}
return L"";
}
unsigned long pyGameMgrInviteRevokedMsg::NewGameID() const
{
if (message)
{
const Srv2Cli_GameMgr_InviteRevoked* gmMsg = (const Srv2Cli_GameMgr_InviteRevoked*)message->netMsg;
return gmMsg->newGameId;
}
return 0;
}

View File

@ -1,109 +1,109 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyGameMgrMsg_h
#define pyGameMgrMsg_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: pyGameMgrMsg
//
// PURPOSE: Class wrapper for game manager messages
//
#include "hsStlUtils.h"
#include "pfGameMgr/pfGameMgr.h"
#include <python.h>
#include "../pyGlueHelpers.h"
class pyGameMgrMsg
{
protected:
pfGameMgrMsg* message;
pyGameMgrMsg();
pyGameMgrMsg(pfGameMgrMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_EXPOSE_TYPE; // so we can subclass
PYTHON_CLASS_NEW_FRIEND(ptGameMgrMsg);
static PyObject* New(pfGameMgrMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameMgrMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameMgrMsg); // converts a PyObject to a pyGameMgrMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaConstantsClasses(PyObject* m);
int GetType() const;
PyObject* UpcastToInviteReceivedMsg() const; // returns ptGameMgrInviteReceivedMsg
PyObject* UpcastToInviteRevokedMsg() const; // returns ptGameMgrInviteRevokedMsg
};
///////////////////////////////////////////////////////////////////////////////
class pyGameMgrInviteReceivedMsg : public pyGameMgrMsg
{
protected:
pyGameMgrInviteReceivedMsg();
pyGameMgrInviteReceivedMsg(pfGameMgrMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptGameMgrInviteReceivedMsg);
static PyObject* New(pfGameMgrMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameMgrInviteReceivedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameMgrInviteReceivedMsg); // converts a PyObject to a pyGameMgrInviteReceivedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
unsigned long InviterID() const;
std::wstring GameTypeID() const;
unsigned long NewGameID() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyGameMgrInviteRevokedMsg : public pyGameMgrMsg
{
protected:
pyGameMgrInviteRevokedMsg();
pyGameMgrInviteRevokedMsg(pfGameMgrMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptGameMgrInviteRevokedMsg);
static PyObject* New(pfGameMgrMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameMgrInviteRevokedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameMgrInviteRevokedMsg); // converts a PyObject to a pyGameMgrInviteRevokedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
unsigned long InviterID() const;
std::wstring GameTypeID() const;
unsigned long NewGameID() const;
};
#endif // pyGameMgrMsg_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyGameMgrMsg_h
#define pyGameMgrMsg_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: pyGameMgrMsg
//
// PURPOSE: Class wrapper for game manager messages
//
#include "hsStlUtils.h"
#include "pfGameMgr/pfGameMgr.h"
#include <python.h>
#include "../pyGlueHelpers.h"
class pyGameMgrMsg
{
protected:
pfGameMgrMsg* message;
pyGameMgrMsg();
pyGameMgrMsg(pfGameMgrMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_EXPOSE_TYPE; // so we can subclass
PYTHON_CLASS_NEW_FRIEND(ptGameMgrMsg);
static PyObject* New(pfGameMgrMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameMgrMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameMgrMsg); // converts a PyObject to a pyGameMgrMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
static void AddPlasmaConstantsClasses(PyObject* m);
int GetType() const;
PyObject* UpcastToInviteReceivedMsg() const; // returns ptGameMgrInviteReceivedMsg
PyObject* UpcastToInviteRevokedMsg() const; // returns ptGameMgrInviteRevokedMsg
};
///////////////////////////////////////////////////////////////////////////////
class pyGameMgrInviteReceivedMsg : public pyGameMgrMsg
{
protected:
pyGameMgrInviteReceivedMsg();
pyGameMgrInviteReceivedMsg(pfGameMgrMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptGameMgrInviteReceivedMsg);
static PyObject* New(pfGameMgrMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameMgrInviteReceivedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameMgrInviteReceivedMsg); // converts a PyObject to a pyGameMgrInviteReceivedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
unsigned long InviterID() const;
std::wstring GameTypeID() const;
unsigned long NewGameID() const;
};
///////////////////////////////////////////////////////////////////////////////
class pyGameMgrInviteRevokedMsg : public pyGameMgrMsg
{
protected:
pyGameMgrInviteRevokedMsg();
pyGameMgrInviteRevokedMsg(pfGameMgrMsg* msg);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptGameMgrInviteRevokedMsg);
static PyObject* New(pfGameMgrMsg* msg);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyGameMgrInviteRevokedMsg object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyGameMgrInviteRevokedMsg); // converts a PyObject to a pyGameMgrInviteRevokedMsg (throws error if not correct type)
static void AddPlasmaClasses(PyObject* m);
unsigned long InviterID() const;
std::wstring GameTypeID() const;
unsigned long NewGameID() const;
};
#endif // pyGameMgrMsg_h

View File

@ -1,203 +1,203 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyGameMgrMsg.h"
#include "../pyEnum.h"
#include <python.h>
///////////////////////////////////////////////////////////////////////////////
//
// Base game manager msg class
//
PYTHON_CLASS_DEFINITION(ptGameMgrMsg, pyGameMgrMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptGameMgrMsg, pyGameMgrMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameMgrMsg)
PYTHON_NO_INIT_DEFINITION(ptGameMgrMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrMsg, getType)
{
return PyInt_FromLong(self->fThis->GetType());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrMsg, upcastToInviteReceivedMsg)
{
return self->fThis->UpcastToInviteReceivedMsg();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrMsg, upcastToInviteRevokedMsg)
{
return self->fThis->UpcastToInviteRevokedMsg();
}
PYTHON_START_METHODS_TABLE(ptGameMgrMsg)
PYTHON_METHOD_NOARGS(ptGameMgrMsg, getType, "Returns the type of the message (see PtGameMgrMsgTypes)"),
PYTHON_METHOD_NOARGS(ptGameMgrMsg, upcastToInviteReceivedMsg, "Returns this message as a ptGameMgrInviteReceivedMsg"),
PYTHON_METHOD_NOARGS(ptGameMgrMsg, upcastToInviteRevokedMsg, "Returns this message as a ptGameMgrInviteRevokedMsg"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE(ptGameMgrMsg, "Message from the game manager");
PYTHON_EXPOSE_TYPE_DEFINITION(ptGameMgrMsg, pyGameMgrMsg);
// required functions for PyObject interoperability
PyObject* pyGameMgrMsg::New(pfGameMgrMsg* msg)
{
ptGameMgrMsg *newObj = (ptGameMgrMsg*)ptGameMgrMsg_type.tp_new(&ptGameMgrMsg_type, NULL, NULL);
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptGameMgrMsg, pyGameMgrMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameMgrMsg, pyGameMgrMsg)
// Module and method definitions
void pyGameMgrMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptGameMgrMsg);
PYTHON_CLASS_IMPORT_END(m);
}
void pyGameMgrMsg::AddPlasmaConstantsClasses(PyObject* m)
{
PYTHON_ENUM_START(PtGameMgrMsgTypes);
PYTHON_ENUM_ELEMENT(PtGameMgrMsgTypes, kGameMgrInviteReceivedMsg, kSrv2Cli_GameMgr_InviteReceived);
PYTHON_ENUM_ELEMENT(PtGameMgrMsgTypes, kGameMgrInviteRevokedMsg, kSrv2Cli_GameMgr_InviteRevoked);
PYTHON_ENUM_END(m, PtGameMgrMsgTypes);
}
///////////////////////////////////////////////////////////////////////////////
//
// Game manager message subclasses
//
PYTHON_CLASS_DEFINITION(ptGameMgrInviteReceivedMsg, pyGameMgrInviteReceivedMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptGameMgrInviteReceivedMsg, pyGameMgrInviteReceivedMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameMgrInviteReceivedMsg)
PYTHON_NO_INIT_DEFINITION(ptGameMgrInviteReceivedMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteReceivedMsg, inviterID)
{
return PyLong_FromUnsignedLong(self->fThis->InviterID());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteReceivedMsg, gameTypeID)
{
std::wstring retVal = self->fThis->GameTypeID();
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteReceivedMsg, newGameID)
{
return PyLong_FromUnsignedLong(self->fThis->NewGameID());
}
PYTHON_START_METHODS_TABLE(ptGameMgrInviteReceivedMsg)
PYTHON_METHOD_NOARGS(ptGameMgrInviteReceivedMsg, inviterID, "Returns the inviter's ID number"),
PYTHON_METHOD_NOARGS(ptGameMgrInviteReceivedMsg, gameTypeID, "Returns the game type ID (as a guid string)"),
PYTHON_METHOD_NOARGS(ptGameMgrInviteReceivedMsg, newGameID, "Returns the new game's ID number"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptGameMgrInviteReceivedMsg, pyGameMgrMsg, "Game manager message when an invite is received");
// required functions for PyObject interoperability
PyObject* pyGameMgrInviteReceivedMsg::New(pfGameMgrMsg* msg)
{
ptGameMgrInviteReceivedMsg *newObj = (ptGameMgrInviteReceivedMsg*)ptGameMgrInviteReceivedMsg_type.tp_new(&ptGameMgrInviteReceivedMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_GameMgr_InviteReceived))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptGameMgrInviteReceivedMsg, pyGameMgrInviteReceivedMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameMgrInviteReceivedMsg, pyGameMgrInviteReceivedMsg)
// Module and method definitions
void pyGameMgrInviteReceivedMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptGameMgrInviteReceivedMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptGameMgrInviteRevokedMsg, pyGameMgrInviteRevokedMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptGameMgrInviteRevokedMsg, pyGameMgrInviteRevokedMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameMgrInviteRevokedMsg)
PYTHON_NO_INIT_DEFINITION(ptGameMgrInviteRevokedMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteRevokedMsg, inviterID)
{
return PyLong_FromUnsignedLong(self->fThis->InviterID());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteRevokedMsg, gameTypeID)
{
std::wstring retVal = self->fThis->GameTypeID();
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteRevokedMsg, newGameID)
{
return PyLong_FromUnsignedLong(self->fThis->NewGameID());
}
PYTHON_START_METHODS_TABLE(ptGameMgrInviteRevokedMsg)
PYTHON_METHOD_NOARGS(ptGameMgrInviteRevokedMsg, inviterID, "Returns the inviter's ID number"),
PYTHON_METHOD_NOARGS(ptGameMgrInviteRevokedMsg, gameTypeID, "Returns the game type ID (as a guid string)"),
PYTHON_METHOD_NOARGS(ptGameMgrInviteRevokedMsg, newGameID, "Returns the new game's ID number"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptGameMgrInviteRevokedMsg, pyGameMgrMsg, "Game manager message when an invite is received");
// required functions for PyObject interoperability
PyObject* pyGameMgrInviteRevokedMsg::New(pfGameMgrMsg* msg)
{
ptGameMgrInviteRevokedMsg *newObj = (ptGameMgrInviteRevokedMsg*)ptGameMgrInviteRevokedMsg_type.tp_new(&ptGameMgrInviteRevokedMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_GameMgr_InviteRevoked))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptGameMgrInviteRevokedMsg, pyGameMgrInviteRevokedMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameMgrInviteRevokedMsg, pyGameMgrInviteRevokedMsg)
// Module and method definitions
void pyGameMgrInviteRevokedMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptGameMgrInviteRevokedMsg);
PYTHON_CLASS_IMPORT_END(m);
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyGameMgrMsg.h"
#include "../pyEnum.h"
#include <python.h>
///////////////////////////////////////////////////////////////////////////////
//
// Base game manager msg class
//
PYTHON_CLASS_DEFINITION(ptGameMgrMsg, pyGameMgrMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptGameMgrMsg, pyGameMgrMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameMgrMsg)
PYTHON_NO_INIT_DEFINITION(ptGameMgrMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrMsg, getType)
{
return PyInt_FromLong(self->fThis->GetType());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrMsg, upcastToInviteReceivedMsg)
{
return self->fThis->UpcastToInviteReceivedMsg();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrMsg, upcastToInviteRevokedMsg)
{
return self->fThis->UpcastToInviteRevokedMsg();
}
PYTHON_START_METHODS_TABLE(ptGameMgrMsg)
PYTHON_METHOD_NOARGS(ptGameMgrMsg, getType, "Returns the type of the message (see PtGameMgrMsgTypes)"),
PYTHON_METHOD_NOARGS(ptGameMgrMsg, upcastToInviteReceivedMsg, "Returns this message as a ptGameMgrInviteReceivedMsg"),
PYTHON_METHOD_NOARGS(ptGameMgrMsg, upcastToInviteRevokedMsg, "Returns this message as a ptGameMgrInviteRevokedMsg"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE(ptGameMgrMsg, "Message from the game manager");
PYTHON_EXPOSE_TYPE_DEFINITION(ptGameMgrMsg, pyGameMgrMsg);
// required functions for PyObject interoperability
PyObject* pyGameMgrMsg::New(pfGameMgrMsg* msg)
{
ptGameMgrMsg *newObj = (ptGameMgrMsg*)ptGameMgrMsg_type.tp_new(&ptGameMgrMsg_type, NULL, NULL);
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptGameMgrMsg, pyGameMgrMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameMgrMsg, pyGameMgrMsg)
// Module and method definitions
void pyGameMgrMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptGameMgrMsg);
PYTHON_CLASS_IMPORT_END(m);
}
void pyGameMgrMsg::AddPlasmaConstantsClasses(PyObject* m)
{
PYTHON_ENUM_START(PtGameMgrMsgTypes);
PYTHON_ENUM_ELEMENT(PtGameMgrMsgTypes, kGameMgrInviteReceivedMsg, kSrv2Cli_GameMgr_InviteReceived);
PYTHON_ENUM_ELEMENT(PtGameMgrMsgTypes, kGameMgrInviteRevokedMsg, kSrv2Cli_GameMgr_InviteRevoked);
PYTHON_ENUM_END(m, PtGameMgrMsgTypes);
}
///////////////////////////////////////////////////////////////////////////////
//
// Game manager message subclasses
//
PYTHON_CLASS_DEFINITION(ptGameMgrInviteReceivedMsg, pyGameMgrInviteReceivedMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptGameMgrInviteReceivedMsg, pyGameMgrInviteReceivedMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameMgrInviteReceivedMsg)
PYTHON_NO_INIT_DEFINITION(ptGameMgrInviteReceivedMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteReceivedMsg, inviterID)
{
return PyLong_FromUnsignedLong(self->fThis->InviterID());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteReceivedMsg, gameTypeID)
{
std::wstring retVal = self->fThis->GameTypeID();
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteReceivedMsg, newGameID)
{
return PyLong_FromUnsignedLong(self->fThis->NewGameID());
}
PYTHON_START_METHODS_TABLE(ptGameMgrInviteReceivedMsg)
PYTHON_METHOD_NOARGS(ptGameMgrInviteReceivedMsg, inviterID, "Returns the inviter's ID number"),
PYTHON_METHOD_NOARGS(ptGameMgrInviteReceivedMsg, gameTypeID, "Returns the game type ID (as a guid string)"),
PYTHON_METHOD_NOARGS(ptGameMgrInviteReceivedMsg, newGameID, "Returns the new game's ID number"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptGameMgrInviteReceivedMsg, pyGameMgrMsg, "Game manager message when an invite is received");
// required functions for PyObject interoperability
PyObject* pyGameMgrInviteReceivedMsg::New(pfGameMgrMsg* msg)
{
ptGameMgrInviteReceivedMsg *newObj = (ptGameMgrInviteReceivedMsg*)ptGameMgrInviteReceivedMsg_type.tp_new(&ptGameMgrInviteReceivedMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_GameMgr_InviteReceived))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptGameMgrInviteReceivedMsg, pyGameMgrInviteReceivedMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameMgrInviteReceivedMsg, pyGameMgrInviteReceivedMsg)
// Module and method definitions
void pyGameMgrInviteReceivedMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptGameMgrInviteReceivedMsg);
PYTHON_CLASS_IMPORT_END(m);
}
///////////////////////////////////////////////////////////////////////////////
PYTHON_CLASS_DEFINITION(ptGameMgrInviteRevokedMsg, pyGameMgrInviteRevokedMsg);
PYTHON_DEFAULT_NEW_DEFINITION(ptGameMgrInviteRevokedMsg, pyGameMgrInviteRevokedMsg)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptGameMgrInviteRevokedMsg)
PYTHON_NO_INIT_DEFINITION(ptGameMgrInviteRevokedMsg)
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteRevokedMsg, inviterID)
{
return PyLong_FromUnsignedLong(self->fThis->InviterID());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteRevokedMsg, gameTypeID)
{
std::wstring retVal = self->fThis->GameTypeID();
return PyUnicode_FromWideChar(retVal.c_str(), retVal.length());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptGameMgrInviteRevokedMsg, newGameID)
{
return PyLong_FromUnsignedLong(self->fThis->NewGameID());
}
PYTHON_START_METHODS_TABLE(ptGameMgrInviteRevokedMsg)
PYTHON_METHOD_NOARGS(ptGameMgrInviteRevokedMsg, inviterID, "Returns the inviter's ID number"),
PYTHON_METHOD_NOARGS(ptGameMgrInviteRevokedMsg, gameTypeID, "Returns the game type ID (as a guid string)"),
PYTHON_METHOD_NOARGS(ptGameMgrInviteRevokedMsg, newGameID, "Returns the new game's ID number"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE_WBASE(ptGameMgrInviteRevokedMsg, pyGameMgrMsg, "Game manager message when an invite is received");
// required functions for PyObject interoperability
PyObject* pyGameMgrInviteRevokedMsg::New(pfGameMgrMsg* msg)
{
ptGameMgrInviteRevokedMsg *newObj = (ptGameMgrInviteRevokedMsg*)ptGameMgrInviteRevokedMsg_type.tp_new(&ptGameMgrInviteRevokedMsg_type, NULL, NULL);
if (msg && (msg->netMsg->messageId == kSrv2Cli_GameMgr_InviteRevoked))
newObj->fThis->message = msg;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptGameMgrInviteRevokedMsg, pyGameMgrInviteRevokedMsg)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptGameMgrInviteRevokedMsg, pyGameMgrInviteRevokedMsg)
// Module and method definitions
void pyGameMgrInviteRevokedMsg::AddPlasmaClasses(PyObject* m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptGameMgrInviteRevokedMsg);
PYTHON_CLASS_IMPORT_END(m);
}

View File

@ -1,125 +1,125 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/////////////////////////////////////////////////////////////////////////////
//
// NAME: cyAccountManagement
//
// PURPOSE: Python wrapper for account management functions
//
#include "cyAccountManagement.h"
#include "plNetClientComm/plNetClientComm.h"
bool cyAccountManagement::IsSubscriptionActive()
{
const NetCommAccount* account = NetCommGetAccount();
return (account->billingType & kBillingTypePaidSubscriber);
}
PyObject* cyAccountManagement::GetPlayerList()
{
const ARRAY(NetCommPlayer)& playerList = NetCommGetPlayerList();
int numPlayers = NetCommGetPlayerCount();
PyObject* pList = PyList_New(0);
PyObject* visitor = nil;
for (int i = 0; i < numPlayers; ++i)
{
PyObject* playerTuple = PyTuple_New(3);
PyObject* playerName = PyUnicode_FromUnicode((const Py_UNICODE*)playerList[i].playerName, wcslen(playerList[i].playerName));
PyObject* playerId = PyInt_FromLong(playerList[i].playerInt);
PyObject* avatarShape = PyString_FromString(playerList[i].avatarDatasetName);
PyTuple_SetItem(playerTuple, 0, playerName);
PyTuple_SetItem(playerTuple, 1, playerId);
PyTuple_SetItem(playerTuple, 2, avatarShape);
if (visitor || playerList[i].explorer)
PyList_Append(pList, playerTuple);
else
visitor = playerTuple;
}
if (visitor)
{
PyList_Insert(pList, 0, visitor);
}
else
{
Py_INCREF(Py_None);
PyList_Insert(pList, 0, Py_None);
}
return pList;
}
std::wstring cyAccountManagement::GetAccountName()
{
const NetCommAccount* acct = NetCommGetAccount();
if (acct)
return acct->accountName;
else
return L"";
}
void cyAccountManagement::CreatePlayer(const char* playerName, const char* avatar, const char* invitationCode)
{
NetCommCreatePlayer(playerName, avatar, invitationCode, 0, nil);
}
void cyAccountManagement::CreatePlayerW(const wchar_t* playerName, const wchar_t* avatar, const wchar_t* invitationCode)
{
NetCommCreatePlayer(playerName, avatar, invitationCode, 0, nil);
}
void cyAccountManagement::DeletePlayer(unsigned playerId)
{
NetCommDeletePlayer(playerId, nil);
}
void cyAccountManagement::SetActivePlayer(unsigned playerId)
{
NetCommSetActivePlayer(playerId, nil);
}
bool cyAccountManagement::IsActivePlayerSet()
{
return NetCommGetPlayer()->playerInt != 0;
}
void cyAccountManagement::UpgradeVisitorToExplorer(unsigned playerId)
{
NetCommUpgradeVisitorToExplorer(playerId, nil);
}
void cyAccountManagement::ChangePassword(const char* password)
{
wchar* wpassword = StrDupToUnicode(password);
NetCommChangeMyPassword(wpassword);
FREE(wpassword);
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
/////////////////////////////////////////////////////////////////////////////
//
// NAME: cyAccountManagement
//
// PURPOSE: Python wrapper for account management functions
//
#include "cyAccountManagement.h"
#include "plNetClientComm/plNetClientComm.h"
bool cyAccountManagement::IsSubscriptionActive()
{
const NetCommAccount* account = NetCommGetAccount();
return (account->billingType & kBillingTypePaidSubscriber);
}
PyObject* cyAccountManagement::GetPlayerList()
{
const ARRAY(NetCommPlayer)& playerList = NetCommGetPlayerList();
int numPlayers = NetCommGetPlayerCount();
PyObject* pList = PyList_New(0);
PyObject* visitor = nil;
for (int i = 0; i < numPlayers; ++i)
{
PyObject* playerTuple = PyTuple_New(3);
PyObject* playerName = PyUnicode_FromUnicode((const Py_UNICODE*)playerList[i].playerName, wcslen(playerList[i].playerName));
PyObject* playerId = PyInt_FromLong(playerList[i].playerInt);
PyObject* avatarShape = PyString_FromString(playerList[i].avatarDatasetName);
PyTuple_SetItem(playerTuple, 0, playerName);
PyTuple_SetItem(playerTuple, 1, playerId);
PyTuple_SetItem(playerTuple, 2, avatarShape);
if (visitor || playerList[i].explorer)
PyList_Append(pList, playerTuple);
else
visitor = playerTuple;
}
if (visitor)
{
PyList_Insert(pList, 0, visitor);
}
else
{
Py_INCREF(Py_None);
PyList_Insert(pList, 0, Py_None);
}
return pList;
}
std::wstring cyAccountManagement::GetAccountName()
{
const NetCommAccount* acct = NetCommGetAccount();
if (acct)
return acct->accountName;
else
return L"";
}
void cyAccountManagement::CreatePlayer(const char* playerName, const char* avatar, const char* invitationCode)
{
NetCommCreatePlayer(playerName, avatar, invitationCode, 0, nil);
}
void cyAccountManagement::CreatePlayerW(const wchar_t* playerName, const wchar_t* avatar, const wchar_t* invitationCode)
{
NetCommCreatePlayer(playerName, avatar, invitationCode, 0, nil);
}
void cyAccountManagement::DeletePlayer(unsigned playerId)
{
NetCommDeletePlayer(playerId, nil);
}
void cyAccountManagement::SetActivePlayer(unsigned playerId)
{
NetCommSetActivePlayer(playerId, nil);
}
bool cyAccountManagement::IsActivePlayerSet()
{
return NetCommGetPlayer()->playerInt != 0;
}
void cyAccountManagement::UpgradeVisitorToExplorer(unsigned playerId)
{
NetCommUpgradeVisitorToExplorer(playerId, nil);
}
void cyAccountManagement::ChangePassword(const char* password)
{
wchar* wpassword = StrDupToUnicode(password);
NetCommChangeMyPassword(wpassword);
FREE(wpassword);
}

View File

@ -1,59 +1,59 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef cyAccountManagement_h
#define cyAccountManagement_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: cyAccountManagement
//
// PURPOSE: Python wrapper for account management functions
//
#include <python.h>
#include "hsTypes.h"
#include "hsStlUtils.h"
class cyAccountManagement
{
public:
static void AddPlasmaMethods(std::vector<PyMethodDef> &methods);
static void AddPlasmaConstantsClasses(PyObject *m);
static bool IsSubscriptionActive();
static PyObject* GetPlayerList();
static std::wstring GetAccountName();
static void CreatePlayer(const char* playerName, const char* avatar, const char* invitationCode);
static void CreatePlayerW(const wchar_t* playerName, const wchar_t* avatar, const wchar_t* invitationCode);
static void DeletePlayer(unsigned playerId);
static void SetActivePlayer(unsigned playerId);
static bool IsActivePlayerSet();
static void UpgradeVisitorToExplorer(unsigned playerId);
static void ChangePassword(const char* password);
};
#endif
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef cyAccountManagement_h
#define cyAccountManagement_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: cyAccountManagement
//
// PURPOSE: Python wrapper for account management functions
//
#include <python.h>
#include "hsTypes.h"
#include "hsStlUtils.h"
class cyAccountManagement
{
public:
static void AddPlasmaMethods(std::vector<PyMethodDef> &methods);
static void AddPlasmaConstantsClasses(PyObject *m);
static bool IsSubscriptionActive();
static PyObject* GetPlayerList();
static std::wstring GetAccountName();
static void CreatePlayer(const char* playerName, const char* avatar, const char* invitationCode);
static void CreatePlayerW(const wchar_t* playerName, const wchar_t* avatar, const wchar_t* invitationCode);
static void DeletePlayer(unsigned playerId);
static void SetActivePlayer(unsigned playerId);
static bool IsActivePlayerSet();
static void UpgradeVisitorToExplorer(unsigned playerId);
static void ChangePassword(const char* password);
};
#endif

View File

@ -1,230 +1,230 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "cyAccountManagement.h"
#include "pyGlueHelpers.h"
#include "pyEnum.h"
#include "plMessage/plAccountUpdateMsg.h"
PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtIsSubscriptionActive, "Returns true if the current player is a paying subscriber")
{
PYTHON_RETURN_BOOL(cyAccountManagement::IsSubscriptionActive());
}
PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetAccountPlayerList, "Returns list of players associated with the current account")
{
return cyAccountManagement::GetPlayerList();
}
PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetAccountName, "Returns the account name for the current account")
{
std::wstring name = cyAccountManagement::GetAccountName();
return PyUnicode_FromWideChar(name.c_str(), name.length());
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtCreatePlayer, args, "Params: playerName, avatarShape, invitation\nCreates a new player")
{
char* playerName;
char* avatarShape;
char* invitation;
if (!PyArg_ParseTuple(args, "ssz", &playerName, &avatarShape, &invitation))
{
PyErr_SetString(PyExc_TypeError, "PtCreatePlayer expects three strings");
PYTHON_RETURN_ERROR;
}
cyAccountManagement::CreatePlayer(playerName, avatarShape, invitation);
PYTHON_RETURN_NONE;
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtCreatePlayerW, args, "Params: playerName, avatarShape, invitation\nUnicode version of PtCreatePlayer")
{
PyObject* playerNameObj;
PyObject* avatarShapeObj;
PyObject* invitationObj;
if (!PyArg_ParseTuple(args, "OOO", &playerNameObj, &avatarShapeObj, &invitationObj))
{
PyErr_SetString(PyExc_TypeError, "PtCreatePlayerW expects three unicode strings");
PYTHON_RETURN_ERROR;
}
std::wstring playerName, avatarShape, invitation;
if (PyUnicode_Check(playerNameObj))
{
int strLen = PyUnicode_GetSize(playerNameObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)playerNameObj, text, strLen);
text[strLen] = L'\0';
playerName = text;
delete [] text;
}
else if (PyString_Check(playerNameObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(playerNameObj);
wchar_t* temp = hsStringToWString(text);
playerName = temp;
delete [] temp;
}
else
{
PyErr_SetString(PyExc_TypeError, "PtCreatePlayerW expects three unicode strings");
PYTHON_RETURN_ERROR;
}
if (PyUnicode_Check(avatarShapeObj))
{
int strLen = PyUnicode_GetSize(avatarShapeObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)avatarShapeObj, text, strLen);
text[strLen] = L'\0';
avatarShape = text;
delete [] text;
}
else if (PyString_Check(avatarShapeObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(avatarShapeObj);
wchar_t* temp = hsStringToWString(text);
avatarShape = temp;
delete [] temp;
}
else
{
PyErr_SetString(PyExc_TypeError, "PtCreatePlayerW expects three unicode strings");
PYTHON_RETURN_ERROR;
}
if (PyUnicode_Check(invitationObj))
{
int strLen = PyUnicode_GetSize(invitationObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)invitationObj, text, strLen);
text[strLen] = L'\0';
invitation = text;
delete [] text;
}
else if (PyString_Check(invitationObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(invitationObj);
wchar_t* temp = hsStringToWString(text);
invitation = temp;
delete [] temp;
}
else
{
PyErr_SetString(PyExc_TypeError, "PtCreatePlayerW expects three unicode strings");
PYTHON_RETURN_ERROR;
}
cyAccountManagement::CreatePlayerW(playerName.c_str(), avatarShape.c_str(), invitation.c_str());
PYTHON_RETURN_NONE;
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtDeletePlayer, args, "Params: playerInt\nDeletes a player associated with the current account")
{
unsigned playerInt = 0;
if (!PyArg_ParseTuple(args, "I", &playerInt))
{
PyErr_SetString(PyExc_TypeError, "PtDeletePlayer expects a unsigned int");
PYTHON_RETURN_ERROR;
}
cyAccountManagement::DeletePlayer(playerInt);
PYTHON_RETURN_NONE;
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtSetActivePlayer, args, "Params: playerInt\nSets the active player associated with the current account")
{
unsigned playerInt = 0;
if (!PyArg_ParseTuple(args, "I", &playerInt))
{
PyErr_SetString(PyExc_TypeError, "PtSetActivePlayer expects a unsigned int");
PYTHON_RETURN_ERROR;
}
cyAccountManagement::SetActivePlayer(playerInt);
PYTHON_RETURN_NONE;
}
PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtIsActivePlayerSet, "Returns whether or not an active player is set")
{
PYTHON_RETURN_BOOL(cyAccountManagement::IsActivePlayerSet());
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtUpgradeVisitorToExplorer, args, "Params: playerInt\nUpgrades the player to explorer status")
{
unsigned playerInt = 0;
if (!PyArg_ParseTuple(args, "I", &playerInt))
{
PyErr_SetString(PyExc_TypeError, "PtUpgradeVisitorToExplorer expects a unsigned int");
PYTHON_RETURN_ERROR;
}
cyAccountManagement::UpgradeVisitorToExplorer(playerInt);
PYTHON_RETURN_NONE;
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtChangePassword, args, "Params: password\nChanges the current account's password")
{
char* password = nil;
if (!PyArg_ParseTuple(args, "s", &password))
{
PyErr_SetString(PyExc_TypeError, "PtChangePassword expects a string");
PYTHON_RETURN_ERROR;
}
cyAccountManagement::ChangePassword(password);
PYTHON_RETURN_NONE;
}
void cyAccountManagement::AddPlasmaMethods(std::vector<PyMethodDef> &methods)
{
PYTHON_GLOBAL_METHOD_NOARGS(methods, PtIsSubscriptionActive);
PYTHON_GLOBAL_METHOD_NOARGS(methods, PtGetAccountPlayerList);
PYTHON_GLOBAL_METHOD_NOARGS(methods, PtGetAccountName);
PYTHON_GLOBAL_METHOD(methods, PtCreatePlayer);
PYTHON_GLOBAL_METHOD(methods, PtCreatePlayerW);
PYTHON_GLOBAL_METHOD(methods, PtDeletePlayer);
PYTHON_GLOBAL_METHOD(methods, PtSetActivePlayer);
PYTHON_GLOBAL_METHOD(methods, PtIsActivePlayerSet);
PYTHON_GLOBAL_METHOD(methods, PtUpgradeVisitorToExplorer);
PYTHON_GLOBAL_METHOD(methods, PtChangePassword);
}
void cyAccountManagement::AddPlasmaConstantsClasses(PyObject *m)
{
PYTHON_ENUM_START(PtAccountUpdateType);
PYTHON_ENUM_ELEMENT(PtAccountUpdateType, kCreatePlayer, plAccountUpdateMsg::kCreatePlayer);
PYTHON_ENUM_ELEMENT(PtAccountUpdateType, kDeletePlayer, plAccountUpdateMsg::kDeletePlayer);
PYTHON_ENUM_ELEMENT(PtAccountUpdateType, kUpgradePlayer, plAccountUpdateMsg::kUpgradePlayer);
PYTHON_ENUM_ELEMENT(PtAccountUpdateType, kActivePlayer, plAccountUpdateMsg::kActivePlayer);
PYTHON_ENUM_ELEMENT(PtAccountUpdateType, kChangePassword, plAccountUpdateMsg::kChangePassword);
PYTHON_ENUM_END(m, PtAccountUpdateType);
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "cyAccountManagement.h"
#include "pyGlueHelpers.h"
#include "pyEnum.h"
#include "plMessage/plAccountUpdateMsg.h"
PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtIsSubscriptionActive, "Returns true if the current player is a paying subscriber")
{
PYTHON_RETURN_BOOL(cyAccountManagement::IsSubscriptionActive());
}
PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetAccountPlayerList, "Returns list of players associated with the current account")
{
return cyAccountManagement::GetPlayerList();
}
PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetAccountName, "Returns the account name for the current account")
{
std::wstring name = cyAccountManagement::GetAccountName();
return PyUnicode_FromWideChar(name.c_str(), name.length());
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtCreatePlayer, args, "Params: playerName, avatarShape, invitation\nCreates a new player")
{
char* playerName;
char* avatarShape;
char* invitation;
if (!PyArg_ParseTuple(args, "ssz", &playerName, &avatarShape, &invitation))
{
PyErr_SetString(PyExc_TypeError, "PtCreatePlayer expects three strings");
PYTHON_RETURN_ERROR;
}
cyAccountManagement::CreatePlayer(playerName, avatarShape, invitation);
PYTHON_RETURN_NONE;
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtCreatePlayerW, args, "Params: playerName, avatarShape, invitation\nUnicode version of PtCreatePlayer")
{
PyObject* playerNameObj;
PyObject* avatarShapeObj;
PyObject* invitationObj;
if (!PyArg_ParseTuple(args, "OOO", &playerNameObj, &avatarShapeObj, &invitationObj))
{
PyErr_SetString(PyExc_TypeError, "PtCreatePlayerW expects three unicode strings");
PYTHON_RETURN_ERROR;
}
std::wstring playerName, avatarShape, invitation;
if (PyUnicode_Check(playerNameObj))
{
int strLen = PyUnicode_GetSize(playerNameObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)playerNameObj, text, strLen);
text[strLen] = L'\0';
playerName = text;
delete [] text;
}
else if (PyString_Check(playerNameObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(playerNameObj);
wchar_t* temp = hsStringToWString(text);
playerName = temp;
delete [] temp;
}
else
{
PyErr_SetString(PyExc_TypeError, "PtCreatePlayerW expects three unicode strings");
PYTHON_RETURN_ERROR;
}
if (PyUnicode_Check(avatarShapeObj))
{
int strLen = PyUnicode_GetSize(avatarShapeObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)avatarShapeObj, text, strLen);
text[strLen] = L'\0';
avatarShape = text;
delete [] text;
}
else if (PyString_Check(avatarShapeObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(avatarShapeObj);
wchar_t* temp = hsStringToWString(text);
avatarShape = temp;
delete [] temp;
}
else
{
PyErr_SetString(PyExc_TypeError, "PtCreatePlayerW expects three unicode strings");
PYTHON_RETURN_ERROR;
}
if (PyUnicode_Check(invitationObj))
{
int strLen = PyUnicode_GetSize(invitationObj);
wchar_t* text = TRACKED_NEW wchar_t[strLen + 1];
PyUnicode_AsWideChar((PyUnicodeObject*)invitationObj, text, strLen);
text[strLen] = L'\0';
invitation = text;
delete [] text;
}
else if (PyString_Check(invitationObj))
{
// we'll allow this, just in case something goes weird
char* text = PyString_AsString(invitationObj);
wchar_t* temp = hsStringToWString(text);
invitation = temp;
delete [] temp;
}
else
{
PyErr_SetString(PyExc_TypeError, "PtCreatePlayerW expects three unicode strings");
PYTHON_RETURN_ERROR;
}
cyAccountManagement::CreatePlayerW(playerName.c_str(), avatarShape.c_str(), invitation.c_str());
PYTHON_RETURN_NONE;
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtDeletePlayer, args, "Params: playerInt\nDeletes a player associated with the current account")
{
unsigned playerInt = 0;
if (!PyArg_ParseTuple(args, "I", &playerInt))
{
PyErr_SetString(PyExc_TypeError, "PtDeletePlayer expects a unsigned int");
PYTHON_RETURN_ERROR;
}
cyAccountManagement::DeletePlayer(playerInt);
PYTHON_RETURN_NONE;
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtSetActivePlayer, args, "Params: playerInt\nSets the active player associated with the current account")
{
unsigned playerInt = 0;
if (!PyArg_ParseTuple(args, "I", &playerInt))
{
PyErr_SetString(PyExc_TypeError, "PtSetActivePlayer expects a unsigned int");
PYTHON_RETURN_ERROR;
}
cyAccountManagement::SetActivePlayer(playerInt);
PYTHON_RETURN_NONE;
}
PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtIsActivePlayerSet, "Returns whether or not an active player is set")
{
PYTHON_RETURN_BOOL(cyAccountManagement::IsActivePlayerSet());
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtUpgradeVisitorToExplorer, args, "Params: playerInt\nUpgrades the player to explorer status")
{
unsigned playerInt = 0;
if (!PyArg_ParseTuple(args, "I", &playerInt))
{
PyErr_SetString(PyExc_TypeError, "PtUpgradeVisitorToExplorer expects a unsigned int");
PYTHON_RETURN_ERROR;
}
cyAccountManagement::UpgradeVisitorToExplorer(playerInt);
PYTHON_RETURN_NONE;
}
PYTHON_GLOBAL_METHOD_DEFINITION(PtChangePassword, args, "Params: password\nChanges the current account's password")
{
char* password = nil;
if (!PyArg_ParseTuple(args, "s", &password))
{
PyErr_SetString(PyExc_TypeError, "PtChangePassword expects a string");
PYTHON_RETURN_ERROR;
}
cyAccountManagement::ChangePassword(password);
PYTHON_RETURN_NONE;
}
void cyAccountManagement::AddPlasmaMethods(std::vector<PyMethodDef> &methods)
{
PYTHON_GLOBAL_METHOD_NOARGS(methods, PtIsSubscriptionActive);
PYTHON_GLOBAL_METHOD_NOARGS(methods, PtGetAccountPlayerList);
PYTHON_GLOBAL_METHOD_NOARGS(methods, PtGetAccountName);
PYTHON_GLOBAL_METHOD(methods, PtCreatePlayer);
PYTHON_GLOBAL_METHOD(methods, PtCreatePlayerW);
PYTHON_GLOBAL_METHOD(methods, PtDeletePlayer);
PYTHON_GLOBAL_METHOD(methods, PtSetActivePlayer);
PYTHON_GLOBAL_METHOD(methods, PtIsActivePlayerSet);
PYTHON_GLOBAL_METHOD(methods, PtUpgradeVisitorToExplorer);
PYTHON_GLOBAL_METHOD(methods, PtChangePassword);
}
void cyAccountManagement::AddPlasmaConstantsClasses(PyObject *m)
{
PYTHON_ENUM_START(PtAccountUpdateType);
PYTHON_ENUM_ELEMENT(PtAccountUpdateType, kCreatePlayer, plAccountUpdateMsg::kCreatePlayer);
PYTHON_ENUM_ELEMENT(PtAccountUpdateType, kDeletePlayer, plAccountUpdateMsg::kDeletePlayer);
PYTHON_ENUM_ELEMENT(PtAccountUpdateType, kUpgradePlayer, plAccountUpdateMsg::kUpgradePlayer);
PYTHON_ENUM_ELEMENT(PtAccountUpdateType, kActivePlayer, plAccountUpdateMsg::kActivePlayer);
PYTHON_ENUM_ELEMENT(PtAccountUpdateType, kChangePassword, plAccountUpdateMsg::kChangePassword);
PYTHON_ENUM_END(m, PtAccountUpdateType);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,149 +1,149 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef cyAnimation_h
#define cyAnimation_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: cyAnimation
//
// PURPOSE: Class wrapper to map animation functions to plasma2 message
//
#include "pyKey.h"
#include "hsTemplates.h"
#include <python.h>
#include "pyGlueHelpers.h"
class cyAnimation
{
plKey fSender;
hsTArray<plKey> fRecvr;
char* fAnimName;
hsBool fNetForce;
virtual void IRunOneCmd(int cmd);
protected:
cyAnimation();
cyAnimation(pyKey& sender);
// copy constructor
cyAnimation(const cyAnimation& anim);
public:
// clean up on the way out
~cyAnimation();
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptAnimation);
PYTHON_CLASS_NEW_DEFINITION;
static PyObject *New(PyObject *sender);
static PyObject *New(cyAnimation &obj);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a cyAnimation object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(cyAnimation); // converts a PyObject to a cyAnimation (throws error if not correct type)
static void AddPlasmaClasses(PyObject *m);
// setters
virtual void SetSender(pyKey& sender);
virtual void AddRecvr(pyKey& recvr);
virtual void SetAnimName(const char* name);
virtual PyObject* GetFirstRecvr();
virtual void SetNetForce(hsBool state);
// Play animation from start to end (whatever is already set)
//
virtual void Play();
// Stop an animation
//
virtual void Stop();
// Continue playing animation from wherever it last stopped
//
virtual void Resume();
// Play an animation only from specific time start to end
//
virtual void PlayRange(hsScalar start, hsScalar end);
// Play (continue) an animation until the specified time is reached
//
virtual void PlayToTime(hsScalar time);
// Play (continue) an animation until the specified point is reached
//
virtual void PlayToPercentage(hsScalar zeroToOne);
// Jump the animation to the specified time
// Doesn't start or stop playing of animation
//
virtual void SkipToTime(hsScalar time);
// Set whether the animation is to be looped or not
//
virtual void Looped(hsBool looped);
// Sets the backwards state for the animation
//
virtual void Backwards(hsBool backwards);
// Sets the start and end of the looping points in the animation
//
virtual void SetLoopStart(hsScalar start);
virtual void SetLoopEnd(hsScalar end);
// Sets the speed of the animation
// Doesn't start or stop playing animation
//
virtual void Speed(hsScalar speed);
// Jump the animation to the specified time
// Doesn't start or stop playing of animation
//
virtual void SkipToBegin();
virtual void SkipToEnd();
virtual void SkipToLoopBegin();
virtual void SkipToLoopEnd();
// Bump the animation ahead one frame (whatever deltime is)
//
virtual void IncrementForward();
// Bump the animation back one frame (whatever deltime is)
//
virtual void IncrementBackward();
};
#endif // cyAnimation_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef cyAnimation_h
#define cyAnimation_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: cyAnimation
//
// PURPOSE: Class wrapper to map animation functions to plasma2 message
//
#include "pyKey.h"
#include "hsTemplates.h"
#include <python.h>
#include "pyGlueHelpers.h"
class cyAnimation
{
plKey fSender;
hsTArray<plKey> fRecvr;
char* fAnimName;
hsBool fNetForce;
virtual void IRunOneCmd(int cmd);
protected:
cyAnimation();
cyAnimation(pyKey& sender);
// copy constructor
cyAnimation(const cyAnimation& anim);
public:
// clean up on the way out
~cyAnimation();
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptAnimation);
PYTHON_CLASS_NEW_DEFINITION;
static PyObject *New(PyObject *sender);
static PyObject *New(cyAnimation &obj);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a cyAnimation object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(cyAnimation); // converts a PyObject to a cyAnimation (throws error if not correct type)
static void AddPlasmaClasses(PyObject *m);
// setters
virtual void SetSender(pyKey& sender);
virtual void AddRecvr(pyKey& recvr);
virtual void SetAnimName(const char* name);
virtual PyObject* GetFirstRecvr();
virtual void SetNetForce(hsBool state);
// Play animation from start to end (whatever is already set)
//
virtual void Play();
// Stop an animation
//
virtual void Stop();
// Continue playing animation from wherever it last stopped
//
virtual void Resume();
// Play an animation only from specific time start to end
//
virtual void PlayRange(hsScalar start, hsScalar end);
// Play (continue) an animation until the specified time is reached
//
virtual void PlayToTime(hsScalar time);
// Play (continue) an animation until the specified point is reached
//
virtual void PlayToPercentage(hsScalar zeroToOne);
// Jump the animation to the specified time
// Doesn't start or stop playing of animation
//
virtual void SkipToTime(hsScalar time);
// Set whether the animation is to be looped or not
//
virtual void Looped(hsBool looped);
// Sets the backwards state for the animation
//
virtual void Backwards(hsBool backwards);
// Sets the start and end of the looping points in the animation
//
virtual void SetLoopStart(hsScalar start);
virtual void SetLoopEnd(hsScalar end);
// Sets the speed of the animation
// Doesn't start or stop playing animation
//
virtual void Speed(hsScalar speed);
// Jump the animation to the specified time
// Doesn't start or stop playing of animation
//
virtual void SkipToBegin();
virtual void SkipToEnd();
virtual void SkipToLoopBegin();
virtual void SkipToLoopEnd();
// Bump the animation ahead one frame (whatever deltime is)
//
virtual void IncrementForward();
// Bump the animation back one frame (whatever deltime is)
//
virtual void IncrementBackward();
};
#endif // cyAnimation_h

View File

@ -1,318 +1,318 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "cyAnimation.h"
#include "hsUtils.h"
#include <python.h>
// glue functions
PYTHON_CLASS_DEFINITION(ptAnimation, cyAnimation);
PYTHON_DEFAULT_NEW_DEFINITION(ptAnimation, cyAnimation)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptAnimation)
PYTHON_INIT_DEFINITION(ptAnimation, args, keywords)
{
PyObject *keyObject = NULL;
if (!PyArg_ParseTuple(args, "|O", &keyObject))
{
PyErr_SetString(PyExc_TypeError, "__init__ expects an optional ptKey");
PYTHON_RETURN_INIT_ERROR;
}
if (keyObject == NULL) // no parameter was passed
PYTHON_RETURN_INIT_OK; // nothing to init
if (!pyKey::Check(keyObject))
{
PyErr_SetString(PyExc_TypeError, "__init__ expects an optional ptKey");
PYTHON_RETURN_INIT_ERROR;
}
pyKey *key = pyKey::ConvertFrom(keyObject);
self->fThis->SetSender(*key);
PYTHON_RETURN_INIT_OK;
}
PYTHON_METHOD_DEFINITION(ptAnimation, sender, args)
{
PyObject *keyObject = NULL;
if (!PyArg_ParseTuple(args, "O", &keyObject))
{
PyErr_SetString(PyExc_TypeError, "sender requires a ptKey argument");
PYTHON_RETURN_ERROR;
}
if (!pyKey::Check(keyObject))
{
PyErr_SetString(PyExc_TypeError, "sender requires a ptKey argument");
PYTHON_RETURN_ERROR;
}
pyKey *key = pyKey::ConvertFrom(keyObject);
self->fThis->SetSender(*key);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptAnimation, addKey, args)
{
PyObject *keyObject = NULL;
if (!PyArg_ParseTuple(args, "O", &keyObject))
{
PyErr_SetString(PyExc_TypeError, "addKey requires a ptKey argument");
PYTHON_RETURN_ERROR;
}
if (!pyKey::Check(keyObject))
{
PyErr_SetString(PyExc_TypeError, "addKey requires a ptKey argument");
PYTHON_RETURN_ERROR;
}
pyKey *key = pyKey::ConvertFrom(keyObject);
self->fThis->AddRecvr(*key);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptAnimation, netForce, args)
{
char forceFlag;
if (!PyArg_ParseTuple(args, "b", &forceFlag))
{
PyErr_SetString(PyExc_TypeError, "netForce requires a boolean argument");
PYTHON_RETURN_ERROR;
}
self->fThis->SetNetForce(forceFlag != 0);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptAnimation, setAnimName, args)
{
char *name = NULL;
if (!PyArg_ParseTuple(args, "s", &name)) // name points at the internal buffer SO DON'T DELETE IT
{
PyErr_SetString(PyExc_TypeError, "setAnimName requires a string argument");
PYTHON_RETURN_ERROR;
}
self->fThis->SetAnimName(name);
PYTHON_RETURN_NONE;
}
PYTHON_BASIC_METHOD_DEFINITION(ptAnimation, play, Play)
PYTHON_BASIC_METHOD_DEFINITION(ptAnimation, stop, Stop)
PYTHON_BASIC_METHOD_DEFINITION(ptAnimation, resume, Resume)
PYTHON_METHOD_DEFINITION(ptAnimation, playRange, args)
{
float start, end;
if (!PyArg_ParseTuple(args, "ff", &start, &end))
{
PyErr_SetString(PyExc_TypeError, "playRange requires two floating-point arguments");
PYTHON_RETURN_ERROR;
}
self->fThis->PlayRange(start, end);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptAnimation, playToTime, args)
{
float time;
if (!PyArg_ParseTuple(args, "f", &time))
{
PyErr_SetString(PyExc_TypeError, "playToTime requires one floating-point argument");
PYTHON_RETURN_ERROR;
}
self->fThis->PlayToTime(time);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptAnimation, playToPercentage, args)
{
float percent;
if (!PyArg_ParseTuple(args, "f", &percent))
{
PyErr_SetString(PyExc_TypeError, "playToPercentage requires one floating-point argument");
PYTHON_RETURN_ERROR;
}
self->fThis->PlayToPercentage(percent);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptAnimation, skipToTime, args)
{
float time;
if (!PyArg_ParseTuple(args, "f", &time))
{
PyErr_SetString(PyExc_TypeError, "skipToTime requires one floating-point argument");
PYTHON_RETURN_ERROR;
}
self->fThis->SkipToTime(time);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptAnimation, looped, args)
{
char looped;
if (!PyArg_ParseTuple(args, "b", &looped))
{
PyErr_SetString(PyExc_TypeError, "looped requires a boolean argument");
PYTHON_RETURN_ERROR;
}
self->fThis->Looped(looped != 0);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptAnimation, backwards, args)
{
char backwards;
if (!PyArg_ParseTuple(args, "b", &backwards))
{
PyErr_SetString(PyExc_TypeError, "backwards requires a boolean argument");
PYTHON_RETURN_ERROR;
}
self->fThis->Backwards(backwards != 0);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptAnimation, setLoopStart, args)
{
float time;
if (!PyArg_ParseTuple(args, "f", &time))
{
PyErr_SetString(PyExc_TypeError, "setLoopStart requires one floating-point argument");
PYTHON_RETURN_ERROR;
}
self->fThis->SetLoopStart(time);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptAnimation, setLoopEnd, args)
{
float time;
if (!PyArg_ParseTuple(args, "f", &time))
{
PyErr_SetString(PyExc_TypeError, "setLoopEnd requires one floating-point argument");
PYTHON_RETURN_ERROR;
}
self->fThis->SetLoopEnd(time);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptAnimation, speed, args)
{
float speed;
if (!PyArg_ParseTuple(args, "f", &speed))
{
PyErr_SetString(PyExc_TypeError, "speed requires one floating-point argument");
PYTHON_RETURN_ERROR;
}
self->fThis->Speed(speed);
PYTHON_RETURN_NONE;
}
PYTHON_BASIC_METHOD_DEFINITION(ptAnimation, skipToBegin, SkipToBegin)
PYTHON_BASIC_METHOD_DEFINITION(ptAnimation, skipToEnd, SkipToEnd)
PYTHON_BASIC_METHOD_DEFINITION(ptAnimation, skipToLoopBegin, SkipToLoopBegin)
PYTHON_BASIC_METHOD_DEFINITION(ptAnimation, skipToLoopEnd, SkipToLoopEnd)
PYTHON_BASIC_METHOD_DEFINITION(ptAnimation, incrementForward, IncrementForward)
PYTHON_BASIC_METHOD_DEFINITION(ptAnimation, incrementBackward, IncrementBackward)
PYTHON_METHOD_DEFINITION_NOARGS(ptAnimation, getFirstKey)
{
PyObject *key = self->fThis->GetFirstRecvr();
if (key == NULL)
PYTHON_RETURN_NONE;
return key;
}
PYTHON_START_METHODS_TABLE(ptAnimation)
PYTHON_METHOD(ptAnimation, sender, "Params: selfKey\nSets the sender of the messages being sent to the animation modifier"),
PYTHON_METHOD(ptAnimation, addKey, "Params: key\nAdds an animation modifier to the list of receiver keys"),
PYTHON_METHOD(ptAnimation, netForce, "Params: forceFlag\nSpecify whether this object needs to use messages that are forced to the network\n"
"- This is to be used if your Python program is running on only one client\n"
"Such as a game master, only running on the client that owns a particular object"),
PYTHON_METHOD(ptAnimation, setAnimName, "Params: name\nSets the animation notetrack name (or (Entire Animation))"),
PYTHON_BASIC_METHOD(ptAnimation, play, "Plays the animation"),
PYTHON_BASIC_METHOD(ptAnimation, stop, "Stops the animation"),
PYTHON_BASIC_METHOD(ptAnimation, resume, "Resumes the animation from where it was stopped last"),
PYTHON_METHOD(ptAnimation, playRange, "Params: start,end\nPlay the animation from start to end"),
PYTHON_METHOD(ptAnimation, playToTime, "Params: time\nPlay the animation to the specified time"),
PYTHON_METHOD(ptAnimation, playToPercentage, "Params: zeroToOne\nPlay the animation to the specified percentage (0 to 1)"),
PYTHON_METHOD(ptAnimation, skipToTime, "Params: time\nSkip the animation to time (don't play)"),
PYTHON_METHOD(ptAnimation, looped, "Params: loopedFlag\nTurn on and off looping of the animation"),
PYTHON_METHOD(ptAnimation, backwards, "Params: backwardsFlag\nTurn on and off playing the animation backwards"),
PYTHON_METHOD(ptAnimation, setLoopStart, "Params: loopStart\nSets the loop starting position\n"
"- 'loopStart' is the number of seconds from the absolute beginning of the animation"),
PYTHON_METHOD(ptAnimation, setLoopEnd, "Params: loopEnd\nSets the loop ending position\n"
"- 'loopEnd' is the number of seconds from the absolute beginning of the animation"),
PYTHON_METHOD(ptAnimation, speed, "Params: speed\nSets the animation playback speed"),
PYTHON_BASIC_METHOD(ptAnimation, skipToBegin, "Skip to the beginning of the animation (don't play)"),
PYTHON_BASIC_METHOD(ptAnimation, skipToEnd, "Skip to the end of the animation (don't play)"),
PYTHON_BASIC_METHOD(ptAnimation, skipToLoopBegin, "Skip to the beginning of the animation loop (don't play)"),
PYTHON_BASIC_METHOD(ptAnimation, skipToLoopEnd, "Skip to the end of the animation loop (don't play)"),
PYTHON_BASIC_METHOD(ptAnimation, incrementForward, "Step the animation forward a frame"),
PYTHON_BASIC_METHOD(ptAnimation, incrementBackward, "Step the animation backward a frame"),
PYTHON_METHOD_NOARGS(ptAnimation, getFirstKey, "This will return a ptKey object that is the first receiver (target)\n"
"However, if the parent is not a modifier or not loaded, then None is returned."),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE(ptAnimation, "Params: key=None\nPlasma animation class");
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_IMPL(ptAnimation, cyAnimation)
PyObject *cyAnimation::New(PyObject *sender)
{
ptAnimation *newObj = (ptAnimation*)ptAnimation_type.tp_new(&ptAnimation_type, NULL, NULL);
pyKey *key = pyKey::ConvertFrom(sender);
newObj->fThis->SetSender(*key);
newObj->fThis->fAnimName = nil;
newObj->fThis->fNetForce = false;
return (PyObject*)newObj;
}
PyObject *cyAnimation::New(cyAnimation &obj)
{
ptAnimation *newObj = (ptAnimation*)ptAnimation_type.tp_new(&ptAnimation_type, NULL, NULL);
newObj->fThis->fSender = obj.fSender;
newObj->fThis->fRecvr = obj.fRecvr;
newObj->fThis->fAnimName = hsStrcpy(obj.fAnimName);
newObj->fThis->fNetForce = obj.fNetForce;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptAnimation, cyAnimation)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptAnimation, cyAnimation)
///////////////////////////////////////////////////////////////////////////
//
// AddPlasmaClasses - the python module definitions
//
void cyAnimation::AddPlasmaClasses(PyObject *m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptAnimation);
PYTHON_CLASS_IMPORT_END(m);
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "cyAnimation.h"
#include "hsUtils.h"
#include <python.h>
// glue functions
PYTHON_CLASS_DEFINITION(ptAnimation, cyAnimation);
PYTHON_DEFAULT_NEW_DEFINITION(ptAnimation, cyAnimation)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptAnimation)
PYTHON_INIT_DEFINITION(ptAnimation, args, keywords)
{
PyObject *keyObject = NULL;
if (!PyArg_ParseTuple(args, "|O", &keyObject))
{
PyErr_SetString(PyExc_TypeError, "__init__ expects an optional ptKey");
PYTHON_RETURN_INIT_ERROR;
}
if (keyObject == NULL) // no parameter was passed
PYTHON_RETURN_INIT_OK; // nothing to init
if (!pyKey::Check(keyObject))
{
PyErr_SetString(PyExc_TypeError, "__init__ expects an optional ptKey");
PYTHON_RETURN_INIT_ERROR;
}
pyKey *key = pyKey::ConvertFrom(keyObject);
self->fThis->SetSender(*key);
PYTHON_RETURN_INIT_OK;
}
PYTHON_METHOD_DEFINITION(ptAnimation, sender, args)
{
PyObject *keyObject = NULL;
if (!PyArg_ParseTuple(args, "O", &keyObject))
{
PyErr_SetString(PyExc_TypeError, "sender requires a ptKey argument");
PYTHON_RETURN_ERROR;
}
if (!pyKey::Check(keyObject))
{
PyErr_SetString(PyExc_TypeError, "sender requires a ptKey argument");
PYTHON_RETURN_ERROR;
}
pyKey *key = pyKey::ConvertFrom(keyObject);
self->fThis->SetSender(*key);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptAnimation, addKey, args)
{
PyObject *keyObject = NULL;
if (!PyArg_ParseTuple(args, "O", &keyObject))
{
PyErr_SetString(PyExc_TypeError, "addKey requires a ptKey argument");
PYTHON_RETURN_ERROR;
}
if (!pyKey::Check(keyObject))
{
PyErr_SetString(PyExc_TypeError, "addKey requires a ptKey argument");
PYTHON_RETURN_ERROR;
}
pyKey *key = pyKey::ConvertFrom(keyObject);
self->fThis->AddRecvr(*key);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptAnimation, netForce, args)
{
char forceFlag;
if (!PyArg_ParseTuple(args, "b", &forceFlag))
{
PyErr_SetString(PyExc_TypeError, "netForce requires a boolean argument");
PYTHON_RETURN_ERROR;
}
self->fThis->SetNetForce(forceFlag != 0);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptAnimation, setAnimName, args)
{
char *name = NULL;
if (!PyArg_ParseTuple(args, "s", &name)) // name points at the internal buffer SO DON'T DELETE IT
{
PyErr_SetString(PyExc_TypeError, "setAnimName requires a string argument");
PYTHON_RETURN_ERROR;
}
self->fThis->SetAnimName(name);
PYTHON_RETURN_NONE;
}
PYTHON_BASIC_METHOD_DEFINITION(ptAnimation, play, Play)
PYTHON_BASIC_METHOD_DEFINITION(ptAnimation, stop, Stop)
PYTHON_BASIC_METHOD_DEFINITION(ptAnimation, resume, Resume)
PYTHON_METHOD_DEFINITION(ptAnimation, playRange, args)
{
float start, end;
if (!PyArg_ParseTuple(args, "ff", &start, &end))
{
PyErr_SetString(PyExc_TypeError, "playRange requires two floating-point arguments");
PYTHON_RETURN_ERROR;
}
self->fThis->PlayRange(start, end);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptAnimation, playToTime, args)
{
float time;
if (!PyArg_ParseTuple(args, "f", &time))
{
PyErr_SetString(PyExc_TypeError, "playToTime requires one floating-point argument");
PYTHON_RETURN_ERROR;
}
self->fThis->PlayToTime(time);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptAnimation, playToPercentage, args)
{
float percent;
if (!PyArg_ParseTuple(args, "f", &percent))
{
PyErr_SetString(PyExc_TypeError, "playToPercentage requires one floating-point argument");
PYTHON_RETURN_ERROR;
}
self->fThis->PlayToPercentage(percent);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptAnimation, skipToTime, args)
{
float time;
if (!PyArg_ParseTuple(args, "f", &time))
{
PyErr_SetString(PyExc_TypeError, "skipToTime requires one floating-point argument");
PYTHON_RETURN_ERROR;
}
self->fThis->SkipToTime(time);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptAnimation, looped, args)
{
char looped;
if (!PyArg_ParseTuple(args, "b", &looped))
{
PyErr_SetString(PyExc_TypeError, "looped requires a boolean argument");
PYTHON_RETURN_ERROR;
}
self->fThis->Looped(looped != 0);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptAnimation, backwards, args)
{
char backwards;
if (!PyArg_ParseTuple(args, "b", &backwards))
{
PyErr_SetString(PyExc_TypeError, "backwards requires a boolean argument");
PYTHON_RETURN_ERROR;
}
self->fThis->Backwards(backwards != 0);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptAnimation, setLoopStart, args)
{
float time;
if (!PyArg_ParseTuple(args, "f", &time))
{
PyErr_SetString(PyExc_TypeError, "setLoopStart requires one floating-point argument");
PYTHON_RETURN_ERROR;
}
self->fThis->SetLoopStart(time);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptAnimation, setLoopEnd, args)
{
float time;
if (!PyArg_ParseTuple(args, "f", &time))
{
PyErr_SetString(PyExc_TypeError, "setLoopEnd requires one floating-point argument");
PYTHON_RETURN_ERROR;
}
self->fThis->SetLoopEnd(time);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptAnimation, speed, args)
{
float speed;
if (!PyArg_ParseTuple(args, "f", &speed))
{
PyErr_SetString(PyExc_TypeError, "speed requires one floating-point argument");
PYTHON_RETURN_ERROR;
}
self->fThis->Speed(speed);
PYTHON_RETURN_NONE;
}
PYTHON_BASIC_METHOD_DEFINITION(ptAnimation, skipToBegin, SkipToBegin)
PYTHON_BASIC_METHOD_DEFINITION(ptAnimation, skipToEnd, SkipToEnd)
PYTHON_BASIC_METHOD_DEFINITION(ptAnimation, skipToLoopBegin, SkipToLoopBegin)
PYTHON_BASIC_METHOD_DEFINITION(ptAnimation, skipToLoopEnd, SkipToLoopEnd)
PYTHON_BASIC_METHOD_DEFINITION(ptAnimation, incrementForward, IncrementForward)
PYTHON_BASIC_METHOD_DEFINITION(ptAnimation, incrementBackward, IncrementBackward)
PYTHON_METHOD_DEFINITION_NOARGS(ptAnimation, getFirstKey)
{
PyObject *key = self->fThis->GetFirstRecvr();
if (key == NULL)
PYTHON_RETURN_NONE;
return key;
}
PYTHON_START_METHODS_TABLE(ptAnimation)
PYTHON_METHOD(ptAnimation, sender, "Params: selfKey\nSets the sender of the messages being sent to the animation modifier"),
PYTHON_METHOD(ptAnimation, addKey, "Params: key\nAdds an animation modifier to the list of receiver keys"),
PYTHON_METHOD(ptAnimation, netForce, "Params: forceFlag\nSpecify whether this object needs to use messages that are forced to the network\n"
"- This is to be used if your Python program is running on only one client\n"
"Such as a game master, only running on the client that owns a particular object"),
PYTHON_METHOD(ptAnimation, setAnimName, "Params: name\nSets the animation notetrack name (or (Entire Animation))"),
PYTHON_BASIC_METHOD(ptAnimation, play, "Plays the animation"),
PYTHON_BASIC_METHOD(ptAnimation, stop, "Stops the animation"),
PYTHON_BASIC_METHOD(ptAnimation, resume, "Resumes the animation from where it was stopped last"),
PYTHON_METHOD(ptAnimation, playRange, "Params: start,end\nPlay the animation from start to end"),
PYTHON_METHOD(ptAnimation, playToTime, "Params: time\nPlay the animation to the specified time"),
PYTHON_METHOD(ptAnimation, playToPercentage, "Params: zeroToOne\nPlay the animation to the specified percentage (0 to 1)"),
PYTHON_METHOD(ptAnimation, skipToTime, "Params: time\nSkip the animation to time (don't play)"),
PYTHON_METHOD(ptAnimation, looped, "Params: loopedFlag\nTurn on and off looping of the animation"),
PYTHON_METHOD(ptAnimation, backwards, "Params: backwardsFlag\nTurn on and off playing the animation backwards"),
PYTHON_METHOD(ptAnimation, setLoopStart, "Params: loopStart\nSets the loop starting position\n"
"- 'loopStart' is the number of seconds from the absolute beginning of the animation"),
PYTHON_METHOD(ptAnimation, setLoopEnd, "Params: loopEnd\nSets the loop ending position\n"
"- 'loopEnd' is the number of seconds from the absolute beginning of the animation"),
PYTHON_METHOD(ptAnimation, speed, "Params: speed\nSets the animation playback speed"),
PYTHON_BASIC_METHOD(ptAnimation, skipToBegin, "Skip to the beginning of the animation (don't play)"),
PYTHON_BASIC_METHOD(ptAnimation, skipToEnd, "Skip to the end of the animation (don't play)"),
PYTHON_BASIC_METHOD(ptAnimation, skipToLoopBegin, "Skip to the beginning of the animation loop (don't play)"),
PYTHON_BASIC_METHOD(ptAnimation, skipToLoopEnd, "Skip to the end of the animation loop (don't play)"),
PYTHON_BASIC_METHOD(ptAnimation, incrementForward, "Step the animation forward a frame"),
PYTHON_BASIC_METHOD(ptAnimation, incrementBackward, "Step the animation backward a frame"),
PYTHON_METHOD_NOARGS(ptAnimation, getFirstKey, "This will return a ptKey object that is the first receiver (target)\n"
"However, if the parent is not a modifier or not loaded, then None is returned."),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE(ptAnimation, "Params: key=None\nPlasma animation class");
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_IMPL(ptAnimation, cyAnimation)
PyObject *cyAnimation::New(PyObject *sender)
{
ptAnimation *newObj = (ptAnimation*)ptAnimation_type.tp_new(&ptAnimation_type, NULL, NULL);
pyKey *key = pyKey::ConvertFrom(sender);
newObj->fThis->SetSender(*key);
newObj->fThis->fAnimName = nil;
newObj->fThis->fNetForce = false;
return (PyObject*)newObj;
}
PyObject *cyAnimation::New(cyAnimation &obj)
{
ptAnimation *newObj = (ptAnimation*)ptAnimation_type.tp_new(&ptAnimation_type, NULL, NULL);
newObj->fThis->fSender = obj.fSender;
newObj->fThis->fRecvr = obj.fRecvr;
newObj->fThis->fAnimName = hsStrcpy(obj.fAnimName);
newObj->fThis->fNetForce = obj.fNetForce;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptAnimation, cyAnimation)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptAnimation, cyAnimation)
///////////////////////////////////////////////////////////////////////////
//
// AddPlasmaClasses - the python module definitions
//
void cyAnimation::AddPlasmaClasses(PyObject *m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptAnimation);
PYTHON_CLASS_IMPORT_END(m);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,370 +1,370 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "cyCamera.h"
#include "pnMessage/plCameraMsg.h"
#include "plMessage/plInputEventMsg.h"
#include "pnKeyedObject/plFixedKey.h"
#include "pnKeyedObject/plUoid.h"
#include "hsResMgr.h"
#include "pyKey.h"
#include "plgDispatch.h"
#include "pfCamera/plVirtualCamNeu.h"
#include "pfCamera/plCameraModifier.h"
#include "pfCamera/plCameraBrain.h"
cyCamera::cyCamera()
{
// get _the_ virtual camera
plUoid pU( kVirtualCamera1_KEY );
hsResMgr* hrm = hsgResMgr::ResMgr();
if ( hrm)
fTheCam = hrm->FindKey( pU );
else
fTheCam = nil;
}
// setters
void cyCamera::SetSender(plKey &sender)
{
fSender = sender;
}
/////////////////////////////////////////////////////////////////////////////
//
// Function : Push
// PARAMETERS :
//
// PURPOSE : Save the current state of the virtual camera
//
// NOTE: doesn't work by itself at the moment
//
void cyCamera::Push(pyKey& newCamKey)
{
// create message
plCameraMsg* pMsg = TRACKED_NEW plCameraMsg;
if ( fSender )
pMsg->SetSender(fSender);
// if we're sending to the virtual camera
if ( fTheCam )
pMsg->AddReceiver(fTheCam);
else
// otherwise, broadcast by type
pMsg->SetBCastFlag(plMessage::kBCastByType);
// set command to do the transition
pMsg->SetCmd(plCameraMsg::kResponderTrigger);
pMsg->SetCmd(plCameraMsg::kRegionPushCamera);
// set the new camera
pMsg->SetNewCam(newCamKey.getKey());
plgDispatch::MsgSend( pMsg ); // whoosh... off it goes
}
/////////////////////////////////////////////////////////////////////////////
//
// Function : Pop
// PARAMETERS :
//
// PURPOSE : Restore the state of the virtual camera with a previously saved setting
//
void cyCamera::Pop(pyKey& oldCamKey)
{
// create message
plCameraMsg* pMsg = TRACKED_NEW plCameraMsg;
if ( fSender )
pMsg->SetSender(fSender);
// if we're sending to the virtual camera
if ( fTheCam )
pMsg->AddReceiver(fTheCam);
else
// otherwise, broadcast by type
pMsg->SetBCastFlag(plMessage::kBCastByType);
// set command to undo the camera... somehow not saying ResponderTrigger but Push means Pop...whatever
pMsg->SetCmd(plCameraMsg::kRegionPushCamera);
// set the new camera
pMsg->SetNewCam(oldCamKey.getKey());
plgDispatch::MsgSend( pMsg ); // whoosh... off it goes
}
/////////////////////////////////////////////////////////////////////////////
//
// Function : ControlKey
// PARAMETERS : controlKey - what command key to simulate being hit
// : activate - whether its being pressed or released (activated or deactivated)
//
// PURPOSE : Send controlKey commands to the virtual camera (should be like a pass thru)
//
void cyCamera::ControlKey(Int32 controlKey, hsBool activated)
{
// make sure that we have a virtual camera to send this to
if ( fTheCam )
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
// set sender if there is one
if ( fSender )
pMsg->SetSender(fSender);
// if we're sending to the virtual camera
pMsg->AddReceiver(fTheCam);
// set the control key and activateFlag
pMsg->SetControlCode((ControlEventCode)controlKey);
pMsg->SetControlActivated(activated);
plgDispatch::MsgSend( pMsg ); // whoosh... off it goes
}
}
/////////////////////////////////////////////////////////////////////////////
//
// Function : TransitionTo
// PARAMETERS : newCamKey - what to switch the camera to
// : time - how long it takes to transition to new camera
//
// PURPOSE : Transition to a new camera (position and settings)
//
void cyCamera::TransitionTo(pyKey& newCamKey, double time, hsBool save)
{
// create message
plCameraMsg* pMsg = TRACKED_NEW plCameraMsg;
if ( fSender )
pMsg->SetSender(fSender);
// must have a receiver!
if ( fTheCam )
{
pMsg->AddReceiver(fTheCam);
// set command to do the transition
pMsg->SetCmd(plCameraMsg::kTransitionTo);
// set the new camera
pMsg->SetNewCam(newCamKey.getKey());
// set the transition time
pMsg->SetTransTime(time);
// test to see if they want to save
if ( save )
pMsg->SetCmd(plCameraMsg::kPush);
plgDispatch::MsgSend( pMsg ); // whoosh... off it goes
}
}
void cyCamera::SetEnableFirstPersonOverride(hsBool state)
{
// must have a receiver!
if ( fTheCam )
{
// create message
plCameraMsg* pMsg = TRACKED_NEW plCameraMsg;
if ( fSender )
pMsg->SetSender(fSender);
pMsg->AddReceiver(fTheCam);
// set command to do the transition
pMsg->SetCmd(plCameraMsg::kPythonSetFirstPersonOverrideEnable);
// set the state
pMsg->SetActivated(state);
plgDispatch::MsgSend( pMsg ); // whoosh... off it goes
}
}
void cyCamera::UndoFirstPerson()
{
// create message
plCameraMsg* pMsg = TRACKED_NEW plCameraMsg;
if ( fSender )
pMsg->SetSender(fSender);
// must have a receiver!
if ( fTheCam )
{
pMsg->AddReceiver(fTheCam);
// set command to do the transition
pMsg->SetCmd(plCameraMsg::kPythonUndoFirstPerson);
plgDispatch::MsgSend( pMsg ); // whoosh... off it goes
}
}
hsScalar cyCamera::GetFOV()
{
if ( fTheCam )
{
plVirtualCam1* virtCam = plVirtualCam1::ConvertNoRef( fTheCam->ObjectIsLoaded() );
if ( virtCam )
{
plCameraModifier1* curCam = virtCam->GetCurrentCamera();
if ( curCam )
{
return curCam->GetFOVh();
}
}
}
return 0.0;
}
void cyCamera::SetFOV(hsScalar fov, double t)
{
if ( fTheCam )
{
plVirtualCam1* virtCam = plVirtualCam1::ConvertNoRef( fTheCam->ObjectIsLoaded() );
if ( virtCam )
{
plCameraModifier1* curCam = virtCam->GetCurrentCamera();
if ( curCam )
{
plCameraBrain1* camBrain = curCam->GetBrain();
if (camBrain)
{
camBrain->SetFOVGoal(fov,t);
}
}
}
}
}
void cyCamera::SetSmootherCam(hsBool state)
{
if ( fTheCam )
{
plVirtualCam1* virtCam = plVirtualCam1::ConvertNoRef( fTheCam->ObjectIsLoaded() );
if ( virtCam )
{
if (state)
{
virtCam->fUseAccelOverride = false;
}
else
{
virtCam->fAccel = 50.0;
virtCam->fDecel = 50.0;
virtCam->fVel = 100.0;
virtCam->fUseAccelOverride = true;
}
}
}
}
hsBool cyCamera::IsSmootherCam()
{
if ( fTheCam )
{
plVirtualCam1* virtCam = plVirtualCam1::ConvertNoRef( fTheCam->ObjectIsLoaded() );
if ( virtCam )
{
if ( virtCam->fUseAccelOverride )
return false;
else
return true;
}
}
return false;
}
void cyCamera::SetWalkAndVerticalPan(hsBool state)
{
if ( fTheCam )
{
plVirtualCam1* virtCam = plVirtualCam1::ConvertNoRef( fTheCam->ObjectIsLoaded() );
if ( virtCam )
{
if (state)
virtCam->WalkPan3rdPerson = true;
else
virtCam->WalkPan3rdPerson = false;
}
}
}
hsBool cyCamera::IsWalkAndVerticalPan()
{
if ( fTheCam )
{
plVirtualCam1* virtCam = plVirtualCam1::ConvertNoRef( fTheCam->ObjectIsLoaded() );
if ( virtCam )
{
return virtCam->WalkPan3rdPerson;
}
}
return false;
}
void cyCamera::SetStayInFirstPerson(hsBool state)
{
if ( fTheCam )
{
plVirtualCam1* virtCam = plVirtualCam1::ConvertNoRef( fTheCam->ObjectIsLoaded() );
if ( virtCam )
{
if (state)
virtCam->StayInFirstPersonForever = true;
else
virtCam->StayInFirstPersonForever = false;
}
}
}
hsBool cyCamera::IsStayInFirstPerson()
{
if ( fTheCam )
{
plVirtualCam1* virtCam = plVirtualCam1::ConvertNoRef( fTheCam->ObjectIsLoaded() );
if ( virtCam )
{
return virtCam->StayInFirstPersonForever;
}
}
return false;
}
void cyCamera::SetAspectRatio(float aspectratio)
{
plVirtualCam1::SetAspectRatio(aspectratio);
}
float cyCamera::GetAspectRatio()
{
return plVirtualCam1::GetAspectRatio();
}
void cyCamera::RefreshFOV()
{
plVirtualCam1::SetFOV(plVirtualCam1::GetFOVw(), plVirtualCam1::GetFOVh());
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "cyCamera.h"
#include "pnMessage/plCameraMsg.h"
#include "plMessage/plInputEventMsg.h"
#include "pnKeyedObject/plFixedKey.h"
#include "pnKeyedObject/plUoid.h"
#include "hsResMgr.h"
#include "pyKey.h"
#include "plgDispatch.h"
#include "pfCamera/plVirtualCamNeu.h"
#include "pfCamera/plCameraModifier.h"
#include "pfCamera/plCameraBrain.h"
cyCamera::cyCamera()
{
// get _the_ virtual camera
plUoid pU( kVirtualCamera1_KEY );
hsResMgr* hrm = hsgResMgr::ResMgr();
if ( hrm)
fTheCam = hrm->FindKey( pU );
else
fTheCam = nil;
}
// setters
void cyCamera::SetSender(plKey &sender)
{
fSender = sender;
}
/////////////////////////////////////////////////////////////////////////////
//
// Function : Push
// PARAMETERS :
//
// PURPOSE : Save the current state of the virtual camera
//
// NOTE: doesn't work by itself at the moment
//
void cyCamera::Push(pyKey& newCamKey)
{
// create message
plCameraMsg* pMsg = TRACKED_NEW plCameraMsg;
if ( fSender )
pMsg->SetSender(fSender);
// if we're sending to the virtual camera
if ( fTheCam )
pMsg->AddReceiver(fTheCam);
else
// otherwise, broadcast by type
pMsg->SetBCastFlag(plMessage::kBCastByType);
// set command to do the transition
pMsg->SetCmd(plCameraMsg::kResponderTrigger);
pMsg->SetCmd(plCameraMsg::kRegionPushCamera);
// set the new camera
pMsg->SetNewCam(newCamKey.getKey());
plgDispatch::MsgSend( pMsg ); // whoosh... off it goes
}
/////////////////////////////////////////////////////////////////////////////
//
// Function : Pop
// PARAMETERS :
//
// PURPOSE : Restore the state of the virtual camera with a previously saved setting
//
void cyCamera::Pop(pyKey& oldCamKey)
{
// create message
plCameraMsg* pMsg = TRACKED_NEW plCameraMsg;
if ( fSender )
pMsg->SetSender(fSender);
// if we're sending to the virtual camera
if ( fTheCam )
pMsg->AddReceiver(fTheCam);
else
// otherwise, broadcast by type
pMsg->SetBCastFlag(plMessage::kBCastByType);
// set command to undo the camera... somehow not saying ResponderTrigger but Push means Pop...whatever
pMsg->SetCmd(plCameraMsg::kRegionPushCamera);
// set the new camera
pMsg->SetNewCam(oldCamKey.getKey());
plgDispatch::MsgSend( pMsg ); // whoosh... off it goes
}
/////////////////////////////////////////////////////////////////////////////
//
// Function : ControlKey
// PARAMETERS : controlKey - what command key to simulate being hit
// : activate - whether its being pressed or released (activated or deactivated)
//
// PURPOSE : Send controlKey commands to the virtual camera (should be like a pass thru)
//
void cyCamera::ControlKey(Int32 controlKey, hsBool activated)
{
// make sure that we have a virtual camera to send this to
if ( fTheCam )
{
plControlEventMsg* pMsg = TRACKED_NEW plControlEventMsg;
// set sender if there is one
if ( fSender )
pMsg->SetSender(fSender);
// if we're sending to the virtual camera
pMsg->AddReceiver(fTheCam);
// set the control key and activateFlag
pMsg->SetControlCode((ControlEventCode)controlKey);
pMsg->SetControlActivated(activated);
plgDispatch::MsgSend( pMsg ); // whoosh... off it goes
}
}
/////////////////////////////////////////////////////////////////////////////
//
// Function : TransitionTo
// PARAMETERS : newCamKey - what to switch the camera to
// : time - how long it takes to transition to new camera
//
// PURPOSE : Transition to a new camera (position and settings)
//
void cyCamera::TransitionTo(pyKey& newCamKey, double time, hsBool save)
{
// create message
plCameraMsg* pMsg = TRACKED_NEW plCameraMsg;
if ( fSender )
pMsg->SetSender(fSender);
// must have a receiver!
if ( fTheCam )
{
pMsg->AddReceiver(fTheCam);
// set command to do the transition
pMsg->SetCmd(plCameraMsg::kTransitionTo);
// set the new camera
pMsg->SetNewCam(newCamKey.getKey());
// set the transition time
pMsg->SetTransTime(time);
// test to see if they want to save
if ( save )
pMsg->SetCmd(plCameraMsg::kPush);
plgDispatch::MsgSend( pMsg ); // whoosh... off it goes
}
}
void cyCamera::SetEnableFirstPersonOverride(hsBool state)
{
// must have a receiver!
if ( fTheCam )
{
// create message
plCameraMsg* pMsg = TRACKED_NEW plCameraMsg;
if ( fSender )
pMsg->SetSender(fSender);
pMsg->AddReceiver(fTheCam);
// set command to do the transition
pMsg->SetCmd(plCameraMsg::kPythonSetFirstPersonOverrideEnable);
// set the state
pMsg->SetActivated(state);
plgDispatch::MsgSend( pMsg ); // whoosh... off it goes
}
}
void cyCamera::UndoFirstPerson()
{
// create message
plCameraMsg* pMsg = TRACKED_NEW plCameraMsg;
if ( fSender )
pMsg->SetSender(fSender);
// must have a receiver!
if ( fTheCam )
{
pMsg->AddReceiver(fTheCam);
// set command to do the transition
pMsg->SetCmd(plCameraMsg::kPythonUndoFirstPerson);
plgDispatch::MsgSend( pMsg ); // whoosh... off it goes
}
}
hsScalar cyCamera::GetFOV()
{
if ( fTheCam )
{
plVirtualCam1* virtCam = plVirtualCam1::ConvertNoRef( fTheCam->ObjectIsLoaded() );
if ( virtCam )
{
plCameraModifier1* curCam = virtCam->GetCurrentCamera();
if ( curCam )
{
return curCam->GetFOVh();
}
}
}
return 0.0;
}
void cyCamera::SetFOV(hsScalar fov, double t)
{
if ( fTheCam )
{
plVirtualCam1* virtCam = plVirtualCam1::ConvertNoRef( fTheCam->ObjectIsLoaded() );
if ( virtCam )
{
plCameraModifier1* curCam = virtCam->GetCurrentCamera();
if ( curCam )
{
plCameraBrain1* camBrain = curCam->GetBrain();
if (camBrain)
{
camBrain->SetFOVGoal(fov,t);
}
}
}
}
}
void cyCamera::SetSmootherCam(hsBool state)
{
if ( fTheCam )
{
plVirtualCam1* virtCam = plVirtualCam1::ConvertNoRef( fTheCam->ObjectIsLoaded() );
if ( virtCam )
{
if (state)
{
virtCam->fUseAccelOverride = false;
}
else
{
virtCam->fAccel = 50.0;
virtCam->fDecel = 50.0;
virtCam->fVel = 100.0;
virtCam->fUseAccelOverride = true;
}
}
}
}
hsBool cyCamera::IsSmootherCam()
{
if ( fTheCam )
{
plVirtualCam1* virtCam = plVirtualCam1::ConvertNoRef( fTheCam->ObjectIsLoaded() );
if ( virtCam )
{
if ( virtCam->fUseAccelOverride )
return false;
else
return true;
}
}
return false;
}
void cyCamera::SetWalkAndVerticalPan(hsBool state)
{
if ( fTheCam )
{
plVirtualCam1* virtCam = plVirtualCam1::ConvertNoRef( fTheCam->ObjectIsLoaded() );
if ( virtCam )
{
if (state)
virtCam->WalkPan3rdPerson = true;
else
virtCam->WalkPan3rdPerson = false;
}
}
}
hsBool cyCamera::IsWalkAndVerticalPan()
{
if ( fTheCam )
{
plVirtualCam1* virtCam = plVirtualCam1::ConvertNoRef( fTheCam->ObjectIsLoaded() );
if ( virtCam )
{
return virtCam->WalkPan3rdPerson;
}
}
return false;
}
void cyCamera::SetStayInFirstPerson(hsBool state)
{
if ( fTheCam )
{
plVirtualCam1* virtCam = plVirtualCam1::ConvertNoRef( fTheCam->ObjectIsLoaded() );
if ( virtCam )
{
if (state)
virtCam->StayInFirstPersonForever = true;
else
virtCam->StayInFirstPersonForever = false;
}
}
}
hsBool cyCamera::IsStayInFirstPerson()
{
if ( fTheCam )
{
plVirtualCam1* virtCam = plVirtualCam1::ConvertNoRef( fTheCam->ObjectIsLoaded() );
if ( virtCam )
{
return virtCam->StayInFirstPersonForever;
}
}
return false;
}
void cyCamera::SetAspectRatio(float aspectratio)
{
plVirtualCam1::SetAspectRatio(aspectratio);
}
float cyCamera::GetAspectRatio()
{
return plVirtualCam1::GetAspectRatio();
}
void cyCamera::RefreshFOV()
{
plVirtualCam1::SetFOV(plVirtualCam1::GetFOVw(), plVirtualCam1::GetFOVh());
}

View File

@ -1,107 +1,107 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef cyCamera_h
#define cyCamera_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: cyCamera
//
// PURPOSE: Class wrapper to map camera functions to plasma2 message
//
#include "hsTypes.h"
#include "pnKeyedObject/plKey.h"
class pyKey;
#include <python.h>
#include "pyGlueHelpers.h"
class cyCamera
{
protected:
plKey fSender;
plKey fTheCam;
cyCamera();
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptCamera);
PYTHON_CLASS_NEW_DEFINITION;
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a cyCamera object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(cyCamera); // converts a PyObject to a cyCamera (throws error if not correct type)
static void AddPlasmaClasses(PyObject *m);
// setters
void SetSender(plKey &sender);
// Save the current state of the virtual camera
// NOTE: doesn't work by itself at the moment
virtual void Push(pyKey& newCamKey);
// Restore the state of the virtual camera with a previously saved setting
virtual void Pop(pyKey& oldCamKey);
// Send controlKey commands to the virtual camera (should be like a pass thru)
virtual void ControlKey(Int32 controlKey, hsBool activated);
/////////////////////////////////////////////////////////////////////////////
//
// Function : TransitionTo
// PARAMETERS : newCamKey - what to switch the camera to
// : time - how long it takes to transition to new camera
//
// PURPOSE : Transition to a new camera (position and settings)
//
virtual void TransitionTo(pyKey& newCamKey, double time, hsBool save);
virtual void SetEnableFirstPersonOverride(hsBool state);
virtual void EnableFirstPersonOverride() { SetEnableFirstPersonOverride(true); }
virtual void DisableFirstPersonOverride() { SetEnableFirstPersonOverride(false); }
virtual void UndoFirstPerson();
virtual hsScalar GetFOV();
virtual void SetFOV(hsScalar fov, double t);
virtual void SetSmootherCam(hsBool state);
virtual hsBool IsSmootherCam();
virtual void SetWalkAndVerticalPan(hsBool state);
virtual hsBool IsWalkAndVerticalPan();
virtual void SetStayInFirstPerson(hsBool state);
virtual hsBool IsStayInFirstPerson();
virtual void SetAspectRatio(float aspectratio);
virtual float GetAspectRatio();
virtual void RefreshFOV();
};
#endif // cyCamera_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef cyCamera_h
#define cyCamera_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: cyCamera
//
// PURPOSE: Class wrapper to map camera functions to plasma2 message
//
#include "hsTypes.h"
#include "pnKeyedObject/plKey.h"
class pyKey;
#include <python.h>
#include "pyGlueHelpers.h"
class cyCamera
{
protected:
plKey fSender;
plKey fTheCam;
cyCamera();
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptCamera);
PYTHON_CLASS_NEW_DEFINITION;
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a cyCamera object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(cyCamera); // converts a PyObject to a cyCamera (throws error if not correct type)
static void AddPlasmaClasses(PyObject *m);
// setters
void SetSender(plKey &sender);
// Save the current state of the virtual camera
// NOTE: doesn't work by itself at the moment
virtual void Push(pyKey& newCamKey);
// Restore the state of the virtual camera with a previously saved setting
virtual void Pop(pyKey& oldCamKey);
// Send controlKey commands to the virtual camera (should be like a pass thru)
virtual void ControlKey(Int32 controlKey, hsBool activated);
/////////////////////////////////////////////////////////////////////////////
//
// Function : TransitionTo
// PARAMETERS : newCamKey - what to switch the camera to
// : time - how long it takes to transition to new camera
//
// PURPOSE : Transition to a new camera (position and settings)
//
virtual void TransitionTo(pyKey& newCamKey, double time, hsBool save);
virtual void SetEnableFirstPersonOverride(hsBool state);
virtual void EnableFirstPersonOverride() { SetEnableFirstPersonOverride(true); }
virtual void DisableFirstPersonOverride() { SetEnableFirstPersonOverride(false); }
virtual void UndoFirstPerson();
virtual hsScalar GetFOV();
virtual void SetFOV(hsScalar fov, double t);
virtual void SetSmootherCam(hsBool state);
virtual hsBool IsSmootherCam();
virtual void SetWalkAndVerticalPan(hsBool state);
virtual hsBool IsWalkAndVerticalPan();
virtual void SetStayInFirstPerson(hsBool state);
virtual hsBool IsStayInFirstPerson();
virtual void SetAspectRatio(float aspectratio);
virtual float GetAspectRatio();
virtual void RefreshFOV();
};
#endif // cyCamera_h

View File

@ -1,261 +1,261 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "cyCamera.h"
#include "pyKey.h"
#include <python.h>
// glue functions
PYTHON_CLASS_DEFINITION(ptCamera, cyCamera);
PYTHON_DEFAULT_NEW_DEFINITION(ptCamera, cyCamera)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptCamera)
PYTHON_INIT_DEFINITION(ptCamera, args, keywords)
{
PYTHON_RETURN_INIT_OK;
}
PYTHON_METHOD_DEFINITION(ptCamera, save, args)
{
PyObject* keyObj = NULL;
if (!PyArg_ParseTuple(args, "O", &keyObj))
{
PyErr_SetString(PyExc_TypeError, "save expects a ptKey object");
PYTHON_RETURN_ERROR;
}
if (!pyKey::Check(keyObj))
{
PyErr_SetString(PyExc_TypeError, "save expects a ptKey object");
PYTHON_RETURN_ERROR;
}
pyKey* key = pyKey::ConvertFrom(keyObj);
self->fThis->Push(*key);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptCamera, restore, args)
{
PyObject* keyObj = NULL;
if (!PyArg_ParseTuple(args, "O", &keyObj))
{
PyErr_SetString(PyExc_TypeError, "restore expects a ptKey object");
PYTHON_RETURN_ERROR;
}
if (!pyKey::Check(keyObj))
{
PyErr_SetString(PyExc_TypeError, "restore expects a ptKey object");
PYTHON_RETURN_ERROR;
}
pyKey* key = pyKey::ConvertFrom(keyObj);
self->fThis->Pop(*key);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptCamera, controlKey, args)
{
long controlKey;
char activateFlag;
if (!PyArg_ParseTuple(args, "lb", &controlKey, &activateFlag))
{
PyErr_SetString(PyExc_TypeError, "controlKey expects a long and a boolean");
PYTHON_RETURN_ERROR;
}
self->fThis->ControlKey(controlKey, activateFlag != 0);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptCamera, set, args)
{
PyObject* keyObj = NULL;
double time;
char save;
if (!PyArg_ParseTuple(args, "Odb", &keyObj, &time, &save))
{
PyErr_SetString(PyExc_TypeError, "set expects a ptKey, double, and a boolean");
PYTHON_RETURN_ERROR;
}
if (!pyKey::Check(keyObj))
{
PyErr_SetString(PyExc_TypeError, "set expects a ptKey, double, and a boolean");
PYTHON_RETURN_ERROR;
}
pyKey* key = pyKey::ConvertFrom(keyObj);
self->fThis->TransitionTo(*key, time, save != 0);
PYTHON_RETURN_NONE;
}
PYTHON_BASIC_METHOD_DEFINITION(ptCamera, enableFirstPersonOverride, EnableFirstPersonOverride)
PYTHON_BASIC_METHOD_DEFINITION(ptCamera, disableFirstPersonOverride, DisableFirstPersonOverride)
PYTHON_BASIC_METHOD_DEFINITION(ptCamera, undoFirstPerson, UndoFirstPerson)
PYTHON_METHOD_DEFINITION_NOARGS(ptCamera, getFOV)
{
return PyFloat_FromDouble(self->fThis->GetFOV());
}
PYTHON_METHOD_DEFINITION(ptCamera, setFOV, args)
{
float fov;
double time;
if (!PyArg_ParseTuple(args, "fd", &fov, &time))
{
PyErr_SetString(PyExc_TypeError, "setFOV expects a float and a double");
PYTHON_RETURN_ERROR;
}
self->fThis->SetFOV(fov, time);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptCamera, setSmootherCam, args)
{
char state;
if (!PyArg_ParseTuple(args, "b", &state))
{
PyErr_SetString(PyExc_TypeError, "setSmootherCam expects a boolean");
PYTHON_RETURN_ERROR;
}
self->fThis->SetSmootherCam(state != 0);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptCamera, isSmootherCam)
{
PYTHON_RETURN_BOOL(self->fThis->IsSmootherCam());
}
PYTHON_METHOD_DEFINITION(ptCamera, setWalkAndVerticalPan, args)
{
char state;
if (!PyArg_ParseTuple(args, "b", &state))
{
PyErr_SetString(PyExc_TypeError, "setWalkAndVerticalPan expects a boolean");
PYTHON_RETURN_ERROR;
}
self->fThis->SetWalkAndVerticalPan(state != 0);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptCamera, isWalkAndVerticalPan)
{
PYTHON_RETURN_BOOL(self->fThis->IsWalkAndVerticalPan());
}
PYTHON_METHOD_DEFINITION(ptCamera, setStayInFirstPerson, args)
{
char state;
if (!PyArg_ParseTuple(args, "b", &state))
{
PyErr_SetString(PyExc_TypeError, "setStayInFirstPerson expects a boolean");
PYTHON_RETURN_ERROR;
}
self->fThis->SetStayInFirstPerson(state != 0);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptCamera, isStayInFirstPerson)
{
PYTHON_RETURN_BOOL(self->fThis->IsStayInFirstPerson());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptCamera, getAspectRatio)
{
return PyFloat_FromDouble(self->fThis->GetAspectRatio());
}
PYTHON_METHOD_DEFINITION(ptCamera, setAspectRatio, args)
{
float aspect;
if (!PyArg_ParseTuple(args, "f", &aspect))
{
PyErr_SetString(PyExc_TypeError, "setAspectRatio expects a float");
PYTHON_RETURN_ERROR;
}
self->fThis->SetAspectRatio(aspect);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptCamera, refreshFOV)
{
self->fThis->RefreshFOV();
PYTHON_RETURN_NONE;
}
PYTHON_START_METHODS_TABLE(ptCamera)
PYTHON_METHOD(ptCamera, save, "Params: cameraKey\nSaves the current camera and sets the camera to cameraKey"),
PYTHON_METHOD(ptCamera, restore, "Params: cameraKey\nRestores camera to saved one"),
PYTHON_METHOD(ptCamera, controlKey, "Params: controlKey,activateFlag\nSend a control key to the camera as if it was hit by the user.\n"
"This is for sending things like pan-up, pan-down, zoom-in, etc."),
PYTHON_METHOD(ptCamera, set, "Params: cameraKey,time,save\nDO NOT USE"),
PYTHON_BASIC_METHOD(ptCamera, enableFirstPersonOverride, "Allows the user to override the camera and go to a first person camera."),
PYTHON_BASIC_METHOD(ptCamera, disableFirstPersonOverride, "Does _not_ allow the user to override the camera to go to first person camera."),
PYTHON_BASIC_METHOD(ptCamera, undoFirstPerson, "If the user has overridden the camera to be in first person, this will take them out of first person.\n"
"If the user didn't override the camera, then this will do nothing."),
PYTHON_METHOD_NOARGS(ptCamera, getFOV, "Returns the current camera's FOV(h)"),
PYTHON_METHOD(ptCamera, setFOV, "Params: fov, time\nSets the current cameras FOV (based on h)"),
PYTHON_METHOD(ptCamera, setSmootherCam, "Params: state\nSet the faster cams thing"),
PYTHON_METHOD_NOARGS(ptCamera, isSmootherCam, "Returns true if we are using the faster cams thing"),
PYTHON_METHOD(ptCamera, setWalkAndVerticalPan, "Params: state\nSet Walk and chew gum"),
PYTHON_METHOD_NOARGS(ptCamera, isWalkAndVerticalPan, "Returns true if we are walking and chewing gum"),
PYTHON_METHOD(ptCamera, setStayInFirstPerson, "Params: state\nSet Stay In First Person Always"),
PYTHON_METHOD_NOARGS(ptCamera, isStayInFirstPerson, "Are we staying in first person?"),
PYTHON_METHOD_NOARGS(ptCamera, getAspectRatio, "Get the global aspect ratio"),
PYTHON_METHOD(ptCamera, setAspectRatio, "Params: aspect\nSet the global aspect ratio"),
PYTHON_METHOD_NOARGS(ptCamera, refreshFOV, "Refreshes the FOV"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE(ptCamera, "Plasma camera class");
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_IMPL(ptCamera, cyCamera)
PYTHON_CLASS_CHECK_IMPL(ptCamera, cyCamera)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptCamera, cyCamera)
///////////////////////////////////////////////////////////////////////////
//
// AddPlasmaClasses - the python module definitions
//
void cyCamera::AddPlasmaClasses(PyObject *m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptCamera);
PYTHON_CLASS_IMPORT_END(m);
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "cyCamera.h"
#include "pyKey.h"
#include <python.h>
// glue functions
PYTHON_CLASS_DEFINITION(ptCamera, cyCamera);
PYTHON_DEFAULT_NEW_DEFINITION(ptCamera, cyCamera)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptCamera)
PYTHON_INIT_DEFINITION(ptCamera, args, keywords)
{
PYTHON_RETURN_INIT_OK;
}
PYTHON_METHOD_DEFINITION(ptCamera, save, args)
{
PyObject* keyObj = NULL;
if (!PyArg_ParseTuple(args, "O", &keyObj))
{
PyErr_SetString(PyExc_TypeError, "save expects a ptKey object");
PYTHON_RETURN_ERROR;
}
if (!pyKey::Check(keyObj))
{
PyErr_SetString(PyExc_TypeError, "save expects a ptKey object");
PYTHON_RETURN_ERROR;
}
pyKey* key = pyKey::ConvertFrom(keyObj);
self->fThis->Push(*key);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptCamera, restore, args)
{
PyObject* keyObj = NULL;
if (!PyArg_ParseTuple(args, "O", &keyObj))
{
PyErr_SetString(PyExc_TypeError, "restore expects a ptKey object");
PYTHON_RETURN_ERROR;
}
if (!pyKey::Check(keyObj))
{
PyErr_SetString(PyExc_TypeError, "restore expects a ptKey object");
PYTHON_RETURN_ERROR;
}
pyKey* key = pyKey::ConvertFrom(keyObj);
self->fThis->Pop(*key);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptCamera, controlKey, args)
{
long controlKey;
char activateFlag;
if (!PyArg_ParseTuple(args, "lb", &controlKey, &activateFlag))
{
PyErr_SetString(PyExc_TypeError, "controlKey expects a long and a boolean");
PYTHON_RETURN_ERROR;
}
self->fThis->ControlKey(controlKey, activateFlag != 0);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptCamera, set, args)
{
PyObject* keyObj = NULL;
double time;
char save;
if (!PyArg_ParseTuple(args, "Odb", &keyObj, &time, &save))
{
PyErr_SetString(PyExc_TypeError, "set expects a ptKey, double, and a boolean");
PYTHON_RETURN_ERROR;
}
if (!pyKey::Check(keyObj))
{
PyErr_SetString(PyExc_TypeError, "set expects a ptKey, double, and a boolean");
PYTHON_RETURN_ERROR;
}
pyKey* key = pyKey::ConvertFrom(keyObj);
self->fThis->TransitionTo(*key, time, save != 0);
PYTHON_RETURN_NONE;
}
PYTHON_BASIC_METHOD_DEFINITION(ptCamera, enableFirstPersonOverride, EnableFirstPersonOverride)
PYTHON_BASIC_METHOD_DEFINITION(ptCamera, disableFirstPersonOverride, DisableFirstPersonOverride)
PYTHON_BASIC_METHOD_DEFINITION(ptCamera, undoFirstPerson, UndoFirstPerson)
PYTHON_METHOD_DEFINITION_NOARGS(ptCamera, getFOV)
{
return PyFloat_FromDouble(self->fThis->GetFOV());
}
PYTHON_METHOD_DEFINITION(ptCamera, setFOV, args)
{
float fov;
double time;
if (!PyArg_ParseTuple(args, "fd", &fov, &time))
{
PyErr_SetString(PyExc_TypeError, "setFOV expects a float and a double");
PYTHON_RETURN_ERROR;
}
self->fThis->SetFOV(fov, time);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptCamera, setSmootherCam, args)
{
char state;
if (!PyArg_ParseTuple(args, "b", &state))
{
PyErr_SetString(PyExc_TypeError, "setSmootherCam expects a boolean");
PYTHON_RETURN_ERROR;
}
self->fThis->SetSmootherCam(state != 0);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptCamera, isSmootherCam)
{
PYTHON_RETURN_BOOL(self->fThis->IsSmootherCam());
}
PYTHON_METHOD_DEFINITION(ptCamera, setWalkAndVerticalPan, args)
{
char state;
if (!PyArg_ParseTuple(args, "b", &state))
{
PyErr_SetString(PyExc_TypeError, "setWalkAndVerticalPan expects a boolean");
PYTHON_RETURN_ERROR;
}
self->fThis->SetWalkAndVerticalPan(state != 0);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptCamera, isWalkAndVerticalPan)
{
PYTHON_RETURN_BOOL(self->fThis->IsWalkAndVerticalPan());
}
PYTHON_METHOD_DEFINITION(ptCamera, setStayInFirstPerson, args)
{
char state;
if (!PyArg_ParseTuple(args, "b", &state))
{
PyErr_SetString(PyExc_TypeError, "setStayInFirstPerson expects a boolean");
PYTHON_RETURN_ERROR;
}
self->fThis->SetStayInFirstPerson(state != 0);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptCamera, isStayInFirstPerson)
{
PYTHON_RETURN_BOOL(self->fThis->IsStayInFirstPerson());
}
PYTHON_METHOD_DEFINITION_NOARGS(ptCamera, getAspectRatio)
{
return PyFloat_FromDouble(self->fThis->GetAspectRatio());
}
PYTHON_METHOD_DEFINITION(ptCamera, setAspectRatio, args)
{
float aspect;
if (!PyArg_ParseTuple(args, "f", &aspect))
{
PyErr_SetString(PyExc_TypeError, "setAspectRatio expects a float");
PYTHON_RETURN_ERROR;
}
self->fThis->SetAspectRatio(aspect);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptCamera, refreshFOV)
{
self->fThis->RefreshFOV();
PYTHON_RETURN_NONE;
}
PYTHON_START_METHODS_TABLE(ptCamera)
PYTHON_METHOD(ptCamera, save, "Params: cameraKey\nSaves the current camera and sets the camera to cameraKey"),
PYTHON_METHOD(ptCamera, restore, "Params: cameraKey\nRestores camera to saved one"),
PYTHON_METHOD(ptCamera, controlKey, "Params: controlKey,activateFlag\nSend a control key to the camera as if it was hit by the user.\n"
"This is for sending things like pan-up, pan-down, zoom-in, etc."),
PYTHON_METHOD(ptCamera, set, "Params: cameraKey,time,save\nDO NOT USE"),
PYTHON_BASIC_METHOD(ptCamera, enableFirstPersonOverride, "Allows the user to override the camera and go to a first person camera."),
PYTHON_BASIC_METHOD(ptCamera, disableFirstPersonOverride, "Does _not_ allow the user to override the camera to go to first person camera."),
PYTHON_BASIC_METHOD(ptCamera, undoFirstPerson, "If the user has overridden the camera to be in first person, this will take them out of first person.\n"
"If the user didn't override the camera, then this will do nothing."),
PYTHON_METHOD_NOARGS(ptCamera, getFOV, "Returns the current camera's FOV(h)"),
PYTHON_METHOD(ptCamera, setFOV, "Params: fov, time\nSets the current cameras FOV (based on h)"),
PYTHON_METHOD(ptCamera, setSmootherCam, "Params: state\nSet the faster cams thing"),
PYTHON_METHOD_NOARGS(ptCamera, isSmootherCam, "Returns true if we are using the faster cams thing"),
PYTHON_METHOD(ptCamera, setWalkAndVerticalPan, "Params: state\nSet Walk and chew gum"),
PYTHON_METHOD_NOARGS(ptCamera, isWalkAndVerticalPan, "Returns true if we are walking and chewing gum"),
PYTHON_METHOD(ptCamera, setStayInFirstPerson, "Params: state\nSet Stay In First Person Always"),
PYTHON_METHOD_NOARGS(ptCamera, isStayInFirstPerson, "Are we staying in first person?"),
PYTHON_METHOD_NOARGS(ptCamera, getAspectRatio, "Get the global aspect ratio"),
PYTHON_METHOD(ptCamera, setAspectRatio, "Params: aspect\nSet the global aspect ratio"),
PYTHON_METHOD_NOARGS(ptCamera, refreshFOV, "Refreshes the FOV"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE(ptCamera, "Plasma camera class");
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_IMPL(ptCamera, cyCamera)
PYTHON_CLASS_CHECK_IMPL(ptCamera, cyCamera)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptCamera, cyCamera)
///////////////////////////////////////////////////////////////////////////
//
// AddPlasmaClasses - the python module definitions
//
void cyCamera::AddPlasmaClasses(PyObject *m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptCamera);
PYTHON_CLASS_IMPORT_END(m);
}

View File

@ -1,105 +1,105 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "cyDraw.h"
#include "plgDispatch.h"
#include "hsBitVector.h"
#include "pnMessage/plEnableMsg.h"
cyDraw::cyDraw(plKey sender, plKey recvr)
{
SetSender(sender);
AddRecvr(recvr);
fNetForce = false;
}
// setters
void cyDraw::SetSender(plKey &sender)
{
fSender = sender;
}
void cyDraw::AddRecvr(plKey &recvr)
{
if ( recvr != nil )
fRecvr.Append(recvr);
}
void cyDraw::SetNetForce(hsBool state)
{
// set our flag
fNetForce = state;
}
void cyDraw::EnableT(hsBool state)
{
// must have a receiver!
if ( fRecvr.Count() > 0 )
{
// create message
plEnableMsg* pMsg = TRACKED_NEW plEnableMsg;
// check if this needs to be network forced to all clients
if (fNetForce )
{
// set the network propagate flag to make sure it gets to the other clients
pMsg->SetBCastFlag(plMessage::kNetPropagate);
pMsg->SetBCastFlag(plMessage::kNetForce);
}
if ( fSender )
pMsg->SetSender(fSender);
// add all our receivers to the message receiver list
int i;
for ( i=0; i<fRecvr.Count(); i++ )
{
pMsg->AddReceiver(fRecvr[i]);
}
// set the interface to the draw
pMsg->SetCmd(plEnableMsg::kDrawable);
pMsg->AddType(plEnableMsg::kDrawable);
pMsg->SetBCastFlag(plMessage::kPropagateToModifiers);
// which way are we doin' it?
if ( state )
pMsg->SetCmd(plEnableMsg::kEnable);
else
pMsg->SetCmd(plEnableMsg::kDisable);
plgDispatch::MsgSend( pMsg ); // whoosh... off it goes
}
}
void cyDraw::Enable()
{
EnableT(true);
}
void cyDraw::Disable()
{
EnableT(false);
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "cyDraw.h"
#include "plgDispatch.h"
#include "hsBitVector.h"
#include "pnMessage/plEnableMsg.h"
cyDraw::cyDraw(plKey sender, plKey recvr)
{
SetSender(sender);
AddRecvr(recvr);
fNetForce = false;
}
// setters
void cyDraw::SetSender(plKey &sender)
{
fSender = sender;
}
void cyDraw::AddRecvr(plKey &recvr)
{
if ( recvr != nil )
fRecvr.Append(recvr);
}
void cyDraw::SetNetForce(hsBool state)
{
// set our flag
fNetForce = state;
}
void cyDraw::EnableT(hsBool state)
{
// must have a receiver!
if ( fRecvr.Count() > 0 )
{
// create message
plEnableMsg* pMsg = TRACKED_NEW plEnableMsg;
// check if this needs to be network forced to all clients
if (fNetForce )
{
// set the network propagate flag to make sure it gets to the other clients
pMsg->SetBCastFlag(plMessage::kNetPropagate);
pMsg->SetBCastFlag(plMessage::kNetForce);
}
if ( fSender )
pMsg->SetSender(fSender);
// add all our receivers to the message receiver list
int i;
for ( i=0; i<fRecvr.Count(); i++ )
{
pMsg->AddReceiver(fRecvr[i]);
}
// set the interface to the draw
pMsg->SetCmd(plEnableMsg::kDrawable);
pMsg->AddType(plEnableMsg::kDrawable);
pMsg->SetBCastFlag(plMessage::kPropagateToModifiers);
// which way are we doin' it?
if ( state )
pMsg->SetCmd(plEnableMsg::kEnable);
else
pMsg->SetCmd(plEnableMsg::kDisable);
plgDispatch::MsgSend( pMsg ); // whoosh... off it goes
}
}
void cyDraw::Enable()
{
EnableT(true);
}
void cyDraw::Disable()
{
EnableT(false);
}

View File

@ -1,70 +1,70 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef cyDraw_h
#define cyDraw_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: cyDraw
//
// PURPOSE: Class wrapper to map draw functions to plasma2 message
//
#include "hsTemplates.h"
#include "pnKeyedObject/plKey.h"
#include <python.h>
#include "pyGlueHelpers.h"
class cyDraw
{
protected:
plKey fSender;
hsTArray<plKey> fRecvr;
hsBool fNetForce;
cyDraw(plKey sender=nil,const plKey recvr=nil);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptDraw);
static PyObject *New(PyObject *sender = NULL, PyObject* recvr = NULL);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a cyDraw object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(cyDraw); // converts a PyObject to a cyDraw (throws error if not correct type)
static void AddPlasmaClasses(PyObject *m);
// setters
void SetSender(plKey &sender);
void AddRecvr(plKey &recvr);
virtual void SetNetForce(hsBool state);
// Enable draw
virtual void EnableT(hsBool state);
virtual void Enable();
virtual void Disable();
};
#endif // cyDraw_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef cyDraw_h
#define cyDraw_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: cyDraw
//
// PURPOSE: Class wrapper to map draw functions to plasma2 message
//
#include "hsTemplates.h"
#include "pnKeyedObject/plKey.h"
#include <python.h>
#include "pyGlueHelpers.h"
class cyDraw
{
protected:
plKey fSender;
hsTArray<plKey> fRecvr;
hsBool fNetForce;
cyDraw(plKey sender=nil,const plKey recvr=nil);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptDraw);
static PyObject *New(PyObject *sender = NULL, PyObject* recvr = NULL);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a cyDraw object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(cyDraw); // converts a PyObject to a cyDraw (throws error if not correct type)
static void AddPlasmaClasses(PyObject *m);
// setters
void SetSender(plKey &sender);
void AddRecvr(plKey &recvr);
virtual void SetNetForce(hsBool state);
// Enable draw
virtual void EnableT(hsBool state);
virtual void Enable();
virtual void Disable();
};
#endif // cyDraw_h

View File

@ -1,109 +1,109 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "cyDraw.h"
#include "pyKey.h"
#include <python.h>
// glue functions
PYTHON_CLASS_DEFINITION(ptDraw, cyDraw);
PYTHON_DEFAULT_NEW_DEFINITION(ptDraw, cyDraw)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptDraw)
PYTHON_NO_INIT_DEFINITION(ptDraw)
PYTHON_METHOD_DEFINITION(ptDraw, netForce, args)
{
char forceFlag;
if (!PyArg_ParseTuple(args, "b", &forceFlag))
{
PyErr_SetString(PyExc_TypeError, "netForce requires a boolean argument");
PYTHON_RETURN_ERROR;
}
self->fThis->SetNetForce(forceFlag != 0);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptDraw, enable, args)
{
char state = 1;
if (!PyArg_ParseTuple(args, "|b", &state))
{
PyErr_SetString(PyExc_TypeError, "enable expects an optional boolean argument");
PYTHON_RETURN_ERROR;
}
self->fThis->EnableT(state != 0);
PYTHON_RETURN_NONE;
}
PYTHON_BASIC_METHOD_DEFINITION(ptDraw, disable, Disable)
PYTHON_START_METHODS_TABLE(ptDraw)
PYTHON_METHOD(ptDraw, netForce, "Params: forceFlag\nSpecify whether this object needs to use messages that are forced to the network\n"
"- This is to be used if your Python program is running on only one client\n"
"Such as a game master, only running on the client that owns a particular object"),
PYTHON_METHOD(ptDraw, enable, "Params: state=1\nSets the draw enable for the sceneobject attached"),
PYTHON_BASIC_METHOD(ptDraw, disable, "Disables the draw on the sceneobject attached\n"
"In other words, makes it invisible"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE(ptDraw, "Plasma Draw class");
// required functions for PyObject interoperability
PyObject *cyDraw::New(PyObject *sender, PyObject *recvr)
{
ptDraw *newObj = (ptDraw*)ptDraw_type.tp_new(&ptDraw_type, NULL, NULL);
if (sender != NULL)
{
pyKey *senderKey = pyKey::ConvertFrom(sender);
newObj->fThis->SetSender(senderKey->getKey());
}
if (recvr != NULL)
{
pyKey *recvrKey = pyKey::ConvertFrom(recvr);
newObj->fThis->AddRecvr(recvrKey->getKey());
}
newObj->fThis->fNetForce = false;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptDraw, cyDraw)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptDraw, cyDraw)
///////////////////////////////////////////////////////////////////////////
//
// AddPlasmaClasses - the python module definitions
//
void cyDraw::AddPlasmaClasses(PyObject *m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptDraw);
PYTHON_CLASS_IMPORT_END(m);
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "cyDraw.h"
#include "pyKey.h"
#include <python.h>
// glue functions
PYTHON_CLASS_DEFINITION(ptDraw, cyDraw);
PYTHON_DEFAULT_NEW_DEFINITION(ptDraw, cyDraw)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptDraw)
PYTHON_NO_INIT_DEFINITION(ptDraw)
PYTHON_METHOD_DEFINITION(ptDraw, netForce, args)
{
char forceFlag;
if (!PyArg_ParseTuple(args, "b", &forceFlag))
{
PyErr_SetString(PyExc_TypeError, "netForce requires a boolean argument");
PYTHON_RETURN_ERROR;
}
self->fThis->SetNetForce(forceFlag != 0);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptDraw, enable, args)
{
char state = 1;
if (!PyArg_ParseTuple(args, "|b", &state))
{
PyErr_SetString(PyExc_TypeError, "enable expects an optional boolean argument");
PYTHON_RETURN_ERROR;
}
self->fThis->EnableT(state != 0);
PYTHON_RETURN_NONE;
}
PYTHON_BASIC_METHOD_DEFINITION(ptDraw, disable, Disable)
PYTHON_START_METHODS_TABLE(ptDraw)
PYTHON_METHOD(ptDraw, netForce, "Params: forceFlag\nSpecify whether this object needs to use messages that are forced to the network\n"
"- This is to be used if your Python program is running on only one client\n"
"Such as a game master, only running on the client that owns a particular object"),
PYTHON_METHOD(ptDraw, enable, "Params: state=1\nSets the draw enable for the sceneobject attached"),
PYTHON_BASIC_METHOD(ptDraw, disable, "Disables the draw on the sceneobject attached\n"
"In other words, makes it invisible"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE(ptDraw, "Plasma Draw class");
// required functions for PyObject interoperability
PyObject *cyDraw::New(PyObject *sender, PyObject *recvr)
{
ptDraw *newObj = (ptDraw*)ptDraw_type.tp_new(&ptDraw_type, NULL, NULL);
if (sender != NULL)
{
pyKey *senderKey = pyKey::ConvertFrom(sender);
newObj->fThis->SetSender(senderKey->getKey());
}
if (recvr != NULL)
{
pyKey *recvrKey = pyKey::ConvertFrom(recvr);
newObj->fThis->AddRecvr(recvrKey->getKey());
}
newObj->fThis->fNetForce = false;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptDraw, cyDraw)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptDraw, cyDraw)
///////////////////////////////////////////////////////////////////////////
//
// AddPlasmaClasses - the python module definitions
//
void cyDraw::AddPlasmaClasses(PyObject *m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptDraw);
PYTHON_CLASS_IMPORT_END(m);
}

View File

@ -1,81 +1,81 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "cyInputInterface.h"
#include "plMessage/plInputIfaceMgrMsg.h"
#include "plInputCore/plTelescopeInputInterface.h"
#include "plgDispatch.h"
cyInputInterface::cyInputInterface() :
fTelescopeInterface(nil)
{
}
cyInputInterface::~cyInputInterface()
{
if (fTelescopeInterface)
hsRefCnt_SafeUnRef( fTelescopeInterface );
}
/////////////////////////////////////////////////////////////////////////////
//
// Function : Push interface functions
// PARAMETERS :
//
// PURPOSE : create and push a specialized input interface onto the control stack.
// : for now we only have the telescope...
//
//
void cyInputInterface::PushTelescopeInterface()
{
if (!fTelescopeInterface)
{
fTelescopeInterface = TRACKED_NEW plTelescopeInputInterface;
plInputIfaceMgrMsg* pMsg = TRACKED_NEW plInputIfaceMgrMsg(plInputIfaceMgrMsg::kAddInterface);
pMsg->SetIFace(fTelescopeInterface);
pMsg->Send();
}
}
/////////////////////////////////////////////////////////////////////////////
//
// Function : Pop
// PARAMETERS :
//
// PURPOSE : Remove and delete the interface we have on the stack
//
void cyInputInterface::PopTelescope()
{
if (fTelescopeInterface)
{
plInputIfaceMgrMsg* pMsg = TRACKED_NEW plInputIfaceMgrMsg(plInputIfaceMgrMsg::kRemoveInterface);
pMsg->SetIFace(fTelescopeInterface);
pMsg->Send();
hsRefCnt_SafeUnRef( fTelescopeInterface );
fTelescopeInterface = nil;
}
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "cyInputInterface.h"
#include "plMessage/plInputIfaceMgrMsg.h"
#include "plInputCore/plTelescopeInputInterface.h"
#include "plgDispatch.h"
cyInputInterface::cyInputInterface() :
fTelescopeInterface(nil)
{
}
cyInputInterface::~cyInputInterface()
{
if (fTelescopeInterface)
hsRefCnt_SafeUnRef( fTelescopeInterface );
}
/////////////////////////////////////////////////////////////////////////////
//
// Function : Push interface functions
// PARAMETERS :
//
// PURPOSE : create and push a specialized input interface onto the control stack.
// : for now we only have the telescope...
//
//
void cyInputInterface::PushTelescopeInterface()
{
if (!fTelescopeInterface)
{
fTelescopeInterface = TRACKED_NEW plTelescopeInputInterface;
plInputIfaceMgrMsg* pMsg = TRACKED_NEW plInputIfaceMgrMsg(plInputIfaceMgrMsg::kAddInterface);
pMsg->SetIFace(fTelescopeInterface);
pMsg->Send();
}
}
/////////////////////////////////////////////////////////////////////////////
//
// Function : Pop
// PARAMETERS :
//
// PURPOSE : Remove and delete the interface we have on the stack
//
void cyInputInterface::PopTelescope()
{
if (fTelescopeInterface)
{
plInputIfaceMgrMsg* pMsg = TRACKED_NEW plInputIfaceMgrMsg(plInputIfaceMgrMsg::kRemoveInterface);
pMsg->SetIFace(fTelescopeInterface);
pMsg->Send();
hsRefCnt_SafeUnRef( fTelescopeInterface );
fTelescopeInterface = nil;
}
}

View File

@ -1,70 +1,70 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef cyInputInterface_h
#define cyInputInterface_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: cyInputInterface
//
// PURPOSE: Class wrapper to map InputInterface functions to plasma2 message
//
#include <python.h>
#include "pyGlueHelpers.h"
class plInputInterface;
class cyInputInterface
{
protected:
plInputInterface* fTelescopeInterface;
cyInputInterface();
public:
~cyInputInterface();
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptInputInterface);
PYTHON_CLASS_NEW_DEFINITION;
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a cyInputInterface object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(cyInputInterface); // converts a PyObject to a cyInputInterface (throws error if not correct type)
static void AddPlasmaClasses(PyObject *m);
// setters
// we should add a ::Push_X_Interface function for any special type
// of interface we might want to set... for now there's just the telescope...
void PushTelescopeInterface();
void PopTelescope();
/////////////////////////////////////////////////////////////////////////////
};
#endif // cyInputInterface_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef cyInputInterface_h
#define cyInputInterface_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: cyInputInterface
//
// PURPOSE: Class wrapper to map InputInterface functions to plasma2 message
//
#include <python.h>
#include "pyGlueHelpers.h"
class plInputInterface;
class cyInputInterface
{
protected:
plInputInterface* fTelescopeInterface;
cyInputInterface();
public:
~cyInputInterface();
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptInputInterface);
PYTHON_CLASS_NEW_DEFINITION;
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a cyInputInterface object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(cyInputInterface); // converts a PyObject to a cyInputInterface (throws error if not correct type)
static void AddPlasmaClasses(PyObject *m);
// setters
// we should add a ::Push_X_Interface function for any special type
// of interface we might want to set... for now there's just the telescope...
void PushTelescopeInterface();
void PopTelescope();
/////////////////////////////////////////////////////////////////////////////
};
#endif // cyInputInterface_h

View File

@ -1,67 +1,67 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "HeadSpin.h"
#include "cyInputInterface.h"
#include <python.h>
// glue functions
PYTHON_CLASS_DEFINITION(ptInputInterface, cyInputInterface);
PYTHON_DEFAULT_NEW_DEFINITION(ptInputInterface, cyInputInterface)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptInputInterface)
PYTHON_INIT_DEFINITION(ptInputInterface, args, keywords)
{
PYTHON_RETURN_INIT_OK;
}
PYTHON_BASIC_METHOD_DEFINITION(ptInputInterface, pushTelescope, PushTelescopeInterface)
PYTHON_BASIC_METHOD_DEFINITION(ptInputInterface, popTelescope, PopTelescope)
PYTHON_START_METHODS_TABLE(ptInputInterface)
PYTHON_BASIC_METHOD(ptInputInterface, pushTelescope, "pushes on the telescope interface"),
PYTHON_BASIC_METHOD(ptInputInterface, popTelescope, "pops off the telescope interface and gos back to previous interface"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE(ptInputInterface, "Plasma input interface class");
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_IMPL(ptInputInterface, cyInputInterface)
PYTHON_CLASS_CHECK_IMPL(ptInputInterface, cyInputInterface)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptInputInterface, cyInputInterface)
///////////////////////////////////////////////////////////////////////////
//
// AddPlasmaClasses - the python module definitions
//
void cyInputInterface::AddPlasmaClasses(PyObject *m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptInputInterface);
PYTHON_CLASS_IMPORT_END(m);
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "HeadSpin.h"
#include "cyInputInterface.h"
#include <python.h>
// glue functions
PYTHON_CLASS_DEFINITION(ptInputInterface, cyInputInterface);
PYTHON_DEFAULT_NEW_DEFINITION(ptInputInterface, cyInputInterface)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptInputInterface)
PYTHON_INIT_DEFINITION(ptInputInterface, args, keywords)
{
PYTHON_RETURN_INIT_OK;
}
PYTHON_BASIC_METHOD_DEFINITION(ptInputInterface, pushTelescope, PushTelescopeInterface)
PYTHON_BASIC_METHOD_DEFINITION(ptInputInterface, popTelescope, PopTelescope)
PYTHON_START_METHODS_TABLE(ptInputInterface)
PYTHON_BASIC_METHOD(ptInputInterface, pushTelescope, "pushes on the telescope interface"),
PYTHON_BASIC_METHOD(ptInputInterface, popTelescope, "pops off the telescope interface and gos back to previous interface"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE(ptInputInterface, "Plasma input interface class");
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_IMPL(ptInputInterface, cyInputInterface)
PYTHON_CLASS_CHECK_IMPL(ptInputInterface, cyInputInterface)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptInputInterface, cyInputInterface)
///////////////////////////////////////////////////////////////////////////
//
// AddPlasmaClasses - the python module definitions
//
void cyInputInterface::AddPlasmaClasses(PyObject *m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptInputInterface);
PYTHON_CLASS_IMPORT_END(m);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,148 +1,148 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "cyParticleSys.h"
#include "hsStream.h"
#include "pnMessage/plMessage.h"
#include "hsResMgr.h"
#include "plgDispatch.h"
#include "plMessage/plParticleUpdateMsg.h"
cyParticleSys::cyParticleSys(plKey sender, plKey recvr)
{
SetSender(sender);
AddRecvr(recvr);
fNetForce = false;
}
// setters
void cyParticleSys::SetSender(plKey &sender)
{
fSender = sender;
}
void cyParticleSys::AddRecvr(plKey &recvr)
{
if ( recvr != nil )
fRecvr.Append(recvr);
}
void cyParticleSys::SetNetForce(hsBool state)
{
// set our flag
fNetForce = state;
}
/////////////////////////////////////////////////////////////////////////////
//
// Function : ISendParticleSysMsg
// PARAMETERS :
//
// PURPOSE : send the message to the Particle System
//
void cyParticleSys::ISendParticleSysMsg(UInt32 param, hsScalar value)
{
plParticleUpdateMsg* pMsg = TRACKED_NEW plParticleUpdateMsg(fSender, nil, nil, param, value);
// check if this needs to be network forced to all clients
if (fNetForce )
{
// set the network propagate flag to make sure it gets to the other clients
pMsg->SetBCastFlag(plMessage::kNetPropagate);
pMsg->SetBCastFlag(plMessage::kNetForce);
}
pMsg->SetBCastFlag(plMessage::kPropagateToModifiers);
// add all our receivers to the message receiver list
int i;
for ( i=0; i<fRecvr.Count(); i++ )
{
pMsg->AddReceiver(fRecvr[i]);
}
plgDispatch::MsgSend(pMsg);
}
/////////////////////////////////////////////////////////////////////////////
//
// All these methods just call the IsendParticleSysMsg to do the real work
//
void cyParticleSys::SetParticlesPerSecond(hsScalar value)
{
ISendParticleSysMsg(plParticleUpdateMsg::kParamParticlesPerSecond,value);
}
void cyParticleSys::SetInitPitchRange(hsScalar value)
{
ISendParticleSysMsg(plParticleUpdateMsg::kParamInitPitchRange,value);
}
void cyParticleSys::SetInitYawRange(hsScalar value)
{
ISendParticleSysMsg(plParticleUpdateMsg::kParamInitYawRange,value);
}
void cyParticleSys::SetVelMin(hsScalar value)
{
ISendParticleSysMsg(plParticleUpdateMsg::kParamVelMin,value);
}
void cyParticleSys::SetVelMax(hsScalar value)
{
ISendParticleSysMsg(plParticleUpdateMsg::kParamVelMax,value);
}
void cyParticleSys::SetXSize(hsScalar value)
{
ISendParticleSysMsg(plParticleUpdateMsg::kParamXSize,value);
}
void cyParticleSys::SetYSize(hsScalar value)
{
ISendParticleSysMsg(plParticleUpdateMsg::kParamYSize,value);
}
void cyParticleSys::SetScaleMin(hsScalar value)
{
ISendParticleSysMsg(plParticleUpdateMsg::kParamScaleMin,value);
}
void cyParticleSys::SetScaleMax(hsScalar value)
{
ISendParticleSysMsg(plParticleUpdateMsg::kParamScaleMax,value);
}
void cyParticleSys::SetGenLife(hsScalar value)
{
ISendParticleSysMsg(plParticleUpdateMsg::kParamGenLife,value);
}
void cyParticleSys::SetPartLifeMin(hsScalar value)
{
ISendParticleSysMsg(plParticleUpdateMsg::kParamPartLifeMin,value);
}
void cyParticleSys::SetPartLifeMax(hsScalar value)
{
ISendParticleSysMsg(plParticleUpdateMsg::kParamPartLifeMax,value);
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "cyParticleSys.h"
#include "hsStream.h"
#include "pnMessage/plMessage.h"
#include "hsResMgr.h"
#include "plgDispatch.h"
#include "plMessage/plParticleUpdateMsg.h"
cyParticleSys::cyParticleSys(plKey sender, plKey recvr)
{
SetSender(sender);
AddRecvr(recvr);
fNetForce = false;
}
// setters
void cyParticleSys::SetSender(plKey &sender)
{
fSender = sender;
}
void cyParticleSys::AddRecvr(plKey &recvr)
{
if ( recvr != nil )
fRecvr.Append(recvr);
}
void cyParticleSys::SetNetForce(hsBool state)
{
// set our flag
fNetForce = state;
}
/////////////////////////////////////////////////////////////////////////////
//
// Function : ISendParticleSysMsg
// PARAMETERS :
//
// PURPOSE : send the message to the Particle System
//
void cyParticleSys::ISendParticleSysMsg(UInt32 param, hsScalar value)
{
plParticleUpdateMsg* pMsg = TRACKED_NEW plParticleUpdateMsg(fSender, nil, nil, param, value);
// check if this needs to be network forced to all clients
if (fNetForce )
{
// set the network propagate flag to make sure it gets to the other clients
pMsg->SetBCastFlag(plMessage::kNetPropagate);
pMsg->SetBCastFlag(plMessage::kNetForce);
}
pMsg->SetBCastFlag(plMessage::kPropagateToModifiers);
// add all our receivers to the message receiver list
int i;
for ( i=0; i<fRecvr.Count(); i++ )
{
pMsg->AddReceiver(fRecvr[i]);
}
plgDispatch::MsgSend(pMsg);
}
/////////////////////////////////////////////////////////////////////////////
//
// All these methods just call the IsendParticleSysMsg to do the real work
//
void cyParticleSys::SetParticlesPerSecond(hsScalar value)
{
ISendParticleSysMsg(plParticleUpdateMsg::kParamParticlesPerSecond,value);
}
void cyParticleSys::SetInitPitchRange(hsScalar value)
{
ISendParticleSysMsg(plParticleUpdateMsg::kParamInitPitchRange,value);
}
void cyParticleSys::SetInitYawRange(hsScalar value)
{
ISendParticleSysMsg(plParticleUpdateMsg::kParamInitYawRange,value);
}
void cyParticleSys::SetVelMin(hsScalar value)
{
ISendParticleSysMsg(plParticleUpdateMsg::kParamVelMin,value);
}
void cyParticleSys::SetVelMax(hsScalar value)
{
ISendParticleSysMsg(plParticleUpdateMsg::kParamVelMax,value);
}
void cyParticleSys::SetXSize(hsScalar value)
{
ISendParticleSysMsg(plParticleUpdateMsg::kParamXSize,value);
}
void cyParticleSys::SetYSize(hsScalar value)
{
ISendParticleSysMsg(plParticleUpdateMsg::kParamYSize,value);
}
void cyParticleSys::SetScaleMin(hsScalar value)
{
ISendParticleSysMsg(plParticleUpdateMsg::kParamScaleMin,value);
}
void cyParticleSys::SetScaleMax(hsScalar value)
{
ISendParticleSysMsg(plParticleUpdateMsg::kParamScaleMax,value);
}
void cyParticleSys::SetGenLife(hsScalar value)
{
ISendParticleSysMsg(plParticleUpdateMsg::kParamGenLife,value);
}
void cyParticleSys::SetPartLifeMin(hsScalar value)
{
ISendParticleSysMsg(plParticleUpdateMsg::kParamPartLifeMin,value);
}
void cyParticleSys::SetPartLifeMax(hsScalar value)
{
ISendParticleSysMsg(plParticleUpdateMsg::kParamPartLifeMax,value);
}

View File

@ -1,84 +1,84 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef cyParticleSys_h
#define cyParticleSys_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: cyParticleSys
//
// PURPOSE: Class wrapper to for Particle System
//
#include "hsTemplates.h"
#include "pnKeyedObject/plKey.h"
class pyKey;
#include <python.h>
#include "pyGlueHelpers.h"
class cyParticleSys
{
protected:
plKey fSender;
hsTArray<plKey> fRecvr;
hsBool fNetForce;
virtual void ISendParticleSysMsg(UInt32 param, hsScalar value);
cyParticleSys(const plKey sender=nil,const plKey recvr=nil);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptParticle);
static PyObject *New(PyObject *sender = nil, PyObject *recvr = nil);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a cyParticleSys object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(cyParticleSys); // converts a PyObject to a cyParticleSys (throws error if not correct type)
static void AddPlasmaClasses(PyObject *m);
// setters
virtual void SetSender(plKey &sender);
virtual void AddRecvr(plKey &recvr);
virtual void SetNetForce(hsBool state);
virtual void SetParticlesPerSecond(hsScalar value);
virtual void SetInitPitchRange(hsScalar value);
virtual void SetInitYawRange(hsScalar value);
virtual void SetVelMin(hsScalar value);
virtual void SetVelMax(hsScalar value);
virtual void SetXSize(hsScalar value);
virtual void SetYSize(hsScalar value);
virtual void SetScaleMin(hsScalar value);
virtual void SetScaleMax(hsScalar value);
virtual void SetGenLife(hsScalar value);
virtual void SetPartLifeMin(hsScalar value);
virtual void SetPartLifeMax(hsScalar value);
};
#endif // cyParticleSys_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef cyParticleSys_h
#define cyParticleSys_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: cyParticleSys
//
// PURPOSE: Class wrapper to for Particle System
//
#include "hsTemplates.h"
#include "pnKeyedObject/plKey.h"
class pyKey;
#include <python.h>
#include "pyGlueHelpers.h"
class cyParticleSys
{
protected:
plKey fSender;
hsTArray<plKey> fRecvr;
hsBool fNetForce;
virtual void ISendParticleSysMsg(UInt32 param, hsScalar value);
cyParticleSys(const plKey sender=nil,const plKey recvr=nil);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptParticle);
static PyObject *New(PyObject *sender = nil, PyObject *recvr = nil);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a cyParticleSys object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(cyParticleSys); // converts a PyObject to a cyParticleSys (throws error if not correct type)
static void AddPlasmaClasses(PyObject *m);
// setters
virtual void SetSender(plKey &sender);
virtual void AddRecvr(plKey &recvr);
virtual void SetNetForce(hsBool state);
virtual void SetParticlesPerSecond(hsScalar value);
virtual void SetInitPitchRange(hsScalar value);
virtual void SetInitYawRange(hsScalar value);
virtual void SetVelMin(hsScalar value);
virtual void SetVelMax(hsScalar value);
virtual void SetXSize(hsScalar value);
virtual void SetYSize(hsScalar value);
virtual void SetScaleMin(hsScalar value);
virtual void SetScaleMax(hsScalar value);
virtual void SetGenLife(hsScalar value);
virtual void SetPartLifeMin(hsScalar value);
virtual void SetPartLifeMax(hsScalar value);
};
#endif // cyParticleSys_h

View File

@ -1,131 +1,131 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "cyParticleSys.h"
#include "pyKey.h"
#include <python.h>
// glue functions
PYTHON_CLASS_DEFINITION(ptParticle, cyParticleSys);
PYTHON_DEFAULT_NEW_DEFINITION(ptParticle, cyParticleSys)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptParticle)
PYTHON_NO_INIT_DEFINITION(ptParticle)
PYTHON_METHOD_DEFINITION(ptParticle, netForce, args)
{
char forceFlag;
if (!PyArg_ParseTuple(args, "b", &forceFlag))
{
PyErr_SetString(PyExc_TypeError, "netForce requires a boolean argument");
PYTHON_RETURN_ERROR;
}
self->fThis->SetNetForce(forceFlag != 0);
PYTHON_RETURN_NONE;
}
// define a nice little marco to do the grunt work, since all the functions are identical
#define PARTICLE_FUNC(funcName, classFunc) \
PYTHON_METHOD_DEFINITION(ptParticle, funcName, args) \
{ \
float val; \
if (!PyArg_ParseTuple(args, "f", &val)) \
{ \
PyErr_SetString(PyExc_TypeError, #funcName " expects a float"); \
PYTHON_RETURN_ERROR; \
} \
self->fThis->classFunc(val); \
PYTHON_RETURN_NONE; \
}
// now make all the functions using the above macro
PARTICLE_FUNC(setParticlesPerSecond, SetParticlesPerSecond)
PARTICLE_FUNC(setInitPitchRange, SetInitPitchRange)
PARTICLE_FUNC(setInitYawRange, SetInitYawRange)
PARTICLE_FUNC(setVelocityMinimum, SetVelMin)
PARTICLE_FUNC(setVelocityMaximum, SetVelMax)
PARTICLE_FUNC(setWidthSize, SetXSize)
PARTICLE_FUNC(setHeightSize, SetYSize)
PARTICLE_FUNC(setScaleMinimum, SetScaleMin)
PARTICLE_FUNC(setScaleMaximum, SetScaleMax)
PARTICLE_FUNC(setGeneratorLife, SetGenLife)
PARTICLE_FUNC(setParticleLifeMinimum, SetPartLifeMin)
PARTICLE_FUNC(setParticleLifeMaximum, SetPartLifeMax)
PYTHON_START_METHODS_TABLE(ptParticle)
PYTHON_METHOD(ptParticle, netForce, "Params: forceFlag\nSpecify whether this object needs to use messages that are forced to the network\n"
"- This is to be used if your Python program is running on only one client\n"
"Such as a game master, only running on the client that owns a particular object"),
PYTHON_METHOD(ptParticle, setParticlesPerSecond, "Params: value\nNEEDS DOCSTRING"),
PYTHON_METHOD(ptParticle, setInitPitchRange, "Params: value\nNEEDS DOCSTRING"),
PYTHON_METHOD(ptParticle, setInitYawRange, "Params: value\nNEEDS DOCSTRING"),
PYTHON_METHOD(ptParticle, setVelocityMinimum, "Params: value\nNEEDS DOCSTRING"),
PYTHON_METHOD(ptParticle, setVelocityMaximum, "Params: value\nNEEDS DOCSTRING"),
PYTHON_METHOD(ptParticle, setWidthSize, "Params: value\nNEEDS DOCSTRING"),
PYTHON_METHOD(ptParticle, setHeightSize, "Params: value\nNEEDS DOCSTRING"),
PYTHON_METHOD(ptParticle, setScaleMinimum, "Params: value\nNEEDS DOCSTRING"),
PYTHON_METHOD(ptParticle, setScaleMaximum, "Params: value\nNEEDS DOCSTRING"),
PYTHON_METHOD(ptParticle, setGeneratorLife, "Params: value\nNEEDS DOCSTRING"),
PYTHON_METHOD(ptParticle, setParticleLifeMinimum, "Params: value\nNEEDS DOCSTRING"),
PYTHON_METHOD(ptParticle, setParticleLifeMaximum, "Params: value\nNEEDS DOCSTRING"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE(ptParticle, "Plasma particle system class");
// required functions for PyObject interoperability
PyObject *cyParticleSys::New(PyObject *sender, PyObject *recvr)
{
ptParticle *newObj = (ptParticle*)ptParticle_type.tp_new(&ptParticle_type, NULL, NULL);
if (sender != NULL)
{
pyKey *senderKey = pyKey::ConvertFrom(sender);
newObj->fThis->SetSender(senderKey->getKey());
}
if (recvr != NULL)
{
pyKey *recvrKey = pyKey::ConvertFrom(recvr);
newObj->fThis->AddRecvr(recvrKey->getKey());
}
newObj->fThis->SetNetForce(false);
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptParticle, cyParticleSys)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptParticle, cyParticleSys)
///////////////////////////////////////////////////////////////////////////
//
// AddPlasmaClasses - the python module definitions
//
void cyParticleSys::AddPlasmaClasses(PyObject *m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptParticle);
PYTHON_CLASS_IMPORT_END(m);
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "cyParticleSys.h"
#include "pyKey.h"
#include <python.h>
// glue functions
PYTHON_CLASS_DEFINITION(ptParticle, cyParticleSys);
PYTHON_DEFAULT_NEW_DEFINITION(ptParticle, cyParticleSys)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptParticle)
PYTHON_NO_INIT_DEFINITION(ptParticle)
PYTHON_METHOD_DEFINITION(ptParticle, netForce, args)
{
char forceFlag;
if (!PyArg_ParseTuple(args, "b", &forceFlag))
{
PyErr_SetString(PyExc_TypeError, "netForce requires a boolean argument");
PYTHON_RETURN_ERROR;
}
self->fThis->SetNetForce(forceFlag != 0);
PYTHON_RETURN_NONE;
}
// define a nice little marco to do the grunt work, since all the functions are identical
#define PARTICLE_FUNC(funcName, classFunc) \
PYTHON_METHOD_DEFINITION(ptParticle, funcName, args) \
{ \
float val; \
if (!PyArg_ParseTuple(args, "f", &val)) \
{ \
PyErr_SetString(PyExc_TypeError, #funcName " expects a float"); \
PYTHON_RETURN_ERROR; \
} \
self->fThis->classFunc(val); \
PYTHON_RETURN_NONE; \
}
// now make all the functions using the above macro
PARTICLE_FUNC(setParticlesPerSecond, SetParticlesPerSecond)
PARTICLE_FUNC(setInitPitchRange, SetInitPitchRange)
PARTICLE_FUNC(setInitYawRange, SetInitYawRange)
PARTICLE_FUNC(setVelocityMinimum, SetVelMin)
PARTICLE_FUNC(setVelocityMaximum, SetVelMax)
PARTICLE_FUNC(setWidthSize, SetXSize)
PARTICLE_FUNC(setHeightSize, SetYSize)
PARTICLE_FUNC(setScaleMinimum, SetScaleMin)
PARTICLE_FUNC(setScaleMaximum, SetScaleMax)
PARTICLE_FUNC(setGeneratorLife, SetGenLife)
PARTICLE_FUNC(setParticleLifeMinimum, SetPartLifeMin)
PARTICLE_FUNC(setParticleLifeMaximum, SetPartLifeMax)
PYTHON_START_METHODS_TABLE(ptParticle)
PYTHON_METHOD(ptParticle, netForce, "Params: forceFlag\nSpecify whether this object needs to use messages that are forced to the network\n"
"- This is to be used if your Python program is running on only one client\n"
"Such as a game master, only running on the client that owns a particular object"),
PYTHON_METHOD(ptParticle, setParticlesPerSecond, "Params: value\nNEEDS DOCSTRING"),
PYTHON_METHOD(ptParticle, setInitPitchRange, "Params: value\nNEEDS DOCSTRING"),
PYTHON_METHOD(ptParticle, setInitYawRange, "Params: value\nNEEDS DOCSTRING"),
PYTHON_METHOD(ptParticle, setVelocityMinimum, "Params: value\nNEEDS DOCSTRING"),
PYTHON_METHOD(ptParticle, setVelocityMaximum, "Params: value\nNEEDS DOCSTRING"),
PYTHON_METHOD(ptParticle, setWidthSize, "Params: value\nNEEDS DOCSTRING"),
PYTHON_METHOD(ptParticle, setHeightSize, "Params: value\nNEEDS DOCSTRING"),
PYTHON_METHOD(ptParticle, setScaleMinimum, "Params: value\nNEEDS DOCSTRING"),
PYTHON_METHOD(ptParticle, setScaleMaximum, "Params: value\nNEEDS DOCSTRING"),
PYTHON_METHOD(ptParticle, setGeneratorLife, "Params: value\nNEEDS DOCSTRING"),
PYTHON_METHOD(ptParticle, setParticleLifeMinimum, "Params: value\nNEEDS DOCSTRING"),
PYTHON_METHOD(ptParticle, setParticleLifeMaximum, "Params: value\nNEEDS DOCSTRING"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE(ptParticle, "Plasma particle system class");
// required functions for PyObject interoperability
PyObject *cyParticleSys::New(PyObject *sender, PyObject *recvr)
{
ptParticle *newObj = (ptParticle*)ptParticle_type.tp_new(&ptParticle_type, NULL, NULL);
if (sender != NULL)
{
pyKey *senderKey = pyKey::ConvertFrom(sender);
newObj->fThis->SetSender(senderKey->getKey());
}
if (recvr != NULL)
{
pyKey *recvrKey = pyKey::ConvertFrom(recvr);
newObj->fThis->AddRecvr(recvrKey->getKey());
}
newObj->fThis->SetNetForce(false);
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptParticle, cyParticleSys)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptParticle, cyParticleSys)
///////////////////////////////////////////////////////////////////////////
//
// AddPlasmaClasses - the python module definitions
//
void cyParticleSys::AddPlasmaClasses(PyObject *m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptParticle);
PYTHON_CLASS_IMPORT_END(m);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,133 +1,133 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef cyPhysics_h
#define cyPhysics_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: cyPhysics
//
// PURPOSE: Class wrapper to map animation functions to plasma2 message
//
#include "hsTemplates.h"
#include "pnKeyedObject/plKey.h"
#include <python.h>
#include "pyGlueHelpers.h"
class pyPoint3;
class pyVector3;
class pyMatrix44;
class pyKey;
class cyPhysics
{
protected:
plKey fSender;
hsTArray<plKey> fRecvr;
hsBool fNetForce;
cyPhysics(plKey sender=nil,plKey recvr=nil);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptPhysics);
static PyObject *New(PyObject *sender = nil, PyObject *recvr = nil);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a cyPhysics object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(cyPhysics); // converts a PyObject to a cyPhysics (throws error if not correct type)
static void AddPlasmaClasses(PyObject *m);
// setters
void SetSender(plKey &sender);
void AddRecvr(plKey &recvr);
virtual void SetNetForce(hsBool state);
// Enable physics (must already be there)
virtual void EnableT(hsBool state);
virtual void Enable();
virtual void Disable();
virtual void EnableCollision();
virtual void DisableCollision();
// Suggest to physics engine where you want to place something
virtual void Warp(pyPoint3& pos);
virtual void WarpObj(pyKey& obj);
// Suggest to physics engine where you want to place something
virtual void WarpMat(pyMatrix44& mat);
// Move the object in a direction and distance
// if the object is physical then warp it
// otherwise just use the coordinate interface and set the transform
virtual void Move(pyVector3& direction, hsScalar distance);
// Rotate the object
// if the object is physical then warp it
// otherwise just use the coordinate interface and set the transform
virtual void Rotate(hsScalar rad, pyVector3& axis);
// apply a force to the center of mass of the receiver
virtual void Force(pyVector3& force);
// apply a force to the receiver as though it were being impacted at the
// given point in global space
virtual void ForceWithOffset(pyVector3& force, pyPoint3& offset);
// Apply the given torque force to the body
// The vector indicates the axes, and the magnitude indicates the strength
virtual void Torque(pyVector3& torque);
// Add the given vector to the objects velocity
virtual void Impulse(pyVector3& impulse);
// Apply the given impulse to the object at the given point in global space
// Will impart torque if not applied to center of mass
virtual void ImpulseWithOffset(pyVector3& impulse, pyPoint3& offset);
// Add the given vector (representing a rotation axis and magnitude)
virtual void AngularImpulse(pyVector3& impulse);
// Decrease all velocities on the given object.
// A damp factor of 0 nulls them all entirely;
// A damp factor of 1 leaves them alone.
virtual void Damp(hsScalar damp);
// Shift the center of mass of the given object by the given
// amount in the given direction.
virtual void ShiftMass(pyVector3& offset);
virtual void Suppress(bool doSuppress);
//Set the Linear Velocity of the Object
virtual void SetLinearVelocity(pyVector3& velocity);
virtual void SetAngularVelocity(pyVector3& angVel);
};
#endif // cyPhysics_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef cyPhysics_h
#define cyPhysics_h
/////////////////////////////////////////////////////////////////////////////
//
// NAME: cyPhysics
//
// PURPOSE: Class wrapper to map animation functions to plasma2 message
//
#include "hsTemplates.h"
#include "pnKeyedObject/plKey.h"
#include <python.h>
#include "pyGlueHelpers.h"
class pyPoint3;
class pyVector3;
class pyMatrix44;
class pyKey;
class cyPhysics
{
protected:
plKey fSender;
hsTArray<plKey> fRecvr;
hsBool fNetForce;
cyPhysics(plKey sender=nil,plKey recvr=nil);
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptPhysics);
static PyObject *New(PyObject *sender = nil, PyObject *recvr = nil);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a cyPhysics object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(cyPhysics); // converts a PyObject to a cyPhysics (throws error if not correct type)
static void AddPlasmaClasses(PyObject *m);
// setters
void SetSender(plKey &sender);
void AddRecvr(plKey &recvr);
virtual void SetNetForce(hsBool state);
// Enable physics (must already be there)
virtual void EnableT(hsBool state);
virtual void Enable();
virtual void Disable();
virtual void EnableCollision();
virtual void DisableCollision();
// Suggest to physics engine where you want to place something
virtual void Warp(pyPoint3& pos);
virtual void WarpObj(pyKey& obj);
// Suggest to physics engine where you want to place something
virtual void WarpMat(pyMatrix44& mat);
// Move the object in a direction and distance
// if the object is physical then warp it
// otherwise just use the coordinate interface and set the transform
virtual void Move(pyVector3& direction, hsScalar distance);
// Rotate the object
// if the object is physical then warp it
// otherwise just use the coordinate interface and set the transform
virtual void Rotate(hsScalar rad, pyVector3& axis);
// apply a force to the center of mass of the receiver
virtual void Force(pyVector3& force);
// apply a force to the receiver as though it were being impacted at the
// given point in global space
virtual void ForceWithOffset(pyVector3& force, pyPoint3& offset);
// Apply the given torque force to the body
// The vector indicates the axes, and the magnitude indicates the strength
virtual void Torque(pyVector3& torque);
// Add the given vector to the objects velocity
virtual void Impulse(pyVector3& impulse);
// Apply the given impulse to the object at the given point in global space
// Will impart torque if not applied to center of mass
virtual void ImpulseWithOffset(pyVector3& impulse, pyPoint3& offset);
// Add the given vector (representing a rotation axis and magnitude)
virtual void AngularImpulse(pyVector3& impulse);
// Decrease all velocities on the given object.
// A damp factor of 0 nulls them all entirely;
// A damp factor of 1 leaves them alone.
virtual void Damp(hsScalar damp);
// Shift the center of mass of the given object by the given
// amount in the given direction.
virtual void ShiftMass(pyVector3& offset);
virtual void Suppress(bool doSuppress);
//Set the Linear Velocity of the Object
virtual void SetLinearVelocity(pyVector3& velocity);
virtual void SetAngularVelocity(pyVector3& angVel);
};
#endif // cyPhysics_h

View File

@ -1,407 +1,407 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "cyPhysics.h"
#include "pyKey.h"
#include "pyGeometry3.h"
#include "pyMatrix44.h"
#include <python.h>
// glue functions
PYTHON_CLASS_DEFINITION(ptPhysics, cyPhysics);
PYTHON_DEFAULT_NEW_DEFINITION(ptPhysics, cyPhysics)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptPhysics)
PYTHON_INIT_DEFINITION(ptPhysics, args, keywords)
{
PYTHON_RETURN_INIT_OK;
}
PYTHON_METHOD_DEFINITION(ptPhysics, netForce, args)
{
char forceFlag;
if (!PyArg_ParseTuple(args, "b", &forceFlag))
{
PyErr_SetString(PyExc_TypeError, "netForce requires a boolean argument");
PYTHON_RETURN_ERROR;
}
self->fThis->SetNetForce(forceFlag != 0);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptPhysics, enable, args)
{
char stateFlag = 1;
if (!PyArg_ParseTuple(args, "|b", &stateFlag))
{
PyErr_SetString(PyExc_TypeError, "enable expects an optional boolean argument");
PYTHON_RETURN_ERROR;
}
self->fThis->EnableT(stateFlag != 0);
PYTHON_RETURN_NONE;
}
PYTHON_BASIC_METHOD_DEFINITION(ptPhysics, disable, Disable)
PYTHON_BASIC_METHOD_DEFINITION(ptPhysics, disableCollision, DisableCollision)
PYTHON_BASIC_METHOD_DEFINITION(ptPhysics, enableCollision, EnableCollision)
PYTHON_METHOD_DEFINITION(ptPhysics, warp, args)
{
PyObject *positionObject = NULL;
if (!PyArg_ParseTuple(args, "O", &positionObject))
{
PyErr_SetString(PyExc_TypeError, "warp expects a ptPoint3 or ptMatrix44 object");
PYTHON_RETURN_ERROR;
}
if (pyPoint3::Check(positionObject))
{
pyPoint3 *pos = pyPoint3::ConvertFrom(positionObject);
self->fThis->Warp(*pos);
PYTHON_RETURN_NONE;
}
else if (pyMatrix44::Check(positionObject))
{
pyMatrix44 *mat = pyMatrix44::ConvertFrom(positionObject);
self->fThis->WarpMat(*mat);
PYTHON_RETURN_NONE;
}
PyErr_SetString(PyExc_TypeError, "warp expects a ptPoint3 or ptMatrix44 object");
PYTHON_RETURN_ERROR;
}
PYTHON_METHOD_DEFINITION(ptPhysics, warpObj, args)
{
PyObject *keyObject = NULL;
if (!PyArg_ParseTuple(args, "O", &keyObject))
{
PyErr_SetString(PyExc_TypeError, "warpObj expects a ptKey");
PYTHON_RETURN_ERROR;
}
if (!pyKey::Check(keyObject))
{
PyErr_SetString(PyExc_TypeError, "warpObj expects a ptKey");
PYTHON_RETURN_ERROR;
}
pyKey *key = pyKey::ConvertFrom(keyObject);
self->fThis->WarpObj(*key);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptPhysics, move, args)
{
PyObject *directionObject = NULL;
float distance;
if (!PyArg_ParseTuple(args, "Of", &directionObject, &distance))
{
PyErr_SetString(PyExc_TypeError, "move expects a ptVector3 and float");
PYTHON_RETURN_ERROR;
}
if (!pyVector3::Check(directionObject))
{
PyErr_SetString(PyExc_TypeError, "move expects a ptVector3 and float");
PYTHON_RETURN_ERROR;
}
pyVector3 *direction = pyVector3::ConvertFrom(directionObject);
self->fThis->Move(*direction, distance);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptPhysics, rotate, args)
{
float radians;
PyObject *axisObject = NULL;
if (!PyArg_ParseTuple(args, "fO", &radians, &axisObject))
{
PyErr_SetString(PyExc_TypeError, "rotate expects a float and ptVector3");
PYTHON_RETURN_ERROR;
}
if (!pyVector3::Check(axisObject))
{
PyErr_SetString(PyExc_TypeError, "rotate expects a float and ptVector3");
PYTHON_RETURN_ERROR;
}
pyVector3 *axis = pyVector3::ConvertFrom(axisObject);
self->fThis->Rotate(radians, *axis);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptPhysics, force, args)
{
PyObject *forceObject = NULL;
if (!PyArg_ParseTuple(args, "O", &forceObject))
{
PyErr_SetString(PyExc_TypeError, "force expects a ptVector3");
PYTHON_RETURN_ERROR;
}
if (!pyVector3::Check(forceObject))
{
PyErr_SetString(PyExc_TypeError, "force expects a ptVector3");
PYTHON_RETURN_ERROR;
}
pyVector3 *force = pyVector3::ConvertFrom(forceObject);
self->fThis->Force(*force);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptPhysics, forceWithOffset, args)
{
PyObject *forceObject = NULL;
PyObject *offsetObject = NULL;
if (!PyArg_ParseTuple(args, "OO", &forceObject, &offsetObject))
{
PyErr_SetString(PyExc_TypeError, "forceWithOffset expects a ptVector3 and a ptPoint3");
PYTHON_RETURN_ERROR;
}
if ((!pyVector3::Check(forceObject)) || (!pyPoint3::Check(offsetObject)))
{
PyErr_SetString(PyExc_TypeError, "forceWithOffset expects a ptVector3 and a ptPoint3");
PYTHON_RETURN_ERROR;
}
pyVector3 *force = pyVector3::ConvertFrom(forceObject);
pyPoint3 *offset = pyPoint3::ConvertFrom(offsetObject);
self->fThis->ForceWithOffset(*force, *offset);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptPhysics, torque, args)
{
PyObject *torqueObject = NULL;
if (!PyArg_ParseTuple(args, "O", &torqueObject))
{
PyErr_SetString(PyExc_TypeError, "torque expects a ptVector3");
PYTHON_RETURN_ERROR;
}
if (!pyVector3::Check(torqueObject))
{
PyErr_SetString(PyExc_TypeError, "torque expects a ptVector3");
PYTHON_RETURN_ERROR;
}
pyVector3 *torque = pyVector3::ConvertFrom(torqueObject);
self->fThis->Torque(*torque);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptPhysics, impulse, args)
{
PyObject *forceObject = NULL;
if (!PyArg_ParseTuple(args, "O", &forceObject))
{
PyErr_SetString(PyExc_TypeError, "impulse expects a ptVector3");
PYTHON_RETURN_ERROR;
}
if (!pyVector3::Check(forceObject))
{
PyErr_SetString(PyExc_TypeError, "impulse expects a ptVector3");
PYTHON_RETURN_ERROR;
}
pyVector3 *force = pyVector3::ConvertFrom(forceObject);
self->fThis->Impulse(*force);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptPhysics, impulseWithOffset, args)
{
PyObject *forceObject = NULL;
PyObject *offsetObject = NULL;
if (!PyArg_ParseTuple(args, "OO", &forceObject, &offsetObject))
{
PyErr_SetString(PyExc_TypeError, "impulseWithOffset expects a ptVector3 and a ptPoint3");
PYTHON_RETURN_ERROR;
}
if ((!pyVector3::Check(forceObject)) || (!pyPoint3::Check(offsetObject)))
{
PyErr_SetString(PyExc_TypeError, "impulseWithOffset expects a ptVector3 and a ptPoint3");
PYTHON_RETURN_ERROR;
}
pyVector3 *force = pyVector3::ConvertFrom(forceObject);
pyPoint3 *offset = pyPoint3::ConvertFrom(offsetObject);
self->fThis->ImpulseWithOffset(*force, *offset);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptPhysics, angularImpulse, args)
{
PyObject *forceObject = NULL;
if (!PyArg_ParseTuple(args, "O", &forceObject))
{
PyErr_SetString(PyExc_TypeError, "angularImpulse expects a ptVector3");
PYTHON_RETURN_ERROR;
}
if (!pyVector3::Check(forceObject))
{
PyErr_SetString(PyExc_TypeError, "angularImpulse expects a ptVector3");
PYTHON_RETURN_ERROR;
}
pyVector3 *force = pyVector3::ConvertFrom(forceObject);
self->fThis->AngularImpulse(*force);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptPhysics, damp, args)
{
float damp;
if (!PyArg_ParseTuple(args, "f", &damp))
{
PyErr_SetString(PyExc_TypeError, "damp expects a float");
PYTHON_RETURN_ERROR;
}
self->fThis->Damp(damp);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptPhysics, shiftMass, args)
{
PyObject *offestObject = NULL;
if (!PyArg_ParseTuple(args, "O", &offestObject))
{
PyErr_SetString(PyExc_TypeError, "shiftMass expects a ptVector3");
PYTHON_RETURN_ERROR;
}
if (!pyVector3::Check(offestObject))
{
PyErr_SetString(PyExc_TypeError, "shiftMass expects a ptVector3");
PYTHON_RETURN_ERROR;
}
pyVector3 *offset = pyVector3::ConvertFrom(offestObject);
self->fThis->ShiftMass(*offset);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptPhysics, suppress, args)
{
char doSuppress;
if (!PyArg_ParseTuple(args, "b", &doSuppress))
{
PyErr_SetString(PyExc_TypeError, "suppress expects a boolean");
PYTHON_RETURN_NONE;
}
self->fThis->Suppress(doSuppress != 0);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptPhysics, setLinearVelocity, args)
{
PyObject *velocity = NULL;
if (!PyArg_ParseTuple(args, "O", &velocity))
{
PyErr_SetString(PyExc_TypeError, "setVelocity expects a ptVector3");
PYTHON_RETURN_ERROR;
}
if (!pyVector3::Check(velocity))
{
PyErr_SetString(PyExc_TypeError, "setVelocity expects a ptVector3");
PYTHON_RETURN_ERROR;
}
pyVector3 *velocityVec = pyVector3::ConvertFrom(velocity);
self->fThis->SetLinearVelocity(*velocityVec);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptPhysics, setAngularVelocity, args)
{
PyObject *velocity = NULL;
if (!PyArg_ParseTuple(args, "O", &velocity))
{
PyErr_SetString(PyExc_TypeError, "setAngularVelocity expects a ptVector3");
PYTHON_RETURN_ERROR;
}
if (!pyVector3::Check(velocity))
{
PyErr_SetString(PyExc_TypeError, "setAngularVelocity expects a ptVector3");
PYTHON_RETURN_ERROR;
}
pyVector3 *velocityVec = pyVector3::ConvertFrom(velocity);
self->fThis->SetAngularVelocity(*velocityVec);
PYTHON_RETURN_NONE;
}
PYTHON_START_METHODS_TABLE(ptPhysics)
PYTHON_METHOD(ptPhysics, netForce, "Params: forceFlag\nSpecify whether this object needs to use messages that are forced to the network\n"
"- This is to be used if your Python program is running on only one client\n"
"Such as a game master, only running on the client that owns a particular object"),
PYTHON_METHOD(ptPhysics, enable, "Params: state=1\nSets the physics enable state for the sceneobject attached"),
PYTHON_BASIC_METHOD(ptPhysics, disable, "Disables physics on the sceneobject attached"),
PYTHON_BASIC_METHOD(ptPhysics, disableCollision, "Disables collision detection on the attached sceneobject"),
PYTHON_BASIC_METHOD(ptPhysics, enableCollision, "Enables collision detection on the attached sceneobject"),
PYTHON_METHOD(ptPhysics, warp, "Params: position\nWarps the sceneobject to a specified location.\n"
"'position' can be a ptPoint3 or a ptMatrix44"),
PYTHON_METHOD(ptPhysics, warpObj, "Params: objkey\nWarps the sceneobject to match the location and orientation of the specified object"),
PYTHON_METHOD(ptPhysics, move, "Params: direction,distance\nMoves the attached sceneobject the specified distance in the specified direction"),
PYTHON_METHOD(ptPhysics, rotate, "Params: radians,axis\nRotates the attached sceneobject the specified radians around the specified axis"),
PYTHON_METHOD(ptPhysics, force, "Params: forceVector\nApplies the specified force to the attached sceneobject"),
PYTHON_METHOD(ptPhysics, forceWithOffset, "Params: forceVector,offsetPt\nApplies the specified offsetted force to the attached sceneobject"),
PYTHON_METHOD(ptPhysics, torque, "Params: torqueVector\nApplies the specified torque to the attached sceneobject"),
PYTHON_METHOD(ptPhysics, impulse, "Params: impulseVector\nAdds the given vector to the attached sceneobject's velocity"),
PYTHON_METHOD(ptPhysics, impulseWithOffset, "Params: impulseVector,offsetPt\nAdds the given vector to the attached sceneobject's velocity\n"
"with the specified offset"),
PYTHON_METHOD(ptPhysics, angularImpulse, "Params: impulseVector\nAdd the given vector (representing a rotation axis and magnitude) to\n"
"the attached sceneobject's velocity"),
PYTHON_METHOD(ptPhysics, damp, "Params: damp\nReduce all velocities on the object (0 = all stop, 1 = no effect)"),
PYTHON_METHOD(ptPhysics, shiftMass, "Params: offsetVector\nShifts the attached sceneobject's center to mass in the specified direction and distance"),
PYTHON_METHOD(ptPhysics, suppress, "Params: doSuppress\nCompletely remove the physical, but keep it around so it\n"
"can be added back later."),
PYTHON_METHOD(ptPhysics, setLinearVelocity, "Params: velocityVector\nSets the objects LinearVelocity to the specified vector"),
PYTHON_METHOD(ptPhysics, setAngularVelocity, "Params: velocityVector\nSets the objects AngularVelocity to the specified vector"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE(ptPhysics, "Plasma physics class");
// required functions for PyObject interoperability
PyObject *cyPhysics::New(PyObject *sender, PyObject *recvr)
{
ptPhysics *newObj = (ptPhysics*)ptPhysics_type.tp_new(&ptPhysics_type, NULL, NULL);
if (sender != NULL)
{
pyKey *senderKey = pyKey::ConvertFrom(sender);
newObj->fThis->SetSender(senderKey->getKey());
}
if (recvr != NULL)
{
pyKey *recvrKey = pyKey::ConvertFrom(recvr);
newObj->fThis->AddRecvr(recvrKey->getKey());
}
newObj->fThis->SetNetForce(false);
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptPhysics, cyPhysics)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptPhysics, cyPhysics)
///////////////////////////////////////////////////////////////////////////
//
// AddPlasmaClasses - the python module definitions
//
void cyPhysics::AddPlasmaClasses(PyObject *m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptPhysics);
PYTHON_CLASS_IMPORT_END(m);
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "cyPhysics.h"
#include "pyKey.h"
#include "pyGeometry3.h"
#include "pyMatrix44.h"
#include <python.h>
// glue functions
PYTHON_CLASS_DEFINITION(ptPhysics, cyPhysics);
PYTHON_DEFAULT_NEW_DEFINITION(ptPhysics, cyPhysics)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptPhysics)
PYTHON_INIT_DEFINITION(ptPhysics, args, keywords)
{
PYTHON_RETURN_INIT_OK;
}
PYTHON_METHOD_DEFINITION(ptPhysics, netForce, args)
{
char forceFlag;
if (!PyArg_ParseTuple(args, "b", &forceFlag))
{
PyErr_SetString(PyExc_TypeError, "netForce requires a boolean argument");
PYTHON_RETURN_ERROR;
}
self->fThis->SetNetForce(forceFlag != 0);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptPhysics, enable, args)
{
char stateFlag = 1;
if (!PyArg_ParseTuple(args, "|b", &stateFlag))
{
PyErr_SetString(PyExc_TypeError, "enable expects an optional boolean argument");
PYTHON_RETURN_ERROR;
}
self->fThis->EnableT(stateFlag != 0);
PYTHON_RETURN_NONE;
}
PYTHON_BASIC_METHOD_DEFINITION(ptPhysics, disable, Disable)
PYTHON_BASIC_METHOD_DEFINITION(ptPhysics, disableCollision, DisableCollision)
PYTHON_BASIC_METHOD_DEFINITION(ptPhysics, enableCollision, EnableCollision)
PYTHON_METHOD_DEFINITION(ptPhysics, warp, args)
{
PyObject *positionObject = NULL;
if (!PyArg_ParseTuple(args, "O", &positionObject))
{
PyErr_SetString(PyExc_TypeError, "warp expects a ptPoint3 or ptMatrix44 object");
PYTHON_RETURN_ERROR;
}
if (pyPoint3::Check(positionObject))
{
pyPoint3 *pos = pyPoint3::ConvertFrom(positionObject);
self->fThis->Warp(*pos);
PYTHON_RETURN_NONE;
}
else if (pyMatrix44::Check(positionObject))
{
pyMatrix44 *mat = pyMatrix44::ConvertFrom(positionObject);
self->fThis->WarpMat(*mat);
PYTHON_RETURN_NONE;
}
PyErr_SetString(PyExc_TypeError, "warp expects a ptPoint3 or ptMatrix44 object");
PYTHON_RETURN_ERROR;
}
PYTHON_METHOD_DEFINITION(ptPhysics, warpObj, args)
{
PyObject *keyObject = NULL;
if (!PyArg_ParseTuple(args, "O", &keyObject))
{
PyErr_SetString(PyExc_TypeError, "warpObj expects a ptKey");
PYTHON_RETURN_ERROR;
}
if (!pyKey::Check(keyObject))
{
PyErr_SetString(PyExc_TypeError, "warpObj expects a ptKey");
PYTHON_RETURN_ERROR;
}
pyKey *key = pyKey::ConvertFrom(keyObject);
self->fThis->WarpObj(*key);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptPhysics, move, args)
{
PyObject *directionObject = NULL;
float distance;
if (!PyArg_ParseTuple(args, "Of", &directionObject, &distance))
{
PyErr_SetString(PyExc_TypeError, "move expects a ptVector3 and float");
PYTHON_RETURN_ERROR;
}
if (!pyVector3::Check(directionObject))
{
PyErr_SetString(PyExc_TypeError, "move expects a ptVector3 and float");
PYTHON_RETURN_ERROR;
}
pyVector3 *direction = pyVector3::ConvertFrom(directionObject);
self->fThis->Move(*direction, distance);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptPhysics, rotate, args)
{
float radians;
PyObject *axisObject = NULL;
if (!PyArg_ParseTuple(args, "fO", &radians, &axisObject))
{
PyErr_SetString(PyExc_TypeError, "rotate expects a float and ptVector3");
PYTHON_RETURN_ERROR;
}
if (!pyVector3::Check(axisObject))
{
PyErr_SetString(PyExc_TypeError, "rotate expects a float and ptVector3");
PYTHON_RETURN_ERROR;
}
pyVector3 *axis = pyVector3::ConvertFrom(axisObject);
self->fThis->Rotate(radians, *axis);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptPhysics, force, args)
{
PyObject *forceObject = NULL;
if (!PyArg_ParseTuple(args, "O", &forceObject))
{
PyErr_SetString(PyExc_TypeError, "force expects a ptVector3");
PYTHON_RETURN_ERROR;
}
if (!pyVector3::Check(forceObject))
{
PyErr_SetString(PyExc_TypeError, "force expects a ptVector3");
PYTHON_RETURN_ERROR;
}
pyVector3 *force = pyVector3::ConvertFrom(forceObject);
self->fThis->Force(*force);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptPhysics, forceWithOffset, args)
{
PyObject *forceObject = NULL;
PyObject *offsetObject = NULL;
if (!PyArg_ParseTuple(args, "OO", &forceObject, &offsetObject))
{
PyErr_SetString(PyExc_TypeError, "forceWithOffset expects a ptVector3 and a ptPoint3");
PYTHON_RETURN_ERROR;
}
if ((!pyVector3::Check(forceObject)) || (!pyPoint3::Check(offsetObject)))
{
PyErr_SetString(PyExc_TypeError, "forceWithOffset expects a ptVector3 and a ptPoint3");
PYTHON_RETURN_ERROR;
}
pyVector3 *force = pyVector3::ConvertFrom(forceObject);
pyPoint3 *offset = pyPoint3::ConvertFrom(offsetObject);
self->fThis->ForceWithOffset(*force, *offset);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptPhysics, torque, args)
{
PyObject *torqueObject = NULL;
if (!PyArg_ParseTuple(args, "O", &torqueObject))
{
PyErr_SetString(PyExc_TypeError, "torque expects a ptVector3");
PYTHON_RETURN_ERROR;
}
if (!pyVector3::Check(torqueObject))
{
PyErr_SetString(PyExc_TypeError, "torque expects a ptVector3");
PYTHON_RETURN_ERROR;
}
pyVector3 *torque = pyVector3::ConvertFrom(torqueObject);
self->fThis->Torque(*torque);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptPhysics, impulse, args)
{
PyObject *forceObject = NULL;
if (!PyArg_ParseTuple(args, "O", &forceObject))
{
PyErr_SetString(PyExc_TypeError, "impulse expects a ptVector3");
PYTHON_RETURN_ERROR;
}
if (!pyVector3::Check(forceObject))
{
PyErr_SetString(PyExc_TypeError, "impulse expects a ptVector3");
PYTHON_RETURN_ERROR;
}
pyVector3 *force = pyVector3::ConvertFrom(forceObject);
self->fThis->Impulse(*force);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptPhysics, impulseWithOffset, args)
{
PyObject *forceObject = NULL;
PyObject *offsetObject = NULL;
if (!PyArg_ParseTuple(args, "OO", &forceObject, &offsetObject))
{
PyErr_SetString(PyExc_TypeError, "impulseWithOffset expects a ptVector3 and a ptPoint3");
PYTHON_RETURN_ERROR;
}
if ((!pyVector3::Check(forceObject)) || (!pyPoint3::Check(offsetObject)))
{
PyErr_SetString(PyExc_TypeError, "impulseWithOffset expects a ptVector3 and a ptPoint3");
PYTHON_RETURN_ERROR;
}
pyVector3 *force = pyVector3::ConvertFrom(forceObject);
pyPoint3 *offset = pyPoint3::ConvertFrom(offsetObject);
self->fThis->ImpulseWithOffset(*force, *offset);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptPhysics, angularImpulse, args)
{
PyObject *forceObject = NULL;
if (!PyArg_ParseTuple(args, "O", &forceObject))
{
PyErr_SetString(PyExc_TypeError, "angularImpulse expects a ptVector3");
PYTHON_RETURN_ERROR;
}
if (!pyVector3::Check(forceObject))
{
PyErr_SetString(PyExc_TypeError, "angularImpulse expects a ptVector3");
PYTHON_RETURN_ERROR;
}
pyVector3 *force = pyVector3::ConvertFrom(forceObject);
self->fThis->AngularImpulse(*force);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptPhysics, damp, args)
{
float damp;
if (!PyArg_ParseTuple(args, "f", &damp))
{
PyErr_SetString(PyExc_TypeError, "damp expects a float");
PYTHON_RETURN_ERROR;
}
self->fThis->Damp(damp);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptPhysics, shiftMass, args)
{
PyObject *offestObject = NULL;
if (!PyArg_ParseTuple(args, "O", &offestObject))
{
PyErr_SetString(PyExc_TypeError, "shiftMass expects a ptVector3");
PYTHON_RETURN_ERROR;
}
if (!pyVector3::Check(offestObject))
{
PyErr_SetString(PyExc_TypeError, "shiftMass expects a ptVector3");
PYTHON_RETURN_ERROR;
}
pyVector3 *offset = pyVector3::ConvertFrom(offestObject);
self->fThis->ShiftMass(*offset);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptPhysics, suppress, args)
{
char doSuppress;
if (!PyArg_ParseTuple(args, "b", &doSuppress))
{
PyErr_SetString(PyExc_TypeError, "suppress expects a boolean");
PYTHON_RETURN_NONE;
}
self->fThis->Suppress(doSuppress != 0);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptPhysics, setLinearVelocity, args)
{
PyObject *velocity = NULL;
if (!PyArg_ParseTuple(args, "O", &velocity))
{
PyErr_SetString(PyExc_TypeError, "setVelocity expects a ptVector3");
PYTHON_RETURN_ERROR;
}
if (!pyVector3::Check(velocity))
{
PyErr_SetString(PyExc_TypeError, "setVelocity expects a ptVector3");
PYTHON_RETURN_ERROR;
}
pyVector3 *velocityVec = pyVector3::ConvertFrom(velocity);
self->fThis->SetLinearVelocity(*velocityVec);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptPhysics, setAngularVelocity, args)
{
PyObject *velocity = NULL;
if (!PyArg_ParseTuple(args, "O", &velocity))
{
PyErr_SetString(PyExc_TypeError, "setAngularVelocity expects a ptVector3");
PYTHON_RETURN_ERROR;
}
if (!pyVector3::Check(velocity))
{
PyErr_SetString(PyExc_TypeError, "setAngularVelocity expects a ptVector3");
PYTHON_RETURN_ERROR;
}
pyVector3 *velocityVec = pyVector3::ConvertFrom(velocity);
self->fThis->SetAngularVelocity(*velocityVec);
PYTHON_RETURN_NONE;
}
PYTHON_START_METHODS_TABLE(ptPhysics)
PYTHON_METHOD(ptPhysics, netForce, "Params: forceFlag\nSpecify whether this object needs to use messages that are forced to the network\n"
"- This is to be used if your Python program is running on only one client\n"
"Such as a game master, only running on the client that owns a particular object"),
PYTHON_METHOD(ptPhysics, enable, "Params: state=1\nSets the physics enable state for the sceneobject attached"),
PYTHON_BASIC_METHOD(ptPhysics, disable, "Disables physics on the sceneobject attached"),
PYTHON_BASIC_METHOD(ptPhysics, disableCollision, "Disables collision detection on the attached sceneobject"),
PYTHON_BASIC_METHOD(ptPhysics, enableCollision, "Enables collision detection on the attached sceneobject"),
PYTHON_METHOD(ptPhysics, warp, "Params: position\nWarps the sceneobject to a specified location.\n"
"'position' can be a ptPoint3 or a ptMatrix44"),
PYTHON_METHOD(ptPhysics, warpObj, "Params: objkey\nWarps the sceneobject to match the location and orientation of the specified object"),
PYTHON_METHOD(ptPhysics, move, "Params: direction,distance\nMoves the attached sceneobject the specified distance in the specified direction"),
PYTHON_METHOD(ptPhysics, rotate, "Params: radians,axis\nRotates the attached sceneobject the specified radians around the specified axis"),
PYTHON_METHOD(ptPhysics, force, "Params: forceVector\nApplies the specified force to the attached sceneobject"),
PYTHON_METHOD(ptPhysics, forceWithOffset, "Params: forceVector,offsetPt\nApplies the specified offsetted force to the attached sceneobject"),
PYTHON_METHOD(ptPhysics, torque, "Params: torqueVector\nApplies the specified torque to the attached sceneobject"),
PYTHON_METHOD(ptPhysics, impulse, "Params: impulseVector\nAdds the given vector to the attached sceneobject's velocity"),
PYTHON_METHOD(ptPhysics, impulseWithOffset, "Params: impulseVector,offsetPt\nAdds the given vector to the attached sceneobject's velocity\n"
"with the specified offset"),
PYTHON_METHOD(ptPhysics, angularImpulse, "Params: impulseVector\nAdd the given vector (representing a rotation axis and magnitude) to\n"
"the attached sceneobject's velocity"),
PYTHON_METHOD(ptPhysics, damp, "Params: damp\nReduce all velocities on the object (0 = all stop, 1 = no effect)"),
PYTHON_METHOD(ptPhysics, shiftMass, "Params: offsetVector\nShifts the attached sceneobject's center to mass in the specified direction and distance"),
PYTHON_METHOD(ptPhysics, suppress, "Params: doSuppress\nCompletely remove the physical, but keep it around so it\n"
"can be added back later."),
PYTHON_METHOD(ptPhysics, setLinearVelocity, "Params: velocityVector\nSets the objects LinearVelocity to the specified vector"),
PYTHON_METHOD(ptPhysics, setAngularVelocity, "Params: velocityVector\nSets the objects AngularVelocity to the specified vector"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE(ptPhysics, "Plasma physics class");
// required functions for PyObject interoperability
PyObject *cyPhysics::New(PyObject *sender, PyObject *recvr)
{
ptPhysics *newObj = (ptPhysics*)ptPhysics_type.tp_new(&ptPhysics_type, NULL, NULL);
if (sender != NULL)
{
pyKey *senderKey = pyKey::ConvertFrom(sender);
newObj->fThis->SetSender(senderKey->getKey());
}
if (recvr != NULL)
{
pyKey *recvrKey = pyKey::ConvertFrom(recvr);
newObj->fThis->AddRecvr(recvrKey->getKey());
}
newObj->fThis->SetNetForce(false);
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptPhysics, cyPhysics)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptPhysics, cyPhysics)
///////////////////////////////////////////////////////////////////////////
//
// AddPlasmaClasses - the python module definitions
//
void cyPhysics::AddPlasmaClasses(PyObject *m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptPhysics);
PYTHON_CLASS_IMPORT_END(m);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,223 +1,223 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////
//
// PythonInterface - The Python interface to the Python dll
//
// NOTE: Eventually, this will be made into a separate dll, because there should
// only be one instance of this interface.
//
#include "hsTypes.h"
#include "hsStlUtils.h"
#include <python.h>
#if defined(HAVE_CYPYTHONIDE) && !defined(PLASMA_EXTERNAL_RELEASE)
#include "../../Apps/CyPythonIDE/plCyDebug/plCyDebServer.h"
#endif
class plStatusLog;
class pyKey;
class PythonInterface
{
private:
static Int32 initialized; // count how many times we initialize
// and make sure that many finalize on the way out
static hsBool FirstTimeInit;
static hsBool IsInShutdown; // whether we are _really_ in shutdown mode
static PyMethodDef* plasmaMethods;
static PyObject* plasmaMod; // python object that holds the Plasma module
static PyObject* plasmaConstantsMod; // python object that holds the PlasmaConstants module
static PyObject* plasmaNetConstantsMod; // python object that holds the PlasmaNetConstants module
static PyObject* plasmaVaultConstantsMod; // python object that holds the PlasmaVaultConstants module
static PyMethodDef* plasmaGameMethods;
static PyObject* plasmaGameMod; // python object that holds the PlasmaGame module
static PyObject* plasmaGameConstantsMod; // python object that holds the PlasmaGameConstants module
static PyObject* stdOut; // python object of the stdout file
static PyObject* stdErr; // python object of the err file
static hsBool debug_initialized; // has the debug been initialized yet?
static PyObject* dbgMod; // display module for stdout and stderr
static PyObject* dbgOut;
static PyObject* dbgSlice; // time slice function for the debug window
static plStatusLog* dbgLog;
#if defined(HAVE_CYPYTHONIDE) && !defined(PLASMA_EXTERNAL_RELEASE)
static bool usePythonDebugger;
static bool requestedExit;
static plCyDebServer debugServer;
#endif
public:
// set that we are truly shutting down
static void WeAreInShutdown() { IsInShutdown = true; }
// Initialize the Python dll
static void initPython();
// Initialize the Plasma module
static void AddPlasmaMethods(std::vector<PyMethodDef> &methods);
static void AddPlasmaClasses();
// Initialize the PlasmaConstants module
static void AddPlasmaConstantsClasses();
// Initialize the PlasmaNetConstants module;
static void AddPlasmaNetConstantsClasses();
// Initialize the PlasmaVaultConstants module;
static void AddPlasmaVaultConstantsClasses();
// Initialize the PlasmaGame module
static void AddPlasmaGameMethods(std::vector<PyMethodDef> &methods);
static void AddPlasmaGameClasses();
// Initialize the PlasmaGameConstants module
static void AddPlasmaGameConstantsClasses();
// Initialize the Python to Plasma
static void initDebugInterface();
// Finalize the Python dll, ie. get ready to shut down
static void finiPython();
// give the debug window a time slice
static void debugTimeSlice();
// get the stdout PyObject
static PyObject* GetStdOut();
static PyObject* GetStdErr();
// get the Output to the error file to be displayed
static int getOutputAndReset(std::string* output = nil);
// Writes 'text' to the Python log
static void WriteToLog(const char* text);
// Writes 'text' to stderr specified in the python interface
static void WriteToStdErr(const char* text);
// Find module. If it doesn't exist then don't create, return nil.
static PyObject* FindModule(char* module);
// create a new module with built-ins
static PyObject* CreateModule(char* module);
// checks to see if a specific function is defined in this module
// get an item (probably a function) from the Plasma module
static PyObject* GetPlasmaItem(char* item);
// Determine if the module name is unique
static hsBool IsModuleNameUnique(char* module);
// get an item (probably a function) from a specific module
static PyObject* GetModuleItem(char* item, PyObject* module);
// check a specific module for the define funcitons
static void CheckModuleForFunctions(PyObject* module, char** funcNames, PyObject** funcTable);
// checks to see if a specific function is defined in this instance of a class
// and will fill out the funcTable with object instances of where the funciton is
//
static void CheckInstanceForFunctions(PyObject* instance, char** funcNames, PyObject** funcTable);
// run a python string in a specific module name
// PARAMETERS : command - string of commands to execute in the...
// : filename - filename to say where to code came from
static PyObject* CompileString(char *command, char* filename);
/////////////////////////////////////////////////////////////////////////////
//
// Function : DumpObject
// PARAMETERS : pyobject - string of commands to execute in the...
//
// PURPOSE : marshals an object into a char string
//
static hsBool DumpObject(PyObject* pyobj, char** pickle, Int32* size);
/////////////////////////////////////////////////////////////////////////////
//
// Function : LoadObject
// PARAMETERS : pickle - the pickled object in char string form
// : size - size of the guts to load into an object
//
// PURPOSE : Load a python object from a pickled object
//
static PyObject* LoadObject(char* pickle, Int32 size);
/////////////////////////////////////////////////////////////////////////////
//
// Function : RunStringInteractive
// PARAMETERS : command - string of commands to execute in the...
// : module - module name to run 'command' in
//
// PURPOSE : run a python string in a specific module name
// : Interactive mode (displays results)
//
static hsBool RunStringInteractive(char *command, PyObject* module);
/////////////////////////////////////////////////////////////////////////////
//
// Function : RunString
// PARAMETERS : command - string of commands to execute in the...
// : module - module name to run 'command' in
//
// PURPOSE : run a python string in a specific module name
//
static hsBool RunString(char *command, PyObject* module);
/////////////////////////////////////////////////////////////////////////////
//
// Function : RunPYC
// PARAMETERS : code - compiled code
// : module - module name to run the code in
//
// PURPOSE : run a compiled python code in a specific module name
//
static hsBool RunPYC(PyObject* code, PyObject* module);
/////////////////////////////////////////////////////////////////////////////
//
// Function : GetpyKeyFromPython
// PARAMETERS : pkey - python object that is a pyKey (ptKey) class
//
// PURPOSE : turn a PyObject* into a pyKey*
//
static pyKey* GetpyKeyFromPython(PyObject* pkey);
#if defined(HAVE_CYPYTHONIDE) && !defined(PLASMA_EXTERNAL_RELEASE)
static bool UsePythonDebugger() { return usePythonDebugger; }
static void UsePythonDebugger(bool use) { usePythonDebugger = use; }
static plCyDebServer* PythonDebugger() {return &debugServer;}
static bool DebuggerRequestedExit() {return requestedExit;}
static void DebuggerRequestedExit(bool reqExit) {requestedExit = reqExit;}
#endif
};
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////
//
// PythonInterface - The Python interface to the Python dll
//
// NOTE: Eventually, this will be made into a separate dll, because there should
// only be one instance of this interface.
//
#include "hsTypes.h"
#include "hsStlUtils.h"
#include <python.h>
#if defined(HAVE_CYPYTHONIDE) && !defined(PLASMA_EXTERNAL_RELEASE)
#include "../../Apps/CyPythonIDE/plCyDebug/plCyDebServer.h"
#endif
class plStatusLog;
class pyKey;
class PythonInterface
{
private:
static Int32 initialized; // count how many times we initialize
// and make sure that many finalize on the way out
static hsBool FirstTimeInit;
static hsBool IsInShutdown; // whether we are _really_ in shutdown mode
static PyMethodDef* plasmaMethods;
static PyObject* plasmaMod; // python object that holds the Plasma module
static PyObject* plasmaConstantsMod; // python object that holds the PlasmaConstants module
static PyObject* plasmaNetConstantsMod; // python object that holds the PlasmaNetConstants module
static PyObject* plasmaVaultConstantsMod; // python object that holds the PlasmaVaultConstants module
static PyMethodDef* plasmaGameMethods;
static PyObject* plasmaGameMod; // python object that holds the PlasmaGame module
static PyObject* plasmaGameConstantsMod; // python object that holds the PlasmaGameConstants module
static PyObject* stdOut; // python object of the stdout file
static PyObject* stdErr; // python object of the err file
static hsBool debug_initialized; // has the debug been initialized yet?
static PyObject* dbgMod; // display module for stdout and stderr
static PyObject* dbgOut;
static PyObject* dbgSlice; // time slice function for the debug window
static plStatusLog* dbgLog;
#if defined(HAVE_CYPYTHONIDE) && !defined(PLASMA_EXTERNAL_RELEASE)
static bool usePythonDebugger;
static bool requestedExit;
static plCyDebServer debugServer;
#endif
public:
// set that we are truly shutting down
static void WeAreInShutdown() { IsInShutdown = true; }
// Initialize the Python dll
static void initPython();
// Initialize the Plasma module
static void AddPlasmaMethods(std::vector<PyMethodDef> &methods);
static void AddPlasmaClasses();
// Initialize the PlasmaConstants module
static void AddPlasmaConstantsClasses();
// Initialize the PlasmaNetConstants module;
static void AddPlasmaNetConstantsClasses();
// Initialize the PlasmaVaultConstants module;
static void AddPlasmaVaultConstantsClasses();
// Initialize the PlasmaGame module
static void AddPlasmaGameMethods(std::vector<PyMethodDef> &methods);
static void AddPlasmaGameClasses();
// Initialize the PlasmaGameConstants module
static void AddPlasmaGameConstantsClasses();
// Initialize the Python to Plasma
static void initDebugInterface();
// Finalize the Python dll, ie. get ready to shut down
static void finiPython();
// give the debug window a time slice
static void debugTimeSlice();
// get the stdout PyObject
static PyObject* GetStdOut();
static PyObject* GetStdErr();
// get the Output to the error file to be displayed
static int getOutputAndReset(std::string* output = nil);
// Writes 'text' to the Python log
static void WriteToLog(const char* text);
// Writes 'text' to stderr specified in the python interface
static void WriteToStdErr(const char* text);
// Find module. If it doesn't exist then don't create, return nil.
static PyObject* FindModule(char* module);
// create a new module with built-ins
static PyObject* CreateModule(char* module);
// checks to see if a specific function is defined in this module
// get an item (probably a function) from the Plasma module
static PyObject* GetPlasmaItem(char* item);
// Determine if the module name is unique
static hsBool IsModuleNameUnique(char* module);
// get an item (probably a function) from a specific module
static PyObject* GetModuleItem(char* item, PyObject* module);
// check a specific module for the define funcitons
static void CheckModuleForFunctions(PyObject* module, char** funcNames, PyObject** funcTable);
// checks to see if a specific function is defined in this instance of a class
// and will fill out the funcTable with object instances of where the funciton is
//
static void CheckInstanceForFunctions(PyObject* instance, char** funcNames, PyObject** funcTable);
// run a python string in a specific module name
// PARAMETERS : command - string of commands to execute in the...
// : filename - filename to say where to code came from
static PyObject* CompileString(char *command, char* filename);
/////////////////////////////////////////////////////////////////////////////
//
// Function : DumpObject
// PARAMETERS : pyobject - string of commands to execute in the...
//
// PURPOSE : marshals an object into a char string
//
static hsBool DumpObject(PyObject* pyobj, char** pickle, Int32* size);
/////////////////////////////////////////////////////////////////////////////
//
// Function : LoadObject
// PARAMETERS : pickle - the pickled object in char string form
// : size - size of the guts to load into an object
//
// PURPOSE : Load a python object from a pickled object
//
static PyObject* LoadObject(char* pickle, Int32 size);
/////////////////////////////////////////////////////////////////////////////
//
// Function : RunStringInteractive
// PARAMETERS : command - string of commands to execute in the...
// : module - module name to run 'command' in
//
// PURPOSE : run a python string in a specific module name
// : Interactive mode (displays results)
//
static hsBool RunStringInteractive(char *command, PyObject* module);
/////////////////////////////////////////////////////////////////////////////
//
// Function : RunString
// PARAMETERS : command - string of commands to execute in the...
// : module - module name to run 'command' in
//
// PURPOSE : run a python string in a specific module name
//
static hsBool RunString(char *command, PyObject* module);
/////////////////////////////////////////////////////////////////////////////
//
// Function : RunPYC
// PARAMETERS : code - compiled code
// : module - module name to run the code in
//
// PURPOSE : run a compiled python code in a specific module name
//
static hsBool RunPYC(PyObject* code, PyObject* module);
/////////////////////////////////////////////////////////////////////////////
//
// Function : GetpyKeyFromPython
// PARAMETERS : pkey - python object that is a pyKey (ptKey) class
//
// PURPOSE : turn a PyObject* into a pyKey*
//
static pyKey* GetpyKeyFromPython(PyObject* pkey);
#if defined(HAVE_CYPYTHONIDE) && !defined(PLASMA_EXTERNAL_RELEASE)
static bool UsePythonDebugger() { return usePythonDebugger; }
static void UsePythonDebugger(bool use) { usePythonDebugger = use; }
static plCyDebServer* PythonDebugger() {return &debugServer;}
static bool DebuggerRequestedExit() {return requestedExit;}
static void DebuggerRequestedExit(bool reqExit) {requestedExit = reqExit;}
#endif
};

View File

@ -1,37 +1,37 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plPythonCreatable_inc
#define plPythonCreatable_inc
#include "pnFactory/plCreator.h"
#include "plPythonFileMod.h"
REGISTER_CREATABLE( plPythonFileMod );
#include "plPythonSDLModifier.h"
REGISTER_CREATABLE( plPythonSDLModifier );
#endif // plPythonCreatable_inc
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plPythonCreatable_inc
#define plPythonCreatable_inc
#include "pnFactory/plCreator.h"
#include "plPythonFileMod.h"
REGISTER_CREATABLE( plPythonFileMod );
#include "plPythonSDLModifier.h"
REGISTER_CREATABLE( plPythonSDLModifier );
#endif // plPythonCreatable_inc

File diff suppressed because it is too large Load Diff

View File

@ -1,203 +1,203 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef _plPythonFileMod_h_
#define _plPythonFileMod_h_
//////////////////////////////////////////////////////////////////////
//
// plPythonFileMod - the 'special' Python File modifier
//
// This modifier will handle the interface to python code that has been file-ized.
//
//////////////////////////////////////////////////////////////////////
#include "pnModifier/plMultiModifier.h"
#include "hsGeometry3.h"
#include "hsResMgr.h"
#include <python.h>
#include "plPythonParameter.h"
class PythonVaultCallback;
class plPythonSDLModifier;
class pyKey;
class pfPythonKeyCatcher;
class plKeyEventMsg;
class plPipeline;
class plPythonFileMod : public plMultiModifier
{
protected:
friend class plPythonSDLModifier;
plPythonSDLModifier* fSDLMod;
hsBool IEval(double secs, hsScalar del, UInt32 dirty);
void IMakeModuleName(char* modulename,plSceneObject* sobj);
char* fPythonFile;
char* fModuleName;
// the list of receivers that want to be notified
hsTArray<plKey> fReceivers;
PyObject* fSelfKey;
plPipeline *fPipe;
// the list of parameters (attributes)
hsTArray<plPythonParameter> fParameters;
// internal data
PyObject* fModule; // python module object
PyObject* fInstance; // python object that the instance of the class to run
static hsBool fAtConvertTime; // flag for when in convert time within Max, don't run code
hsBool fLocalNotify; // True when This Mod was Notified by a local plNotify
hsBool fIsFirstTimeEval; // flag to determine when the first time at the eval,
// so the Python coders can hava a chance to run initialization
// code after the system is up, but before things are displayed
hsBool fAmIAttachedToClone; // is this python file mod attached to a cloned object
// callback class for the KI
PythonVaultCallback *fVaultCallback;
pfPythonKeyCatcher *fKeyCatcher;
struct NamedComponent
{
char* name;
Int32 id;
bool isActivator;
};
hsTArray<NamedComponent> fNamedCompQueue;
virtual void IFindResponderAndAdd(const char *responderName, Int32 id);
virtual void IFindActivatorAndAdd(const char *activatorName, Int32 id);
void ISetKeyValue(const plKey& key, Int32 id);
bool ILoadPythonCode();
enum genref_whats
{
kNotSure = 0,
kAddNotify
};
public:
plPythonFileMod();
~plPythonFileMod();
CLASSNAME_REGISTER( plPythonFileMod );
GETINTERFACE_ANY( plPythonFileMod, plMultiModifier );
plPythonSDLModifier* GetSDLMod() { return fSDLMod; }
hsBool WasLocalNotify() { return fLocalNotify; }
plPipeline* GetPipeline() { return fPipe; }
virtual void SetSourceFile(const char* filename);
virtual int getPythonOutput(std::string* line);
virtual void ReportError();
virtual void DisplayPythonOutput();
static void SetAtConvertTime() { fAtConvertTime=true; }
virtual hsBool AmIAttachedToClone() { return fAmIAttachedToClone; }
virtual void AddToNotifyList(plKey pKey) { fReceivers.Append(pKey); }
virtual Int32 NotifyListCount() { return fReceivers.Count(); }
virtual plKey GetNotifyListItem(Int32 i) { return fReceivers[i]; }
virtual void AddParameter(plPythonParameter param) { fParameters.Append(param); }
virtual Int32 GetParameterListCount() { return fParameters.Count(); }
virtual plPythonParameter GetParameterItem(Int32 i) { return fParameters[i]; }
virtual void AddTarget(plSceneObject* sobj);
virtual void RemoveTarget(plSceneObject* so);
virtual void EnableControlKeyEvents();
virtual void DisableControlKeyEvents();
virtual hsBool MsgReceive(plMessage* msg);
virtual void Read(hsStream* stream, hsResMgr* mgr);
virtual void Write(hsStream* stream, hsResMgr* mgr);
// this is to keep track of what python functions are available and working,
// so there is no need to keep trying and banging our head until its bloody
enum func_num
{
kfunc_FirstUpdate = 0, // these enums _have_ to match the static names in fEventFunctionNames
kfunc_Update,
kfunc_Notify, // OnNotify
kfunc_AtTimer,
kfunc_OnKeyEvent,
kfunc_Load,
kfunc_Save,
kfunc_GUINotify,
kfunc_PageLoad,
kfunc_ClothingUpdate,
kfunc_KIMsg,
kfunc_MemberUpdate,
kfunc_RemoteAvatarInfo,
kfunc_RTChat,
kfunc_VaultEvent,
kfunc_AvatarPage,
kfunc_SDLNotify,
kfunc_OwnershipNotify,
kfunc_AgeVaultEvent,
kfunc_Init,
kfunc_OnCCRMsg,
kfunc_OnServerInitComplete,
kfunc_OnVaultNotify,
kfunc_OnDefaultKeyCaught,
kfunc_OnMarkerMsg,
kfunc_OnBackdoorMsg,
kfunc_OnBehaviorNotify,
kfunc_OnLOSNotify,
kfunc_OnBeginAgeLoad,
kfunc_OnMovieEvent,
kfunc_OnScreenCaptureDone,
kfunc_OnClimbBlockerEvent,
kfunc_OnAvatarSpawn,
kfunc_OnAccountUpdate,
kfunc_gotPublicAgeList,
kfunc_OnGameMgrMsg,
kfunc_OnGameCliMsg,
kfunc_OnAIMsg,
kfunc_lastone
};
// array of matching Python instance where the functions are, if defined
PyObject* fPyFunctionInstances[kfunc_lastone];
// array of the names of the standard functions that can be called
static char* fFunctionNames[];
// The konstant hard-coded name to be used for all global pythonFileMods
static char kGlobalNameKonstant[];
// API for processing discarded keys as the deafult key catcher
void HandleDiscardedKey( plKeyEventMsg *msg );
};
#endif // _plPythonFileMod_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef _plPythonFileMod_h_
#define _plPythonFileMod_h_
//////////////////////////////////////////////////////////////////////
//
// plPythonFileMod - the 'special' Python File modifier
//
// This modifier will handle the interface to python code that has been file-ized.
//
//////////////////////////////////////////////////////////////////////
#include "pnModifier/plMultiModifier.h"
#include "hsGeometry3.h"
#include "hsResMgr.h"
#include <python.h>
#include "plPythonParameter.h"
class PythonVaultCallback;
class plPythonSDLModifier;
class pyKey;
class pfPythonKeyCatcher;
class plKeyEventMsg;
class plPipeline;
class plPythonFileMod : public plMultiModifier
{
protected:
friend class plPythonSDLModifier;
plPythonSDLModifier* fSDLMod;
hsBool IEval(double secs, hsScalar del, UInt32 dirty);
void IMakeModuleName(char* modulename,plSceneObject* sobj);
char* fPythonFile;
char* fModuleName;
// the list of receivers that want to be notified
hsTArray<plKey> fReceivers;
PyObject* fSelfKey;
plPipeline *fPipe;
// the list of parameters (attributes)
hsTArray<plPythonParameter> fParameters;
// internal data
PyObject* fModule; // python module object
PyObject* fInstance; // python object that the instance of the class to run
static hsBool fAtConvertTime; // flag for when in convert time within Max, don't run code
hsBool fLocalNotify; // True when This Mod was Notified by a local plNotify
hsBool fIsFirstTimeEval; // flag to determine when the first time at the eval,
// so the Python coders can hava a chance to run initialization
// code after the system is up, but before things are displayed
hsBool fAmIAttachedToClone; // is this python file mod attached to a cloned object
// callback class for the KI
PythonVaultCallback *fVaultCallback;
pfPythonKeyCatcher *fKeyCatcher;
struct NamedComponent
{
char* name;
Int32 id;
bool isActivator;
};
hsTArray<NamedComponent> fNamedCompQueue;
virtual void IFindResponderAndAdd(const char *responderName, Int32 id);
virtual void IFindActivatorAndAdd(const char *activatorName, Int32 id);
void ISetKeyValue(const plKey& key, Int32 id);
bool ILoadPythonCode();
enum genref_whats
{
kNotSure = 0,
kAddNotify
};
public:
plPythonFileMod();
~plPythonFileMod();
CLASSNAME_REGISTER( plPythonFileMod );
GETINTERFACE_ANY( plPythonFileMod, plMultiModifier );
plPythonSDLModifier* GetSDLMod() { return fSDLMod; }
hsBool WasLocalNotify() { return fLocalNotify; }
plPipeline* GetPipeline() { return fPipe; }
virtual void SetSourceFile(const char* filename);
virtual int getPythonOutput(std::string* line);
virtual void ReportError();
virtual void DisplayPythonOutput();
static void SetAtConvertTime() { fAtConvertTime=true; }
virtual hsBool AmIAttachedToClone() { return fAmIAttachedToClone; }
virtual void AddToNotifyList(plKey pKey) { fReceivers.Append(pKey); }
virtual Int32 NotifyListCount() { return fReceivers.Count(); }
virtual plKey GetNotifyListItem(Int32 i) { return fReceivers[i]; }
virtual void AddParameter(plPythonParameter param) { fParameters.Append(param); }
virtual Int32 GetParameterListCount() { return fParameters.Count(); }
virtual plPythonParameter GetParameterItem(Int32 i) { return fParameters[i]; }
virtual void AddTarget(plSceneObject* sobj);
virtual void RemoveTarget(plSceneObject* so);
virtual void EnableControlKeyEvents();
virtual void DisableControlKeyEvents();
virtual hsBool MsgReceive(plMessage* msg);
virtual void Read(hsStream* stream, hsResMgr* mgr);
virtual void Write(hsStream* stream, hsResMgr* mgr);
// this is to keep track of what python functions are available and working,
// so there is no need to keep trying and banging our head until its bloody
enum func_num
{
kfunc_FirstUpdate = 0, // these enums _have_ to match the static names in fEventFunctionNames
kfunc_Update,
kfunc_Notify, // OnNotify
kfunc_AtTimer,
kfunc_OnKeyEvent,
kfunc_Load,
kfunc_Save,
kfunc_GUINotify,
kfunc_PageLoad,
kfunc_ClothingUpdate,
kfunc_KIMsg,
kfunc_MemberUpdate,
kfunc_RemoteAvatarInfo,
kfunc_RTChat,
kfunc_VaultEvent,
kfunc_AvatarPage,
kfunc_SDLNotify,
kfunc_OwnershipNotify,
kfunc_AgeVaultEvent,
kfunc_Init,
kfunc_OnCCRMsg,
kfunc_OnServerInitComplete,
kfunc_OnVaultNotify,
kfunc_OnDefaultKeyCaught,
kfunc_OnMarkerMsg,
kfunc_OnBackdoorMsg,
kfunc_OnBehaviorNotify,
kfunc_OnLOSNotify,
kfunc_OnBeginAgeLoad,
kfunc_OnMovieEvent,
kfunc_OnScreenCaptureDone,
kfunc_OnClimbBlockerEvent,
kfunc_OnAvatarSpawn,
kfunc_OnAccountUpdate,
kfunc_gotPublicAgeList,
kfunc_OnGameMgrMsg,
kfunc_OnGameCliMsg,
kfunc_OnAIMsg,
kfunc_lastone
};
// array of matching Python instance where the functions are, if defined
PyObject* fPyFunctionInstances[kfunc_lastone];
// array of the names of the standard functions that can be called
static char* fFunctionNames[];
// The konstant hard-coded name to be used for all global pythonFileMods
static char kGlobalNameKonstant[];
// API for processing discarded keys as the deafult key catcher
void HandleDiscardedKey( plKeyEventMsg *msg );
};
#endif // _plPythonFileMod_h

View File

@ -1,60 +1,60 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef _plPythonHelpers_h_
#define _plPythonHelpers_h_
//////////////////////////////////////////////////////////////////////
//
// plPythonHelpers - helper definitions for plPythonFileMod
//
//////////////////////////////////////////////////////////////////////
// notetrack data structure
typedef struct
{
plKey objKey; // plKey to the object
const char* note_name; // notetrack name
plKey modKey; // the animation modifier plKey that is associated with the notetrack name
} PY_NOTETRACK;
// material animation record structure
typedef struct
{
const char* material_name; // material name
const char* note_name; // notetrack name
plKey modKey; // the animation modifier plKey that is associated with this material animation
} PY_MATERIAL_ANIM;
// material animation record structure
typedef struct
{
const char* sound_name; // the sound name
int sound_index; // the sound index that goes with the sound
} PY_SOUND_IDX;
#endif // _plPythonHelpers_h
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef _plPythonHelpers_h_
#define _plPythonHelpers_h_
//////////////////////////////////////////////////////////////////////
//
// plPythonHelpers - helper definitions for plPythonFileMod
//
//////////////////////////////////////////////////////////////////////
// notetrack data structure
typedef struct
{
plKey objKey; // plKey to the object
const char* note_name; // notetrack name
plKey modKey; // the animation modifier plKey that is associated with the notetrack name
} PY_NOTETRACK;
// material animation record structure
typedef struct
{
const char* material_name; // material name
const char* note_name; // notetrack name
plKey modKey; // the animation modifier plKey that is associated with this material animation
} PY_MATERIAL_ANIM;
// material animation record structure
typedef struct
{
const char* sound_name; // the sound name
int sound_index; // the sound index that goes with the sound
} PY_SOUND_IDX;
#endif // _plPythonHelpers_h

View File

@ -1,229 +1,229 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "hsTypes.h"
#include "hsStlUtils.h"
#include "plPythonPack.h"
#include "hsStream.h"
#include "plFile/hsFiles.h"
#include "plFile/plSecureStream.h"
#include "plFile/plStreamSource.h"
#include "hsStlSortUtils.h"
#include "marshal.h"
static const char* kPackFilePath = ".\\Python\\";
struct plPackOffsetInfo
{
UInt32 fOffset;
UInt32 fStreamIndex; // index of the stream object in the plPythonPack object that the file resides in
};
class plPythonPack
{
protected:
std::vector<hsStream*> fPackStreams;
bool fPackNotFound; // No pack file, don't keep trying
typedef std::map<std::string, plPackOffsetInfo> FileOffset;
FileOffset fFileOffsets;
plPythonPack();
public:
~plPythonPack();
static plPythonPack& Instance();
bool Open();
void Close();
PyObject* OpenPacked(const char *fileName);
hsBool IsPackedFile(const char* fileName);
};
PyObject* PythonPack::OpenPythonPacked(const char* fileName)
{
return plPythonPack::Instance().OpenPacked(fileName);
}
hsBool PythonPack::IsItPythonPacked(const char* fileName)
{
return plPythonPack::Instance().IsPackedFile(fileName);
}
plPythonPack::plPythonPack() : fPackNotFound(false)
{
}
plPythonPack::~plPythonPack()
{
Close();
}
plPythonPack& plPythonPack::Instance()
{
static plPythonPack theInstance;
return theInstance;
}
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
bool plPythonPack::Open()
{
if (fPackStreams.size() > 0)
return true;
// We already tried and it wasn't there
if (fPackNotFound)
return false;
fPackNotFound = true;
// Get the names of all the pak files
std::vector<std::wstring> files = plStreamSource::GetInstance()->GetListOfNames(L"python", L".pak");
std::vector<time_t> modTimes; // the modification time for each of the streams (to resolve duplicate file issues)
// grab all the .pak files in the folder
for (int curName = 0; curName < files.size(); curName++)
{
// obtain the stream
hsStream *fPackStream = plStreamSource::GetInstance()->GetFile(files[curName]);
if (fPackStream)
{
fPackStream->Rewind(); // make sure we're at the beginning of the file
fPackNotFound = false;
char* tempFilename = hsWStringToString(files[curName].c_str());
struct stat buf;
time_t curModTime = 0;
if (stat(tempFilename,&buf)==0)
curModTime = buf.st_mtime;
modTimes.push_back(curModTime);
delete [] tempFilename;
// read the index data
int numFiles = fPackStream->ReadSwap32();
UInt32 streamIndex = (UInt32)(fPackStreams.size());
for (int i = 0; i < numFiles; i++)
{
// and pack the index into our own data structure
char* buf = fPackStream->ReadSafeString();
std::string pythonName = buf; // reading a "string" from a hsStream directly into a stl string causes memory loss
delete [] buf;
UInt32 offset = fPackStream->ReadSwap32();
plPackOffsetInfo offsetInfo;
offsetInfo.fOffset = offset;
offsetInfo.fStreamIndex = streamIndex;
if (fFileOffsets.find(pythonName) != fFileOffsets.end())
{
UInt32 index = fFileOffsets[pythonName].fStreamIndex;
if (modTimes[index] < curModTime) // is the existing file older then the new one?
fFileOffsets[pythonName] = offsetInfo; // yup, so replace it with the new info
}
else
fFileOffsets[pythonName] = offsetInfo; // no conflicts, add the info
}
fPackStreams.push_back(fPackStream);
}
}
return !fPackNotFound;
}
void plPythonPack::Close()
{
if (fPackStreams.size() == 0)
return;
int i;
for (i=0; i<fPackStreams.size(); i++)
{
hsStream* fPackStream = fPackStreams[i];
// do NOT close or delete the streams, the preloader will do that for us
fPackStreams[i] = nil;
}
fPackStreams.clear();
fFileOffsets.clear();
}
PyObject* plPythonPack::OpenPacked(const char* fileName)
{
if (!Open())
return nil;
std::string pythonName = fileName;
pythonName += ".py";
FileOffset::iterator it = fFileOffsets.find(pythonName);
if (it != fFileOffsets.end())
{
plPackOffsetInfo offsetInfo = (*it).second;
hsStream* fPackStream = fPackStreams[offsetInfo.fStreamIndex];
fPackStream->SetPosition(offsetInfo.fOffset);
Int32 size = fPackStream->ReadSwap32();
if (size > 0)
{
char *buf = TRACKED_NEW char[size];
UInt32 readSize = fPackStream->Read(size, buf);
hsAssert(readSize <= size, xtl::format("Python PackFile %s: Incorrect amount of data, read %d instead of %d",
fileName, readSize, size).c_str());
// let the python marshal make it back into a code object
PyObject *pythonCode = PyMarshal_ReadObjectFromString(buf, size);
delete [] buf;
return pythonCode;
}
}
return nil;
}
hsBool plPythonPack::IsPackedFile(const char* fileName)
{
if (!Open())
return nil;
std::string pythonName = fileName;
pythonName += ".py";
FileOffset:: iterator it = fFileOffsets.find(pythonName);
if (it != fFileOffsets.end())
return true;
return false;
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "hsTypes.h"
#include "hsStlUtils.h"
#include "plPythonPack.h"
#include "hsStream.h"
#include "plFile/hsFiles.h"
#include "plFile/plSecureStream.h"
#include "plFile/plStreamSource.h"
#include "hsStlSortUtils.h"
#include "marshal.h"
static const char* kPackFilePath = ".\\Python\\";
struct plPackOffsetInfo
{
UInt32 fOffset;
UInt32 fStreamIndex; // index of the stream object in the plPythonPack object that the file resides in
};
class plPythonPack
{
protected:
std::vector<hsStream*> fPackStreams;
bool fPackNotFound; // No pack file, don't keep trying
typedef std::map<std::string, plPackOffsetInfo> FileOffset;
FileOffset fFileOffsets;
plPythonPack();
public:
~plPythonPack();
static plPythonPack& Instance();
bool Open();
void Close();
PyObject* OpenPacked(const char *fileName);
hsBool IsPackedFile(const char* fileName);
};
PyObject* PythonPack::OpenPythonPacked(const char* fileName)
{
return plPythonPack::Instance().OpenPacked(fileName);
}
hsBool PythonPack::IsItPythonPacked(const char* fileName)
{
return plPythonPack::Instance().IsPackedFile(fileName);
}
plPythonPack::plPythonPack() : fPackNotFound(false)
{
}
plPythonPack::~plPythonPack()
{
Close();
}
plPythonPack& plPythonPack::Instance()
{
static plPythonPack theInstance;
return theInstance;
}
#include <time.h>
#include <sys/types.h>
#include <sys/stat.h>
bool plPythonPack::Open()
{
if (fPackStreams.size() > 0)
return true;
// We already tried and it wasn't there
if (fPackNotFound)
return false;
fPackNotFound = true;
// Get the names of all the pak files
std::vector<std::wstring> files = plStreamSource::GetInstance()->GetListOfNames(L"python", L".pak");
std::vector<time_t> modTimes; // the modification time for each of the streams (to resolve duplicate file issues)
// grab all the .pak files in the folder
for (int curName = 0; curName < files.size(); curName++)
{
// obtain the stream
hsStream *fPackStream = plStreamSource::GetInstance()->GetFile(files[curName]);
if (fPackStream)
{
fPackStream->Rewind(); // make sure we're at the beginning of the file
fPackNotFound = false;
char* tempFilename = hsWStringToString(files[curName].c_str());
struct stat buf;
time_t curModTime = 0;
if (stat(tempFilename,&buf)==0)
curModTime = buf.st_mtime;
modTimes.push_back(curModTime);
delete [] tempFilename;
// read the index data
int numFiles = fPackStream->ReadSwap32();
UInt32 streamIndex = (UInt32)(fPackStreams.size());
for (int i = 0; i < numFiles; i++)
{
// and pack the index into our own data structure
char* buf = fPackStream->ReadSafeString();
std::string pythonName = buf; // reading a "string" from a hsStream directly into a stl string causes memory loss
delete [] buf;
UInt32 offset = fPackStream->ReadSwap32();
plPackOffsetInfo offsetInfo;
offsetInfo.fOffset = offset;
offsetInfo.fStreamIndex = streamIndex;
if (fFileOffsets.find(pythonName) != fFileOffsets.end())
{
UInt32 index = fFileOffsets[pythonName].fStreamIndex;
if (modTimes[index] < curModTime) // is the existing file older then the new one?
fFileOffsets[pythonName] = offsetInfo; // yup, so replace it with the new info
}
else
fFileOffsets[pythonName] = offsetInfo; // no conflicts, add the info
}
fPackStreams.push_back(fPackStream);
}
}
return !fPackNotFound;
}
void plPythonPack::Close()
{
if (fPackStreams.size() == 0)
return;
int i;
for (i=0; i<fPackStreams.size(); i++)
{
hsStream* fPackStream = fPackStreams[i];
// do NOT close or delete the streams, the preloader will do that for us
fPackStreams[i] = nil;
}
fPackStreams.clear();
fFileOffsets.clear();
}
PyObject* plPythonPack::OpenPacked(const char* fileName)
{
if (!Open())
return nil;
std::string pythonName = fileName;
pythonName += ".py";
FileOffset::iterator it = fFileOffsets.find(pythonName);
if (it != fFileOffsets.end())
{
plPackOffsetInfo offsetInfo = (*it).second;
hsStream* fPackStream = fPackStreams[offsetInfo.fStreamIndex];
fPackStream->SetPosition(offsetInfo.fOffset);
Int32 size = fPackStream->ReadSwap32();
if (size > 0)
{
char *buf = TRACKED_NEW char[size];
UInt32 readSize = fPackStream->Read(size, buf);
hsAssert(readSize <= size, xtl::format("Python PackFile %s: Incorrect amount of data, read %d instead of %d",
fileName, readSize, size).c_str());
// let the python marshal make it back into a code object
PyObject *pythonCode = PyMarshal_ReadObjectFromString(buf, size);
delete [] buf;
return pythonCode;
}
}
return nil;
}
hsBool plPythonPack::IsPackedFile(const char* fileName)
{
if (!Open())
return nil;
std::string pythonName = fileName;
pythonName += ".py";
FileOffset:: iterator it = fFileOffsets.find(pythonName);
if (it != fFileOffsets.end())
return true;
return false;
}

View File

@ -1,38 +1,38 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plPythonPack_h_inc
#define plPythonPack_h_inc
#include "Python.h"
#include "hsTypes.h"
namespace PythonPack
{
PyObject* OpenPythonPacked(const char* fileName);
hsBool IsItPythonPacked(const char* fileName);
}
#endif // plPythonPack_h_inc
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plPythonPack_h_inc
#define plPythonPack_h_inc
#include "Python.h"
#include "hsTypes.h"
namespace PythonPack
{
PyObject* OpenPythonPacked(const char* fileName);
hsBool IsItPythonPacked(const char* fileName);
}
#endif // plPythonPack_h_inc

View File

@ -1,450 +1,450 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plPythonParameter_h_inc
#define plPythonParameter_h_inc
#include "pnKeyedObject/plKey.h"
//
// This is the data for the parameters (or attributes) for the PythonFile components
//
// What is in the records is the id of the attribute and its value
//
// NOTE: Lists of values for parameters will have a specific type that means list
// however, the list of values will not be in one record but many records, with
// the fID being the same.
//
typedef struct plPythonParameter
{
public:
// this is a unique (within one Python mod) id for this parameter
Int32 fID;
// then comes the value, which is a type followed by the data
enum valueType
{
kInt=1,
kFloat,
kBoolean,
kString,
kSceneObject,
kSceneObjectList,
kActivatorList,
kResponderList,
kDynamicText,
kGUIDialog,
kExcludeRegion,
kAnimation,
kAnimationName,
kBehavior,
kMaterial,
kGUIPopUpMenu,
kGUISkin,
kWaterComponent,
kSwimCurrentInterface,
kClusterComponentList,
kMaterialAnimation,
kGrassShaderComponent,
kNone
};
Int32 fValueType; // what type of value (dataType enum)
// the data of the value
union
{
Int32 fIntNumber;
hsScalar fFloatNumber;
hsBool fBool;
char* fString;
} datarecord;
plKey fObjectKey; // the plKey of the scene object (should be part of the union, but unions don't allow complex types)
plPythonParameter()
{
fID = 0;
fValueType = kNone;
}
plPythonParameter(Int32 id)
{
fID = id;
fValueType = kNone;
}
plPythonParameter& operator=(const plPythonParameter& other)
{
return Copy(other);
}
// copy constructor
plPythonParameter(const plPythonParameter& other)
{
fID = 0;
fValueType = kNone;
Copy(other);
}
plPythonParameter& Copy(const plPythonParameter& other)
{
fID = other.fID;
switch ( other.fValueType )
{
case kInt:
SetToInt(other.datarecord.fIntNumber);
break;
case kFloat:
SetToFloat(other.datarecord.fFloatNumber);
break;
case kBoolean:
SetToBoolean(other.datarecord.fBool);
break;
case kString:
SetToString(other.datarecord.fString);
break;
case kSceneObject:
SetToSceneObject(other.fObjectKey);
break;
case kSceneObjectList:
SetToSceneObject(other.fObjectKey,true);
break;
case kActivatorList:
SetToActivator(other.fObjectKey);
break;
case kResponderList:
SetToResponder(other.fObjectKey);
break;
case kDynamicText:
SetToDynamicText(other.fObjectKey);
break;
case kGUIDialog:
SetToGUIDialog(other.fObjectKey);
break;
case kExcludeRegion:
SetToExcludeRegion(other.fObjectKey);
break;
case kAnimation:
SetToAnimation(other.fObjectKey);
break;
case kAnimationName:
SetToAnimationName(other.datarecord.fString);
break;
case kBehavior:
SetToBehavior(other.fObjectKey);
break;
case kMaterial:
SetToMaterial(other.fObjectKey);
break;
case kGUIPopUpMenu:
SetToGUIPopUpMenu(other.fObjectKey);
break;
case kGUISkin:
SetToGUISkin(other.fObjectKey);
break;
case kWaterComponent:
SetToWaterComponent(other.fObjectKey);
break;
case kSwimCurrentInterface:
SetToSwimCurrentInterface(other.fObjectKey);
break;
case kClusterComponentList:
SetToClusterComponent(other.fObjectKey);
break;
case kMaterialAnimation:
SetToMaterialAnimation(other.fObjectKey);
break;
case kGrassShaderComponent:
SetToGrassShaderComponent(other.fObjectKey);
break;
}
return *this;
}
~plPythonParameter()
{
SetToNone();
}
void SetToNone()
{
// remove the string if one was created
if ( fValueType == kString || fValueType == kAnimationName )
delete [] datarecord.fString;
fValueType = kNone;
}
void SetToInt(Int32 number)
{
SetToNone();
fValueType = kInt;
datarecord.fIntNumber = number;
}
void SetToFloat(hsScalar number)
{
SetToNone();
fValueType = kFloat;
datarecord.fFloatNumber = number;
}
void SetToBoolean(hsBool state)
{
SetToNone();
fValueType = kBoolean;
datarecord.fBool = state;
}
void SetToString(const char* string)
{
SetToNone();
fValueType = kString;
datarecord.fString = hsStrcpy(string);
}
void SetToSceneObject(plKey key, hsBool list=false)
{
SetToNone();
if (list)
fValueType = kSceneObjectList;
else
fValueType = kSceneObject;
fObjectKey = key;
}
void SetToActivator(plKey key)
{
SetToNone();
fValueType = kActivatorList;
fObjectKey = key;
}
void SetToResponder(plKey key)
{
SetToNone();
fValueType = kResponderList;
fObjectKey = key;
}
void SetToDynamicText(plKey key)
{
SetToNone();
fValueType = kDynamicText;
fObjectKey = key;
}
void SetToGUIDialog(plKey key)
{
SetToNone();
fValueType = kGUIDialog;
fObjectKey = key;
}
void SetToExcludeRegion(plKey key)
{
SetToNone();
fValueType = kExcludeRegion;
fObjectKey = key;
}
void SetToWaterComponent(plKey key)
{
SetToNone();
fValueType = kWaterComponent;
fObjectKey = key;
}
void SetToSwimCurrentInterface(plKey key)
{
SetToNone();
fValueType = kSwimCurrentInterface;
fObjectKey = key;
}
void SetToAnimation(plKey key)
{
SetToNone();
fValueType = kAnimation;
fObjectKey = key;
}
void SetToAnimationName(const char* string)
{
SetToNone();
fValueType = kAnimationName;
datarecord.fString = hsStrcpy(string);
}
void SetToBehavior(plKey key)
{
SetToNone();
fValueType = kBehavior;
fObjectKey = key;
}
void SetToMaterial(plKey key)
{
SetToNone();
fValueType = kMaterial;
fObjectKey = key;
}
void SetToGUIPopUpMenu(plKey key)
{
SetToNone();
fValueType = kGUIPopUpMenu;
fObjectKey = key;
}
void SetToGUISkin(plKey key)
{
SetToNone();
fValueType = kGUISkin;
fObjectKey = key;
}
void SetToClusterComponent(plKey key)
{
SetToNone();
fValueType = kClusterComponentList;
fObjectKey = key;
}
void SetToMaterialAnimation(plKey key)
{
SetToNone();
fValueType = kMaterialAnimation;
fObjectKey = key;
}
void SetToGrassShaderComponent(plKey key)
{
SetToNone();
fValueType = kGrassShaderComponent;
fObjectKey = key;
}
// read and write routines for export and reading in at runtime
void Read(hsStream *stream, hsResMgr* mgr)
{
SetToNone();
fID = stream->ReadSwap32();
fValueType = stream->ReadSwap32();
// read the different types of data
int count;
switch ( fValueType )
{
case kInt:
datarecord.fIntNumber = stream->ReadSwap32();
break;
case kFloat:
stream->ReadSwap(&datarecord.fFloatNumber);
break;
case kBoolean:
datarecord.fBool = stream->ReadSwap32();
break;
case kString:
case kAnimationName:
count = stream->ReadSwap32();
if ( count != 0 )
{
datarecord.fString = TRACKED_NEW char[count+1];
stream->ReadSwap(count,datarecord.fString);
}
else
datarecord.fString = nil;
break;
case kSceneObject:
case kSceneObjectList:
case kActivatorList:
case kResponderList:
case kDynamicText:
case kGUIDialog:
case kExcludeRegion:
case kAnimation:
case kBehavior:
case kMaterial:
case kGUIPopUpMenu:
case kGUISkin:
case kWaterComponent:
case kSwimCurrentInterface:
case kClusterComponentList:
case kMaterialAnimation:
case kGrassShaderComponent:
fObjectKey = mgr->ReadKey(stream);
break;
}
}
void Write(hsStream * stream, hsResMgr* mgr)
{
int count;
stream->WriteSwap32(fID);
stream->WriteSwap32(fValueType);
switch ( fValueType )
{
case kInt:
stream->WriteSwap32(datarecord.fIntNumber);
break;
case kFloat:
stream->WriteSwap(datarecord.fFloatNumber);
break;
case kBoolean:
stream->WriteSwap32(datarecord.fBool);
break;
case kString:
case kAnimationName:
if ( datarecord.fString != nil )
count = hsStrlen(datarecord.fString)+1;
else
count = 0;
stream->WriteSwap(count);
if ( count != 0 )
stream->WriteSwap(count,datarecord.fString);
break;
case kSceneObject:
case kSceneObjectList:
case kActivatorList:
case kResponderList:
case kDynamicText:
case kGUIDialog:
case kExcludeRegion:
case kAnimation:
case kBehavior:
case kMaterial:
case kGUIPopUpMenu:
case kGUISkin:
case kWaterComponent:
case kSwimCurrentInterface:
case kClusterComponentList:
case kMaterialAnimation:
case kGrassShaderComponent:
mgr->WriteKey(stream, fObjectKey);
break;
}
}
} plPythonParameter;
#endif // plPythonParameter_h_inc
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plPythonParameter_h_inc
#define plPythonParameter_h_inc
#include "pnKeyedObject/plKey.h"
//
// This is the data for the parameters (or attributes) for the PythonFile components
//
// What is in the records is the id of the attribute and its value
//
// NOTE: Lists of values for parameters will have a specific type that means list
// however, the list of values will not be in one record but many records, with
// the fID being the same.
//
typedef struct plPythonParameter
{
public:
// this is a unique (within one Python mod) id for this parameter
Int32 fID;
// then comes the value, which is a type followed by the data
enum valueType
{
kInt=1,
kFloat,
kBoolean,
kString,
kSceneObject,
kSceneObjectList,
kActivatorList,
kResponderList,
kDynamicText,
kGUIDialog,
kExcludeRegion,
kAnimation,
kAnimationName,
kBehavior,
kMaterial,
kGUIPopUpMenu,
kGUISkin,
kWaterComponent,
kSwimCurrentInterface,
kClusterComponentList,
kMaterialAnimation,
kGrassShaderComponent,
kNone
};
Int32 fValueType; // what type of value (dataType enum)
// the data of the value
union
{
Int32 fIntNumber;
hsScalar fFloatNumber;
hsBool fBool;
char* fString;
} datarecord;
plKey fObjectKey; // the plKey of the scene object (should be part of the union, but unions don't allow complex types)
plPythonParameter()
{
fID = 0;
fValueType = kNone;
}
plPythonParameter(Int32 id)
{
fID = id;
fValueType = kNone;
}
plPythonParameter& operator=(const plPythonParameter& other)
{
return Copy(other);
}
// copy constructor
plPythonParameter(const plPythonParameter& other)
{
fID = 0;
fValueType = kNone;
Copy(other);
}
plPythonParameter& Copy(const plPythonParameter& other)
{
fID = other.fID;
switch ( other.fValueType )
{
case kInt:
SetToInt(other.datarecord.fIntNumber);
break;
case kFloat:
SetToFloat(other.datarecord.fFloatNumber);
break;
case kBoolean:
SetToBoolean(other.datarecord.fBool);
break;
case kString:
SetToString(other.datarecord.fString);
break;
case kSceneObject:
SetToSceneObject(other.fObjectKey);
break;
case kSceneObjectList:
SetToSceneObject(other.fObjectKey,true);
break;
case kActivatorList:
SetToActivator(other.fObjectKey);
break;
case kResponderList:
SetToResponder(other.fObjectKey);
break;
case kDynamicText:
SetToDynamicText(other.fObjectKey);
break;
case kGUIDialog:
SetToGUIDialog(other.fObjectKey);
break;
case kExcludeRegion:
SetToExcludeRegion(other.fObjectKey);
break;
case kAnimation:
SetToAnimation(other.fObjectKey);
break;
case kAnimationName:
SetToAnimationName(other.datarecord.fString);
break;
case kBehavior:
SetToBehavior(other.fObjectKey);
break;
case kMaterial:
SetToMaterial(other.fObjectKey);
break;
case kGUIPopUpMenu:
SetToGUIPopUpMenu(other.fObjectKey);
break;
case kGUISkin:
SetToGUISkin(other.fObjectKey);
break;
case kWaterComponent:
SetToWaterComponent(other.fObjectKey);
break;
case kSwimCurrentInterface:
SetToSwimCurrentInterface(other.fObjectKey);
break;
case kClusterComponentList:
SetToClusterComponent(other.fObjectKey);
break;
case kMaterialAnimation:
SetToMaterialAnimation(other.fObjectKey);
break;
case kGrassShaderComponent:
SetToGrassShaderComponent(other.fObjectKey);
break;
}
return *this;
}
~plPythonParameter()
{
SetToNone();
}
void SetToNone()
{
// remove the string if one was created
if ( fValueType == kString || fValueType == kAnimationName )
delete [] datarecord.fString;
fValueType = kNone;
}
void SetToInt(Int32 number)
{
SetToNone();
fValueType = kInt;
datarecord.fIntNumber = number;
}
void SetToFloat(hsScalar number)
{
SetToNone();
fValueType = kFloat;
datarecord.fFloatNumber = number;
}
void SetToBoolean(hsBool state)
{
SetToNone();
fValueType = kBoolean;
datarecord.fBool = state;
}
void SetToString(const char* string)
{
SetToNone();
fValueType = kString;
datarecord.fString = hsStrcpy(string);
}
void SetToSceneObject(plKey key, hsBool list=false)
{
SetToNone();
if (list)
fValueType = kSceneObjectList;
else
fValueType = kSceneObject;
fObjectKey = key;
}
void SetToActivator(plKey key)
{
SetToNone();
fValueType = kActivatorList;
fObjectKey = key;
}
void SetToResponder(plKey key)
{
SetToNone();
fValueType = kResponderList;
fObjectKey = key;
}
void SetToDynamicText(plKey key)
{
SetToNone();
fValueType = kDynamicText;
fObjectKey = key;
}
void SetToGUIDialog(plKey key)
{
SetToNone();
fValueType = kGUIDialog;
fObjectKey = key;
}
void SetToExcludeRegion(plKey key)
{
SetToNone();
fValueType = kExcludeRegion;
fObjectKey = key;
}
void SetToWaterComponent(plKey key)
{
SetToNone();
fValueType = kWaterComponent;
fObjectKey = key;
}
void SetToSwimCurrentInterface(plKey key)
{
SetToNone();
fValueType = kSwimCurrentInterface;
fObjectKey = key;
}
void SetToAnimation(plKey key)
{
SetToNone();
fValueType = kAnimation;
fObjectKey = key;
}
void SetToAnimationName(const char* string)
{
SetToNone();
fValueType = kAnimationName;
datarecord.fString = hsStrcpy(string);
}
void SetToBehavior(plKey key)
{
SetToNone();
fValueType = kBehavior;
fObjectKey = key;
}
void SetToMaterial(plKey key)
{
SetToNone();
fValueType = kMaterial;
fObjectKey = key;
}
void SetToGUIPopUpMenu(plKey key)
{
SetToNone();
fValueType = kGUIPopUpMenu;
fObjectKey = key;
}
void SetToGUISkin(plKey key)
{
SetToNone();
fValueType = kGUISkin;
fObjectKey = key;
}
void SetToClusterComponent(plKey key)
{
SetToNone();
fValueType = kClusterComponentList;
fObjectKey = key;
}
void SetToMaterialAnimation(plKey key)
{
SetToNone();
fValueType = kMaterialAnimation;
fObjectKey = key;
}
void SetToGrassShaderComponent(plKey key)
{
SetToNone();
fValueType = kGrassShaderComponent;
fObjectKey = key;
}
// read and write routines for export and reading in at runtime
void Read(hsStream *stream, hsResMgr* mgr)
{
SetToNone();
fID = stream->ReadSwap32();
fValueType = stream->ReadSwap32();
// read the different types of data
int count;
switch ( fValueType )
{
case kInt:
datarecord.fIntNumber = stream->ReadSwap32();
break;
case kFloat:
stream->ReadSwap(&datarecord.fFloatNumber);
break;
case kBoolean:
datarecord.fBool = stream->ReadSwap32();
break;
case kString:
case kAnimationName:
count = stream->ReadSwap32();
if ( count != 0 )
{
datarecord.fString = TRACKED_NEW char[count+1];
stream->ReadSwap(count,datarecord.fString);
}
else
datarecord.fString = nil;
break;
case kSceneObject:
case kSceneObjectList:
case kActivatorList:
case kResponderList:
case kDynamicText:
case kGUIDialog:
case kExcludeRegion:
case kAnimation:
case kBehavior:
case kMaterial:
case kGUIPopUpMenu:
case kGUISkin:
case kWaterComponent:
case kSwimCurrentInterface:
case kClusterComponentList:
case kMaterialAnimation:
case kGrassShaderComponent:
fObjectKey = mgr->ReadKey(stream);
break;
}
}
void Write(hsStream * stream, hsResMgr* mgr)
{
int count;
stream->WriteSwap32(fID);
stream->WriteSwap32(fValueType);
switch ( fValueType )
{
case kInt:
stream->WriteSwap32(datarecord.fIntNumber);
break;
case kFloat:
stream->WriteSwap(datarecord.fFloatNumber);
break;
case kBoolean:
stream->WriteSwap32(datarecord.fBool);
break;
case kString:
case kAnimationName:
if ( datarecord.fString != nil )
count = hsStrlen(datarecord.fString)+1;
else
count = 0;
stream->WriteSwap(count);
if ( count != 0 )
stream->WriteSwap(count,datarecord.fString);
break;
case kSceneObject:
case kSceneObjectList:
case kActivatorList:
case kResponderList:
case kDynamicText:
case kGUIDialog:
case kExcludeRegion:
case kAnimation:
case kBehavior:
case kMaterial:
case kGUIPopUpMenu:
case kGUISkin:
case kWaterComponent:
case kSwimCurrentInterface:
case kClusterComponentList:
case kMaterialAnimation:
case kGrassShaderComponent:
mgr->WriteKey(stream, fObjectKey);
break;
}
}
} plPythonParameter;
#endif // plPythonParameter_h_inc

File diff suppressed because it is too large Load Diff

View File

@ -1,141 +1,141 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plPythonSDLModifier_h_inc
#define plPythonSDLModifier_h_inc
class plPythonFileMod;
class plStateDataRecord;
class plSimpleStateVariable;
#include "hsStlUtils.h"
#include "plModifier/plSDLModifier.h"
#include <python.h>
#include "pyGlueHelpers.h"
// hack for plNetClientVNodeMgr single-player mode SDLHook stuff.
plStateDataRecord * GetAgeSDL();
class pyKey;
//
// The fields of a SDL record in Python format.
// If the Python code changes a value an update is sent automatically
//
class plPythonSDLModifier : public plSDLModifier
{
protected:
class SDLObj
{
public:
PyObject* obj;
int size; // 0 for resizable
bool sendToClients;
bool skipLocalCheck;
bool sendImmediate;
std::string hintString;
SDLObj() : obj(nil), size(-1), sendToClients(false) {}
SDLObj(PyObject* obj, int size, bool sendToClients) : obj(obj), size(size), sendToClients(sendToClients) {}
};
typedef std::map<std::string, SDLObj> SDLMap;
SDLMap fMap;
plPythonFileMod* fOwner;
plPythonSDLModifier() {}
PyObject* ISDLVarToPython(plSimpleStateVariable* var);
PyObject* ISDLVarIdxToPython(plSimpleStateVariable* var, int type, int idx);
void IPythonVarToSDL(plStateDataRecord* state, const char* name);
bool IPythonVarIdxToSDL(plSimpleStateVariable* var, int varIdx, int type, PyObject* pyVar, const char* hintstring);
void ISetItem(const char* key, PyObject* value);
void IDirtySynchState(const char* name, hsBool sendImmediate = false);
void IPutCurrentStateIn(plStateDataRecord* dstState);
void ISetCurrentStateFrom(const plStateDataRecord* srcState);
public:
plPythonSDLModifier(plPythonFileMod* owner);
~plPythonSDLModifier();
CLASSNAME_REGISTER(plPythonSDLModifier);
GETINTERFACE_ANY(plPythonSDLModifier, plSDLModifier);
virtual const char* GetSDLName() const;
virtual void SetItemFromSDLVar(plSimpleStateVariable* var);
static bool HasSDL(const char* pythonFile);
// find the Age global SDL guy... if there is one
static const plPythonSDLModifier* FindAgeSDL();
static plKey FindAgeSDLTarget();
void SetDefault(const char* key, PyObject* value);
void SendToClients(const char* key);
void SetNotify(pyKey& selfkey, const char* key, float tolerance);
PyObject* GetItem(const char* key);
void SetItem(const char* key, PyObject* value);
void SetItemIdx(const char* key, int idx, PyObject* value, hsBool sendImmediate = false);
void SetFlags(const char* name, bool sendImmediate, bool skipOwnershipCheck);
void SetTagString(const char* name, const char* tag);
};
// A wrapper for plPythonSDLModifier that Python uses
class pySDLModifier
{
protected:
plPythonSDLModifier* fRecord;
pySDLModifier(plPythonSDLModifier* sdlMod);
pySDLModifier() {}
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptSDL);
PYTHON_CLASS_NEW_DEFINITION;
static PyObject *New(plPythonSDLModifier *sdlMod);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pySDLModifier object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pySDLModifier); // converts a PyObject to a pySDLModifier (throws error if not correct type)
static void AddPlasmaClasses(PyObject *m);
static void AddPlasmaMethods(std::vector<PyMethodDef> &methods);
// global function to get the GrandMaster Age SDL object
static PyObject* GetAgeSDL();
static void SetDefault(pySDLModifier& self, std::string key, PyObject* value);
static void SendToClients(pySDLModifier& self, std::string key);
static void SetNotify(pySDLModifier& self, pyKey& selfkey, std::string key, float tolerance);
static PyObject* GetItem(pySDLModifier& self, std::string key);
static void SetItem(pySDLModifier& self, std::string key, PyObject* value);
static void SetItemIdx(pySDLModifier& self, std::string key, int idx, PyObject* value);
static void SetItemIdxImmediate(pySDLModifier& self, std::string key, int idx, PyObject* value);
static void SetFlags(pySDLModifier& self, const char* name, bool sendImmediate, bool skipOwnershipCheck);
static void SetTagString(pySDLModifier& self, const char* name, const char* tag);
};
#endif // plPythonSDLModifier_h_inc
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef plPythonSDLModifier_h_inc
#define plPythonSDLModifier_h_inc
class plPythonFileMod;
class plStateDataRecord;
class plSimpleStateVariable;
#include "hsStlUtils.h"
#include "plModifier/plSDLModifier.h"
#include <python.h>
#include "pyGlueHelpers.h"
// hack for plNetClientVNodeMgr single-player mode SDLHook stuff.
plStateDataRecord * GetAgeSDL();
class pyKey;
//
// The fields of a SDL record in Python format.
// If the Python code changes a value an update is sent automatically
//
class plPythonSDLModifier : public plSDLModifier
{
protected:
class SDLObj
{
public:
PyObject* obj;
int size; // 0 for resizable
bool sendToClients;
bool skipLocalCheck;
bool sendImmediate;
std::string hintString;
SDLObj() : obj(nil), size(-1), sendToClients(false) {}
SDLObj(PyObject* obj, int size, bool sendToClients) : obj(obj), size(size), sendToClients(sendToClients) {}
};
typedef std::map<std::string, SDLObj> SDLMap;
SDLMap fMap;
plPythonFileMod* fOwner;
plPythonSDLModifier() {}
PyObject* ISDLVarToPython(plSimpleStateVariable* var);
PyObject* ISDLVarIdxToPython(plSimpleStateVariable* var, int type, int idx);
void IPythonVarToSDL(plStateDataRecord* state, const char* name);
bool IPythonVarIdxToSDL(plSimpleStateVariable* var, int varIdx, int type, PyObject* pyVar, const char* hintstring);
void ISetItem(const char* key, PyObject* value);
void IDirtySynchState(const char* name, hsBool sendImmediate = false);
void IPutCurrentStateIn(plStateDataRecord* dstState);
void ISetCurrentStateFrom(const plStateDataRecord* srcState);
public:
plPythonSDLModifier(plPythonFileMod* owner);
~plPythonSDLModifier();
CLASSNAME_REGISTER(plPythonSDLModifier);
GETINTERFACE_ANY(plPythonSDLModifier, plSDLModifier);
virtual const char* GetSDLName() const;
virtual void SetItemFromSDLVar(plSimpleStateVariable* var);
static bool HasSDL(const char* pythonFile);
// find the Age global SDL guy... if there is one
static const plPythonSDLModifier* FindAgeSDL();
static plKey FindAgeSDLTarget();
void SetDefault(const char* key, PyObject* value);
void SendToClients(const char* key);
void SetNotify(pyKey& selfkey, const char* key, float tolerance);
PyObject* GetItem(const char* key);
void SetItem(const char* key, PyObject* value);
void SetItemIdx(const char* key, int idx, PyObject* value, hsBool sendImmediate = false);
void SetFlags(const char* name, bool sendImmediate, bool skipOwnershipCheck);
void SetTagString(const char* name, const char* tag);
};
// A wrapper for plPythonSDLModifier that Python uses
class pySDLModifier
{
protected:
plPythonSDLModifier* fRecord;
pySDLModifier(plPythonSDLModifier* sdlMod);
pySDLModifier() {}
public:
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptSDL);
PYTHON_CLASS_NEW_DEFINITION;
static PyObject *New(plPythonSDLModifier *sdlMod);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pySDLModifier object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pySDLModifier); // converts a PyObject to a pySDLModifier (throws error if not correct type)
static void AddPlasmaClasses(PyObject *m);
static void AddPlasmaMethods(std::vector<PyMethodDef> &methods);
// global function to get the GrandMaster Age SDL object
static PyObject* GetAgeSDL();
static void SetDefault(pySDLModifier& self, std::string key, PyObject* value);
static void SendToClients(pySDLModifier& self, std::string key);
static void SetNotify(pySDLModifier& self, pyKey& selfkey, std::string key, float tolerance);
static PyObject* GetItem(pySDLModifier& self, std::string key);
static void SetItem(pySDLModifier& self, std::string key, PyObject* value);
static void SetItemIdx(pySDLModifier& self, std::string key, int idx, PyObject* value);
static void SetItemIdxImmediate(pySDLModifier& self, std::string key, int idx, PyObject* value);
static void SetFlags(pySDLModifier& self, const char* name, bool sendImmediate, bool skipOwnershipCheck);
static void SetTagString(pySDLModifier& self, const char* name, const char* tag);
};
#endif // plPythonSDLModifier_h_inc

View File

@ -1,243 +1,243 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "plPythonSDLModifier.h"
#include "pyKey.h"
#include <python.h>
// glue functions
PYTHON_CLASS_DEFINITION(ptSDL, pySDLModifier);
PYTHON_DEFAULT_NEW_DEFINITION(ptSDL, pySDLModifier)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptSDL)
PYTHON_INIT_DEFINITION(ptSDL, args, keywords)
{
PYTHON_RETURN_INIT_OK;
}
PYTHON_METHOD_DEFINITION(ptSDL, setIndex, args)
{
char* key;
int idx;
PyObject* value = NULL;
if (!PyArg_ParseTuple(args, "siO", &key, &idx, &value))
{
PyErr_SetString(PyExc_TypeError, "setIndex expects a string, int, and an object");
PYTHON_RETURN_ERROR;
}
pySDLModifier::SetItemIdx(*(self->fThis), key, idx, value);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptSDL, setIndexNow, args)
{
char* key;
int idx;
PyObject* value = NULL;
if (!PyArg_ParseTuple(args, "siO", &key, &idx, &value))
{
PyErr_SetString(PyExc_TypeError, "setIndexNow expects a string, int, and an object");
PYTHON_RETURN_ERROR;
}
pySDLModifier::SetItemIdxImmediate(*(self->fThis), key, idx, value);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptSDL, setDefault, args)
{
char* key;
PyObject* value = NULL;
if (!PyArg_ParseTuple(args, "sO", &key, &value))
{
PyErr_SetString(PyExc_TypeError, "setDefault expects a string and a tuple");
PYTHON_RETURN_ERROR;
}
if (!PyTuple_Check(value))
{
PyErr_SetString(PyExc_TypeError, "setDefault expects a string and a tuple");
PYTHON_RETURN_ERROR;
}
pySDLModifier::SetDefault(*(self->fThis), key, value);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptSDL, sendToClients, args)
{
char* key;
if (!PyArg_ParseTuple(args, "s", &key))
{
PyErr_SetString(PyExc_TypeError, "sendToClients expects a string");
PYTHON_RETURN_ERROR;
}
pySDLModifier::SendToClients(*(self->fThis), key);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptSDL, setNotify, args)
{
PyObject* selfKeyObj;
char* key;
float tolerance;
if (!PyArg_ParseTuple(args, "Osf", &selfKeyObj, &key, &tolerance))
{
PyErr_SetString(PyExc_TypeError, "setNotify expects a ptKey, string, and float");
PYTHON_RETURN_ERROR;
}
if (!pyKey::Check(selfKeyObj))
{
PyErr_SetString(PyExc_TypeError, "setNotify expects a ptKey, string, and float");
PYTHON_RETURN_ERROR;
}
pyKey* selfKey = pyKey::ConvertFrom(selfKeyObj);
pySDLModifier::SetNotify(*(self->fThis), *selfKey, key, tolerance);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptSDL, setFlags, args)
{
char* key;
char sendImmediate, skipOwnershipCheck;
if (!PyArg_ParseTuple(args, "sbb", &key, &sendImmediate, &skipOwnershipCheck))
{
PyErr_SetString(PyExc_TypeError, "setFlags expects a string and two booleans");
PYTHON_RETURN_ERROR;
}
pySDLModifier::SetFlags(*(self->fThis), key, sendImmediate != 0, skipOwnershipCheck != 0);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptSDL, setTagString, args)
{
char* key;
char* tag;
if (!PyArg_ParseTuple(args, "ss", &key, &tag))
{
PyErr_SetString(PyExc_TypeError, "setTagString expects two strings");
PYTHON_RETURN_ERROR;
}
pySDLModifier::SetTagString(*(self->fThis), key, tag);
PYTHON_RETURN_NONE;
}
PYTHON_START_METHODS_TABLE(ptSDL)
PYTHON_METHOD(ptSDL, setIndex, "Params: key,idx,value\nSets the value at a specific index in the tuple,\n"
"so you don't have to pass the whole thing in"),
PYTHON_METHOD(ptSDL, setIndexNow, "Params: key,idx,value\nSame as setIndex but sends immediately"),
PYTHON_METHOD(ptSDL, setDefault, "Params: key,value\nLike setitem, but doesn't broadcast over the net.\n"
"Only use for setting defaults that everyone will\n"
"already know (from reading it off disk)"),
PYTHON_METHOD(ptSDL, sendToClients, "Params: key\nSets it so changes to this key are sent to the\n"
"server AND the clients. (Normally it just goes\n"
"to the server.)"),
PYTHON_METHOD(ptSDL, setNotify, "Params: selfkey,key,tolerance\nSets the OnSDLNotify to be called when 'key'\n"
"SDL variable changes by 'tolerance' (if number)"),
PYTHON_METHOD(ptSDL, setFlags, "Params: name,sendImmediate,skipOwnershipCheck\nSets the flags for a variable in this SDL"),
PYTHON_METHOD(ptSDL, setTagString, "Params: name,tag\nSets the tag string for a variable"),
PYTHON_END_METHODS_TABLE;
PyObject* ptSDL_subscript(ptSDL* self, PyObject* key)
{
if (!PyString_Check(key))
{
PyErr_SetString(PyExc_TypeError, "SDL indexes must be strings");
PYTHON_RETURN_ERROR;
}
char *keyStr = PyString_AsString(key);
return pySDLModifier::GetItem(*(self->fThis), keyStr);
}
int ptSDL_ass_subscript(ptSDL* self, PyObject* key, PyObject* value)
{
if (value == NULL) // remove, which isn't supported
{
PyErr_SetString(PyExc_RuntimeError, "Cannot remove sdl records");
return -1; // error return
}
if (!PyString_Check(key))
{
PyErr_SetString(PyExc_TypeError, "SDL indexes must be strings");
return -1; // error return
}
if (!PyTuple_Check(value))
{
PyErr_SetString(PyExc_TypeError, "SDL values must be tuples");
return -1; // error return
}
char* keyStr = PyString_AsString(key);
pySDLModifier::SetItem(*(self->fThis), keyStr, value);
return 0; // success return
}
PYTHON_START_AS_MAPPING_TABLE(ptSDL)
0, /* mp_length */
(binaryfunc)ptSDL_subscript, /* mp_subscript */
(objobjargproc)ptSDL_ass_subscript, /* mp_ass_subscript */
PYTHON_END_AS_MAPPING_TABLE;
#define ptSDL_COMPARE PYTHON_NO_COMPARE
#define ptSDL_AS_NUMBER PYTHON_NO_AS_NUMBER
#define ptSDL_AS_SEQUENCE PYTHON_NO_AS_SEQUENCE
#define ptSDL_AS_MAPPING PYTHON_DEFAULT_AS_MAPPING(ptSDL)
#define ptSDL_STR PYTHON_NO_STR
#define ptSDL_RICH_COMPARE PYTHON_NO_RICH_COMPARE
#define ptSDL_GETSET PYTHON_NO_GETSET
#define ptSDL_BASE PYTHON_NO_BASE
PLASMA_CUSTOM_TYPE(ptSDL, "SDL accessor");
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_IMPL(ptSDL, pySDLModifier)
PyObject *pySDLModifier::New(plPythonSDLModifier *sdlMod)
{
ptSDL *newObj = (ptSDL*)ptSDL_type.tp_new(&ptSDL_type, NULL, NULL);
newObj->fThis->fRecord = sdlMod;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptSDL, pySDLModifier)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptSDL, pySDLModifier)
///////////////////////////////////////////////////////////////////////////
//
// AddPlasmaClasses - the python module definitions
//
void pySDLModifier::AddPlasmaClasses(PyObject *m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptSDL);
PYTHON_CLASS_IMPORT_END(m);
}
PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetAgeSDL, "Returns the global ptSDL for the current Age")
{
return pySDLModifier::GetAgeSDL();
}
void pySDLModifier::AddPlasmaMethods(std::vector<PyMethodDef> &methods)
{
PYTHON_GLOBAL_METHOD_NOARGS(methods, PtGetAgeSDL);
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "plPythonSDLModifier.h"
#include "pyKey.h"
#include <python.h>
// glue functions
PYTHON_CLASS_DEFINITION(ptSDL, pySDLModifier);
PYTHON_DEFAULT_NEW_DEFINITION(ptSDL, pySDLModifier)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptSDL)
PYTHON_INIT_DEFINITION(ptSDL, args, keywords)
{
PYTHON_RETURN_INIT_OK;
}
PYTHON_METHOD_DEFINITION(ptSDL, setIndex, args)
{
char* key;
int idx;
PyObject* value = NULL;
if (!PyArg_ParseTuple(args, "siO", &key, &idx, &value))
{
PyErr_SetString(PyExc_TypeError, "setIndex expects a string, int, and an object");
PYTHON_RETURN_ERROR;
}
pySDLModifier::SetItemIdx(*(self->fThis), key, idx, value);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptSDL, setIndexNow, args)
{
char* key;
int idx;
PyObject* value = NULL;
if (!PyArg_ParseTuple(args, "siO", &key, &idx, &value))
{
PyErr_SetString(PyExc_TypeError, "setIndexNow expects a string, int, and an object");
PYTHON_RETURN_ERROR;
}
pySDLModifier::SetItemIdxImmediate(*(self->fThis), key, idx, value);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptSDL, setDefault, args)
{
char* key;
PyObject* value = NULL;
if (!PyArg_ParseTuple(args, "sO", &key, &value))
{
PyErr_SetString(PyExc_TypeError, "setDefault expects a string and a tuple");
PYTHON_RETURN_ERROR;
}
if (!PyTuple_Check(value))
{
PyErr_SetString(PyExc_TypeError, "setDefault expects a string and a tuple");
PYTHON_RETURN_ERROR;
}
pySDLModifier::SetDefault(*(self->fThis), key, value);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptSDL, sendToClients, args)
{
char* key;
if (!PyArg_ParseTuple(args, "s", &key))
{
PyErr_SetString(PyExc_TypeError, "sendToClients expects a string");
PYTHON_RETURN_ERROR;
}
pySDLModifier::SendToClients(*(self->fThis), key);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptSDL, setNotify, args)
{
PyObject* selfKeyObj;
char* key;
float tolerance;
if (!PyArg_ParseTuple(args, "Osf", &selfKeyObj, &key, &tolerance))
{
PyErr_SetString(PyExc_TypeError, "setNotify expects a ptKey, string, and float");
PYTHON_RETURN_ERROR;
}
if (!pyKey::Check(selfKeyObj))
{
PyErr_SetString(PyExc_TypeError, "setNotify expects a ptKey, string, and float");
PYTHON_RETURN_ERROR;
}
pyKey* selfKey = pyKey::ConvertFrom(selfKeyObj);
pySDLModifier::SetNotify(*(self->fThis), *selfKey, key, tolerance);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptSDL, setFlags, args)
{
char* key;
char sendImmediate, skipOwnershipCheck;
if (!PyArg_ParseTuple(args, "sbb", &key, &sendImmediate, &skipOwnershipCheck))
{
PyErr_SetString(PyExc_TypeError, "setFlags expects a string and two booleans");
PYTHON_RETURN_ERROR;
}
pySDLModifier::SetFlags(*(self->fThis), key, sendImmediate != 0, skipOwnershipCheck != 0);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptSDL, setTagString, args)
{
char* key;
char* tag;
if (!PyArg_ParseTuple(args, "ss", &key, &tag))
{
PyErr_SetString(PyExc_TypeError, "setTagString expects two strings");
PYTHON_RETURN_ERROR;
}
pySDLModifier::SetTagString(*(self->fThis), key, tag);
PYTHON_RETURN_NONE;
}
PYTHON_START_METHODS_TABLE(ptSDL)
PYTHON_METHOD(ptSDL, setIndex, "Params: key,idx,value\nSets the value at a specific index in the tuple,\n"
"so you don't have to pass the whole thing in"),
PYTHON_METHOD(ptSDL, setIndexNow, "Params: key,idx,value\nSame as setIndex but sends immediately"),
PYTHON_METHOD(ptSDL, setDefault, "Params: key,value\nLike setitem, but doesn't broadcast over the net.\n"
"Only use for setting defaults that everyone will\n"
"already know (from reading it off disk)"),
PYTHON_METHOD(ptSDL, sendToClients, "Params: key\nSets it so changes to this key are sent to the\n"
"server AND the clients. (Normally it just goes\n"
"to the server.)"),
PYTHON_METHOD(ptSDL, setNotify, "Params: selfkey,key,tolerance\nSets the OnSDLNotify to be called when 'key'\n"
"SDL variable changes by 'tolerance' (if number)"),
PYTHON_METHOD(ptSDL, setFlags, "Params: name,sendImmediate,skipOwnershipCheck\nSets the flags for a variable in this SDL"),
PYTHON_METHOD(ptSDL, setTagString, "Params: name,tag\nSets the tag string for a variable"),
PYTHON_END_METHODS_TABLE;
PyObject* ptSDL_subscript(ptSDL* self, PyObject* key)
{
if (!PyString_Check(key))
{
PyErr_SetString(PyExc_TypeError, "SDL indexes must be strings");
PYTHON_RETURN_ERROR;
}
char *keyStr = PyString_AsString(key);
return pySDLModifier::GetItem(*(self->fThis), keyStr);
}
int ptSDL_ass_subscript(ptSDL* self, PyObject* key, PyObject* value)
{
if (value == NULL) // remove, which isn't supported
{
PyErr_SetString(PyExc_RuntimeError, "Cannot remove sdl records");
return -1; // error return
}
if (!PyString_Check(key))
{
PyErr_SetString(PyExc_TypeError, "SDL indexes must be strings");
return -1; // error return
}
if (!PyTuple_Check(value))
{
PyErr_SetString(PyExc_TypeError, "SDL values must be tuples");
return -1; // error return
}
char* keyStr = PyString_AsString(key);
pySDLModifier::SetItem(*(self->fThis), keyStr, value);
return 0; // success return
}
PYTHON_START_AS_MAPPING_TABLE(ptSDL)
0, /* mp_length */
(binaryfunc)ptSDL_subscript, /* mp_subscript */
(objobjargproc)ptSDL_ass_subscript, /* mp_ass_subscript */
PYTHON_END_AS_MAPPING_TABLE;
#define ptSDL_COMPARE PYTHON_NO_COMPARE
#define ptSDL_AS_NUMBER PYTHON_NO_AS_NUMBER
#define ptSDL_AS_SEQUENCE PYTHON_NO_AS_SEQUENCE
#define ptSDL_AS_MAPPING PYTHON_DEFAULT_AS_MAPPING(ptSDL)
#define ptSDL_STR PYTHON_NO_STR
#define ptSDL_RICH_COMPARE PYTHON_NO_RICH_COMPARE
#define ptSDL_GETSET PYTHON_NO_GETSET
#define ptSDL_BASE PYTHON_NO_BASE
PLASMA_CUSTOM_TYPE(ptSDL, "SDL accessor");
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_IMPL(ptSDL, pySDLModifier)
PyObject *pySDLModifier::New(plPythonSDLModifier *sdlMod)
{
ptSDL *newObj = (ptSDL*)ptSDL_type.tp_new(&ptSDL_type, NULL, NULL);
newObj->fThis->fRecord = sdlMod;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptSDL, pySDLModifier)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptSDL, pySDLModifier)
///////////////////////////////////////////////////////////////////////////
//
// AddPlasmaClasses - the python module definitions
//
void pySDLModifier::AddPlasmaClasses(PyObject *m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptSDL);
PYTHON_CLASS_IMPORT_END(m);
}
PYTHON_GLOBAL_METHOD_DEFINITION_NOARGS(PtGetAgeSDL, "Returns the global ptSDL for the current Age")
{
return pySDLModifier::GetAgeSDL();
}
void pySDLModifier::AddPlasmaMethods(std::vector<PyMethodDef> &methods)
{
PYTHON_GLOBAL_METHOD_NOARGS(methods, PtGetAgeSDL);
}

View File

@ -1,217 +1,217 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "hsStlUtils.h"
#include "pyAgeInfoStruct.h"
///////////////////////////////////////////////////////////////////////////
pyAgeInfoStruct::pyAgeInfoStruct()
{
}
pyAgeInfoStruct::pyAgeInfoStruct(plAgeInfoStruct * info)
{
fAgeInfo.CopyFrom( info );
}
pyAgeInfoStruct::~pyAgeInfoStruct()
{
}
bool pyAgeInfoStruct::operator==(const pyAgeInfoStruct &other) const
{
return fAgeInfo.IsEqualTo( other.GetAgeInfo() );
}
/////////////////////////////////////////////////////////////////////
void pyAgeInfoStruct::CopyFrom( const pyAgeInfoStruct & other )
{
fAgeInfo.CopyFrom( other.GetAgeInfo() );
}
void pyAgeInfoStruct::CopyFromRef( const pyAgeInfoStructRef & other )
{
fAgeInfo.CopyFrom( other.GetAgeInfo() );
}
const char * pyAgeInfoStruct::GetAgeFilename() const
{
return fAgeInfo.GetAgeFilename();
}
void pyAgeInfoStruct::SetAgeFilename( const char * v )
{
fAgeInfo.SetAgeFilename( v );
}
const char * pyAgeInfoStruct::GetAgeInstanceName() const
{
return fAgeInfo.GetAgeInstanceName();
}
void pyAgeInfoStruct::SetAgeInstanceName( const char * v )
{
fAgeInfo.SetAgeInstanceName( v );
}
const char * pyAgeInfoStruct::GetAgeUserDefinedName() const
{
return fAgeInfo.GetAgeUserDefinedName();
}
void pyAgeInfoStruct::SetAgeUserDefinedName( const char * v )
{
fAgeInfo.SetAgeUserDefinedName( v );
}
const char * pyAgeInfoStruct::GetAgeDescription() const
{
return fAgeInfo.GetAgeDescription();
}
void pyAgeInfoStruct::SetAgeDescription( const char * v )
{
fAgeInfo.SetAgeDescription( v );
}
const char * pyAgeInfoStruct::GetAgeInstanceGuid() const
{
fAgeInstanceGuidStr = fAgeInfo.GetAgeInstanceGuid()->AsStdString();
return fAgeInstanceGuidStr.c_str();
}
void pyAgeInfoStruct::SetAgeInstanceGuid( const char * guid )
{
fAgeInfo.SetAgeInstanceGuid( &plUUID( guid ) );
}
Int32 pyAgeInfoStruct::GetAgeSequenceNumber() const
{
return fAgeInfo.GetAgeSequenceNumber();
}
void pyAgeInfoStruct::SetAgeSequenceNumber( Int32 v )
{
fAgeInfo.SetAgeSequenceNumber( v );
}
Int32 pyAgeInfoStruct::GetAgeLanguage() const
{
return fAgeInfo.GetAgeLanguage();
}
void pyAgeInfoStruct::SetAgeLanguage( Int32 v )
{
fAgeInfo.SetAgeLanguage( v );
}
const char * pyAgeInfoStruct::GetDisplayName() const
{
Int32 seq = GetAgeSequenceNumber();
if ( seq>0 )
xtl::format( fDisplayName, "%s (%d) %s", GetAgeUserDefinedName(), seq, GetAgeInstanceName() );
else
xtl::format( fDisplayName, "%s %s", GetAgeUserDefinedName(), GetAgeInstanceName() );
return fDisplayName.c_str();
}
/////////////////////////////////////////////////////////////////////
plAgeInfoStruct pyAgeInfoStructRef::fDefaultAgeInfo; // created so a default constructor could be made for python. Do NOT use
void pyAgeInfoStructRef::CopyFrom( const pyAgeInfoStruct & other )
{
fAgeInfo.CopyFrom( other.GetAgeInfo() );
}
void pyAgeInfoStructRef::CopyFromRef( const pyAgeInfoStructRef & other )
{
fAgeInfo.CopyFrom( other.GetAgeInfo() );
}
const char * pyAgeInfoStructRef::GetAgeFilename() const
{
return fAgeInfo.GetAgeFilename();
}
void pyAgeInfoStructRef::SetAgeFilename( const char * v )
{
fAgeInfo.SetAgeFilename( v );
}
const char * pyAgeInfoStructRef::GetAgeInstanceName() const
{
return fAgeInfo.GetAgeInstanceName();
}
void pyAgeInfoStructRef::SetAgeInstanceName( const char * v )
{
fAgeInfo.SetAgeInstanceName( v );
}
const char * pyAgeInfoStructRef::GetAgeUserDefinedName() const
{
return fAgeInfo.GetAgeUserDefinedName();
}
void pyAgeInfoStructRef::SetAgeUserDefinedName( const char * v )
{
fAgeInfo.SetAgeUserDefinedName( v );
}
const char * pyAgeInfoStructRef::GetAgeInstanceGuid() const
{
fAgeInstanceGuidStr = fAgeInfo.GetAgeInstanceGuid()->AsStdString();
return fAgeInstanceGuidStr.c_str();
}
void pyAgeInfoStructRef::SetAgeInstanceGuid( const char * guid )
{
fAgeInfo.SetAgeInstanceGuid( &plUUID( guid ) );
}
Int32 pyAgeInfoStructRef::GetAgeSequenceNumber() const
{
return fAgeInfo.GetAgeSequenceNumber();
}
void pyAgeInfoStructRef::SetAgeSequenceNumber( Int32 v )
{
fAgeInfo.SetAgeSequenceNumber( v );
}
const char * pyAgeInfoStructRef::GetDisplayName() const
{
Int32 seq = GetAgeSequenceNumber();
if ( seq>0 )
xtl::format( fDisplayName, "%s (%d) %s", GetAgeUserDefinedName(), seq, GetAgeInstanceName() );
else
xtl::format( fDisplayName, "%s %s", GetAgeUserDefinedName(), GetAgeInstanceName() );
return fDisplayName.c_str();
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "hsStlUtils.h"
#include "pyAgeInfoStruct.h"
///////////////////////////////////////////////////////////////////////////
pyAgeInfoStruct::pyAgeInfoStruct()
{
}
pyAgeInfoStruct::pyAgeInfoStruct(plAgeInfoStruct * info)
{
fAgeInfo.CopyFrom( info );
}
pyAgeInfoStruct::~pyAgeInfoStruct()
{
}
bool pyAgeInfoStruct::operator==(const pyAgeInfoStruct &other) const
{
return fAgeInfo.IsEqualTo( other.GetAgeInfo() );
}
/////////////////////////////////////////////////////////////////////
void pyAgeInfoStruct::CopyFrom( const pyAgeInfoStruct & other )
{
fAgeInfo.CopyFrom( other.GetAgeInfo() );
}
void pyAgeInfoStruct::CopyFromRef( const pyAgeInfoStructRef & other )
{
fAgeInfo.CopyFrom( other.GetAgeInfo() );
}
const char * pyAgeInfoStruct::GetAgeFilename() const
{
return fAgeInfo.GetAgeFilename();
}
void pyAgeInfoStruct::SetAgeFilename( const char * v )
{
fAgeInfo.SetAgeFilename( v );
}
const char * pyAgeInfoStruct::GetAgeInstanceName() const
{
return fAgeInfo.GetAgeInstanceName();
}
void pyAgeInfoStruct::SetAgeInstanceName( const char * v )
{
fAgeInfo.SetAgeInstanceName( v );
}
const char * pyAgeInfoStruct::GetAgeUserDefinedName() const
{
return fAgeInfo.GetAgeUserDefinedName();
}
void pyAgeInfoStruct::SetAgeUserDefinedName( const char * v )
{
fAgeInfo.SetAgeUserDefinedName( v );
}
const char * pyAgeInfoStruct::GetAgeDescription() const
{
return fAgeInfo.GetAgeDescription();
}
void pyAgeInfoStruct::SetAgeDescription( const char * v )
{
fAgeInfo.SetAgeDescription( v );
}
const char * pyAgeInfoStruct::GetAgeInstanceGuid() const
{
fAgeInstanceGuidStr = fAgeInfo.GetAgeInstanceGuid()->AsStdString();
return fAgeInstanceGuidStr.c_str();
}
void pyAgeInfoStruct::SetAgeInstanceGuid( const char * guid )
{
fAgeInfo.SetAgeInstanceGuid( &plUUID( guid ) );
}
Int32 pyAgeInfoStruct::GetAgeSequenceNumber() const
{
return fAgeInfo.GetAgeSequenceNumber();
}
void pyAgeInfoStruct::SetAgeSequenceNumber( Int32 v )
{
fAgeInfo.SetAgeSequenceNumber( v );
}
Int32 pyAgeInfoStruct::GetAgeLanguage() const
{
return fAgeInfo.GetAgeLanguage();
}
void pyAgeInfoStruct::SetAgeLanguage( Int32 v )
{
fAgeInfo.SetAgeLanguage( v );
}
const char * pyAgeInfoStruct::GetDisplayName() const
{
Int32 seq = GetAgeSequenceNumber();
if ( seq>0 )
xtl::format( fDisplayName, "%s (%d) %s", GetAgeUserDefinedName(), seq, GetAgeInstanceName() );
else
xtl::format( fDisplayName, "%s %s", GetAgeUserDefinedName(), GetAgeInstanceName() );
return fDisplayName.c_str();
}
/////////////////////////////////////////////////////////////////////
plAgeInfoStruct pyAgeInfoStructRef::fDefaultAgeInfo; // created so a default constructor could be made for python. Do NOT use
void pyAgeInfoStructRef::CopyFrom( const pyAgeInfoStruct & other )
{
fAgeInfo.CopyFrom( other.GetAgeInfo() );
}
void pyAgeInfoStructRef::CopyFromRef( const pyAgeInfoStructRef & other )
{
fAgeInfo.CopyFrom( other.GetAgeInfo() );
}
const char * pyAgeInfoStructRef::GetAgeFilename() const
{
return fAgeInfo.GetAgeFilename();
}
void pyAgeInfoStructRef::SetAgeFilename( const char * v )
{
fAgeInfo.SetAgeFilename( v );
}
const char * pyAgeInfoStructRef::GetAgeInstanceName() const
{
return fAgeInfo.GetAgeInstanceName();
}
void pyAgeInfoStructRef::SetAgeInstanceName( const char * v )
{
fAgeInfo.SetAgeInstanceName( v );
}
const char * pyAgeInfoStructRef::GetAgeUserDefinedName() const
{
return fAgeInfo.GetAgeUserDefinedName();
}
void pyAgeInfoStructRef::SetAgeUserDefinedName( const char * v )
{
fAgeInfo.SetAgeUserDefinedName( v );
}
const char * pyAgeInfoStructRef::GetAgeInstanceGuid() const
{
fAgeInstanceGuidStr = fAgeInfo.GetAgeInstanceGuid()->AsStdString();
return fAgeInstanceGuidStr.c_str();
}
void pyAgeInfoStructRef::SetAgeInstanceGuid( const char * guid )
{
fAgeInfo.SetAgeInstanceGuid( &plUUID( guid ) );
}
Int32 pyAgeInfoStructRef::GetAgeSequenceNumber() const
{
return fAgeInfo.GetAgeSequenceNumber();
}
void pyAgeInfoStructRef::SetAgeSequenceNumber( Int32 v )
{
fAgeInfo.SetAgeSequenceNumber( v );
}
const char * pyAgeInfoStructRef::GetDisplayName() const
{
Int32 seq = GetAgeSequenceNumber();
if ( seq>0 )
xtl::format( fDisplayName, "%s (%d) %s", GetAgeUserDefinedName(), seq, GetAgeInstanceName() );
else
xtl::format( fDisplayName, "%s %s", GetAgeUserDefinedName(), GetAgeInstanceName() );
return fDisplayName.c_str();
}

View File

@ -1,134 +1,134 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyAgeInfoStruct_h_inc
#define pyAgeInfoStruct_h_inc
#include "hsTypes.h"
#include "hsStlUtils.h"
#include "plNetCommon/plNetServerSessionInfo.h"
#include <python.h>
#include "pyGlueHelpers.h"
//////////////////////////////////////////////////////////////////////
//
// pyAgeInfoStruct - a wrapper class to provide interface to the plAgeInfoStruct
//
//////////////////////////////////////////////////////////////////////
class pyVaultAgeInfoNode;
class pyAgeInfoStructRef;
class pyAgeInfoStruct
{
private:
plAgeInfoStruct fAgeInfo;
mutable std::string fAgeInstanceGuidStr; // for getting Age Instance GUID
mutable std::string fDisplayName; // used by GetDisplayName()
protected:
pyAgeInfoStruct();
pyAgeInfoStruct(plAgeInfoStruct * info);
public:
~pyAgeInfoStruct();
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptAgeInfoStruct);
PYTHON_CLASS_NEW_DEFINITION;
static PyObject *New(plAgeInfoStruct *info);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyAgeInfoStruct object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyAgeInfoStruct); // converts a PyObject to a pyAgeInfoStruct (throws error if not correct type)
static void AddPlasmaClasses(PyObject *m);
bool operator==(const pyAgeInfoStruct &other) const;
bool operator!=(const pyAgeInfoStruct &other) const { return !(other==*this); }
plAgeInfoStruct * GetAgeInfo() { return &fAgeInfo; }
const plAgeInfoStruct * GetAgeInfo() const { return &fAgeInfo; }
static void PythonModDef();
void CopyFrom( const pyAgeInfoStruct & other );
void CopyFromRef( const pyAgeInfoStructRef & other );
const char * GetAgeFilename() const;
void SetAgeFilename( const char * v );
const char * GetAgeInstanceName() const;
void SetAgeInstanceName( const char * v );
const char * GetAgeUserDefinedName() const;
void SetAgeUserDefinedName( const char * v );
const char * GetAgeDescription() const;
void SetAgeDescription( const char * v );
const char * GetAgeInstanceGuid() const;
void SetAgeInstanceGuid( const char * guid );
Int32 GetAgeSequenceNumber() const;
void SetAgeSequenceNumber( Int32 v );
Int32 GetAgeLanguage() const;
void SetAgeLanguage( Int32 v );
const char * GetDisplayName() const;
};
class pyAgeInfoStructRef
{
private:
static plAgeInfoStruct fDefaultAgeInfo; // created so a default constructor could be made for python. Do NOT use
plAgeInfoStruct & fAgeInfo;
mutable std::string fAgeInstanceGuidStr; // for getting Age Instance GUID
mutable std::string fDisplayName; // used by GetDisplayName()
protected:
pyAgeInfoStructRef(): fAgeInfo( fDefaultAgeInfo ) {} // only here for the python glue... do NOT call directly
pyAgeInfoStructRef(plAgeInfoStruct & info): fAgeInfo( info ){}
public:
~pyAgeInfoStructRef() {}
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptAgeInfoStructRef);
static PyObject *New(plAgeInfoStruct &info);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyAgeInfoStructRef object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyAgeInfoStructRef); // converts a PyObject to a pyAgeInfoStructRef (throws error if not correct type)
static void AddPlasmaClasses(PyObject *m);
plAgeInfoStruct * GetAgeInfo() { return &fAgeInfo; }
const plAgeInfoStruct * GetAgeInfo() const { return &fAgeInfo; }
void CopyFrom( const pyAgeInfoStruct & other );
void CopyFromRef( const pyAgeInfoStructRef & other );
const char * GetAgeFilename() const;
void SetAgeFilename( const char * v );
const char * GetAgeInstanceName() const;
void SetAgeInstanceName( const char * v );
const char * GetAgeUserDefinedName() const;
void SetAgeUserDefinedName( const char * v );
const char * GetAgeInstanceGuid() const;
void SetAgeInstanceGuid( const char * guid );
Int32 GetAgeSequenceNumber() const;
void SetAgeSequenceNumber( Int32 v );
const char * GetDisplayName() const;
};
#endif // pyAgeInfoStruct_h_inc
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyAgeInfoStruct_h_inc
#define pyAgeInfoStruct_h_inc
#include "hsTypes.h"
#include "hsStlUtils.h"
#include "plNetCommon/plNetServerSessionInfo.h"
#include <python.h>
#include "pyGlueHelpers.h"
//////////////////////////////////////////////////////////////////////
//
// pyAgeInfoStruct - a wrapper class to provide interface to the plAgeInfoStruct
//
//////////////////////////////////////////////////////////////////////
class pyVaultAgeInfoNode;
class pyAgeInfoStructRef;
class pyAgeInfoStruct
{
private:
plAgeInfoStruct fAgeInfo;
mutable std::string fAgeInstanceGuidStr; // for getting Age Instance GUID
mutable std::string fDisplayName; // used by GetDisplayName()
protected:
pyAgeInfoStruct();
pyAgeInfoStruct(plAgeInfoStruct * info);
public:
~pyAgeInfoStruct();
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptAgeInfoStruct);
PYTHON_CLASS_NEW_DEFINITION;
static PyObject *New(plAgeInfoStruct *info);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyAgeInfoStruct object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyAgeInfoStruct); // converts a PyObject to a pyAgeInfoStruct (throws error if not correct type)
static void AddPlasmaClasses(PyObject *m);
bool operator==(const pyAgeInfoStruct &other) const;
bool operator!=(const pyAgeInfoStruct &other) const { return !(other==*this); }
plAgeInfoStruct * GetAgeInfo() { return &fAgeInfo; }
const plAgeInfoStruct * GetAgeInfo() const { return &fAgeInfo; }
static void PythonModDef();
void CopyFrom( const pyAgeInfoStruct & other );
void CopyFromRef( const pyAgeInfoStructRef & other );
const char * GetAgeFilename() const;
void SetAgeFilename( const char * v );
const char * GetAgeInstanceName() const;
void SetAgeInstanceName( const char * v );
const char * GetAgeUserDefinedName() const;
void SetAgeUserDefinedName( const char * v );
const char * GetAgeDescription() const;
void SetAgeDescription( const char * v );
const char * GetAgeInstanceGuid() const;
void SetAgeInstanceGuid( const char * guid );
Int32 GetAgeSequenceNumber() const;
void SetAgeSequenceNumber( Int32 v );
Int32 GetAgeLanguage() const;
void SetAgeLanguage( Int32 v );
const char * GetDisplayName() const;
};
class pyAgeInfoStructRef
{
private:
static plAgeInfoStruct fDefaultAgeInfo; // created so a default constructor could be made for python. Do NOT use
plAgeInfoStruct & fAgeInfo;
mutable std::string fAgeInstanceGuidStr; // for getting Age Instance GUID
mutable std::string fDisplayName; // used by GetDisplayName()
protected:
pyAgeInfoStructRef(): fAgeInfo( fDefaultAgeInfo ) {} // only here for the python glue... do NOT call directly
pyAgeInfoStructRef(plAgeInfoStruct & info): fAgeInfo( info ){}
public:
~pyAgeInfoStructRef() {}
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptAgeInfoStructRef);
static PyObject *New(plAgeInfoStruct &info);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyAgeInfoStructRef object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyAgeInfoStructRef); // converts a PyObject to a pyAgeInfoStructRef (throws error if not correct type)
static void AddPlasmaClasses(PyObject *m);
plAgeInfoStruct * GetAgeInfo() { return &fAgeInfo; }
const plAgeInfoStruct * GetAgeInfo() const { return &fAgeInfo; }
void CopyFrom( const pyAgeInfoStruct & other );
void CopyFromRef( const pyAgeInfoStructRef & other );
const char * GetAgeFilename() const;
void SetAgeFilename( const char * v );
const char * GetAgeInstanceName() const;
void SetAgeInstanceName( const char * v );
const char * GetAgeUserDefinedName() const;
void SetAgeUserDefinedName( const char * v );
const char * GetAgeInstanceGuid() const;
void SetAgeInstanceGuid( const char * guid );
Int32 GetAgeSequenceNumber() const;
void SetAgeSequenceNumber( Int32 v );
const char * GetDisplayName() const;
};
#endif // pyAgeInfoStruct_h_inc

View File

@ -1,436 +1,436 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyAgeInfoStruct.h"
#include <python.h>
// glue functions
PYTHON_CLASS_DEFINITION(ptAgeInfoStruct, pyAgeInfoStruct);
PYTHON_DEFAULT_NEW_DEFINITION(ptAgeInfoStruct, pyAgeInfoStruct)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptAgeInfoStruct)
PYTHON_INIT_DEFINITION(ptAgeInfoStruct, args, keywords)
{
PYTHON_RETURN_INIT_OK;
}
PYTHON_RICH_COMPARE_DEFINITION(ptAgeInfoStruct, obj1, obj2, compareType)
{
if ((obj1 == Py_None) || (obj2 == Py_None) || !pyAgeInfoStruct::Check(obj1) || !pyAgeInfoStruct::Check(obj2))
{
// if they aren't the same type, they don't match, obviously (we also never equal none)
if (compareType == Py_EQ)
PYTHON_RCOMPARE_FALSE;
else if (compareType == Py_NE)
PYTHON_RCOMPARE_TRUE;
else
{
PyErr_SetString(PyExc_NotImplementedError, "invalid comparison for a ptAgeInfoStruct object");
PYTHON_RCOMPARE_ERROR;
}
}
pyAgeInfoStruct *struct1 = pyAgeInfoStruct::ConvertFrom(obj1);
pyAgeInfoStruct *struct2 = pyAgeInfoStruct::ConvertFrom(obj2);
if (compareType == Py_EQ)
{
if ((*struct1) == (*struct2))
PYTHON_RCOMPARE_TRUE;
PYTHON_RCOMPARE_FALSE;
}
else if (compareType == Py_NE)
{
if ((*struct1) != (*struct2))
PYTHON_RCOMPARE_TRUE;
PYTHON_RCOMPARE_FALSE;
}
PyErr_SetString(PyExc_NotImplementedError, "invalid comparison for a ptAgeInfoStruct object");
PYTHON_RCOMPARE_ERROR;
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, copyFrom, args)
{
PyObject* infoStructObj = NULL;
if (!PyArg_ParseTuple(args, "O", &infoStructObj))
{
PyErr_SetString(PyExc_TypeError, "copyFrom expects a ptAgeInfoStruct or ptAgeInfoStructRef");
PYTHON_RETURN_ERROR;
}
if (pyAgeInfoStruct::Check(infoStructObj))
{
pyAgeInfoStruct* infoStruct = pyAgeInfoStruct::ConvertFrom(infoStructObj);
self->fThis->CopyFrom(*infoStruct);
PYTHON_RETURN_NONE;
}
else if (pyAgeInfoStructRef::Check(infoStructObj))
{
pyAgeInfoStructRef* infoStruct = pyAgeInfoStructRef::ConvertFrom(infoStructObj);
self->fThis->CopyFromRef(*infoStruct);
PYTHON_RETURN_NONE;
}
PyErr_SetString(PyExc_TypeError, "copyFrom expects a ptAgeInfoStruct or ptAgeInfoStructRef");
PYTHON_RETURN_ERROR;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStruct, getAgeFilename)
{
return PyString_FromString(self->fThis->GetAgeFilename());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeFilename, args)
{
char* filename;
if (!PyArg_ParseTuple(args, "s", &filename))
{
PyErr_SetString(PyExc_TypeError, "setAgeFilename expects a string");
PYTHON_RETURN_ERROR;
}
self->fThis->SetAgeFilename(filename);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStruct, getAgeInstanceName)
{
return PyString_FromString(self->fThis->GetAgeInstanceName());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeInstanceName, args)
{
char* instanceName;
if (!PyArg_ParseTuple(args, "s", &instanceName))
{
PyErr_SetString(PyExc_TypeError, "setAgeInstanceName expects a string");
PYTHON_RETURN_ERROR;
}
self->fThis->SetAgeInstanceName(instanceName);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStruct, getAgeUserDefinedName)
{
return PyString_FromString(self->fThis->GetAgeUserDefinedName());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeUserDefinedName, args)
{
char* userName;
if (!PyArg_ParseTuple(args, "s", &userName))
{
PyErr_SetString(PyExc_TypeError, "setAgeUserDefinedName expects a string");
PYTHON_RETURN_ERROR;
}
self->fThis->SetAgeUserDefinedName(userName);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStruct, getAgeDescription)
{
return PyString_FromString(self->fThis->GetAgeDescription());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeDescription, args)
{
char* desc;
if (!PyArg_ParseTuple(args, "s", &desc))
{
PyErr_SetString(PyExc_TypeError, "setAgeDescription expects a string");
PYTHON_RETURN_ERROR;
}
self->fThis->SetAgeDescription(desc);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStruct, getAgeInstanceGuid)
{
return PyString_FromString(self->fThis->GetAgeInstanceGuid());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeInstanceGuid, args)
{
char* guid;
if (!PyArg_ParseTuple(args, "s", &guid))
{
PyErr_SetString(PyExc_TypeError, "setAgeInstanceGuid expects a string");
PYTHON_RETURN_ERROR;
}
self->fThis->SetAgeInstanceGuid(guid);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStruct, getAgeSequenceNumber)
{
return PyInt_FromLong(self->fThis->GetAgeSequenceNumber());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeSequenceNumber, args)
{
long sequenceNum;
if (!PyArg_ParseTuple(args, "l", &sequenceNum))
{
PyErr_SetString(PyExc_TypeError, "setAgeSequenceNumber expects a long");
PYTHON_RETURN_ERROR;
}
self->fThis->SetAgeSequenceNumber(sequenceNum);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStruct, getAgeLanguage)
{
return PyInt_FromLong(self->fThis->GetAgeLanguage());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeLanguage, args)
{
long lang;
if (!PyArg_ParseTuple(args, "l", &lang))
{
PyErr_SetString(PyExc_TypeError, "setAgeLanguage expects a long");
PYTHON_RETURN_ERROR;
}
self->fThis->SetAgeLanguage(lang);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStruct, getDisplayName)
{
return PyString_FromString(self->fThis->GetDisplayName());
}
PYTHON_START_METHODS_TABLE(ptAgeInfoStruct)
PYTHON_METHOD(ptAgeInfoStruct, copyFrom, "Params: other\nCopies data from one ptAgeInfoStruct or ptAgeInfoStructRef to this one"),
PYTHON_METHOD_NOARGS(ptAgeInfoStruct, getAgeFilename, "Gets the Age's filename"),
PYTHON_METHOD(ptAgeInfoStruct, setAgeFilename, "Params: filename\nSets the filename of the Age"),
PYTHON_METHOD_NOARGS(ptAgeInfoStruct, getAgeInstanceName, "Get the instance name of the Age"),
PYTHON_METHOD(ptAgeInfoStruct, setAgeInstanceName, "Params: instanceName\nSets the instance name of the Age"),
PYTHON_METHOD_NOARGS(ptAgeInfoStruct, getAgeUserDefinedName, "Gets the user defined part of the Age name"),
PYTHON_METHOD(ptAgeInfoStruct, setAgeUserDefinedName, "Params: udName\nSets the user defined part of the Age"),
PYTHON_METHOD_NOARGS(ptAgeInfoStruct, getAgeDescription, "Gets the description part of the Age name"),
PYTHON_METHOD(ptAgeInfoStruct, setAgeDescription, "Params: udName\nSets the description part of the Age"),
PYTHON_METHOD_NOARGS(ptAgeInfoStruct, getAgeInstanceGuid, "Get the Age's instance GUID"),
PYTHON_METHOD(ptAgeInfoStruct, setAgeInstanceGuid, "Params: guid\nSets the Age instance's GUID"),
PYTHON_METHOD_NOARGS(ptAgeInfoStruct, getAgeSequenceNumber, "Gets the unique sequence number"),
PYTHON_METHOD(ptAgeInfoStruct, setAgeSequenceNumber, "Params: seqNumber\nSets the unique sequence number"),
PYTHON_METHOD_NOARGS(ptAgeInfoStruct, getAgeLanguage, "Gets the age's language (integer)"),
PYTHON_METHOD(ptAgeInfoStruct, setAgeLanguage, "Params: lang\nSets the age's language (integer)"),
PYTHON_METHOD_NOARGS(ptAgeInfoStruct, getDisplayName, "Returns a string that is the displayable name of the age instance"),
PYTHON_END_METHODS_TABLE;
// type structure definition
#define ptAgeInfoStruct_COMPARE PYTHON_NO_COMPARE
#define ptAgeInfoStruct_AS_NUMBER PYTHON_NO_AS_NUMBER
#define ptAgeInfoStruct_AS_SEQUENCE PYTHON_NO_AS_SEQUENCE
#define ptAgeInfoStruct_AS_MAPPING PYTHON_NO_AS_MAPPING
#define ptAgeInfoStruct_STR PYTHON_NO_STR
#define ptAgeInfoStruct_RICH_COMPARE PYTHON_DEFAULT_RICH_COMPARE(ptAgeInfoStruct)
#define ptAgeInfoStruct_GETSET PYTHON_NO_GETSET
#define ptAgeInfoStruct_BASE PYTHON_NO_BASE
PLASMA_CUSTOM_TYPE(ptAgeInfoStruct, "Class to hold AgeInfo struct data");
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_IMPL(ptAgeInfoStruct, pyAgeInfoStruct)
PyObject *pyAgeInfoStruct::New(plAgeInfoStruct *info)
{
ptAgeInfoStruct *newObj = (ptAgeInfoStruct*)ptAgeInfoStruct_type.tp_new(&ptAgeInfoStruct_type, NULL, NULL);
newObj->fThis->fAgeInfo.CopyFrom(info);
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptAgeInfoStruct, pyAgeInfoStruct)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptAgeInfoStruct, pyAgeInfoStruct)
///////////////////////////////////////////////////////////////////////////
//
// AddPlasmaClasses - the python module definitions
//
void pyAgeInfoStruct::AddPlasmaClasses(PyObject *m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptAgeInfoStruct);
PYTHON_CLASS_IMPORT_END(m);
}
// glue functions
PYTHON_CLASS_DEFINITION(ptAgeInfoStructRef, pyAgeInfoStructRef);
PYTHON_DEFAULT_NEW_DEFINITION(ptAgeInfoStructRef, pyAgeInfoStructRef)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptAgeInfoStructRef)
PYTHON_NO_INIT_DEFINITION(ptAgeInfoStructRef)
PYTHON_METHOD_DEFINITION(ptAgeInfoStructRef, copyFrom, args)
{
PyObject* infoStructObj = NULL;
if (!PyArg_ParseTuple(args, "O", &infoStructObj))
{
PyErr_SetString(PyExc_TypeError, "copyFrom expects a ptAgeInfoStruct or ptAgeInfoStructRef");
PYTHON_RETURN_ERROR;
}
if (pyAgeInfoStruct::Check(infoStructObj))
{
pyAgeInfoStruct* infoStruct = pyAgeInfoStruct::ConvertFrom(infoStructObj);
self->fThis->CopyFrom(*infoStruct);
PYTHON_RETURN_NONE;
}
else if (pyAgeInfoStructRef::Check(infoStructObj))
{
pyAgeInfoStructRef* infoStruct = pyAgeInfoStructRef::ConvertFrom(infoStructObj);
self->fThis->CopyFromRef(*infoStruct);
PYTHON_RETURN_NONE;
}
PyErr_SetString(PyExc_TypeError, "copyFrom expects a ptAgeInfoStruct or ptAgeInfoStructRef");
PYTHON_RETURN_ERROR;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStructRef, getAgeFilename)
{
return PyString_FromString(self->fThis->GetAgeFilename());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStructRef, setAgeFilename, args)
{
char* filename;
if (!PyArg_ParseTuple(args, "s", &filename))
{
PyErr_SetString(PyExc_TypeError, "setAgeFilename expects a string");
PYTHON_RETURN_ERROR;
}
self->fThis->SetAgeFilename(filename);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStructRef, getAgeInstanceName)
{
return PyString_FromString(self->fThis->GetAgeInstanceName());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStructRef, setAgeInstanceName, args)
{
char* instanceName;
if (!PyArg_ParseTuple(args, "s", &instanceName))
{
PyErr_SetString(PyExc_TypeError, "setAgeInstanceName expects a string");
PYTHON_RETURN_ERROR;
}
self->fThis->SetAgeInstanceName(instanceName);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStructRef, getAgeUserDefinedName)
{
return PyString_FromString(self->fThis->GetAgeUserDefinedName());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStructRef, setAgeUserDefinedName, args)
{
char* userName;
if (!PyArg_ParseTuple(args, "s", &userName))
{
PyErr_SetString(PyExc_TypeError, "setAgeUserDefinedName expects a string");
PYTHON_RETURN_ERROR;
}
self->fThis->SetAgeUserDefinedName(userName);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStructRef, getAgeInstanceGuid)
{
return PyString_FromString(self->fThis->GetAgeInstanceGuid());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStructRef, setAgeInstanceGuid, args)
{
char* guid;
if (!PyArg_ParseTuple(args, "s", &guid))
{
PyErr_SetString(PyExc_TypeError, "setAgeInstanceGuid expects a string");
PYTHON_RETURN_ERROR;
}
self->fThis->SetAgeInstanceGuid(guid);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStructRef, getAgeSequenceNumber)
{
return PyInt_FromLong(self->fThis->GetAgeSequenceNumber());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStructRef, setAgeSequenceNumber, args)
{
long sequenceNum;
if (!PyArg_ParseTuple(args, "l", &sequenceNum))
{
PyErr_SetString(PyExc_TypeError, "setAgeSequenceNumber expects a long");
PYTHON_RETURN_ERROR;
}
self->fThis->SetAgeSequenceNumber(sequenceNum);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStructRef, getDisplayName)
{
return PyString_FromString(self->fThis->GetDisplayName());
}
PYTHON_START_METHODS_TABLE(ptAgeInfoStructRef)
PYTHON_METHOD(ptAgeInfoStructRef, copyFrom, "Params: other\nCopies data from one ptAgeInfoStruct or ptAgeInfoStructRef to this one"),
PYTHON_METHOD_NOARGS(ptAgeInfoStructRef, getAgeFilename, "Gets the Age's filename"),
PYTHON_METHOD(ptAgeInfoStructRef, setAgeFilename, "Params: filename\nSets the filename of the Age"),
PYTHON_METHOD_NOARGS(ptAgeInfoStructRef, getAgeInstanceName, "Get the instance name of the Age"),
PYTHON_METHOD(ptAgeInfoStructRef, setAgeInstanceName, "Params: instanceName\nSets the instance name of the Age"),
PYTHON_METHOD_NOARGS(ptAgeInfoStructRef, getAgeUserDefinedName, "Gets the user defined part of the Age name"),
PYTHON_METHOD(ptAgeInfoStructRef, setAgeUserDefinedName, "Params: udName\nSets the user defined part of the Age"),
PYTHON_METHOD_NOARGS(ptAgeInfoStructRef, getAgeInstanceGuid, "Get the Age's instance GUID"),
PYTHON_METHOD(ptAgeInfoStructRef, setAgeInstanceGuid, "Params: guid\nSets the Age instance's GUID"),
PYTHON_METHOD_NOARGS(ptAgeInfoStructRef, getAgeSequenceNumber, "Gets the unique sequence number"),
PYTHON_METHOD(ptAgeInfoStructRef, setAgeSequenceNumber, "Params: seqNumber\nSets the unique sequence number"),
PYTHON_METHOD_NOARGS(ptAgeInfoStructRef, getDisplayName, "Returns a string that is the displayable name of the age instance"),
PYTHON_END_METHODS_TABLE;
// type structure definition
PLASMA_DEFAULT_TYPE(ptAgeInfoStructRef, "Class to hold AgeInfo struct data");
// required functions for PyObject interoperability
PyObject *pyAgeInfoStructRef::New(plAgeInfoStruct &info)
{
ptAgeInfoStructRef *newObj = (ptAgeInfoStructRef*)ptAgeInfoStructRef_type.tp_new(&ptAgeInfoStructRef_type, NULL, NULL);
newObj->fThis->fAgeInfo = info;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptAgeInfoStructRef, pyAgeInfoStructRef)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptAgeInfoStructRef, pyAgeInfoStructRef)
///////////////////////////////////////////////////////////////////////////
//
// AddPlasmaClasses - the python module definitions
//
void pyAgeInfoStructRef::AddPlasmaClasses(PyObject *m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptAgeInfoStructRef);
PYTHON_CLASS_IMPORT_END(m);
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyAgeInfoStruct.h"
#include <python.h>
// glue functions
PYTHON_CLASS_DEFINITION(ptAgeInfoStruct, pyAgeInfoStruct);
PYTHON_DEFAULT_NEW_DEFINITION(ptAgeInfoStruct, pyAgeInfoStruct)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptAgeInfoStruct)
PYTHON_INIT_DEFINITION(ptAgeInfoStruct, args, keywords)
{
PYTHON_RETURN_INIT_OK;
}
PYTHON_RICH_COMPARE_DEFINITION(ptAgeInfoStruct, obj1, obj2, compareType)
{
if ((obj1 == Py_None) || (obj2 == Py_None) || !pyAgeInfoStruct::Check(obj1) || !pyAgeInfoStruct::Check(obj2))
{
// if they aren't the same type, they don't match, obviously (we also never equal none)
if (compareType == Py_EQ)
PYTHON_RCOMPARE_FALSE;
else if (compareType == Py_NE)
PYTHON_RCOMPARE_TRUE;
else
{
PyErr_SetString(PyExc_NotImplementedError, "invalid comparison for a ptAgeInfoStruct object");
PYTHON_RCOMPARE_ERROR;
}
}
pyAgeInfoStruct *struct1 = pyAgeInfoStruct::ConvertFrom(obj1);
pyAgeInfoStruct *struct2 = pyAgeInfoStruct::ConvertFrom(obj2);
if (compareType == Py_EQ)
{
if ((*struct1) == (*struct2))
PYTHON_RCOMPARE_TRUE;
PYTHON_RCOMPARE_FALSE;
}
else if (compareType == Py_NE)
{
if ((*struct1) != (*struct2))
PYTHON_RCOMPARE_TRUE;
PYTHON_RCOMPARE_FALSE;
}
PyErr_SetString(PyExc_NotImplementedError, "invalid comparison for a ptAgeInfoStruct object");
PYTHON_RCOMPARE_ERROR;
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, copyFrom, args)
{
PyObject* infoStructObj = NULL;
if (!PyArg_ParseTuple(args, "O", &infoStructObj))
{
PyErr_SetString(PyExc_TypeError, "copyFrom expects a ptAgeInfoStruct or ptAgeInfoStructRef");
PYTHON_RETURN_ERROR;
}
if (pyAgeInfoStruct::Check(infoStructObj))
{
pyAgeInfoStruct* infoStruct = pyAgeInfoStruct::ConvertFrom(infoStructObj);
self->fThis->CopyFrom(*infoStruct);
PYTHON_RETURN_NONE;
}
else if (pyAgeInfoStructRef::Check(infoStructObj))
{
pyAgeInfoStructRef* infoStruct = pyAgeInfoStructRef::ConvertFrom(infoStructObj);
self->fThis->CopyFromRef(*infoStruct);
PYTHON_RETURN_NONE;
}
PyErr_SetString(PyExc_TypeError, "copyFrom expects a ptAgeInfoStruct or ptAgeInfoStructRef");
PYTHON_RETURN_ERROR;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStruct, getAgeFilename)
{
return PyString_FromString(self->fThis->GetAgeFilename());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeFilename, args)
{
char* filename;
if (!PyArg_ParseTuple(args, "s", &filename))
{
PyErr_SetString(PyExc_TypeError, "setAgeFilename expects a string");
PYTHON_RETURN_ERROR;
}
self->fThis->SetAgeFilename(filename);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStruct, getAgeInstanceName)
{
return PyString_FromString(self->fThis->GetAgeInstanceName());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeInstanceName, args)
{
char* instanceName;
if (!PyArg_ParseTuple(args, "s", &instanceName))
{
PyErr_SetString(PyExc_TypeError, "setAgeInstanceName expects a string");
PYTHON_RETURN_ERROR;
}
self->fThis->SetAgeInstanceName(instanceName);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStruct, getAgeUserDefinedName)
{
return PyString_FromString(self->fThis->GetAgeUserDefinedName());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeUserDefinedName, args)
{
char* userName;
if (!PyArg_ParseTuple(args, "s", &userName))
{
PyErr_SetString(PyExc_TypeError, "setAgeUserDefinedName expects a string");
PYTHON_RETURN_ERROR;
}
self->fThis->SetAgeUserDefinedName(userName);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStruct, getAgeDescription)
{
return PyString_FromString(self->fThis->GetAgeDescription());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeDescription, args)
{
char* desc;
if (!PyArg_ParseTuple(args, "s", &desc))
{
PyErr_SetString(PyExc_TypeError, "setAgeDescription expects a string");
PYTHON_RETURN_ERROR;
}
self->fThis->SetAgeDescription(desc);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStruct, getAgeInstanceGuid)
{
return PyString_FromString(self->fThis->GetAgeInstanceGuid());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeInstanceGuid, args)
{
char* guid;
if (!PyArg_ParseTuple(args, "s", &guid))
{
PyErr_SetString(PyExc_TypeError, "setAgeInstanceGuid expects a string");
PYTHON_RETURN_ERROR;
}
self->fThis->SetAgeInstanceGuid(guid);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStruct, getAgeSequenceNumber)
{
return PyInt_FromLong(self->fThis->GetAgeSequenceNumber());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeSequenceNumber, args)
{
long sequenceNum;
if (!PyArg_ParseTuple(args, "l", &sequenceNum))
{
PyErr_SetString(PyExc_TypeError, "setAgeSequenceNumber expects a long");
PYTHON_RETURN_ERROR;
}
self->fThis->SetAgeSequenceNumber(sequenceNum);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStruct, getAgeLanguage)
{
return PyInt_FromLong(self->fThis->GetAgeLanguage());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStruct, setAgeLanguage, args)
{
long lang;
if (!PyArg_ParseTuple(args, "l", &lang))
{
PyErr_SetString(PyExc_TypeError, "setAgeLanguage expects a long");
PYTHON_RETURN_ERROR;
}
self->fThis->SetAgeLanguage(lang);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStruct, getDisplayName)
{
return PyString_FromString(self->fThis->GetDisplayName());
}
PYTHON_START_METHODS_TABLE(ptAgeInfoStruct)
PYTHON_METHOD(ptAgeInfoStruct, copyFrom, "Params: other\nCopies data from one ptAgeInfoStruct or ptAgeInfoStructRef to this one"),
PYTHON_METHOD_NOARGS(ptAgeInfoStruct, getAgeFilename, "Gets the Age's filename"),
PYTHON_METHOD(ptAgeInfoStruct, setAgeFilename, "Params: filename\nSets the filename of the Age"),
PYTHON_METHOD_NOARGS(ptAgeInfoStruct, getAgeInstanceName, "Get the instance name of the Age"),
PYTHON_METHOD(ptAgeInfoStruct, setAgeInstanceName, "Params: instanceName\nSets the instance name of the Age"),
PYTHON_METHOD_NOARGS(ptAgeInfoStruct, getAgeUserDefinedName, "Gets the user defined part of the Age name"),
PYTHON_METHOD(ptAgeInfoStruct, setAgeUserDefinedName, "Params: udName\nSets the user defined part of the Age"),
PYTHON_METHOD_NOARGS(ptAgeInfoStruct, getAgeDescription, "Gets the description part of the Age name"),
PYTHON_METHOD(ptAgeInfoStruct, setAgeDescription, "Params: udName\nSets the description part of the Age"),
PYTHON_METHOD_NOARGS(ptAgeInfoStruct, getAgeInstanceGuid, "Get the Age's instance GUID"),
PYTHON_METHOD(ptAgeInfoStruct, setAgeInstanceGuid, "Params: guid\nSets the Age instance's GUID"),
PYTHON_METHOD_NOARGS(ptAgeInfoStruct, getAgeSequenceNumber, "Gets the unique sequence number"),
PYTHON_METHOD(ptAgeInfoStruct, setAgeSequenceNumber, "Params: seqNumber\nSets the unique sequence number"),
PYTHON_METHOD_NOARGS(ptAgeInfoStruct, getAgeLanguage, "Gets the age's language (integer)"),
PYTHON_METHOD(ptAgeInfoStruct, setAgeLanguage, "Params: lang\nSets the age's language (integer)"),
PYTHON_METHOD_NOARGS(ptAgeInfoStruct, getDisplayName, "Returns a string that is the displayable name of the age instance"),
PYTHON_END_METHODS_TABLE;
// type structure definition
#define ptAgeInfoStruct_COMPARE PYTHON_NO_COMPARE
#define ptAgeInfoStruct_AS_NUMBER PYTHON_NO_AS_NUMBER
#define ptAgeInfoStruct_AS_SEQUENCE PYTHON_NO_AS_SEQUENCE
#define ptAgeInfoStruct_AS_MAPPING PYTHON_NO_AS_MAPPING
#define ptAgeInfoStruct_STR PYTHON_NO_STR
#define ptAgeInfoStruct_RICH_COMPARE PYTHON_DEFAULT_RICH_COMPARE(ptAgeInfoStruct)
#define ptAgeInfoStruct_GETSET PYTHON_NO_GETSET
#define ptAgeInfoStruct_BASE PYTHON_NO_BASE
PLASMA_CUSTOM_TYPE(ptAgeInfoStruct, "Class to hold AgeInfo struct data");
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_IMPL(ptAgeInfoStruct, pyAgeInfoStruct)
PyObject *pyAgeInfoStruct::New(plAgeInfoStruct *info)
{
ptAgeInfoStruct *newObj = (ptAgeInfoStruct*)ptAgeInfoStruct_type.tp_new(&ptAgeInfoStruct_type, NULL, NULL);
newObj->fThis->fAgeInfo.CopyFrom(info);
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptAgeInfoStruct, pyAgeInfoStruct)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptAgeInfoStruct, pyAgeInfoStruct)
///////////////////////////////////////////////////////////////////////////
//
// AddPlasmaClasses - the python module definitions
//
void pyAgeInfoStruct::AddPlasmaClasses(PyObject *m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptAgeInfoStruct);
PYTHON_CLASS_IMPORT_END(m);
}
// glue functions
PYTHON_CLASS_DEFINITION(ptAgeInfoStructRef, pyAgeInfoStructRef);
PYTHON_DEFAULT_NEW_DEFINITION(ptAgeInfoStructRef, pyAgeInfoStructRef)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptAgeInfoStructRef)
PYTHON_NO_INIT_DEFINITION(ptAgeInfoStructRef)
PYTHON_METHOD_DEFINITION(ptAgeInfoStructRef, copyFrom, args)
{
PyObject* infoStructObj = NULL;
if (!PyArg_ParseTuple(args, "O", &infoStructObj))
{
PyErr_SetString(PyExc_TypeError, "copyFrom expects a ptAgeInfoStruct or ptAgeInfoStructRef");
PYTHON_RETURN_ERROR;
}
if (pyAgeInfoStruct::Check(infoStructObj))
{
pyAgeInfoStruct* infoStruct = pyAgeInfoStruct::ConvertFrom(infoStructObj);
self->fThis->CopyFrom(*infoStruct);
PYTHON_RETURN_NONE;
}
else if (pyAgeInfoStructRef::Check(infoStructObj))
{
pyAgeInfoStructRef* infoStruct = pyAgeInfoStructRef::ConvertFrom(infoStructObj);
self->fThis->CopyFromRef(*infoStruct);
PYTHON_RETURN_NONE;
}
PyErr_SetString(PyExc_TypeError, "copyFrom expects a ptAgeInfoStruct or ptAgeInfoStructRef");
PYTHON_RETURN_ERROR;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStructRef, getAgeFilename)
{
return PyString_FromString(self->fThis->GetAgeFilename());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStructRef, setAgeFilename, args)
{
char* filename;
if (!PyArg_ParseTuple(args, "s", &filename))
{
PyErr_SetString(PyExc_TypeError, "setAgeFilename expects a string");
PYTHON_RETURN_ERROR;
}
self->fThis->SetAgeFilename(filename);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStructRef, getAgeInstanceName)
{
return PyString_FromString(self->fThis->GetAgeInstanceName());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStructRef, setAgeInstanceName, args)
{
char* instanceName;
if (!PyArg_ParseTuple(args, "s", &instanceName))
{
PyErr_SetString(PyExc_TypeError, "setAgeInstanceName expects a string");
PYTHON_RETURN_ERROR;
}
self->fThis->SetAgeInstanceName(instanceName);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStructRef, getAgeUserDefinedName)
{
return PyString_FromString(self->fThis->GetAgeUserDefinedName());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStructRef, setAgeUserDefinedName, args)
{
char* userName;
if (!PyArg_ParseTuple(args, "s", &userName))
{
PyErr_SetString(PyExc_TypeError, "setAgeUserDefinedName expects a string");
PYTHON_RETURN_ERROR;
}
self->fThis->SetAgeUserDefinedName(userName);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStructRef, getAgeInstanceGuid)
{
return PyString_FromString(self->fThis->GetAgeInstanceGuid());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStructRef, setAgeInstanceGuid, args)
{
char* guid;
if (!PyArg_ParseTuple(args, "s", &guid))
{
PyErr_SetString(PyExc_TypeError, "setAgeInstanceGuid expects a string");
PYTHON_RETURN_ERROR;
}
self->fThis->SetAgeInstanceGuid(guid);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStructRef, getAgeSequenceNumber)
{
return PyInt_FromLong(self->fThis->GetAgeSequenceNumber());
}
PYTHON_METHOD_DEFINITION(ptAgeInfoStructRef, setAgeSequenceNumber, args)
{
long sequenceNum;
if (!PyArg_ParseTuple(args, "l", &sequenceNum))
{
PyErr_SetString(PyExc_TypeError, "setAgeSequenceNumber expects a long");
PYTHON_RETURN_ERROR;
}
self->fThis->SetAgeSequenceNumber(sequenceNum);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeInfoStructRef, getDisplayName)
{
return PyString_FromString(self->fThis->GetDisplayName());
}
PYTHON_START_METHODS_TABLE(ptAgeInfoStructRef)
PYTHON_METHOD(ptAgeInfoStructRef, copyFrom, "Params: other\nCopies data from one ptAgeInfoStruct or ptAgeInfoStructRef to this one"),
PYTHON_METHOD_NOARGS(ptAgeInfoStructRef, getAgeFilename, "Gets the Age's filename"),
PYTHON_METHOD(ptAgeInfoStructRef, setAgeFilename, "Params: filename\nSets the filename of the Age"),
PYTHON_METHOD_NOARGS(ptAgeInfoStructRef, getAgeInstanceName, "Get the instance name of the Age"),
PYTHON_METHOD(ptAgeInfoStructRef, setAgeInstanceName, "Params: instanceName\nSets the instance name of the Age"),
PYTHON_METHOD_NOARGS(ptAgeInfoStructRef, getAgeUserDefinedName, "Gets the user defined part of the Age name"),
PYTHON_METHOD(ptAgeInfoStructRef, setAgeUserDefinedName, "Params: udName\nSets the user defined part of the Age"),
PYTHON_METHOD_NOARGS(ptAgeInfoStructRef, getAgeInstanceGuid, "Get the Age's instance GUID"),
PYTHON_METHOD(ptAgeInfoStructRef, setAgeInstanceGuid, "Params: guid\nSets the Age instance's GUID"),
PYTHON_METHOD_NOARGS(ptAgeInfoStructRef, getAgeSequenceNumber, "Gets the unique sequence number"),
PYTHON_METHOD(ptAgeInfoStructRef, setAgeSequenceNumber, "Params: seqNumber\nSets the unique sequence number"),
PYTHON_METHOD_NOARGS(ptAgeInfoStructRef, getDisplayName, "Returns a string that is the displayable name of the age instance"),
PYTHON_END_METHODS_TABLE;
// type structure definition
PLASMA_DEFAULT_TYPE(ptAgeInfoStructRef, "Class to hold AgeInfo struct data");
// required functions for PyObject interoperability
PyObject *pyAgeInfoStructRef::New(plAgeInfoStruct &info)
{
ptAgeInfoStructRef *newObj = (ptAgeInfoStructRef*)ptAgeInfoStructRef_type.tp_new(&ptAgeInfoStructRef_type, NULL, NULL);
newObj->fThis->fAgeInfo = info;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptAgeInfoStructRef, pyAgeInfoStructRef)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptAgeInfoStructRef, pyAgeInfoStructRef)
///////////////////////////////////////////////////////////////////////////
//
// AddPlasmaClasses - the python module definitions
//
void pyAgeInfoStructRef::AddPlasmaClasses(PyObject *m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptAgeInfoStructRef);
PYTHON_CLASS_IMPORT_END(m);
}

View File

@ -1,159 +1,159 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "hsStlUtils.h"
#include "pyAgeLinkStruct.h"
#include "pySpawnPointInfo.h"
///////////////////////////////////////////////////////////////////////////
pyAgeLinkStruct::pyAgeLinkStruct()
{
}
pyAgeLinkStruct::pyAgeLinkStruct( plAgeLinkStruct * link )
{
fAgeLink.CopyFrom( link );
}
pyAgeLinkStruct::~pyAgeLinkStruct()
{
}
bool pyAgeLinkStruct::operator==(const pyAgeLinkStruct &other) const
{
return fAgeLink.IsEqualTo( other.GetAgeLink() );
}
/////////////////////////////////////////////////////////////////////
PyObject * pyAgeLinkStruct::GetAgeInfo()
{
return pyAgeInfoStructRef::New( *fAgeLink.GetAgeInfo() );
}
void pyAgeLinkStruct::SetAgeInfo( pyAgeInfoStruct & info )
{
fAgeLink.GetAgeInfo()->CopyFrom( info.GetAgeInfo() );
}
const char* pyAgeLinkStruct::GetParentAgeFilename()
{
return fAgeLink.GetParentAgeFilename();
}
void pyAgeLinkStruct::SetParentAgeFilename( const char* parentname )
{
fAgeLink.SetParentAgeFilename(parentname);
}
void pyAgeLinkStruct::CopyFrom( const pyAgeLinkStruct & other )
{
fAgeLink.CopyFrom( other.GetAgeLink() );
}
void pyAgeLinkStruct::CopyFromRef( const pyAgeLinkStructRef & other )
{
fAgeLink.CopyFrom( other.GetAgeLink() );
}
void pyAgeLinkStruct::SetLinkingRules( int v )
{
fAgeLink.SetLinkingRules( v );
}
int pyAgeLinkStruct::GetLinkingRules() const
{
return fAgeLink.GetLinkingRules();
}
void pyAgeLinkStruct::SetSpawnPoint( pySpawnPointInfo & v )
{
fAgeLink.SpawnPoint() = v.SpawnPoint();
}
void pyAgeLinkStruct::SetSpawnPointRef( pySpawnPointInfoRef & v )
{
fAgeLink.SpawnPoint() = v.SpawnPoint();
}
PyObject * pyAgeLinkStruct::GetSpawnPoint()
{
return pySpawnPointInfoRef::New( fAgeLink.SpawnPoint() );
}
////////////////////////////////////////////////////////////////////////
plAgeLinkStruct pyAgeLinkStructRef::fDefaultLinkStruct; // created so a default constructor could be made for python. Do NOT use
PyObject * pyAgeLinkStructRef::GetAgeInfo()
{
return pyAgeInfoStructRef::New( *fAgeLink.GetAgeInfo() );
}
void pyAgeLinkStructRef::SetAgeInfo( pyAgeInfoStruct & info )
{
fAgeLink.GetAgeInfo()->CopyFrom( info.GetAgeInfo() );
}
void pyAgeLinkStructRef::CopyFrom( const pyAgeLinkStruct & other )
{
fAgeLink.CopyFrom( other.GetAgeLink() );
}
void pyAgeLinkStructRef::CopyFromRef( const pyAgeLinkStructRef & other )
{
fAgeLink.CopyFrom( other.GetAgeLink() );
}
void pyAgeLinkStructRef::SetLinkingRules( int v )
{
fAgeLink.SetLinkingRules( v );
}
int pyAgeLinkStructRef::GetLinkingRules() const
{
return fAgeLink.GetLinkingRules();
}
void pyAgeLinkStructRef::SetSpawnPoint( pySpawnPointInfo & v )
{
fAgeLink.SpawnPoint() = v.SpawnPoint();
}
void pyAgeLinkStructRef::SetSpawnPointRef( pySpawnPointInfoRef & v )
{
fAgeLink.SpawnPoint() = v.SpawnPoint();
}
PyObject * pyAgeLinkStructRef::GetSpawnPoint()
{
return pySpawnPointInfoRef::New( fAgeLink.SpawnPoint() );
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "hsStlUtils.h"
#include "pyAgeLinkStruct.h"
#include "pySpawnPointInfo.h"
///////////////////////////////////////////////////////////////////////////
pyAgeLinkStruct::pyAgeLinkStruct()
{
}
pyAgeLinkStruct::pyAgeLinkStruct( plAgeLinkStruct * link )
{
fAgeLink.CopyFrom( link );
}
pyAgeLinkStruct::~pyAgeLinkStruct()
{
}
bool pyAgeLinkStruct::operator==(const pyAgeLinkStruct &other) const
{
return fAgeLink.IsEqualTo( other.GetAgeLink() );
}
/////////////////////////////////////////////////////////////////////
PyObject * pyAgeLinkStruct::GetAgeInfo()
{
return pyAgeInfoStructRef::New( *fAgeLink.GetAgeInfo() );
}
void pyAgeLinkStruct::SetAgeInfo( pyAgeInfoStruct & info )
{
fAgeLink.GetAgeInfo()->CopyFrom( info.GetAgeInfo() );
}
const char* pyAgeLinkStruct::GetParentAgeFilename()
{
return fAgeLink.GetParentAgeFilename();
}
void pyAgeLinkStruct::SetParentAgeFilename( const char* parentname )
{
fAgeLink.SetParentAgeFilename(parentname);
}
void pyAgeLinkStruct::CopyFrom( const pyAgeLinkStruct & other )
{
fAgeLink.CopyFrom( other.GetAgeLink() );
}
void pyAgeLinkStruct::CopyFromRef( const pyAgeLinkStructRef & other )
{
fAgeLink.CopyFrom( other.GetAgeLink() );
}
void pyAgeLinkStruct::SetLinkingRules( int v )
{
fAgeLink.SetLinkingRules( v );
}
int pyAgeLinkStruct::GetLinkingRules() const
{
return fAgeLink.GetLinkingRules();
}
void pyAgeLinkStruct::SetSpawnPoint( pySpawnPointInfo & v )
{
fAgeLink.SpawnPoint() = v.SpawnPoint();
}
void pyAgeLinkStruct::SetSpawnPointRef( pySpawnPointInfoRef & v )
{
fAgeLink.SpawnPoint() = v.SpawnPoint();
}
PyObject * pyAgeLinkStruct::GetSpawnPoint()
{
return pySpawnPointInfoRef::New( fAgeLink.SpawnPoint() );
}
////////////////////////////////////////////////////////////////////////
plAgeLinkStruct pyAgeLinkStructRef::fDefaultLinkStruct; // created so a default constructor could be made for python. Do NOT use
PyObject * pyAgeLinkStructRef::GetAgeInfo()
{
return pyAgeInfoStructRef::New( *fAgeLink.GetAgeInfo() );
}
void pyAgeLinkStructRef::SetAgeInfo( pyAgeInfoStruct & info )
{
fAgeLink.GetAgeInfo()->CopyFrom( info.GetAgeInfo() );
}
void pyAgeLinkStructRef::CopyFrom( const pyAgeLinkStruct & other )
{
fAgeLink.CopyFrom( other.GetAgeLink() );
}
void pyAgeLinkStructRef::CopyFromRef( const pyAgeLinkStructRef & other )
{
fAgeLink.CopyFrom( other.GetAgeLink() );
}
void pyAgeLinkStructRef::SetLinkingRules( int v )
{
fAgeLink.SetLinkingRules( v );
}
int pyAgeLinkStructRef::GetLinkingRules() const
{
return fAgeLink.GetLinkingRules();
}
void pyAgeLinkStructRef::SetSpawnPoint( pySpawnPointInfo & v )
{
fAgeLink.SpawnPoint() = v.SpawnPoint();
}
void pyAgeLinkStructRef::SetSpawnPointRef( pySpawnPointInfoRef & v )
{
fAgeLink.SpawnPoint() = v.SpawnPoint();
}
PyObject * pyAgeLinkStructRef::GetSpawnPoint()
{
return pySpawnPointInfoRef::New( fAgeLink.SpawnPoint() );
}

View File

@ -1,122 +1,122 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyAgeLinkStruct_h_inc
#define pyAgeLinkStruct_h_inc
#include "hsTypes.h"
#include "hsStlUtils.h"
#include "plNetCommon/plNetServerSessionInfo.h"
#include "pyAgeInfoStruct.h"
#include <python.h>
#include "pyGlueHelpers.h"
//////////////////////////////////////////////////////////////////////
//
// pyAgeLinkStruct - a wrapper class to provide interface to the plAgeLinkStruct
//
//////////////////////////////////////////////////////////////////////
class pyVaultAgeLinkNode;
class pySpawnPointInfo;
class pySpawnPointInfoRef;
class pyAgeLinkStructRef;
class pyAgeLinkStruct
{
private:
plAgeLinkStruct fAgeLink;
protected:
pyAgeLinkStruct();
pyAgeLinkStruct( plAgeLinkStruct * link );
public:
~pyAgeLinkStruct();
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptAgeLinkStruct);
PYTHON_CLASS_NEW_DEFINITION;
static PyObject *New(plAgeLinkStruct* link);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyAgeLinkStruct object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyAgeLinkStruct); // converts a PyObject to a pyAgeLinkStruct (throws error if not correct type)
static void AddPlasmaClasses(PyObject *m);
bool operator==(const pyAgeLinkStruct &other) const;
bool operator!=(const pyAgeLinkStruct &other) const { return !(other==*this); }
plAgeLinkStruct * GetAgeLink() { return &fAgeLink; }
const plAgeLinkStruct * GetAgeLink() const { return &fAgeLink; }
PyObject * GetAgeInfo(); // returns pyAgeInfoStructRef
void SetAgeInfo( pyAgeInfoStruct & info );
const char* GetParentAgeFilename();
void SetParentAgeFilename( const char* parentname );
void CopyFrom( const pyAgeLinkStruct & other );
void CopyFromRef( const pyAgeLinkStructRef & other );
void SetLinkingRules( int v );
int GetLinkingRules() const;
void SetSpawnPoint( pySpawnPointInfo & v );
void SetSpawnPointRef( pySpawnPointInfoRef & v );
PyObject * GetSpawnPoint(); // returns pySpawnPointInfoRef
};
class pyAgeLinkStructRef
{
private:
static plAgeLinkStruct fDefaultLinkStruct; // created so a default constructor could be made for python, do NOT use
plAgeLinkStruct & fAgeLink;
protected:
pyAgeLinkStructRef(): fAgeLink(fDefaultLinkStruct) {} // only used by python glue, do NOT call directly
pyAgeLinkStructRef( plAgeLinkStruct & link ):fAgeLink(link) {}
public:
~pyAgeLinkStructRef(){}
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptAgeLinkStructRef);
static PyObject *New(plAgeLinkStruct& link);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyAgeLinkStructRef object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyAgeLinkStructRef); // converts a PyObject to a pyAgeLinkStructRef (throws error if not correct type)
static void AddPlasmaClasses(PyObject *m);
plAgeLinkStruct * GetAgeLink() { return &fAgeLink; }
const plAgeLinkStruct * GetAgeLink() const { return &fAgeLink; }
PyObject * GetAgeInfo(); // returns pyAgeInfoStructRef
void SetAgeInfo( pyAgeInfoStruct & info );
void CopyFrom( const pyAgeLinkStruct & other );
void CopyFromRef( const pyAgeLinkStructRef & other );
void SetLinkingRules( int v );
int GetLinkingRules() const;
void SetSpawnPoint( pySpawnPointInfo & v );
void SetSpawnPointRef( pySpawnPointInfoRef & v );
PyObject * GetSpawnPoint(); // returns pySpawnPointInfoRef
};
#endif // pyAgeLinkStruct_h_inc
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyAgeLinkStruct_h_inc
#define pyAgeLinkStruct_h_inc
#include "hsTypes.h"
#include "hsStlUtils.h"
#include "plNetCommon/plNetServerSessionInfo.h"
#include "pyAgeInfoStruct.h"
#include <python.h>
#include "pyGlueHelpers.h"
//////////////////////////////////////////////////////////////////////
//
// pyAgeLinkStruct - a wrapper class to provide interface to the plAgeLinkStruct
//
//////////////////////////////////////////////////////////////////////
class pyVaultAgeLinkNode;
class pySpawnPointInfo;
class pySpawnPointInfoRef;
class pyAgeLinkStructRef;
class pyAgeLinkStruct
{
private:
plAgeLinkStruct fAgeLink;
protected:
pyAgeLinkStruct();
pyAgeLinkStruct( plAgeLinkStruct * link );
public:
~pyAgeLinkStruct();
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptAgeLinkStruct);
PYTHON_CLASS_NEW_DEFINITION;
static PyObject *New(plAgeLinkStruct* link);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyAgeLinkStruct object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyAgeLinkStruct); // converts a PyObject to a pyAgeLinkStruct (throws error if not correct type)
static void AddPlasmaClasses(PyObject *m);
bool operator==(const pyAgeLinkStruct &other) const;
bool operator!=(const pyAgeLinkStruct &other) const { return !(other==*this); }
plAgeLinkStruct * GetAgeLink() { return &fAgeLink; }
const plAgeLinkStruct * GetAgeLink() const { return &fAgeLink; }
PyObject * GetAgeInfo(); // returns pyAgeInfoStructRef
void SetAgeInfo( pyAgeInfoStruct & info );
const char* GetParentAgeFilename();
void SetParentAgeFilename( const char* parentname );
void CopyFrom( const pyAgeLinkStruct & other );
void CopyFromRef( const pyAgeLinkStructRef & other );
void SetLinkingRules( int v );
int GetLinkingRules() const;
void SetSpawnPoint( pySpawnPointInfo & v );
void SetSpawnPointRef( pySpawnPointInfoRef & v );
PyObject * GetSpawnPoint(); // returns pySpawnPointInfoRef
};
class pyAgeLinkStructRef
{
private:
static plAgeLinkStruct fDefaultLinkStruct; // created so a default constructor could be made for python, do NOT use
plAgeLinkStruct & fAgeLink;
protected:
pyAgeLinkStructRef(): fAgeLink(fDefaultLinkStruct) {} // only used by python glue, do NOT call directly
pyAgeLinkStructRef( plAgeLinkStruct & link ):fAgeLink(link) {}
public:
~pyAgeLinkStructRef(){}
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptAgeLinkStructRef);
static PyObject *New(plAgeLinkStruct& link);
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyAgeLinkStructRef object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyAgeLinkStructRef); // converts a PyObject to a pyAgeLinkStructRef (throws error if not correct type)
static void AddPlasmaClasses(PyObject *m);
plAgeLinkStruct * GetAgeLink() { return &fAgeLink; }
const plAgeLinkStruct * GetAgeLink() const { return &fAgeLink; }
PyObject * GetAgeInfo(); // returns pyAgeInfoStructRef
void SetAgeInfo( pyAgeInfoStruct & info );
void CopyFrom( const pyAgeLinkStruct & other );
void CopyFromRef( const pyAgeLinkStructRef & other );
void SetLinkingRules( int v );
int GetLinkingRules() const;
void SetSpawnPoint( pySpawnPointInfo & v );
void SetSpawnPointRef( pySpawnPointInfoRef & v );
PyObject * GetSpawnPoint(); // returns pySpawnPointInfoRef
};
#endif // pyAgeLinkStruct_h_inc

View File

@ -1,366 +1,366 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyAgeLinkStruct.h"
#include "pySpawnPointInfo.h"
#include <python.h>
// glue functions
PYTHON_CLASS_DEFINITION(ptAgeLinkStruct, pyAgeLinkStruct);
PYTHON_DEFAULT_NEW_DEFINITION(ptAgeLinkStruct, pyAgeLinkStruct)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptAgeLinkStruct)
PYTHON_INIT_DEFINITION(ptAgeLinkStruct, args, keywords)
{
PYTHON_RETURN_INIT_OK;
}
PYTHON_RICH_COMPARE_DEFINITION(ptAgeLinkStruct, obj1, obj2, compareType)
{
if ((obj1 == Py_None) || (obj2 == Py_None) || !pyAgeLinkStruct::Check(obj1) || !pyAgeLinkStruct::Check(obj2))
{
// if they aren't the same type, they don't match, obviously (we also never equal none)
if (compareType == Py_EQ)
PYTHON_RCOMPARE_FALSE;
else if (compareType == Py_NE)
PYTHON_RCOMPARE_TRUE;
else
{
PyErr_SetString(PyExc_NotImplementedError, "invalid comparison for a ptAgeLinkStruct object");
PYTHON_RCOMPARE_ERROR;
}
}
pyAgeLinkStruct *struct1 = pyAgeLinkStruct::ConvertFrom(obj1);
pyAgeLinkStruct *struct2 = pyAgeLinkStruct::ConvertFrom(obj2);
if (compareType == Py_EQ)
{
if ((*struct1) == (*struct2))
PYTHON_RCOMPARE_TRUE;
PYTHON_RCOMPARE_FALSE;
}
else if (compareType == Py_NE)
{
if ((*struct1) != (*struct2))
PYTHON_RCOMPARE_TRUE;
PYTHON_RCOMPARE_FALSE;
}
PyErr_SetString(PyExc_NotImplementedError, "invalid comparison for a ptAgeLinkStruct object");
PYTHON_RCOMPARE_ERROR;
}
PYTHON_METHOD_DEFINITION(ptAgeLinkStruct, copyFrom, args)
{
PyObject* linkStructObj = NULL;
if (!PyArg_ParseTuple(args, "O", &linkStructObj))
{
PyErr_SetString(PyExc_TypeError, "copyFrom expects a ptAgeLinkStruct or ptAgeLinkStructRef");
PYTHON_RETURN_ERROR;
}
if (pyAgeLinkStruct::Check(linkStructObj))
{
pyAgeLinkStruct* linkStruct = pyAgeLinkStruct::ConvertFrom(linkStructObj);
self->fThis->CopyFrom(*linkStruct);
PYTHON_RETURN_NONE;
}
else if (pyAgeLinkStructRef::Check(linkStructObj))
{
pyAgeLinkStructRef* linkStruct = pyAgeLinkStructRef::ConvertFrom(linkStructObj);
self->fThis->CopyFromRef(*linkStruct);
PYTHON_RETURN_NONE;
}
PyErr_SetString(PyExc_TypeError, "copyFrom expects a ptAgeLinkStruct or ptAgeLinkStructRef");
PYTHON_RETURN_ERROR;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeLinkStruct, getAgeInfo)
{
return self->fThis->GetAgeInfo();
}
PYTHON_METHOD_DEFINITION(ptAgeLinkStruct, setAgeInfo, args)
{
PyObject* ageInfoObj = NULL;
if (!PyArg_ParseTuple(args, "O", &ageInfoObj))
{
PyErr_SetString(PyExc_TypeError, "setAgeInfo expects a ptAgeInfoStruct");
PYTHON_RETURN_ERROR;
}
if (!pyAgeInfoStruct::Check(ageInfoObj))
{
PyErr_SetString(PyExc_TypeError, "setAgeInfo expects a ptAgeInfoStruct");
PYTHON_RETURN_ERROR;
}
pyAgeInfoStruct* ageInfo = pyAgeInfoStruct::ConvertFrom(ageInfoObj);
self->fThis->SetAgeInfo(*ageInfo);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeLinkStruct, getParentAgeFilename)
{
return PyString_FromString(self->fThis->GetParentAgeFilename());
}
PYTHON_METHOD_DEFINITION(ptAgeLinkStruct, setParentAgeFilename, args)
{
char* filename;
if (!PyArg_ParseTuple(args, "s", &filename))
{
PyErr_SetString(PyExc_TypeError, "setParentAgeFilename expects a string");
PYTHON_RETURN_ERROR;
}
self->fThis->SetParentAgeFilename(filename);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeLinkStruct, getLinkingRules)
{
return PyInt_FromLong(self->fThis->GetLinkingRules());
}
PYTHON_METHOD_DEFINITION(ptAgeLinkStruct, setLinkingRules, args)
{
int rules;
if (!PyArg_ParseTuple(args, "i", &rules))
{
PyErr_SetString(PyExc_TypeError, "setLinkingRules expects an int");
PYTHON_RETURN_ERROR;
}
self->fThis->SetLinkingRules(rules);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeLinkStruct, getSpawnPoint)
{
return self->fThis->GetSpawnPoint();
}
PYTHON_METHOD_DEFINITION(ptAgeLinkStruct, setSpawnPoint, args)
{
PyObject* spawnPtInfoObj = NULL;
if (!PyArg_ParseTuple(args, "O", &spawnPtInfoObj))
{
PyErr_SetString(PyExc_TypeError, "setSpawnPoint expects a ptSpawnPointInfo or a ptSpawnPointInfoRef");
PYTHON_RETURN_ERROR;
}
if (pySpawnPointInfo::Check(spawnPtInfoObj))
{
pySpawnPointInfo* spawnPt = pySpawnPointInfo::ConvertFrom(spawnPtInfoObj);
self->fThis->SetSpawnPoint(*spawnPt);
PYTHON_RETURN_NONE;
}
else if (pySpawnPointInfoRef::Check(spawnPtInfoObj))
{
pySpawnPointInfoRef* spawnPt = pySpawnPointInfoRef::ConvertFrom(spawnPtInfoObj);
self->fThis->SetSpawnPointRef(*spawnPt);
PYTHON_RETURN_NONE;
}
PyErr_SetString(PyExc_TypeError, "setSpawnPoint expects a ptSpawnPointInfo or a ptSpawnPointInfoRef");
PYTHON_RETURN_ERROR;
}
PYTHON_START_METHODS_TABLE(ptAgeLinkStruct)
PYTHON_METHOD(ptAgeLinkStruct, copyFrom, "Params: other\nCopies data from one ptAgeLinkStruct or ptAgeLinkStructRef to this one"),
PYTHON_METHOD_NOARGS(ptAgeLinkStruct, getAgeInfo, "Returns a ptAgeInfoStructRef of the AgeInfo for this link"),
PYTHON_METHOD(ptAgeLinkStruct, setAgeInfo, "Params: ageInfo\nSets the AgeInfoStruct from the data in ageInfo (a ptAgeInfoStruct)"),
PYTHON_METHOD_NOARGS(ptAgeLinkStruct, getParentAgeFilename, "Returns a string of the parent age filename"),
PYTHON_METHOD(ptAgeLinkStruct, setParentAgeFilename, "Params: filename\nSets the parent age filename for child age links"),
PYTHON_METHOD_NOARGS(ptAgeLinkStruct, getLinkingRules, "Returns the linking rules of this link"),
PYTHON_METHOD(ptAgeLinkStruct, setLinkingRules, "Params: rule\nSets the linking rules for this link"),
PYTHON_METHOD_NOARGS(ptAgeLinkStruct, getSpawnPoint, "Gets the spawn point ptSpawnPointInfoRef of this link"),
PYTHON_METHOD(ptAgeLinkStruct, setSpawnPoint, "Params: spawnPtInfo\nSets the spawn point of this link (a ptSpawnPointInfo or ptSpawnPointInfoRef)"),
PYTHON_END_METHODS_TABLE;
// type structure definition
#define ptAgeLinkStruct_COMPARE PYTHON_NO_COMPARE
#define ptAgeLinkStruct_AS_NUMBER PYTHON_NO_AS_NUMBER
#define ptAgeLinkStruct_AS_SEQUENCE PYTHON_NO_AS_SEQUENCE
#define ptAgeLinkStruct_AS_MAPPING PYTHON_NO_AS_MAPPING
#define ptAgeLinkStruct_STR PYTHON_NO_STR
#define ptAgeLinkStruct_RICH_COMPARE PYTHON_DEFAULT_RICH_COMPARE(ptAgeLinkStruct)
#define ptAgeLinkStruct_GETSET PYTHON_NO_GETSET
#define ptAgeLinkStruct_BASE PYTHON_NO_BASE
PLASMA_CUSTOM_TYPE(ptAgeLinkStruct, "Class to hold the data of the AgeLink structure");
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_IMPL(ptAgeLinkStruct, pyAgeLinkStruct)
PyObject *pyAgeLinkStruct::New(plAgeLinkStruct *link)
{
ptAgeLinkStruct *newObj = (ptAgeLinkStruct*)ptAgeLinkStruct_type.tp_new(&ptAgeLinkStruct_type, NULL, NULL);
newObj->fThis->fAgeLink.CopyFrom(link);
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptAgeLinkStruct, pyAgeLinkStruct)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptAgeLinkStruct, pyAgeLinkStruct)
///////////////////////////////////////////////////////////////////////////
//
// AddPlasmaClasses - the python module definitions
//
void pyAgeLinkStruct::AddPlasmaClasses(PyObject *m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptAgeLinkStruct);
PYTHON_CLASS_IMPORT_END(m);
}
// glue functions
PYTHON_CLASS_DEFINITION(ptAgeLinkStructRef, pyAgeLinkStructRef);
PYTHON_DEFAULT_NEW_DEFINITION(ptAgeLinkStructRef, pyAgeLinkStructRef)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptAgeLinkStructRef)
PYTHON_NO_INIT_DEFINITION(ptAgeLinkStructRef)
PYTHON_METHOD_DEFINITION(ptAgeLinkStructRef, copyFrom, args)
{
PyObject* linkStructObj = NULL;
if (!PyArg_ParseTuple(args, "O", &linkStructObj))
{
PyErr_SetString(PyExc_TypeError, "copyFrom expects a ptAgeLinkStruct or ptAgeLinkStructRef");
PYTHON_RETURN_ERROR;
}
if (pyAgeLinkStruct::Check(linkStructObj))
{
pyAgeLinkStruct* linkStruct = pyAgeLinkStruct::ConvertFrom(linkStructObj);
self->fThis->CopyFrom(*linkStruct);
PYTHON_RETURN_NONE;
}
else if (pyAgeLinkStructRef::Check(linkStructObj))
{
pyAgeLinkStructRef* linkStruct = pyAgeLinkStructRef::ConvertFrom(linkStructObj);
self->fThis->CopyFromRef(*linkStruct);
PYTHON_RETURN_NONE;
}
PyErr_SetString(PyExc_TypeError, "copyFrom expects a ptAgeLinkStruct or ptAgeLinkStructRef");
PYTHON_RETURN_ERROR;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeLinkStructRef, getAgeInfo)
{
return self->fThis->GetAgeInfo();
}
PYTHON_METHOD_DEFINITION(ptAgeLinkStructRef, setAgeInfo, args)
{
PyObject* ageInfoObj = NULL;
if (!PyArg_ParseTuple(args, "O", &ageInfoObj))
{
PyErr_SetString(PyExc_TypeError, "setAgeInfo expects a ptAgeInfoStruct");
PYTHON_RETURN_ERROR;
}
if (!pyAgeInfoStruct::Check(ageInfoObj))
{
PyErr_SetString(PyExc_TypeError, "setAgeInfo expects a ptAgeInfoStruct");
PYTHON_RETURN_ERROR;
}
pyAgeInfoStruct* ageInfo = pyAgeInfoStruct::ConvertFrom(ageInfoObj);
self->fThis->SetAgeInfo(*ageInfo);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeLinkStructRef, getLinkingRules)
{
return PyInt_FromLong(self->fThis->GetLinkingRules());
}
PYTHON_METHOD_DEFINITION(ptAgeLinkStructRef, setLinkingRules, args)
{
int rules;
if (!PyArg_ParseTuple(args, "i", &rules))
{
PyErr_SetString(PyExc_TypeError, "setLinkingRules expects an int");
PYTHON_RETURN_ERROR;
}
self->fThis->SetLinkingRules(rules);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeLinkStructRef, getSpawnPoint)
{
return self->fThis->GetSpawnPoint();
}
PYTHON_METHOD_DEFINITION(ptAgeLinkStructRef, setSpawnPoint, args)
{
PyObject* spawnPtInfoObj = NULL;
if (!PyArg_ParseTuple(args, "O", &spawnPtInfoObj))
{
PyErr_SetString(PyExc_TypeError, "setSpawnPoint expects a ptSpawnPointInfo or a ptSpawnPointInfoRef");
PYTHON_RETURN_ERROR;
}
if (pySpawnPointInfo::Check(spawnPtInfoObj))
{
pySpawnPointInfo* spawnPt = pySpawnPointInfo::ConvertFrom(spawnPtInfoObj);
self->fThis->SetSpawnPoint(*spawnPt);
PYTHON_RETURN_NONE;
}
else if (pySpawnPointInfoRef::Check(spawnPtInfoObj))
{
pySpawnPointInfoRef* spawnPt = pySpawnPointInfoRef::ConvertFrom(spawnPtInfoObj);
self->fThis->SetSpawnPointRef(*spawnPt);
PYTHON_RETURN_NONE;
}
PyErr_SetString(PyExc_TypeError, "setSpawnPoint expects a ptSpawnPointInfo or a ptSpawnPointInfoRef");
PYTHON_RETURN_ERROR;
}
PYTHON_START_METHODS_TABLE(ptAgeLinkStructRef)
PYTHON_METHOD(ptAgeLinkStructRef, copyFrom, "Params: other\nCopies data from one ptAgeLinkStruct or ptAgeLinkStructRef to this one"),
PYTHON_METHOD_NOARGS(ptAgeLinkStructRef, getAgeInfo, "Returns a ptAgeInfoStructRef of the AgeInfo for this link"),
PYTHON_METHOD(ptAgeLinkStructRef, setAgeInfo, "Params: ageInfo\nSets the AgeInfoStruct from the data in ageInfo (a ptAgeInfoStruct)"),
PYTHON_METHOD_NOARGS(ptAgeLinkStructRef, getLinkingRules, "Returns the linking rules of this link"),
PYTHON_METHOD(ptAgeLinkStructRef, setLinkingRules, "Params: rule\nSets the linking rules for this link"),
PYTHON_METHOD_NOARGS(ptAgeLinkStructRef, getSpawnPoint, "Gets the spawn point ptSpawnPointInfoRef of this link"),
PYTHON_METHOD(ptAgeLinkStructRef, setSpawnPoint, "Params: spawnPtInfo\nSets the spawn point of this link (a ptSpawnPointInfo or ptSpawnPointInfoRef)"),
PYTHON_END_METHODS_TABLE;
// type structure definition
PLASMA_DEFAULT_TYPE(ptAgeLinkStructRef, "Class to hold the data of the AgeLink structure");
// required functions for PyObject interoperability
PyObject *pyAgeLinkStructRef::New(plAgeLinkStruct &link)
{
ptAgeLinkStructRef *newObj = (ptAgeLinkStructRef*)ptAgeLinkStructRef_type.tp_new(&ptAgeLinkStructRef_type, NULL, NULL);
newObj->fThis->fAgeLink = link;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptAgeLinkStructRef, pyAgeLinkStructRef)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptAgeLinkStructRef, pyAgeLinkStructRef)
///////////////////////////////////////////////////////////////////////////
//
// AddPlasmaClasses - the python module definitions
//
void pyAgeLinkStructRef::AddPlasmaClasses(PyObject *m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptAgeLinkStructRef);
PYTHON_CLASS_IMPORT_END(m);
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyAgeLinkStruct.h"
#include "pySpawnPointInfo.h"
#include <python.h>
// glue functions
PYTHON_CLASS_DEFINITION(ptAgeLinkStruct, pyAgeLinkStruct);
PYTHON_DEFAULT_NEW_DEFINITION(ptAgeLinkStruct, pyAgeLinkStruct)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptAgeLinkStruct)
PYTHON_INIT_DEFINITION(ptAgeLinkStruct, args, keywords)
{
PYTHON_RETURN_INIT_OK;
}
PYTHON_RICH_COMPARE_DEFINITION(ptAgeLinkStruct, obj1, obj2, compareType)
{
if ((obj1 == Py_None) || (obj2 == Py_None) || !pyAgeLinkStruct::Check(obj1) || !pyAgeLinkStruct::Check(obj2))
{
// if they aren't the same type, they don't match, obviously (we also never equal none)
if (compareType == Py_EQ)
PYTHON_RCOMPARE_FALSE;
else if (compareType == Py_NE)
PYTHON_RCOMPARE_TRUE;
else
{
PyErr_SetString(PyExc_NotImplementedError, "invalid comparison for a ptAgeLinkStruct object");
PYTHON_RCOMPARE_ERROR;
}
}
pyAgeLinkStruct *struct1 = pyAgeLinkStruct::ConvertFrom(obj1);
pyAgeLinkStruct *struct2 = pyAgeLinkStruct::ConvertFrom(obj2);
if (compareType == Py_EQ)
{
if ((*struct1) == (*struct2))
PYTHON_RCOMPARE_TRUE;
PYTHON_RCOMPARE_FALSE;
}
else if (compareType == Py_NE)
{
if ((*struct1) != (*struct2))
PYTHON_RCOMPARE_TRUE;
PYTHON_RCOMPARE_FALSE;
}
PyErr_SetString(PyExc_NotImplementedError, "invalid comparison for a ptAgeLinkStruct object");
PYTHON_RCOMPARE_ERROR;
}
PYTHON_METHOD_DEFINITION(ptAgeLinkStruct, copyFrom, args)
{
PyObject* linkStructObj = NULL;
if (!PyArg_ParseTuple(args, "O", &linkStructObj))
{
PyErr_SetString(PyExc_TypeError, "copyFrom expects a ptAgeLinkStruct or ptAgeLinkStructRef");
PYTHON_RETURN_ERROR;
}
if (pyAgeLinkStruct::Check(linkStructObj))
{
pyAgeLinkStruct* linkStruct = pyAgeLinkStruct::ConvertFrom(linkStructObj);
self->fThis->CopyFrom(*linkStruct);
PYTHON_RETURN_NONE;
}
else if (pyAgeLinkStructRef::Check(linkStructObj))
{
pyAgeLinkStructRef* linkStruct = pyAgeLinkStructRef::ConvertFrom(linkStructObj);
self->fThis->CopyFromRef(*linkStruct);
PYTHON_RETURN_NONE;
}
PyErr_SetString(PyExc_TypeError, "copyFrom expects a ptAgeLinkStruct or ptAgeLinkStructRef");
PYTHON_RETURN_ERROR;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeLinkStruct, getAgeInfo)
{
return self->fThis->GetAgeInfo();
}
PYTHON_METHOD_DEFINITION(ptAgeLinkStruct, setAgeInfo, args)
{
PyObject* ageInfoObj = NULL;
if (!PyArg_ParseTuple(args, "O", &ageInfoObj))
{
PyErr_SetString(PyExc_TypeError, "setAgeInfo expects a ptAgeInfoStruct");
PYTHON_RETURN_ERROR;
}
if (!pyAgeInfoStruct::Check(ageInfoObj))
{
PyErr_SetString(PyExc_TypeError, "setAgeInfo expects a ptAgeInfoStruct");
PYTHON_RETURN_ERROR;
}
pyAgeInfoStruct* ageInfo = pyAgeInfoStruct::ConvertFrom(ageInfoObj);
self->fThis->SetAgeInfo(*ageInfo);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeLinkStruct, getParentAgeFilename)
{
return PyString_FromString(self->fThis->GetParentAgeFilename());
}
PYTHON_METHOD_DEFINITION(ptAgeLinkStruct, setParentAgeFilename, args)
{
char* filename;
if (!PyArg_ParseTuple(args, "s", &filename))
{
PyErr_SetString(PyExc_TypeError, "setParentAgeFilename expects a string");
PYTHON_RETURN_ERROR;
}
self->fThis->SetParentAgeFilename(filename);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeLinkStruct, getLinkingRules)
{
return PyInt_FromLong(self->fThis->GetLinkingRules());
}
PYTHON_METHOD_DEFINITION(ptAgeLinkStruct, setLinkingRules, args)
{
int rules;
if (!PyArg_ParseTuple(args, "i", &rules))
{
PyErr_SetString(PyExc_TypeError, "setLinkingRules expects an int");
PYTHON_RETURN_ERROR;
}
self->fThis->SetLinkingRules(rules);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeLinkStruct, getSpawnPoint)
{
return self->fThis->GetSpawnPoint();
}
PYTHON_METHOD_DEFINITION(ptAgeLinkStruct, setSpawnPoint, args)
{
PyObject* spawnPtInfoObj = NULL;
if (!PyArg_ParseTuple(args, "O", &spawnPtInfoObj))
{
PyErr_SetString(PyExc_TypeError, "setSpawnPoint expects a ptSpawnPointInfo or a ptSpawnPointInfoRef");
PYTHON_RETURN_ERROR;
}
if (pySpawnPointInfo::Check(spawnPtInfoObj))
{
pySpawnPointInfo* spawnPt = pySpawnPointInfo::ConvertFrom(spawnPtInfoObj);
self->fThis->SetSpawnPoint(*spawnPt);
PYTHON_RETURN_NONE;
}
else if (pySpawnPointInfoRef::Check(spawnPtInfoObj))
{
pySpawnPointInfoRef* spawnPt = pySpawnPointInfoRef::ConvertFrom(spawnPtInfoObj);
self->fThis->SetSpawnPointRef(*spawnPt);
PYTHON_RETURN_NONE;
}
PyErr_SetString(PyExc_TypeError, "setSpawnPoint expects a ptSpawnPointInfo or a ptSpawnPointInfoRef");
PYTHON_RETURN_ERROR;
}
PYTHON_START_METHODS_TABLE(ptAgeLinkStruct)
PYTHON_METHOD(ptAgeLinkStruct, copyFrom, "Params: other\nCopies data from one ptAgeLinkStruct or ptAgeLinkStructRef to this one"),
PYTHON_METHOD_NOARGS(ptAgeLinkStruct, getAgeInfo, "Returns a ptAgeInfoStructRef of the AgeInfo for this link"),
PYTHON_METHOD(ptAgeLinkStruct, setAgeInfo, "Params: ageInfo\nSets the AgeInfoStruct from the data in ageInfo (a ptAgeInfoStruct)"),
PYTHON_METHOD_NOARGS(ptAgeLinkStruct, getParentAgeFilename, "Returns a string of the parent age filename"),
PYTHON_METHOD(ptAgeLinkStruct, setParentAgeFilename, "Params: filename\nSets the parent age filename for child age links"),
PYTHON_METHOD_NOARGS(ptAgeLinkStruct, getLinkingRules, "Returns the linking rules of this link"),
PYTHON_METHOD(ptAgeLinkStruct, setLinkingRules, "Params: rule\nSets the linking rules for this link"),
PYTHON_METHOD_NOARGS(ptAgeLinkStruct, getSpawnPoint, "Gets the spawn point ptSpawnPointInfoRef of this link"),
PYTHON_METHOD(ptAgeLinkStruct, setSpawnPoint, "Params: spawnPtInfo\nSets the spawn point of this link (a ptSpawnPointInfo or ptSpawnPointInfoRef)"),
PYTHON_END_METHODS_TABLE;
// type structure definition
#define ptAgeLinkStruct_COMPARE PYTHON_NO_COMPARE
#define ptAgeLinkStruct_AS_NUMBER PYTHON_NO_AS_NUMBER
#define ptAgeLinkStruct_AS_SEQUENCE PYTHON_NO_AS_SEQUENCE
#define ptAgeLinkStruct_AS_MAPPING PYTHON_NO_AS_MAPPING
#define ptAgeLinkStruct_STR PYTHON_NO_STR
#define ptAgeLinkStruct_RICH_COMPARE PYTHON_DEFAULT_RICH_COMPARE(ptAgeLinkStruct)
#define ptAgeLinkStruct_GETSET PYTHON_NO_GETSET
#define ptAgeLinkStruct_BASE PYTHON_NO_BASE
PLASMA_CUSTOM_TYPE(ptAgeLinkStruct, "Class to hold the data of the AgeLink structure");
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_IMPL(ptAgeLinkStruct, pyAgeLinkStruct)
PyObject *pyAgeLinkStruct::New(plAgeLinkStruct *link)
{
ptAgeLinkStruct *newObj = (ptAgeLinkStruct*)ptAgeLinkStruct_type.tp_new(&ptAgeLinkStruct_type, NULL, NULL);
newObj->fThis->fAgeLink.CopyFrom(link);
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptAgeLinkStruct, pyAgeLinkStruct)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptAgeLinkStruct, pyAgeLinkStruct)
///////////////////////////////////////////////////////////////////////////
//
// AddPlasmaClasses - the python module definitions
//
void pyAgeLinkStruct::AddPlasmaClasses(PyObject *m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptAgeLinkStruct);
PYTHON_CLASS_IMPORT_END(m);
}
// glue functions
PYTHON_CLASS_DEFINITION(ptAgeLinkStructRef, pyAgeLinkStructRef);
PYTHON_DEFAULT_NEW_DEFINITION(ptAgeLinkStructRef, pyAgeLinkStructRef)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptAgeLinkStructRef)
PYTHON_NO_INIT_DEFINITION(ptAgeLinkStructRef)
PYTHON_METHOD_DEFINITION(ptAgeLinkStructRef, copyFrom, args)
{
PyObject* linkStructObj = NULL;
if (!PyArg_ParseTuple(args, "O", &linkStructObj))
{
PyErr_SetString(PyExc_TypeError, "copyFrom expects a ptAgeLinkStruct or ptAgeLinkStructRef");
PYTHON_RETURN_ERROR;
}
if (pyAgeLinkStruct::Check(linkStructObj))
{
pyAgeLinkStruct* linkStruct = pyAgeLinkStruct::ConvertFrom(linkStructObj);
self->fThis->CopyFrom(*linkStruct);
PYTHON_RETURN_NONE;
}
else if (pyAgeLinkStructRef::Check(linkStructObj))
{
pyAgeLinkStructRef* linkStruct = pyAgeLinkStructRef::ConvertFrom(linkStructObj);
self->fThis->CopyFromRef(*linkStruct);
PYTHON_RETURN_NONE;
}
PyErr_SetString(PyExc_TypeError, "copyFrom expects a ptAgeLinkStruct or ptAgeLinkStructRef");
PYTHON_RETURN_ERROR;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeLinkStructRef, getAgeInfo)
{
return self->fThis->GetAgeInfo();
}
PYTHON_METHOD_DEFINITION(ptAgeLinkStructRef, setAgeInfo, args)
{
PyObject* ageInfoObj = NULL;
if (!PyArg_ParseTuple(args, "O", &ageInfoObj))
{
PyErr_SetString(PyExc_TypeError, "setAgeInfo expects a ptAgeInfoStruct");
PYTHON_RETURN_ERROR;
}
if (!pyAgeInfoStruct::Check(ageInfoObj))
{
PyErr_SetString(PyExc_TypeError, "setAgeInfo expects a ptAgeInfoStruct");
PYTHON_RETURN_ERROR;
}
pyAgeInfoStruct* ageInfo = pyAgeInfoStruct::ConvertFrom(ageInfoObj);
self->fThis->SetAgeInfo(*ageInfo);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeLinkStructRef, getLinkingRules)
{
return PyInt_FromLong(self->fThis->GetLinkingRules());
}
PYTHON_METHOD_DEFINITION(ptAgeLinkStructRef, setLinkingRules, args)
{
int rules;
if (!PyArg_ParseTuple(args, "i", &rules))
{
PyErr_SetString(PyExc_TypeError, "setLinkingRules expects an int");
PYTHON_RETURN_ERROR;
}
self->fThis->SetLinkingRules(rules);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeLinkStructRef, getSpawnPoint)
{
return self->fThis->GetSpawnPoint();
}
PYTHON_METHOD_DEFINITION(ptAgeLinkStructRef, setSpawnPoint, args)
{
PyObject* spawnPtInfoObj = NULL;
if (!PyArg_ParseTuple(args, "O", &spawnPtInfoObj))
{
PyErr_SetString(PyExc_TypeError, "setSpawnPoint expects a ptSpawnPointInfo or a ptSpawnPointInfoRef");
PYTHON_RETURN_ERROR;
}
if (pySpawnPointInfo::Check(spawnPtInfoObj))
{
pySpawnPointInfo* spawnPt = pySpawnPointInfo::ConvertFrom(spawnPtInfoObj);
self->fThis->SetSpawnPoint(*spawnPt);
PYTHON_RETURN_NONE;
}
else if (pySpawnPointInfoRef::Check(spawnPtInfoObj))
{
pySpawnPointInfoRef* spawnPt = pySpawnPointInfoRef::ConvertFrom(spawnPtInfoObj);
self->fThis->SetSpawnPointRef(*spawnPt);
PYTHON_RETURN_NONE;
}
PyErr_SetString(PyExc_TypeError, "setSpawnPoint expects a ptSpawnPointInfo or a ptSpawnPointInfoRef");
PYTHON_RETURN_ERROR;
}
PYTHON_START_METHODS_TABLE(ptAgeLinkStructRef)
PYTHON_METHOD(ptAgeLinkStructRef, copyFrom, "Params: other\nCopies data from one ptAgeLinkStruct or ptAgeLinkStructRef to this one"),
PYTHON_METHOD_NOARGS(ptAgeLinkStructRef, getAgeInfo, "Returns a ptAgeInfoStructRef of the AgeInfo for this link"),
PYTHON_METHOD(ptAgeLinkStructRef, setAgeInfo, "Params: ageInfo\nSets the AgeInfoStruct from the data in ageInfo (a ptAgeInfoStruct)"),
PYTHON_METHOD_NOARGS(ptAgeLinkStructRef, getLinkingRules, "Returns the linking rules of this link"),
PYTHON_METHOD(ptAgeLinkStructRef, setLinkingRules, "Params: rule\nSets the linking rules for this link"),
PYTHON_METHOD_NOARGS(ptAgeLinkStructRef, getSpawnPoint, "Gets the spawn point ptSpawnPointInfoRef of this link"),
PYTHON_METHOD(ptAgeLinkStructRef, setSpawnPoint, "Params: spawnPtInfo\nSets the spawn point of this link (a ptSpawnPointInfo or ptSpawnPointInfoRef)"),
PYTHON_END_METHODS_TABLE;
// type structure definition
PLASMA_DEFAULT_TYPE(ptAgeLinkStructRef, "Class to hold the data of the AgeLink structure");
// required functions for PyObject interoperability
PyObject *pyAgeLinkStructRef::New(plAgeLinkStruct &link)
{
ptAgeLinkStructRef *newObj = (ptAgeLinkStructRef*)ptAgeLinkStructRef_type.tp_new(&ptAgeLinkStructRef_type, NULL, NULL);
newObj->fThis->fAgeLink = link;
return (PyObject*)newObj;
}
PYTHON_CLASS_CHECK_IMPL(ptAgeLinkStructRef, pyAgeLinkStructRef)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptAgeLinkStructRef, pyAgeLinkStructRef)
///////////////////////////////////////////////////////////////////////////
//
// AddPlasmaClasses - the python module definitions
//
void pyAgeLinkStructRef::AddPlasmaClasses(PyObject *m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptAgeLinkStructRef);
PYTHON_CLASS_IMPORT_END(m);
}

View File

@ -1,329 +1,329 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////
//
// pyAgeVault - a wrapper class to provide interface to the plVaultAgeNode
//
//////////////////////////////////////////////////////////////////////
#include "pyAgeVault.h"
#include "pyVault.h"
#include "pyVaultNodeRef.h"
#include "pyVaultFolderNode.h"
#include "pyVaultPlayerInfoListNode.h"
#include "pyVaultPlayerInfoNode.h"
#include "pyVaultAgeInfoNode.h"
#include "pyVaultAgeLinkNode.h"
#include "pyVaultChronicleNode.h"
#include "pyVaultTextNoteNode.h"
#include "pyNetLinkingMgr.h"
#include "pyAgeInfoStruct.h"
#include "pySDL.h"
#include "plVault/plVault.h"
#include "plNetClient/plNetClientMgr.h"
#include "plNetClient/plNetLinkingMgr.h"
#include "plNetTransport/plNetTransport.h"
#include "plNetTransport/plNetTransportMember.h"
#include "plSDL/plSDL.h"
#include "pnNetCommon/plNetApp.h"
pyAgeVault::pyAgeVault() {
}
pyAgeVault::~pyAgeVault() {
}
//////////////////////////////////////////////////
PyObject* pyAgeVault::GetAgeInfo()
{
RelVaultNode * rvn = VaultGetAgeInfoNodeIncRef();
if (rvn) {
PyObject * result = pyVaultAgeInfoNode::New(rvn);
rvn->DecRef();
return result;
}
// just return a None object
PYTHON_RETURN_NONE;
}
PyObject* pyAgeVault::GetAgeDevicesFolder( void )
{
RelVaultNode * rvn = VaultGetAgeDevicesFolderIncRef();
if (rvn) {
PyObject * result = pyVaultFolderNode::New(rvn);
rvn->DecRef();
return result;
}
// just return a None object
PYTHON_RETURN_NONE;
}
PyObject* pyAgeVault::GetSubAgesFolder( void )
{
RelVaultNode * rvn = VaultGetAgeSubAgesFolderIncRef();
if (rvn) {
PyObject * result = pyVaultFolderNode::New(rvn);
rvn->DecRef();
return result;
}
// just return a None object
PYTHON_RETURN_NONE;
}
PyObject* pyAgeVault::GetChronicleFolder( void )
{
RelVaultNode * rvn = VaultGetAgeChronicleFolderIncRef();
if (rvn) {
PyObject * result = pyVaultFolderNode::New(rvn);
rvn->DecRef();
return result;
}
// just return a None object
PYTHON_RETURN_NONE;
}
PyObject* pyAgeVault::GetBookshelfFolder ( void )
{
RelVaultNode * rvn = VaultAgeGetBookshelfFolderIncRef();
if (rvn) {
PyObject * result = pyVaultFolderNode::New(rvn);
rvn->DecRef();
return result;
}
// just return a None object
PYTHON_RETURN_NONE;
}
PyObject* pyAgeVault::GetPeopleIKnowAboutFolder( void )
{
RelVaultNode * rvn = VaultGetAgePeopleIKnowAboutFolderIncRef();
if (rvn) {
PyObject * result = pyVaultFolderNode::New(rvn);
rvn->DecRef();
return result;
}
// just return a None object
PYTHON_RETURN_NONE;
}
PyObject* pyAgeVault::GetPublicAgesFolder(void)
{
RelVaultNode * rvn = VaultGetAgePublicAgesFolderIncRef();
if (rvn) {
PyObject * result = pyVaultFolderNode::New(rvn);
rvn->DecRef();
return result;
}
// just return a None object
PYTHON_RETURN_NONE;
}
PyObject* pyAgeVault::GetSubAgeLink( const pyAgeInfoStruct & info )
{
RelVaultNode * rvn = VaultFindAgeSubAgeLinkIncRef(info.GetAgeInfo());
if (rvn) {
PyObject * result = pyVaultAgeLinkNode::New(rvn);
rvn->DecRef();
return result;
}
// just return a None object
PYTHON_RETURN_NONE;
}
const char* pyAgeVault::GetAgeGuid( void )
{
RelVaultNode * rvn = VaultGetAgeInfoNodeIncRef();
if (rvn) {
VaultAgeInfoNode ageInfo(rvn);
GuidToString(ageInfo.ageInstUuid, fAgeGuid, arrsize(fAgeGuid));
rvn->DecRef();
}
else {
fAgeGuid[0] = 0;
}
return fAgeGuid;
}
///////////////
// Chronicle
PyObject* pyAgeVault::FindChronicleEntry( const char * entryName )
{
wchar wEntryName[kMaxVaultNodeStringLength];
StrToUnicode(wEntryName, entryName, arrsize(wEntryName));
if (RelVaultNode * rvn = VaultFindAgeChronicleEntryIncRef(wEntryName)) {
PyObject * result = pyVaultChronicleNode::New(rvn);
rvn->DecRef();
return result;
}
// just return a None object
PYTHON_RETURN_NONE;
}
void pyAgeVault::AddChronicleEntry( const char * name, UInt32 type, const char * value )
{
wchar * wEntryName = StrDupToUnicode(name);
wchar * wEntryValue = StrDupToUnicode(value);
VaultAddAgeChronicleEntry(wEntryName, type, wEntryValue);
FREE(wEntryName);
FREE(wEntryValue);
}
// AGE DEVICES. AKA IMAGERS, WHATEVER.
// Add a new device.
void pyAgeVault::AddDevice( const char * deviceName, PyObject * cbObject, UInt32 cbContext )
{
pyVaultNode::pyVaultNodeOperationCallback * cb = NEWZERO(pyVaultNode::pyVaultNodeOperationCallback)( cbObject );
cb->VaultOperationStarted( cbContext );
wchar wStr[MAX_PATH];
StrToUnicode(wStr, deviceName, arrsize(wStr));
if (RelVaultNode * rvn = VaultAgeAddDeviceAndWaitIncRef(wStr)) {
cb->SetNode(rvn);
rvn->DecRef();
}
cb->VaultOperationComplete( cbContext, cb->GetNode() ? hsOK : hsFail); // cbHolder deletes itself here.
}
// Remove a device.
void pyAgeVault::RemoveDevice( const char * deviceName )
{
wchar wStr[MAX_PATH];
StrToUnicode(wStr, deviceName, arrsize(wStr));
VaultAgeRemoveDevice(wStr);
}
// True if device exists in age.
bool pyAgeVault::HasDevice( const char * deviceName )
{
wchar wStr[MAX_PATH];
StrToUnicode(wStr, deviceName, arrsize(wStr));
return VaultAgeHasDevice(wStr);
}
PyObject * pyAgeVault::GetDevice( const char * deviceName )
{
wchar wStr[MAX_PATH];
StrToUnicode(wStr, deviceName, arrsize(wStr));
if (RelVaultNode * rvn = VaultAgeGetDeviceIncRef(wStr)) {
PyObject * result = pyVaultTextNoteNode::New(rvn);
rvn->DecRef();
return result;
}
PYTHON_RETURN_NONE;
}
// Sets the inbox associated with a device.
void pyAgeVault::SetDeviceInbox( const char * deviceName, const char * inboxName, PyObject * cbObject, UInt32 cbContext )
{
pyVaultNode::pyVaultNodeOperationCallback * cb = NEWZERO(pyVaultNode::pyVaultNodeOperationCallback)( cbObject );
cb->VaultOperationStarted( cbContext );
wchar wDev[MAX_PATH];
StrToUnicode(wDev, deviceName, arrsize(wDev));
wchar wInb[MAX_PATH];
StrToUnicode(wInb, inboxName, arrsize(wInb));
if (RelVaultNode * rvn = VaultAgeSetDeviceInboxAndWaitIncRef(wDev, wInb)) {
cb->SetNode(rvn);
rvn->DecRef();
}
cb->VaultOperationComplete( cbContext, cb->GetNode() ? hsOK : hsFail ); // cbHolder deletes itself here.
}
PyObject * pyAgeVault::GetDeviceInbox( const char * deviceName )
{
wchar wStr[MAX_PATH];
StrToUnicode(wStr, deviceName, arrsize(wStr));
if (RelVaultNode * rvn = VaultAgeGetDeviceInboxIncRef(wStr)) {
PyObject * result = pyVaultTextNoteNode::New(rvn);
rvn->DecRef();
return result;
}
PYTHON_RETURN_NONE;
}
PyObject * pyAgeVault::GetAgeSDL() const
{
plStateDataRecord * rec = NEWZERO(plStateDataRecord);
if (!VaultAgeGetAgeSDL(rec)) {
DEL(rec);
PYTHON_RETURN_NONE;
}
else {
return pySDLStateDataRecord::New( rec );
}
}
void pyAgeVault::UpdateAgeSDL( pySDLStateDataRecord & pyrec )
{
plStateDataRecord * rec = pyrec.GetRec();
if ( !rec )
return;
VaultAgeUpdateAgeSDL(rec);
}
PyObject* pyAgeVault::FindNode( pyVaultNode* templateNode ) const
{
if (RelVaultNode * rvn = VaultGetAgeNodeIncRef()) {
RelVaultNode * find = rvn->GetChildNodeIncRef(templateNode->fNode, 1);
rvn->DecRef();
if (find) {
PyObject * result = pyVaultNode::New(find);
find->DecRef();
return result;
}
}
PYTHON_RETURN_NONE;
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////
//
// pyAgeVault - a wrapper class to provide interface to the plVaultAgeNode
//
//////////////////////////////////////////////////////////////////////
#include "pyAgeVault.h"
#include "pyVault.h"
#include "pyVaultNodeRef.h"
#include "pyVaultFolderNode.h"
#include "pyVaultPlayerInfoListNode.h"
#include "pyVaultPlayerInfoNode.h"
#include "pyVaultAgeInfoNode.h"
#include "pyVaultAgeLinkNode.h"
#include "pyVaultChronicleNode.h"
#include "pyVaultTextNoteNode.h"
#include "pyNetLinkingMgr.h"
#include "pyAgeInfoStruct.h"
#include "pySDL.h"
#include "plVault/plVault.h"
#include "plNetClient/plNetClientMgr.h"
#include "plNetClient/plNetLinkingMgr.h"
#include "plNetTransport/plNetTransport.h"
#include "plNetTransport/plNetTransportMember.h"
#include "plSDL/plSDL.h"
#include "pnNetCommon/plNetApp.h"
pyAgeVault::pyAgeVault() {
}
pyAgeVault::~pyAgeVault() {
}
//////////////////////////////////////////////////
PyObject* pyAgeVault::GetAgeInfo()
{
RelVaultNode * rvn = VaultGetAgeInfoNodeIncRef();
if (rvn) {
PyObject * result = pyVaultAgeInfoNode::New(rvn);
rvn->DecRef();
return result;
}
// just return a None object
PYTHON_RETURN_NONE;
}
PyObject* pyAgeVault::GetAgeDevicesFolder( void )
{
RelVaultNode * rvn = VaultGetAgeDevicesFolderIncRef();
if (rvn) {
PyObject * result = pyVaultFolderNode::New(rvn);
rvn->DecRef();
return result;
}
// just return a None object
PYTHON_RETURN_NONE;
}
PyObject* pyAgeVault::GetSubAgesFolder( void )
{
RelVaultNode * rvn = VaultGetAgeSubAgesFolderIncRef();
if (rvn) {
PyObject * result = pyVaultFolderNode::New(rvn);
rvn->DecRef();
return result;
}
// just return a None object
PYTHON_RETURN_NONE;
}
PyObject* pyAgeVault::GetChronicleFolder( void )
{
RelVaultNode * rvn = VaultGetAgeChronicleFolderIncRef();
if (rvn) {
PyObject * result = pyVaultFolderNode::New(rvn);
rvn->DecRef();
return result;
}
// just return a None object
PYTHON_RETURN_NONE;
}
PyObject* pyAgeVault::GetBookshelfFolder ( void )
{
RelVaultNode * rvn = VaultAgeGetBookshelfFolderIncRef();
if (rvn) {
PyObject * result = pyVaultFolderNode::New(rvn);
rvn->DecRef();
return result;
}
// just return a None object
PYTHON_RETURN_NONE;
}
PyObject* pyAgeVault::GetPeopleIKnowAboutFolder( void )
{
RelVaultNode * rvn = VaultGetAgePeopleIKnowAboutFolderIncRef();
if (rvn) {
PyObject * result = pyVaultFolderNode::New(rvn);
rvn->DecRef();
return result;
}
// just return a None object
PYTHON_RETURN_NONE;
}
PyObject* pyAgeVault::GetPublicAgesFolder(void)
{
RelVaultNode * rvn = VaultGetAgePublicAgesFolderIncRef();
if (rvn) {
PyObject * result = pyVaultFolderNode::New(rvn);
rvn->DecRef();
return result;
}
// just return a None object
PYTHON_RETURN_NONE;
}
PyObject* pyAgeVault::GetSubAgeLink( const pyAgeInfoStruct & info )
{
RelVaultNode * rvn = VaultFindAgeSubAgeLinkIncRef(info.GetAgeInfo());
if (rvn) {
PyObject * result = pyVaultAgeLinkNode::New(rvn);
rvn->DecRef();
return result;
}
// just return a None object
PYTHON_RETURN_NONE;
}
const char* pyAgeVault::GetAgeGuid( void )
{
RelVaultNode * rvn = VaultGetAgeInfoNodeIncRef();
if (rvn) {
VaultAgeInfoNode ageInfo(rvn);
GuidToString(ageInfo.ageInstUuid, fAgeGuid, arrsize(fAgeGuid));
rvn->DecRef();
}
else {
fAgeGuid[0] = 0;
}
return fAgeGuid;
}
///////////////
// Chronicle
PyObject* pyAgeVault::FindChronicleEntry( const char * entryName )
{
wchar wEntryName[kMaxVaultNodeStringLength];
StrToUnicode(wEntryName, entryName, arrsize(wEntryName));
if (RelVaultNode * rvn = VaultFindAgeChronicleEntryIncRef(wEntryName)) {
PyObject * result = pyVaultChronicleNode::New(rvn);
rvn->DecRef();
return result;
}
// just return a None object
PYTHON_RETURN_NONE;
}
void pyAgeVault::AddChronicleEntry( const char * name, UInt32 type, const char * value )
{
wchar * wEntryName = StrDupToUnicode(name);
wchar * wEntryValue = StrDupToUnicode(value);
VaultAddAgeChronicleEntry(wEntryName, type, wEntryValue);
FREE(wEntryName);
FREE(wEntryValue);
}
// AGE DEVICES. AKA IMAGERS, WHATEVER.
// Add a new device.
void pyAgeVault::AddDevice( const char * deviceName, PyObject * cbObject, UInt32 cbContext )
{
pyVaultNode::pyVaultNodeOperationCallback * cb = NEWZERO(pyVaultNode::pyVaultNodeOperationCallback)( cbObject );
cb->VaultOperationStarted( cbContext );
wchar wStr[MAX_PATH];
StrToUnicode(wStr, deviceName, arrsize(wStr));
if (RelVaultNode * rvn = VaultAgeAddDeviceAndWaitIncRef(wStr)) {
cb->SetNode(rvn);
rvn->DecRef();
}
cb->VaultOperationComplete( cbContext, cb->GetNode() ? hsOK : hsFail); // cbHolder deletes itself here.
}
// Remove a device.
void pyAgeVault::RemoveDevice( const char * deviceName )
{
wchar wStr[MAX_PATH];
StrToUnicode(wStr, deviceName, arrsize(wStr));
VaultAgeRemoveDevice(wStr);
}
// True if device exists in age.
bool pyAgeVault::HasDevice( const char * deviceName )
{
wchar wStr[MAX_PATH];
StrToUnicode(wStr, deviceName, arrsize(wStr));
return VaultAgeHasDevice(wStr);
}
PyObject * pyAgeVault::GetDevice( const char * deviceName )
{
wchar wStr[MAX_PATH];
StrToUnicode(wStr, deviceName, arrsize(wStr));
if (RelVaultNode * rvn = VaultAgeGetDeviceIncRef(wStr)) {
PyObject * result = pyVaultTextNoteNode::New(rvn);
rvn->DecRef();
return result;
}
PYTHON_RETURN_NONE;
}
// Sets the inbox associated with a device.
void pyAgeVault::SetDeviceInbox( const char * deviceName, const char * inboxName, PyObject * cbObject, UInt32 cbContext )
{
pyVaultNode::pyVaultNodeOperationCallback * cb = NEWZERO(pyVaultNode::pyVaultNodeOperationCallback)( cbObject );
cb->VaultOperationStarted( cbContext );
wchar wDev[MAX_PATH];
StrToUnicode(wDev, deviceName, arrsize(wDev));
wchar wInb[MAX_PATH];
StrToUnicode(wInb, inboxName, arrsize(wInb));
if (RelVaultNode * rvn = VaultAgeSetDeviceInboxAndWaitIncRef(wDev, wInb)) {
cb->SetNode(rvn);
rvn->DecRef();
}
cb->VaultOperationComplete( cbContext, cb->GetNode() ? hsOK : hsFail ); // cbHolder deletes itself here.
}
PyObject * pyAgeVault::GetDeviceInbox( const char * deviceName )
{
wchar wStr[MAX_PATH];
StrToUnicode(wStr, deviceName, arrsize(wStr));
if (RelVaultNode * rvn = VaultAgeGetDeviceInboxIncRef(wStr)) {
PyObject * result = pyVaultTextNoteNode::New(rvn);
rvn->DecRef();
return result;
}
PYTHON_RETURN_NONE;
}
PyObject * pyAgeVault::GetAgeSDL() const
{
plStateDataRecord * rec = NEWZERO(plStateDataRecord);
if (!VaultAgeGetAgeSDL(rec)) {
DEL(rec);
PYTHON_RETURN_NONE;
}
else {
return pySDLStateDataRecord::New( rec );
}
}
void pyAgeVault::UpdateAgeSDL( pySDLStateDataRecord & pyrec )
{
plStateDataRecord * rec = pyrec.GetRec();
if ( !rec )
return;
VaultAgeUpdateAgeSDL(rec);
}
PyObject* pyAgeVault::FindNode( pyVaultNode* templateNode ) const
{
if (RelVaultNode * rvn = VaultGetAgeNodeIncRef()) {
RelVaultNode * find = rvn->GetChildNodeIncRef(templateNode->fNode, 1);
rvn->DecRef();
if (find) {
PyObject * result = pyVaultNode::New(find);
find->DecRef();
return result;
}
}
PYTHON_RETURN_NONE;
}

View File

@ -1,110 +1,110 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef _pyAgeVault_h_
#define _pyAgeVault_h_
#ifdef BUILDING_PYPLASMA
# error "pyAgeVault is not compatible with pyPlasma.pyd. Use BUILDING_PYPLASMA macro to ifdef out unwanted headers."
#endif
//////////////////////////////////////////////////////////////////////
//
// pyAgeVault - a wrapper class to provide interface to the plVaultAgeNode
//
//////////////////////////////////////////////////////////////////////
#include "hsTypes.h"
#include "hsStlUtils.h"
#include <python.h>
#include "pyGlueHelpers.h"
class pyVaultNode;
class pyVaultFolderNode;
class pyVaultPlayerInfoListNode;
class pyVaultAgeLinkNode;
class pyVaultAgeInfoNode;
class pyAgeInfoStruct;
class pyVaultChronicleNode;
class pySDLStateDataRecord;
class pyVaultTextNoteNode;
class pyAgeVault
{
private:
mutable char fAgeGuid[MAX_PATH]; // for getting Age GUID
protected:
pyAgeVault();
public:
~pyAgeVault();
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptAgeVault);
PYTHON_CLASS_NEW_DEFINITION;
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyAgeVault object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyAgeVault); // converts a PyObject to a pyAgeVault (throws error if not correct type)
static void AddPlasmaClasses(PyObject *m);
const char* GetAgeGuid( void );
PyObject * GetAgeSDL() const; // returns pySDLStateDataRecord
void UpdateAgeSDL( pySDLStateDataRecord & pyrec );
PyObject* GetAgeInfo(); // returns pyVaultAgeInfoNode
PyObject* GetAgeDevicesFolder( void ); // returns pyVaultFolderNode
PyObject* GetSubAgesFolder( void ); // returns pyVaultFolderNode
PyObject* GetChronicleFolder( void ); // returns pyVaultFolderNode
// Age chronicle (not the player chronicle!)
PyObject* FindChronicleEntry( const char * entryName ); // returns pyVaultChronicleNode
void AddChronicleEntry( const char * name, UInt32 type, const char * value );
// Players who have published to devices in this age
PyObject* GetPeopleIKnowAboutFolder( void ); // returns pyVaultPlayerInfoListNode
// PERSONAL AGE SPECIFIC
PyObject* GetBookshelfFolder ( void ); // returns pyVaultFolderNode
// NEXUS SPECIFIC
PyObject* GetPublicAgesFolder( void ); // returns pyVaultFolderNode
PyObject* GetSubAgeLink( const pyAgeInfoStruct & info ); // returns pyVaultAgeLinkNode
// AGE DEVICES. AKA IMAGERS, WHATEVER.
// Add a new device.
void AddDevice( const char * deviceName, PyObject * cb=nil, UInt32 cbContext=0 );
// Remove a device.
void RemoveDevice( const char * deviceName );
// True if device exists in age.
bool HasDevice( const char * deviceName );
// Get the device node by name.
PyObject * GetDevice( const char * deviceName ); // returns pyVaultTextNoteNode
// Sets the inbox associated with a device.
void SetDeviceInbox( const char * deviceName, const char * inboxName, PyObject * cb=nil, UInt32 cbContext=0 );
// Get the inbox associated with a device.
PyObject * GetDeviceInbox( const char * deviceName ); // returns pyVaultFolderNode
// find matching node
PyObject* FindNode( pyVaultNode* templateNode ) const; // returns pyVaultNode
};
#endif // _pyAgeVault_h_
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef _pyAgeVault_h_
#define _pyAgeVault_h_
#ifdef BUILDING_PYPLASMA
# error "pyAgeVault is not compatible with pyPlasma.pyd. Use BUILDING_PYPLASMA macro to ifdef out unwanted headers."
#endif
//////////////////////////////////////////////////////////////////////
//
// pyAgeVault - a wrapper class to provide interface to the plVaultAgeNode
//
//////////////////////////////////////////////////////////////////////
#include "hsTypes.h"
#include "hsStlUtils.h"
#include <python.h>
#include "pyGlueHelpers.h"
class pyVaultNode;
class pyVaultFolderNode;
class pyVaultPlayerInfoListNode;
class pyVaultAgeLinkNode;
class pyVaultAgeInfoNode;
class pyAgeInfoStruct;
class pyVaultChronicleNode;
class pySDLStateDataRecord;
class pyVaultTextNoteNode;
class pyAgeVault
{
private:
mutable char fAgeGuid[MAX_PATH]; // for getting Age GUID
protected:
pyAgeVault();
public:
~pyAgeVault();
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_FRIEND(ptAgeVault);
PYTHON_CLASS_NEW_DEFINITION;
PYTHON_CLASS_CHECK_DEFINITION; // returns true if the PyObject is a pyAgeVault object
PYTHON_CLASS_CONVERT_FROM_DEFINITION(pyAgeVault); // converts a PyObject to a pyAgeVault (throws error if not correct type)
static void AddPlasmaClasses(PyObject *m);
const char* GetAgeGuid( void );
PyObject * GetAgeSDL() const; // returns pySDLStateDataRecord
void UpdateAgeSDL( pySDLStateDataRecord & pyrec );
PyObject* GetAgeInfo(); // returns pyVaultAgeInfoNode
PyObject* GetAgeDevicesFolder( void ); // returns pyVaultFolderNode
PyObject* GetSubAgesFolder( void ); // returns pyVaultFolderNode
PyObject* GetChronicleFolder( void ); // returns pyVaultFolderNode
// Age chronicle (not the player chronicle!)
PyObject* FindChronicleEntry( const char * entryName ); // returns pyVaultChronicleNode
void AddChronicleEntry( const char * name, UInt32 type, const char * value );
// Players who have published to devices in this age
PyObject* GetPeopleIKnowAboutFolder( void ); // returns pyVaultPlayerInfoListNode
// PERSONAL AGE SPECIFIC
PyObject* GetBookshelfFolder ( void ); // returns pyVaultFolderNode
// NEXUS SPECIFIC
PyObject* GetPublicAgesFolder( void ); // returns pyVaultFolderNode
PyObject* GetSubAgeLink( const pyAgeInfoStruct & info ); // returns pyVaultAgeLinkNode
// AGE DEVICES. AKA IMAGERS, WHATEVER.
// Add a new device.
void AddDevice( const char * deviceName, PyObject * cb=nil, UInt32 cbContext=0 );
// Remove a device.
void RemoveDevice( const char * deviceName );
// True if device exists in age.
bool HasDevice( const char * deviceName );
// Get the device node by name.
PyObject * GetDevice( const char * deviceName ); // returns pyVaultTextNoteNode
// Sets the inbox associated with a device.
void SetDeviceInbox( const char * deviceName, const char * inboxName, PyObject * cb=nil, UInt32 cbContext=0 );
// Get the inbox associated with a device.
PyObject * GetDeviceInbox( const char * deviceName ); // returns pyVaultFolderNode
// find matching node
PyObject* FindNode( pyVaultNode* templateNode ) const; // returns pyVaultNode
};
#endif // _pyAgeVault_h_

View File

@ -1,268 +1,268 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyAgeVault.h"
#include "pyAgeInfoStruct.h"
#include "pySDL.h"
#include <python.h>
// glue functions
PYTHON_CLASS_DEFINITION(ptAgeVault, pyAgeVault);
PYTHON_DEFAULT_NEW_DEFINITION(ptAgeVault, pyAgeVault)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptAgeVault)
PYTHON_INIT_DEFINITION(ptAgeVault, args, keywords)
{
PYTHON_RETURN_INIT_OK;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeVault, getAgeInfo)
{
return self->fThis->GetAgeInfo();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeVault, getAgeDevicesFolder)
{
return self->fThis->GetAgeDevicesFolder();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeVault, getSubAgesFolder)
{
return self->fThis->GetSubAgesFolder();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeVault, getChronicleFolder)
{
return self->fThis->GetChronicleFolder();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeVault, getAgesIOwnFolder)
{
return self->fThis->GetBookshelfFolder();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeVault, getBookshelfFolder)
{
return self->fThis->GetBookshelfFolder();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeVault, getPeopleIKnowAboutFolder)
{
return self->fThis->GetPeopleIKnowAboutFolder();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeVault, getPublicAgesFolder)
{
return self->fThis->GetPublicAgesFolder();
}
PYTHON_METHOD_DEFINITION(ptAgeVault, getSubAgeLink, args)
{
PyObject* ageInfoObj = NULL;
if (!PyArg_ParseTuple(args, "O", &ageInfoObj))
{
PyErr_SetString(PyExc_TypeError, "getSubAgeLink expects a ptAgeInfoStruct");
PYTHON_RETURN_ERROR;
}
if (!pyAgeInfoStruct::Check(ageInfoObj))
{
PyErr_SetString(PyExc_TypeError, "getSubAgeLink expects a ptAgeInfoStruct");
PYTHON_RETURN_ERROR;
}
pyAgeInfoStruct* ageInfo = pyAgeInfoStruct::ConvertFrom(ageInfoObj);
return self->fThis->GetSubAgeLink(*ageInfo);
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeVault, getAgeGuid)
{
return PyString_FromString(self->fThis->GetAgeGuid());
}
PYTHON_METHOD_DEFINITION(ptAgeVault, addDevice, args)
{
char* name;
PyObject* cbObj = NULL;
unsigned long context = 0;
if (!PyArg_ParseTuple(args, "s|Ol", &name, &cbObj, &context))
{
PyErr_SetString(PyExc_TypeError, "addDevice expects a string, an optional object, and an optional unsigned long");
PYTHON_RETURN_ERROR;
}
self->fThis->AddDevice(name, cbObj, context);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptAgeVault, removeDevice, args)
{
char* name;
if (!PyArg_ParseTuple(args, "s", &name))
{
PyErr_SetString(PyExc_TypeError, "removeDevice expects a string");
PYTHON_RETURN_ERROR;
}
self->fThis->RemoveDevice(name);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptAgeVault, hasDevice, args)
{
char* name;
if (!PyArg_ParseTuple(args, "s", &name))
{
PyErr_SetString(PyExc_TypeError, "hasDevice expects a string");
PYTHON_RETURN_ERROR;
}
PYTHON_RETURN_BOOL(self->fThis->HasDevice(name));
}
PYTHON_METHOD_DEFINITION(ptAgeVault, getDevice, args)
{
char* name;
if (!PyArg_ParseTuple(args, "s", &name))
{
PyErr_SetString(PyExc_TypeError, "getDevice expects a string");
PYTHON_RETURN_ERROR;
}
return self->fThis->GetDevice(name);
}
PYTHON_METHOD_DEFINITION(ptAgeVault, setDeviceInbox, args)
{
char* name;
char* inboxName;
PyObject* cb = NULL;
unsigned long context = 0;
if (!PyArg_ParseTuple(args, "ss|Ol", &name, &inboxName, &cb, &context))
{
PyErr_SetString(PyExc_TypeError, "setDeviceInbox expects two strings, an optional object, and an optional unsigned long");
PYTHON_RETURN_ERROR;
}
self->fThis->SetDeviceInbox(name, inboxName, cb, context);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptAgeVault, getDeviceInbox, args)
{
char* name;
if (!PyArg_ParseTuple(args, "s", &name))
{
PyErr_SetString(PyExc_TypeError, "getDeviceInbox expects a string");
PYTHON_RETURN_ERROR;
}
return self->fThis->GetDeviceInbox(name);
}
PYTHON_METHOD_DEFINITION(ptAgeVault, findChronicleEntry, args)
{
char* name;
if (!PyArg_ParseTuple(args, "s", &name))
{
PyErr_SetString(PyExc_TypeError, "findChronicleEntry expects a string");
PYTHON_RETURN_ERROR;
}
return self->fThis->FindChronicleEntry(name);
}
PYTHON_METHOD_DEFINITION(ptAgeVault, addChronicleEntry, args)
{
char* name;
unsigned long entryType;
char* val;
if (!PyArg_ParseTuple(args, "sls", &name, &entryType, &val))
{
PyErr_SetString(PyExc_TypeError, "addChronicleEntry expects a string, an unsigned long, and a string");
PYTHON_RETURN_ERROR;
}
self->fThis->AddChronicleEntry(name, entryType, val);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeVault, getAgeSDL)
{
return self->fThis->GetAgeSDL();
}
PYTHON_METHOD_DEFINITION(ptAgeVault, updateAgeSDL, args)
{
PyObject* recordObj = NULL;
if (!PyArg_ParseTuple(args, "O", &recordObj))
{
PyErr_SetString(PyExc_TypeError, "updateAgeSDL expects a ptSDLStateDataRecord");
PYTHON_RETURN_NONE;
}
if (!pySDLStateDataRecord::Check(recordObj))
{
PyErr_SetString(PyExc_TypeError, "updateAgeSDL expects a ptSDLStateDataRecord");
PYTHON_RETURN_NONE;
}
pySDLStateDataRecord* record = pySDLStateDataRecord::ConvertFrom(recordObj);
self->fThis->UpdateAgeSDL(*record);
PYTHON_RETURN_NONE;
}
PYTHON_START_METHODS_TABLE(ptAgeVault)
PYTHON_METHOD_NOARGS(ptAgeVault, getAgeInfo, "Returns a ptVaultAgeInfoNode of the this Age"),
PYTHON_METHOD_NOARGS(ptAgeVault, getAgeDevicesFolder, "Returns a ptVaultFolderNode of the inboxes for the devices in this Age."),
PYTHON_METHOD_NOARGS(ptAgeVault, getSubAgesFolder, "Returns a ptVaultFolderNode of sub Age's folder."),
PYTHON_METHOD_NOARGS(ptAgeVault, getChronicleFolder, "Returns a ptVaultFolderNode"),
PYTHON_METHOD_NOARGS(ptAgeVault, getAgesIOwnFolder, "(depreciated, use getBookshelfFolder) Returns a ptVaultFolderNode that contain the Ages I own"),
PYTHON_METHOD_NOARGS(ptAgeVault, getBookshelfFolder, "Personal age only: Returns a ptVaultFolderNode that contains the owning player's AgesIOwn age list"),
PYTHON_METHOD_NOARGS(ptAgeVault, getPeopleIKnowAboutFolder, "Returns a ptVaultPlayerInfoListNode of the players the Age knows about(?)."),
PYTHON_METHOD_NOARGS(ptAgeVault, getPublicAgesFolder, "Returns a ptVaultFolderNode that contains all the public Ages"),
PYTHON_METHOD(ptAgeVault, getSubAgeLink, "Params: ageInfo\nReturns a ptVaultAgeLinkNode to 'ageInfo' (a ptAgeInfoStruct) for this Age."),
PYTHON_METHOD_NOARGS(ptAgeVault, getAgeGuid, "Returns the current Age's guid as a string."),
PYTHON_METHOD(ptAgeVault, addDevice, "Params: deviceName,cb=None,cbContext=0\nAdds a device to the age"),
PYTHON_METHOD(ptAgeVault, removeDevice, "Params: deviceName\nRemoves a device from the age"),
PYTHON_METHOD(ptAgeVault, hasDevice, "Params: deviceName\nDoes a device with this name exist?"),
PYTHON_METHOD(ptAgeVault, getDevice, "Params: deviceName\nReturns the specified device (ptVaultTextNoteNode)"),
PYTHON_METHOD(ptAgeVault, setDeviceInbox, "Params: deviceName,inboxName,cb=None,cbContext=0\nSet's the device's inbox"),
PYTHON_METHOD(ptAgeVault, getDeviceInbox, "Params: deviceName\nReturns a ptVaultFolderNode of the inbox for the named device in this age."),
PYTHON_METHOD(ptAgeVault, findChronicleEntry, "Params: entryName\nReturns the named ptVaultChronicleNode"),
PYTHON_METHOD(ptAgeVault, addChronicleEntry, "Params: name,type,value\nAdds a chronicle entry with the specified type and value"),
PYTHON_METHOD_NOARGS(ptAgeVault, getAgeSDL, "Returns the age's SDL (ptSDLStateDataRecord)"),
PYTHON_METHOD(ptAgeVault, updateAgeSDL, "Params: pyrec\nUpdates the age's SDL"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE(ptAgeVault, "Accessor class to the Age's vault");
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_IMPL(ptAgeVault, pyAgeVault)
PYTHON_CLASS_CHECK_IMPL(ptAgeVault, pyAgeVault)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptAgeVault, pyAgeVault)
///////////////////////////////////////////////////////////////////////////
//
// AddPlasmaClasses - the python module definitions
//
void pyAgeVault::AddPlasmaClasses(PyObject *m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptAgeVault);
PYTHON_CLASS_IMPORT_END(m);
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyAgeVault.h"
#include "pyAgeInfoStruct.h"
#include "pySDL.h"
#include <python.h>
// glue functions
PYTHON_CLASS_DEFINITION(ptAgeVault, pyAgeVault);
PYTHON_DEFAULT_NEW_DEFINITION(ptAgeVault, pyAgeVault)
PYTHON_DEFAULT_DEALLOC_DEFINITION(ptAgeVault)
PYTHON_INIT_DEFINITION(ptAgeVault, args, keywords)
{
PYTHON_RETURN_INIT_OK;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeVault, getAgeInfo)
{
return self->fThis->GetAgeInfo();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeVault, getAgeDevicesFolder)
{
return self->fThis->GetAgeDevicesFolder();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeVault, getSubAgesFolder)
{
return self->fThis->GetSubAgesFolder();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeVault, getChronicleFolder)
{
return self->fThis->GetChronicleFolder();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeVault, getAgesIOwnFolder)
{
return self->fThis->GetBookshelfFolder();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeVault, getBookshelfFolder)
{
return self->fThis->GetBookshelfFolder();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeVault, getPeopleIKnowAboutFolder)
{
return self->fThis->GetPeopleIKnowAboutFolder();
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeVault, getPublicAgesFolder)
{
return self->fThis->GetPublicAgesFolder();
}
PYTHON_METHOD_DEFINITION(ptAgeVault, getSubAgeLink, args)
{
PyObject* ageInfoObj = NULL;
if (!PyArg_ParseTuple(args, "O", &ageInfoObj))
{
PyErr_SetString(PyExc_TypeError, "getSubAgeLink expects a ptAgeInfoStruct");
PYTHON_RETURN_ERROR;
}
if (!pyAgeInfoStruct::Check(ageInfoObj))
{
PyErr_SetString(PyExc_TypeError, "getSubAgeLink expects a ptAgeInfoStruct");
PYTHON_RETURN_ERROR;
}
pyAgeInfoStruct* ageInfo = pyAgeInfoStruct::ConvertFrom(ageInfoObj);
return self->fThis->GetSubAgeLink(*ageInfo);
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeVault, getAgeGuid)
{
return PyString_FromString(self->fThis->GetAgeGuid());
}
PYTHON_METHOD_DEFINITION(ptAgeVault, addDevice, args)
{
char* name;
PyObject* cbObj = NULL;
unsigned long context = 0;
if (!PyArg_ParseTuple(args, "s|Ol", &name, &cbObj, &context))
{
PyErr_SetString(PyExc_TypeError, "addDevice expects a string, an optional object, and an optional unsigned long");
PYTHON_RETURN_ERROR;
}
self->fThis->AddDevice(name, cbObj, context);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptAgeVault, removeDevice, args)
{
char* name;
if (!PyArg_ParseTuple(args, "s", &name))
{
PyErr_SetString(PyExc_TypeError, "removeDevice expects a string");
PYTHON_RETURN_ERROR;
}
self->fThis->RemoveDevice(name);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptAgeVault, hasDevice, args)
{
char* name;
if (!PyArg_ParseTuple(args, "s", &name))
{
PyErr_SetString(PyExc_TypeError, "hasDevice expects a string");
PYTHON_RETURN_ERROR;
}
PYTHON_RETURN_BOOL(self->fThis->HasDevice(name));
}
PYTHON_METHOD_DEFINITION(ptAgeVault, getDevice, args)
{
char* name;
if (!PyArg_ParseTuple(args, "s", &name))
{
PyErr_SetString(PyExc_TypeError, "getDevice expects a string");
PYTHON_RETURN_ERROR;
}
return self->fThis->GetDevice(name);
}
PYTHON_METHOD_DEFINITION(ptAgeVault, setDeviceInbox, args)
{
char* name;
char* inboxName;
PyObject* cb = NULL;
unsigned long context = 0;
if (!PyArg_ParseTuple(args, "ss|Ol", &name, &inboxName, &cb, &context))
{
PyErr_SetString(PyExc_TypeError, "setDeviceInbox expects two strings, an optional object, and an optional unsigned long");
PYTHON_RETURN_ERROR;
}
self->fThis->SetDeviceInbox(name, inboxName, cb, context);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION(ptAgeVault, getDeviceInbox, args)
{
char* name;
if (!PyArg_ParseTuple(args, "s", &name))
{
PyErr_SetString(PyExc_TypeError, "getDeviceInbox expects a string");
PYTHON_RETURN_ERROR;
}
return self->fThis->GetDeviceInbox(name);
}
PYTHON_METHOD_DEFINITION(ptAgeVault, findChronicleEntry, args)
{
char* name;
if (!PyArg_ParseTuple(args, "s", &name))
{
PyErr_SetString(PyExc_TypeError, "findChronicleEntry expects a string");
PYTHON_RETURN_ERROR;
}
return self->fThis->FindChronicleEntry(name);
}
PYTHON_METHOD_DEFINITION(ptAgeVault, addChronicleEntry, args)
{
char* name;
unsigned long entryType;
char* val;
if (!PyArg_ParseTuple(args, "sls", &name, &entryType, &val))
{
PyErr_SetString(PyExc_TypeError, "addChronicleEntry expects a string, an unsigned long, and a string");
PYTHON_RETURN_ERROR;
}
self->fThis->AddChronicleEntry(name, entryType, val);
PYTHON_RETURN_NONE;
}
PYTHON_METHOD_DEFINITION_NOARGS(ptAgeVault, getAgeSDL)
{
return self->fThis->GetAgeSDL();
}
PYTHON_METHOD_DEFINITION(ptAgeVault, updateAgeSDL, args)
{
PyObject* recordObj = NULL;
if (!PyArg_ParseTuple(args, "O", &recordObj))
{
PyErr_SetString(PyExc_TypeError, "updateAgeSDL expects a ptSDLStateDataRecord");
PYTHON_RETURN_NONE;
}
if (!pySDLStateDataRecord::Check(recordObj))
{
PyErr_SetString(PyExc_TypeError, "updateAgeSDL expects a ptSDLStateDataRecord");
PYTHON_RETURN_NONE;
}
pySDLStateDataRecord* record = pySDLStateDataRecord::ConvertFrom(recordObj);
self->fThis->UpdateAgeSDL(*record);
PYTHON_RETURN_NONE;
}
PYTHON_START_METHODS_TABLE(ptAgeVault)
PYTHON_METHOD_NOARGS(ptAgeVault, getAgeInfo, "Returns a ptVaultAgeInfoNode of the this Age"),
PYTHON_METHOD_NOARGS(ptAgeVault, getAgeDevicesFolder, "Returns a ptVaultFolderNode of the inboxes for the devices in this Age."),
PYTHON_METHOD_NOARGS(ptAgeVault, getSubAgesFolder, "Returns a ptVaultFolderNode of sub Age's folder."),
PYTHON_METHOD_NOARGS(ptAgeVault, getChronicleFolder, "Returns a ptVaultFolderNode"),
PYTHON_METHOD_NOARGS(ptAgeVault, getAgesIOwnFolder, "(depreciated, use getBookshelfFolder) Returns a ptVaultFolderNode that contain the Ages I own"),
PYTHON_METHOD_NOARGS(ptAgeVault, getBookshelfFolder, "Personal age only: Returns a ptVaultFolderNode that contains the owning player's AgesIOwn age list"),
PYTHON_METHOD_NOARGS(ptAgeVault, getPeopleIKnowAboutFolder, "Returns a ptVaultPlayerInfoListNode of the players the Age knows about(?)."),
PYTHON_METHOD_NOARGS(ptAgeVault, getPublicAgesFolder, "Returns a ptVaultFolderNode that contains all the public Ages"),
PYTHON_METHOD(ptAgeVault, getSubAgeLink, "Params: ageInfo\nReturns a ptVaultAgeLinkNode to 'ageInfo' (a ptAgeInfoStruct) for this Age."),
PYTHON_METHOD_NOARGS(ptAgeVault, getAgeGuid, "Returns the current Age's guid as a string."),
PYTHON_METHOD(ptAgeVault, addDevice, "Params: deviceName,cb=None,cbContext=0\nAdds a device to the age"),
PYTHON_METHOD(ptAgeVault, removeDevice, "Params: deviceName\nRemoves a device from the age"),
PYTHON_METHOD(ptAgeVault, hasDevice, "Params: deviceName\nDoes a device with this name exist?"),
PYTHON_METHOD(ptAgeVault, getDevice, "Params: deviceName\nReturns the specified device (ptVaultTextNoteNode)"),
PYTHON_METHOD(ptAgeVault, setDeviceInbox, "Params: deviceName,inboxName,cb=None,cbContext=0\nSet's the device's inbox"),
PYTHON_METHOD(ptAgeVault, getDeviceInbox, "Params: deviceName\nReturns a ptVaultFolderNode of the inbox for the named device in this age."),
PYTHON_METHOD(ptAgeVault, findChronicleEntry, "Params: entryName\nReturns the named ptVaultChronicleNode"),
PYTHON_METHOD(ptAgeVault, addChronicleEntry, "Params: name,type,value\nAdds a chronicle entry with the specified type and value"),
PYTHON_METHOD_NOARGS(ptAgeVault, getAgeSDL, "Returns the age's SDL (ptSDLStateDataRecord)"),
PYTHON_METHOD(ptAgeVault, updateAgeSDL, "Params: pyrec\nUpdates the age's SDL"),
PYTHON_END_METHODS_TABLE;
// Type structure definition
PLASMA_DEFAULT_TYPE(ptAgeVault, "Accessor class to the Age's vault");
// required functions for PyObject interoperability
PYTHON_CLASS_NEW_IMPL(ptAgeVault, pyAgeVault)
PYTHON_CLASS_CHECK_IMPL(ptAgeVault, pyAgeVault)
PYTHON_CLASS_CONVERT_FROM_IMPL(ptAgeVault, pyAgeVault)
///////////////////////////////////////////////////////////////////////////
//
// AddPlasmaClasses - the python module definitions
//
void pyAgeVault::AddPlasmaClasses(PyObject *m)
{
PYTHON_CLASS_IMPORT_START(m);
PYTHON_CLASS_IMPORT(m, ptAgeVault);
PYTHON_CLASS_IMPORT_END(m);
}

View File

@ -1,127 +1,127 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyAlarm.h"
#include "hsTimer.h"
#include "hsStlUtils.h"
////////////////////////////////////////////////////////////////////
struct pyAlarm
{
double fStart;
float fSecs;
PyObject * fCb;
UInt32 fCbContext;
pyAlarm( double start, float secs, PyObject * cb, UInt32 cbContext )
: fStart( start )
, fSecs( secs )
, fCb( cb )
, fCbContext( cbContext )
{
Py_XINCREF( fCb );
}
~pyAlarm()
{
Py_XDECREF( fCb );
}
bool MaybeFire( double secs )
{
if ( secs-fStart>fSecs )
{
Fire();
return true;
}
return false;
}
void Fire()
{
if ( fCb )
{
PyObject* func = nil;
// Call the callback.
func = PyObject_GetAttrString( fCb, "onAlarm" );
if ( func )
{
if ( PyCallable_Check(func)>0 )
{
PyObject *retVal = PyObject_CallMethod(fCb, "onAlarm", "l", fCbContext);
Py_XDECREF(retVal);
}
}
Py_XDECREF(func);
}
}
};
////////////////////////////////////////////////////////////////////
//static
pyAlarmMgr * pyAlarmMgr::GetInstance()
{
static pyAlarmMgr inst;
return &inst;
}
pyAlarmMgr::~pyAlarmMgr()
{
// Clear();
}
void pyAlarmMgr::Update( double secs )
{
Alarms::iterator it = fAlarms.begin();
while ( it!=fAlarms.end() )
{
pyAlarm * alarm = (*it);
if ( alarm->MaybeFire( secs ) )
{
Alarms::iterator jt = it++;
fAlarms.erase( jt );
delete alarm;
}
else
{
it++;
}
}
}
void pyAlarmMgr::SetAlarm( float secs, PyObject * cb, UInt32 cbContext )
{
double start = hsTimer::GetSysSeconds();
fAlarms.push_back( TRACKED_NEW pyAlarm( start, secs, cb, cbContext ) );
}
void pyAlarmMgr::Clear()
{
for (Alarms::iterator i = fAlarms.begin(); i != fAlarms.end(); i++)
delete *i;
fAlarms.clear();
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "pyAlarm.h"
#include "hsTimer.h"
#include "hsStlUtils.h"
////////////////////////////////////////////////////////////////////
struct pyAlarm
{
double fStart;
float fSecs;
PyObject * fCb;
UInt32 fCbContext;
pyAlarm( double start, float secs, PyObject * cb, UInt32 cbContext )
: fStart( start )
, fSecs( secs )
, fCb( cb )
, fCbContext( cbContext )
{
Py_XINCREF( fCb );
}
~pyAlarm()
{
Py_XDECREF( fCb );
}
bool MaybeFire( double secs )
{
if ( secs-fStart>fSecs )
{
Fire();
return true;
}
return false;
}
void Fire()
{
if ( fCb )
{
PyObject* func = nil;
// Call the callback.
func = PyObject_GetAttrString( fCb, "onAlarm" );
if ( func )
{
if ( PyCallable_Check(func)>0 )
{
PyObject *retVal = PyObject_CallMethod(fCb, "onAlarm", "l", fCbContext);
Py_XDECREF(retVal);
}
}
Py_XDECREF(func);
}
}
};
////////////////////////////////////////////////////////////////////
//static
pyAlarmMgr * pyAlarmMgr::GetInstance()
{
static pyAlarmMgr inst;
return &inst;
}
pyAlarmMgr::~pyAlarmMgr()
{
// Clear();
}
void pyAlarmMgr::Update( double secs )
{
Alarms::iterator it = fAlarms.begin();
while ( it!=fAlarms.end() )
{
pyAlarm * alarm = (*it);
if ( alarm->MaybeFire( secs ) )
{
Alarms::iterator jt = it++;
fAlarms.erase( jt );
delete alarm;
}
else
{
it++;
}
}
}
void pyAlarmMgr::SetAlarm( float secs, PyObject * cb, UInt32 cbContext )
{
double start = hsTimer::GetSysSeconds();
fAlarms.push_back( TRACKED_NEW pyAlarm( start, secs, cb, cbContext ) );
}
void pyAlarmMgr::Clear()
{
for (Alarms::iterator i = fAlarms.begin(); i != fAlarms.end(); i++)
delete *i;
fAlarms.clear();
}

View File

@ -1,47 +1,47 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyAlarm_h_inc
#define pyAlarm_h_inc
#include "hsTypes.h"
#include "hsStlUtils.h"
#include <python.h>
struct pyAlarm;
class pyAlarmMgr
{
typedef std::list<pyAlarm*> Alarms;
Alarms fAlarms;
public:
~pyAlarmMgr();
static pyAlarmMgr * GetInstance();
void Update( double secs );
void SetAlarm( float secs, PyObject * cb, UInt32 cbContext );
void Clear();
};
#endif
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef pyAlarm_h_inc
#define pyAlarm_h_inc
#include "hsTypes.h"
#include "hsStlUtils.h"
#include <python.h>
struct pyAlarm;
class pyAlarmMgr
{
typedef std::list<pyAlarm*> Alarms;
Alarms fAlarms;
public:
~pyAlarmMgr();
static pyAlarmMgr * GetInstance();
void Update( double secs );
void SetAlarm( float secs, PyObject * cb, UInt32 cbContext );
void Clear();
};
#endif

View File

@ -1,433 +1,433 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////
//
// pyAudioControl - a wrapper class all the audio control functions
//
//////////////////////////////////////////////////////////////////////
#include "pyAudioControl.h"
#include "plAudio/plAudioSystem.h"
#include "plAudio/plVoiceChat.h"
#include "plAudio/plWinMicLevel.h"
#include "plAudio/plAudioCaps.h"
// Sets the master volume of a given audio channel
void pyAudioControl::SetSoundFXVolume( hsScalar volume )
{
plgAudioSys::ASChannel chan;
chan = plgAudioSys::kSoundFX;
// make sure the volume is within range
if( volume > 1.f )
volume = 1.f;
else if( volume < 0.f )
volume = 0.f;
plgAudioSys::SetChannelVolume( chan, volume );
}
void pyAudioControl::SetMusicVolume( hsScalar volume )
{
plgAudioSys::ASChannel chan;
chan = plgAudioSys::kBgndMusic;
// make sure the volume is within range
if( volume > 1.f )
volume = 1.f;
else if( volume < 0.f )
volume = 0.f;
plgAudioSys::SetChannelVolume( chan, volume );
}
void pyAudioControl::SetVoiceVolume( hsScalar volume )
{
plgAudioSys::ASChannel chan;
chan = plgAudioSys::kVoice;
// make sure the volume is within range
if( volume > 1.f )
volume = 1.f;
else if( volume < 0.f )
volume = 0.f;
plgAudioSys::SetChannelVolume( chan, volume );
}
void pyAudioControl::SetAmbienceVolume( hsScalar volume )
{
plgAudioSys::ASChannel chan;
chan = plgAudioSys::kAmbience;
// make sure the volume is within range
if( volume > 1.f )
volume = 1.f;
else if( volume < 0.f )
volume = 0.f;
plgAudioSys::SetChannelVolume( chan, volume );
}
void pyAudioControl::SetGUIVolume( hsScalar volume )
{
plgAudioSys::ASChannel chan;
chan = plgAudioSys::kGUI;
// make sure the volume is within range
if( volume > 1.f )
volume = 1.f;
else if( volume < 0.f )
volume = 0.f;
plgAudioSys::SetChannelVolume( chan, volume );
}
void pyAudioControl::SetNPCVoiceVolume( hsScalar volume )
{
plgAudioSys::ASChannel chan;
chan = plgAudioSys::kNPCVoice;
// make sure the volume is within range
if( volume > 1.f )
volume = 1.f;
else if( volume < 0.f )
volume = 0.f;
plgAudioSys::SetChannelVolume( chan, volume );
}
hsScalar pyAudioControl::GetSoundFXVolume()
{
plgAudioSys::ASChannel chan;
chan = plgAudioSys::kSoundFX;
return plgAudioSys::GetChannelVolume(chan);
}
hsScalar pyAudioControl::GetMusicVolume()
{
plgAudioSys::ASChannel chan;
chan = plgAudioSys::kBgndMusic;
return plgAudioSys::GetChannelVolume(chan);
}
hsScalar pyAudioControl::GetVoiceVolume()
{
plgAudioSys::ASChannel chan;
chan = plgAudioSys::kVoice;
return plgAudioSys::GetChannelVolume(chan);
}
hsScalar pyAudioControl::GetAmbienceVolume()
{
plgAudioSys::ASChannel chan;
chan = plgAudioSys::kAmbience;
return plgAudioSys::GetChannelVolume(chan);
}
hsScalar pyAudioControl::GetGUIVolume()
{
plgAudioSys::ASChannel chan;
chan = plgAudioSys::kGUI;
return plgAudioSys::GetChannelVolume(chan);
}
hsScalar pyAudioControl::GetNPCVoiceVolume()
{
plgAudioSys::ASChannel chan;
chan = plgAudioSys::kNPCVoice;
return plgAudioSys::GetChannelVolume(chan);
}
// Switch DirectX Audio on or off at runtime
void pyAudioControl::Enable()
{
plgAudioSys::Activate(true);
}
void pyAudioControl::Disable()
{
plgAudioSys::Activate(false);
}
hsBool pyAudioControl::IsEnabled()
{
return plgAudioSys::Active();
}
// Enable or disable load-on-demand for sounds
void pyAudioControl::SetLoadOnDemand( hsBool state )
{
plSound::SetLoadOnDemand(state);
}
// Enables or disables two-stage LOD, where sounds can be loaded into RAM but not into sound buffers.
// ...Less of a performance hit, harder on memory.
void pyAudioControl::SetTwoStageLOD( hsBool state )
{
// For two-stage LOD, we want to disable LoadFromDiskOnDemand, so that we'll load into RAM at startup but not
// into sound buffers until demanded to do so. Enabling LoadFromDiskOnDemand basically conserves as much memory
// as possible
plSound::SetLoadFromDiskOnDemand( !state );
}
// Enable audio hardware acceleration
void pyAudioControl::UseHardwareAcceleration( hsBool state )
{
plgAudioSys::SetUseHardware(state);
}
hsBool pyAudioControl::IsHardwareAccelerated()
{
return plgAudioSys::Hardware();
}
// Enable EAX sound acceleration (requires hardware acceleration)
void pyAudioControl::UseEAXAcceleration( hsBool state )
{
plgAudioSys::EnableEAX(state);
}
hsBool pyAudioControl::IsUsingEAXAcceleration()
{
return plgAudioSys::UsingEAX();
}
// Mute or unmute all sounds
void pyAudioControl::MuteAll()
{
plgAudioSys::SetMuted(true);
}
void pyAudioControl::UnmuteAll()
{
plgAudioSys::SetMuted(false);
}
hsBool pyAudioControl::IsMuted()
{
return plgAudioSys::IsMuted();
}
hsBool pyAudioControl::SupportEAX(const char *deviceName)
{
return plgAudioSys::SupportsEAX(deviceName);
}
//------------------------
// Voice Settings
// Sets the microphone volume, in the range of 0 to 1
hsBool pyAudioControl::CanSetMicLevel()
{
return plWinMicLevel::CanSetLevel();
}
void pyAudioControl::SetMicLevel( hsScalar level )
{
// make sure the volume is within range
if( level > 1.f )
level = 1.f;
else if( level < 0.f )
level = 0.f;
if( CanSetMicLevel() )
plWinMicLevel::SetLevel( level );
}
hsScalar pyAudioControl::GetMicLevel()
{
return plWinMicLevel::GetLevel();
}
// turn voice recording on or off
void pyAudioControl::EnableVoiceRecording( hsBool state )
{
plVoiceRecorder::EnableRecording(state);
}
hsBool pyAudioControl::IsVoiceRecordingEnabled()
{
return plVoiceRecorder::RecordingEnabled();
}
// turn voice compression on and off
void pyAudioControl::EnableVoiceCompression( hsBool state )
{
}
hsBool pyAudioControl::IsVoiceCompressionEnabled()
{
return true;
}
// turn voice-over-net on and off
void pyAudioControl::EnableVoiceNetBroadcast( hsBool state )
{
//plWinRecorder::EnableNetVoice(state);
}
hsBool pyAudioControl::IsVoiceNetBroadcastEnabled()
{
return true;
}
void pyAudioControl::EnableVoiceChat(hsBool enable)
{
plVoicePlayer::Enable(enable);
}
// turn voice recording icons on and off
void pyAudioControl::ShowIcons()
{
plVoiceRecorder::EnableIcons(true);
}
void pyAudioControl::HideIcons()
{
plVoiceRecorder::EnableIcons(false);
}
// turn push-to-talk on or off
void pyAudioControl::PushToTalk( hsBool state )
{
plVoiceRecorder::EnablePushToTalk(state);
}
// Set the squelch level
void pyAudioControl::SquelchLevel( hsScalar level )
{
plVoiceRecorder::SetSquelch(level);
}
// Adjust voice packet frame size
void pyAudioControl::RecordFrame( Int32 size )
{
}
// Set the sample rate for recording
void pyAudioControl::RecordSampleRate( Int32 sample_rate )
{
}
UInt8 pyAudioControl::GetPriorityCutoff( void )
{
return plgAudioSys::GetPriorityCutoff();
}
void pyAudioControl::SetPriorityCutoff( UInt8 cut )
{
plgAudioSys::SetPriorityCutoff( cut );
}
void pyAudioControl::SetAudioSystemMode(int mode)
{
switch (mode)
{
case plgAudioSys::kDisabled:
plgAudioSys::SetAudioMode(plgAudioSys::kDisabled);
break;
case plgAudioSys::kSoftware:
plgAudioSys::SetAudioMode(plgAudioSys::kSoftware);
break;
case plgAudioSys::kHardware:
plgAudioSys::SetAudioMode(plgAudioSys::kHardware);
break;
case plgAudioSys::kHardwarePlusEAX:
plgAudioSys::SetAudioMode(plgAudioSys::kHardwarePlusEAX);
break;
default:
break;
}
}
int pyAudioControl::GetAudioSystemMode()
{
return plgAudioSys::GetAudioMode();
}
int pyAudioControl::GetHighestAudioMode()
{
int highestMode = plgAudioSys::kDisabled;
plAudioCaps caps = plAudioCapsDetector::Detect();
if ( caps.IsEAXAvailable() )
{
highestMode = plgAudioSys::kHardwarePlusEAX;
}
else
{
if ( 1 ) // This is taken care of in the audio system
{
highestMode = plgAudioSys::kHardware;
}
else
{
if ( caps.IsAvailable() )
{
highestMode = plgAudioSys::kSoftware;
}
}
}
return highestMode;
}
int pyAudioControl::GetNumAudioDevices()
{
return plgAudioSys::GetNumAudioDevices();
}
const char *pyAudioControl::GetAudioDeviceName(int index)
{
return plgAudioSys::GetAudioDeviceName(index);
}
void pyAudioControl::SetDeviceName(const char *device, bool restart)
{
plgAudioSys::SetDeviceName(device, restart);
}
const char * pyAudioControl::GetDeviceName()
{
return plgAudioSys::GetDeviceName();
}
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
//////////////////////////////////////////////////////////////////////
//
// pyAudioControl - a wrapper class all the audio control functions
//
//////////////////////////////////////////////////////////////////////
#include "pyAudioControl.h"
#include "plAudio/plAudioSystem.h"
#include "plAudio/plVoiceChat.h"
#include "plAudio/plWinMicLevel.h"
#include "plAudio/plAudioCaps.h"
// Sets the master volume of a given audio channel
void pyAudioControl::SetSoundFXVolume( hsScalar volume )
{
plgAudioSys::ASChannel chan;
chan = plgAudioSys::kSoundFX;
// make sure the volume is within range
if( volume > 1.f )
volume = 1.f;
else if( volume < 0.f )
volume = 0.f;
plgAudioSys::SetChannelVolume( chan, volume );
}
void pyAudioControl::SetMusicVolume( hsScalar volume )
{
plgAudioSys::ASChannel chan;
chan = plgAudioSys::kBgndMusic;
// make sure the volume is within range
if( volume > 1.f )
volume = 1.f;
else if( volume < 0.f )
volume = 0.f;
plgAudioSys::SetChannelVolume( chan, volume );
}
void pyAudioControl::SetVoiceVolume( hsScalar volume )
{
plgAudioSys::ASChannel chan;
chan = plgAudioSys::kVoice;
// make sure the volume is within range
if( volume > 1.f )
volume = 1.f;
else if( volume < 0.f )
volume = 0.f;
plgAudioSys::SetChannelVolume( chan, volume );
}
void pyAudioControl::SetAmbienceVolume( hsScalar volume )
{
plgAudioSys::ASChannel chan;
chan = plgAudioSys::kAmbience;
// make sure the volume is within range
if( volume > 1.f )
volume = 1.f;
else if( volume < 0.f )
volume = 0.f;
plgAudioSys::SetChannelVolume( chan, volume );
}
void pyAudioControl::SetGUIVolume( hsScalar volume )
{
plgAudioSys::ASChannel chan;
chan = plgAudioSys::kGUI;
// make sure the volume is within range
if( volume > 1.f )
volume = 1.f;
else if( volume < 0.f )
volume = 0.f;
plgAudioSys::SetChannelVolume( chan, volume );
}
void pyAudioControl::SetNPCVoiceVolume( hsScalar volume )
{
plgAudioSys::ASChannel chan;
chan = plgAudioSys::kNPCVoice;
// make sure the volume is within range
if( volume > 1.f )
volume = 1.f;
else if( volume < 0.f )
volume = 0.f;
plgAudioSys::SetChannelVolume( chan, volume );
}
hsScalar pyAudioControl::GetSoundFXVolume()
{
plgAudioSys::ASChannel chan;
chan = plgAudioSys::kSoundFX;
return plgAudioSys::GetChannelVolume(chan);
}
hsScalar pyAudioControl::GetMusicVolume()
{
plgAudioSys::ASChannel chan;
chan = plgAudioSys::kBgndMusic;
return plgAudioSys::GetChannelVolume(chan);
}
hsScalar pyAudioControl::GetVoiceVolume()
{
plgAudioSys::ASChannel chan;
chan = plgAudioSys::kVoice;
return plgAudioSys::GetChannelVolume(chan);
}
hsScalar pyAudioControl::GetAmbienceVolume()
{
plgAudioSys::ASChannel chan;
chan = plgAudioSys::kAmbience;
return plgAudioSys::GetChannelVolume(chan);
}
hsScalar pyAudioControl::GetGUIVolume()
{
plgAudioSys::ASChannel chan;
chan = plgAudioSys::kGUI;
return plgAudioSys::GetChannelVolume(chan);
}
hsScalar pyAudioControl::GetNPCVoiceVolume()
{
plgAudioSys::ASChannel chan;
chan = plgAudioSys::kNPCVoice;
return plgAudioSys::GetChannelVolume(chan);
}
// Switch DirectX Audio on or off at runtime
void pyAudioControl::Enable()
{
plgAudioSys::Activate(true);
}
void pyAudioControl::Disable()
{
plgAudioSys::Activate(false);
}
hsBool pyAudioControl::IsEnabled()
{
return plgAudioSys::Active();
}
// Enable or disable load-on-demand for sounds
void pyAudioControl::SetLoadOnDemand( hsBool state )
{
plSound::SetLoadOnDemand(state);
}
// Enables or disables two-stage LOD, where sounds can be loaded into RAM but not into sound buffers.
// ...Less of a performance hit, harder on memory.
void pyAudioControl::SetTwoStageLOD( hsBool state )
{
// For two-stage LOD, we want to disable LoadFromDiskOnDemand, so that we'll load into RAM at startup but not
// into sound buffers until demanded to do so. Enabling LoadFromDiskOnDemand basically conserves as much memory
// as possible
plSound::SetLoadFromDiskOnDemand( !state );
}
// Enable audio hardware acceleration
void pyAudioControl::UseHardwareAcceleration( hsBool state )
{
plgAudioSys::SetUseHardware(state);
}
hsBool pyAudioControl::IsHardwareAccelerated()
{
return plgAudioSys::Hardware();
}
// Enable EAX sound acceleration (requires hardware acceleration)
void pyAudioControl::UseEAXAcceleration( hsBool state )
{
plgAudioSys::EnableEAX(state);
}
hsBool pyAudioControl::IsUsingEAXAcceleration()
{
return plgAudioSys::UsingEAX();
}
// Mute or unmute all sounds
void pyAudioControl::MuteAll()
{
plgAudioSys::SetMuted(true);
}
void pyAudioControl::UnmuteAll()
{
plgAudioSys::SetMuted(false);
}
hsBool pyAudioControl::IsMuted()
{
return plgAudioSys::IsMuted();
}
hsBool pyAudioControl::SupportEAX(const char *deviceName)
{
return plgAudioSys::SupportsEAX(deviceName);
}
//------------------------
// Voice Settings
// Sets the microphone volume, in the range of 0 to 1
hsBool pyAudioControl::CanSetMicLevel()
{
return plWinMicLevel::CanSetLevel();
}
void pyAudioControl::SetMicLevel( hsScalar level )
{
// make sure the volume is within range
if( level > 1.f )
level = 1.f;
else if( level < 0.f )
level = 0.f;
if( CanSetMicLevel() )
plWinMicLevel::SetLevel( level );
}
hsScalar pyAudioControl::GetMicLevel()
{
return plWinMicLevel::GetLevel();
}
// turn voice recording on or off
void pyAudioControl::EnableVoiceRecording( hsBool state )
{
plVoiceRecorder::EnableRecording(state);
}
hsBool pyAudioControl::IsVoiceRecordingEnabled()
{
return plVoiceRecorder::RecordingEnabled();
}
// turn voice compression on and off
void pyAudioControl::EnableVoiceCompression( hsBool state )
{
}
hsBool pyAudioControl::IsVoiceCompressionEnabled()
{
return true;
}
// turn voice-over-net on and off
void pyAudioControl::EnableVoiceNetBroadcast( hsBool state )
{
//plWinRecorder::EnableNetVoice(state);
}
hsBool pyAudioControl::IsVoiceNetBroadcastEnabled()
{
return true;
}
void pyAudioControl::EnableVoiceChat(hsBool enable)
{
plVoicePlayer::Enable(enable);
}
// turn voice recording icons on and off
void pyAudioControl::ShowIcons()
{
plVoiceRecorder::EnableIcons(true);
}
void pyAudioControl::HideIcons()
{
plVoiceRecorder::EnableIcons(false);
}
// turn push-to-talk on or off
void pyAudioControl::PushToTalk( hsBool state )
{
plVoiceRecorder::EnablePushToTalk(state);
}
// Set the squelch level
void pyAudioControl::SquelchLevel( hsScalar level )
{
plVoiceRecorder::SetSquelch(level);
}
// Adjust voice packet frame size
void pyAudioControl::RecordFrame( Int32 size )
{
}
// Set the sample rate for recording
void pyAudioControl::RecordSampleRate( Int32 sample_rate )
{
}
UInt8 pyAudioControl::GetPriorityCutoff( void )
{
return plgAudioSys::GetPriorityCutoff();
}
void pyAudioControl::SetPriorityCutoff( UInt8 cut )
{
plgAudioSys::SetPriorityCutoff( cut );
}
void pyAudioControl::SetAudioSystemMode(int mode)
{
switch (mode)
{
case plgAudioSys::kDisabled:
plgAudioSys::SetAudioMode(plgAudioSys::kDisabled);
break;
case plgAudioSys::kSoftware:
plgAudioSys::SetAudioMode(plgAudioSys::kSoftware);
break;
case plgAudioSys::kHardware:
plgAudioSys::SetAudioMode(plgAudioSys::kHardware);
break;
case plgAudioSys::kHardwarePlusEAX:
plgAudioSys::SetAudioMode(plgAudioSys::kHardwarePlusEAX);
break;
default:
break;
}
}
int pyAudioControl::GetAudioSystemMode()
{
return plgAudioSys::GetAudioMode();
}
int pyAudioControl::GetHighestAudioMode()
{
int highestMode = plgAudioSys::kDisabled;
plAudioCaps caps = plAudioCapsDetector::Detect();
if ( caps.IsEAXAvailable() )
{
highestMode = plgAudioSys::kHardwarePlusEAX;
}
else
{
if ( 1 ) // This is taken care of in the audio system
{
highestMode = plgAudioSys::kHardware;
}
else
{
if ( caps.IsAvailable() )
{
highestMode = plgAudioSys::kSoftware;
}
}
}
return highestMode;
}
int pyAudioControl::GetNumAudioDevices()
{
return plgAudioSys::GetNumAudioDevices();
}
const char *pyAudioControl::GetAudioDeviceName(int index)
{
return plgAudioSys::GetAudioDeviceName(index);
}
void pyAudioControl::SetDeviceName(const char *device, bool restart)
{
plgAudioSys::SetDeviceName(device, restart);
}
const char * pyAudioControl::GetDeviceName()
{
return plgAudioSys::GetDeviceName();
}

Some files were not shown because too many files have changed in this diff Show More