check if user tries to convert soil <-> stone throw some warning if he does
| 268 | // check if user tries to convert soil <-> stone |
| 269 | // throw some warning if he does |
| 270 | bool conversionAllowed(color_ostream &out, MaterialInfo mat_new, MaterialInfo mat_old, bool force) |
| 271 | { |
| 272 | // check if current layer mat is stone or soil: |
| 273 | // by default don't allow to turn stone to soil and vice versa |
| 274 | bool unsafe = false; |
| 275 | bool allowed = true; |
| 276 | |
| 277 | // throw warning if user wants to change soil to stone or vice versa |
| 278 | // while it does work it might be unsafe and can have weird results |
| 279 | // you can't simply convert stone to soil, the rock walls will remain (same the other way round) |
| 280 | // the floor will turn into soil, though, so it might be useful for creating farm plots |
| 281 | // therefore it's not completely forbidden and can be enabled by the 'force' option |
| 282 | |
| 283 | if ( mat_new.inorganic->flags.is_set(inorganic_flags::SOIL_ANY) |
| 284 | && !mat_old.inorganic->flags.is_set(inorganic_flags::SOIL_ANY)) |
| 285 | { |
| 286 | if(!warned) |
| 287 | { |
| 288 | out << "Changing a stone layer into soil is probably not wise." << endl |
| 289 | << "The stone will remain and you get a soil floor after digging." << endl; |
| 290 | } |
| 291 | unsafe = true; |
| 292 | } |
| 293 | else if ( !mat_new.inorganic->flags.is_set(inorganic_flags::SOIL_ANY) |
| 294 | && mat_old.inorganic->flags.is_set(inorganic_flags::SOIL_ANY)) |
| 295 | { |
| 296 | if(!warned) |
| 297 | { |
| 298 | out << "Changing a soil layer into stone is probably not wise." << endl |
| 299 | << "The soil will remain and you only get a stone floor after digging." << endl; |
| 300 | } |
| 301 | unsafe = true; |
| 302 | } |
| 303 | |
| 304 | if(unsafe) |
| 305 | { |
| 306 | if(force) |
| 307 | { |
| 308 | if(!warned) |
| 309 | { |
| 310 | out << "You've been warned, good luck." << endl; |
| 311 | } |
| 312 | allowed = true; |
| 313 | } |
| 314 | else |
| 315 | { |
| 316 | if(!warned) |
| 317 | { |
| 318 | out << "Use the option 'force' if you REALLY want to do that." << endl |
| 319 | << "Weird things can happen with your map, so save your game before trying!" << endl |
| 320 | << "Example: 'changelayer GRANITE force'" << endl; |
| 321 | } |
| 322 | allowed = false; |
| 323 | } |
| 324 | // avoid multiple warnings for the same stuff |
| 325 | warned = true; |
| 326 | } |
| 327 | return allowed; |