From eb4b3404aa00220d659e532151dab13d642c17a3 Mon Sep 17 00:00:00 2001 From: Svxy Date: Wed, 31 May 2023 17:31:32 -0400 Subject: Released --- tools/SectorTable/Release/SectorTable.exe | Bin 0 -> 53248 bytes tools/SectorTable/SectorTable.cpp | 121 ++++++++++++++++++++++++++ tools/SectorTable/SectorTable.sln | 51 +++++++++++ tools/SectorTable/SectorTable.vcproj | 137 ++++++++++++++++++++++++++++++ tools/SectorTable/stdafx.cpp | 8 ++ tools/SectorTable/stdafx.h | 12 +++ 6 files changed, 329 insertions(+) create mode 100644 tools/SectorTable/Release/SectorTable.exe create mode 100644 tools/SectorTable/SectorTable.cpp create mode 100644 tools/SectorTable/SectorTable.sln create mode 100644 tools/SectorTable/SectorTable.vcproj create mode 100644 tools/SectorTable/stdafx.cpp create mode 100644 tools/SectorTable/stdafx.h (limited to 'tools/SectorTable') diff --git a/tools/SectorTable/Release/SectorTable.exe b/tools/SectorTable/Release/SectorTable.exe new file mode 100644 index 0000000..bedcb51 Binary files /dev/null and b/tools/SectorTable/Release/SectorTable.exe differ diff --git a/tools/SectorTable/SectorTable.cpp b/tools/SectorTable/SectorTable.cpp new file mode 100644 index 0000000..41cd895 --- /dev/null +++ b/tools/SectorTable/SectorTable.cpp @@ -0,0 +1,121 @@ +// SectorTable.cpp : Defines the entry point for the console application. +// + +#include "stdafx.h" +#include + +int _tmain(int argc, _TCHAR* argv[]) +{ + const int NameCount = 75; + char* sectorNames[ NameCount ] = { + "l1r1.p3d", "l1r2.p3d", "l1r3.p3d", "l1r4a.p3d", "l1r4b.p3d", "l1r6.p3d", "l1r7.p3d", + "l1z1.p3d", "l1z2.p3d", "l1z3.p3d", "l1z4.p3d", "l1z6.p3d", "l1z7.p3d", + "l2r1.p3d", "l2r2.p3d", "l2r3.p3d", "l2r4.p3d", + "l2z1.p3d", "l2z2.p3d", "l2z3.p3d", "l2z4.p3d", + "l3r1.p3d", "l3r2.p3d", "l3r3.p3d", "l3r4.p3d", "l3r5.p3d", + "l3z1.p3d", "l3z2.p3d", "l3z3.p3d", "l3z4.p3d", "l3z5.p3d", + "l4r1.p3d", "l4r2.p3d", "l4r3.p3d", "l4r4a.p3d", "l4r4b.p3d", "l4r6.p3d", "l4r7.p3d", + "l4z1.p3d", "l4z2.p3d", "l4z3.p3d", "l4z4.p3d", "l4z6.p3d", "l4z7.p3d", + "l5r1.p3d", "l5r2.p3d", "l5r3.p3d", "l5r4.p3d", + "l5z1.p3d", "l5z2.p3d", "l5z3.p3d", "l5z4.p3d", + "l6r1.p3d", "l6r2.p3d", "l6r3.p3d", "l6r4.p3d", "l6r5.p3d", + "l6z1.p3d", "l6z2.p3d", "l6z3.p3d", "l6z4.p3d", "l6z5.p3d", + "l7r1.p3d", "l7r2.p3d", "l7r3.p3d", "l7r4a.p3d", "l7r4b.p3d", "l7r6.p3d", "l7r7.p3d", + "l7z1.p3d", "l7z2.p3d", "l7z3.p3d", "l7z4.p3d", "l7z6.p3d", "l7z7.p3d" }; + + char* typeStr[ 4 ] = { "unsigned char", "unsigned short", "int", "TLUID" }; + TLUID sectorIDs[ NameCount ]; + for( int i = 0; i < NameCount; ++i ) + { + sectorIDs[ i ] = tlEntity::MakeUID( sectorNames[ i ] ); + } + + // Check for dups in the lower order bits. + bool noDups = true; + int type = 0; + int mask = 0xFF; + for( int i = 0; ( i < NameCount - 1 ) && ( noDups ); ++i ) + { + char first = (char)( sectorIDs[ i ] & mask ); + for( int j = i + 1; j < NameCount; ++j ) + { + char second = (char)( sectorIDs[ j ] & mask ); + if( first == second ) + { + noDups = false; + break; + } + } + } + if( !noDups ) + { + ++type; + noDups = true; + mask = 0xFFFF; + for( int i = 0; ( i < NameCount - 1 ) && ( noDups ); ++i ) + { + short first = (short)( sectorIDs[ i ] & mask ); + for( int j = i + 1; j < NameCount; ++j ) + { + short second = (short)( sectorIDs[ j ] & mask ); + if( first == second ) + { + noDups = false; + break; + } + } + } + } + if( !noDups ) + { + ++type; + noDups = true; + mask = 0xFFFFFFFF; + for( int i = 0; ( i < NameCount - 1 ) && ( noDups ); ++i ) + { + int first = (int)( sectorIDs[ i ] & mask ); + for( int j = i + 1; j < NameCount; ++j ) + { + int second = (int)( sectorIDs[ j ] & mask ); + if( first == second ) + { + noDups = false; + break; + } + } + } + } + if( !noDups ) + { + ++type; + } + + printf( "// Auto generated with SectorTable.\n" ); + printf( "struct SectorMap\n{\n %s Sector;\n char CurIndex;\n};\n\n", typeStr[ type ] ); + printf( "static const int NUM_SECTORS = %d;\n\n", NameCount ); + printf( "SectorMap sSectorMap[ NUM_SECTORS ] = {\n" ); + for( int i = 0; i < NameCount; ++i ) + { + TLUID id = tlEntity::MakeUID( sectorNames[ i ] ); + unsigned hi = (unsigned)( id >> 32 ); + unsigned lo = (unsigned)( id & 0xFFFFFFFF ); + printf( "{ 0x" ); + switch( type ) + { + case 0: + printf("%02X", lo & 0xFF ); + break; + case 1: + printf("%04X", lo & 0xFFFF ); + break; + case 2: + printf("%08X", lo ); + break; + default: + printf( "%08X%08X", hi, lo ); + break; + } + printf( ", 0 }%s //%s\n", i != NameCount -1 ? ", " : " };", sectorNames[ i ] ); + } + return 0; +} \ No newline at end of file diff --git a/tools/SectorTable/SectorTable.sln b/tools/SectorTable/SectorTable.sln new file mode 100644 index 0000000..c40d4c8 --- /dev/null +++ b/tools/SectorTable/SectorTable.sln @@ -0,0 +1,51 @@ +Microsoft Visual Studio Solution File, Format Version 7.00 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "toollib", "..\..\game\libs\pure3d\toollib\toollib.vcproj", "{A224C960-67EC-49C2-8171-9FA441C7634D}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SectorTable", "SectorTable.vcproj", "{B316572B-39EC-4EB1-B40D-E62D1B033F52}" +EndProject +Global + GlobalSection(SourceCodeControl) = preSolution + SccNumberOfProjects = 1 + SccProjectUniqueName0 = ..\\..\\game\\libs\\pure3d\\toollib\\toollib.vcproj + SccProjectName0 = Perforce\u0020Project + SccLocalPath0 = ..\\..\\game\\libs\\pure3d\\toollib + SccProvider0 = MSSCCI:Perforce\u0020SCM + CanCheckoutShared = true + EndGlobalSection + GlobalSection(SolutionConfiguration) = preSolution + ConfigName.0 = Debug + ConfigName.1 = Release + ConfigName.2 = Tools Debug + ConfigName.3 = Tools Release + ConfigName.4 = Tune + EndGlobalSection + GlobalSection(ProjectDependencies) = postSolution + {B316572B-39EC-4EB1-B40D-E62D1B033F52}.0 = {A224C960-67EC-49C2-8171-9FA441C7634D} + EndGlobalSection + GlobalSection(ProjectConfiguration) = postSolution + {A224C960-67EC-49C2-8171-9FA441C7634D}.Debug.ActiveCfg = Debug|Win32 + {A224C960-67EC-49C2-8171-9FA441C7634D}.Debug.Build.0 = Debug|Win32 + {A224C960-67EC-49C2-8171-9FA441C7634D}.Release.ActiveCfg = Release|Win32 + {A224C960-67EC-49C2-8171-9FA441C7634D}.Release.Build.0 = Release|Win32 + {A224C960-67EC-49C2-8171-9FA441C7634D}.Tools Debug.ActiveCfg = Tools Debug|Win32 + {A224C960-67EC-49C2-8171-9FA441C7634D}.Tools Debug.Build.0 = Tools Debug|Win32 + {A224C960-67EC-49C2-8171-9FA441C7634D}.Tools Release.ActiveCfg = Tools Release|Win32 + {A224C960-67EC-49C2-8171-9FA441C7634D}.Tools Release.Build.0 = Tools Release|Win32 + {A224C960-67EC-49C2-8171-9FA441C7634D}.Tune.ActiveCfg = Tools Release|Win32 + {A224C960-67EC-49C2-8171-9FA441C7634D}.Tune.Build.0 = Tools Release|Win32 + {B316572B-39EC-4EB1-B40D-E62D1B033F52}.Debug.ActiveCfg = Debug|Win32 + {B316572B-39EC-4EB1-B40D-E62D1B033F52}.Debug.Build.0 = Debug|Win32 + {B316572B-39EC-4EB1-B40D-E62D1B033F52}.Release.ActiveCfg = Release|Win32 + {B316572B-39EC-4EB1-B40D-E62D1B033F52}.Release.Build.0 = Release|Win32 + {B316572B-39EC-4EB1-B40D-E62D1B033F52}.Tools Debug.ActiveCfg = Debug|Win32 + {B316572B-39EC-4EB1-B40D-E62D1B033F52}.Tools Debug.Build.0 = Debug|Win32 + {B316572B-39EC-4EB1-B40D-E62D1B033F52}.Tools Release.ActiveCfg = Release|Win32 + {B316572B-39EC-4EB1-B40D-E62D1B033F52}.Tools Release.Build.0 = Release|Win32 + {B316572B-39EC-4EB1-B40D-E62D1B033F52}.Tune.ActiveCfg = Release|Win32 + {B316572B-39EC-4EB1-B40D-E62D1B033F52}.Tune.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + EndGlobalSection + GlobalSection(ExtensibilityAddIns) = postSolution + EndGlobalSection +EndGlobal diff --git a/tools/SectorTable/SectorTable.vcproj b/tools/SectorTable/SectorTable.vcproj new file mode 100644 index 0000000..be79730 --- /dev/null +++ b/tools/SectorTable/SectorTable.vcproj @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tools/SectorTable/stdafx.cpp b/tools/SectorTable/stdafx.cpp new file mode 100644 index 0000000..0366889 --- /dev/null +++ b/tools/SectorTable/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// SectorTable.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/tools/SectorTable/stdafx.h b/tools/SectorTable/stdafx.h new file mode 100644 index 0000000..ea18047 --- /dev/null +++ b/tools/SectorTable/stdafx.h @@ -0,0 +1,12 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + +#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers +#include +#include + +// TODO: reference additional headers your program requires here -- cgit v1.2.3