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,39 +1,39 @@
include_directories("../../CoreLib")
include_directories("../../NucleusLib/inc")
include_directories("../../NucleusLib")
include_directories("../../PubUtilLib")
set(plSDL_SOURCES
plSDLMgr.cpp
plSDLParser.cpp
plStateChangeNotifier.cpp
plStateDataRecord.cpp
plStateDescriptor.cpp
plStateVariable.cpp
plVarDescriptor.cpp
)
set(plSDL_HEADERS
plSDL.h
plSDLCreatable.h
plSDLDescriptor.h
)
set(plSDL_SDLFILES
SDL/animation.sdl
SDL/avatar.sdl
SDL/cloneMessage.sdl
SDL/clothing.sdl
SDL/morph.sdl
SDL/particle.sdl
SDL/physical.sdl
SDL/responder.sdl
SDL/sound.sdl
SDL/xregion.sdl
)
add_library(plSDL STATIC ${plSDL_SOURCES} ${plSDL_HEADERS} ${plSDL_SDLFILES})
source_group("Source Files" FILES ${plSDL_SOURCES})
source_group("Header Files" FILES ${plSDL_HEADERS})
source_group("SDL" FILES ${plSDL_SDLFILES})
include_directories("../../CoreLib")
include_directories("../../NucleusLib/inc")
include_directories("../../NucleusLib")
include_directories("../../PubUtilLib")
set(plSDL_SOURCES
plSDLMgr.cpp
plSDLParser.cpp
plStateChangeNotifier.cpp
plStateDataRecord.cpp
plStateDescriptor.cpp
plStateVariable.cpp
plVarDescriptor.cpp
)
set(plSDL_HEADERS
plSDL.h
plSDLCreatable.h
plSDLDescriptor.h
)
set(plSDL_SDLFILES
SDL/animation.sdl
SDL/avatar.sdl
SDL/cloneMessage.sdl
SDL/clothing.sdl
SDL/morph.sdl
SDL/particle.sdl
SDL/physical.sdl
SDL/responder.sdl
SDL/sound.sdl
SDL/xregion.sdl
)
add_library(plSDL STATIC ${plSDL_SOURCES} ${plSDL_HEADERS} ${plSDL_SDLFILES})
source_group("Source Files" FILES ${plSDL_SOURCES})
source_group("Header Files" FILES ${plSDL_HEADERS})
source_group("SDL" FILES ${plSDL_SDLFILES})

View File

@ -1,72 +1,72 @@
#===============================================
# Changing an SDL record? Be sure to leave the
# legacy record intact and make changes in
# a new copy of the record. - eap
#===============================================
#
# Animation State Description
#
#
# Defines the state of an animation controller
#
STATEDESC AnimTimeConvert
{
VERSION 5
VAR INT flags[1] DEFAULT=0
VAR FLOAT lastStateAnimTime[1] DEFAULT=0
VAR FLOAT loopEnd[1] DEFAULT=0
VAR FLOAT loopBegin[1] DEFAULT=0
VAR FLOAT speed[1] DEFAULT=1
VAR CREATABLE speedEaseCurve[1]
VAR BYTE currentEaseCurve[1] DEFAULT=0 # 0=nil, 1=easeIn, 2=easeOut, 3=speed
VAR TIME currentEaseBeginWorldTime[1] DEFAULT=0
VAR TIME lastStateChange[1] DEFAULT=0
}
STATEDESC AnimTimeConvert
{
VERSION 6
VAR INT flags[1] DEFAULT=0
VAR FLOAT lastStateAnimTime[1] DEFAULT=0
VAR FLOAT loopEnd[1] DEFAULT=0
VAR FLOAT loopBegin[1] DEFAULT=0
VAR FLOAT speed[1] DEFAULT=1
VAR BYTE currentEaseCurve[1] DEFAULT=0 # 0=nil, 1=easeIn, 2=easeOut, 3=speed
VAR TIME currentEaseBeginWorldTime[1] DEFAULT=0
VAR TIME lastStateChange[1] DEFAULT=0
}
#
# TOP LEVEL
# Describes the state of an animated object (non-material)
#
STATEDESC AGMaster
{
VERSION 5
VAR $AnimTimeConvert atcs[] # variable length list
VAR BYTE blends[]
}
#
# TOP LEVEL
# Describes the state of an animated layer
#
STATEDESC Layer
{
VERSION 6
VAR $AnimTimeConvert atc[1]
VAR INT passThruChannels[1] DEFAULT=0
VAR FLOAT transform[] # Size will be 0 or 16, depending on whether we own the channel
VAR BYTE channelData[] # A byte array for the channels below. Its size
# will depend on the layer's fOwnedChannels.
#VAR RGB8 preshadeColor[1] DEFAULT=(1,1,1)
#VAR RGB8 runtimeColor[1] DEFAULT=(1,1,1)
#VAR RGB8 ambientColor[1] DEFAULT=(1,1,1)
#VAR BYTE opacity[1] DEFAULT=255
}
#===============================================
# Changing an SDL record? Be sure to leave the
# legacy record intact and make changes in
# a new copy of the record. - eap
#===============================================
#
# Animation State Description
#
#
# Defines the state of an animation controller
#
STATEDESC AnimTimeConvert
{
VERSION 5
VAR INT flags[1] DEFAULT=0
VAR FLOAT lastStateAnimTime[1] DEFAULT=0
VAR FLOAT loopEnd[1] DEFAULT=0
VAR FLOAT loopBegin[1] DEFAULT=0
VAR FLOAT speed[1] DEFAULT=1
VAR CREATABLE speedEaseCurve[1]
VAR BYTE currentEaseCurve[1] DEFAULT=0 # 0=nil, 1=easeIn, 2=easeOut, 3=speed
VAR TIME currentEaseBeginWorldTime[1] DEFAULT=0
VAR TIME lastStateChange[1] DEFAULT=0
}
STATEDESC AnimTimeConvert
{
VERSION 6
VAR INT flags[1] DEFAULT=0
VAR FLOAT lastStateAnimTime[1] DEFAULT=0
VAR FLOAT loopEnd[1] DEFAULT=0
VAR FLOAT loopBegin[1] DEFAULT=0
VAR FLOAT speed[1] DEFAULT=1
VAR BYTE currentEaseCurve[1] DEFAULT=0 # 0=nil, 1=easeIn, 2=easeOut, 3=speed
VAR TIME currentEaseBeginWorldTime[1] DEFAULT=0
VAR TIME lastStateChange[1] DEFAULT=0
}
#
# TOP LEVEL
# Describes the state of an animated object (non-material)
#
STATEDESC AGMaster
{
VERSION 5
VAR $AnimTimeConvert atcs[] # variable length list
VAR BYTE blends[]
}
#
# TOP LEVEL
# Describes the state of an animated layer
#
STATEDESC Layer
{
VERSION 6
VAR $AnimTimeConvert atc[1]
VAR INT passThruChannels[1] DEFAULT=0
VAR FLOAT transform[] # Size will be 0 or 16, depending on whether we own the channel
VAR BYTE channelData[] # A byte array for the channels below. Its size
# will depend on the layer's fOwnedChannels.
#VAR RGB8 preshadeColor[1] DEFAULT=(1,1,1)
#VAR RGB8 runtimeColor[1] DEFAULT=(1,1,1)
#VAR RGB8 ambientColor[1] DEFAULT=(1,1,1)
#VAR BYTE opacity[1] DEFAULT=255
}

View File

