project-navigation
Personal tools

Author Topic: random map assembly not random  (Read 2388 times)

Offline dodon

  • Rookie
  • ***
  • Posts: 48
    • View Profile
random map assembly not random
« on: July 17, 2010, 10:26:36 pm »
if the cvar "sv_threads" is not 0 (default since r03484) the layout of RMAs is always the same.

examples from ufoconsole.log:
Code: [Select]
2010/07/17 21:53:15 CM_LoadMap: "-africa/af_ +craft_ufo_scout +craft_drop_firebird +empty1 +empty2 +house1 +house2 +house3 +house4 +house5 +fence3 +misc1 +fence1 +misc1 +misc1" "0 -8 0 -24 -16 0 -24 8 0 16 8 0 16 0 0 -8 0 0 8 8 0 0 -16 0 -8 8 0 -16 8 0 -8 -8 0 -8 -16 0 16 -8 0 16 -16 0"
2010/07/17 21:53:42 CM_LoadMap: "-africa/af_ +craft_ufo_scout +craft_drop_firebird +empty1 +empty2 +house1 +house2 +house3 +house4 +house5 +fence3 +misc1 +fence1 +misc1 +misc1" "0 -8 0 -24 -16 0 -24 8 0 16 8 0 16 0 0 -8 0 0 8 8 0 0 -16 0 -8 8 0 -16 8 0 -8 -8 0 -8 -16 0 16 -8 0 16 -16 0"
2010/07/17 21:56:10 CM_LoadMap: "-africa/af_ +craft_ufo_scout +craft_drop_firebird +empty1 +empty2 +house1 +house2 +house3 +house4 +house5 +fence3 +misc1 +fence1 +misc1 +misc1" "0 -8 0 -24 -16 0 -24 8 0 16 8 0 16 0 0 -8 0 0 8 8 0 0 -16 0 -8 8 0 -16 8 0 -8 -8 0 -8 -16 0 16 -8 0 16 -16 0"

The reason for this behaviour is, that the threads, that create the maps always use the same sequence of random numbers due to a missing "srand" command.

I atached a quickfix for this problem.
It's a quickfix, because ...
  • it might break some testcode
  • with more than one thread the probability all threads use the same seed is high

 




Offline Duke

  • Administrator
  • PHALANX veteran
  • *****
  • Posts: 1037
    • View Profile
Re: random map assembly not random
« Reply #1 on: July 19, 2010, 12:21:55 am »
Ouch. I guess you found something important.
Stay tuned.