Started work on procgen
This commit is contained in:
@@ -521,13 +521,36 @@ void StreamWorld::run_command(const String &command, const Array &args)
|
||||
print_line("changed building: " + itos(id) +
|
||||
" from: " + old_type + " to: " + new_type);
|
||||
} else if (command == "remove_building") {
|
||||
/* TODO: implement */
|
||||
if (args.size() == 0) {
|
||||
print_error("bad command: not enough args: " + command);
|
||||
return;
|
||||
}
|
||||
int id = args[0];
|
||||
remove_building(id);
|
||||
} else if (command == "remove_buildings_by_prefix") {
|
||||
if (args.size() == 0) {
|
||||
print_error("bad command: not enough args: " + command);
|
||||
return;
|
||||
}
|
||||
std::vector<int> erased_indices;
|
||||
erased_indices.reserve(buildings.size());
|
||||
String prefix = args[0];
|
||||
int i, j;
|
||||
for (i = 0; i < (int)buildings.size(); i++) {
|
||||
if (buildings[i].id.begins_with(prefix))
|
||||
erased_indices.push_back(i);
|
||||
}
|
||||
print_line("delete buildings: " + itos(erased_indices.size()) +
|
||||
" prefix: " + prefix);
|
||||
for (i = erased_indices.size() - 1; i >= 0; i--) {
|
||||
int index = erased_indices[i];
|
||||
unload_building(index);
|
||||
buildings.erase(buildings.begin() + index);
|
||||
for (j = index; j < (int)buildings.size(); j++)
|
||||
item_nodes[j] = item_nodes[j + 1];
|
||||
item_nodes.erase(buildings.size());
|
||||
}
|
||||
update_items();
|
||||
} else if (command == "remove_generated_stuff") {
|
||||
remove_generated_stuff();
|
||||
update_items();
|
||||
|
||||
Reference in New Issue
Block a user