find a workaround to have size of some blocks and items

This commit is contained in:
Beu 2023-11-04 11:25:33 +01:00
parent 88221039bb
commit 14e21b2e4b

View File

@ -32,15 +32,18 @@ void RefreshBlocks() {
auto pluginmaptype = cast<CGameEditorPluginMapMapType>(cast<CGameCtnEditorFree>(GetApp().Editor).PluginMapType); auto pluginmaptype = cast<CGameEditorPluginMapMapType>(cast<CGameCtnEditorFree>(GetApp().Editor).PluginMapType);
for(uint i = 0; i < blocks.Length; i++) { for(uint i = 0; i < blocks.Length; i++) {
int idifexist = -1; string blockname = blocks[i].BlockModel.IdName;
string blockname; int fallbacksize = 0;
bool isofficial = true; bool isofficial = true;
blockname = blocks[i].BlockModel.IdName;
if (blockname.ToLower().SubStr(blockname.Length - 22, 22) == ".block.gbx_customblock") { if (blockname.ToLower().SubStr(blockname.Length - 22, 22) == ".block.gbx_customblock") {
isofficial = false; isofficial = false;
blockname = blockname.SubStr(0, blockname.Length - 12); blockname = blockname.SubStr(0, blockname.Length - 12);
auto article = cast<CGameCtnArticle>(blocks[i].BlockInfo.ArticlePtr);
fallbacksize = article.BlockItem_ItemModelArticle.CollectorFid.ByteSize;
} }
if (include_default_objects || blockname.ToLower().SubStr(blockname.Length - 10, 10) == ".block.gbx") { if (include_default_objects || blockname.ToLower().SubStr(blockname.Length - 10, 10) == ".block.gbx") {
vec3 pos; vec3 pos;
if (blocks[i].CoordX != 4294967295 && blocks[i].CoordZ != 4294967295) { // Not placed in free mapping if (blocks[i].CoordX != 4294967295 && blocks[i].CoordZ != 4294967295) { // Not placed in free mapping
@ -67,7 +70,7 @@ void RefreshBlocks() {
objects[index].positions.InsertLast(pos); objects[index].positions.InsertLast(pos);
} else { } else {
int trigger = blocks[i].BlockModel.EdWaypointType; int trigger = blocks[i].BlockModel.EdWaypointType;
AddNewObject(blockname, trigger, "Block", pos, 0, isofficial); AddNewObject(blockname, trigger, "Block", pos, fallbacksize, isofficial);
objectsindex.InsertLast(blockname); objectsindex.InsertLast(blockname);
} }
} }
@ -84,7 +87,6 @@ void RefreshItems() {
// Items // Items
auto items = map.AnchoredObjects; auto items = map.AnchoredObjects;
for(uint i = 0; i < items.Length; i++) { for(uint i = 0; i < items.Length; i++) {
int idifexist = -1;
string itemname = items[i].ItemModel.IdName; string itemname = items[i].ItemModel.IdName;
int fallbacksize = 0; int fallbacksize = 0;
bool isofficial = true; bool isofficial = true;
@ -94,11 +96,10 @@ void RefreshItems() {
auto article = cast<CGameCtnArticle>(items[i].ItemModel.ArticlePtr); auto article = cast<CGameCtnArticle>(items[i].ItemModel.ArticlePtr);
if (article !is null) { if (article !is null) {
itemname = string(article.PageName) + string(article.Name) + ".Item.Gbx"; itemname = string(article.PageName) + string(article.Name) + ".Item.Gbx";
} else { }
auto fid = cast<CSystemFidFile@>(GetFidFromNod(items[i].ItemModel)); auto fid = cast<CSystemFidFile@>(GetFidFromNod(items[i].ItemModel));
fallbacksize = fid.ByteSize; fallbacksize = fid.ByteSize;
} }
}
if (include_default_objects || itemname.ToLower().SubStr(itemname.Length - 9, 9) == ".item.gbx") { if (include_default_objects || itemname.ToLower().SubStr(itemname.Length - 9, 9) == ".item.gbx") {
int index = objectsindex.Find(itemname); int index = objectsindex.Find(itemname);