-
Notifications
You must be signed in to change notification settings - Fork 29
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
Showing
52 changed files
with
18,225 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,12 @@ | ||
{ | ||
"version": 1, | ||
"isRoot": true, | ||
"tools": { | ||
"dotnet-ef": { | ||
"version": "7.0.0", | ||
"commands": [ | ||
"dotnet-ef" | ||
] | ||
} | ||
} | ||
} |
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 |
---|---|---|
|
@@ -396,3 +396,6 @@ FodyWeavers.xsd | |
|
||
# JetBrains Rider | ||
*.sln.iml | ||
|
||
# Listfile | ||
listfile.csv |
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,9 @@ | ||
[submodule "CascLib"] | ||
path = CascLib | ||
url = https://github.com/WoW-Tools/CascLib | ||
[submodule "DBCD"] | ||
path = DBCD | ||
url = https://github.com/wowdev/DBCD | ||
[submodule "WoWDBDefs"] | ||
path = WoWDBDefs | ||
url = https://github.com/wowdev/WoWDBDefs |
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,31 @@ | ||
using Microsoft.AspNetCore.Mvc; | ||
using wow.tools.local.Services; | ||
|
||
namespace wow.tools.local.Controllers | ||
{ | ||
[Route("casc/")] | ||
[ApiController] | ||
public class CASCController : Controller | ||
{ | ||
[Route("fdid")] | ||
[HttpGet] | ||
public FileStreamResult File(uint fileDataID) | ||
{ | ||
return new FileStreamResult(CASC.GetFileByID(fileDataID), "application/octet-stream") | ||
{ | ||
FileDownloadName = fileDataID.ToString() | ||
}; | ||
} | ||
|
||
[Route("buildname")] | ||
[HttpGet] | ||
public string BuildName() | ||
{ | ||
// WOW-46801patch10.0.2_PTR | ||
var splitName= CASC.BuildName.Replace("WOW-", "").Split("patch"); | ||
var buildName = splitName[1].Split("_")[0] + "." + splitName[0]; | ||
Console.WriteLine("Set modelviewer build name as " + buildName); | ||
return buildName; | ||
} | ||
} | ||
} |
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,138 @@ | ||
using DBCD; | ||
using wow.tools.local.Services; | ||
using Microsoft.AspNetCore.Mvc; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
|
||
namespace wow.tools.local.Controllers | ||
{ | ||
[Route("dbc/find")] | ||
[ApiController] | ||
public class DBCFindController : ControllerBase | ||
{ | ||
private readonly DBCManager dbcManager; | ||
|
||
public DBCFindController(IDBCManager dbcManager) => this.dbcManager = (DBCManager)dbcManager; | ||
|
||
// GET: find/ | ||
[HttpGet] | ||
public string Get() | ||
{ | ||
return "No DBC selected!"; | ||
} | ||
|
||
// GET: find/name | ||
[HttpGet("{name}")] | ||
public async Task<List<Dictionary<string, string>>> Get(string name, string build, string col, int val, bool useHotfixes = false, bool calcOffset = true) | ||
{ | ||
Console.WriteLine("Finding results for " + name + "::" + col + " (" + build + ", hotfixes: " + useHotfixes + ") value " + val); | ||
|
||
var storage = await dbcManager.GetOrLoad(name, build, useHotfixes); | ||
|
||
var result = new List<Dictionary<string, string>>(); | ||
|
||
if (!storage.Values.Any()) | ||
{ | ||
return result; | ||
} | ||
|
||
if (!calcOffset && col == "ID") | ||
{ | ||
if (storage.TryGetValue(val, out DBCDRow row)) | ||
{ | ||
for (var i = 0; i < storage.AvailableColumns.Length; ++i) | ||
{ | ||
string fieldName = storage.AvailableColumns[i]; | ||
|
||
if (fieldName != col) | ||
continue; | ||
|
||
var field = row[fieldName]; | ||
|
||
// Don't think FKs to arrays are possible, so only check regular value | ||
if (field.ToString() == val.ToString()) | ||
{ | ||
var newDict = new Dictionary<string, string>(); | ||
for (var j = 0; j < storage.AvailableColumns.Length; ++j) | ||
{ | ||
string subfieldName = storage.AvailableColumns[j]; | ||
var subfield = row[subfieldName]; | ||
|
||
if (subfield is Array a) | ||
{ | ||
for (var k = 0; k < a.Length; k++) | ||
{ | ||
newDict.Add(subfieldName + "[" + k + "]", a.GetValue(k).ToString()); | ||
} | ||
} | ||
else | ||
{ | ||
newDict.Add(subfieldName, subfield.ToString()); | ||
} | ||
} | ||
|
||
result.Add(newDict); | ||
} | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
var arrIndex = 0; | ||
|
||
if (col.Contains("[")) | ||
{ | ||
arrIndex = int.Parse(col.Split("[")[1].Replace("]", string.Empty)); | ||
col = col.Split("[")[0]; | ||
} | ||
|
||
foreach (DBCDRow row in storage.Values) | ||
{ | ||
for (var i = 0; i < storage.AvailableColumns.Length; ++i) | ||
{ | ||
string fieldName = storage.AvailableColumns[i]; | ||
|
||
if (fieldName != col) | ||
continue; | ||
|
||
var field = row[fieldName]; | ||
|
||
if (field is Array arrayField) | ||
{ | ||
field = arrayField.GetValue(arrIndex).ToString(); | ||
} | ||
|
||
// Don't think FKs to arrays are possible, so only check regular value | ||
if (field.ToString() == val.ToString()) | ||
{ | ||
var newDict = new Dictionary<string, string>(); | ||
for (var j = 0; j < storage.AvailableColumns.Length; ++j) | ||
{ | ||
string subfieldName = storage.AvailableColumns[j]; | ||
var subfield = row[subfieldName]; | ||
|
||
if (subfield is Array a) | ||
{ | ||
for (var k = 0; k < a.Length; k++) | ||
{ | ||
newDict.Add(subfieldName + "[" + k + "]", a.GetValue(k).ToString()); | ||
} | ||
} | ||
else | ||
{ | ||
newDict.Add(subfieldName, subfield.ToString()); | ||
} | ||
} | ||
|
||
result.Add(newDict); | ||
} | ||
} | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
} | ||
} |
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,145 @@ | ||
using DBCD; | ||
using wow.tools.local.Services; | ||
using Microsoft.AspNetCore.Mvc; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Threading.Tasks; | ||
using CASCLib; | ||
|
||
namespace wow.tools.local.Controllers | ||
{ | ||
[Route("dbc/peek")] | ||
[ApiController] | ||
public class DBCPeekController : ControllerBase | ||
{ | ||
private readonly DBCManager dbcManager; | ||
|
||
public DBCPeekController(IDBCManager dbcManager) | ||
{ | ||
this.dbcManager = dbcManager as DBCManager; | ||
} | ||
|
||
public class PeekResult | ||
{ | ||
public Dictionary<string, string> values { get; set; } | ||
public int offset { get; set; } | ||
} | ||
|
||
// GET: peek/ | ||
[HttpGet] | ||
public string Get() | ||
{ | ||
return "No DBC selected!"; | ||
} | ||
|
||
// GET: peek/name | ||
[HttpGet("{name}")] | ||
public async Task<PeekResult> Get(string name, string build, string col, int val, bool useHotfixes = false, string pushIDs = "") | ||
{ | ||
Console.WriteLine("Serving peek row for " + name + "::" + col + " (" + build + ", hotfixes: " + useHotfixes + ") value " + val); | ||
|
||
List<int> pushIDList = null; | ||
|
||
if (useHotfixes && pushIDs != "") | ||
{ | ||
pushIDList = new List<int>(); | ||
|
||
var pushIDsExploded = pushIDs.Split(','); | ||
|
||
if (pushIDsExploded.Length > 0) | ||
{ | ||
foreach (var pushID in pushIDs.Split(',')) | ||
{ | ||
if (int.TryParse(pushID, out int pushIDInt)) | ||
{ | ||
pushIDList.Add(pushIDInt); | ||
} | ||
} | ||
} | ||
} | ||
|
||
var storage = await dbcManager.GetOrLoad(name, build, useHotfixes, LocaleFlags.All_WoW, pushIDList); | ||
|
||
var result = new PeekResult { values = new Dictionary<string, string>() }; | ||
|
||
if (!storage.Values.Any()) | ||
{ | ||
return result; | ||
} | ||
|
||
if (col == "ID" && storage.TryGetValue(val, out var rowByIndex)) | ||
{ | ||
foreach (var fieldName in storage.AvailableColumns) | ||
{ | ||
if (fieldName != col) | ||
continue; | ||
|
||
var field = rowByIndex[fieldName]; | ||
|
||
// Don't think FKs to arrays are possible, so only check regular value | ||
if (field.ToString() != val.ToString()) continue; | ||
|
||
foreach (var subfieldName in storage.AvailableColumns) | ||
{ | ||
var subfield = rowByIndex[subfieldName]; | ||
|
||
if (subfield is Array a) | ||
{ | ||
for (var k = 0; k < a.Length; k++) | ||
{ | ||
result.values.Add(subfieldName + "[" + k + "]", a.GetValue(k).ToString()); | ||
} | ||
} | ||
else | ||
{ | ||
result.values.Add(subfieldName, subfield.ToString()); | ||
} | ||
} | ||
} | ||
} | ||
else | ||
{ | ||
var recordFound = false; | ||
|
||
foreach (var row in storage.Values) | ||
{ | ||
if (recordFound) | ||
continue; | ||
|
||
foreach (var fieldName in storage.AvailableColumns) | ||
{ | ||
if (fieldName != col) | ||
continue; | ||
|
||
var field = row[fieldName]; | ||
|
||
// Don't think FKs to arrays are possible, so only check regular value | ||
if (field.ToString() != val.ToString()) continue; | ||
|
||
foreach (var subfieldName in storage.AvailableColumns) | ||
{ | ||
var subfield = row[subfieldName]; | ||
|
||
if (subfield is Array a) | ||
{ | ||
for (var k = 0; k < a.Length; k++) | ||
{ | ||
result.values.Add(subfieldName + "[" + k + "]", a.GetValue(k).ToString()); | ||
} | ||
} | ||
else | ||
{ | ||
result.values.Add(subfieldName, subfield.ToString()); | ||
} | ||
} | ||
|
||
recordFound = true; | ||
} | ||
} | ||
} | ||
|
||
return result; | ||
} | ||
} | ||
} |
Oops, something went wrong.