Skip to content

Commit

Permalink
Fix for field terminals. (#2)
Browse files Browse the repository at this point in the history
* Fix for field terminals.

* fix remote market server error

* gives player equal syndicate protection and molecular instability when teleporting.

* Tweak syndicate protection to be 25% less than instability
  • Loading branch information
LoyalServant authored and MikeJeffers committed Jan 12, 2018
1 parent d0e4627 commit 3f8849c
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 39 deletions.
74 changes: 38 additions & 36 deletions src/Perpetuum.RequestHandlers/GetRobotInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,55 +24,57 @@ public GetRobotInfo(IZoneManager zoneManager,RobotHelper robotHelper)

public void HandleRequest(IRequest request)
{
TransactionScope scope = null;
try
// make sure the transaction scope is disposed of properly.
using (TransactionScope scope = Db.CreateTransaction())
{
if (TryGetRobotFromZone(request, out Robot robot))
try
{
scope = Db.CreateTransaction();
robot.EnlistTransaction();
}
else
{
var robotEid = request.Data.GetOrDefault<long>(k.robotEID);
robot = _robotHelper.LoadRobotForCharacter(robotEid,request.Session.Character);
}
if (TryGetRobotFromZone(request, out Robot robot))
{
robot.EnlistTransaction();
}
else
{
var robotEid = request.Data.GetOrDefault<long>(k.robotEID);
robot = _robotHelper.LoadRobotForCharacter(robotEid, request.Session.Character);
}

if (robot == null)
throw new PerpetuumException(ErrorCodes.RobotNotFound);
if (robot == null)
throw new PerpetuumException(ErrorCodes.RobotNotFound);

if ( !robot.IsSingleAndUnpacked)
throw new PerpetuumException(ErrorCodes.RobotMustbeSingleAndNonRepacked);
if (!robot.IsSingleAndUnpacked)
throw new PerpetuumException(ErrorCodes.RobotMustbeSingleAndNonRepacked);

if (ForFitting)
{
robot.CheckOwnerOnlyCharacterAndThrowIfFailed(request.Session.Character);
}
else
{
robot.CheckOwnerCharacterAndCorporationAndThrowIfFailed(request.Session.Character);
}
if (ForFitting)
{
robot.CheckOwnerOnlyCharacterAndThrowIfFailed(request.Session.Character);
}
else
{
robot.CheckOwnerCharacterAndCorporationAndThrowIfFailed(request.Session.Character);
}

switch (robot.GetOrLoadParentEntity())
{
case DefaultSystemContainer _:
case RobotInventory _ when ForFitting:
case CorporateHangar _ when ForFitting:
switch (robot.GetOrLoadParentEntity())
{
throw new PerpetuumException(ErrorCodes.AccessDenied);
case DefaultSystemContainer _:
case RobotInventory _ when ForFitting:
case CorporateHangar _ when ForFitting:
{
throw new PerpetuumException(ErrorCodes.AccessDenied);
}
}
}

var result = new Dictionary<string, object>
var result = new Dictionary<string, object>
{
{ k.robot,robot.ToDictionary() }
};

Message.Builder.FromRequest(request).WithData(result).WrapToResult().WithEmpty().Send();
}
finally
{
scope?.Complete();
Message.Builder.FromRequest(request).WithData(result).WrapToResult().WithEmpty().Send();
}
finally
{
scope?.Complete();
}
}
}

Expand Down
7 changes: 7 additions & 0 deletions src/Perpetuum/Players/Player.cs
Original file line number Diff line number Diff line change
Expand Up @@ -315,9 +315,16 @@ public void SendModuleProcessError(Module module, ErrorCodes error)
public void ApplyInvulnerableEffect()
{
var builder = NewEffectBuilder().SetType(EffectType.effect_invulnerable);
builder.WithDurationModifier(0.75); //Reduce span of syndicate protection
ApplyEffect(builder);
}

public void RemoveInvulnerableEffect()
{
EffectHandler.RemoveEffectsByType(EffectType.effect_invulnerable);
}


public void ApplyTeleportSicknessEffect()
{
var zone = Zone;
Expand Down
6 changes: 4 additions & 2 deletions src/Perpetuum/Services/MarketEngine/MarketOrderRepository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public static class MarketOrderRepositoryExtensions

public class MarketOrderRepository : IMarketOrderRepository
{
private const string ORDER_COLUMNS = "marketitemid, marketeid, itemeid, itemdefinition, submittereid, submitted, duration, isSell, price, quantity, usecorporationwallet, isvendoritem, formembersof FROM marketitems ";
private const string ORDER_COLUMNS = "marketitems.marketitemid, marketitems.marketeid, marketitems.itemeid, marketitems.itemdefinition, marketitems.submittereid, marketitems.submitted, marketitems.duration, marketitems.isSell, marketitems.price, marketitems.quantity, marketitems.usecorporationwallet, marketitems.isvendoritem, marketitems.formembersof FROM marketitems ";
private const string ORDER_SELECT = "SELECT " + ORDER_COLUMNS;
private const string TOP1_SELECT = "SELECT TOP (1) " + ORDER_COLUMNS;
private readonly MarketOrder.Factory _marketOrderFactory;
Expand Down Expand Up @@ -155,7 +155,9 @@ public IEnumerable<MarketOrder> GetExpiredOrders(TimeSpan duration)

public IEnumerable<MarketOrder> GetAllByDefinition(int definition)
{
const string cmd = ORDER_SELECT + @"where itemdefinition = @definition";
// this is an example as to why we should not have a table that references itself.
// the purpose of this is to not return market items on disabled zones.
const string cmd = ORDER_SELECT + @"INNER JOIN entities as childentity on (marketitems.marketeid=childentity.eid) INNER JOIN entities parent on (childentity.eid=parent.eid) INNER JOIN zoneentities on (parent.parent=zoneentities.eid) INNER JOIN zones on (zoneentities.zoneid=zones.id) where itemdefinition = @definition and zones.enabled=1";

return Db.Query().CommandText(cmd)
.SetParameter("@definition", definition)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,15 @@ public Task DoTeleportAsync(Player player)
player.AddToZone(zone,validPosition,ZoneEnterType.LocalTeleport);
player.SendInitSelf();
if ( ApplyTeleportSickness )
if (ApplyTeleportSickness)
{
player.ApplyTeleportSicknessEffect();
}
if (ApplyInvulnerable)
{
player.RemoveInvulnerableEffect(); // remove previous effect.
player.ApplyInvulnerableEffect(); // re-add effect to restart counter.
}
// mozoghat, fade out
player.States.InMoveable = false;
Expand Down

0 comments on commit 3f8849c

Please sign in to comment.