public object Get(StructureRequest Req) { SWGEmuAPI.Model.Structure.StructureItemDetails details = StructureModel.GetStructureDetails(Req.object_id, Req.owner_object_id); var ro = Request.Items.GetValue <ResourceOwner>("auth:user"); if (details != null && ro.id != "0" && ro.id.ToUInt() != details.owner_account_id) { throw new ArgumentException("Structure does not belong to the authorized user"); } return(details); }
public object Any(StructureRequest request) { var compiler = new RegexCompiler(); StructureResponse response; try { var regex = compiler.Compile(request.Pattern); var regexDto = DtoMapper.Map<RegexNodeDto>(regex); response = new StructureResponse { Regex = regexDto }; } catch (Exception ex) { response = new StructureResponse { ResponseStatus = new ResponseStatus(ex.GetType().Name, ex.Message) { StackTrace = ex.StackTrace } }; } return new HttpResult(response, ContentType.Json); }
private void HandleStructureRequest(StructureRequest request) { Debug.LogError("handling a structure request " + request.ToString()); if (expandableRoads.Count <= 0) { return; } LocationPair bounds = null; Road success = null; List <RoadNode> toRemove = new List <RoadNode>(); foreach (RoadNode toConsider in expandableRoads) { if (!toConsider.IsAvailable()) { toRemove.Add(toConsider); continue; } bounds = toConsider.TryToBuild(request.size); if (bounds != null) { success = (Road)(toConsider.ground.Surface); break; } } foreach (RoadNode removed in toRemove) { expandableRoads.RemoveAll((elem) => (elem == removed)); } if (bounds == null) { bool someoneChanged = false; foreach (RoadNode toGrow in expandableRoads) { RoadNode expanded = toGrow.Grow(); if (expanded != null) { expandableRoads.Add(expanded); someoneChanged = true; break; } } if (!someoneChanged) { foreach (RoadNode toSplit in expandableRoads) { RoadNode split = toSplit.Split(); if (split != null) { expandableRoads.Add(split); someoneChanged = true; break; } } } if (someoneChanged) { request.Reject(); } } else { // buildStructure(Road connectedTo, Direction directionFromRoad, Structure.Type givenType, LocationPair locals) structurer.buildStructure(success, bounds.toHere, Structure.Type.House, bounds); } }