Permalink
Browse files

#12: Had to correct for 3 dimensions worst case.

The constant is based on distance in one dimension.
  • Loading branch information...
1 parent 5dfe61f commit 57ec4c183198e061400ba0ed41fb576a046b365c @larspensjo committed Oct 3, 2012
Showing with 4 additions and 3 deletions.
  1. +1 −1 src/cmd/server/config.go
  2. +3 −2 src/cmd/server/manage_clients.go
@@ -43,7 +43,7 @@ const (
CnfgMonsterAggroDistance = 20 // How close you have to be to a monser to get aggro
CnfgMonsterFieldOfView = 1.40 // The viewing angle for a monster, in radians
CnfgMeleeDistLimit = 4 // Max block distance to be allowed to hit
- CnfgMaxChunkReqDist = 5 // Client can not request chunks further away than this. Max view distance is 160 blocks, which correspopnds to 5 chunks.
+ CnfgMaxChunkReqDist = 6 // Client can not request chunks further away than this (in one dimension). Max view distance is 160 blocks, which correspopnds to 5 chunks.
MaxMonsterSpawnHeightDiff = 6 // The monster will not spawn outside of this diff to the player (in blocks)
MonsterLimitForRespawn = 3 // If there is at least this many monsters near, no new will be spawned.
LoginChallengeLength = 20 // The number of random bytes used in login, sent to the client.
@@ -539,8 +539,9 @@ func (up *user) CmdReadChunk_WLwWLcBl(cc chunkdb.CC) {
dy := userCC.Y - cc.Y
dz := userCC.Z - cc.Z
dist := dx*dx + dy*dy + dz*dz
- if dist > CnfgMaxChunkReqDist*CnfgMaxChunkReqDist {
- log.Println("User", up.pl.name, "requested chunk too far away", userCC, cc)
+ if dist > 3*CnfgMaxChunkReqDist*CnfgMaxChunkReqDist {
+ // Factor 3 is need for worst case with maximum distance in all three dimensions.
+ log.Println("User", up.pl.name, "requested chunk too far away", userCC, cc, "distance", dist)
up.Printf("!Bad chunk request")
return
}

0 comments on commit 57ec4c1

Please sign in to comment.