int building_create(int type, int x, int y) { Building* building; if (type == 1) { building = 0; } else { AList props; props.set_int("x-pos", x); props.set_int("y-pos", y); building = BuildingTypeManager::current()->create_building(type, props); } if (building) { BuildingManager::current()->add_building(building, x, y); return building->get_id(); } else { std::cout << "BuildingCommands: Unhandled building type: " << type << std::endl; return 0; } }
int building_create_type(const char* name, SCM lst) { AList alist; while(!gh_null_p(lst)) { SCM key = gh_car(lst); if (gh_null_p(gh_cdr(lst))) { std::cout << "Missing argument to keyword!" << std::endl; } SCM value = gh_cadr(lst); if (gh_boolean_p(value)) { alist.set_bool(Guile::keyword2string(key), gh_scm2bool(value)); } else if (gh_number_p(value)) { alist.set_int(Guile::keyword2string(key), gh_scm2int(value)); } else if (gh_string_p(value)) { alist.set_string(Guile::keyword2string(key), Guile::scm2string(value)); } else { std::cout << "BuildingCommands: unknown argumnent type" << std::endl; } lst = gh_cddr(lst); } return BuildingTypeManager::current()->register_factory(new CustomBuildingFactory(name, alist)); }