Ignore:
Timestamp:
Oct 28, 2015, 7:51:20 PM (9 years ago)
Author:
peter.souza
Message:

Enemies (zombies and hostile animal entities) are now shown on the map as Hostiles and require permission level 'webapi.gethostilelocation' for web viewers to see.

Animals (non-hostile entities) are now shown on the map as Animals and require permission level 'webapi.getanimalslocation' for web viewers to see.

Permission level for 'webapi.viewallclaims' is now required for a viewer to see all claims, otherwise the permission level for 'webapi.getlandclaims' will only show viewer-owned claims. A viewer requires both 'webapi.getlandclaims' and 'webapi.viewallclaims' to be set for all claims to show (you can't just set 'webapi.viewallclaims').
https://7daystodie.com/forums/showthread.php?12837-Improvements-for-the-dedicated-server&p=317405&viewfull=1#post317405

Permission level for 'webapi.viewallplayers' is now required for a viewer to see all players, otherwise the permission level for 'webapi.getplayerslocation' will only show the player for the currently-authenticated viewer. A viewer requires both 'webapi.getplayerslocation' and 'webapi.viewallplayers' to be set for all players to show (you can't just set 'webapi.viewallplayers').
https://7daystodie.com/forums/showthread.php?12837-Improvements-for-the-dedicated-server&p=317405&viewfull=1#post317405

Banned players are now hidden from the web map.
https://7daystodie.com/forums/showthread.php?12837-Improvements-for-the-dedicated-server&p=320702&viewfull=1#post320702

Items using 'CustomIcon' and 'CustomIconTint' are now supported (although the exact tinting may not be perfectly the same as the game).
https://7daystodie.com/forums/showthread.php?12837-Improvements-for-the-dedicated-server&p=317117&viewfull=1#post317117
https://7daystodie.com/forums/showthread.php?12837-Improvements-for-the-dedicated-server&p=317679&viewfull=1#post317679

Map marker icons for players, hostiles, and animals have been updated.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • binary-improvements/MapRendering/Web/Handlers/ItemIconHandler.cs

    r244 r251  
    11using System;
    22using System.Collections.Generic;
    3 using System.IO;
    43using System.Net;
    54using System.Threading;
     
    1312                private string staticPart;
    1413                private bool logMissingFiles;
    15                 private Dictionary<string, byte[]> icons = new Dictionary<string, byte[]> ();
    16                 private bool loaded = false;
     14        private Dictionary<string, byte[]> icons = new Dictionary<string, byte[]> ();
     15        private bool loaded = false;
    1716
    1817                public ItemIconHandler (string staticPart, bool logMissingFiles, string moduleName = null) : base(moduleName) {
     
    3029                        }
    3130
    32                         string fn = req.Url.AbsolutePath.Remove (0, staticPart.Length);
    33                         fn = fn.Remove (fn.LastIndexOf ('.'));
     31            // BEGIN CHANGED BY PSOUZA4
     32                        string requestFileName = req.Url.AbsolutePath.Remove (0, staticPart.Length);
     33                        requestFileName = requestFileName.Remove (requestFileName.LastIndexOf ('.'));
    3434
    35                         if (icons.ContainsKey (fn)) {
     35            string requestColorTintHex = string.Empty;
     36           
     37            // Chose a split instead of using a querystring variable in the URI, but that may arguably be cleaner
     38            if (requestFileName.Contains("@@")) {
     39                try {
     40                    string[] tempTintingOptions = requestFileName.Split (new string[] { "@@" }, StringSplitOptions.RemoveEmptyEntries);
     41                    requestFileName = tempTintingOptions [0];
     42                    requestColorTintHex = tempTintingOptions [1].Trim ().ToUpper ();
     43                }
     44                catch { }
     45            }
     46
     47            if (icons.ContainsKey (requestFileName) && req.Url.AbsolutePath.ToLower ().EndsWith(".png")) {
    3648                                resp.ContentType = MimeType.GetMimeType (".png");
    37                                 resp.ContentLength64 = icons [fn].Length;
    38                                 resp.OutputStream.Write (icons [fn], 0, icons [fn].Length);
     49
     50                byte[] itemIconData = icons [requestFileName];
     51
     52                // Note: optionally split this code into a ImageMultiplyBlend method
     53                if (!string.IsNullOrEmpty (requestColorTintHex) && (requestColorTintHex != "FFFFFF")) {
     54                    try {
     55                        System.Drawing.Color colorTint = System.Drawing.ColorTranslator.FromHtml ("#" + requestColorTintHex);
     56                        System.Drawing.Bitmap image = (System.Drawing.Bitmap)PetesUtils.GetImageFromBytes (itemIconData);
     57
     58                        for (var x = 0; x < image.Width; x++) {
     59                            for (int y = 0; y < image.Height; y++) {
     60                                System.Drawing.Color originalColor = image.GetPixel (x, y);
     61                                System.Drawing.Color changedColor = originalColor;
     62
     63                                // Only change the icon tinting if the alpha channel is fully opaque
     64                                if (originalColor.A == 255) {
     65                                    // based on http://stackoverflow.com/questions/3837757/multiply-two-images-in-c-sharp-as-multiply-two-layers-in-photoshop
     66
     67                                    double component_R = (((double)originalColor.R) * ((double)colorTint.R)) / 255.0;
     68                                    double component_G = (((double)originalColor.G) * ((double)colorTint.G)) / 255.0;
     69                                    double component_B = (((double)originalColor.B) * ((double)colorTint.B)) / 255.0;
     70
     71                                    if (component_R > 255.0) component_R = 255.0;
     72                                    if (component_G > 255.0) component_G = 255.0;
     73                                    if (component_B > 255.0) component_B = 255.0;
     74
     75                                    // multiply blend shouldn't ever calculate below 0, but for completeness let's leave in this logic
     76                                    if (component_R < 0.0) component_R = 0.0;
     77                                    if (component_G < 0.0) component_G = 0.0;
     78                                    if (component_B < 0.0) component_B = 0.0;
     79
     80                                    changedColor = System.Drawing.Color.FromArgb (originalColor.A, (int)component_R, (int)component_G, (int)component_B);
     81                                }                               
     82
     83                                image.SetPixel (x, y, changedColor);
     84                            }
     85                        }
     86
     87                        itemIconData = PetesUtils.SaveImage_ToBytes (image, true);
     88                    }
     89                    catch { }
     90                }
     91
     92                                resp.ContentLength64 = itemIconData.Length;
     93                                resp.OutputStream.Write (itemIconData, 0, itemIconData.Length);
     94                // END CHANGED BY PSOUZA4
    3995                        } else {
    4096                                resp.StatusCode = (int)HttpStatusCode.NotFound;
Note: See TracChangeset for help on using the changeset viewer.