Re: Z Coordinates ...
PostPosted: Wed Nov 09, 2016 4:32 pm
Ops last piece missing:
on the Zone.cs INSIDE the constructor
after
on the Zone.cs INSIDE the constructor
after
- Code: Select all
public Zone(Region region, ushort id, string desc, int xoff, int yoff, int width, int height, ushort zoneskinID, bool isDivingEnabled, int waterlevel, bool islava, int xpBonus, int rpBonus, int bpBonus, int coinBonus, byte realm) { m_Region = region; m_ID = id; m_Description = desc; m_XOffset = xoff; m_YOffset = yoff; m_Width = width; m_Height = height; m_zoneSkinID = zoneskinID; m_waterlevel = waterlevel; m_isDivingEnabled = isDivingEnabled; m_isLava = islava; m_bonusXP = xpBonus; m_bonusRP = rpBonus; m_bonusBP = bpBonus; m_bonusCoin = coinBonus; // initialise subzone objects and counters m_subZoneElements = new SubNodeElement[SUBZONE_NBR][]; m_initialized = false; m_realm = (eRealm)realm;
- Code: Select all
// Nydirac 09/11/2016 // Load terrain and offset files for calculating Z // TODO: if needed load water map // factors loading.... // Yeah better to create some field on the db but i cant bother now... Its pretty simple to do string sectorpath = GameServer.Instance.Configuration.RootDirectory + "\\ServerFiles\\dat" + id.ToString("000") + "\\sector.dat"; if (File.Exists(sectorpath)) { TextReader reader = File.OpenText(sectorpath); string line; while ((line = reader.ReadLine()) != null) { line = line.ToLower(); if (line.Contains("scalefactor")) { m_scalefactor = byte.Parse(line.Replace("scalefactor", "").Replace("=", "").Trim()); // separate replace of = because of inconsistency of spaces... not worth the time to use regex if (m_offsetfactor != 0) //Dont need to parse ALL the file, its ugly but meh break; } if (line.Contains("offsetfactor")) { m_offsetfactor = byte.Parse(line.Replace("offsetfactor", "").Replace("=", "").Trim()); if (m_scalefactor != 0) //Dont need to parse ALL the file, its ugly but meh break; } } } // Offset loading... string offsetpath = GameServer.Instance.Configuration.RootDirectory + "\\ServerFiles\\dat" + id.ToString("000") + "\\offset.pcx"; if (File.Exists(offsetpath)) { System.Drawing.Bitmap offsetbmap = PCXFile.getBitmap(offsetpath); byte[,] zoff = new byte[256, 256]; for (int y = 0; y < 255; y++) { for (int x = 0; x < 255; x++) { zoff[x, y] = offsetbmap.GetPixel(x, y).R; } } m_zoneOffset = zoff; } // Offset loading... string terrainpath = GameServer.Instance.Configuration.RootDirectory + "\\ServerFiles\\dat" + id.ToString("000") + "\\terrain.pcx"; if (File.Exists(terrainpath)) { System.Drawing.Bitmap terrainbmap = PCXFile.getBitmap(terrainpath); byte[,] zterr = new byte[256, 256]; for (int y = 0; y < 255; y++) { for (int x = 0; x < 255; x++) { zterr[x, y] = terrainbmap.GetPixel(x, y).R; } } m_zoneTerrain = zterr; } if (m_offsetfactor != 0 && m_scalefactor != 0 && m_zoneTerrain != null && m_zoneOffset != null) // Z System components needed m_zActive = true;