-
Notifications
You must be signed in to change notification settings - Fork 2
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
kgersen@hotmail.com
committed
Mar 20, 2013
1 parent
d5e60b8
commit 4bd146b
Showing
7 changed files
with
350 additions
and
1 deletion.
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,6 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<configuration> | ||
<startup> | ||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> | ||
</startup> | ||
</configuration> |
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 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{2ACBB749-5E7C-4936-BF92-D0024C5C0D2C}</ProjectGuid> | ||
<OutputType>Exe</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>CoreDump</RootNamespace> | ||
<AssemblyName>CoreDump</AssemblyName> | ||
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<PlatformTarget>x86</PlatformTarget> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<PlatformTarget>AnyCPU</PlatformTarget> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Xml" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="ObjectDumper.cs" /> | ||
<Compile Include="Program.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<None Include="App.config" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\IGCLib\IGCLib.vcxproj"> | ||
<Project>{ede83343-470f-4718-af8e-1f1d438ea77d}</Project> | ||
<Name>IGCLib</Name> | ||
</ProjectReference> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. | ||
Other similar extension points exist, see Microsoft.Common.targets. | ||
<Target Name="BeforeBuild"> | ||
</Target> | ||
<Target Name="AfterBuild"> | ||
</Target> | ||
--> | ||
</Project> |
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,161 @@ | ||
//Copyright (C) Microsoft Corporation. All rights reserved. | ||
// kgersen = heavily modified to "flatten" and "single line"ing the output | ||
using System; | ||
using System.IO; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Reflection; | ||
using IGCLib; | ||
|
||
// See the ReadMe.html for additional information | ||
public class ObjectDumper { | ||
|
||
public static void Write(string prefix, object element) | ||
{ | ||
Write(prefix, element, Console.Out); | ||
} | ||
|
||
public static void Write(string prefix, object element, TextWriter log) | ||
{ | ||
ObjectDumper dumper = new ObjectDumper(); | ||
dumper.writer = log; | ||
dumper.WriteObject(prefix, element); | ||
} | ||
|
||
TextWriter writer; | ||
int pos; | ||
|
||
private ObjectDumper() | ||
{ | ||
} | ||
|
||
private void Write(string s) | ||
{ | ||
if (s != null) { | ||
writer.Write(s); | ||
pos += s.Length; | ||
} | ||
} | ||
|
||
private void WriteLine() | ||
{ | ||
writer.WriteLine(); | ||
pos = 0; | ||
} | ||
|
||
private void WriteTab() | ||
{ | ||
Write(" "); | ||
while (pos % 8 != 0) Write(" "); | ||
} | ||
|
||
private void WriteObject(string prefix, object element) | ||
{ | ||
if (element == null || element is ValueType || element is string || element is TechTreeBitMask) { | ||
Write(prefix); | ||
WriteValue(element); | ||
WriteLine(); | ||
} | ||
else | ||
{ | ||
IEnumerable enumerableElement = element as IEnumerable; | ||
if (enumerableElement != null) | ||
{ | ||
foreach (object item in enumerableElement) | ||
{ | ||
if (item is IEnumerable && !(item is string)) | ||
{ | ||
Write(prefix); | ||
Write("..."); | ||
WriteLine(); | ||
WriteObject(prefix, item); | ||
} | ||
else | ||
{ | ||
WriteObject(prefix, item); | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
MemberInfo[] members = element.GetType().GetMembers(BindingFlags.Public | BindingFlags.Instance); | ||
foreach (MemberInfo m in members) | ||
{ | ||
FieldInfo f = m as FieldInfo; | ||
PropertyInfo p = m as PropertyInfo; | ||
if (f != null || p != null) | ||
{ | ||
Type t = f != null ? f.FieldType : p.PropertyType; | ||
if (t.IsValueType || t == typeof(string)) | ||
{ | ||
Write(prefix); | ||
Write(m.Name); | ||
Write("="); | ||
WriteValue(f != null ? f.GetValue(element) : p.GetValue(element, null)); | ||
WriteLine(); | ||
} | ||
else | ||
{ | ||
if (typeof(IEnumerable).IsAssignableFrom(t)) | ||
{ | ||
//Write("..."); WriteLine(); | ||
} | ||
else | ||
{ | ||
//Write("{ }"); WriteLine(); | ||
} | ||
} | ||
} | ||
} | ||
foreach (MemberInfo m in members) | ||
{ | ||
FieldInfo f = m as FieldInfo; | ||
PropertyInfo p = m as PropertyInfo; | ||
if (f != null || p != null) | ||
{ | ||
Type t = f != null ? f.FieldType : p.PropertyType; | ||
if (!(t.IsValueType || t == typeof(string))) | ||
{ | ||
object value = f != null ? f.GetValue(element) : p.GetValue(element, null); | ||
if (value != null) | ||
{ | ||
WriteObject(prefix + m.Name + ": ", value); | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
private void WriteValue(object o) | ||
{ | ||
if (o == null) { | ||
Write("null"); | ||
} | ||
else if (o is DateTime) { | ||
Write(((DateTime)o).ToShortDateString()); | ||
} | ||
else if (o is ValueType || o is string) { | ||
Write(o.ToString()); | ||
} | ||
else if (o is TechTreeBitMask) | ||
{ | ||
TechTreeBitMask ttbm = (TechTreeBitMask)o; | ||
int idx = 0; | ||
foreach (bool b in ttbm.bits) | ||
{ | ||
if (b) WriteValue(" "+idx); | ||
idx++; | ||
} | ||
} | ||
else if (o is IEnumerable) | ||
{ | ||
Write("..."); | ||
} | ||
else | ||
{ | ||
Write("{ }"); | ||
} | ||
} | ||
} |
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,69 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using IGCLib; | ||
using System.Reflection; | ||
|
||
namespace CoreDump | ||
{ | ||
class Program | ||
{ | ||
static void Main(string[] args) | ||
{ | ||
if (args.Length != 1) | ||
{ | ||
Console.Out.Write("error: no argument"); | ||
return; | ||
} | ||
IGCCore core = new IGCCore(); | ||
core.Load(args[0]); | ||
|
||
//TODO: fancy print GAs attributes and other array values | ||
|
||
ObjectDumper.Write("Globals-",core.Constants); | ||
|
||
foreach (DataCivilizationIGC civ in core.m_civilizations) | ||
{ | ||
string civid = "Factions-" + civ.name + "(" + civ.civilizationID+ ")-"; | ||
ObjectDumper.Write(civid,civ); | ||
} | ||
foreach (DataDevelopmentIGC dev in core.m_developments) | ||
{ | ||
string devid = "Devels-"+dev.name+"("+dev.developmentID+")-"; | ||
ObjectDumper.Write(devid, dev); | ||
} | ||
foreach (DataDroneTypeIGC d in core.m_droneTypes) | ||
{ | ||
string did = "Drones-" + d.name + " (" + d.droneTypeID + ")-"; | ||
ObjectDumper.Write(did, d); | ||
} | ||
foreach (DataProjectileTypeIGC p in core.m_projectileTypes) | ||
{ | ||
string pid = "Projectiles-p#" + p.projectileTypeID +"-"; | ||
ObjectDumper.Write(pid, p); | ||
} | ||
foreach (DataStationTypeIGC s in core.m_stationTypes) | ||
{ | ||
string sid = "Stations-" + s.name + "(" + s.stationTypeID + ")-"; | ||
ObjectDumper.Write(sid, s); | ||
} | ||
foreach (DataHullTypeIGC h in core.m_hullTypes) | ||
{ | ||
string hid = "Ships-" + h.name + "(" + h.hullID + ")-"; | ||
ObjectDumper.Write(hid, h); | ||
} | ||
foreach (DataPartTypeIGC p in core.m_partTypes) | ||
{ | ||
string pid = "Parts-" + p.name + "(" + p.partID + ")-"; | ||
ObjectDumper.Write(pid, p); | ||
} | ||
foreach (DataTreasureSetIGC t in core.m_treasureSets) | ||
{ | ||
string tid = "Treasures-" + t.name + "(" + t.treasureSetID + ")-"; | ||
ObjectDumper.Write(tid, t); | ||
} | ||
} | ||
} | ||
} |
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,36 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// 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("CoreDump")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("")] | ||
[assembly: AssemblyProduct("CoreDump")] | ||
[assembly: AssemblyCopyright("Copyright © 2013")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// Setting ComVisible to false makes the types in this assembly not visible | ||
// to COM components. If you need to access a type in this assembly from | ||
// COM, set the ComVisible attribute to true on that type. | ||
[assembly: ComVisible(false)] | ||
|
||
// The following GUID is for the ID of the typelib if this project is exposed to COM | ||
[assembly: Guid("cd9072f4-c358-48a3-913a-0559a0bfe43f")] | ||
|
||
// 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 Build and Revision Numbers | ||
// by using the '*' as shown below: | ||
// [assembly: AssemblyVersion("1.0.*")] | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |
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
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