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

Conversation

thmsndk
Copy link
Contributor

@thmsndk thmsndk commented May 8, 2024

This PR makes it easier to make new instances. Instead of hardcoding server_bfs for instances in init_game it will now dynamically acquire them from G.maps. and run server_bfs if there are npcs or monsters in the instance.

This change was initially part of the bee dungeon branch i'm working on.

This is the console output from my ptr server with added debug, keep in mind create_instance in server_functions.js will also call server_bfs if precompute has not been run.

log output from my change where i've added a console log for precomputed.

2024-08-13 20:48:46 tomb is precomputed
2024-08-13 20:48:46 dungeon0 is precomputed
2024-08-13 20:48:46 shellsisland is precomputed
2024-08-13 20:48:48 crypt is precomputed
2024-08-13 20:48:48 winter_instance is precomputed

@thmsndk thmsndk force-pushed the feature/no-hardcode-server_bfs-for-instances branch from 17617fd to 99d3319 Compare July 27, 2024 20:34
Comment on lines +382 to +394
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);
}
}
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

@Telokis Telokis added Type: enhancement Changes the existing content of the game Scope: game server The game server is impacted Status: waiting for author The maintainers are waiting for the author or contributor to reply or perform changes labels Aug 13, 2024
@Telokis Telokis added Status: waiting for review This PR is waiting for a maintainer to review it and removed Status: waiting for author The maintainers are waiting for the author or contributor to reply or perform changes labels Aug 13, 2024
@thmsndk thmsndk force-pushed the feature/no-hardcode-server_bfs-for-instances branch from 99d3319 to 99107b4 Compare August 13, 2024 20:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: game server The game server is impacted Status: waiting for review This PR is waiting for a maintainer to review it Type: enhancement Changes the existing content of the game
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants