Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

init_game now runs server_bfs for instance maps with npcs or monsters #137

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions node/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -378,11 +378,20 @@ function init_game() {
create_instance("d_b1");
create_instance("d_a1");
create_instance("d_a2");
server_bfs("crypt");
server_bfs("winter_instance");
server_bfs("tomb");
server_bfs("dungeon0");
server_bfs("cgallery");

for (const name in G.maps) {
const gMap = G.maps[name];
if (gMap.ignore) {
continue;
}

const hasNpcs = gMap.npcs && gMap.npcs.length > 0;
const hasMonsters = gMap.monsters && gMap.monsters.length > 0;
if (gMap.instance && (hasNpcs || hasMonsters)) {
// running this is important for instances, so that npcs and monsters can navigate / move
server_bfs(name);
}
}
Comment on lines +382 to +394
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to see the full list of what this loop will run the bfs for, please! Can you edit the PR description with the info? Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll update the description when I'm on my computer, as far as I remember this run of bfs is only needed if precompute.js has not been run. But I'll verify it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code is a little different on my own branches where I've added more debug output but this part returns early if data has been precomputed in server_bfs

if ((precomputed && precomputed.version == G.version) || (precomputed && precomputed.smap_data)) {
smap_data[map] = precomputed.smap_data[map];
amap_data[map] = precomputed.amap_data[map];
return;
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the description, I have additional debug statements in my branch for my server, I could include them in the PR as well if you think so. @Telokis feel free to mark this conversation as resolved if you think it is

} else if (gameplay == "dungeon") {
for (var name in G.maps) {
if (G.maps[name].world == "dungeon") {
Expand Down