Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a8f507a
Showing
587 changed files
with
265,934 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# Other version control systems | ||
.svn/ | ||
|
||
# Visual Studio cruft | ||
*.csproj.user | ||
*.suo | ||
App_Data/ | ||
obj/ | ||
bin/ | ||
|
||
# Web site stuff | ||
web.config | ||
robots.txt | ||
sitemap.xml | ||
|
||
# Publishing stuff | ||
*.bat | ||
*.scr | ||
|
||
# Unrelated stuff on site | ||
info.htm | ||
model2/ | ||
pictures/ | ||
tmp/ | ||
res/Sectors/Legacy/ | ||
|
||
# Windows cruft | ||
Thumbs.db |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%@ Page language="c#" Codebehind="Admin.aspx.cs" AutoEventWireup="false" Inherits="Maps.Pages.Admin" %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
using System; | ||
using System.Data.SqlClient; | ||
using System.IO; | ||
using System.Text; | ||
|
||
namespace Maps.Pages | ||
{ | ||
public class Admin : BasePage | ||
{ | ||
public override string DefaultContentType { get { return System.Net.Mime.MediaTypeNames.Text.Html; } } | ||
|
||
private void Page_Load(object sender, System.EventArgs e) | ||
{ | ||
if (!AdminAuthorized()) | ||
return; | ||
|
||
Server.ScriptTimeout = 3600; // An hour should be plenty | ||
Response.ContentType = System.Net.Mime.MediaTypeNames.Text.Html; | ||
Response.BufferOutput = false; | ||
|
||
Response.Write("<!DOCTYPE html>"); | ||
Response.Write("<title>Admin Page</title>"); | ||
Response.Write("<style>"); | ||
using (var reader = new StreamReader(Server.MapPath("~/site.css"), Encoding.UTF8)) | ||
{ | ||
while (!reader.EndOfStream) | ||
{ | ||
Response.Write(reader.ReadLine()); | ||
} | ||
} | ||
Response.Write("</style>"); | ||
Response.Write("<h1>Traveller Map - Administration</h1>"); | ||
Response.Flush(); | ||
|
||
string action = GetStringOption("action"); | ||
switch (action) | ||
{ | ||
case "reindex": Reindex(); return; | ||
case "flush": Flush(); return; | ||
} | ||
Write("Unknown action: <pre>" + action + "</pre>"); | ||
Write("<b>Ω</b>"); | ||
} | ||
|
||
private void Write(string line) | ||
{ | ||
Response.Write("<div>"); | ||
Response.Write(line); | ||
Response.Write("</div>"); | ||
Response.Flush(); | ||
} | ||
|
||
private void Flush() | ||
{ | ||
SectorMap.Flush(); | ||
Write("Sector map flushed."); | ||
Write("<b>Ω</b>"); | ||
} | ||
|
||
private void Reindex() | ||
{ | ||
|
||
Write("Initializing resource manager..."); | ||
ResourceManager resourceManager = new ResourceManager(Server, Cache); | ||
|
||
SearchEngine.PopulateDatabase(resourceManager, Write); | ||
|
||
Write(" "); | ||
Write("Summary:"); | ||
using (var connection = DBUtil.MakeConnection()) | ||
{ | ||
foreach (string table in new string[] { "sectors", "subsectors", "worlds" }) | ||
{ | ||
string sql = String.Format("SELECT COUNT(*) FROM {0}", table); | ||
using (var command = new SqlCommand(sql, connection)) | ||
{ | ||
using (var reader = command.ExecuteReader()) | ||
{ | ||
while (reader.Read()) | ||
{ | ||
Write(String.Format("{0}: {1}", table, reader.GetInt32(0))); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
Write("<b>Ω</b>"); | ||
|
||
} | ||
|
||
#region Web Form Designer generated code | ||
override protected void OnInit(EventArgs e) | ||
{ | ||
// | ||
// CODEGEN: This call is required by the ASP.NET Web Form Designer. | ||
// | ||
InitializeComponent(); | ||
base.OnInit(e); | ||
} | ||
|
||
/// <summary> | ||
/// Required method for Designer support - do not modify | ||
/// the contents of this method with the code editor. | ||
/// </summary> | ||
private void InitializeComponent() | ||
{ | ||
this.Load += new System.EventHandler(this.Page_Load); | ||
} | ||
#endregion | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
using System; | ||
using System.Reflection; | ||
|
||
// | ||
// General Information about an assembly is controlled through the following | ||
// set of attributes. Change these attribute values to modify the information | ||
// associated with an assembly. | ||
// | ||
[assembly: AssemblyTitle("")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("")] | ||
[assembly: AssemblyCopyright("")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// | ||
// Version information for an assembly consists of the following four values: | ||
// | ||
// Major Version | ||
// Minor Version | ||
// Build Number | ||
// Revision | ||
// | ||
// You can specify all the values or you can default the Revision and Build Numbers | ||
// by using the '*' as shown below: | ||
|
||
[assembly: AssemblyVersion("1.0.*")] | ||
|
||
// | ||
// In order to sign your assembly you must specify a key to use. Refer to the | ||
// Microsoft .NET Framework documentation for more information on assembly signing. | ||
// | ||
// Use the attributes below to control which key is used for signing. | ||
// | ||
// Notes: | ||
// (*) If no key is specified, the assembly is not signed. | ||
// (*) KeyName refers to a key that has been installed in the Crypto Service | ||
// Provider (CSP) on your machine. KeyFile refers to a file which contains | ||
// a key. | ||
// (*) If the KeyFile and the KeyName values are both specified, the | ||
// following processing occurs: | ||
// (1) If the KeyName can be found in the CSP, that key is used. | ||
// (2) If the KeyName does not exist and the KeyFile does exist, the key | ||
// in the KeyFile is installed into the CSP and used. | ||
// (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. | ||
// When specifying the KeyFile, the location of the KeyFile should be | ||
// relative to the "project output directory". The location of the project output | ||
// directory is dependent on whether you are working with a local or web project. | ||
// For local projects, the project output directory is defined as | ||
// <Project Directory>\obj\<Configuration>. For example, if your KeyFile is | ||
// located in the project directory, you would specify the AssemblyKeyFile | ||
// attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] | ||
// For web projects, the project output directory is defined as | ||
// %HOMEPATH%\VSWebCache\<Machine Name>\<Project Directory>\obj\<Configuration>. | ||
// (*) Delay Signing is an advanced option - see the Microsoft .NET Framework | ||
// documentation for more information on this. | ||
// | ||
[assembly: AssemblyDelaySign(false)] | ||
[assembly: AssemblyKeyFile("")] | ||
[assembly: AssemblyKeyName("")] | ||
|
||
[assembly: CLSCompliant(false)] | ||
[assembly: System.Runtime.InteropServices.ComVisible(false)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,126 @@ | ||
using System; | ||
using System.Drawing; | ||
|
||
namespace Maps | ||
{ | ||
|
||
public static class Astrometrics | ||
{ | ||
public const int SectorWidth = 32; // parsecs | ||
public const int SectorHeight = 40; // parsecs | ||
|
||
public const int SectorCentralHex = (SectorWidth / 2) * 100 + (SectorHeight / 2); | ||
|
||
public const int SubsectorWidth = 8; // parsecs | ||
public const int SubsectorHeight = 10; // parsecs | ||
|
||
// Parsecs are not square - there is horizontal overlap in a hex grid | ||
// width:height ratio for parsecs is cos(30) | ||
// (a subsector is 8:10 parsecs but 0.69:1 aspect ratio) | ||
public static readonly float ParsecScaleX = (float)Math.Cos(Math.PI / 6); | ||
public static readonly float ParsecScaleY = 1.0f; | ||
|
||
// Reference (Core 0140) | ||
// Origin of the coordinate system, relative to the containing sector | ||
// ("Reference, Center of the Imperium" The Travellers' Digest 10) | ||
public static readonly Point ReferenceSector = new Point(0, 0); | ||
public static readonly Point ReferenceHex = new Point(01, 40); | ||
|
||
public static Point LocationToCoordinates(Location location) | ||
{ | ||
return LocationToCoordinates(location.SectorLocation, location.HexLocation); | ||
} | ||
public static Point LocationToCoordinates(Point sector, Point hex) | ||
{ | ||
int x = (sector.X - ReferenceSector.X) * SectorWidth + (hex.X - ReferenceHex.X); | ||
int y = (sector.Y - ReferenceSector.Y) * SectorHeight + (hex.Y - ReferenceHex.Y); | ||
|
||
return new Point(x, y); | ||
} | ||
public static Location CoordinatesToLocation(Point coordinates) | ||
{ | ||
return CoordinatesToLocation(coordinates.X, coordinates.Y); | ||
} | ||
public static Location CoordinatesToLocation(int x, int y) | ||
{ | ||
x += Astrometrics.ReferenceHex.X - 1; | ||
y += Astrometrics.ReferenceHex.Y - 1; | ||
|
||
Point sector = Point.Empty; | ||
Point hex = Point.Empty; | ||
|
||
sector.X = (x - (x < 0 ? Astrometrics.SectorWidth - 1 : 0)) / Astrometrics.SectorWidth; | ||
sector.Y = (y - (y < 0 ? Astrometrics.SectorHeight - 1 : 0)) / Astrometrics.SectorHeight; | ||
|
||
hex.X = x - (sector.X * Astrometrics.SectorWidth) + 1; | ||
hex.Y = y - (sector.Y * Astrometrics.SectorHeight) + 1; | ||
|
||
return new Location(sector, hex); | ||
} | ||
|
||
public static int HexDistance(Point hex1, Point hex2) | ||
{ | ||
int dx = hex2.X - hex1.X; | ||
int dy = hex2.Y - hex1.Y; | ||
|
||
int adx = Math.Abs(dx); | ||
int ody = dy + (adx / 2); | ||
|
||
if ((hex1.X % 2 == 0) && (hex2.X % 2 != 0)) { ody += 1; } | ||
|
||
return Math.Max(adx - ody, Math.Max(ody, adx)); | ||
|
||
} | ||
|
||
public static PointF HexToCenter(Point point) | ||
{ | ||
PointF pf = PointF.Empty; | ||
|
||
pf.X = point.X - 0.5f; | ||
pf.Y = point.Y - ((point.X % 2) != 0 ? 0.0f : 0.5f); | ||
|
||
return pf; | ||
} | ||
|
||
public static int HexNeighbor(int hex, int direction) | ||
{ | ||
// return col,row of a neighboring hex (0..5, starting LL and going clockwise) | ||
|
||
int c = hex / 100; | ||
int r = hex % 100; | ||
|
||
switch (direction) | ||
{ | ||
case 0: r += 1 - (c-- % 2); break; | ||
case 1: r -= (c-- % 2); break; | ||
case 2: r--; break; | ||
case 3: r -= (c++ % 2); break; | ||
case 4: r += 1 - (c++ % 2); break; | ||
case 5: r++; break; | ||
} | ||
|
||
return c * 100 + r; | ||
} | ||
public static Point HexNeighbor(Point coord, int direction) | ||
{ | ||
int c = coord.X; | ||
int r = coord.Y; | ||
|
||
// NOTE: semantics of even/odd column handing are opposite of numbered hexes since this | ||
// is Reference-centric (and reference is in an "odd number" hex 0140) | ||
switch (direction) | ||
{ | ||
case 0: r += 1 - (c-- % 2 != 0 ? 0 : 1); break; | ||
case 1: r -= (c-- % 2 != 0 ? 0 : 1); break; | ||
case 2: r--; break; | ||
case 3: r -= (c++ % 2 != 0 ? 0 : 1); break; | ||
case 4: r += 1 - (c++ % 2 != 0 ? 0 : 1); break; | ||
case 5: r++; break; | ||
} | ||
|
||
return new Point(c, r); | ||
} | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<%@ Page language="c#" Codebehind="Codes.aspx.cs" AutoEventWireup="false" Inherits="Maps.Pages.Codes" %> |
Oops, something went wrong.