Skip to content

Commit

Permalink
- addced: coredump project
Browse files Browse the repository at this point in the history
  • Loading branch information
kgersen@hotmail.com committed Mar 20, 2013
1 parent d5e60b8 commit 4bd146b
Show file tree
Hide file tree
Showing 7 changed files with 350 additions and 1 deletion.
6 changes: 6 additions & 0 deletions ICE/CoreDump/App.config
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>
65 changes: 65 additions & 0 deletions ICE/CoreDump/CoreDump.csproj
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>
161 changes: 161 additions & 0 deletions ICE/CoreDump/ObjectDumper.cs
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("{ }");
}
}
}
69 changes: 69 additions & 0 deletions ICE/CoreDump/Program.cs
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);
}
}
}
}
36 changes: 36 additions & 0 deletions ICE/CoreDump/Properties/AssemblyInfo.cs
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")]
12 changes: 12 additions & 0 deletions ICE/ICE.sln
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICE3", "ICE3\ICE3.csproj",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICECube", "ICECube\ICECube.csproj", "{9C76CAAC-82F8-460C-B072-44987D8E28F7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CoreDump", "CoreDump\CoreDump.csproj", "{2ACBB749-5E7C-4936-BF92-D0024C5C0D2C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -58,6 +60,16 @@ Global
{9C76CAAC-82F8-460C-B072-44987D8E28F7}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{9C76CAAC-82F8-460C-B072-44987D8E28F7}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{9C76CAAC-82F8-460C-B072-44987D8E28F7}.Release|Win32.ActiveCfg = Release|Any CPU
{2ACBB749-5E7C-4936-BF92-D0024C5C0D2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2ACBB749-5E7C-4936-BF92-D0024C5C0D2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2ACBB749-5E7C-4936-BF92-D0024C5C0D2C}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
{2ACBB749-5E7C-4936-BF92-D0024C5C0D2C}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
{2ACBB749-5E7C-4936-BF92-D0024C5C0D2C}.Debug|Win32.ActiveCfg = Debug|Any CPU
{2ACBB749-5E7C-4936-BF92-D0024C5C0D2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2ACBB749-5E7C-4936-BF92-D0024C5C0D2C}.Release|Any CPU.Build.0 = Release|Any CPU
{2ACBB749-5E7C-4936-BF92-D0024C5C0D2C}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
{2ACBB749-5E7C-4936-BF92-D0024C5C0D2C}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{2ACBB749-5E7C-4936-BF92-D0024C5C0D2C}.Release|Win32.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
2 changes: 1 addition & 1 deletion ICE/ICE3/Window1.xaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Window x:Class="ICE3.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="ICE 3" Height="315.423" Width="448">
Title="ICE 3" Height="426.281" Width="637.27">
<Window.Resources>
<DataTemplate x:Key="civFormating" DataType="DataCivilizationIGC">
<StackPanel Orientation="Horizontal">
Expand Down

0 comments on commit 4bd146b

Please sign in to comment.