@ -1,150 +1,150 @@
#===============================================
# Changing an SDL record? Be sure to leave the
# legacy record intact and make changes in
# a new copy of the record. - eap
#===============================================
#
# Avatar State Description
# You might want to read these from the bottom of the file up to get the top-down perspective
#
#
# Defines a standard anim stage (used by the genericBrain)
#
STATEDESC standardStage
{
VERSION 2
VAR STRING32 name[1]
VAR SHORT numLoops[1] DEFAULT=0 # -1=loopForever
VAR BYTE forward[1] DEFAULT=0 # 0=none, 1=kbd, 2=auto
VAR BYTE backward[1] DEFAULT=0 # 0=none, 1=kbd
VAR BYTE stageAdvance[1] DEFAULT=0 # 0=none, 1=auto
VAR BYTE stageRegress[1] DEFAULT=0 # 0=none, 1=auto
VAR BOOL notifyEnter[1] DEFAULT=false
VAR BOOL notifyLoop[1] DEFAULT=false
VAR BOOL notifyStageAdvance[1] DEFAULT=false
VAR BOOL notifyStageRegress[1] DEFAULT=false
VAR BOOL useGlobalCoords[1] DEFAULT=false
VAR FLOAT localTime[1] DEFAULT=0
VAR FLOAT length[1] DEFAULT=0
VAR SHORT currentLoop[1] DEFAULT=0
VAR BOOL isAttached[1] DEFAULT=false
}
STATEDESC standardStage
{
VERSION 3
VAR STRING32 name[1]
VAR SHORT numLoops[1] DEFAULT=0 # -1=loopForever
VAR BYTE forward[1] DEFAULT=0 # 0=none, 1=kbd, 2=auto
VAR BYTE backward[1] DEFAULT=0 # 0=none, 1=kbd
VAR BYTE stageAdvance[1] DEFAULT=0 # 0=none, 1=auto
VAR BYTE stageRegress[1] DEFAULT=0 # 0=none, 1=auto
VAR BOOL notifyEnter[1] DEFAULT=false
VAR BOOL notifyLoop[1] DEFAULT=false
VAR BOOL notifyStageAdvance[1] DEFAULT=false
VAR BOOL notifyStageRegress[1] DEFAULT=false
VAR BOOL useGlobalCoords[1] DEFAULT=false
VAR FLOAT localTime[1] DEFAULT=0
VAR SHORT currentLoop[1] DEFAULT=0
VAR BOOL isAttached[1] DEFAULT=false
}
#
# State for the plAvBrainGeneric
#
STATEDESC genericBrain
{
VERSION 3
VAR BOOL noBrain[1] DEFAULT=true # set if not a brain
VAR $standardStage stages[]
VAR BYTE currentStage[1] DEFAULT=0
VAR BOOL freezePhysicalAtEnd[1] DEFAULT=false
VAR PLKEY callbackRcvr[1]
VAR BOOL movingForward[1] DEFAULT=true
VAR BYTE exitFlags[1] DEFAULT=0
VAR BYTE type[1] # could be byte
VAR BYTE mode[1] # could be byte
VAR FLOAT fadeIn[1] DEFAULT=1.0
VAR FLOAT fadeOut[1] DEFAULT=1.0
VAR BYTE moveMode[1] # could be byte
VAR BYTE bodyUsage[1] # could be byte
}
#
# State for the plAvBrainClimb
#
STATEDESC climbBrain
{
VERSION 1
VAR INT curMode[1]
VAR INT nextMode[1]
VAR INT allowedDirections[1]
VAR INT allowedDismounts[1]
VAR FLOAT vertProbeLength[1]
VAR FLOAT horizProbeLength[1]
VAR BOOL curStageAttached[1]
VAR INT curStage[1]
VAR FLOAT curStageTime[1]
VAR FLOAT curStageStrength[1]
VAR BOOL exitStageAttached[1]
VAR INT exitStage[1]
VAR FLOAT exitStageTime[1]
VAR BOOL exitStageStrength[1]
}
STATEDESC driveBrain
{
VERSION 1
VAR INT unUsed[1]
}
#
# A pseudo-union structure. It looks like it contains several varying-length
# arrays, but in reality only one of them has anything in it, and only one
# brain at that.
STATEDESC brainUnion
{
VERSION 1
VAR $genericBrain fGenericBrain[]
VAR $climbBrain fClimbBrain[]
VAR $driveBrain fDriveBrain[]
}
#
# The base block contains state for the plAvBrainHuman (which all avatars must have)
# and a variable-length state of brains of varying type.
#
STATEDESC avatar
{
VERSION 5
VAR $brainUnion brainStack[]
VAR BYTE invisibilityLevel[1] DEFAULT=0 # 0 means visible, >0 is CCR level of invisibility
}
STATEDESC avatar
{
VERSION 6
VAR $brainUnion brainStack[]
VAR BYTE invisibilityLevel[1] DEFAULT=0 # 0 means visible, >0 is CCR level of invisibility
VAR POINT3 position[1] DEFAULT=(0,0,0)
VAR FLOAT rotation[1] DEFAULT=0.0
VAR PLKEY subworld[1]
}
STATEDESC avatar
{
VERSION 7
VAR $brainUnion brainStack[]
VAR BYTE invisibilityLevel[1] DEFAULT=0 # 0 means visible, >0 is CCR level of invisibility
}
STATEDESC avatarPhysical
{
VERSION 1
VAR POINT3 position[1] DEFAULT=(0,0,0)
VAR FLOAT rotation[1] DEFAULT=0.0
VAR PLKEY subworld[1]
}
#===============================================
# Changing an SDL record? Be sure to leave the
# legacy record intact and make changes in
# a new copy of the record. - eap
#===============================================
#
# Avatar State Description
# You might want to read these from the bottom of the file up to get the top-down perspective
#
#
# Defines a standard anim stage (used by the genericBrain)
#
STATEDESC standardStage
{
VERSION 2
VAR STRING32 name[1]
VAR SHORT numLoops[1] DEFAULT=0 # -1=loopForever
VAR BYTE forward[1] DEFAULT=0 # 0=none, 1=kbd, 2=auto
VAR BYTE backward[1] DEFAULT=0 # 0=none, 1=kbd
VAR BYTE stageAdvance[1] DEFAULT=0 # 0=none, 1=auto
VAR BYTE stageRegress[1] DEFAULT=0 # 0=none, 1=auto
VAR BOOL notifyEnter[1] DEFAULT=false
VAR BOOL notifyLoop[1] DEFAULT=false
VAR BOOL notifyStageAdvance[1] DEFAULT=false
VAR BOOL notifyStageRegress[1] DEFAULT=false
VAR BOOL useGlobalCoords[1] DEFAULT=false
VAR FLOAT localTime[1] DEFAULT=0
VAR FLOAT length[1] DEFAULT=0
VAR SHORT currentLoop[1] DEFAULT=0
VAR BOOL isAttached[1] DEFAULT=false
}
STATEDESC standardStage
{
VERSION 3
VAR STRING32 name[1]
VAR SHORT numLoops[1] DEFAULT=0 # -1=loopForever
VAR BYTE forward[1] DEFAULT=0 # 0=none, 1=kbd, 2=auto
VAR BYTE backward[1] DEFAULT=0 # 0=none, 1=kbd
VAR BYTE stageAdvance[1] DEFAULT=0 # 0=none, 1=auto
VAR BYTE stageRegress[1] DEFAULT=0 # 0=none, 1=auto
VAR BOOL notifyEnter[1] DEFAULT=false
VAR BOOL notifyLoop[1] DEFAULT=false
VAR BOOL notifyStageAdvance[1] DEFAULT=false
VAR BOOL notifyStageRegress[1] DEFAULT=false
VAR BOOL useGlobalCoords[1] DEFAULT=false
VAR FLOAT localTime[1] DEFAULT=0
VAR SHORT currentLoop[1] DEFAULT=0
VAR BOOL isAttached[1] DEFAULT=false
}
#
# State for the plAvBrainGeneric
#
STATEDESC genericBrain
{
VERSION 3
VAR BOOL noBrain[1] DEFAULT=true # set if not a brain
VAR $standardStage stages[]
VAR BYTE currentStage[1] DEFAULT=0
VAR BOOL freezePhysicalAtEnd[1] DEFAULT=false
VAR PLKEY callbackRcvr[1]
VAR BOOL movingForward[1] DEFAULT=true
VAR BYTE exitFlags[1] DEFAULT=0
VAR BYTE type[1] # could be byte
VAR BYTE mode[1] # could be byte
VAR FLOAT fadeIn[1] DEFAULT=1.0
VAR FLOAT fadeOut[1] DEFAULT=1.0
VAR BYTE moveMode[1] # could be byte
VAR BYTE bodyUsage[1] # could be byte
}
#
# State for the plAvBrainClimb
#
STATEDESC climbBrain
{
VERSION 1
VAR INT curMode[1]
VAR INT nextMode[1]
VAR INT allowedDirections[1]
VAR INT allowedDismounts[1]
VAR FLOAT vertProbeLength[1]
VAR FLOAT horizProbeLength[1]
VAR BOOL curStageAttached[1]
VAR INT curStage[1]
VAR FLOAT curStageTime[1]
VAR FLOAT curStageStrength[1]
VAR BOOL exitStageAttached[1]
VAR INT exitStage[1]
VAR FLOAT exitStageTime[1]
VAR BOOL exitStageStrength[1]
}
STATEDESC driveBrain
{
VERSION 1
VAR INT unUsed[1]
}
#
# A pseudo-union structure. It looks like it contains several varying-length
# arrays, but in reality only one of them has anything in it, and only one
# brain at that.
STATEDESC brainUnion
{
VERSION 1
VAR $genericBrain fGenericBrain[]
VAR $climbBrain fClimbBrain[]
VAR $driveBrain fDriveBrain[]
}
#
# The base block contains state for the plAvBrainHuman (which all avatars must have)
# and a variable-length state of brains of varying type.
#
STATEDESC avatar
{
VERSION 5
VAR $brainUnion brainStack[]
VAR BYTE invisibilityLevel[1] DEFAULT=0 # 0 means visible, >0 is CCR level of invisibility
}
STATEDESC avatar
{
VERSION 6
VAR $brainUnion brainStack[]
VAR BYTE invisibilityLevel[1] DEFAULT=0 # 0 means visible, >0 is CCR level of invisibility
VAR POINT3 position[1] DEFAULT=(0,0,0)
VAR FLOAT rotation[1] DEFAULT=0.0
VAR PLKEY subworld[1]
}
STATEDESC avatar
{
VERSION 7
VAR $brainUnion brainStack[]
VAR BYTE invisibilityLevel[1] DEFAULT=0 # 0 means visible, >0 is CCR level of invisibility
}
STATEDESC avatarPhysical
{
VERSION 1
VAR POINT3 position[1] DEFAULT=(0,0,0)
VAR FLOAT rotation[1] DEFAULT=0.0
VAR PLKEY subworld[1]
}

View File

@ -1,23 +1,23 @@
#===============================================
# Changing an SDL record? Be sure to leave the
# legacy record intact and make changes in
# a new copy of the record. - eap
#===============================================
#
# State Description Language for a LoadClone message
# Currently only used by the gameserver to store a loadClone msg as dynamic object state
#
#
# This is the only SDL file allowed to use the "CREATABLE" type. Normally that type is
# a security hole. We can't guarantee that trying to read a creatable on an arbitrary
# (i.e. hacked) stream won't crash the game. However, since this state is generated by the
# server, we can trust that.
#
STATEDESC CloneMessage
{
VERSION 1
VAR CREATABLE message[1] # The message as a creatable stream
}
#===============================================
# Changing an SDL record? Be sure to leave the
# legacy record intact and make changes in
# a new copy of the record. - eap
#===============================================
#
# State Description Language for a LoadClone message
# Currently only used by the gameserver to store a loadClone msg as dynamic object state
#
#
# This is the only SDL file allowed to use the "CREATABLE" type. Normally that type is
# a security hole. We can't guarantee that trying to read a creatable on an arbitrary
# (i.e. hacked) stream won't crash the game. However, since this state is generated by the
# server, we can trust that.
#
STATEDESC CloneMessage
{
VERSION 1
VAR CREATABLE message[1] # The message as a creatable stream
}

View File

@ -1,46 +1,46 @@
#===============================================
# Changing an SDL record? Be sure to leave the
# legacy record intact and make changes in
# a new copy of the record. - eap
#===============================================
#
# State Description for an avatar's clothing
#
#
# Helper SDL desc
# Defines an item of clothing
#
STATEDESC clothingItem
{
VERSION 3 # version is an int
VAR PLKEY item[1]
VAR RGB8 tint[1] DEFAULT=(1,1,1)
VAR RGB8 tint2[1] DEFAULT=(1,1,1)
}
#
# Helper SDL desc
# Defines appearance options
#
STATEDESC appearanceOptions
{
VERSION 2
VAR RGB8 skinTint[1] DEFAULT=(1,1,1)
VAR BYTE faceBlends[] DEFAULT=0;
}
#
# Top level SDL desc
# A variable-length list of clothing items
#
STATEDESC clothing
{
VERSION 4
VAR $clothingItem wardrobe[]
VAR $appearanceOptions appearance[1]
VAR PLKEY linkInAnim[1] DEFAULT=nil
}
#===============================================
# Changing an SDL record? Be sure to leave the
# legacy record intact and make changes in
# a new copy of the record. - eap
#===============================================
#
# State Description for an avatar's clothing
#
#
# Helper SDL desc
# Defines an item of clothing
#
STATEDESC clothingItem
{
VERSION 3 # version is an int
VAR PLKEY item[1]
VAR RGB8 tint[1] DEFAULT=(1,1,1)
VAR RGB8 tint2[1] DEFAULT=(1,1,1)
}
#
# Helper SDL desc
# Defines appearance options
#
STATEDESC appearanceOptions
{
VERSION 2
VAR RGB8 skinTint[1] DEFAULT=(1,1,1)
VAR BYTE faceBlends[] DEFAULT=0;
}
#
# Top level SDL desc
# A variable-length list of clothing items
#
STATEDESC clothing
{
VERSION 4
VAR $clothingItem wardrobe[]
VAR $appearanceOptions appearance[1]
VAR PLKEY linkInAnim[1] DEFAULT=nil
}

View File

@ -1,28 +1,28 @@
#===============================================
# Changing an SDL record? Be sure to leave the
# legacy record intact and make changes in
# a new copy of the record. - eap
#===============================================
#
# State Description for a morph sequence modifier
#
STATEDESC MorphSet
{
VERSION 2
VAR PLKEY mesh[1] DEFAULT=nil
VAR BYTE weights[] DEFAULT=0
}
STATEDESC MorphSequence
{
VERSION 2
# User data. The avatar sets this so that it can later differentiate between
# various records in the vault
VAR BYTE targetID[1] DEFAULT=0
VAR $MorphSet morphs[]
}
#===============================================
# Changing an SDL record? Be sure to leave the
# legacy record intact and make changes in
# a new copy of the record. - eap
#===============================================
#
# State Description for a morph sequence modifier
#
STATEDESC MorphSet
{
VERSION 2
VAR PLKEY mesh[1] DEFAULT=nil
VAR BYTE weights[] DEFAULT=0
}
STATEDESC MorphSequence
{
VERSION 2
# User data. The avatar sets this so that it can later differentiate between
# various records in the vault
VAR BYTE targetID[1] DEFAULT=0
VAR $MorphSet morphs[]
}

View File

@ -1,17 +1,17 @@
#===============================================
# Changing an SDL record? Be sure to leave the
# legacy record intact and make changes in
# a new copy of the record. - eap
#===============================================
#
# State Description for a morph sequence modifier
# 99% of the particle systems won't need this (and won't save state)
# This is intended for cloned systems that attach to the avatar.
#
STATEDESC ParticleSystem
{
VERSION 1
VAR INT numParticles[1] DEFAULT=0
}
#===============================================
# Changing an SDL record? Be sure to leave the
# legacy record intact and make changes in
# a new copy of the record. - eap
#===============================================
#
# State Description for a morph sequence modifier
# 99% of the particle systems won't need this (and won't save state)
# This is intended for cloned systems that attach to the avatar.
#
STATEDESC ParticleSystem
{
VERSION 1
VAR INT numParticles[1] DEFAULT=0
}

View File

@ -1,23 +1,23 @@
#===============================================
# Changing an SDL record? Be sure to leave the
# legacy record intact and make changes in
# a new copy of the record. - eap
#===============================================
#
# State Description Language for
# physical changes to an object
#
STATEDESC physical
{
VERSION 2
VAR POINT3 position[1] DEFAULT=(0,0,0)
VAR QUATERNION orientation[1] DEFAULT=(0,0,0,1)
VAR VECTOR3 linear[1] DEFAULT=(0,0,0)
VAR VECTOR3 angular[1] DEFAULT=(0,0,0)
VAR PLKEY subworld[1]
}
#===============================================
# Changing an SDL record? Be sure to leave the
# legacy record intact and make changes in
# a new copy of the record. - eap
#===============================================
#
# State Description Language for
# physical changes to an object
#
STATEDESC physical
{
VERSION 2
VAR POINT3 position[1] DEFAULT=(0,0,0)
VAR QUATERNION orientation[1] DEFAULT=(0,0,0,1)
VAR VECTOR3 linear[1] DEFAULT=(0,0,0)
VAR VECTOR3 angular[1] DEFAULT=(0,0,0)
VAR PLKEY subworld[1]
}

View File

