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

[WIP] Player structure array + initial multiplayer support #200

Draft
wants to merge 47 commits into
base: master
Choose a base branch
from

Conversation

iamgreaser
Copy link
Contributor

@iamgreaser iamgreaser commented Oct 6, 2019

WIP, but I'd like to get some eyes over the code so I have a better idea of how this should be done. [OK I'm happy to have this merged once everyone's happy with it] [Also please ignore the WIP tag, I hate the GitHub interface and I think I've blocked the element that lets me change the title of this thing]

My earlier attempt at adding multiplayer to MegaZeux dates back to early-to-mid 2018 and since then the code's had a clue-by-4-rocket-machine-launcher-steamroller applied to it so good luck getting that to apply.

So far this contains enough to... well, work normally when you don't enable multiplayer support. However when you do enable it, you get something which behaves similarly to the previous attempt except every player uses the exact same inputs.

I'm considering getting a little bit more clone-b-gone into this before dropping the WIP tag [There's still clones in the multiplayer cases which tend to show up in Ordnance but singleplayer is fine] but I'm tempted to do the input support in a separate PR. Consider this PR impractical for actually playing multiplayer but there isn't an obvious way to do multiplayer input well with MZX. [I have something in mind]

Either way, this does end up moving stuff into a player structure with the wonderful power of sed -i, and some of the code has been refactored to take advantage of this. Also, unlike the previous attempt, moving the primary player doesn't require moving all of the other merged players at the same time. [I then proceeded to manually MPify and structify all the things so there's now only two places which have mzx_world->players[0] in them and they're not particularly worth structifying]

replace_player now loops over all players
find_player now loops over all players
In this case, swap the foreground and background as per the
convention of my original attempt at multiplayer.
Worst case, O(MAX_PLAYERS*pushes) noops and O(MAX_PLAYERS) scans

If this is slow I'd like to know. (Try getting that out of your head.)
These will come in handy when working out which player to target and/or blame
Also, actually compile and link distance.c
And with that said we have reached peak multiplayer
I think this may cover all things that aren't bears
I'm going to need to work out what's going on with the sensors

If knowing what they're doing is bad for my sanity please let me know
because we're about to import something that has a hurt_player
I've tried to go with what's intuitive, but combinations of things can clash.

But at least the Forest of Ruin triggers work nicely.
That should be the rest of the stuff that doesn't involve sensors
Just a little bit.

I'll revisit this once we start getting more multiplayer stuff in.
@iamgreaser iamgreaser marked this pull request as ready for review October 8, 2019 07:12
@AliceLR AliceLR marked this pull request as draft December 6, 2023 09:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant