Use an inteligenter method of setting the gem shapes.

develop
Japa Mala Illo 2018-01-08 09:58:37 +05:30
parent 29426111f7
commit 724fb00b73
2 changed files with 203 additions and 5 deletions

@ -275,7 +275,6 @@ message Item
optional float velocity_x = 13; optional float velocity_x = 13;
optional float velocity_y = 14; optional float velocity_y = 14;
optional float velocity_z = 15; optional float velocity_z = 15;
optional int32 shape = 16;
} }
message MapBlock message MapBlock

@ -920,7 +920,84 @@ static command_result GetItemList(color_ostream &stream, const EmptyMessage *in,
mat_def->mutable_mat_pair()->set_mat_type((int)it); mat_def->mutable_mat_pair()->set_mat_type((int)it);
mat_def->mutable_mat_pair()->set_mat_index(-1); mat_def->mutable_mat_pair()->set_mat_index(-1);
mat_def->set_id(ENUM_KEY_STR(item_type, it)); mat_def->set_id(ENUM_KEY_STR(item_type, it));
if (it == item_type::BOX) switch (it)
{
case df::enums::item_type::NONE:
break;
case df::enums::item_type::BAR:
break;
case df::enums::item_type::GEM:
case df::enums::item_type::SMALLGEM:
{
for (int i = 0; i < world->raws.language.shapes.size(); i++)
{
auto shape = world->raws.language.shapes[i];
if (shape->gems_use.whole == 0)
continue;
mat_def = out->add_material_list();
mat_def->mutable_mat_pair()->set_mat_type((int)it);
mat_def->mutable_mat_pair()->set_mat_index(i);
mat_def->set_id(ENUM_KEY_STR(item_type, it) + "/" + shape->id);
}
break;
}
case df::enums::item_type::BLOCKS:
break;
case df::enums::item_type::ROUGH:
break;
case df::enums::item_type::BOULDER:
break;
case df::enums::item_type::WOOD:
break;
case df::enums::item_type::DOOR:
break;
case df::enums::item_type::FLOODGATE:
break;
case df::enums::item_type::BED:
break;
case df::enums::item_type::CHAIR:
break;
case df::enums::item_type::CHAIN:
break;
case df::enums::item_type::FLASK:
break;
case df::enums::item_type::GOBLET:
break;
case df::enums::item_type::INSTRUMENT:
break;
case df::enums::item_type::TOY:
break;
case df::enums::item_type::WINDOW:
break;
case df::enums::item_type::CAGE:
break;
case df::enums::item_type::BARREL:
break;
case df::enums::item_type::BUCKET:
break;
case df::enums::item_type::ANIMALTRAP:
break;
case df::enums::item_type::TABLE:
break;
case df::enums::item_type::COFFIN:
break;
case df::enums::item_type::STATUE:
break;
case df::enums::item_type::CORPSE:
break;
case df::enums::item_type::WEAPON:
break;
case df::enums::item_type::ARMOR:
break;
case df::enums::item_type::SHOES:
break;
case df::enums::item_type::SHIELD:
break;
case df::enums::item_type::HELM:
break;
case df::enums::item_type::GLOVES:
break;
case df::enums::item_type::BOX:
{ {
mat_def = out->add_material_list(); mat_def = out->add_material_list();
mat_def->mutable_mat_pair()->set_mat_type((int)it); mat_def->mutable_mat_pair()->set_mat_type((int)it);
@ -930,6 +1007,128 @@ static command_result GetItemList(color_ostream &stream, const EmptyMessage *in,
mat_def->mutable_mat_pair()->set_mat_type((int)it); mat_def->mutable_mat_pair()->set_mat_type((int)it);
mat_def->mutable_mat_pair()->set_mat_index(1); mat_def->mutable_mat_pair()->set_mat_index(1);
mat_def->set_id("BOX_BAG"); mat_def->set_id("BOX_BAG");
break;
}
case df::enums::item_type::BIN:
break;
case df::enums::item_type::ARMORSTAND:
break;
case df::enums::item_type::WEAPONRACK:
break;
case df::enums::item_type::CABINET:
break;
case df::enums::item_type::FIGURINE:
break;
case df::enums::item_type::AMULET:
break;
case df::enums::item_type::SCEPTER:
break;
case df::enums::item_type::AMMO:
break;
case df::enums::item_type::CROWN:
break;
case df::enums::item_type::RING:
break;
case df::enums::item_type::EARRING:
break;
case df::enums::item_type::BRACELET:
break;
case df::enums::item_type::ANVIL:
break;
case df::enums::item_type::CORPSEPIECE:
break;
case df::enums::item_type::REMAINS:
break;
case df::enums::item_type::MEAT:
break;
case df::enums::item_type::FISH:
break;
case df::enums::item_type::FISH_RAW:
break;
case df::enums::item_type::VERMIN:
break;
case df::enums::item_type::PET:
break;
case df::enums::item_type::SEEDS:
break;
case df::enums::item_type::PLANT:
break;
case df::enums::item_type::SKIN_TANNED:
break;
case df::enums::item_type::PLANT_GROWTH:
break;
case df::enums::item_type::THREAD:
break;
case df::enums::item_type::CLOTH:
break;
case df::enums::item_type::TOTEM:
break;
case df::enums::item_type::PANTS:
break;
case df::enums::item_type::BACKPACK:
break;
case df::enums::item_type::QUIVER:
break;
case df::enums::item_type::CATAPULTPARTS:
break;
case df::enums::item_type::BALLISTAPARTS:
break;
case df::enums::item_type::SIEGEAMMO:
break;
case df::enums::item_type::BALLISTAARROWHEAD:
break;
case df::enums::item_type::TRAPPARTS:
break;
case df::enums::item_type::TRAPCOMP:
break;
case df::enums::item_type::DRINK:
break;
case df::enums::item_type::POWDER_MISC:
break;
case df::enums::item_type::CHEESE:
break;
case df::enums::item_type::FOOD:
break;
case df::enums::item_type::LIQUID_MISC:
break;
case df::enums::item_type::COIN:
break;
case df::enums::item_type::GLOB:
break;
case df::enums::item_type::ROCK:
break;
case df::enums::item_type::PIPE_SECTION:
break;
case df::enums::item_type::HATCH_COVER:
break;
case df::enums::item_type::GRATE:
break;
case df::enums::item_type::QUERN:
break;
case df::enums::item_type::MILLSTONE:
break;
case df::enums::item_type::SPLINT:
break;
case df::enums::item_type::CRUTCH:
break;
case df::enums::item_type::TRACTION_BENCH:
break;
case df::enums::item_type::ORTHOPEDIC_CAST:
break;
case df::enums::item_type::TOOL:
break;
case df::enums::item_type::SLAB:
break;
case df::enums::item_type::EGG:
break;
case df::enums::item_type::BOOK:
break;
case df::enums::item_type::SHEET:
break;
case df::enums::item_type::BRANCH:
break;
default:
break;
} }
int subtypes = Items::getSubtypeCount(it); int subtypes = Items::getSubtypeCount(it);
if (subtypes >= 0) if (subtypes >= 0)
@ -940,7 +1139,7 @@ static command_result GetItemList(color_ostream &stream, const EmptyMessage *in,
mat_def->mutable_mat_pair()->set_mat_type((int)it); mat_def->mutable_mat_pair()->set_mat_type((int)it);
mat_def->mutable_mat_pair()->set_mat_index(i); mat_def->mutable_mat_pair()->set_mat_index(i);
df::itemdef * item = Items::getSubtypeDef(it, i); df::itemdef * item = Items::getSubtypeDef(it, i);
mat_def->set_id(item->id); mat_def->set_id(ENUM_KEY_STR(item_type, it) + "/" + item->id);
} }
} }
} }
@ -1429,12 +1628,12 @@ void CopyItem(RemoteFortressReader::Item * NetItem, df::item * DfItem)
VIRTUAL_CAST_VAR(gem_item, df::item_gemst, DfItem); VIRTUAL_CAST_VAR(gem_item, df::item_gemst, DfItem);
if (gem_item) if (gem_item)
{ {
NetItem->set_shape(gem_item->shape); type->set_mat_index(gem_item->shape);
} }
VIRTUAL_CAST_VAR(smallgem_item, df::item_smallgemst, DfItem); VIRTUAL_CAST_VAR(smallgem_item, df::item_smallgemst, DfItem);
if (smallgem_item) if (smallgem_item)
{ {
NetItem->set_shape(smallgem_item->shape); type->set_mat_index(smallgem_item->shape);
} }
VIRTUAL_CAST_VAR(constructed_item, df::item_constructed, DfItem); VIRTUAL_CAST_VAR(constructed_item, df::item_constructed, DfItem);
if (constructed_item) if (constructed_item)