@ -1,24 +1,24 @@
#===============================================
# Changing an SDL record? Be sure to leave the
# legacy record intact and make changes in
# a new copy of the record. - eap
#===============================================
#
# State Description Language for a responder
#
STATEDESC Responder
{
VERSION 3
VAR INT curState[1] DEFAULT=0 # The current state (first index for fCommandList)
VAR INT curCommand[1] DEFAULT=-1 # The command we are currently waiting to send
# (or -1 if we're not sending)
VAR BOOL netRequest[1] DEFAULT=false # Was the last trigger a net request
VAR INT completedEvents[] # Which events that commands are waiting on have completed
VAR BOOL enabled[1] DEFAULT=true
VAR PLKEY playerKey[1] # The player who triggered this last
VAR PLKEY triggerer[1] # Whoever triggered us (for sending notify callbacks)
}
#===============================================
# Changing an SDL record? Be sure to leave the
# legacy record intact and make changes in
# a new copy of the record. - eap
#===============================================
#
# State Description Language for a responder
#
STATEDESC Responder
{
VERSION 3
VAR INT curState[1] DEFAULT=0 # The current state (first index for fCommandList)
VAR INT curCommand[1] DEFAULT=-1 # The command we are currently waiting to send
# (or -1 if we're not sending)
VAR BOOL netRequest[1] DEFAULT=false # Was the last trigger a net request
VAR INT completedEvents[] # Which events that commands are waiting on have completed
VAR BOOL enabled[1] DEFAULT=true
VAR PLKEY playerKey[1] # The player who triggered this last
VAR PLKEY triggerer[1] # Whoever triggered us (for sending notify callbacks)
}

View File

@ -1,29 +1,29 @@
#===============================================
# Changing an SDL record? Be sure to leave the
# legacy record intact and make changes in
# a new copy of the record. - eap
#===============================================
#
# State Description Language for sounds
#
STATEDESC SoundState
{
VERSION 1
VAR FLOAT desiredVolume[1] DEFAULT=0 # 0 to 1
VAR TIME time[1] DEFAULT=0 # time sound was started
VAR BOOL playing[1] DEFAULT=false # is it playing
}
#
# Describes the sound state for a sceneObject
# TOPLEVEL
#
STATEDESC Sound
{
VERSION 1
VAR $SoundState sounds[] # List of soundStates on a sceneObject
}
#===============================================
# Changing an SDL record? Be sure to leave the
# legacy record intact and make changes in
# a new copy of the record. - eap
#===============================================
#
# State Description Language for sounds
#
STATEDESC SoundState
{
VERSION 1
VAR FLOAT desiredVolume[1] DEFAULT=0 # 0 to 1
VAR TIME time[1] DEFAULT=0 # time sound was started
VAR BOOL playing[1] DEFAULT=false # is it playing
}
#
# Describes the sound state for a sceneObject
# TOPLEVEL
#
STATEDESC Sound
{
VERSION 1
VAR $SoundState sounds[] # List of soundStates on a sceneObject
}

View File

