So yes, monsters on the whole map move around without players (as I understand). That's why the OP chose to iterate players, cause he apparently doesn't care about notifying other creatures about anything. He just loops through all of them every round. Plus he assumed way fewer players online than tiles to search.
Yeah, I've kinda been through all of this earlier.
I haven't gotten to the point where notifying creatures has become an interest to implement.
Running over benchmarks of vectors and things here I must admit I was actually wrong, vectors are fast, virtually as fast as a simple for(i=0; i<n; i++) loop, but both are not as cheap as I thought, to my surprise they're both in the 0.5-1µs per iteration range.
This does mean that the option of iterating over all the creatures won't be as cheap as I thought.
It will still be doable to iterate over all players + creatures once per second, even with thousands of players, but not much more than that.
Meaning that iterating "over the tiles" will actually be cheaper, something I will act upon in the coming days/hours.
Edit: Nvm, I'm tripping balls, it's in the 0.001µs per iteration range. I'm used to using 1k loops, switched to 1m in case of inaccuracies using too low numbers, and miscalculated the costs. So yeah, iterating over creatures should still be fairly inexpensive, but you're still right that iterating over tiles will be cheaper, part of my map implementation got me worried that "accessing tiles" would be more expensive, but I did a benchmark and it's actually dirt cheap as it should be, so I'll still be switching over to a getCreatures(...) function over the idea of iterating over all creatures in the future.
Nah for sure, I meant using getSpectators which I don't have or use.
But you could notify all creatures there, where for monsters and NPCs it would mean changing their state (waking up) and then chaining them, so that later you don't have to iterate over and call all non player creatures to do actions (move, etc.) every round, like I think you do now(?). You said that you could easily add another loop through monsters list aside of your getPlayers function for that, but then it's better to search through the map for creatures than iterate all creatures and calculate the distance.
Speaking of Cip engine, you may want to take a look at their TFindCreatures class and ProcessCreatures function.
Hmm, I don't think that's feasible given that any new creature appearing would require a new round of chaining. But I guess you mean in terms of spells.
I don't iterate over creatures currently, I basically run an addEvent for each creature that recursively walks and sleeps in a while loop.
You're right about iterating over tiles is faster than iterating over creatures, I wasn't aware of how expensive any iteration or loop is to begin with and was under the impression that loops are cheap and why I believed iterating over creatures would actually be cheaper.
I'll make sure to do that. Appreciate it a lot.