private bool ReceiveMessage_WorldCreateBeginToClient(NetworkNode.ConnectedNode sender, MessageType messageType, ReceiveDataReader reader, ref string additionalErrorMessage) { string worldTypeName = reader.ReadString(); string mapVirtualFileName = reader.ReadString(); int worldCheckIdentifier = reader.ReadInt32(); if (!reader.Complete()) { return(false); } //send world identifier back to server { MessageType messageType2 = GetMessageType("worldIdentifierToServer"); SendDataWriter writer = BeginMessage(messageType2); writer.Write(worldCheckIdentifier); EndMessage(); } bool remoteWorldAlreadyExists = EntitySystemWorld.Instance.RemoteEntityWorlds.Contains( serverRemoteEntityWorld); if (!remoteWorldAlreadyExists) { serverRemoteEntityWorld = new RemoteEntityWorld("Server remote entity world"); networkingInterface.ConnectRemoteEntityWorld(serverRemoteEntityWorld); } WorldType worldType = EntityTypes.Instance.GetByName(worldTypeName) as WorldType; if (worldType == null) { Log.Fatal("EntitySystemClientNetworkService: " + "ReceiveMessage_WorldCreateBeginToClient: World type \"{0}\" is not exists.", worldTypeName); } if (WorldCreateBegin != null) { WorldCreateBegin(this, worldType, mapVirtualFileName); } return(true); }
private bool ReceiveMessage_CheckWorldIdentifierToServer(NetworkNode.ConnectedNode sender, MessageType messageType, ReceiveDataReader reader, ref string additionalErrorMessage) { int identifier = reader.ReadInt32(); if (!reader.Complete()) { return(false); } ClientRemoteEntityWorld fromRemoteEntityWorld = GetRemoteEntityWorld(sender); if (fromRemoteEntityWorld == null) { //no such world already. as example World has been deleted. return(true); } fromRemoteEntityWorld.ReceivedWorldIdentifier = identifier; return(true); }
private bool ReceiveMessage_WorldCreateBeginToClient(NetworkNode.ConnectedNode sender, MessageType messageType, ReceiveDataReader reader, ref string additionalErrorMessage) { string worldTypeName = reader.ReadString(); string mapVirtualFileName = reader.ReadString(); int worldCheckIdentifier = reader.ReadInt32(); if (!reader.Complete()) return false; //send world identifier back to server { MessageType messageType2 = GetMessageType("worldIdentifierToServer"); SendDataWriter writer = BeginMessage(messageType2); writer.Write(worldCheckIdentifier); EndMessage(); } bool remoteWorldAlreadyExists = EntitySystemWorld.Instance.RemoteEntityWorlds.Contains( serverRemoteEntityWorld); if (!remoteWorldAlreadyExists) { serverRemoteEntityWorld = new RemoteEntityWorld("Server remote entity world"); networkingInterface.ConnectRemoteEntityWorld(serverRemoteEntityWorld); } WorldType worldType = EntityTypes.Instance.GetByName(worldTypeName) as WorldType; if (worldType == null) { Log.Fatal("EntitySystemClientNetworkService: " + "ReceiveMessage_WorldCreateBeginToClient: World type \"{0}\" is not exists.", worldTypeName); } if (WorldCreateBegin != null) WorldCreateBegin(this, worldType, mapVirtualFileName); return true; }
private bool ReceiveMessage_CheckWorldIdentifierToServer(NetworkNode.ConnectedNode sender, MessageType messageType, ReceiveDataReader reader, ref string additionalErrorMessage) { int identifier = reader.ReadInt32(); if (!reader.Complete()) return false; ClientRemoteEntityWorld fromRemoteEntityWorld = GetRemoteEntityWorld(sender); if (fromRemoteEntityWorld == null) { //no such world already. as example World has been deleted. return true; } fromRemoteEntityWorld.ReceivedWorldIdentifier = identifier; return true; }
byte[] GetCookedTriangleMeshFromCache( Vec3[] vertices, int[] indices, short[] materialIndices ) { try { string cacheDirectory = "user:Caches\\PhysXCookedTriangleMeshes"; string realCacheDirectory = VirtualFileSystem.GetRealPathByVirtual( cacheDirectory ); if( Directory.Exists( realCacheDirectory ) ) { byte[] sourceBuffer; string baseName; GetCookTriangleMeshSourceBuffer( vertices, indices, materialIndices, out sourceBuffer, out baseName ); string realFileName = Path.Combine( realCacheDirectory, baseName + ".cache" ); if( File.Exists( realFileName ) ) { int major, minor, bugfix; PhysXNativeWorld.GetSDKVersion( out major, out minor, out bugfix ); int additional = 0; int version = ( ( ( ( ( major << 8 ) + minor ) << 8 ) + bugfix ) << 8 ) + additional; //File format: //1. PhysX version (4 bytes) //2. source buffer length (4 bytes) //3. source buffer //4. cooked data length (4 bytes) //5. cooked data //no archive byte[] fileData = File.ReadAllBytes( realFileName ); //archive //byte[] fileData; ////Mono runtime specific //if( RuntimeFramework.Runtime == RuntimeFramework.RuntimeType.Mono ) // ZipConstants.DefaultCodePage = 0; //using( ZipFile zipFile = new ZipFile( realFileName ) ) //{ // ZipEntry entry = zipFile.GetEntry( "data" ); // Stream zipStream = zipFile.GetInputStream( entry ); // fileData = new byte[ entry.Size ]; // if( zipStream.Read( fileData, 0, (int)entry.Size ) != fileData.Length ) // return null; //} ReceiveDataReader reader = new ReceiveDataReader(); reader.Init( fileData, 0, fileData.Length * 8 ); //check for old version int fileVersion = reader.ReadInt32(); if( version != fileVersion ) return null; int fileBufferSize = reader.ReadInt32(); if( sourceBuffer.Length != fileBufferSize ) return null; byte[] fileSourceBuffer = new byte[ fileBufferSize ]; reader.ReadBuffer( fileSourceBuffer ); unsafe { fixed( byte* pSource = sourceBuffer, pFileBuffer = fileSourceBuffer ) { if( NativeUtils.CompareMemory( (IntPtr)pSource, (IntPtr)pFileBuffer, sourceBuffer.Length ) != 0 ) { return null; } } } int cookedSize = reader.ReadInt32(); byte[] cookedData = new byte[ cookedSize ]; reader.ReadBuffer( cookedData ); return cookedData; } } } catch { } return null; }
void Server_ReceivePlayerTeam(RemoteEntityWorld sender, ReceiveDataReader reader) { uint uni = reader.ReadUInt32(); PlayerTeam value = (PlayerTeam)reader.ReadInt32(); if (!reader.Complete()) return; this.playerTeam = value; UserManagementServerNetworkService.UserInfo uinfo = GameNetworkServer.Instance.UserManagementService.GetUser(uni); PlayerManager.ServerOrSingle_Player player = PlayerManager.Instance.ServerOrSingle_GetPlayer(uinfo.Name); player.Team = playerTeam; // foreach( PlayerManager.ServerOrSingle_Player player in // PlayerManager.Instance.ServerOrSingle_Players ) { // if (player.Identifier == uni ) // { // player.Team = value; // } // } }