by Spike » Tue Apr 26, 2016 4:14 pm
side note: when using random() it is generally better to use floor instead of ceil, but the reason for this is engine-specific.
fte/dp: random returns a value between 0 <= val < 1
vanilla: random returns a value between 0 <= val <= 1
note the equals. random can and WILL return 0 sometimes, but it will NEVER return 1 in fte/dp.
the fact that it can return 0 means that ceil will sometimes bug out with a 0 value, while floor will only bug out in vanilla engines.
this means you will pretty much always need an else statement... but else doesn't really make sense when it comes to array offsets, in which case you're screwed, but you're at least more likely to be using one of the advanced engines if you're using such functionality, so its all okay, right?
well, meh, maybe not. but either way its a good practise to get into.
anyway, just saying.
the statements that the engine prints out on a qc crash are only losely related to the statement that was executing at the time. specifically it doesn't understand branches so they're not all even related to the issue. the exception is of course the last statement that it displays, in this case a CALL0 to the global at 4562 (aka: monsterspawner).
thus monsterspawner is the variable that is null. if it were a variable then the previous statements might have given a hint at how its initialised, but in this case only the last one is interesting. so yeah, see my post about fteqcc, yeah, double posts, evil. I just thought I'd explain things in a little more detail. what can I say, ceil(random()*foo) irks me.
and yeah, as frag.machine points out, bprint can have a delay to it, which means the message may not appear until AFTER the server has already crashed, which makes it painful for debugging.
so yeah, developer 1 combined with dprint is more reliable for print-based debugging, especially when hunting down host_errors.
.