@ -1,15 +1,15 @@
#===============================================
# Changing an SDL record? Be sure to leave the
# legacy record intact and make changes in
# a new copy of the record. - eap
#===============================================
#
# State Description Language for Exclude Regions
#
STATEDESC XRegion
{
VERSION 1
VAR BOOL cleared[1] DEFAULT=false # is it cleared
#===============================================
# Changing an SDL record? Be sure to leave the
# legacy record intact and make changes in
# a new copy of the record. - eap
#===============================================
#
# State Description Language for Exclude Regions
#
STATEDESC XRegion
{
VERSION 1
VAR BOOL cleared[1] DEFAULT=false # is it cleared
}

File diff suppressed because it is too large Load Diff

View File

@ -1,33 +1,33 @@
/*==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 plSDLCreatable_h
#define plSDLCreatable_h
#include "plSDL.h"
REGISTER_CREATABLE(plStateDataRecord);
#endif // plSDLCreatable_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 plSDLCreatable_h
#define plSDLCreatable_h
#include "plSDL.h"
REGISTER_CREATABLE(plStateDataRecord);
#endif // plSDLCreatable_h

View File

@ -1,240 +1,240 @@
/*==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 plSDL_DESC_inc
#define plSDL_DESC_inc
//
// Code for State Description Language (SDL) Descriptors.
// These define a schema representing an object's saveState buffer.
//
#include "hsTypes.h"
#include "hsUtils.h"
#include "hsStlUtils.h"
//
// Describes a variable in a state descriptor.
// Every variable is actually a list, either fixed or variable length.
// Abstract base class.
//
class hsStream;
class plSimpleVarDescriptor;
class plSDVarDescriptor;
class plVarDescriptor
{
public:
enum Type
{
kNone = -1,
// atomic types
kInt,
kFloat,
kBool,
kString32,
kKey, // plKey - basically a uoid
kStateDescriptor, // this var refers to another state descriptor
kCreatable, // plCreatable - basically a classIdx and a read/write buffer
kDouble,
kTime, // double which is automatically converted to server clock and back, use for animation times
kByte,
kShort,
kAgeTimeOfDay, // float which is automatically set to the current age time of day (0-1)
// the following are a vector of floats
kVector3=50,// atomicCount=3
kPoint3, // atomicCount=3
kRGB, // atomicCount=3
kRGBA, // atomicCount=4
kQuaternion, // atomicCount=4
kRGB8, // atomicCount=3
kRGBA8, // atomicCount=4
};
typedef char String32[32];
enum Flags
{
kInternal = 0x1, // Don't allow access to this var in Vault Mgr
kAlwaysNew = 0x2, // Treat this var as always having the latest timestamp when FlaggingNewerState
kVariableLength = 0x4 // Var is defined as int foo[], so it's length is variable, starting at 0
};
protected:
static const UInt8 kVersion; // for Read/Write format
char* fDefault; // set by .sdl
char* fName; // set by .sdl
int fCount; // set by .sdl
Type fType; // set by .sdl
char* fTypeString; // string version of fType
UInt32 fFlags;
std::string fDisplayOptions; // set by .sdl
public:
plVarDescriptor();
virtual ~plVarDescriptor();
virtual void CopyFrom(const plVarDescriptor* v);
// conversion ops
virtual plSimpleVarDescriptor* GetAsSimpleVarDescriptor() = 0;
virtual plSDVarDescriptor* GetAsSDVarDescriptor() = 0;
virtual const plSimpleVarDescriptor* GetAsSimpleVarDescriptor() const = 0;
virtual const plSDVarDescriptor* GetAsSDVarDescriptor() const = 0;
// getters
const char* GetDefault() const { return fDefault; }
const char* GetName() const { return fName; }
Type GetType() const { return fType; }
const char* GetTypeString() const { return fTypeString; }
int GetCount() const { return fCount; }
bool IsInternal() const { return (fFlags & kInternal) != 0; }
bool IsAlwaysNew() const { return (fFlags & kAlwaysNew) != 0; }
bool IsVariableLength() const { return (fFlags & kVariableLength) != 0; }
const char* GetDisplayOptions() const { return fDisplayOptions.c_str(); }
// setters
void SetDefault(const char* n) { delete [] fDefault; fDefault= hsStrcpy(n); }
void SetName(const char* n) { delete [] fName; fName = hsStrcpy(n); }
void SetCount(int c) { fCount=c; }
virtual bool SetType(const char* type);
void SetType(Type t) { fType=t; }
void SetInternal(bool d) { if (d) fFlags |= kInternal; else fFlags &= ~kInternal; }
void SetAlwaysNew(bool d) { if (d) fFlags |= kAlwaysNew; else fFlags &= ~kAlwaysNew; }
void SetVariableLength(bool d) { if (d) fFlags |= kVariableLength; else fFlags &= ~kVariableLength; }
void SetDisplayOptions(const char* s) { fDisplayOptions=s; }
// IO
virtual bool Read(hsStream* s);
virtual void Write(hsStream* s) const;
};
//
// Simple, non-nested var descriptors. These are comprised of single types, as opposed to
// referring to another state descriptor.
//
class plSimpleVarDescriptor : public plVarDescriptor
{
protected:
Type fAtomicType; // base type (it. quaternion == kFloat)
int fAtomicCount; // computed from type in .sdl (ie. quaternion == 4)
public:
plSimpleVarDescriptor();
virtual ~plSimpleVarDescriptor() { }
plSimpleVarDescriptor* GetAsSimpleVarDescriptor() { return this; }
plSDVarDescriptor* GetAsSDVarDescriptor() { return nil; }
const plSimpleVarDescriptor* GetAsSimpleVarDescriptor() const { return this; }
const plSDVarDescriptor* GetAsSDVarDescriptor() const { return nil; }
void CopyFrom(const plSimpleVarDescriptor* v);
void CopyFrom(const plVarDescriptor* v) { plVarDescriptor::CopyFrom(v); } // lame compiler
// getters
int GetSize() const;
int GetAtomicSize() const; // size of one item in bytes (regardless of count)
Type GetAtomicType() const { return fAtomicType; }
int GetAtomicCount() const { return fAtomicCount; }
// setters
bool SetType(const char* type);
void SetType(Type t) { plVarDescriptor::SetType(t); } // for lame compiler
void SetAtomicType(Type t) { fAtomicType=t; }
// IO
virtual bool Read(hsStream* s);
virtual void Write(hsStream* s) const;
};
//
// A var descriptor which references another state descriptor.
//
class plStateDescriptor;
class plSDVarDescriptor : public plVarDescriptor
{
protected:
plStateDescriptor* fStateDesc;
public:
plSDVarDescriptor(plStateDescriptor* sd=nil) : fStateDesc(sd) { }
plSimpleVarDescriptor* GetAsSimpleVarDescriptor() { return nil; }
plSDVarDescriptor* GetAsSDVarDescriptor() { return this; }
const plSimpleVarDescriptor* GetAsSimpleVarDescriptor() const { return nil; }
const plSDVarDescriptor* GetAsSDVarDescriptor() const { return this; }
// getters
plStateDescriptor* GetStateDescriptor() const { return fStateDesc; }
// setters
void SetStateDesc(plStateDescriptor* sd) { fStateDesc=sd; }
void CopyFrom(const plSDVarDescriptor* v);
void CopyFrom(const plVarDescriptor* v) { plVarDescriptor::CopyFrom(v); } // lame compiler
// IO
bool Read(hsStream* s);
void Write(hsStream* s) const;
};
//
// A state descriptor - describes the contents of a type of state buffer.
// There is one of these for each persistent object type.
// These descriptors are defined in a user-created .sdl file.
//
class plKey;
class plStateDescriptor
{
private:
static const UInt8 kVersion; // for Read/Write format
typedef std::vector<plVarDescriptor*> VarsList;
VarsList fVarsList;
int fVersion;
char* fName;
std::string fFilename; // the filename this descriptor was read from
void IDeInit();
public:
plStateDescriptor() : fVersion(-1),fName(nil) {}
~plStateDescriptor();
// getters
const char* GetName() const { return fName; }
int GetNumVars() const { return fVarsList.size(); }
plVarDescriptor* GetVar(int i) const { return fVarsList[i]; }
int GetVersion() const { return fVersion; }
const char * GetFilename() const { return fFilename.c_str();}
// setters
void SetVersion(int v) { fVersion=v; }
void SetName(const char* n) { delete [] fName; fName=hsStrcpy(n); }
void AddVar(plVarDescriptor* v) { fVarsList.push_back(v); }
void SetFilename( const char * n ) { fFilename=n;}
plVarDescriptor* FindVar(const char* name, int* idx=nil) const;
// IO
bool Read(hsStream* s);
void Write(hsStream* s) const;
};
#endif // plSDL_DESC_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 plSDL_DESC_inc
#define plSDL_DESC_inc
//
// Code for State Description Language (SDL) Descriptors.
// These define a schema representing an object's saveState buffer.
//
#include "hsTypes.h"
#include "hsUtils.h"
#include "hsStlUtils.h"
//
// Describes a variable in a state descriptor.
// Every variable is actually a list, either fixed or variable length.
// Abstract base class.
//
class hsStream;
class plSimpleVarDescriptor;
class plSDVarDescriptor;
class plVarDescriptor
{
public:
enum Type
{
kNone = -1,
// atomic types
kInt,
kFloat,
kBool,
kString32,
kKey, // plKey - basically a uoid
kStateDescriptor, // this var refers to another state descriptor
kCreatable, // plCreatable - basically a classIdx and a read/write buffer
kDouble,
kTime, // double which is automatically converted to server clock and back, use for animation times
kByte,
kShort,
kAgeTimeOfDay, // float which is automatically set to the current age time of day (0-1)
// the following are a vector of floats
kVector3=50,// atomicCount=3
kPoint3, // atomicCount=3
kRGB, // atomicCount=3
kRGBA, // atomicCount=4
kQuaternion, // atomicCount=4
kRGB8, // atomicCount=3
kRGBA8, // atomicCount=4
};
typedef char String32[32];
enum Flags
{
kInternal = 0x1, // Don't allow access to this var in Vault Mgr
kAlwaysNew = 0x2, // Treat this var as always having the latest timestamp when FlaggingNewerState
kVariableLength = 0x4 // Var is defined as int foo[], so it's length is variable, starting at 0
};
protected:
static const UInt8 kVersion; // for Read/Write format
char* fDefault; // set by .sdl
char* fName; // set by .sdl
int fCount; // set by .sdl
Type fType; // set by .sdl
char* fTypeString; // string version of fType
UInt32 fFlags;
std::string fDisplayOptions; // set by .sdl
public:
plVarDescriptor();
virtual ~plVarDescriptor();
virtual void CopyFrom(const plVarDescriptor* v);
// conversion ops
virtual plSimpleVarDescriptor* GetAsSimpleVarDescriptor() = 0;
virtual plSDVarDescriptor* GetAsSDVarDescriptor() = 0;
virtual const plSimpleVarDescriptor* GetAsSimpleVarDescriptor() const = 0;
virtual const plSDVarDescriptor* GetAsSDVarDescriptor() const = 0;
// getters
const char* GetDefault() const { return fDefault; }
const char* GetName() const { return fName; }
Type GetType() const { return fType; }
const char* GetTypeString() const { return fTypeString; }
int GetCount() const { return fCount; }
bool IsInternal() const { return (fFlags & kInternal) != 0; }
bool IsAlwaysNew() const { return (fFlags & kAlwaysNew) != 0; }
bool IsVariableLength() const { return (fFlags & kVariableLength) != 0; }
const char* GetDisplayOptions() const { return fDisplayOptions.c_str(); }
// setters
void SetDefault(const char* n) { delete [] fDefault; fDefault= hsStrcpy(n); }
void SetName(const char* n) { delete [] fName; fName = hsStrcpy(n); }
void SetCount(int c) { fCount=c; }
virtual bool SetType(const char* type);
void SetType(Type t) { fType=t; }
void SetInternal(bool d) { if (d) fFlags |= kInternal; else fFlags &= ~kInternal; }
void SetAlwaysNew(bool d) { if (d) fFlags |= kAlwaysNew; else fFlags &= ~kAlwaysNew; }
void SetVariableLength(bool d) { if (d) fFlags |= kVariableLength; else fFlags &= ~kVariableLength; }
void SetDisplayOptions(const char* s) { fDisplayOptions=s; }
// IO
virtual bool Read(hsStream* s);
virtual void Write(hsStream* s) const;
};
//
// Simple, non-nested var descriptors. These are comprised of single types, as opposed to
// referring to another state descriptor.
//
class plSimpleVarDescriptor : public plVarDescriptor
{
protected:
Type fAtomicType; // base type (it. quaternion == kFloat)
int fAtomicCount; // computed from type in .sdl (ie. quaternion == 4)
public:
plSimpleVarDescriptor();
virtual ~plSimpleVarDescriptor() { }
plSimpleVarDescriptor* GetAsSimpleVarDescriptor() { return this; }
plSDVarDescriptor* GetAsSDVarDescriptor() { return nil; }
const plSimpleVarDescriptor* GetAsSimpleVarDescriptor() const { return this; }
const plSDVarDescriptor* GetAsSDVarDescriptor() const { return nil; }
void CopyFrom(const plSimpleVarDescriptor* v);
void CopyFrom(const plVarDescriptor* v) { plVarDescriptor::CopyFrom(v); } // lame compiler
// getters
int GetSize() const;
int GetAtomicSize() const; // size of one item in bytes (regardless of count)
Type GetAtomicType() const { return fAtomicType; }
int GetAtomicCount() const { return fAtomicCount; }
// setters
bool SetType(const char* type);
void SetType(Type t) { plVarDescriptor::SetType(t); } // for lame compiler
void SetAtomicType(Type t) { fAtomicType=t; }
// IO
virtual bool Read(hsStream* s);
virtual void Write(hsStream* s) const;
};
//
// A var descriptor which references another state descriptor.
//
class plStateDescriptor;
class plSDVarDescriptor : public plVarDescriptor
{
protected:
plStateDescriptor* fStateDesc;
public:
plSDVarDescriptor(plStateDescriptor* sd=nil) : fStateDesc(sd) { }
plSimpleVarDescriptor* GetAsSimpleVarDescriptor() { return nil; }
plSDVarDescriptor* GetAsSDVarDescriptor() { return this; }
const plSimpleVarDescriptor* GetAsSimpleVarDescriptor() const { return nil; }
const plSDVarDescriptor* GetAsSDVarDescriptor() const { return this; }
// getters
plStateDescriptor* GetStateDescriptor() const { return fStateDesc; }
// setters
void SetStateDesc(plStateDescriptor* sd) { fStateDesc=sd; }
void CopyFrom(const plSDVarDescriptor* v);
void CopyFrom(const plVarDescriptor* v) { plVarDescriptor::CopyFrom(v); } // lame compiler
// IO
bool Read(hsStream* s);
void Write(hsStream* s) const;
};
//
// A state descriptor - describes the contents of a type of state buffer.
// There is one of these for each persistent object type.
// These descriptors are defined in a user-created .sdl file.
//
class plKey;
class plStateDescriptor
{
private:
static const UInt8 kVersion; // for Read/Write format
typedef std::vector<plVarDescriptor*> VarsList;
VarsList fVarsList;
int fVersion;
char* fName;
std::string fFilename; // the filename this descriptor was read from
void IDeInit();
public:
plStateDescriptor() : fVersion(-1),fName(nil) {}
~plStateDescriptor();
// getters
const char* GetName() const { return fName; }
int GetNumVars() const { return fVarsList.size(); }
plVarDescriptor* GetVar(int i) const { return fVarsList[i]; }
int GetVersion() const { return fVersion; }
const char * GetFilename() const { return fFilename.c_str();}
// setters
void SetVersion(int v) { fVersion=v; }
void SetName(const char* n) { delete [] fName; fName=hsStrcpy(n); }
void AddVar(plVarDescriptor* v) { fVarsList.push_back(v); }
void SetFilename( const char * n ) { fFilename=n;}
plVarDescriptor* FindVar(const char* name, int* idx=nil) const;
// IO
bool Read(hsStream* s);
void Write(hsStream* s) const;
};
#endif // plSDL_DESC_inc

View File

@ -1,191 +1,191 @@
/*==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 "hsStream.h"
#include "hsStlUtils.h"
#include "plSDL.h"
#include "pnNetCommon/plNetApp.h"
#include "pnNetCommon/pnNetCommon.h"
#include <algorithm>
/////////////////////////////////////////////////////////////////////////////////
// SDL MGR
/////////////////////////////////////////////////////////////////////////////////
//
//
//
plSDLMgr::plSDLMgr() : fSDLDir("SDL"), fNetApp(nil), fBehaviorFlags(0)
{
}
//
//
//
plSDLMgr::~plSDLMgr()
{
DeInit();
}
bool plSDLMgr::Init( UInt32 behaviorFlags )
{
fBehaviorFlags = behaviorFlags;
plSDLParser parser;
return parser.Parse();
}
void plSDLMgr::DeInit()
{
IDeleteDescriptors(&fDescriptors);
}
//
// delete all descriptors
//
void plSDLMgr::IDeleteDescriptors(plSDL::DescriptorList* dl)
{
std::for_each( dl->begin(), dl->end(), xtl::delete_ptr() );
dl->clear();
}
//
// STATIC
//
plSDLMgr* plSDLMgr::GetInstance()
{
static plSDLMgr gSDLMgr;
return &gSDLMgr;
}
//
// search latest and legacy descriptors for one that matches.
// if version is -1, search for latest descriptor with matching name
//
plStateDescriptor* plSDLMgr::FindDescriptor(const char* name, int version, const plSDL::DescriptorList * dl) const
{
if (!name)
return nil;
if ( !dl )
dl = &fDescriptors;
plStateDescriptor* sd = nil;
plSDL::DescriptorList::const_iterator it;
int highestFound = -1;
for(it=(*dl).begin(); it!= (*dl).end(); it++)
{
if (!_stricmp((*it)->GetName(), name) )
{
if ( (*it)->GetVersion()==version )
{
sd = *it;
break;
}
else if ( version==plSDL::kLatestVersion && (*it)->GetVersion()>highestFound )
{
sd = *it;
highestFound = (*it)->GetVersion();
}
}
}
return sd;
}
//
// write latest descriptors to a stream.
// return number of bytes
//
int plSDLMgr::Write(hsStream* s, const plSDL::DescriptorList* dl)
{
int pos=s->GetPosition();
if (dl==nil)
dl=&fDescriptors;
UInt16 num=dl->size();
s->WriteSwap(num);
plSDL::DescriptorList::const_iterator it;
for(it=dl->begin(); it!= dl->end(); it++)
(*it)->Write(s);
int bytes=s->GetPosition()-pos;
if (fNetApp)
{
hsLogEntry(fNetApp->DebugMsg("Writing %d SDL descriptors, %d bytes", num, bytes));
}
return bytes;
}
//
// read descriptors into provided list
// return number of bytes
//
int plSDLMgr::Read(hsStream* s, plSDL::DescriptorList* dl)
{
int pos=s->GetPosition();
if (dl==nil)
dl=&fDescriptors;
// clear dl
IDeleteDescriptors(dl);
UInt16 num;
try
{
// read dtor list
s->ReadSwap(&num);
int i;
for(i=0;i<num;i++)
{
plStateDescriptor* sd=TRACKED_NEW plStateDescriptor;
if (sd->Read(s))
dl->push_back(sd);
}
}
catch(...)
{
if (fNetApp)
{
hsLogEntry(fNetApp->DebugMsg("Something bad happened while reading SDLMgr data"));
}
return 0;
}
int bytes=s->GetPosition()-pos;
if (fNetApp)
{
hsLogEntry(fNetApp->DebugMsg("Reading %d SDL descriptors, %d bytes", num, bytes));
}
return bytes;
}
/*==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 "hsStream.h"
#include "hsStlUtils.h"
#include "plSDL.h"
#include "pnNetCommon/plNetApp.h"
#include "pnNetCommon/pnNetCommon.h"
#include <algorithm>
/////////////////////////////////////////////////////////////////////////////////
// SDL MGR
/////////////////////////////////////////////////////////////////////////////////
//
//
//
plSDLMgr::plSDLMgr() : fSDLDir("SDL"), fNetApp(nil), fBehaviorFlags(0)
{
}
//
//
//
plSDLMgr::~plSDLMgr()
{
DeInit();
}
bool plSDLMgr::Init( UInt32 behaviorFlags )
{
fBehaviorFlags = behaviorFlags;
plSDLParser parser;
return parser.Parse();
}
void plSDLMgr::DeInit()
{
IDeleteDescriptors(&fDescriptors);
}
//
// delete all descriptors
//
void plSDLMgr::IDeleteDescriptors(plSDL::DescriptorList* dl)
{
std::for_each( dl->begin(), dl->end(), xtl::delete_ptr() );
dl->clear();
}
//
// STATIC
//
plSDLMgr* plSDLMgr::GetInstance()
{
static plSDLMgr gSDLMgr;
return &gSDLMgr;
}
//
// search latest and legacy descriptors for one that matches.
// if version is -1, search for latest descriptor with matching name
//
plStateDescriptor* plSDLMgr::FindDescriptor(const char* name, int version, const plSDL::DescriptorList * dl) const
{
if (!name)
return nil;
if ( !dl )
dl = &fDescriptors;
plStateDescriptor* sd = nil;
plSDL::DescriptorList::const_iterator it;
int highestFound = -1;
for(it=(*dl).begin(); it!= (*dl).end(); it++)
{
if (!_stricmp((*it)->GetName(), name) )
{
if ( (*it)->GetVersion()==version )
{
sd = *it;
break;
}
else if ( version==plSDL::kLatestVersion && (*it)->GetVersion()>highestFound )
{
sd = *it;
highestFound = (*it)->GetVersion();
}
}
}
return sd;
}
//
// write latest descriptors to a stream.
// return number of bytes
//
int plSDLMgr::Write(hsStream* s, const plSDL::DescriptorList* dl)
{
int pos=s->GetPosition();
if (dl==nil)
dl=&fDescriptors;
UInt16 num=dl->size();
s->WriteSwap(num);
plSDL::DescriptorList::const_iterator it;
for(it=dl->begin(); it!= dl->end(); it++)
(*it)->Write(s);
int bytes=s->GetPosition()-pos;
if (fNetApp)
{
hsLogEntry(fNetApp->DebugMsg("Writing %d SDL descriptors, %d bytes", num, bytes));
}
return bytes;
}
//
// read descriptors into provided list
// return number of bytes
//
int plSDLMgr::Read(hsStream* s, plSDL::DescriptorList* dl)
{
int pos=s->GetPosition();
if (dl==nil)
dl=&fDescriptors;
// clear dl
IDeleteDescriptors(dl);
UInt16 num;
try
{
// read dtor list
s->ReadSwap(&num);
int i;
for(i=0;i<num;i++)
{
plStateDescriptor* sd=TRACKED_NEW plStateDescriptor;
if (sd->Read(s))
dl->push_back(sd);
}
}
catch(...)
{
if (fNetApp)
{
hsLogEntry(fNetApp->DebugMsg("Something bad happened while reading SDLMgr data"));
}
return 0;
}
int bytes=s->GetPosition()-pos;
if (fNetApp)
{
hsLogEntry(fNetApp->DebugMsg("Reading %d SDL descriptors, %d bytes", num, bytes));
}
return bytes;
}

View File

@ -1,423 +1,423 @@
/*==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 "plSDL.h"
#include "plFile/hsFiles.h"
#include "plFile/plStreamSource.h"
#include "pnNetCommon/pnNetCommon.h"
#include "pnNetCommon/plNetApp.h"
static const int kTokenLen=256;
void plSDLParser::DebugMsg(char* fmt, ...) const
{
return;
plNetApp* netApp = plSDLMgr::GetInstance()->GetNetApp();
va_list args;
va_start(args, fmt);
if (netApp)
{
hsLogEntry(netApp->DebugMsgV(fmt, args));
}
else
DebugMsgV(fmt, args);
va_end(args);
}
void plSDLParser::DebugMsgV(char* fmt, va_list args) const
{
if (strlen(fmt)==nil)
return;
hsStatusMessage(xtl::formatv(fmt,args).c_str());
}
//
// parsing stateDesc
// read name, version
// return true to skip the next token read
//
bool plSDLParser::IParseStateDesc(const char* fileName, hsStream* stream, char token[], plStateDescriptor*& curDesc) const
{
plSDL::DescriptorList* descList = &plSDLMgr::GetInstance()->fDescriptors;
bool ok = true;
//
// NAME
//
// curDesc=plSDLMgr::GetInstance()->FindDescriptor(token, plSDL::kLatestVersion);
// if (!curDesc)
{
curDesc = TRACKED_NEW plStateDescriptor;
curDesc->SetName(token);
DebugMsg("SDL: DESC name=%s", token);
}
//
// {
//
stream->GetToken(token, kTokenLen); // skip '{'
//
// VERSION
//
if (stream->GetToken(token, kTokenLen))
{
if (!strcmp(token, "VERSION"))
{
// read desc version
hsAssert(curDesc, xtl::format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
if (stream->GetToken(token, kTokenLen))
{
int v=atoi(token);
curDesc->SetVersion(v);
DebugMsg("\tVersion=%d", v);
}
}
else
{
hsAssert(false, xtl::format("Error parsing state desc, missing VERSION, fileName=%s",
fileName).c_str());
ok = false;
}
}
else
{
hsAssert(false, xtl::format("Error parsing state desc, fileName=%s", fileName).c_str());
ok = false;
}
if ( ok )
{
ok = ( plSDLMgr::GetInstance()->FindDescriptor(curDesc->GetName(), curDesc->GetVersion())==nil );
if ( !ok )
{
std::string err = xtl::format( "Found duplicate SDL descriptor for %s version %d.\nFailed to parse file: %s", curDesc->GetName(), curDesc->GetVersion(), fileName );
plNetApp::StaticErrorMsg( err.c_str() );
hsAssert( false, err.c_str() );
}
}
if ( ok )
{
descList->push_back(curDesc);
}
else
{
delete curDesc;
curDesc = nil;
}
return false;
}
//
// Parse a variable descriptor.
// read type, name, count [default]
// return true to skip the next token read
//
bool plSDLParser::IParseVarDesc(const char* fileName, hsStream* stream, char token[], plStateDescriptor*& curDesc,
plVarDescriptor*& curVar) const
{
hsAssert(curDesc, xtl::format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
if ( !curDesc )
return false;
bool skipNext=false;
std::string dbgStr;
static char seps[] = "( ,)[]";
// read type, name, cnt, [default]
//
// TYPE
// create new state var, make current
//
if (*token == '$')
{
// nested sdls
char* sdlName = token+1;
plStateDescriptor* stateDesc = plSDLMgr::GetInstance()->FindDescriptor(sdlName, plSDL::kLatestVersion);
hsAssert(stateDesc, xtl::format("can't find nested state desc reference %s, fileName=%s",
sdlName, fileName).c_str());
curVar = TRACKED_NEW plSDVarDescriptor(stateDesc);
}
else
curVar = TRACKED_NEW plSimpleVarDescriptor;
curDesc->AddVar(curVar);
bool ok=curVar->SetType(token);
hsAssert(ok, xtl::format("Variable 'type' syntax problem with .sdl file, type=%s, fileName=%s", token, fileName).c_str());
dbgStr = xtl::format("\tVAR Type=%s ", token).c_str();
//
// NAME (foo[1])
//
if (stream->GetToken(token, kTokenLen))
{
hsAssert(strstr(token, "[") && strstr(token, "]"), xtl::format("invalid var syntax, missing [x], fileName=%s",
fileName).c_str());
char* ptr = strtok( token, seps ); // skip [
hsAssert(curVar, xtl::format("Missing current var. Syntax problem with .sdl file, fileName=%s", fileName).c_str());
curVar->SetName(token);
//
// COUNT
//
char* cntTok=strtok(nil, seps); // kill ]
int cnt = cntTok ? atoi(cntTok) : 0;
curVar->SetCount(cnt);
if (cnt==0)
curVar->SetVariableLength(true);
dbgStr += xtl::format("Name=%s[%d]", curVar->GetName(), cnt).c_str();
}
//
// optional tokens: DEFAULT, INTERNAL
//
while (stream->GetToken(token, kTokenLen))
{
if (!strcmp(token, "DEFAULT"))
{
hsAssert(curVar, xtl::format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
// read state var type
std::string defaultStr;
plSimpleVarDescriptor* sVar=(plSimpleVarDescriptor*)curVar;
if (sVar)
{
int i;
for(i=0;i<sVar->GetAtomicCount();i++)
{
if (stream->GetToken(token, kTokenLen))
{
defaultStr += token;
if (i!=sVar->GetAtomicCount()-1)
defaultStr += ",";
}
}
}
if (defaultStr.size())
{
curVar->SetDefault(defaultStr.c_str());
dbgStr += std::string(" DEFAULT=") + defaultStr;
}
}
else
if (!strcmp(token, "DISPLAYOPTION"))
{
hsAssert(curVar, xtl::format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
dbgStr += std::string(" ") + token;
hsBool read=stream->GetToken(token, kTokenLen);
if (read)
{
std::string oldOptions=curVar->GetDisplayOptions();
if (oldOptions.size())
oldOptions += std::string(",");
oldOptions += token;
curVar->SetDisplayOptions(oldOptions.c_str());
dbgStr += std::string("=") + token;
if (!stricmp(token, "hidden"))
curVar->SetInternal(true);
}
else
{
hsAssert(false, xtl::format("missing displayOption string, fileName=%s", fileName).c_str());
}
}
else
if (!strcmp(token, "DEFAULTOPTION"))
{
hsAssert(curVar, xtl::format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
dbgStr += std::string(" ") + token;
hsBool read=stream->GetToken(token, kTokenLen);
if (read)
{
dbgStr += std::string("=") + token;
if (!stricmp(token, "vault"))
curVar->SetAlwaysNew(true);
}
else
{
hsAssert(false, xtl::format("missing defaultOption string, fileName=%s", fileName).c_str());
}
}
#if 1 // delete me in May 2003
else
if (!strcmp(token, "INTERNAL"))
{
hsAssert(curVar, xtl::format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
curVar->SetInternal(true);
dbgStr += std::string(" ") + token;
}
else
if (!strcmp(token, "PHASED"))
{
hsAssert(curVar, xtl::format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
curVar->SetAlwaysNew(true);
dbgStr += std::string(" ") + token;
}
#endif
else
{
skipNext=true;
break;
}
}
DebugMsg((char*)dbgStr.c_str());
return skipNext;
}
//
// create state descriptor from sdl file.
// return false on err.
//
bool plSDLParser::ILoadSDLFile(const char* fileName) const
{
DebugMsg("Parsing SDL file %s", fileName);
wchar_t* temp = hsStringToWString(fileName);
hsStream* stream = plStreamSource::GetInstance()->GetFile(temp);
delete [] temp;
if (!stream)
return false;
stream->Rewind();
plVarDescriptor* curVar=nil;
plStateDescriptor* curDesc=nil;
char token[kTokenLen];
bool parsingStateDesc=false;
bool skip=false;
while (1)
{
if (!skip)
{
if (!stream->GetToken(token, kTokenLen))
break;
}
skip=false;
if (!strcmp(token, "VAR"))
{
parsingStateDesc=false;
curVar=nil; // start fresh
continue;
}
if (!strcmp(token, "STATEDESC"))
{
parsingStateDesc=true;
curDesc=nil; // start fresh
continue;
}
if (!strcmp(token, "}"))
{
if ( curDesc )
curDesc->SetFilename( fileName );
parsingStateDesc=false;
continue;
}
if (parsingStateDesc)
{
skip=IParseStateDesc(fileName, stream, token, curDesc);
if ( !curDesc )
break; // failed to parse state desc
}
else
{
skip=IParseVarDesc(fileName, stream, token, curDesc, curVar);
}
}
// If the very last char is a } without a \n, then it won't be handled above for some reason, so we have to catch it here.
if ( curDesc )
curDesc->SetFilename( fileName );
// do not close or delete the stream, we do not own it
return true;
}
//
// load all .sdl files in sdl directory, and create descriptors for each.
// return false on error
//
bool plSDLParser::IReadDescriptors() const
{
std::string sdlDir = plSDLMgr::GetInstance()->GetSDLDir();
DebugMsg("SDL: Reading latest descriptors from directory %s", sdlDir.c_str());
wchar_t* temp = hsStringToWString(sdlDir.c_str());
std::wstring wSDLDir = temp;
delete [] temp;
// Get the names of all the sdl files
std::vector<std::wstring> files = plStreamSource::GetInstance()->GetListOfNames(wSDLDir, L".sdl");
bool ret=true;
int cnt=0;
for (int i = 0; i < files.size(); i++)
{
char* str = hsWStringToString(files[i].c_str());
if (!ILoadSDLFile(str))
{
plNetApp* netApp = plSDLMgr::GetInstance()->GetNetApp();
if (netApp)
netApp->ErrorMsg("Error loading SDL file %s", str);
else
hsStatusMessageF("Error loading SDL file %s", str);
ret=false;
}
else
cnt++;
delete [] str;
}
DebugMsg("Done reading SDL files");
if (!cnt)
ret=false;
return ret;
}
//
// reads sdl folder, creates descriptor list
//
bool plSDLParser::Parse() const
{
return IReadDescriptors();
}
/*==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 "plSDL.h"
#include "plFile/hsFiles.h"
#include "plFile/plStreamSource.h"
#include "pnNetCommon/pnNetCommon.h"
#include "pnNetCommon/plNetApp.h"
static const int kTokenLen=256;
void plSDLParser::DebugMsg(char* fmt, ...) const
{
return;
plNetApp* netApp = plSDLMgr::GetInstance()->GetNetApp();
va_list args;
va_start(args, fmt);
if (netApp)
{
hsLogEntry(netApp->DebugMsgV(fmt, args));
}
else
DebugMsgV(fmt, args);
va_end(args);
}
void plSDLParser::DebugMsgV(char* fmt, va_list args) const
{
if (strlen(fmt)==nil)
return;
hsStatusMessage(xtl::formatv(fmt,args).c_str());
}
//
// parsing stateDesc
// read name, version
// return true to skip the next token read
//
bool plSDLParser::IParseStateDesc(const char* fileName, hsStream* stream, char token[], plStateDescriptor*& curDesc) const
{
plSDL::DescriptorList* descList = &plSDLMgr::GetInstance()->fDescriptors;
bool ok = true;
//
// NAME
//
// curDesc=plSDLMgr::GetInstance()->FindDescriptor(token, plSDL::kLatestVersion);
// if (!curDesc)
{
curDesc = TRACKED_NEW plStateDescriptor;
curDesc->SetName(token);
DebugMsg("SDL: DESC name=%s", token);
}
//
// {
//
stream->GetToken(token, kTokenLen); // skip '{'
//
// VERSION
//
if (stream->GetToken(token, kTokenLen))
{
if (!strcmp(token, "VERSION"))
{
// read desc version
hsAssert(curDesc, xtl::format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
if (stream->GetToken(token, kTokenLen))
{
int v=atoi(token);
curDesc->SetVersion(v);
DebugMsg("\tVersion=%d", v);
}
}
else
{
hsAssert(false, xtl::format("Error parsing state desc, missing VERSION, fileName=%s",
fileName).c_str());
ok = false;
}
}
else
{
hsAssert(false, xtl::format("Error parsing state desc, fileName=%s", fileName).c_str());
ok = false;
}
if ( ok )
{
ok = ( plSDLMgr::GetInstance()->FindDescriptor(curDesc->GetName(), curDesc->GetVersion())==nil );
if ( !ok )
{
std::string err = xtl::format( "Found duplicate SDL descriptor for %s version %d.\nFailed to parse file: %s", curDesc->GetName(), curDesc->GetVersion(), fileName );
plNetApp::StaticErrorMsg( err.c_str() );
hsAssert( false, err.c_str() );
}
}
if ( ok )
{
descList->push_back(curDesc);
}
else
{
delete curDesc;
curDesc = nil;
}
return false;
}
//
// Parse a variable descriptor.
// read type, name, count [default]
// return true to skip the next token read
//
bool plSDLParser::IParseVarDesc(const char* fileName, hsStream* stream, char token[], plStateDescriptor*& curDesc,
plVarDescriptor*& curVar) const
{
hsAssert(curDesc, xtl::format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
if ( !curDesc )
return false;
bool skipNext=false;
std::string dbgStr;
static char seps[] = "( ,)[]";
// read type, name, cnt, [default]
//
// TYPE
// create new state var, make current
//
if (*token == '$')
{
// nested sdls
char* sdlName = token+1;
plStateDescriptor* stateDesc = plSDLMgr::GetInstance()->FindDescriptor(sdlName, plSDL::kLatestVersion);
hsAssert(stateDesc, xtl::format("can't find nested state desc reference %s, fileName=%s",
sdlName, fileName).c_str());
curVar = TRACKED_NEW plSDVarDescriptor(stateDesc);
}
else
curVar = TRACKED_NEW plSimpleVarDescriptor;
curDesc->AddVar(curVar);
bool ok=curVar->SetType(token);
hsAssert(ok, xtl::format("Variable 'type' syntax problem with .sdl file, type=%s, fileName=%s", token, fileName).c_str());
dbgStr = xtl::format("\tVAR Type=%s ", token).c_str();
//
// NAME (foo[1])
//
if (stream->GetToken(token, kTokenLen))
{
hsAssert(strstr(token, "[") && strstr(token, "]"), xtl::format("invalid var syntax, missing [x], fileName=%s",
fileName).c_str());
char* ptr = strtok( token, seps ); // skip [
hsAssert(curVar, xtl::format("Missing current var. Syntax problem with .sdl file, fileName=%s", fileName).c_str());
curVar->SetName(token);
//
// COUNT
//
char* cntTok=strtok(nil, seps); // kill ]
int cnt = cntTok ? atoi(cntTok) : 0;
curVar->SetCount(cnt);
if (cnt==0)
curVar->SetVariableLength(true);
dbgStr += xtl::format("Name=%s[%d]", curVar->GetName(), cnt).c_str();
}
//
// optional tokens: DEFAULT, INTERNAL
//
while (stream->GetToken(token, kTokenLen))
{
if (!strcmp(token, "DEFAULT"))
{
hsAssert(curVar, xtl::format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
// read state var type
std::string defaultStr;
plSimpleVarDescriptor* sVar=(plSimpleVarDescriptor*)curVar;
if (sVar)
{
int i;
for(i=0;i<sVar->GetAtomicCount();i++)
{
if (stream->GetToken(token, kTokenLen))
{
defaultStr += token;
if (i!=sVar->GetAtomicCount()-1)
defaultStr += ",";
}
}
}
if (defaultStr.size())
{
curVar->SetDefault(defaultStr.c_str());
dbgStr += std::string(" DEFAULT=") + defaultStr;
}
}
else
if (!strcmp(token, "DISPLAYOPTION"))
{
hsAssert(curVar, xtl::format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
dbgStr += std::string(" ") + token;
hsBool read=stream->GetToken(token, kTokenLen);
if (read)
{
std::string oldOptions=curVar->GetDisplayOptions();
if (oldOptions.size())
oldOptions += std::string(",");
oldOptions += token;
curVar->SetDisplayOptions(oldOptions.c_str());
dbgStr += std::string("=") + token;
if (!stricmp(token, "hidden"))
curVar->SetInternal(true);
}
else
{
hsAssert(false, xtl::format("missing displayOption string, fileName=%s", fileName).c_str());
}
}
else
if (!strcmp(token, "DEFAULTOPTION"))
{
hsAssert(curVar, xtl::format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
dbgStr += std::string(" ") + token;
hsBool read=stream->GetToken(token, kTokenLen);
if (read)
{
dbgStr += std::string("=") + token;
if (!stricmp(token, "vault"))
curVar->SetAlwaysNew(true);
}
else
{
hsAssert(false, xtl::format("missing defaultOption string, fileName=%s", fileName).c_str());
}
}
#if 1 // delete me in May 2003
else
if (!strcmp(token, "INTERNAL"))
{
hsAssert(curVar, xtl::format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
curVar->SetInternal(true);
dbgStr += std::string(" ") + token;
}
else
if (!strcmp(token, "PHASED"))
{
hsAssert(curVar, xtl::format("Syntax problem with .sdl file, fileName=%s", fileName).c_str());
curVar->SetAlwaysNew(true);
dbgStr += std::string(" ") + token;
}
#endif
else
{
skipNext=true;
break;
}
}
DebugMsg((char*)dbgStr.c_str());
return skipNext;
}
//
// create state descriptor from sdl file.
// return false on err.
//
bool plSDLParser::ILoadSDLFile(const char* fileName) const
{
DebugMsg("Parsing SDL file %s", fileName);
wchar_t* temp = hsStringToWString(fileName);
hsStream* stream = plStreamSource::GetInstance()->GetFile(temp);
delete [] temp;
if (!stream)
return false;
stream->Rewind();
plVarDescriptor* curVar=nil;
plStateDescriptor* curDesc=nil;
char token[kTokenLen];
bool parsingStateDesc=false;
bool skip=false;
while (1)
{
if (!skip)
{
if (!stream->GetToken(token, kTokenLen))
break;
}
skip=false;
if (!strcmp(token, "VAR"))
{
parsingStateDesc=false;
curVar=nil; // start fresh
continue;
}
if (!strcmp(token, "STATEDESC"))
{
parsingStateDesc=true;
curDesc=nil; // start fresh
continue;
}
if (!strcmp(token, "}"))
{
if ( curDesc )
curDesc->SetFilename( fileName );
parsingStateDesc=false;
continue;
}
if (parsingStateDesc)
{
skip=IParseStateDesc(fileName, stream, token, curDesc);
if ( !curDesc )
break; // failed to parse state desc
}
else
{
skip=IParseVarDesc(fileName, stream, token, curDesc, curVar);
}
}
// If the very last char is a } without a \n, then it won't be handled above for some reason, so we have to catch it here.
if ( curDesc )
curDesc->SetFilename( fileName );
// do not close or delete the stream, we do not own it
return true;
}
//
// load all .sdl files in sdl directory, and create descriptors for each.
// return false on error
//
bool plSDLParser::IReadDescriptors() const
{
std::string sdlDir = plSDLMgr::GetInstance()->GetSDLDir();
DebugMsg("SDL: Reading latest descriptors from directory %s", sdlDir.c_str());
wchar_t* temp = hsStringToWString(sdlDir.c_str());
std::wstring wSDLDir = temp;
delete [] temp;
// Get the names of all the sdl files
std::vector<std::wstring> files = plStreamSource::GetInstance()->GetListOfNames(wSDLDir, L".sdl");
bool ret=true;
int cnt=0;
for (int i = 0; i < files.size(); i++)
{
char* str = hsWStringToString(files[i].c_str());
if (!ILoadSDLFile(str))
{
plNetApp* netApp = plSDLMgr::GetInstance()->GetNetApp();
if (netApp)
netApp->ErrorMsg("Error loading SDL file %s", str);
else
hsStatusMessageF("Error loading SDL file %s", str);
ret=false;
}
else
cnt++;
delete [] str;
}
DebugMsg("Done reading SDL files");
if (!cnt)
ret=false;
return ret;
}
//
// reads sdl folder, creates descriptor list
//
bool plSDLParser::Parse() const
{
return IReadDescriptors();
}

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==*/
#include "plSDL.h"
#include "pnMessage/plSDLNotificationMsg.h"
#include <algorithm>
// static
UInt32 plStateChangeNotifier::fCurrentPlayerID = 0;
plStateChangeNotifier::plStateChangeNotifier() :
fDelta(0)
{
}
plStateChangeNotifier::plStateChangeNotifier(float i, plKey k)
{
SetValue(i);
IAddKey(k);
}
void plStateChangeNotifier::IAddKey(plKey k)
{
KeyList::iterator it = std::find(fKeys.begin(), fKeys.end(), k);
if (it==fKeys.end())
fKeys.push_back(k);
}
int plStateChangeNotifier::IRemoveKey(plKey k)
{
KeyList::iterator it = std::find(fKeys.begin(), fKeys.end(), k);
if (it!=fKeys.end())
fKeys.erase(it);
return fKeys.size();
}
//
// returns number of keys left after removal
//
int plStateChangeNotifier::RemoveNotificationKey(plKey k)
{
return IRemoveKey(k);
}
//
// returns number of keys left after removal
//
int plStateChangeNotifier::RemoveNotificationKeys(KeyList keys)
{
KeyList::iterator it=keys.begin();
for( ; it != keys.end(); it++)
IRemoveKey(*it);
return fKeys.size();
}
void plStateChangeNotifier::AddNotificationKeys(KeyList keys)
{
KeyList::iterator it=keys.begin();
for( ; it != keys.end(); it++)
IAddKey(*it);
}
bool plStateChangeNotifier::GetValue(float* i) const
{
*i=fDelta;
return true;
}
bool plStateChangeNotifier::SetValue(float i)
{
fDelta=i;
return true;
}
bool plStateChangeNotifier::operator==(const plStateChangeNotifier &other) const
{
return (other.fDelta==fDelta && other.fKeys==fKeys);
}
//
// send notification msg to all registered recipients
//
void plStateChangeNotifier::SendNotificationMsg(const plSimpleStateVariable* srcVar, const plSimpleStateVariable* dstVar,
const char* sdlName)
{
plSDLNotificationMsg* m = TRACKED_NEW plSDLNotificationMsg;
// add receivers
KeyList::iterator kit=fKeys.begin();
for(; kit != fKeys.end(); kit++)
m->AddReceiver(*kit);
m->fDelta=fDelta;
m->fVar=dstVar;
m->fSDLName = sdlName;
m->fPlayerID = GetCurrentPlayerID();
m->fHintString = srcVar->GetNotificationInfo().GetHintString();
m->Send();
}
/*==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 "plSDL.h"
#include "pnMessage/plSDLNotificationMsg.h"
#include <algorithm>
// static
UInt32 plStateChangeNotifier::fCurrentPlayerID = 0;
plStateChangeNotifier::plStateChangeNotifier() :
fDelta(0)
{
}
plStateChangeNotifier::plStateChangeNotifier(float i, plKey k)
{
SetValue(i);
IAddKey(k);
}
void plStateChangeNotifier::IAddKey(plKey k)
{
KeyList::iterator it = std::find(fKeys.begin(), fKeys.end(), k);
if (it==fKeys.end())
fKeys.push_back(k);
}
int plStateChangeNotifier::IRemoveKey(plKey k)
{
KeyList::iterator it = std::find(fKeys.begin(), fKeys.end(), k);
if (it!=fKeys.end())
fKeys.erase(it);
return fKeys.size();
}
//
// returns number of keys left after removal
//
int plStateChangeNotifier::RemoveNotificationKey(plKey k)
{
return IRemoveKey(k);
}
//
// returns number of keys left after removal
//
int plStateChangeNotifier::RemoveNotificationKeys(KeyList keys)
{
KeyList::iterator it=keys.begin();
for( ; it != keys.end(); it++)
IRemoveKey(*it);
return fKeys.size();
}
void plStateChangeNotifier::AddNotificationKeys(KeyList keys)
{
KeyList::iterator it=keys.begin();
for( ; it != keys.end(); it++)
IAddKey(*it);
}
bool plStateChangeNotifier::GetValue(float* i) const
{
*i=fDelta;
return true;
}
bool plStateChangeNotifier::SetValue(float i)
{
fDelta=i;
return true;
}
bool plStateChangeNotifier::operator==(const plStateChangeNotifier &other) const
{
return (other.fDelta==fDelta && other.fKeys==fKeys);
}
//
// send notification msg to all registered recipients
//
void plStateChangeNotifier::SendNotificationMsg(const plSimpleStateVariable* srcVar, const plSimpleStateVariable* dstVar,
const char* sdlName)
{
plSDLNotificationMsg* m = TRACKED_NEW plSDLNotificationMsg;
// add receivers
KeyList::iterator kit=fKeys.begin();
for(; kit != fKeys.end(); kit++)
m->AddReceiver(*kit);
m->fDelta=fDelta;
m->fVar=dstVar;
m->fSDLName = sdlName;
m->fPlayerID = GetCurrentPlayerID();
m->fHintString = srcVar->GetNotificationInfo().GetHintString();
m->Send();
}

File diff suppressed because it is too large Load Diff

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 "hsStream.h"
#include "plSDL.h"
#include "pnNetCommon/plNetApp.h"
const UInt8 plStateDescriptor::kVersion=1; // for Read/Write format
/////////////////////////////////////////////////////////////////////////////////
// STATE DESC
/////////////////////////////////////////////////////////////////////////////////
plStateDescriptor::~plStateDescriptor()
{
IDeInit();
}
void plStateDescriptor::IDeInit()
{
delete [] fName;
int i;
for(i=0;i<fVarsList.size();i++)
delete fVarsList[i];
fVarsList.clear();
}
plVarDescriptor* plStateDescriptor::FindVar(const char* name, int* idx) const
{
VarsList::const_iterator it;
for(it=fVarsList.begin(); it != fVarsList.end(); it++)
{
if (!stricmp((*it)->GetName(), name))
{
if (idx)
*idx = it-fVarsList.begin();
return *it;
}
}
return nil;
}
//
// Usage: The GameServer reads and write state descriptors along with each saved game
//
bool plStateDescriptor::Read(hsStream* s)
{
UInt8 rwVersion;
s->ReadSwap(&rwVersion);
if (rwVersion != kVersion)
{
plNetApp::StaticWarningMsg("StateDescriptor Read/Write version mismatch, mine %d, read %d", kVersion, rwVersion);
return false;
}
IDeInit();
delete [] fName;
fName = s->ReadSafeString();
UInt16 version=s->ReadSwap16();
fVersion=version;
UInt16 numVars=s->ReadSwap16();
fVarsList.reserve(numVars);
int i;
for(i=0;i<numVars; i++)
{
UInt8 SDVar=s->ReadByte();
plVarDescriptor* var = nil;
if (SDVar)
var = TRACKED_NEW plSDVarDescriptor;
else
var = TRACKED_NEW plSimpleVarDescriptor;
if (var->Read(s))
fVarsList.push_back(var);
else
return false;
}
return true;
}
//
// Usage: The GameServer reads and write state descriptors alon with each saved game
//
void plStateDescriptor::Write(hsStream* s) const
{
s->WriteSwap(kVersion);
s->WriteSafeString(fName);
UInt16 version=fVersion;
s->WriteSwap(version);
UInt16 numVars=fVarsList.size();
s->WriteSwap(numVars);
VarsList::const_iterator it;
for(it=fVarsList.begin(); it!=fVarsList.end(); it++)
{
UInt8 SDVar = ((*it)->GetAsSDVarDescriptor() != nil);
s->WriteByte(SDVar);
(*it)->Write(s);
}
}
/*==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 "hsStream.h"
#include "plSDL.h"
#include "pnNetCommon/plNetApp.h"
const UInt8 plStateDescriptor::kVersion=1; // for Read/Write format
/////////////////////////////////////////////////////////////////////////////////
// STATE DESC
/////////////////////////////////////////////////////////////////////////////////
plStateDescriptor::~plStateDescriptor()
{
IDeInit();
}
void plStateDescriptor::IDeInit()
{
delete [] fName;
int i;
for(i=0;i<fVarsList.size();i++)
delete fVarsList[i];
fVarsList.clear();
}
plVarDescriptor* plStateDescriptor::FindVar(const char* name, int* idx) const
{
VarsList::const_iterator it;
for(it=fVarsList.begin(); it != fVarsList.end(); it++)
{
if (!stricmp((*it)->GetName(), name))
{
if (idx)
*idx = it-fVarsList.begin();
return *it;
}
}
return nil;
}
//
// Usage: The GameServer reads and write state descriptors along with each saved game
//
bool plStateDescriptor::Read(hsStream* s)
{
UInt8 rwVersion;
s->ReadSwap(&rwVersion);
if (rwVersion != kVersion)
{
plNetApp::StaticWarningMsg("StateDescriptor Read/Write version mismatch, mine %d, read %d", kVersion, rwVersion);
return false;
}
IDeInit();
delete [] fName;
fName = s->ReadSafeString();
UInt16 version=s->ReadSwap16();
fVersion=version;
UInt16 numVars=s->ReadSwap16();
fVarsList.reserve(numVars);
int i;
for(i=0;i<numVars; i++)
{
UInt8 SDVar=s->ReadByte();
plVarDescriptor* var = nil;
if (SDVar)
var = TRACKED_NEW plSDVarDescriptor;
else
var = TRACKED_NEW plSimpleVarDescriptor;
if (var->Read(s))
fVarsList.push_back(var);
else
return false;
}
return true;
}
//
// Usage: The GameServer reads and write state descriptors alon with each saved game
//
void plStateDescriptor::Write(hsStream* s) const
{
s->WriteSwap(kVersion);
s->WriteSafeString(fName);
UInt16 version=fVersion;
s->WriteSwap(version);
UInt16 numVars=fVarsList.size();
s->WriteSwap(numVars);
VarsList::const_iterator it;
for(it=fVarsList.begin(); it!=fVarsList.end(); it++)
{
UInt8 SDVar = ((*it)->GetAsSDVarDescriptor() != nil);
s->WriteByte(SDVar);
(*it)->Write(s);
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,404 +1,404 @@
/*==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 "hsStream.h"
#include "plSDL.h"
#include "hsStlUtils.h"
#include "pnKeyedObject/plUoid.h"
#include "pnNetCommon/plNetApp.h"
#include "pnMessage/plMessage.h"
#include "plUnifiedTime/plUnifiedTime.h"
const UInt8 plVarDescriptor::kVersion=3; // for Read/Write format
/////////////////////////////////////////////////////////////////////////////////
// State Var
/////////////////////////////////////////////////////////////////////////////////
plVarDescriptor::plVarDescriptor() :
fName(nil),
fCount(1),
fType(kNone),
fTypeString(nil),
fDefault(nil),
fFlags(0)
{
}
plVarDescriptor::~plVarDescriptor()
{
delete [] fName;
delete [] fDefault;
delete [] fTypeString;
}
//
// Set type from a string. Return false on err.
//
bool plVarDescriptor::SetType(const char* type)
{
if (!type)
return false;
if (!stricmp(type, "vector3"))
fType=kVector3;
else
if (!stricmp(type, "point3"))
fType=kPoint3;
else
if (!stricmp(type, "rgb"))
fType=kRGB;
else
if (!stricmp(type, "rgba"))
fType=kRGBA;
else
if (!stricmp(type, "rgb8"))
fType=kRGB8;
else
if (!stricmp(type, "rgba8"))
fType=kRGBA8;
else
if (!strnicmp(type, "quat",4))
fType=kQuaternion;
else
if (!stricmp(type, "rgba"))
fType=kRGBA;
else
if (!stricmp(type, "int"))
fType=kInt;
else
if (!stricmp(type, "byte"))
fType=kByte;
else
if (!stricmp(type, "short"))
fType=kShort;
else
if (!stricmp(type, "float"))
fType=kFloat;
else
if (!stricmp(type, "double"))
fType=kDouble;
else
if (!stricmp(type, "time"))
fType=kTime;
else
if (!stricmp(type, "ageTimeOfDay"))
fType=kAgeTimeOfDay;
else
if (!stricmp(type, "bool"))
fType=kBool;
else
if (!stricmp(type, "string32"))
fType=kString32;
else
if (!stricmp(type, "plKey"))
fType=kKey;
else
if (!stricmp(type, "message") || !stricmp(type, "creatable") )
fType=kCreatable;
else
if (*type=='$')
fType=kStateDescriptor;
else
return false; // err
delete [] fTypeString;
fTypeString = hsStrcpy(type);
return true; // ok
}
void plVarDescriptor::CopyFrom(const plVarDescriptor* other)
{
SetName(other->GetName());
SetDefault(other->GetDefault());
SetCount(other->GetCount());
SetDisplayOptions(other->GetDisplayOptions());
delete [] fTypeString;
fTypeString=hsStrcpy(other->GetTypeString());
fType = other->GetType();
fFlags = other->fFlags;
}
//
// Var descriptors are read and written by state descriptors
//
bool plVarDescriptor::Read(hsStream* s)
{
UInt8 version;
s->ReadSwap(&version);
if (version != kVersion)
{
if (plSDLMgr::GetInstance()->GetNetApp())
plSDLMgr::GetInstance()->GetNetApp()->WarningMsg("SDL VarDescriptor version mismatch, read %d, should be %d - ignoring",
version, kVersion);
return false;
}
delete [] fName;
fName=s->ReadSafeString();
plMsgStdStringHelper::Peek(fDisplayOptions, s);
fCount=s->ReadSwap32();
fType=(Type)s->ReadByte();
delete [] fDefault;
fDefault = s->ReadSafeString();
fFlags = s->ReadSwap32();
return true;
}
//
// Var descriptors are read and written by state descriptors
//
void plVarDescriptor::Write(hsStream* s) const
{
s->WriteSwap(kVersion);
s->WriteSafeString(fName);
plMsgStdStringHelper::Poke(fDisplayOptions, s);
s->WriteSwap32(fCount);
s->WriteByte((UInt8)fType);
s->WriteSafeString(fDefault);
s->WriteSwap32(fFlags);
}
/////////////////////////////////////////////////////////////////////////////////
// plSimpleVarDescriptor
/////////////////////////////////////////////////////////////////////////////////
plSimpleVarDescriptor::plSimpleVarDescriptor() :
fAtomicType(kNone),
fAtomicCount(1)
{
}
// size in bytes
int plSimpleVarDescriptor::GetAtomicSize() const
{
switch(fAtomicType)
{
case kInt:
return sizeof(int)*GetAtomicCount();
case kByte:
return sizeof(byte)*GetAtomicCount();
case kShort:
return sizeof(short)*GetAtomicCount();
case kAgeTimeOfDay:
case kFloat:
return sizeof(float)*GetAtomicCount();
case kTime:
return sizeof(plUnifiedTime)*GetAtomicCount();
case kDouble:
return sizeof(double)*GetAtomicCount();
case kBool:
return sizeof(bool)*GetAtomicCount();
case kString32:
return sizeof(String32)*GetAtomicCount();
case kKey:
return sizeof(plUoid)*GetAtomicCount();
default:
return -1; // err
}
}
// size of var in bytes
int plSimpleVarDescriptor::GetSize() const
{
int size=GetAtomicSize();
return size>=0 ? size*GetCount() : size;
}
//
// Set type from a string. Return false on err.
// Sets atomicCount and atomicType
//
bool plSimpleVarDescriptor::SetType(const char* type)
{
if (!type)
return false;
if (!plVarDescriptor::SetType(type))
return false;
if (!stricmp(type, "vector3"))
{
fAtomicCount = 3;
fAtomicType=kFloat;
}
else
if (!stricmp(type, "point3"))
{
fAtomicCount = 3;
fAtomicType=kFloat;
}
else
if (!stricmp(type, "rgb"))
{
fAtomicCount = 3;
fAtomicType=kFloat;
}
else
if (!stricmp(type, "rgba"))
{
fAtomicCount = 4;
fAtomicType=kFloat;
}
else
if (!stricmp(type, "rgb8"))
{
fAtomicCount = 3;
fAtomicType=kByte;
}
else
if (!stricmp(type, "rgba8"))
{
fAtomicCount = 4;
fAtomicType=kByte;
}
else
if (!strnicmp(type, "quat",4))
{
fAtomicCount = 4;
fAtomicType=kFloat;
}
else
if (!stricmp(type, "int"))
fAtomicType=kInt;
else
if (!stricmp(type, "byte"))
fAtomicType=kByte;
else
if (!stricmp(type, "short"))
fAtomicType=kShort;
else
if (!stricmp(type, "float"))
fAtomicType=kFloat;
else
if (!stricmp(type, "double"))
fAtomicType=kDouble;
else
if (!stricmp(type, "time"))
fAtomicType=kTime;
else
if (!stricmp(type, "ageTimeOfDay"))
fAtomicType=kAgeTimeOfDay;
else
if (!stricmp(type, "bool"))
fAtomicType=kBool;
else
if (!stricmp(type, "string32"))
fAtomicType=kString32;
else
if (!stricmp(type, "plKey"))
fAtomicType=kKey;
else
if (!stricmp(type, "message") || !stricmp(type, "creatable"))
fAtomicType=kCreatable;
else
return false; // err
return true; // ok
}
void plSimpleVarDescriptor::CopyFrom(const plSimpleVarDescriptor* other)
{
plVarDescriptor::CopyFrom(other);
fAtomicCount=other->GetAtomicCount();
fAtomicType=other->GetAtomicType();
}
//
// Var descriptors are read and written by state descriptors
//
bool plSimpleVarDescriptor::Read(hsStream* s)
{
if (!plVarDescriptor::Read(s))
return false;
fAtomicCount=s->ReadSwap16();
fAtomicType=(Type)s->ReadByte();
return true;
}
//
// Var descriptors are read and written by state descriptors
//
void plSimpleVarDescriptor::Write(hsStream* s) const
{
plVarDescriptor::Write(s);
s->WriteSwap16((Int16)fAtomicCount);
s->WriteByte((UInt8)fAtomicType);
}
/////////////////////////////////////////////////////////////////////////////////
// plSDVarDescriptor
// A var which references another state descriptor
/////////////////////////////////////////////////////////////////////////////////
void plSDVarDescriptor::CopyFrom(const plSDVarDescriptor* other)
{
plVarDescriptor::CopyFrom(other);
SetStateDesc(other->GetStateDescriptor());
}
//
// Var descriptors are read and written by state descriptors
//
bool plSDVarDescriptor::Read(hsStream* s)
{
if (!plVarDescriptor::Read(s))
return false;
char* sdName=s->ReadSafeString();
UInt16 version = s->ReadSwap16();
plStateDescriptor* sd=plSDLMgr::GetInstance()->FindDescriptor(sdName, version);
hsAssert( sd, xtl::format("Failed to find sdl descriptor: %s,%d. Missing legacy descriptor?", sdName, version ).c_str() );
SetStateDesc(sd);
delete [] sdName;
return true;
}
//
// Var descriptors are read and written by state descriptors
//
void plSDVarDescriptor::Write(hsStream* s) const
{
plVarDescriptor::Write(s);
s->WriteSafeString(GetStateDescriptor()->GetName());
UInt16 version=GetStateDescriptor()->GetVersion();
s->WriteSwap(version);
}
/*==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 "hsStream.h"
#include "plSDL.h"
#include "hsStlUtils.h"
#include "pnKeyedObject/plUoid.h"
#include "pnNetCommon/plNetApp.h"
#include "pnMessage/plMessage.h"
#include "plUnifiedTime/plUnifiedTime.h"
const UInt8 plVarDescriptor::kVersion=3; // for Read/Write format
/////////////////////////////////////////////////////////////////////////////////
// State Var
/////////////////////////////////////////////////////////////////////////////////
plVarDescriptor::plVarDescriptor() :
fName(nil),
fCount(1),
fType(kNone),
fTypeString(nil),
fDefault(nil),
fFlags(0)
{
}
plVarDescriptor::~plVarDescriptor()
{
delete [] fName;
delete [] fDefault;
delete [] fTypeString;
}
//
// Set type from a string. Return false on err.
//
bool plVarDescriptor::SetType(const char* type)
{
if (!type)
return false;
if (!stricmp(type, "vector3"))
fType=kVector3;
else
if (!stricmp(type, "point3"))
fType=kPoint3;
else
if (!stricmp(type, "rgb"))
fType=kRGB;
else
if (!stricmp(type, "rgba"))
fType=kRGBA;
else
if (!stricmp(type, "rgb8"))
fType=kRGB8;
else
if (!stricmp(type, "rgba8"))
fType=kRGBA8;
else
if (!strnicmp(type, "quat",4))
fType=kQuaternion;
else
if (!stricmp(type, "rgba"))
fType=kRGBA;
else
if (!stricmp(type, "int"))
fType=kInt;
else
if (!stricmp(type, "byte"))
fType=kByte;
else
if (!stricmp(type, "short"))
fType=kShort;
else
if (!stricmp(type, "float"))
fType=kFloat;
else
if (!stricmp(type, "double"))
fType=kDouble;
else
if (!stricmp(type, "time"))
fType=kTime;
else
if (!stricmp(type, "ageTimeOfDay"))
fType=kAgeTimeOfDay;
else
if (!stricmp(type, "bool"))
fType=kBool;
else
if (!stricmp(type, "string32"))
fType=kString32;
else
if (!stricmp(type, "plKey"))
fType=kKey;
else
if (!stricmp(type, "message") || !stricmp(type, "creatable") )
fType=kCreatable;
else
if (*type=='$')
fType=kStateDescriptor;
else
return false; // err
delete [] fTypeString;
fTypeString = hsStrcpy(type);
return true; // ok
}
void plVarDescriptor::CopyFrom(const plVarDescriptor* other)
{
SetName(other->GetName());
SetDefault(other->GetDefault());
SetCount(other->GetCount());
SetDisplayOptions(other->GetDisplayOptions());
delete [] fTypeString;
fTypeString=hsStrcpy(other->GetTypeString());
fType = other->GetType();
fFlags = other->fFlags;
}
//
// Var descriptors are read and written by state descriptors
//
bool plVarDescriptor::Read(hsStream* s)
{
UInt8 version;
s->ReadSwap(&version);
if (version != kVersion)
{
if (plSDLMgr::GetInstance()->GetNetApp())
plSDLMgr::GetInstance()->GetNetApp()->WarningMsg("SDL VarDescriptor version mismatch, read %d, should be %d - ignoring",
version, kVersion);
return false;
}
delete [] fName;
fName=s->ReadSafeString();
plMsgStdStringHelper::Peek(fDisplayOptions, s);
fCount=s->ReadSwap32();
fType=(Type)s->ReadByte();
delete [] fDefault;
fDefault = s->ReadSafeString();
fFlags = s->ReadSwap32();
return true;
}
//
// Var descriptors are read and written by state descriptors
//
void plVarDescriptor::Write(hsStream* s) const
{
s->WriteSwap(kVersion);
s->WriteSafeString(fName);
plMsgStdStringHelper::Poke(fDisplayOptions, s);
s->WriteSwap32(fCount);
s->WriteByte((UInt8)fType);
s->WriteSafeString(fDefault);
s->WriteSwap32(fFlags);
}
/////////////////////////////////////////////////////////////////////////////////
// plSimpleVarDescriptor
/////////////////////////////////////////////////////////////////////////////////
plSimpleVarDescriptor::plSimpleVarDescriptor() :
fAtomicType(kNone),
fAtomicCount(1)
{
}
// size in bytes
int plSimpleVarDescriptor::GetAtomicSize() const
{
switch(fAtomicType)
{
case kInt:
return sizeof(int)*GetAtomicCount();
case kByte:
return sizeof(byte)*GetAtomicCount();
case kShort:
return sizeof(short)*GetAtomicCount();
case kAgeTimeOfDay:
case kFloat:
return sizeof(float)*GetAtomicCount();
case kTime:
return sizeof(plUnifiedTime)*GetAtomicCount();
case kDouble:
return sizeof(double)*GetAtomicCount();
case kBool:
return sizeof(bool)*GetAtomicCount();
case kString32:
return sizeof(String32)*GetAtomicCount();
case kKey:
return sizeof(plUoid)*GetAtomicCount();
default:
return -1; // err
}
}
// size of var in bytes
int plSimpleVarDescriptor::GetSize() const
{
int size=GetAtomicSize();
return size>=0 ? size*GetCount() : size;
}
//
// Set type from a string. Return false on err.
// Sets atomicCount and atomicType
//
bool plSimpleVarDescriptor::SetType(const char* type)
{
if (!type)
return false;
if (!plVarDescriptor::SetType(type))
return false;
if (!stricmp(type, "vector3"))
{
fAtomicCount = 3;
fAtomicType=kFloat;
}
else
if (!stricmp(type, "point3"))
{
fAtomicCount = 3;
fAtomicType=kFloat;
}
else
if (!stricmp(type, "rgb"))
{
fAtomicCount = 3;
fAtomicType=kFloat;
}
else
if (!stricmp(type, "rgba"))
{
fAtomicCount = 4;
fAtomicType=kFloat;
}
else
if (!stricmp(type, "rgb8"))
{
fAtomicCount = 3;
fAtomicType=kByte;
}
else
if (!stricmp(type, "rgba8"))
{
fAtomicCount = 4;
fAtomicType=kByte;
}
else
if (!strnicmp(type, "quat",4))
{
fAtomicCount = 4;
fAtomicType=kFloat;
}
else
if (!stricmp(type, "int"))
fAtomicType=kInt;
else
if (!stricmp(type, "byte"))
fAtomicType=kByte;
else
if (!stricmp(type, "short"))
fAtomicType=kShort;
else
if (!stricmp(type, "float"))
fAtomicType=kFloat;
else
if (!stricmp(type, "double"))
fAtomicType=kDouble;
else
if (!stricmp(type, "time"))
fAtomicType=kTime;
else
if (!stricmp(type, "ageTimeOfDay"))
fAtomicType=kAgeTimeOfDay;
else
if (!stricmp(type, "bool"))
fAtomicType=kBool;
else
if (!stricmp(type, "string32"))
fAtomicType=kString32;
else
if (!stricmp(type, "plKey"))
fAtomicType=kKey;
else
if (!stricmp(type, "message") || !stricmp(type, "creatable"))
fAtomicType=kCreatable;
else
return false; // err
return true; // ok
}
void plSimpleVarDescriptor::CopyFrom(const plSimpleVarDescriptor* other)
{
plVarDescriptor::CopyFrom(other);
fAtomicCount=other->GetAtomicCount();
fAtomicType=other->GetAtomicType();
}
//
// Var descriptors are read and written by state descriptors
//
bool plSimpleVarDescriptor::Read(hsStream* s)
{
if (!plVarDescriptor::Read(s))
return false;
fAtomicCount=s->ReadSwap16();
fAtomicType=(Type)s->ReadByte();
return true;
}
//
// Var descriptors are read and written by state descriptors
//
void plSimpleVarDescriptor::Write(hsStream* s) const
{
plVarDescriptor::Write(s);
s->WriteSwap16((Int16)fAtomicCount);
s->WriteByte((UInt8)fAtomicType);
}
/////////////////////////////////////////////////////////////////////////////////
// plSDVarDescriptor
// A var which references another state descriptor
/////////////////////////////////////////////////////////////////////////////////
void plSDVarDescriptor::CopyFrom(const plSDVarDescriptor* other)
{
plVarDescriptor::CopyFrom(other);
SetStateDesc(other->GetStateDescriptor());
}
//
// Var descriptors are read and written by state descriptors
//
bool plSDVarDescriptor::Read(hsStream* s)
{
if (!plVarDescriptor::Read(s))
return false;
char* sdName=s->ReadSafeString();
UInt16 version = s->ReadSwap16();
plStateDescriptor* sd=plSDLMgr::GetInstance()->FindDescriptor(sdName, version);
hsAssert( sd, xtl::format("Failed to find sdl descriptor: %s,%d. Missing legacy descriptor?", sdName, version ).c_str() );
SetStateDesc(sd);
delete [] sdName;
return true;
}
//
// Var descriptors are read and written by state descriptors
//
void plSDVarDescriptor::Write(hsStream* s) const
{
plVarDescriptor::Write(s);
s->WriteSafeString(GetStateDescriptor()->GetName());
UInt16 version=GetStateDescriptor()->GetVersion();
s->WriteSwap(version);
}