Mobs spawning
#1
I am just trying to rework the Mob spawning code.
At first I stopped limitless spawning mobs.
Second I spawn up to 50 mobs every 2 seconds when a player is online.
Third I destroy every mob after 1000 ticks (at the moment)
So wherever i go i get new mobs.

What to do next ?
- spawn mobs for each player (50 mobs for each player)
- destroy mobs only when no player is near
- don't destroy passive mobs and save passive mobs with chunk
- spawn mobs where they are supposed to be (for example squids only in water - maybe based on binomes, maybe configurable in world.ini for each biome)

- look at chunk loading/unloading - are mobs saved/loaded with chunk ?
while testing i got sometimes a server crash:

[7da60700|03:11:49] Assertion failed: BytesToEndOfBuffer >= 0, file source/ByteBuffer.cpp, line 357
MCServer: source/ByteBuffer.cpp:357: bool cByteBuffer::ReadBuf(void*, int): Assertion `0' failed.

what could this be ?


Attached Files
.txt   monster.txt (Size: 3.04 KB / Downloads: 293)
Reply
Thanks given by:
#2
I think the vanilla spawning algorithm is pretty good, and it is documented quite well in the minecraft wiki. Having that implemented in MCServer would be great.
Reply
Thanks given by:
#3
(11-19-2012, 04:33 PM)xoft Wrote: I think the vanilla spawning algorithm is pretty good, and it is documented quite well in the minecraft wiki. Having that implemented in MCServer would be great.

Yes - that would be the goal to reach Wink ..
I'm going step by step - i've to analyse the source in detail yet to do some of the features ...

do you know something about the other problem ? The Assertion ? It looks like there the recieve call has no data - so there it gives the assertion. but could'nt this be ignored ? Or should this not be possible that the recieve buffer is empty ?
Reply
Thanks given by:
#4
I'm just saying because it seems to me that you're heading in a direction slightly different than the vanilla algorithm.

The assertion is weird, it means that someone has put the cByteBuffer object into an invalid state (reading position is beyond buffer end - how did it get there without wrapping?) If you comment the assertion out, it won't stop the server immediately, but the server will crash soon afterwards without a warning, because memory is being overwritten where it shouldn't be.
I've been hunting that bug for quite some time and I thought I fixed it; it doesn't happen for me at all anymore.
Reply
Thanks given by:
#5
Yes - i've read the spawning alogrithm of vanilla just today - but as i can see it is not so far away from what i've imaged. At the moment i am a little bit experimenting to see how the code works. with the original code in mcserver i did't see any mobs because they are spawning only after few minutes. And as i could see right now they are spawning infinite. So i wanted to see more mobs and add a limit first of all ..

Is anybody working on it - or should i go on with it ?

the assertion - yes it's wired - i've got it only after a few minutes of simulating the world - this means a lot of spawning/destroying mob entites. but this should not have any connection to the cbytebuffer code ?

Reply
Thanks given by:
#6
As far as I know, no-one's working on mob spawning.

The assertion happens when data is read from the clients, and it can happen only after 64 KiB of data is read. That is usually only after a few minutes of gameplay.
I'll add more assertions like this one to the cByteBuffer code, we'll figure out where it goes haywire.
Reply
Thanks given by:
#7
should i post actual patch files when working on it, or do you prefer other ways to share code ?
Reply
Thanks given by:
#8
Patch files are great. Unfortunately this forum doesn't accept them as attachments, so either upload them elsewhere and post a link, or change their extension to .txt to attach them here.
Reply
Thanks given by:
#9
Code:
m_DestroyTimer += a_Dt/1000;

what is a_Dt - when debugging the value is mostly the same - so i can't see what this line will do ?
Is a_Dt the difference time to the last Tick ? Should this delay the death of the Monster ? Why ?

Reply
Thanks given by:
#10
a_Dt in Tick functions is the time elapsed since the last tick (I don't know now in what units, probably ms or float seconds). I'm not sure what that line does, I suppose the m_DestroyTimer is later checked and if it's high enough, the mob is destroyed. Sorry for the vague answer, don't have access to the source right now.
Reply
Thanks given by:




Users browsing this thread: 1 Guest(s)