public void UpdateCharacter(UpdateCharacterEvent evt) { Dictionary <ShipModelSlotType, string> model = new Dictionary <ShipModelSlotType, string>(); foreach (DictionaryEntry entry in evt.Model) { model.Add((ShipModelSlotType)(byte)int.Parse(entry.Key.ToString()), entry.Value.ToString()); } mCache.UpdatePlayerCharacterObject(evt.GameRefId, evt.CharacterId, model, evt.WorldId, evt.Exp); }
protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters) { try { if (log.IsDebugEnabled) { log.DebugFormat("OnOperationRequest: pid={0}, op={1}", this.ConnectionId, operationRequest.OperationCode); } OperationResponse response = null; switch ((ServerToServerOperationCode)operationRequest.OperationCode) { default: response = new OperationResponse(operationRequest.OperationCode) { ReturnCode = -1, DebugMessage = "Unknown operation code" }; break; case ServerToServerOperationCode.RegisterGameServer: { response = this.ServerId.HasValue ? new OperationResponse(operationRequest.OperationCode) { ReturnCode = -1, DebugMessage = "Already registered" } : this.HandleRegisterGameServerRequest(operationRequest); break; } case ServerToServerOperationCode.UpdateShipModel: { UpdateShipModel operation = new UpdateShipModel(this.Protocol, operationRequest); if (!operation.IsValid) { response = new OperationResponse(operationRequest.OperationCode) { ReturnCode = (short)ReturnCode.InvalidOperationParameter, DebugMessage = "InvalidOperationParameter" }; } else { UpdateShipModelEvent evtData = new UpdateShipModelEvent { CharacterId = operation.CharacterId, GameRefId = operation.GameRefId, SlotType = operation.SlotType, TemplateId = operation.TemplateId }; EventData evt = new EventData((byte)S2SEventCode.UpdateShipModel, evtData); application.GameServers.SendEvent(evt, new SendParameters(), ServerType.SelectCharacter); } break; } case ServerToServerOperationCode.UpdateCharacter: { UpdateCharacter operation = new UpdateCharacter(this.Protocol, operationRequest); UpdateCharacterEvent evtData = new UpdateCharacterEvent { CharacterId = operation.CharacterId, Deleted = operation.Deleted, GameRefId = operation.GameRefId, Model = operation.Model, Race = operation.Race, Workshop = operation.Workshop, Exp = operation.Exp, WorldId = operation.WorldId }; EventData evt = new EventData((byte)S2SEventCode.UpdateCharacter, evtData); application.GameServers.SendEvent(evt, new SendParameters(), ServerType.SelectCharacter); break; } } if (response != null) { this.SendOperationResponse(response, sendParameters); } } catch (Exception ex) { log.Error(ex); } }
private void HandleUpdateCharacterEvent(IEventData eventData) { var updateCharacter = new UpdateCharacterEvent(this.Protocol, eventData); application.Players.UpdateCharacter(updateCharacter); }