• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
No Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Automap (client) [VS plugin mod]


Commit MetaInfo

Revisãoc46988f0b9e821ef654f7334608b0abc4966e57f (tree)
Hora2020-03-11 22:22:18
AutorThe Grand Dog <alex.h@me.c...>
CommiterThe Grand Dog

Mensagem de Log

change the way the metadata is exported, typos

instead of having a map of objects, a map of arrays with a seperate array of names is used, this makes a smaller file

Mudança Sumário

Diff

--- a/Automap/Data/BlockDesignator.cs
+++ b/Automap/Data/BlockDesignator.cs
@@ -9,7 +9,7 @@ using Vintagestory.API.MathTools;
99
1010 namespace Automap
1111 {
12- public delegate void BlockDesignatonAction(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block);
12+ public delegate void BlockDesignatorAction(ICoreClientAPI clientAPI, PointsOfInterest poi, BlockPos posn, Block block);
1313
1414 /// <summary>
1515 /// Point of Interest Rule Designator
@@ -17,7 +17,7 @@ namespace Automap
1717 public class BlockDesignator
1818 {
1919 public Color OverwriteColor;
20- public BlockDesignatonAction SpecialAction;
20+ public BlockDesignatorAction SpecialAction;
2121 public AssetLocation Pattern;
2222 public EnumBlockMaterial? Material;
2323 public bool Enabled { get; set; }
@@ -35,7 +35,7 @@ namespace Automap
3535 this.Enabled = true;
3636 }
3737
38- public BlockDesignator(AssetLocation pattern, Color overwriteColor, EnumBlockMaterial? material, BlockDesignatonAction specialAct)
38+ public BlockDesignator(AssetLocation pattern, Color overwriteColor, EnumBlockMaterial? material, BlockDesignatorAction specialAct)
3939 {
4040 this.Pattern = pattern;
4141 this.OverwriteColor = overwriteColor;
--- a/Automap/Data/EntitiesOfInterest.cs
+++ b/Automap/Data/EntitiesOfInterest.cs
@@ -10,7 +10,7 @@ using Vintagestory.API.MathTools;
1010 namespace Automap
1111 {
1212 /// <summary>
13- /// Actual Physical Point in space - that is interesting.
13+ /// Basically the same as a POI but for an entity
1414 /// </summary>
1515 public struct EntityOfInterest
1616 {
@@ -26,6 +26,8 @@ namespace Automap
2626 /// <remarks>Tracked by ID - these never leave.</remarks>
2727 public class EntitiesOfInterest : KeyedCollection<long, EntityOfInterest>
2828 {
29+ protected override long GetKeyForItem(EntityOfInterest item)
30+ => item.EntityId;
2931
3032 internal void AddReplace(EntityOfInterest entity)
3133 {
@@ -35,8 +37,6 @@ namespace Automap
3537 Add(entity);
3638 }
3739
38- protected override long GetKeyForItem(EntityOfInterest item)
39- => item.EntityId;
4040 }
4141 }
4242
--- a/Automap/Data/EntityDesignator.cs
+++ b/Automap/Data/EntityDesignator.cs
@@ -10,7 +10,7 @@ using Vintagestory.API.MathTools;
1010
1111 namespace Automap
1212 {
13- public delegate void EntityDesignatonAction(ICoreClientAPI clientAPI, EntitiesOfInterest poi, BlockPos posn, Entity entity);
13+ public delegate void EntityDesignatorAction(ICoreClientAPI clientAPI, EntitiesOfInterest poi, BlockPos posn, Entity entity);
1414
1515 /// <summary>
1616 /// Point of Interest Rule Designator
@@ -18,7 +18,7 @@ namespace Automap
1818 public class EntityDesignator
1919 {
2020 public Color Color;
21- public EntityDesignatonAction SpecialAction;
21+ public EntityDesignatorAction SpecialAction;
2222 public AssetLocation Pattern;
2323 public EnumEntityState? StateCheck;//Needed?
2424 public bool Enabled { get; set; }
@@ -36,7 +36,7 @@ namespace Automap
3636 Enabled = true;
3737 }
3838
39- public EntityDesignator(AssetLocation pattern, Color color, EnumEntityState? state, EntityDesignatonAction specialAct)
39+ public EntityDesignator(AssetLocation pattern, Color color, EnumEntityState? state, EntityDesignatorAction specialAct)
4040 {
4141 Pattern = pattern;
4242 Color = color;
--- a/Automap/Designators/DefaultDesignators.cs
+++ b/Automap/Designators/DefaultDesignators.cs
@@ -131,7 +131,7 @@ namespace Automap
131131
132132 internal static void KeepTrackOfMerchant(ICoreClientAPI clientAPI, EntitiesOfInterest poi, BlockPos posn, Entity entity)
133133 {
134- clientAPI.Logger.VerboseDebug("Trader: {0} @ {1}", entity.GetName(), posn);
134+ //clientAPI.Logger.VerboseDebug("Trader: {0} @ {1}", entity.GetName(), posn);
135135
136136 var traderJoe = entity as EntityTrader;
137137 var message = $"{entity.GetName()} Alive: {traderJoe.Alive}";
--- a/Automap/Subsystems/AutomapSystem.cs
+++ b/Automap/Subsystems/AutomapSystem.cs
@@ -169,11 +169,13 @@ namespace Automap
169169 }
170170
171171 ColumnMeta chunkMeta;
172- if (chunkTopMetadata.Contains(mostActiveCol.Key)) {
173- chunkMeta = chunkTopMetadata[mostActiveCol.Key];
172+ if (chunkTopMetadata.Contains(mostActiveCol.Key))
173+ {
174+ chunkMeta = chunkTopMetadata[mostActiveCol.Key];
174175 }
175- else {
176- chunkMeta = CreateColumnMetadata(mostActiveCol, mapChunk);
176+ else
177+ {
178+ chunkMeta = CreateColumnMetadata(mostActiveCol, mapChunk);
177179 }
178180
179181 UpdateEntityMetadata();
@@ -309,33 +311,40 @@ namespace Automap
309311 jsonWriter.Write("ViewFrame.chunks.southMostChunk={0};", chunkTopMetadata.South_mostChunk);
310312 jsonWriter.Write("ViewFrame.chunks.eastMostChunk={0};", chunkTopMetadata.East_mostChunk);
311313 jsonWriter.Write("ViewFrame.chunks.westMostChunk={0};", chunkTopMetadata.West_mostChunk);
314+ // this is so that the tool tip doesnt need to be hard coded in the map
315+ jsonWriter.Write("ViewFrame.chunks.chunkMetaNames=[");
316+ // there are 10 (TEN) (ten) things
317+ jsonWriter.Write("'Loc.','Age','Temp.','Y Max','Fert.','Forest','Rain','Shrub','Air','Non-Air'");
318+ jsonWriter.Write("];");
312319 //MAP object format - [key, value]: key is "x_y"
313320 jsonWriter.Write("ViewFrame.chunks.chunkMetadata=new Map([");
314321 foreach (var shard in chunkTopMetadata)
315322 {
316323 jsonWriter.Write("['{0}_{1}',", shard.Location.X, shard.Location.Y);
317- jsonWriter.Write("{");
318- jsonWriter.Write("prettyCoord:'{0}',", shard.Location.PrettyCoords(ClientAPI));
319- jsonWriter.Write("chunkAge:'{0}',", shard.ChunkAge.ToString("g"));//World age - relative? or last edit ??
320- jsonWriter.Write("temp:'{0}',", shard.Temperature.ToString("F1"));
321- jsonWriter.Write("YMax:'{0}',", shard.YMax);
322- jsonWriter.Write("fert:'{0}',", shard.Fertility.ToString("F1"));
323- jsonWriter.Write("forestDens:'{0}',", shard.ForestDensity.ToString("F1"));
324- jsonWriter.Write("rain:'{0}',", shard.Rainfall.ToString("F1"));
325- jsonWriter.Write("shrubDens:'{0}',", shard.ShrubDensity.ToString("F1"));
326- jsonWriter.Write("airBlocks:'{0}',", shard.AirBlocks);
327- jsonWriter.Write("nonAirBlocks:'{0}',", shard.NonAirBlocks);
328- //TODO: Heightmap
324+ jsonWriter.Write("[");
325+ // 10 things but 0 indexed so NINE (9)
326+ jsonWriter.Write("'{0}','{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}'",
327+ shard.Location.PrettyCoords(ClientAPI),
328+ shard.ChunkAge.ToString("g"),//World age - relative? or last edit ??
329+ shard.Temperature.ToString("F1"),
330+ shard.YMax,
331+ shard.Fertility.ToString("F1"),
332+ shard.ForestDensity.ToString("F1"),
333+ shard.Rainfall.ToString("F1"),
334+ shard.ShrubDensity.ToString("F1"),
335+ shard.AirBlocks,
336+ shard.NonAirBlocks
337+ );
329338 //TODO: Rock-ratio, also requires a BlockID => Name lookup table....elsewhere
330- jsonWriter.Write("}],");
339+ jsonWriter.Write("]],");
331340 }
332341 jsonWriter.Write("]);");
333342
334343
335- jsonWriter.Write("ViewFrame.chunks.pointsOfInterest = new Map([");
344+ jsonWriter.Write("ViewFrame.chunks.pointsOfInterest=new Map([");
336345 foreach (var poi in POIs)
337346 {
338- jsonWriter.Write("['{0}_{1}',", poi.Location.X, poi.Location.Z);
347+ jsonWriter.Write("['{0}_{1}',", (float) poi.Location.X / chunkSize, (float) poi.Location.Z / chunkSize);
339348 jsonWriter.Write("{");
340349 jsonWriter.Write("prettyCoord:'{0}',", poi.Location.PrettyCoords(ClientAPI));
341350 jsonWriter.Write("notes:{0},", JsonConvert.ToString(poi.Notes, '\'', StringEscapeHandling.EscapeHtml));
@@ -343,15 +352,18 @@ namespace Automap
343352 jsonWriter.Write("chunkPos:'{0}_{1}',", (poi.Location.X / chunkSize), (poi.Location.Z / chunkSize));
344353 jsonWriter.Write("}],");
345354 }
355+ jsonWriter.Write("]);");
346356
347- foreach (var poi in EOIs)
357+ jsonWriter.Write("ViewFrame.chunks.entitiesOfInterest=new Map([");
358+ foreach (var eoi in EOIs)
348359 {
349- jsonWriter.Write("['{0}_{1}',", poi.Location.X, poi.Location.Z);
360+ jsonWriter.Write("['{0}_{1}',", (float) eoi.Location.X / chunkSize, (float) eoi.Location.Z / chunkSize);
350361 jsonWriter.Write("{");
351- jsonWriter.Write("prettyCoord:'{0}',", poi.Location.PrettyCoords(ClientAPI));
352- jsonWriter.Write("notes:{0},", JsonConvert.ToString(poi.Notes, '\'', StringEscapeHandling.EscapeHtml));
353- jsonWriter.Write("time:new Date('{0}'),", poi.Timestamp.ToString("O"));
354- jsonWriter.Write("chunkPos:'{0}_{1}',", (poi.Location.X / chunkSize), (poi.Location.Z / chunkSize));
362+ jsonWriter.Write("prettyCoord:'{0}',", eoi.Location.PrettyCoords(ClientAPI));
363+ jsonWriter.Write("notes:{0},", JsonConvert.ToString(eoi.Notes, '\'', StringEscapeHandling.EscapeHtml));
364+ jsonWriter.Write("time:new Date('{0}'),", eoi.Timestamp.ToString("O"));
365+ jsonWriter.Write("chunkPos:'{0}_{1}',", (eoi.Location.X / chunkSize), (eoi.Location.Z / chunkSize));
366+ jsonWriter.Write("entityId:'{0}'", eoi.EntityId);
355367 jsonWriter.Write("}],");
356368 }
357369 jsonWriter.Write("]);");
@@ -364,7 +376,7 @@ namespace Automap
364376
365377 private ColumnMeta CreateColumnMetadata(KeyValuePair<Vec2i, uint> mostActiveCol, IMapChunk mapChunk)
366378 {
367- ColumnMeta data = new ColumnMeta(mostActiveCol.Key.Copy(), ( byte )chunkSize);
379+ ColumnMeta data = new ColumnMeta(mostActiveCol.Key.Copy(), (byte) chunkSize);
368380 BlockPos equivBP = new BlockPos(mostActiveCol.Key.X * chunkSize,
369381 mapChunk.YMax,
370382 mostActiveCol.Key.Y * chunkSize);
@@ -390,38 +402,41 @@ namespace Automap
390402
391403 if (files.Length > 0)
392404 {
393- #if DEBUG
405+#if DEBUG
394406 Logger.VerboseDebug("{0} Existing world chunk shards", files.Length);
395- #endif
396-
397- foreach (var shardFile in files) {
407+#endif
398408
399- if (shardFile.Length < 1024) continue;
400- var result = chunkShardRegex.Match(shardFile.Name);
401- if (result.Success) {
402- int X_chunk_pos = int.Parse(result.Groups["X"].Value);
403- int Z_chunk_pos = int.Parse(result.Groups["Z"].Value);
409+ foreach (var shardFile in files)
410+ {
404411
405- try
412+ if (shardFile.Length < 1024) continue;
413+ var result = chunkShardRegex.Match(shardFile.Name);
414+ if (result.Success)
406415 {
407- using (var fileStream = shardFile.OpenRead( )) {
416+ int X_chunk_pos = int.Parse(result.Groups["X"].Value);
417+ int Z_chunk_pos = int.Parse(result.Groups["Z"].Value);
408418
409- PngReader pngRead = new PngReader(fileStream);
410- pngRead.ReadSkippingAllRows( );
411- pngRead.End( );
412- //Parse PNG chunks for METADATA in shard
413- PngMetadataChunk metadataFromPng = pngRead.GetChunksList( ).GetById1(PngMetadataChunk.ID) as PngMetadataChunk;
419+ try
420+ {
421+ using (var fileStream = shardFile.OpenRead())
422+ {
414423
415- chunkTopMetadata.Add(metadataFromPng.ChunkMetadata);
416- }
424+ PngReader pngRead = new PngReader(fileStream);
425+ pngRead.ReadSkippingAllRows();
426+ pngRead.End();
427+ //Parse PNG chunks for METADATA in shard
428+ PngMetadataChunk metadataFromPng = pngRead.GetChunksList().GetById1(PngMetadataChunk.ID) as PngMetadataChunk;
417429
430+ chunkTopMetadata.Add(metadataFromPng.ChunkMetadata);
431+ }
432+
433+ }
434+ catch (PngjException someEx)
435+ {
436+ Logger.Error("PNG Corruption file '{0}' - Reason: {1}", shardFile.Name, someEx);
437+ continue;
438+ }
418439 }
419- catch (PngjException someEx)
420- {
421- Logger.Error("PNG Corruption file '{0}' - Reason: {1}", shardFile.Name, someEx);
422- continue;
423- }
424- }
425440
426441 }
427442 }
@@ -475,21 +490,21 @@ namespace Automap
475490 int targetChunkY = mapChunk.YMax / chunkSize;//Surface ...
476491 for (; targetChunkY > 0; targetChunkY--)
477492 {
478- WorldChunk chunkData = ClientAPI.World.BlockAccessor.GetChunk(key.X, targetChunkY, key.Y) as WorldChunk;
479-
480- if (chunkData == null || chunkData.BlockEntities == null) {
481- #if DEBUG
482- Logger.VerboseDebug("Chunk null or empty X{0} Y{1} Z{2}", key.X, targetChunkY, key.Y);
483- #endif
484- continue;
485- }
493+ WorldChunk chunkData = ClientAPI.World.BlockAccessor.GetChunk(key.X, targetChunkY, key.Y) as WorldChunk;
494+ if (chunkData == null || chunkData.BlockEntities == null)
495+ {
496+#if DEBUG
497+ Logger.VerboseDebug("Chunk null or empty X{0} Y{1} Z{2}", key.X, targetChunkY, key.Y);
498+#endif
499+ continue;
500+ }
486501
487502 /*************** Chunk Entities Scanning *********************/
488503 if (chunkData.BlockEntities != null && chunkData.BlockEntities.Length > 0)
489504 {
490- #if DEBUG
505+#if DEBUG
491506 Logger.VerboseDebug("Surface@ {0} = BlockEntities: {1}", key, chunkData.BlockEntities.Length);
492- #endif
507+#endif
493508
494509 foreach (var blockEnt in chunkData.BlockEntities)
495510 {
@@ -534,10 +549,12 @@ namespace Automap
534549
535550 chunkMeta.NonAirBlocks++;
536551
537- //Heightmap
538- if (chunkMeta.HeightMap[X_index, Z_index] == 0)
539- { chunkMeta.HeightMap[X_index, Z_index] = (ushort) (Y_index + (targetChunkY * chunkSize)); }
540-
552+ ////Heightmap
553+ //if (chunkMeta.HeightMap[X_index, Z_index] == 0)
554+ //{
555+ // chunkMeta.HeightMap[X_index, Z_index]
556+ // = (ushort) (Y_index + (targetChunkY * chunkSize));
557+ //}
541558 }
542559 while (X_index++ < (chunkSize - 1));
543560 X_index = 0;
@@ -564,6 +581,7 @@ namespace Automap
564581 var dMatch = Entity_Designators.SingleOrDefault(se => se.Key.Equals(loadedEntity.Value.Code));
565582 if (dMatch.Value != null)
566583 {
584+ Logger.Chat("Entity designator hit!");
567585 dMatch.Value.SpecialAction(ClientAPI, this.EOIs, loadedEntity.Value.LocalPos.AsBlockPos.Copy(), loadedEntity.Value);
568586 }
569587