Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Deleting terrain problem

Author
Message
Cescano
10
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 8th Jun 2015 21:10 Edited at: 8th Jun 2015 21:33
Even trying both delete terrain and destroy terrain, when i remake the terrain it quit the game with an error saying "terrain already exist, cannot overwrite".

Why that happens?


Edit:

Seems that the only way to fix it is to avoid to check if the terrain exist before destroying it
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 8th Jun 2015 21:43
Works fine for me. However, if I try to reuse the same object ID for another object then I get an error - but not if I make another terrain.

This is what I tried (code fragment only)



You could try adding delete object terrainID after destroying the terrain.



Powered by Free Banners
Cescano
10
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 8th Jun 2015 22:30
I already use delete objects 1,65535 just after trying to delete the terrains
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 9th Jun 2015 00:41
Could you post a simple runnable snippet which reproduces your problem?



Powered by Free Banners
Cescano
10
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 9th Jun 2015 06:18
I use this code to make the terrain:



(obviously there is a lot of more code such as texturing the terrain and applying an effect for example)

Then if i want to delete the terrain and load it again, if I do like this:



the terrain exist() function returns Always false even if the terrain exist, so the destroy terrain command is not called, and if i remake the terrain again obviously I get an error saying that the terrain already exist.
So the only workaround for this is to remove the terrain exist() function and force a destroy terrain without to check if it exists. like this:




Don't mind about the for next cycle, I use it because I have added this piece of code in a "Delete Everything" function, so if in the future I will add more terrains they will be all deleted without changing this code again
Scorpyo
22
Years of Service
User Offline
Joined: 26th Aug 2002
Location: italy
Posted: 9th Jun 2015 09:40
I think that IF TERRAIN EXIST (n) is a command from the old set of the WORLD COMMANDS and it responds to the MAKE TERRAIN command and not to the AT command MAKE OBJECT TERRAIN.
Just speculating tho, I tried IF OBJECT EXIST(n) THEN DESTROY TERRAIN (n) doesn't work either.
The only work around I see is to use a flag array keeping track of what terrain has been built and what not.

pseudo code example:

Just an idea
Cheers
Scorpyo
Cescano
10
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 9th Jun 2015 09:58
Yes it works but there is no reason to make things trickier when you can just force a destroy terrain like I am doing
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 9th Jun 2015 10:09
Quote: "Just speculating tho, I tried IF OBJECT EXIST(n) THEN DESTROY TERRAIN (n) doesn't work either."


Works fine for me.

Quote: "Yes it works but there is no reason to make things trickier when you can just force a destroy terrain like I am doing"


As I said before:

Quote: "Could you post a simple runnable snippet which reproduces your problem?"


Since the destroy terrain works me as I described earlier, it would help enormously if you could show complete runnable code (you obviously don't need to post your entire project). Then I can make some progress on this.



Powered by Free Banners
Cescano
10
Years of Service
User Offline
Joined: 4th Sep 2014
Location: Italy
Posted: 9th Jun 2015 18:31
We already got which is the problem so it's not required anymore to post a runnable code, it would takes time for nothing as I would have to rewrite some code and remake another heightmap as I can't post mine.

The problem is that the "make OBJECT terrain" build a terrain not using a "terrain slot" but a "object slot".

Is not even required to check "if object exist(x)" because even calling destroy terrain without to check if it exists works either.
Green Gandalf
VIP Member
20
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 9th Jun 2015 19:38
Quote: "The problem is that the "make OBJECT terrain" build a terrain not using a "terrain slot" but a "object slot"."


That is true - which is one reason why you need to use delete object as well in some circumstances as said earlier. Actually it uses an advanced terrain (AT) slot as well as an object slot which is why you need to use destroy terrain to get rid of the extra AT stuff.

Anyway, glad you know what to do now.



Powered by Free Banners

Login to post a reply

Server time is: 2025-08-09 02:29:52
Your offset time is: 2025-08-09 02:29:52