Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions Maple2.File.Ingest/Mapper/MapEntityMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ private IEnumerable<MapEntity> ParseMap(string xblock, IEnumerable<IMapEntity> e
IMS2Bounding? secondBounding = null;

Dictionary<string, IMS2WayPoint> ms2WayPoints = new();
foreach (var wayPoint in entities) {
IMapEntity[] mapEntities = entities as IMapEntity[] ?? entities.ToArray();
foreach (IMapEntity wayPoint in mapEntities) {
switch (wayPoint) {
case IMS2WayPoint ms2WayPoint:
ms2WayPoints.Add(ms2WayPoint.EntityId, ms2WayPoint);
Expand All @@ -35,7 +36,7 @@ private IEnumerable<MapEntity> ParseMap(string xblock, IEnumerable<IMapEntity> e
}
}

foreach (IMapEntity entity in entities) {
foreach (IMapEntity entity in mapEntities) {
switch (entity) {
case IMS2InteractObject interactObject:

Expand All @@ -56,6 +57,9 @@ private IEnumerable<MapEntity> ParseMap(string xblock, IEnumerable<IMapEntity> e
};
continue;
case IMS2SimpleUiObject simpleUiObject:
yield return new MapEntity(xblock, new Guid(entity.EntityId), entity.EntityName) {
Block = new Ms2SimpleUiObject(simpleUiObject.interactID, simpleUiObject.Position, simpleUiObject.Rotation),
};
continue;
case IMS2Telescope telescope:
yield return new MapEntity(xblock, new Guid(entity.EntityId), entity.EntityName) {
Expand Down
6 changes: 3 additions & 3 deletions Maple2.File.Ingest/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,11 @@

var index = new FlatTypeIndex(exportedReader);

XBlockParser parser = new XBlockParser(exportedReader, index);
var xBlockParser = new XBlockParser(exportedReader, index);

UpdateDatabase(metadataContext, new MapEntityMapper(metadataContext, parser));
UpdateDatabase(metadataContext, new MapEntityMapper(metadataContext, xBlockParser));

MapDataMapper mapDataMapper = new MapDataMapper(metadataContext, parser);
var mapDataMapper = new MapDataMapper(metadataContext, xBlockParser);

UpdateDatabase(metadataContext, mapDataMapper);

Expand Down
3 changes: 3 additions & 0 deletions Maple2.Model/Common/Vector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public static implicit operator Vector3(Vector3B vector) {
public static Vector3B operator +(in Vector3B a, in Vector3B b) =>
new((sbyte) (a.X + b.X), (sbyte) (a.Y + b.Y), (sbyte) (a.Z + b.Z));

public static Vector3 operator *(in Vector3B a, float multiplier) =>
new(a.X * multiplier, a.Y * multiplier, a.Z * multiplier);

public int ConvertToInt() {
// Convert x, y, and z to a single 24-bit integer
return ((Z & 0xFF) << 16) | ((Y & 0xFF) << 8) | (X & 0xFF);
Expand Down
4 changes: 3 additions & 1 deletion Maple2.Server.Game/Commands/CoordCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ private void Handle(InvocationContext ctx, string? x, string? y, string? z, bool
if (session.Field is null) return;

Vector3 pos = session.Player.Position;
Vector3B vector3B = pos;
Vector3 center = vector3B * Constant.BlockSize;
if (x == null && y == null && z == null) {
ctx.Console.Out.WriteLine("Current position: " + pos + ", Vector3B: " + (Vector3B) pos);
ctx.Console.Out.WriteLine("Current position: " + pos + "\nVector3B: " + vector3B + "\nBlock center: " + center);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ public bool RemoveInteract(IInteractObject interactObject, TimeSpan removeDelay
}

public bool RemoveNpc(int objectId, TimeSpan removeDelay = default) {
if (!Mobs.TryGetValue(objectId, out FieldNpc? npc) && !Npcs.TryGetValue(objectId, out npc)) {
if (!Mobs.TryGetValue(objectId, out _) && !Npcs.TryGetValue(objectId, out _)) {
return false;
}

Expand Down