202 Commits
Author SHA1 Message Date
Catherine Reprobate be0293f555 update Readme links 2026-05-25 23:55:29 -07:00
fgsfds 54d35b47a0 Merge pull request #716 from jonaeru/port-net-disablemenu
[port-net] Disable all menus in Perfect Menu except Network Game and Change Agent
2026-05-02 12:20:13 +02:00
Jonaeru 04a518840f Add "Player Setup" menu to "Join Game" menu
Add `MENUDIALOGFLAG_STARTSELECTS` to the "Network Game" menu
Remove `MENUDIALOGFLAG_IGNOREBACK` from the "Join Network Game" menu
2026-04-26 20:59:32 +09:00
Jonaeru 68df5343ba Disable all menus in Perfect Menu except Network Game and Change Agent 2026-04-25 00:53:00 +09:00
fgsfds aead1bc4c4 port-net: kick ci 2026-04-11 22:13:44 +02:00
fgsfds b86cc88991 port-net: update netplay.md
doing this mostly to kick CI
2025-12-31 21:10:42 +01:00
fgsfds d946e332ae port: net: don't transfer projectile/embedded flags in damage event 2025-09-28 10:26:50 +02:00
fgsfds 57041735cb port: net: fix build on newer mingw versions 2025-08-03 14:15:10 +02:00
fgsfds f3ce20fb6e port: net: fix laptop gun altfire on clients; better autogun sync 2025-04-27 19:52:28 +02:00
fgsfds 75d1886da1 port: net: load mpsetups from mpsetups.bin when entering host menu 2025-04-27 17:36:03 +02:00
fgsfds a582068c21 port: net: sync prop damage 2025-04-27 16:41:33 +02:00
fgsfds 4c1e9ece94 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2025-04-27 16:01:37 +02:00
fgsfds a9ccc61f96 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2025-04-27 15:45:45 +02:00
fgsfds 110876b036 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2025-03-16 09:18:31 +01:00
fgsfds ae7b21cf56 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2025-03-02 13:38:12 +01:00
fgsfds e8a57d7f6f Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2025-02-22 11:28:12 +01:00
fgsfds 2362444efd Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2025-02-11 20:06:26 +01:00
fgsfds f5251fa1b9 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2025-01-05 15:46:00 +01:00
fgsfds da4e5e4832 what the fuck git 2025-01-05 15:44:14 +01:00
fgsfds 5ebce756ed Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2025-01-05 15:43:52 +01:00
fgsfds 839ef7cc44 thank you git very cool 2025-01-05 12:44:51 +01:00
fgsfds c597915466 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2025-01-05 12:33:15 +01:00
fgsfds 5db911a58b Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-11-29 09:58:04 +01:00
fgsfds 5425c21c83 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-11-23 20:40:38 +01:00
fgsfds abe04c0dda Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-11-19 18:33:29 +01:00
fgsfds 7721297dc8 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-11-17 11:09:06 +01:00
fgsfds 44c5a4c213 port-net: note that switch is not supported 2024-11-16 15:39:13 +01:00
fgsfds 7677b40b06 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-11-16 15:38:27 +01:00
fgsfds f948fc06f2 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-11-16 15:30:34 +01:00
fgsfds 26c24d62aa Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-11-16 12:56:01 +01:00
fgsfds 9a484c1aea Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-11-15 19:14:04 +01:00
fgsfds 3f45d41de6 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-11-15 19:13:07 +01:00
fgsfds 6ddebf8aa6 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-11-15 01:36:54 +01:00
fgsfds 6d20ed25fb Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-11-14 18:46:15 +01:00
fgsfds 112f6da972 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-11-13 09:09:47 +01:00
fgsfds 80cd44d8e2 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-11-13 08:55:19 +01:00
fgsfds 3ff2f9e0ec Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-11-13 08:51:43 +01:00
fgsfds 8b8eedcdfc port-net: fix artifact links 2024-11-12 23:20:22 +01:00
fgsfds 1398f5d0f5 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-11-12 23:18:53 +01:00
fgsfds 4d96fab71f Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-11-12 14:46:26 +01:00
fgsfds 796241d443 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-09-02 11:03:24 +02:00
fgsfds 3455708e38 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-09-02 10:07:04 +02:00
fgsfds ae0ba57c24 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-08-06 16:54:36 +02:00
fgsfds f7435e0ead Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-08-05 11:42:49 +02:00
fgsfds fceacee0e2 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-08-04 11:09:30 +02:00
fgsfds a5a2970b67 Merge branch 'port' into port-net 2024-05-19 19:45:37 +02:00
fgsfds 0d6a5f2d0f Merge branch 'port' into port-net 2024-05-18 19:33:21 +02:00
fgsfds c5ab7d20df Merge branch 'port' into port-net 2024-05-18 19:18:36 +02:00
fgsfds d53dd8c48f Merge branch 'port' into port-net 2024-05-18 19:02:30 +02:00
fgsfds edced1d0e2 Merge branch 'port' into port-net 2024-05-15 14:11:30 +02:00
fgsfds 7cc389bc69 Merge branch 'port' into port-net 2024-05-15 13:39:19 +02:00
fgsfds 5e03342562 Merge branch 'port' into port-net 2024-05-15 12:29:45 +02:00
fgsfds 30e987eb50 Merge branch 'port' into port-net 2024-05-15 12:13:43 +02:00
fgsfds e5f142b110 Merge branch 'port' into port-net 2024-05-14 23:16:48 +02:00
fgsfds 95bf97a2c1 Merge branch 'port' into port-net 2024-05-14 22:56:54 +02:00
fgsfds f52fa8f759 Merge branch 'port' into port-net 2024-05-14 22:53:08 +02:00
fgsfds ff4321673b port: net: add note about regions 2024-05-14 22:24:10 +02:00
fgsfds 7590f0bdc3 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-05-14 22:23:00 +02:00
fgsfds 70882d8a32 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-05-14 22:17:09 +02:00
fgsfds 045d5d2e46 Merge branch 'port-net' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-05-14 22:00:44 +02:00
fgsfds 7fabc68e95 Merge branch 'port' into port-net 2024-05-14 21:06:26 +02:00
fgsfds 948a3e0c51 Merge branch 'port' into port-net 2024-05-14 20:33:50 +02:00
fgsfds 7ffc1d393b Update README.md 2024-05-14 12:10:52 +02:00
fgsfds aba98349ae Merge branch 'port' into port-net 2024-05-14 12:07:19 +02:00
fgsfds 9625cd7d28 Merge branch 'port' into port-net 2024-05-14 11:37:47 +02:00
fgsfds 0e2de3b746 Merge branch 'port' into port-net 2024-05-14 11:29:28 +02:00
fgsfds 32417c164c Merge branch 'port' into port-net 2024-05-14 11:12:56 +02:00
fgsfds 1db33f278b Merge branch 'port' into port-net 2024-05-14 10:56:58 +02:00
fgsfds abc6612641 Merge branch 'port' into port-net 2024-05-14 10:35:06 +02:00
fgsfds 57b1e37397 Merge branch 'port' into port-net 2024-05-14 10:15:19 +02:00
fgsfds 3f3c091289 Merge branch 'port' into port-net 2024-05-13 22:23:16 +02:00
fgsfds 41ddcc7822 Merge branch 'port' into port-net 2024-05-13 18:49:16 +02:00
fgsfds 6708bf2aa6 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-05-13 15:27:06 +02:00
fgsfds c16aa70a66 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-05-13 12:20:12 +02:00
fgsfds 60c30e9b67 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-05-13 01:15:50 +02:00
fgsfds bc01ff558f Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-05-13 00:30:42 +02:00
fgsfds 8c844874e7 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-05-12 16:32:16 +02:00
fgsfds 2e18ffdad9 update branch name in build instructions 2024-05-11 15:58:56 +02:00
fgsfds b2ea9aa5f2 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-05-11 15:57:20 +02:00
fgsfds b9a51e4a62 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-05-11 14:14:15 +02:00
fgsfds b72d7f54e1 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-03-09 22:38:35 +01:00
fgsfds d8b21f78e0 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-03-09 17:45:41 +01:00
fgsfds 0d0de5b0d4 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-03-09 17:43:11 +01:00
fgsfds 7667d37ff0 Merge pull request #388 from iamgreaser/gm/net/counterop-4player
port-net: Extend counter-op mode to 4 players
2024-03-09 16:58:31 +01:00
fgsfds cf7c4d4239 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-02-13 01:17:45 +01:00
GreaseMonkey adcf56ed34 Handle cases for Counter-Op where certain local players can be missing; Don't support 2.x controls for Counter-Op
I'm not sure if this happens in practice in the port itself, but with a bit of temporary hackery one can force certain players to be absent.
This handles that case cleanly.
2024-02-11 13:25:35 +13:00
fgsfds 5e65e84210 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-02-11 00:59:18 +01:00
GreaseMonkey 63a9a26908 set_chr_team(CHR_ANTI, *) now sets all counter-op player teams
The easiest-to-test effect of this is that counter-op players will no longer attempt to auto-aim against one another (p2 vs any other).

Maps where this was necessary: Villa, Chicago, Rescue, Air Base, Air Force One
(Other maps stick to the default of `TEAM_ENEMY`, and so this doesn't really affect it.)
2024-02-10 14:17:22 +13:00
GreaseMonkey f4530633d6 Replace "Counter-Operative" player selection with "Main Player" + extend to 4 entries 2024-02-10 11:20:01 +13:00
GreaseMonkey 94e244a236 Report correct ending success/failure when any counter-op player aborts 2024-02-09 16:15:09 +13:00
GreaseMonkey 92d3a9f564 Add macros for counter-op player determination; Handle some missing checks 2024-02-09 13:44:04 +13:00
GreaseMonkey 44a67e60e8 net: Use LOCALPLAYERCOUNT() for UI size determination 2024-02-09 09:10:33 +13:00
GreaseMonkey 634eecb35d Use vertical-split versions of menus in 3+-player main missions
These work fine in the 2x2 split arrangement.
2024-02-09 08:40:02 +13:00
GreaseMonkey a0db91a0c9 Preliminary 4-player counter-op mode
Here's some things that will be needed off the top of my head:

- Handling the half-screen-width case for the pause menus
- Changing the player select menu to select the not-counter-op player instead, then extending that to 4 players
- Thorough testing of each level for any weird counter-op-specific features
2024-02-09 08:40:02 +13:00
fgsfds 6b105d0be0 Merge pull request #381 from iamgreaser/gm/net/broadcast-queries-001
query.py: Allow broadcast queries and wait for all replies
2024-02-06 10:49:58 +01:00
GreaseMonkey 11febd7ace port-net: query.py: Print reply source addresses 2024-02-06 12:16:05 +13:00
GreaseMonkey dface4696c port-net: query.py: List all server query replies
This is for when one provides a broadcast address to query.
2024-02-06 12:14:20 +13:00
GreaseMonkey 0669ce5668 port-net: query.py: Allow querying broadcast
This waits for the first reply and then exits.
2024-02-06 12:05:17 +13:00
fgsfds 6d3ea5b0fd Update README.md 2024-01-29 22:14:06 +01:00
fgsfds 409e955883 Merge pull request #376 from abgrac/readme-links-titles
Updated title & links titles for consistency with Master
2024-01-29 22:10:06 +01:00
Adriano Bini f006f9ba7b Updated title/link titles for consistency with MST
Some people are not being able to properly download/play because of Github's always defaulting to master's README.MD. This includes netplay links in the master branchg README as well.
2024-01-29 17:16:07 -03:00
fgsfds 6a03e8d9cf port: net: unify console and join address input routines 2024-01-28 19:28:51 +01:00
fgsfds a1af5b655a Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-01-28 18:46:13 +01:00
fgsfds edeafa596d Merge pull request #373 from abgrac/port-net
Changed server footer color to more readable green
2024-01-27 14:51:30 +01:00
Adriano Bini b954e3ce80 Changed server footer color to more readable green 2024-01-27 02:17:48 -03:00
fgsfds bfa4035642 port: net: bump protocol version 2024-01-16 01:59:01 +01:00
fgsfds 35be4d589e Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-01-16 01:57:15 +01:00
fgsfds 884a30f970 port: net: bump protocol version 2024-01-16 01:27:22 +01:00
fgsfds 7288947390 port: net: handle UCMD_ACTIVATE as a press 2024-01-16 01:27:03 +01:00
fgsfds c444e76ecb port: net: skip intro cutscene if netgame requested on command line 2024-01-15 13:10:57 +01:00
fgsfds c4b1a8d4a2 port: net: fix --maxclients 2024-01-15 13:01:13 +01:00
fgsfds 7c8b1176c7 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-01-15 12:58:35 +01:00
fgsfds c5a088e7b8 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-01-15 11:40:30 +01:00
fgsfds 8e443d4830 port: ifdef around sight scale changes 2024-01-14 21:13:31 +01:00
fgsfds 2cb52b749c Merge pull request #332 from Calinou/add-crosshair-size-option
Add a crosshair size option
2024-01-14 21:11:58 +01:00
fgsfds de14f90daf Merge branch 'port-net' into add-crosshair-size-option 2024-01-14 21:11:44 +01:00
fgsfds 9afc7e113e Merge pull request #333 from AXDOOMER/port
Always use high detail weapon models
2024-01-14 20:49:20 +01:00
fgsfds fbfe4b4564 port: net: allow up to 120fps in netgames 2024-01-14 20:48:22 +01:00
fgsfds 4cb99506cb port: net: replace useless checksum with slightly more useful crc16 2024-01-14 20:36:03 +01:00
fgsfds 562e763fbd tools: add server query client example 2024-01-14 20:03:16 +01:00
fgsfds 952de6e82b port: net: allow connectionless server info queries 2024-01-14 19:59:00 +01:00
fgsfds 7ec54e6d0b port: net: fix team/handicap menus with 5+ players 2024-01-14 17:54:16 +01:00
fgsfds e6df6014c7 port: net: bump protocol version 2024-01-14 17:40:02 +01:00
fgsfds e688a1c6e6 port: net: do not assume contiguous player slots 2024-01-14 17:36:19 +01:00
fgsfds e44298d0c2 port: net: fix player options not working in SP 2024-01-14 17:15:43 +01:00
fgsfds 31cd8fc28a port: net: fix #328 2024-01-14 15:49:18 +01:00
fgsfds a46ce32ad4 port: net: don't crash if there aren't any player props
although I still don't know what actually leads to this situation
2024-01-14 15:38:05 +01:00
fgsfds 31d8aae704 port: net: move the rest of the IP logging to log only 2024-01-08 12:31:42 +01:00
fgsfds 4b30f52b32 port: net: cap --maxclients 2024-01-07 22:20:46 +01:00
fgsfds c8d42bbf20 port: net: if going into netgame from command line, skip intro and default to profile 0 2024-01-07 22:14:59 +01:00
fgsfds 511d6ca299 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-01-07 22:06:47 +01:00
fgsfds 33f6d643be port: net: add command line arguments for quick hosting and joining 2024-01-07 22:01:20 +01:00
fgsfds c2d09135f7 port: net: probably fix ipv6 address parsing 2024-01-07 21:17:59 +01:00
fgsfds 9f6b21e870 port: net: fix main menu lockup after playing a 5+ player game 2024-01-07 20:52:31 +01:00
fgsfds 4eca4a1f07 port: net: fix a bunch of access violations 2024-01-07 19:54:27 +01:00
fgsfds 4439fdf411 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-01-07 19:10:21 +01:00
fgsfds 6ac8a1a0f6 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-01-07 17:08:44 +01:00
Alexandre-Xavier Labonté-Lamoureux f4ec781b8e port: always use high detail weapon models 2024-01-06 02:58:54 -05:00
Hugo Locurcio 5e256ea406 Add a crosshair size option
5 sizes are available (from 0 to 4), with 2 being the default vanilla-like
value.

Size 0 is a dot with alpha adjusted to match the crosshair color
settings.
2024-01-05 20:21:44 +01:00
fgsfds 5abb0e484e port: net: fix maxplayers cap 2024-01-05 00:33:51 +01:00
fgsfds 16c247a24e port: net: change default LerpTicks to 3 2024-01-04 19:27:14 +01:00
fgsfds 0737c688d7 port: net: don't explode in menu code with > 4 players 2024-01-04 00:00:14 +01:00
fgsfds 9de245eab6 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2024-01-03 21:56:28 +01:00
fgsfds a3cc54d33a port: net: bump protocol version 2024-01-02 19:03:11 +01:00
fgsfds a261246e64 port: net: move clsettings to a separate message; add join notifications 2024-01-02 19:02:23 +01:00
fgsfds 2e195fe21a port: net: bump protocol version 2024-01-02 00:44:40 +01:00
fgsfds 36a692991f port: net: transmit more player options; allow headroll death in netgames 2024-01-02 00:44:08 +01:00
fgsfds ca0e3c3060 port: net: disable headroll in netgames 2024-01-01 21:25:36 +01:00
fgsfds 39474e97a7 port: net: bump protocol version 2024-01-01 20:26:52 +01:00
fgsfds b74cd095a1 port: net: better gun and crosshair position sync; fix zooming guns 2024-01-01 20:18:32 +01:00
fgsfds 96e1c57f61 port: net: carry some of the client inputs over to server-sent moves 2023-12-31 21:00:54 +01:00
fgsfds f6ee8bbf71 port: net: don't die when there's a % in a chat message 2023-12-31 20:31:37 +01:00
fgsfds 188faeecf6 port: net: update netplay.md 2023-12-31 19:51:13 +01:00
fgsfds 2c0a0a1337 port: net: don't play death music, pain and pickup sounds from other players 2023-12-30 14:32:35 +01:00
fgsfds 7f92551d5a port: net: don't create hudmsgs for other players 2023-12-30 13:21:36 +01:00
fgsfds f54dbb596e Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2023-12-30 12:20:03 +01:00
fgsfds aa3c5a85b7 port: net: make team sync slightly less insane 2023-12-29 11:56:54 +01:00
fgsfds f46e112c3d port: net: fix dualwielding, probably; bump protocol version 2023-12-29 02:06:12 +01:00
fgsfds bcb5b3f5c1 port: net: fix uninitialized tickop in SVC_PROP_USE 2023-12-28 22:49:39 +01:00
fgsfds 65589e2fd2 port: net: sort of sync lifts; bump protocol version 2023-12-28 22:43:27 +01:00
fgsfds 54fbd8ba54 port: net: log protocol name 2023-12-28 21:41:27 +01:00
fgsfds 49129dd3e7 port: log branch name 2023-12-28 21:41:20 +01:00
fgsfds 7bfa2b9425 port: net: bump protocol number 2023-12-28 21:38:33 +01:00
fgsfds 53fbbb8a10 port: net: fix teams in netgames 2023-12-28 21:38:17 +01:00
fgsfds 7bee9cdcfc port: net: sync instant environmental death 2023-12-28 12:45:18 +01:00
fgsfds 928544ae5f port: net: bump protocol version just in case 2023-12-28 12:11:43 +01:00
fgsfds 312c752205 port: net: set client rng at the same time the server sends it 2023-12-28 12:10:43 +01:00
fgsfds a5d1c25fea port: net: set g_NumReasonsToEndMatch when server ends the match
just in case
2023-12-28 12:00:21 +01:00
fgsfds 7abebe7405 port: net: don't end match locally on the client 2023-12-28 11:58:38 +01:00
fgsfds ebc126f837 port: net: disable pause in netgames 2023-12-27 19:30:29 +01:00
fgsfds 67bc9c4858 port: net: ignore handicap in netgames 2023-12-27 16:08:49 +01:00
fgsfds c4a3c18208 port: net: clarify chrslots 2023-12-27 16:08:41 +01:00
fgsfds cf1b87a833 port: net: discard game-related messages on client if not in CLSTATE_GAME 2023-12-27 01:51:44 +01:00
fgsfds fb123603ca port: net: put SVC_STAGE_START/END back in the default channel 2023-12-27 01:40:05 +01:00
fgsfds b3ab58da3b Update netplay.md 2023-12-27 01:15:23 +01:00
fgsfds 6374fc834c Update README.md 2023-12-27 01:03:04 +01:00
fgsfds 6df31649f5 Update README.md 2023-12-27 00:38:05 +01:00
fgsfds 9de6b580ba port: net: document netplay status 2023-12-27 00:37:19 +01:00
fgsfds 8eb6880694 port: net: fix linux builds probably 2023-12-26 23:15:05 +01:00
fgsfds fe4d86fae1 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2023-12-26 22:58:20 +01:00
fgsfds 8492670bad ci: build port-net branch 2023-12-26 22:49:18 +01:00
fgsfds 04f95ed1d1 port: net: experimental 8 player support 2023-12-26 22:48:28 +01:00
fgsfds ee037c10ce port: net: ignore UpdateFrames when reliable move is required 2023-12-26 22:40:33 +01:00
fgsfds cbf65e53b9 port: net: only send player moves when needed; add stuff to net debug 2023-12-26 22:33:57 +01:00
fgsfds 8c2b15d649 port: on-screen messages include all rows of the message 2023-12-26 16:55:39 +01:00
fgsfds 2134571b9a port: net: check clients for matching mods; bump protocol version 2023-12-26 16:51:55 +01:00
fgsfds a541c79eda port: net: add movement update rate to ini 2023-12-26 16:21:07 +01:00
fgsfds 454086be6b port: net: separate control msgs into another channel; add bandwidth settings 2023-12-26 16:18:20 +01:00
fgsfds 6bd5997059 port: net: don't draw console or net debug when the font is unloaded 2023-12-25 18:25:07 +01:00
fgsfds 99911b2290 port: net: domain names can in fact start with a digit 2023-12-25 13:10:07 +01:00
fgsfds 95d8b0692f port: net: add some config vars 2023-12-24 17:31:57 +01:00
fgsfds e85cc3b309 port: net: hardcap fps to 60 if in network game 2023-12-24 17:14:19 +01:00
fgsfds 2a01d562c3 Update README.md 2023-12-24 17:07:24 +01:00
fgsfds 51daf45c19 Update README.md 2023-12-24 17:06:29 +01:00
fgsfds c9bd2bfd54 port: net: clarify what this is 2023-12-24 17:01:40 +01:00
fgsfds 6225f62412 port: net: partially fix rockets 2023-12-24 16:56:05 +01:00
fgsfds d2ffd73dea port: net: add net debug info, add copypaste support to IP input 2023-12-24 00:39:36 +01:00
fgsfds 02329b64a1 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2023-12-23 22:09:43 +01:00
fgsfds aae0f70dd3 port: net: sync some projectiles, doors, parts of bgun, etc 2023-12-23 22:09:37 +01:00
fgsfds 41d9cb4578 port: add console for chat and log messages 2023-12-23 22:09:02 +01:00
fgsfds 370047b1b0 Merge branch 'port' of https://github.com/fgsfdsfgs/perfect_dark into port-net 2023-12-18 16:34:58 +01:00
fgsfds 6fc99e4c23 port: net: basic networking with barely working position sync 2023-12-17 12:54:48 +01:00
80 changed files with 11108 additions and 386 deletions

No files matched your search

+1 -1
View File
@@ -2,7 +2,7 @@ name: C/C++ CI
on: on:
push: push:
branches: [ "port" ] branches: [ "port", "port-net" ]
pull_request: pull_request:
branches: [ "port" ] branches: [ "port" ]
workflow_dispatch: workflow_dispatch:
+1 -1
View File
@@ -244,7 +244,7 @@ list(APPEND LIBS "${GL_LIBRARY}")
# Platform-specific extra libs # Platform-specific extra libs
if(NOT EXTRA_LIBRARIES) if(NOT EXTRA_LIBRARIES)
if(WIN32) if(WIN32)
set(EXTRA_LIBRARIES dbghelp -static-libstdc++) set(EXTRA_LIBRARIES ws2_32 winmm dbghelp -static-libstdc++)
elseif(NINTENDO_SWITCH) elseif(NINTENDO_SWITCH)
set(EXTRA_LIBRARIES stdc++ pthread) set(EXTRA_LIBRARIES stdc++ pthread)
else() else()
+26 -13
View File
@@ -1,4 +1,14 @@
# Perfect Dark port # Perfect Dark port (`port-net`)
## Experimental netplay branch
This branch of the port contains an **extremely** early and experimental implementation of network play.
**DISCLAIMER:** This is **NOT READY** for prime time. Use at your own risk if you are not a developer.
**Do not create issues about problems in this branch until this disclaimer is gone.**
See [this file](https://github.com/perfect-dark-pc-port/perfect_dark/blob/port-net/docs/netplay.md) for more information on how this works.
## Original description
This repository contains a work-in-progress port of the [Perfect Dark decompilation](https://github.com/n64decomp/perfect_dark) to modern platforms. This repository contains a work-in-progress port of the [Perfect Dark decompilation](https://github.com/n64decomp/perfect_dark) to modern platforms.
@@ -43,14 +53,13 @@ There are minor graphics- and gameplay-related issues, and possibly occasional c
## Download ## Download
Latest [automatic builds](https://github.com/fgsfdsfgs/perfect_dark/releases/tag/ci-dev-build) for supported platforms: Latest [automatic builds](https://github.com/perfect-dark-pc-port/perfect_dark/actions) of the netplay branch for supported platforms:
* [x86_64-windows](https://github.com/fgsfdsfgs/perfect_dark/releases/download/ci-dev-build/pd-x86_64-windows.zip) * [x86_64-windows (`port-net`)](https://nightly.link/perfect-dark-pc-port/perfect_dark/workflows/c-cpp/port-net/pd-x86_64-windows.zip)
* [i686-windows](https://github.com/fgsfdsfgs/perfect_dark/releases/download/ci-dev-build/pd-i686-windows.zip) * [i686-windows (`port-net`)](https://nightly.link/perfect-dark-pc-port/perfect_dark/workflows/c-cpp/port-net/pd-i686-windows.zip)
* [x86_64-linux](https://github.com/fgsfdsfgs/perfect_dark/releases/download/ci-dev-build/pd-x86_64-linux.tar.gz) * [x86_64-linux (`port-net`)](https://nightly.link/perfect-dark-pc-port/perfect_dark/workflows/c-cpp/port-net/pd-x86_64-linux.zip)
* [i686-linux](https://github.com/fgsfdsfgs/perfect_dark/releases/download/ci-dev-build/pd-i686-linux.tar.gz) * [i686-linux (`port-net`)](https://nightly.link/perfect-dark-pc-port/perfect_dark/workflows/c-cpp/port-net/pd-i686-linux.zip)
* [arm64-nswitch](https://github.com/fgsfdsfgs/perfect_dark/releases/download/ci-dev-build/pd-arm64-nswitch.zip)
If you are looking for netplay builds (the `port-net` branch), see [this link](https://github.com/fgsfdsfgs/perfect_dark/blob/port-net/README.md#download). If you are looking for regular builds (the `port` branch), see [this link](https://github.com/perfect-dark-pc-port/perfect_dark/blob/port/README.md#download).
## Running ## Running
@@ -70,7 +79,9 @@ Optionally, you can also put your Perfect Dark for GameBoy Color ROM named `pd.g
Optionally, you can move the data folder to `~/.local/share/perfectdark` on Linux or `~/Library/Application Support/perfectdark` on MacOS. Optionally, you can move the data folder to `~/.local/share/perfectdark` on Linux or `~/Library/Application Support/perfectdark` on MacOS.
Additional information can be found in the [wiki](https://github.com/fgsfdsfgs/perfect_dark/wiki). Note that users with different ROMs can't play netgames with each other.
Additional information can be found in the [wiki](https://github.com/perfect-dark-pc-port/perfect_dark/wiki).
A GPU supporting OpenGL 3.0/ES3.0 or above is required to run the port. A GPU supporting OpenGL 3.0/ES3.0 or above is required to run the port.
@@ -80,6 +91,8 @@ The Nintendo Switch build ZIP comes with all 3 regions in different folders: `pe
Take the folder for the region you want and put it into the `/switch` folder on your SD card, then put your ROM into the `data` folder inside of the folder you extracted as described above. Take the folder for the region you want and put it into the `/switch` folder on your SD card, then put your ROM into the `data` folder inside of the folder you extracted as described above.
`port-net` currently does not work on the Switch.
## Controls ## Controls
1964GEPD-style and Xbox-style bindings are implemented. 1964GEPD-style and Xbox-style bindings are implemented.
@@ -118,7 +131,7 @@ Controls can be rebound in `pd.ini`. Default control scheme is as follows:
3. Install dependencies: 3. Install dependencies:
`pacman -S mingw-w64-x86_64-toolchain mingw-w64-x86_64-SDL2 mingw-w64-x86_64-zlib mingw-w64-x86_64-cmake mingw-w64-x86_64-python3 mingw-w64-i686-toolchain mingw-w64-i686-SDL2 mingw-w64-i686-zlib mingw-w64-i686-cmake mingw-w64-i686-python3 make git` `pacman -S mingw-w64-x86_64-toolchain mingw-w64-x86_64-SDL2 mingw-w64-x86_64-zlib mingw-w64-x86_64-cmake mingw-w64-x86_64-python3 mingw-w64-i686-toolchain mingw-w64-i686-SDL2 mingw-w64-i686-zlib mingw-w64-i686-cmake mingw-w64-i686-python3 make git`
4. Get the source code: 4. Get the source code:
`git clone --recursive https://github.com/fgsfdsfgs/perfect_dark.git && cd perfect_dark` `git clone -b port-net --recursive https://github.com/perfect-dark-pc-port/perfect_dark.git && cd perfect_dark`
5. Run `cmake -G"Unix Makefiles" -Bbuild .`. 5. Run `cmake -G"Unix Makefiles" -Bbuild .`.
* Add ` -DROMID=pal-final` or ` -DROMID=jpn-final` at the end of the command if you want to build a PAL or JPN executable respectively.\ * Add ` -DROMID=pal-final` or ` -DROMID=jpn-final` at the end of the command if you want to build a PAL or JPN executable respectively.\
6. Run `cmake --build build -j4 -- -O`. 6. Run `cmake --build build -j4 -- -O`.
@@ -130,7 +143,7 @@ Controls can be rebound in `pd.ini`. Default control scheme is as follows:
1. Ensure you have gcc, g++ (version 10.0+), make, cmake, git, python3 and SDL2 (version 2.0.12+), libGL and ZLib installed on your system. 1. Ensure you have gcc, g++ (version 10.0+), make, cmake, git, python3 and SDL2 (version 2.0.12+), libGL and ZLib installed on your system.
* If you wish to crosscompile, you will also need to have libraries and compilers for the target platform installed, e.g. `gcc-multilib` and `g++-multilib` for x86_64 -> i686 crosscompilation. * If you wish to crosscompile, you will also need to have libraries and compilers for the target platform installed, e.g. `gcc-multilib` and `g++-multilib` for x86_64 -> i686 crosscompilation.
2. Get the source code: 2. Get the source code:
`git clone --recursive https://github.com/fgsfdsfgs/perfect_dark.git && cd perfect_dark` `git clone -b port-net --recursive https://github.com/perfect-dark-pc-port/perfect_dark.git && cd perfect_dark`
3. Run the following command: 3. Run the following command:
* ```cmake -G"Unix Makefiles" -Bbuild .``` * ```cmake -G"Unix Makefiles" -Bbuild .```
* Add ` -DROMID=pal-final` or ` -DROMID=jpn-final` at the end of the command if you want to build a PAL or JPN executable respectively. * Add ` -DROMID=pal-final` or ` -DROMID=jpn-final` at the end of the command if you want to build a PAL or JPN executable respectively.
@@ -154,7 +167,7 @@ Controls can be rebound in `pd.ini`. Default control scheme is as follows:
* This installs SDL2 system-wide and this is how the automatic builds are done. The game will also look for it in the executable path, so you could * This installs SDL2 system-wide and this is how the automatic builds are done. The game will also look for it in the executable path, so you could
download it locally instead. download it locally instead.
4. Get the source code: 4. Get the source code:
`git clone --recursive https://github.com/fgsfdsfgs/perfect_dark.git && cd perfect_dark` `git clone --recursive https://github.com/perfect-dark-pc-port/perfect_dark.git && cd perfect_dark`
5. Configure: 5. Configure:
* Execute command: `cmake -G"Unix Makefiles" -Bbuild -DCMAKE_OSX_ARCHITECTURES=x86_64 .` * Execute command: `cmake -G"Unix Makefiles" -Bbuild -DCMAKE_OSX_ARCHITECTURES=x86_64 .`
* Replace `x86_64` with `arm64` if building for an ARM64 Mac. * Replace `x86_64` with `arm64` if building for an ARM64 Mac.
@@ -180,7 +193,7 @@ Controls can be rebound in `pd.ini`. Default control scheme is as follows:
``` ```
* If in MSYS2 or `dkp-pacman` doesn't work, replace it with just `pacman`. * If in MSYS2 or `dkp-pacman` doesn't work, replace it with just `pacman`.
4. Get the source code: 4. Get the source code:
`git clone --recursive https://github.com/fgsfdsfgs/perfect_dark.git && cd perfect_dark` `git clone --recursive https://github.com/perfect-dark-pc-port/perfect_dark.git && cd perfect_dark`
5. Ensure devkitA64 environment variables are set: 5. Ensure devkitA64 environment variables are set:
* Execute command: `source /opt/devkitpro/switchvars.sh` * Execute command: `source /opt/devkitpro/switchvars.sh`
* If your `$DEVKITPRO` path is different, substitute that instead or set the variables manually. * If your `$DEVKITPRO` path is different, substitute that instead or set the variables manually.
+47
View File
@@ -0,0 +1,47 @@
## Experimental netplay branch
This branch contains a **highly experimental** implementation of network play.
Currently only Combat Sim is partially working with experimental 8 player support and really bad netcode.
Expect nothing to work right.
### Hosting
1. Forward the server port (`27100` by default, can be changed in `pd.ini`).
* You can also use something like ZeroTier or Hamachi if you can't port forward.
3. Choose `Network Game` -> `Host Game`, configure the player cap, press `Start Game`.
4. Configure Combat Sim as desired, but do not start it yet. Keep in mind:
* You can save and load the settings as normal.
* Your player will have the config of Combat Sim player 1.
5. Wait for everyone to join. You can use the console (press `~`) to chat in the meantime.
6. Hit Enter/Start. During the game no more players will be able to join.
7. After game is over, you will be kicked back to Combat Sim settings, at which point people can join again and the process repeats from step 3.
### Joining
1. Your player will have the config of Combat Sim player 1, so set that up beforehand in the Combat Sim menu.
2. Choose `Network Game` -> `Join Game`, enter the address (and port if it's not 27100), press `Start Game`.
3. If the message says `Waiting for host`, wait until the host configures the game. You can use the console (press `~`) to chat in the meantime or `ESC` to disconnect.
4. The game will start automatically.
5. After the game is over, press Enter/Start on the stats screen and you will be kicked back to the `Waiting for host` screen, at which point the process repeats from step 3.
### Misc
* Everyone has to have the same ROM. The game only compares the file name, but different regions in one game will definitely break everything.
* Press `~` to bring up the console, press `F9` for network stats.
* You can chat at any time during a net game by entering messages in the console and hitting Enter.
* Server port and other network settings can be configured in `pd.ini`.
* For a 4+ player game I would recommend changing `Net.Server.UpdateFrames` to `2` in `pd.ini` on the server to lower the bandwidth usage.
* You can paste stuff into the `Enter Address` prompt by hitting `CTRL+V`.
* Expect nothing to work right.
### Known issues
* Clients see rocket rotation incorrectly.
* Clients can't use Slayer fly-by-wire rockets and they will not correctly sync if the server uses them.
* Clients can't use the alt fire mode on the FarSight and probably a couple other guns.
* Cloaking device is not synced.
* Most likely only Combat works properly.
* Sims don't work in netgames.
* Bandwidth consumption on the server is pretty large on the default settings, especially with 8 players.
+10
View File
@@ -0,0 +1,10 @@
#ifndef _WIN32
#ifndef _POSIX_C_SOURCE
#define _POSIX_C_SOURCE 200809L
#endif
#endif
#define ENET_IMPLEMENTATION 1
#define ENET_NO_PRAGMA_LINK 1
#include "external/enet.h"
+2
View File
@@ -0,0 +1,2 @@
#define MINIMP3_IMPLEMENTATION
#include "external/minimp3.h"
+15
View File
@@ -0,0 +1,15 @@
#ifndef _IN_CONSOLE_H
#define _IN_CONSOLE_H
#include <PR/ultratypes.h>
#include "types.h"
void conInit(void);
Gfx *conRender(Gfx *gdl);
void conTick(void);
void conPrint(s32 showmsg, const char *s);
void conPrintf(s32 showmsg, const char *fmt, ...);
void conPrintLn(s32 showmsg, const char *s);
s32 conIsOpen(void);
#endif
+5100
View File
File diff suppressed because it is too large. Load diff
+163
View File
@@ -0,0 +1,163 @@
#ifndef _IN_NET_H
#define _IN_NET_H
#include "types.h"
#include "constants.h"
#include "net/netbuf.h"
#define NET_PROTOCOL_VER 12
#define NET_QUERY_MAGIC "PDQM\x01"
#define NET_MAX_CLIENTS MAX_PLAYERS
#define NET_MAX_NAME MAX_PLAYERNAME
#define NET_MAX_ADDR 256
#define NET_BUFSIZE 1440
#define NET_DEFAULT_PORT 27100
#define NET_NULL_CLIENT 0xFF
#define NET_NULL_PROP 0
#define NETCHAN_DEFAULT 0
#define NETCHAN_CONTROL 1
#define NETCHAN_COUNT 2
#define DISCONNECT_UNKNOWN 0
#define DISCONNECT_SHUTDOWN 1
#define DISCONNECT_VERSION 2
#define DISCONNECT_KICKED 3
#define DISCONNECT_BANNED 4
#define DISCONNECT_TIMEOUT 5
#define DISCONNECT_FULL 6
#define DISCONNECT_LATE 7
#define DISCONNECT_FILES 8
#define CLSTATE_DISCONNECTED 0
#define CLSTATE_CONNECTING 1
#define CLSTATE_AUTH 2
#define CLSTATE_LOBBY 3
#define CLSTATE_GAME 4
#define UCMD_FIRE (1 << 0)
#define UCMD_ACTIVATE (1 << 1)
#define UCMD_RELOAD (1 << 2)
#define UCMD_AIMMODE (1 << 3)
#define UCMD_DUCK (1 << 4)
#define UCMD_SQUAT (1 << 5)
#define UCMD_ZOOMIN (1 << 6)
#define UCMD_SELECT (1 << 7)
#define UCMD_SELECT_DUAL (1 << 8)
#define UCMD_EYESSHUT (1 << 9)
#define UCMD_SECONDARY (1 << 10)
#define UCMD_RESPAWN (1 << 27)
#define UCMD_CHAT (1 << 28)
#define UCMD_IMPORTANT_MASK (UCMD_FIRE | UCMD_ACTIVATE | UCMD_RELOAD | UCMD_AIMMODE | UCMD_SELECT | UCMD_SELECT_DUAL)
#define UCMD_FL_FORCEPOS (1 << 29)
#define UCMD_FL_FORCEANGLE (1 << 30)
#define UCMD_FL_FORCEGROUND (1 << 31)
#define UCMD_FL_FORCEMASK (UCMD_FL_FORCEPOS | UCMD_FL_FORCEANGLE | UCMD_FL_FORCEGROUND)
struct netplayermove {
u32 tick; // g_NetTIck value when this struct was written; if 0, this struct is invalid
u32 ucmd; // player commands (UCMD_)
f32 leanofs; // analog lean value (-1 .. 1; equal to player->swaytarget / 75.f)
f32 crouchofs; // analog crouch value (-90 for SQUAT, 0 for STAND; player->crouchofs)
f32 zoomfov; // manual zoom fov for the current gun; synced only if UCMD_AIMING is set
f32 movespeed[2]; // move inputs, [0] is forward, [1] is sideways; used mostly for animation
f32 angles[2]; // view angles, [0] is theta, [1] is verta
f32 crosspos[2]; // crosshair position in aiming mode; normalized to default aspect ratio
s8 weaponnum; // switch to this weapon if UCMD_SELECT is set
struct coord pos; // player position at g_NetTick == tick
};
struct netclient {
struct _ENetPeer *peer;
u32 id; // remote client number, server is always 0, even on clients
u32 state; // CLSTATE_
u32 flags; // CLFLAG_
struct {
char name[NET_MAX_NAME];
u16 options;
u8 headnum;
u8 bodynum;
u8 team;
f32 fovy;
f32 fovzoommult;
} settings;
struct mpplayerconfig *config;
struct player *player;
u8 playernum;
struct netplayermove outmove[2]; // last 2 outgoing player inputs, newest one first
struct netplayermove inmove[2]; // last 2 incoming player inputs, newest one first
u32 inmovetick; // last inmove tick which was applied to the player
u32 outmoveack; // last acked outmove tick
u32 forcetick; // tick on which the client's position was forced, or 0 if not forcing
u32 lerpticks; // how many ticks we've been lerping the position
struct netbuf out; // outbound messages are written here, except broadcasts
struct netbuf in; // incoming packets are fed here
u8 out_data[NET_BUFSIZE]; // buffer for out
};
extern s32 g_NetMode;
extern s32 g_NetJoinLatch;
extern s32 g_NetHostLatch;
// net frame, ticks at 60 fps, starts at 0 when the server is started
extern u32 g_NetTick;
extern u32 g_NetNextSyncId;
extern u64 g_NetRngSeeds[2];
extern u32 g_NetRngLatch;
extern u32 g_NetInterpTicks;
extern u32 g_NetServerPort;
extern char g_NetLastJoinAddr[NET_MAX_ADDR + 1];
extern s32 g_NetDebugDraw;
extern s32 g_NetMaxClients;
extern s32 g_NetNumClients;
extern struct netclient g_NetClients[NET_MAX_CLIENTS + 1]; // last is an extra temporary client
extern struct netclient *g_NetLocalClient;
extern struct netbuf g_NetMsg;
extern struct netbuf g_NetMsgRel;
const char *netFormatClientAddr(const struct netclient *cl);
void netInit(void);
s32 netDisconnect(void);
void netStartFrame(void);
void netEndFrame(void);
s32 netStartServer(u16 port, s32 maxclients);
s32 netStartClient(const char *addr);
u32 netSend(struct netclient *dstcl, struct netbuf *buf, const s32 reliable, const s32 chan);
void netChat(struct netclient *dst, const char *text);
void netChatPrintf(struct netclient *dst, const char *fmt, ...);
void netServerStageStart(void);
void netServerStageEnd(void);
void netServerKick(struct netclient *cl, const u32 reason);
struct netclient *netClientForPlayerNum(s32 playernum);
void netClientSyncRng(void);
void netClientSettingsChanged(void);
void netPlayersAllocate(void);
void netSyncIdsAllocate(void);
Gfx *netDebugRender(Gfx *gdl);
#endif // _IN_NET_H
+50
View File
@@ -0,0 +1,50 @@
#ifndef _IN_NETBUF_H
#define _IN_NETBUF_H
#include "types.h"
struct netbuf {
u8 *data;
u32 size;
u32 rp;
u32 wp;
u32 error;
};
void netbufStartRead(struct netbuf *buf);
void netbufStartReadData(struct netbuf *buf, const void *data, u32 size);
s32 netbufReadLeft(const struct netbuf *buf);
u32 netbufReadData(struct netbuf *buf, void *out, u32 num);
u8 netbufReadU8(struct netbuf *buf);
u16 netbufReadU16(struct netbuf *buf);
u32 netbufReadU32(struct netbuf *buf);
u64 netbufReadU64(struct netbuf *buf);
s8 netbufReadS8(struct netbuf *buf);
s16 netbufReadS16(struct netbuf *buf);
s32 netbufReadS32(struct netbuf *buf);
s64 netbufReadS64(struct netbuf *buf);
f32 netbufReadF32(struct netbuf *buf);
char *netbufReadStr(struct netbuf *buf);
u32 netbufReadCoord(struct netbuf *buf, struct coord *out);
u32 netbufReadMtxf(struct netbuf *buf, Mtxf *out);
u32 netbufReadSkip(struct netbuf *buf, u32 count);
void netbufStartWrite(struct netbuf *buf);
s32 netbufWriteLeft(const struct netbuf *buf);
u32 netbufWriteData(struct netbuf *buf, const void *data, u32 num);
u32 netbufWriteU8(struct netbuf *buf, const u8 v);
u32 netbufWriteU16(struct netbuf *buf, const u16 v);
u32 netbufWriteU32(struct netbuf *buf, const u32 v);
u32 netbufWriteU64(struct netbuf *buf, const u64 v);
u32 netbufWriteS8(struct netbuf *buf, const s8 v);
u32 netbufWriteS16(struct netbuf *buf, const s16 v);
u32 netbufWriteS32(struct netbuf *buf, const s32 v);
u32 netbufWriteS64(struct netbuf *buf, const s64 v);
u32 netbufWriteF32(struct netbuf *buf, const f32 v);
u32 netbufWriteStr(struct netbuf *buf, const char *v);
u32 netbufWriteCoord(struct netbuf *buf, const struct coord *v);
u32 netbufWriteMtxf(struct netbuf *buf, const Mtxf *in);
void netbufReset(struct netbuf *buf);
#endif
+10
View File
@@ -0,0 +1,10 @@
#ifndef _IN_NETENET_H
#define _IN_NETENET_H
#define ENET_NO_PRAGMA_LINK 1
#include "external/enet.h"
#undef bool
#undef near
#undef far
#endif
+74
View File
@@ -0,0 +1,74 @@
#ifndef _IN_NETMSG_H
#define _IN_NETMSG_H
#include <PR/ultratypes.h>
#include "net/net.h"
#include "net/netbuf.h"
#define SVC_BAD 0x00 // trash
#define SVC_NOP 0x01 // does nothing
#define SVC_AUTH 0x02 // auth response, sent in response to CLC_AUTH
#define SVC_CHAT 0x03 // chat message
#define SVC_STAGE_START 0x10 // start level
#define SVC_STAGE_END 0x11 // end level
#define SVC_PLAYER_MOVE 0x20 // player movement and inputs
#define SVC_PLAYER_GUNS 0x21 // player gun state
#define SVC_PLAYER_STATS 0x22 // player stats (health etc)
#define SVC_PROP_MOVE 0x30 // prop movement
#define SVC_PROP_SPAWN 0x31 // new prop spawned
#define SVC_PROP_DAMAGE 0x32 // prop was damaged
#define SVC_PROP_PICKUP 0x33 // prop was picked up
#define SVC_PROP_USE 0x34 // door/lift/etc was used
#define SVC_PROP_DOOR 0x35 // door state changed
#define SVC_PROP_LIFT 0x36 // lift state changed
#define SVC_CHR_DAMAGE 0x42 // chr was damaged
#define SVC_CHR_DISARM 0x43 // chr's weapons were dropped
#define CLC_BAD 0x00 // trash
#define CLC_NOP 0x01 // does nothing
#define CLC_AUTH 0x02 // auth request, sent immediately after connecting
#define CLC_CHAT 0x03 // chat message
#define CLC_MOVE 0x04 // player input
#define CLC_SETTINGS 0x05 // player settings changed
u32 netmsgClcAuthWrite(struct netbuf *dst);
u32 netmsgClcAuthRead(struct netbuf *src, struct netclient *srccl);
u32 netmsgClcChatWrite(struct netbuf *dst, const char *str);
u32 netmsgClcChatRead(struct netbuf *src, struct netclient *srccl);
u32 netmsgClcMoveWrite(struct netbuf *dst);
u32 netmsgClcMoveRead(struct netbuf *src, struct netclient *srccl);
u32 netmsgClcSettingsWrite(struct netbuf *dst);
u32 netmsgClcSettingsRead(struct netbuf *src, struct netclient *srccl);
u32 netmsgSvcAuthWrite(struct netbuf *dst, struct netclient *authcl);
u32 netmsgSvcAuthRead(struct netbuf *src, struct netclient *srccl);
u32 netmsgSvcChatWrite(struct netbuf *dst, const char *str);
u32 netmsgSvcChatRead(struct netbuf *src, struct netclient *srccl);
u32 netmsgSvcStageStartWrite(struct netbuf *dst);
u32 netmsgSvcStageStartRead(struct netbuf *src, struct netclient *srccl);
u32 netmsgSvcStageEndWrite(struct netbuf *dst);
u32 netmsgSvcStageEndRead(struct netbuf *src, struct netclient *srccl);
u32 netmsgSvcPlayerMoveWrite(struct netbuf *dst, struct netclient *movecl);
u32 netmsgSvcPlayerMoveRead(struct netbuf *src, struct netclient *srccl);
u32 netmsgSvcPlayerStatsWrite(struct netbuf *dst, struct netclient *actcl);
u32 netmsgSvcPlayerStatsRead(struct netbuf *src, struct netclient *srccl);
u32 netmsgSvcPropSpawnWrite(struct netbuf *dst, struct prop *prop);
u32 netmsgSvcPropSpawnRead(struct netbuf *src, struct netclient *srccl);
u32 netmsgSvcPropMoveWrite(struct netbuf *dst, struct prop *prop, struct coord *initrot);
u32 netmsgSvcPropMoveRead(struct netbuf *src, struct netclient *srccl);
u32 netmsgSvcPropDamageWrite(struct netbuf *dst, struct prop *prop, f32 damage, struct coord *pos, s32 weaponnum, s32 playernum);
u32 netmsgSvcPropDamageRead(struct netbuf *src, struct netclient *srccl);
u32 netmsgSvcPropPickupWrite(struct netbuf *dst, struct netclient *actcl, struct prop *prop, const s32 tickop);
u32 netmsgSvcPropPickupRead(struct netbuf *src, struct netclient *srccl);
u32 netmsgSvcPropUseWrite(struct netbuf *dst, struct prop *prop, struct netclient *usercl, const s32 tickop);
u32 netmsgSvcPropUseRead(struct netbuf *src, struct netclient *srccl);
u32 netmsgSvcPropDoorWrite(struct netbuf *dst, struct prop *prop, struct netclient *usercl);
u32 netmsgSvcPropDoorRead(struct netbuf *src, struct netclient *srccl);
u32 netmsgSvcPropLiftWrite(struct netbuf *dst, struct prop *prop);
u32 netmsgSvcPropLiftRead(struct netbuf *src, struct netclient *srccl);
u32 netmsgSvcChrDamageWrite(struct netbuf *dst, struct chrdata *chr, f32 damage, struct coord *vector, struct gset *gset, struct prop *aprop, s32 hitpart, bool damageshield, struct prop *prop2, s32 side, s16 *arg11, bool explosion, struct coord *explosionpos);
u32 netmsgSvcChrDamageRead(struct netbuf *src, struct netclient *srccl);
u32 netmsgSvcChrDisarmWrite(struct netbuf *dst, struct chrdata *chr, struct prop *attacker, u8 weaponnum, f32 wpndamage, struct coord *wpnpos);
u32 netmsgSvcChrDisarmRead(struct netbuf *src, struct netclient *srccl);
#endif
+1
View File
@@ -5,6 +5,7 @@
extern u8 *g_RomFile; extern u8 *g_RomFile;
extern u32 g_RomFileSize; extern u32 g_RomFileSize;
extern const char *g_RomName;
s32 romdataInit(void); s32 romdataInit(void);
+9 -4
View File
@@ -7,10 +7,14 @@ extern "C" {
#include <PR/ultratypes.h> #include <PR/ultratypes.h>
enum LogLevel { #define LOGFLAG_NOCON (1 << 6)
LOG_NOTE, #define LOGFLAG_SHOWMSG (1 << 7)
LOG_WARNING,
LOG_ERROR, enum loglevel {
LOG_NOTE = 0,
LOG_CHAT = 0 | LOGFLAG_SHOWMSG,
LOG_WARNING = 1 | LOGFLAG_SHOWMSG,
LOG_ERROR = 2 | LOGFLAG_SHOWMSG,
}; };
void sysInitArgs(s32 argc, const char **argv); void sysInitArgs(s32 argc, const char **argv);
@@ -21,6 +25,7 @@ const char *sysArgGetString(const char *arg);
s32 sysArgGetInt(const char *arg, s32 defval); s32 sysArgGetInt(const char *arg, s32 defval);
u64 sysGetMicroseconds(void); u64 sysGetMicroseconds(void);
f32 sysGetSeconds(void);
void sysFatalError(const char *fmt, ...) __attribute__((noreturn)); void sysFatalError(const char *fmt, ...) __attribute__((noreturn));
+14
View File
@@ -12,4 +12,18 @@ char *strParseToken(char *str, char *out, s32 *outCount);
char *strFmt(const char *fmt, ...); char *strFmt(const char *fmt, ...);
char *strDuplicate(const char *str); char *strDuplicate(const char *str);
static inline f32 lerpf(const f32 a, const f32 b, const f32 t) {
return a + (b - a) * t;
}
static inline f32 lerpanglef(const f32 a, const f32 b, const f32 t) {
f32 d = b - a;
if (d > 180.f) {
d -= 360.f;
} else if (d < -180.f) {
d += 360.f;
}
return a + d * t;
}
#endif #endif
+2
View File
@@ -51,6 +51,8 @@ s32 videoGetMSAA(void);
f32 videoGetAverageFPS(void); f32 videoGetAverageFPS(void);
f64 videoGetLastRenderTime(void); f64 videoGetLastRenderTime(void);
void videoCapFramerate(s32 limit);
void videoSetWindowOffset(s32 x, s32 y); void videoSetWindowOffset(s32 x, s32 y);
void videoSetFullscreen(s32 fs); void videoSetFullscreen(s32 fs);
void videoSetFullscreenMode(s32 mode); void videoSetFullscreenMode(s32 mode);
+220
View File
@@ -0,0 +1,220 @@
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <ctype.h>
#include "platform.h"
#include "types.h"
#include "constants.h"
#include "data.h"
#include "bss.h"
#include "config.h"
#include "video.h"
#include "input.h"
#include "console.h"
#include "system.h"
#include "utils.h"
#include "net/net.h"
#include "game/hudmsg.h"
#include "game/game_1531a0.h"
#include "lib/vi.h"
#define CON_ROWS 80
#define CON_COLS 56
#define CON_VISROWS 10
#define CON_MSGROWS 4
#define CON_MSGTIMER 3.f
static char conBuf[CON_ROWS][CON_COLS + 1];
static char conInput[CON_COLS + 1];
static char *conVisRows[CON_VISROWS];
static s32 conPrintRow = 0;
static s32 conPrintCol = 0;
static s32 conMsgRows = 0;
static f32 conMsgTimer = 0.f;
static s32 conInputCol = 0;
static u32 conTextColour = 0x00ff00ff;
static s32 conOpen = 0;
static s32 conButton = 0;
void conInit(void)
{
memset(conBuf, 0, sizeof(conBuf));
memset(conInput, 0, sizeof(conInput));
memset(conVisRows, 0, sizeof(conVisRows));
conPrintRow = conPrintCol = 0;
conOpen = 0;
conMsgRows = 0;
conMsgTimer = 0.0f;
conInputCol = 0;
}
void conPrint(s32 showmsg, const char *str)
{
if (!str || !*str) {
return;
}
const s32 oldRow = conPrintRow;
for (const char *s = str; *s; ++s) {
char ch = *s;
switch (ch) {
case '\n':
if (conPrintCol) {
conPrintCol = 0;
conPrintRow = (conPrintRow + 1) % CON_ROWS;
}
break;
case '\r':
break;
case '\t':
ch = ' ';
/* fallthrough */
default:
conBuf[conPrintRow][conPrintCol++] = ch;
if (conPrintCol == CON_COLS) {
conPrintCol = 0;
conPrintRow = (conPrintRow + 1) % CON_ROWS;
}
break;
}
conBuf[conPrintRow][conPrintCol] = '\0';
}
if (conPrintRow != oldRow) {
// scroll time
for (s32 i = 0; i < ARRAYCOUNT(conVisRows); ++i) {
s32 row = conPrintRow - i - 1;
if (row < 0) {
row = CON_ROWS + row;
}
conVisRows[i] = &conBuf[row][0];
}
if (showmsg) {
if (conMsgRows < CON_MSGROWS) {
if (conPrintRow > oldRow) {
conMsgRows += conPrintRow - oldRow;
} else {
conMsgRows += conPrintRow + (CON_ROWS - oldRow);
}
}
conMsgTimer = sysGetSeconds() + CON_MSGTIMER;
}
}
}
void conPrintLn(s32 showmsg, const char *s)
{
char tmp[4096];
snprintf(tmp, sizeof(tmp), "%s\n", s);
conPrint(showmsg, tmp);
}
void conPrintf(s32 showmsg, const char *fmt, ...)
{
char tmp[4096];
tmp[sizeof(tmp) - 1] = '\0';
tmp[0] = '\0';
va_list args;
va_start(args, fmt);
vsnprintf(tmp, sizeof(tmp), fmt, args);
va_end(args);
conPrint(showmsg, tmp);
}
static inline Gfx *conRenderMsgs(Gfx *gdl)
{
if (conMsgRows) {
s32 x, y;
const u32 c = (conTextColour & 0xffffff00) | 0xa0;
for (s32 i = 0; i < conMsgRows; ++i) {
char *s = conVisRows[i];
if (s) {
x = 4;
y = 4 + 8 * (conMsgRows - i - 1);
gdl = textRenderProjected(gdl, &x, &y, s, g_CharsHandelGothicXs, g_FontHandelGothicXs, c, viGetWidth(), viGetHeight(), 0, 0);
}
}
const f32 t = sysGetSeconds();
if (conMsgTimer <= t) {
conMsgTimer = t + CON_MSGTIMER;
--conMsgRows;
}
} else {
conMsgTimer = 0;
}
return gdl;
}
Gfx *conRender(Gfx *gdl)
{
if (!g_CharsHandelGothicXs || !g_FontHandelGothicXs) {
return gdl;
}
gdl = text0f153628(gdl);
if (!conOpen) {
gSPExtraGeometryModeEXT(gdl++, G_ASPECT_MODE_EXT, G_ASPECT_LEFT_EXT);
gdl = conRenderMsgs(gdl);
} else {
s32 x, y;
gSPExtraGeometryModeEXT(gdl++, G_ASPECT_MODE_EXT, G_ASPECT_CENTER_EXT);
gdl = hudmsgRenderBox(gdl, 16, 0, SCREEN_WIDTH_LO - 16, 4 + 8 * (CON_VISROWS + 1), 1.f, conTextColour, 0.9f);
for (s32 i = 0; i < CON_VISROWS; ++i) {
char *s = conVisRows[i];
if (s) {
x = 18;
y = 4 + 8 * (CON_VISROWS - i - 1);
gdl = textRenderProjected(gdl, &x, &y, s, g_CharsHandelGothicXs, g_FontHandelGothicXs, conTextColour, viGetWidth(), viGetHeight(), 0, 0);
}
}
char tmp[CON_COLS + 3];
snprintf(tmp, sizeof(tmp), "> %s", conInput);
x = 18;
y = 4 + 8 * CON_VISROWS;
gdl = textRenderProjected(gdl, &x, &y, tmp, g_CharsHandelGothicXs, g_FontHandelGothicXs, conTextColour, viGetWidth(), viGetHeight(), 0, 0);
}
gSPClearExtraGeometryModeEXT(gdl++, G_ASPECT_MODE_EXT);
gdl = text0f153780(gdl);
return gdl;
}
void conTick(void)
{
const s32 button = inputKeyPressed(VK_GRAVE);
if (button && !conButton) {
conOpen = !conOpen;
g_MenuKeyboardPlayer = -1;
if (conOpen) {
inputClearLastTextChar();
inputStartTextInput();
} else {
inputStopTextInput();
}
}
conButton = button;
if (conOpen) {
if (inputTextHandler(conInput, CON_COLS, &conInputCol, false)) {
if (g_NetMode) {
netChat(NULL, conInput);
}
conInput[0] = '\0';
conInputCol = 0;
}
}
}
s32 conIsOpen(void)
{
return conOpen;
}
+18 -3
View File
@@ -16,7 +16,9 @@
#include "config.h" #include "config.h"
#include "mod.h" #include "mod.h"
#include "system.h" #include "system.h"
#include "console.h"
#include "utils.h" #include "utils.h"
#include "net/net.h"
u32 g_OsMemSize = 0; u32 g_OsMemSize = 0;
s32 g_OsMemSizeMb = 16; s32 g_OsMemSizeMb = 16;
@@ -69,7 +71,7 @@ static void gameInit(void)
{ {
osMemSize = g_OsMemSizeMb * 1024 * 1024; osMemSize = g_OsMemSizeMb * 1024 * 1024;
for (s32 i = 0; i < MAX_PLAYERS; ++i) { for (s32 i = 0; i < MAX_LOCAL_PLAYERS; ++i) {
struct extplayerconfig *cfg = g_PlayerExtCfg + i; struct extplayerconfig *cfg = g_PlayerExtCfg + i;
cfg->fovzoommult = cfg->fovzoom ? cfg->fovy / 60.0f : 1.0f; cfg->fovzoommult = cfg->fovzoom ? cfg->fovy / 60.0f : 1.0f;
} }
@@ -86,6 +88,7 @@ static void gameInit(void)
static void cleanup(void) static void cleanup(void)
{ {
sysLogPrintf(LOG_NOTE, "shutdown"); sysLogPrintf(LOG_NOTE, "shutdown");
netDisconnect();
inputSaveBinds(); inputSaveBinds();
configSave(CONFIG_PATH); configSave(CONFIG_PATH);
videoShutdown(); videoShutdown();
@@ -101,6 +104,7 @@ int main(int argc, const char **argv)
crashInit(); crashInit();
} }
conInit();
sysInit(); sysInit();
fsInit(); fsInit();
configInit(); configInit();
@@ -108,6 +112,7 @@ int main(int argc, const char **argv)
inputInit(); inputInit();
audioInit(); audioInit();
romdataInit(); romdataInit();
netInit();
g_ValidGbcRomFound = romdataCheckGbcRom(); g_ValidGbcRomFound = romdataCheckGbcRom();
@@ -136,6 +141,8 @@ int main(int argc, const char **argv)
g_StageNum = sysArgGetInt("--boot-stage", STAGE_TITLE); g_StageNum = sysArgGetInt("--boot-stage", STAGE_TITLE);
g_FileAutoSelect = sysArgGetInt("--profile", -1);
if (g_StageNum == STAGE_TITLE && (sysArgCheck("--skip-intro") || g_SkipIntro)) { if (g_StageNum == STAGE_TITLE && (sysArgCheck("--skip-intro") || g_SkipIntro)) {
// shorthand for --boot-stage 0x26 // shorthand for --boot-stage 0x26
g_StageNum = STAGE_CITRAINING; g_StageNum = STAGE_CITRAINING;
@@ -144,11 +151,19 @@ int main(int argc, const char **argv)
g_StageNum = STAGE_TITLE; g_StageNum = STAGE_TITLE;
} }
if (g_NetJoinLatch || g_NetHostLatch) {
if (g_FileAutoSelect < 0) {
// default to profile 0 if going into a net game
g_FileAutoSelect = 0;
}
// skip the intro if going into a net game
g_StageNum = STAGE_CITRAINING;
}
if (g_StageNum != STAGE_TITLE) { if (g_StageNum != STAGE_TITLE) {
sysLogPrintf(LOG_NOTE, "boot stage set to 0x%02x", g_StageNum); sysLogPrintf(LOG_NOTE, "boot stage set to 0x%02x", g_StageNum);
} }
g_FileAutoSelect = sysArgGetInt("--profile", -1);
if (g_FileAutoSelect >= 0) { if (g_FileAutoSelect >= 0) {
sysLogPrintf(LOG_NOTE, "player profile set to %d", g_FileAutoSelect); sysLogPrintf(LOG_NOTE, "player profile set to %d", g_FileAutoSelect);
} }
@@ -169,7 +184,7 @@ PD_CONSTRUCTOR static void gameConfigInit(void)
configRegisterInt("Game.SkipIntro", &g_SkipIntro, 0, 1); configRegisterInt("Game.SkipIntro", &g_SkipIntro, 0, 1);
configRegisterInt("Game.DisableMpDeathMusic", &g_MusicDisableMpDeath, 0, 1); configRegisterInt("Game.DisableMpDeathMusic", &g_MusicDisableMpDeath, 0, 1);
configRegisterInt("Game.GEMuzzleFlashes", &g_BgunGeMuzzleFlashes, 0, 1); configRegisterInt("Game.GEMuzzleFlashes", &g_BgunGeMuzzleFlashes, 0, 1);
for (s32 j = 0; j < MAX_PLAYERS; ++j) { for (s32 j = 0; j < MAX_LOCAL_PLAYERS; ++j) {
const s32 i = j + 1; const s32 i = j + 1;
configRegisterFloat(strFmt("Game.Player%d.FovY", i), &g_PlayerExtCfg[j].fovy, 5.f, 175.f); configRegisterFloat(strFmt("Game.Player%d.FovY", i), &g_PlayerExtCfg[j].fovy, 5.f, 175.f);
configRegisterInt(strFmt("Game.Player%d.FovAffectsZoom", i), &g_PlayerExtCfg[j].fovzoom, 0, 1); configRegisterInt(strFmt("Game.Player%d.FovAffectsZoom", i), &g_PlayerExtCfg[j].fovzoom, 0, 1);
-1
View File
@@ -6,7 +6,6 @@
#include "mixer.h" #include "mixer.h"
#include "platform.h" #include "platform.h"
#define MINIMP3_IMPLEMENTATION
#include "external/minimp3.h" #include "external/minimp3.h"
#ifdef __SSE4_1__ #ifdef __SSE4_1__
+1127
View File
File diff suppressed because it is too large. Load diff
+305
View File
@@ -0,0 +1,305 @@
#include <string.h>
#include "types.h"
#include "platform.h"
#include "system.h"
#include "net/netbuf.h"
/* read */
void netbufStartRead(struct netbuf *buf)
{
buf->error = 0;
buf->wp = buf->size;
buf->rp = 0;
}
void netbufStartReadData(struct netbuf *buf, const void *data, u32 size)
{
buf->size = size;
buf->data = (void *)data;
netbufStartRead(buf);
}
s32 netbufReadLeft(const struct netbuf *buf)
{
return buf->wp - buf->rp;
}
static inline u32 netbufCanRead(struct netbuf *buf, const u32 num)
{
if (buf->error || buf->rp + num > buf->wp) {
sysLogPrintf(LOG_ERROR, "NET: could not read %u bytes", num);
__builtin_trap();
buf->error = 1;
return false;
}
return true;
}
u32 netbufReadData(struct netbuf *buf, void *out, u32 num)
{
if (netbufCanRead(buf, num)) {
memcpy(out, buf->data + buf->rp, num);
buf->rp += num;
return num;
}
return 0;
}
u8 netbufReadU8(struct netbuf *buf)
{
if (netbufCanRead(buf, 1)) {
return buf->data[buf->rp++];
}
return 0;
}
u16 netbufReadU16(struct netbuf *buf)
{
if (netbufCanRead(buf, 2)) {
const u16 ret = *(u16 *)&buf->data[buf->rp];
buf->rp += sizeof(ret);
return PD_LE16(ret);
}
return 0;
}
u32 netbufReadU32(struct netbuf *buf)
{
if (netbufCanRead(buf, 4)) {
const u32 ret = *(u32 *)&buf->data[buf->rp];
buf->rp += sizeof(ret);
return PD_LE32(ret);
}
return 0;
}
u64 netbufReadU64(struct netbuf *buf)
{
if (netbufCanRead(buf, 8)) {
const u64 ret = *(u64 *)&buf->data[buf->rp];
buf->rp += sizeof(ret);
return PD_LE64(ret);
}
return 0;
}
s8 netbufReadS8(struct netbuf *buf) {
return (s8)netbufReadU8(buf);
}
s16 netbufReadS16(struct netbuf *buf) {
return (s16)netbufReadU16(buf);
}
s32 netbufReadS32(struct netbuf *buf) {
return (s32)netbufReadU32(buf);
}
s64 netbufReadS64(struct netbuf *buf) {
return (s64)netbufReadU64(buf);
}
f32 netbufReadF32(struct netbuf *buf)
{
union {
f32 f;
u32 i;
} hack;
hack.i = netbufReadU32(buf);
return hack.f;
}
char *netbufReadStr(struct netbuf *buf)
{
const u16 len = netbufReadU16(buf);
if (netbufCanRead(buf, len)) {
char *ret = (char *)&buf->data[buf->rp];
buf->rp += len;
return ret;
}
return NULL;
}
u32 netbufReadCoord(struct netbuf *buf, struct coord *out)
{
if (netbufCanRead(buf, sizeof(*out))) {
out->x = netbufReadF32(buf);
out->y = netbufReadF32(buf);
out->z = netbufReadF32(buf);
return sizeof(*out);
}
return 0;
}
u32 netbufReadMtxf(struct netbuf *buf, Mtxf *out)
{
if (netbufCanRead(buf, sizeof(*out))) {
for (s32 i = 0; i < 4; ++i) {
for (s32 j = 0; j < 4; ++j) {
out->m[i][j] = netbufReadF32(buf);
}
}
return sizeof(*out);
}
return 0;
}
u32 netbufReadSkip(struct netbuf *buf, u32 count)
{
if (netbufCanRead(buf, count)) {
buf->rp += count;
return count;
}
return 0;
}
/* write */
void netbufStartWrite(struct netbuf *buf)
{
buf->wp = 0;
buf->error = 0;
}
static inline u32 netbufCanWrite(struct netbuf *buf, const u32 num)
{
if (buf->error || buf->wp + num > buf->size) {
buf->error = 1;
return false;
}
return true;
}
s32 netbufWriteLeft(const struct netbuf *buf)
{
return buf->size - buf->wp;
}
u32 netbufWriteData(struct netbuf *buf, const void *data, u32 num)
{
if (netbufCanWrite(buf, num)) {
memcpy(buf->data + buf->wp, data, num);
buf->wp += num;
return num;
}
return 0;
}
u32 netbufWriteU8(struct netbuf *buf, const u8 v)
{
if (netbufCanWrite(buf, sizeof(v))) {
buf->data[buf->wp++] = v;
return sizeof(v);
}
return 0;
}
u32 netbufWriteU16(struct netbuf *buf, const u16 v)
{
if (netbufCanWrite(buf, sizeof(v))) {
*(u16 *)&buf->data[buf->wp] = PD_LE16(v);
buf->wp += sizeof(v);
return sizeof(v);
}
return 0;
}
u32 netbufWriteU32(struct netbuf *buf, const u32 v)
{
if (netbufCanWrite(buf, sizeof(v))) {
*(u32 *)&buf->data[buf->wp] = PD_LE32(v);
buf->wp += sizeof(v);
return sizeof(v);
}
return 0;
}
u32 netbufWriteU64(struct netbuf *buf, const u64 v)
{
if (netbufCanWrite(buf, sizeof(v))) {
*(u64 *)&buf->data[buf->wp] = PD_LE64(v);
buf->wp += sizeof(v);
return sizeof(v);
}
return 0;
}
u32 netbufWriteS8(struct netbuf *buf, const s8 v)
{
return netbufWriteU8(buf, (u8)v);
}
u32 netbufWriteS16(struct netbuf *buf, const s16 v)
{
return netbufWriteU16(buf, (u16)v);
}
u32 netbufWriteS32(struct netbuf *buf, const s32 v)
{
return netbufWriteU32(buf, (u32)v);
}
u32 netbufWriteS64(struct netbuf *buf, const s64 v)
{
return netbufWriteU64(buf, (u64)v);
}
u32 netbufWriteF32(struct netbuf *buf, const f32 v)
{
const union {
f32 f;
u32 i;
} hack = { .f = v };
return netbufWriteU32(buf, hack.i);
}
u32 netbufWriteStr(struct netbuf *buf, const char *v)
{
if (!v) {
return 0;
}
u32 len = strlen(v) + 1;
if (len > 0xFFFF) {
len = 0xFFFF;
}
if (netbufCanWrite(buf, len + sizeof(u16))) {
netbufWriteU16(buf, len);
netbufWriteData(buf, v, len);
buf->data[buf->wp - 1] = 0;
return sizeof(u16) + len;
}
return 0;
}
u32 netbufWriteCoord(struct netbuf *buf, const struct coord *v)
{
if (netbufCanWrite(buf, sizeof(*v))) {
netbufWriteF32(buf, v->x);
netbufWriteF32(buf, v->y);
netbufWriteF32(buf, v->z);
return sizeof(*v);
}
return 0;
}
u32 netbufWriteMtxf(struct netbuf *buf, const Mtxf *in)
{
if (netbufCanWrite(buf, sizeof(*in))) {
for (s32 i = 0; i < 4; ++i) {
for (s32 j = 0; j < 4; ++j) {
netbufWriteF32(buf, in->m[i][j]);
}
}
return sizeof(*in);
}
return 0;
}
void netbufReset(struct netbuf *buf)
{
memset(buf, 0, sizeof(*buf));
}
+422
View File
@@ -0,0 +1,422 @@
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <PR/ultratypes.h>
#include "platform.h"
#include "data.h"
#include "types.h"
#include "game/mainmenu.h"
#include "game/menu.h"
#include "game/gamefile.h"
#include "game/filelist.h"
#include "video.h"
#include "input.h"
#include "config.h"
#include "mpsetups.h"
#include "net/net.h"
extern MenuItemHandlerResult menuhandlerMainMenuCombatSimulator(s32 operation, struct menuitem *item, union handlerdata *data);
extern MenuItemHandlerResult menuhandlerMpAdvancedSetup(s32 operation, struct menuitem *item, union handlerdata *data);
extern struct menuitem g_MpPlayerSetup234MenuItems[];
extern struct menudialogdef g_NetJoinPlayerSetupMenuDialog;
static s32 g_NetMenuMaxPlayers = NET_MAX_CLIENTS;
static s32 g_NetMenuPort = NET_DEFAULT_PORT;
static char g_NetJoinAddr[NET_MAX_ADDR + 1];
static s32 g_NetJoinAddrPtr = 0;
/* host */
static MenuItemHandlerResult menuhandlerHostMaxPlayers(s32 operation, struct menuitem *item, union handlerdata *data)
{
switch (operation) {
case MENUOP_GETSLIDER:
data->slider.value = g_NetMenuMaxPlayers;
break;
case MENUOP_SET:
if (data->slider.value) {
g_NetMenuMaxPlayers = data->slider.value;
}
break;
}
return 0;
}
static MenuItemHandlerResult menuhandlerHostPort(s32 operation, struct menuitem *item, union handlerdata *data)
{
if (operation == MENUOP_SET) {
}
return 0;
}
static char *menuhandlerHostPortValue(struct menuitem *item)
{
static char tmp[16];
snprintf(tmp, sizeof(tmp), "%u\n", g_NetMenuPort);
return tmp;
}
MenuItemHandlerResult menuhandlerHostStart(s32 operation, struct menuitem *item, union handlerdata *data)
{
if (operation == MENUOP_SET) {
if (netStartServer(g_NetMenuPort, g_NetMenuMaxPlayers) == 0) {
// load the setup file when entering the Combat Simulator
mpsetupCopyAllFromPak();
mpsetupLoadCurrentFile();
menuhandlerMainMenuCombatSimulator(MENUOP_SET, NULL, NULL);
menuhandlerMpAdvancedSetup(MENUOP_SET, NULL, NULL);
}
}
return 0;
}
struct menuitem g_NetHostMenuItems[] = {
{
MENUITEMTYPE_SLIDER,
0,
MENUITEMFLAG_LITERAL_TEXT,
(uintptr_t)"Max Players",
NET_MAX_CLIENTS,
menuhandlerHostMaxPlayers,
},
{
MENUITEMTYPE_SELECTABLE,
0,
MENUITEMFLAG_LITERAL_TEXT,
(uintptr_t)"Port\n",
(uintptr_t)&menuhandlerHostPortValue,
menuhandlerHostPort,
},
{
MENUITEMTYPE_SELECTABLE,
0,
0,
L_MPMENU_036, // "Start Game"
0,
menuhandlerHostStart,
},
{
MENUITEMTYPE_SEPARATOR,
0,
0,
0,
0,
NULL,
},
{
MENUITEMTYPE_SELECTABLE,
0,
MENUITEMFLAG_SELECTABLE_CLOSESDIALOG,
L_OPTIONS_213, // "Back"
0,
NULL,
},
{ MENUITEMTYPE_END },
};
struct menudialogdef g_NetHostMenuDialog = {
MENUDIALOGTYPE_DEFAULT,
(uintptr_t)"Host Network Game",
g_NetHostMenuItems,
NULL,
MENUDIALOGFLAG_LITERAL_TEXT | MENUDIALOGFLAG_STARTSELECTS,
NULL,
};
/* join */
static const char *menutextJoinAddress(struct menuitem *item)
{
static char tmp[256 + 1];
if (item && item->flags & MENUITEMFLAG_SELECTABLE_CENTRE) {
// in centered dialog
if (g_NetMode == NETMODE_NONE) {
snprintf(tmp, sizeof(tmp), "%s_\n", g_NetJoinAddr);
} else if (g_NetLocalClient->state == CLSTATE_CONNECTING) {
snprintf(tmp, sizeof(tmp), "Connecting to %s...\n", g_NetJoinAddr);
} else if (g_NetLocalClient->state == CLSTATE_AUTH) {
snprintf(tmp, sizeof(tmp), "Authenticating with %s...\n", g_NetJoinAddr);
} else if (g_NetLocalClient->state == CLSTATE_LOBBY) {
snprintf(tmp, sizeof(tmp), "Waiting for host...\n");
}
} else {
// label
snprintf(tmp, sizeof(tmp), "%s\n", g_NetJoinAddr);
}
return tmp;
}
static MenuItemHandlerResult menuhandlerJoining(s32 operation, struct menuitem *item, union handlerdata *data)
{
if (inputKeyPressed(VK_ESCAPE)) {
netDisconnect();
menuPopDialog();
}
return 0;
}
struct menuitem g_NetJoiningMenuItems[] = {
{
MENUITEMTYPE_LABEL,
0,
MENUITEMFLAG_SELECTABLE_CENTRE,
(uintptr_t)&menutextJoinAddress,
0,
NULL,
},
{
MENUITEMTYPE_SEPARATOR,
0,
0,
0,
0,
NULL,
},
{
MENUITEMTYPE_SELECTABLE,
0,
MENUITEMFLAG_SELECTABLE_CENTRE | MENUITEMFLAG_LITERAL_TEXT,
(uintptr_t)"ESC to abort\n",
0,
menuhandlerJoining,
},
{ MENUITEMTYPE_END },
};
struct menudialogdef g_NetJoiningDialog = {
MENUDIALOGTYPE_SUCCESS,
(uintptr_t)"Joining Game...",
g_NetJoiningMenuItems,
NULL,
MENUDIALOGFLAG_LITERAL_TEXT | MENUDIALOGFLAG_IGNOREBACK | MENUDIALOGFLAG_STARTSELECTS,
NULL,
};
static MenuItemHandlerResult menuhandlerEnterJoinAddress(s32 operation, struct menuitem *item, union handlerdata *data);
struct menuitem g_NetJoinAddressMenuItems[] = {
{
MENUITEMTYPE_LABEL,
0,
MENUITEMFLAG_SELECTABLE_CENTRE,
(uintptr_t)&menutextJoinAddress,
0,
NULL,
},
{
MENUITEMTYPE_SEPARATOR,
0,
0,
0,
0,
NULL,
},
{
MENUITEMTYPE_SELECTABLE,
0,
MENUITEMFLAG_SELECTABLE_CENTRE | MENUITEMFLAG_LITERAL_TEXT,
(uintptr_t)"ESC to return\n",
0,
menuhandlerEnterJoinAddress,
},
{ MENUITEMTYPE_END },
};
struct menudialogdef g_NetJoinAddressDialog = {
MENUDIALOGTYPE_SUCCESS,
(uintptr_t)"Enter Address",
g_NetJoinAddressMenuItems,
NULL,
MENUDIALOGFLAG_LITERAL_TEXT | MENUDIALOGFLAG_IGNOREBACK | MENUDIALOGFLAG_STARTSELECTS,
NULL,
};
static MenuItemHandlerResult menuhandlerEnterJoinAddress(s32 operation, struct menuitem *item, union handlerdata *data)
{
if (!menuIsDialogOpen(&g_NetJoinAddressDialog)) {
return 0;
}
if (inputTextHandler(g_NetJoinAddr, NET_MAX_ADDR, &g_NetJoinAddrPtr, false) < 0) {
// escape has been pressed, stop editing
inputStopTextInput();
menuPopDialog();
}
return 0;
}
static MenuItemHandlerResult menuhandlerJoinAddress(s32 operation, struct menuitem *item, union handlerdata *data)
{
if (operation == MENUOP_SET) {
inputClearLastKey();
inputClearLastTextChar();
inputStartTextInput();
g_NetJoinAddrPtr = strlen(g_NetJoinAddr);
menuPushDialog(&g_NetJoinAddressDialog);
}
return 0;
}
MenuItemHandlerResult menuhandlerJoinStart(s32 operation, struct menuitem *item, union handlerdata *data)
{
if (operation == MENUOP_SET) {
if (netStartClient(g_NetJoinAddr) == 0) {
menuPushDialog(&g_NetJoiningDialog);
}
}
return 0;
}
static MenuItemHandlerResult menuhandlerJoinPlayerSetup(s32 operation, struct menuitem *item, union handlerdata *data)
{
if (operation == MENUOP_SET) {
// load MP player file
filelistCreate(0, FILETYPE_MPPLAYER);
filelistsTick();
menuPushDialog(&g_NetJoinPlayerSetupMenuDialog);
}
return 0;
}
struct menuitem g_NetJoinMenuItems[] = {
{
MENUITEMTYPE_SELECTABLE,
0,
MENUITEMFLAG_LITERAL_TEXT,
(uintptr_t)"Address: \n",
(uintptr_t)&menutextJoinAddress,
menuhandlerJoinAddress,
},
{
MENUITEMTYPE_SELECTABLE,
0,
0,
L_MPMENU_028, // "Player Setup"
0,
menuhandlerJoinPlayerSetup,
},
{
MENUITEMTYPE_SELECTABLE,
0,
0,
L_MPMENU_036, // "Start Game"
0,
menuhandlerJoinStart,
},
{
MENUITEMTYPE_SEPARATOR,
0,
0,
0,
0,
NULL,
},
{
MENUITEMTYPE_SELECTABLE,
0,
MENUITEMFLAG_SELECTABLE_CLOSESDIALOG,
L_OPTIONS_213, // "Back"
0,
NULL,
},
{ MENUITEMTYPE_END },
};
struct menudialogdef g_NetJoinMenuDialog = {
MENUDIALOGTYPE_DEFAULT,
(uintptr_t)"Join Network Game",
g_NetJoinMenuItems,
NULL,
MENUDIALOGFLAG_LITERAL_TEXT | MENUDIALOGFLAG_STARTSELECTS,
NULL,
};
/* main */
MenuItemHandlerResult menuhandlerHostGame(s32 operation, struct menuitem *item, union handlerdata *data)
{
if (operation == MENUOP_SET) {
g_NetMenuPort = g_NetServerPort;
g_NetMenuMaxPlayers = g_NetMaxClients;
menuPushDialog(&g_NetHostMenuDialog);
}
return 0;
}
MenuItemHandlerResult menuhandlerJoinGame(s32 operation, struct menuitem *item, union handlerdata *data)
{
if (operation == MENUOP_SET) {
if (g_NetJoinAddr[0] == '\0') {
strncpy(g_NetJoinAddr, g_NetLastJoinAddr, NET_MAX_ADDR);
g_NetJoinAddrPtr = strlen(g_NetJoinAddr);
}
menuPushDialog(&g_NetJoinMenuDialog);
}
return 0;
}
struct menuitem g_NetMenuItems[] = {
{
MENUITEMTYPE_SELECTABLE,
0,
MENUITEMFLAG_LITERAL_TEXT,
(uintptr_t)"Host Game\n",
0,
menuhandlerHostGame,
},
{
MENUITEMTYPE_SELECTABLE,
0,
MENUITEMFLAG_LITERAL_TEXT,
(uintptr_t)"Join Game\n",
0,
menuhandlerJoinGame,
},
{
MENUITEMTYPE_SEPARATOR,
0,
0,
0,
0,
NULL,
},
{
MENUITEMTYPE_SELECTABLE,
0,
MENUITEMFLAG_SELECTABLE_CLOSESDIALOG,
L_OPTIONS_213, // "Back"
0,
NULL,
},
{ MENUITEMTYPE_END },
};
struct menudialogdef g_NetMenuDialog = {
MENUDIALOGTYPE_DEFAULT,
(uintptr_t)"Network Game",
g_NetMenuItems,
NULL,
MENUDIALOGFLAG_MPLOCKABLE | MENUDIALOGFLAG_LITERAL_TEXT | MENUDIALOGFLAG_STARTSELECTS,
NULL,
};
struct menudialogdef g_NetJoinPlayerSetupMenuDialog = {
MENUDIALOGTYPE_DEFAULT,
L_MPMENU_028, // "Player Setup"
g_MpPlayerSetup234MenuItems,
NULL,
MENUDIALOGFLAG_DROPOUTONCLOSE | MENUDIALOGFLAG_STARTSELECTS,
NULL,
};
File diff suppressed because it is too large. Load diff
+23 -12
View File
@@ -73,6 +73,9 @@
#include "data.h" #include "data.h"
#include "types.h" #include "types.h"
#include "system.h" #include "system.h"
#include "console.h"
#include "net/net.h"
#include "net/netmsg.h"
extern u8 *g_MempHeap; extern u8 *g_MempHeap;
extern u32 g_MempHeapSize; extern u32 g_MempHeapSize;
@@ -421,6 +424,9 @@ void mainLoop(void)
if (argFindByPrefix(1, "-ma")) { if (argFindByPrefix(1, "-ma")) {
g_MainMemaHeapSize = strtol(argFindByPrefix(1, "-ma"), NULL, 0) * 1024; g_MainMemaHeapSize = strtol(argFindByPrefix(1, "-ma"), NULL, 0) * 1024;
if (g_NetMode && g_NetMaxClients > MAX_LOCAL_PLAYERS) {
g_MainMemaHeapSize *= MAX_PLAYERS / MAX_LOCAL_PLAYERS;
}
} }
memaReset(mempAlloc(g_MainMemaHeapSize, MEMPOOL_STAGE), g_MainMemaHeapSize); memaReset(mempAlloc(g_MainMemaHeapSize, MEMPOOL_STAGE), g_MainMemaHeapSize);
@@ -462,7 +468,15 @@ void mainLoop(void)
} }
if (g_Vars.coopplayernum >= 0 || g_Vars.antiplayernum >= 0) { if (g_Vars.coopplayernum >= 0 || g_Vars.antiplayernum >= 0) {
#ifdef PLATFORM_N64
g_MpSetup.chrslots = 0x03; g_MpSetup.chrslots = 0x03;
#else
if (g_Vars.antiplayernum < 0) {
// Counter-Operative now uses a different approach which allows more than 2 players.
// Co-Operative, on the other hand, is currently limited to 2 players.
g_MpSetup.chrslots = 0x03;
}
#endif
mpReset(); mpReset();
} else if (g_Vars.perfectbuddynum) { } else if (g_Vars.perfectbuddynum) {
mpReset(); mpReset();
@@ -470,16 +484,8 @@ void mainLoop(void)
&& (numplayers >= 2 || g_Vars.lvmpbotlevel || argFindByPrefix(1, "-play"))) { && (numplayers >= 2 || g_Vars.lvmpbotlevel || argFindByPrefix(1, "-play"))) {
g_MpSetup.chrslots = 1; g_MpSetup.chrslots = 1;
if (numplayers >= 2) { for (s32 i = 1; i < numplayers; ++i) {
g_MpSetup.chrslots |= 1 << 1; g_MpSetup.chrslots |= 1 << i;
}
if (numplayers >= 3) {
g_MpSetup.chrslots |= 1 << 2;
}
if (numplayers >= 4) {
g_MpSetup.chrslots |= 1 << 3;
} }
g_MpSetup.stagenum = g_StageNum; g_MpSetup.stagenum = g_StageNum;
@@ -563,6 +569,9 @@ void mainTick(void)
gdl = profileRender(gdl); gdl = profileRender(gdl);
} }
gdl = conRender(gdl);
gdl = netDebugRender(gdl);
gDPFullSync(gdl++); gDPFullSync(gdl++);
gSPEndDisplayList(gdl++); gSPEndDisplayList(gdl++);
} }
@@ -590,7 +599,7 @@ void mainEndStage(void)
s32 prevplayernum = g_Vars.currentplayernum; s32 prevplayernum = g_Vars.currentplayernum;
s32 i; s32 i;
for (i = 0; i < PLAYERCOUNT(); i++) { for (i = 0; i < LOCALPLAYERCOUNT(); i++) {
setCurrentPlayerNum(i); setCurrentPlayerNum(i);
endscreenPushCoop(); endscreenPushCoop();
} }
@@ -601,7 +610,7 @@ void mainEndStage(void)
s32 prevplayernum = g_Vars.currentplayernum; s32 prevplayernum = g_Vars.currentplayernum;
s32 i; s32 i;
for (i = 0; i < PLAYERCOUNT(); i++) { for (i = 0; i < LOCALPLAYERCOUNT(); i++) {
setCurrentPlayerNum(i); setCurrentPlayerNum(i);
endscreenPushAnti(); endscreenPushAnti();
} }
@@ -614,6 +623,8 @@ void mainEndStage(void)
endscreenPrepare(); endscreenPrepare();
musicStartMenu(); musicStartMenu();
} }
netServerStageEnd();
} }
g_MainIsEndscreen = true; g_MainIsEndscreen = true;
+23
View File
@@ -24,7 +24,9 @@
#include "video.h" #include "video.h"
#include "audio.h" #include "audio.h"
#include "input.h" #include "input.h"
#include "console.h"
#include "mixer.h" #include "mixer.h"
#include "net/net.h"
/* /*
* private typedefs and defines * private typedefs and defines
@@ -240,6 +242,14 @@ void schedSubmitTask(OSSched *sc, OSScTask *t)
void schedStartFrame(OSSched *sc) void schedStartFrame(OSSched *sc)
{ {
videoStartFrame(); videoStartFrame();
if (g_Vars.diffframe60) {
if (g_NetMode) {
videoCapFramerate(120);
netStartFrame();
} else {
videoCapFramerate(0);
}
}
} }
void schedAudioFrame(OSSched *sc) void schedAudioFrame(OSSched *sc)
@@ -270,6 +280,8 @@ void schedAudioFrame(OSSched *sc)
*/ */
void schedEndFrame(OSSched *sc) void schedEndFrame(OSSched *sc)
{ {
static bool netDebugKey = false;
sc->frameCount++; sc->frameCount++;
#if PAL #if PAL
@@ -289,11 +301,22 @@ void schedEndFrame(OSSched *sc)
} }
inputUpdate(); inputUpdate();
conTick();
const bool newKey = inputKeyPressed(VK_F9);
if (!netDebugKey && newKey) {
g_NetDebugDraw = !g_NetDebugDraw;
}
netDebugKey = newKey;
joyStartReadData(&g_PiMesgQueue); joyStartReadData(&g_PiMesgQueue);
joyReadData(); joyReadData();
joy00014238(); joy00014238();
if (g_Vars.diffframe60) {
netEndFrame();
}
sndHandleRetrace(); sndHandleRetrace();
schedAudioFrame(sc); schedAudioFrame(sc);
schedRenderCrashPeriodically(sc->frameCount); schedRenderCrashPeriodically(sc->frameCount);
+4
View File
@@ -50,6 +50,10 @@ u8 *preprocessMpConfigs(u8* data, u32 size, u32* outSize)
PD_SWAP_VAL(cfg->setup.options); PD_SWAP_VAL(cfg->setup.options);
PD_SWAP_VAL(cfg->setup.teamscorelimit); PD_SWAP_VAL(cfg->setup.teamscorelimit);
PD_SWAP_VAL(cfg->setup.chrslots); PD_SWAP_VAL(cfg->setup.chrslots);
#if MAX_PLAYERS > 4
// make space for the extra players
cfg->setup.chrslots = (cfg->setup.chrslots & 0x000f) | ((cfg->setup.chrslots & 0x0ff0) << 4);
#endif
// TODO: are these required or are they always 0? // TODO: are these required or are they always 0?
PD_SWAP_VAL(cfg->setup.fileguid.deviceserial); PD_SWAP_VAL(cfg->setup.fileguid.deviceserial);
PD_SWAP_VAL(cfg->setup.fileguid.fileid); PD_SWAP_VAL(cfg->setup.fileguid.fileid);
+5 -5
View File
@@ -55,10 +55,10 @@
u8 *g_RomFile; u8 *g_RomFile;
u32 g_RomFileSize; u32 g_RomFileSize;
const char *g_RomName = ROMDATA_ROM_NAME;
static u8 *romDataSeg; static u8 *romDataSeg;
static u32 romDataSegSize; static u32 romDataSegSize;
static const char *romName = ROMDATA_ROM_NAME;
enum loadsource { enum loadsource {
SRC_UNLOADED = 0, SRC_UNLOADED = 0,
@@ -190,12 +190,12 @@ static inline void romdataWrongRomError(const char *fmt, ...)
static inline void romdataLoadRom(void) static inline void romdataLoadRom(void)
{ {
sysLogPrintf(LOG_NOTE, "ROM file: %s", romName); sysLogPrintf(LOG_NOTE, "ROM file: %s", g_RomName);
g_RomFile = fsFileLoad(romName, &g_RomFileSize); g_RomFile = fsFileLoad(g_RomName, &g_RomFileSize);
if (!g_RomFile) { if (!g_RomFile) {
sysFatalError("Could not open ROM file %s.\nEnsure that it is in the %s directory.", romName, fsFullPath("")); sysFatalError("Could not open ROM file %s.\nEnsure that it is in the %s directory.", g_RomName, fsFullPath(""));
} }
// zips are not guaranteed to start with PK, but might as well at least try // zips are not guaranteed to start with PK, but might as well at least try
@@ -383,7 +383,7 @@ s32 romdataInit(void)
{ {
const char *altRomName = sysArgGetString("--rom-file"); const char *altRomName = sysArgGetString("--rom-file");
if (altRomName) { if (altRomName) {
romName = altRomName; g_RomName = altRomName;
} }
romdataLoadRom(); romdataLoadRom();
+14 -2
View File
@@ -12,6 +12,7 @@
#include <SDL.h> #include <SDL.h>
#include <PR/ultratypes.h> #include <PR/ultratypes.h>
#include "platform.h" #include "platform.h"
#include "console.h"
#include "system.h" #include "system.h"
#ifdef PLATFORM_WIN32 #ifdef PLATFORM_WIN32
@@ -157,6 +158,12 @@ u64 sysGetMicroseconds(void)
return ((u64)tv.tv_sec * USEC_IN_SEC + (u64)tv.tv_usec) - startTick; return ((u64)tv.tv_sec * USEC_IN_SEC + (u64)tv.tv_usec) - startTick;
} }
float sysGetSeconds(void)
{
u64 t = sysGetMicroseconds();
return (f32)t / 1000000.f;
}
s32 sysLogIsOpen(void) s32 sysLogIsOpen(void)
{ {
return (logPath[0] != '\0'); return (logPath[0] != '\0');
@@ -183,8 +190,13 @@ void sysLogPrintf(s32 level, const char *fmt, ...)
} }
} }
FILE *fout = (level == LOG_NOTE) ? stdout : stderr; FILE *fout = ((level & 0x0f) == LOG_NOTE) ? stdout : stderr;
fprintf(fout, "%s%s\n", prefix[level], logmsg); fprintf(fout, "%s%s\n", prefix[level & 0x0f], logmsg);
fflush(fout);
if ((level & LOGFLAG_NOCON) == 0) {
conPrintLn((level & LOGFLAG_SHOWMSG) != 0, logmsg);
}
} }
void sysFatalError(const char *fmt, ...) void sysFatalError(const char *fmt, ...)
+8
View File
@@ -447,6 +447,14 @@ void videoSetDetailTextures(s32 detail)
gfx_detail_textures_enabled = (bool)texDetail; gfx_detail_textures_enabled = (bool)texDetail;
} }
void videoCapFramerate(s32 limit)
{
if (vidFramerateLimit > 0 && vidFramerateLimit < limit) {
limit = vidFramerateLimit;
}
wmAPI->set_target_fps(limit ? limit : vidFramerateLimit);
}
s32 videoCreateFramebuffer(u32 w, u32 h, s32 upscale, s32 autoresize) s32 videoCreateFramebuffer(u32 w, u32 h, s32 upscale, s32 autoresize)
{ {
return gfx_create_framebuffer(w, h, upscale, autoresize); return gfx_create_framebuffer(w, h, upscale, autoresize);
+29 -29
View File
@@ -26,7 +26,7 @@
#include "data.h" #include "data.h"
#include "types.h" #include "types.h"
struct activemenu g_AmMenus[MAX_PLAYERS]; struct activemenu g_AmMenus[MAX_LOCAL_PLAYERS];
struct fontchar *g_AmFont1; struct fontchar *g_AmFont1;
struct font *g_AmFont2; struct font *g_AmFont2;
s32 g_AmIndex; s32 g_AmIndex;
@@ -547,7 +547,7 @@ void amReset(void)
g_AmFont1 = g_CharsHandelGothicSm; g_AmFont1 = g_CharsHandelGothicSm;
g_AmFont2 = g_FontHandelGothicSm; g_AmFont2 = g_FontHandelGothicSm;
#else #else
if (PLAYERCOUNT() >= 2) { if (LOCALPLAYERCOUNT() >= 2) {
g_AmFont1 = g_CharsHandelGothicXs; g_AmFont1 = g_CharsHandelGothicXs;
g_AmFont2 = g_FontHandelGothicXs; g_AmFont2 = g_FontHandelGothicXs;
} else { } else {
@@ -578,7 +578,7 @@ s16 amCalculateSlotWidth(void)
} }
#if VERSION >= VERSION_NTSC_1_0 #if VERSION >= VERSION_NTSC_1_0
if (PLAYERCOUNT() > 1) { if (LOCALPLAYERCOUNT() > 1) {
max += 3; max += 3;
} else { } else {
max += 4; max += 4;
@@ -762,32 +762,32 @@ void amClose(void)
bool amIsCramped(void) bool amIsCramped(void)
{ {
#if VERSION == VERSION_JPN_FINAL #if VERSION == VERSION_JPN_FINAL
if (PLAYERCOUNT() >= 3 && g_AmMenus[g_AmIndex].screenindex != 1) { if (LOCALPLAYERCOUNT() >= 3 && g_AmMenus[g_AmIndex].screenindex != 1) {
return true; return true;
} }
if (IS4MB() && PLAYERCOUNT() == 2) { if (IS4MB() && LOCALPLAYERCOUNT() == 2) {
return true; return true;
} }
if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL
&& PLAYERCOUNT() == 2 && LOCALPLAYERCOUNT() == 2
&& g_AmMenus[g_AmIndex].screenindex != 1) { && g_AmMenus[g_AmIndex].screenindex != 1) {
return true; return true;
} }
return false; return false;
#else #else
return (g_AmMenus[g_AmIndex].screenindex == 0 && PLAYERCOUNT() >= 3) return (g_AmMenus[g_AmIndex].screenindex == 0 && LOCALPLAYERCOUNT() >= 3)
|| (IS4MB() && PLAYERCOUNT() == 2) || (IS4MB() && LOCALPLAYERCOUNT() == 2)
|| (PLAYERCOUNT() == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL); || (LOCALPLAYERCOUNT() == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL);
#endif #endif
} }
void amCalculateSlotPosition(s16 column, s16 row, s16 *x, s16 *y) void amCalculateSlotPosition(s16 column, s16 row, s16 *x, s16 *y)
{ {
#if VERSION == VERSION_JPN_FINAL #if VERSION == VERSION_JPN_FINAL
s32 playercount = PLAYERCOUNT(); s32 playercount = LOCALPLAYERCOUNT();
*x = g_AmMenus[g_AmIndex].xradius * (column - 1); *x = g_AmMenus[g_AmIndex].xradius * (column - 1);
*y = (row - 1) * 50; *y = (row - 1) * 50;
@@ -841,7 +841,7 @@ void amCalculateSlotPosition(s16 column, s16 row, s16 *x, s16 *y)
} }
} }
#elif VERSION >= VERSION_NTSC_1_0 #elif VERSION >= VERSION_NTSC_1_0
s32 playercount = PLAYERCOUNT(); s32 playercount = LOCALPLAYERCOUNT();
*x = g_AmMenus[g_AmIndex].xradius * (column - 1); *x = g_AmMenus[g_AmIndex].xradius * (column - 1);
*y = (row - 1) * 50; *y = (row - 1) * 50;
@@ -893,7 +893,7 @@ void amCalculateSlotPosition(s16 column, s16 row, s16 *x, s16 *y)
} }
} }
#else #else
s32 playercount = PLAYERCOUNT(); s32 playercount = LOCALPLAYERCOUNT();
*x = g_AmMenus[g_AmIndex].xradius * (column - 1); *x = g_AmMenus[g_AmIndex].xradius * (column - 1);
*y = (row - 1) * 50; *y = (row - 1) * 50;
@@ -973,15 +973,15 @@ Gfx *amRenderAibotInfo(Gfx *gdl, s32 buddynum)
#endif #endif
#if VERSION >= VERSION_NTSC_1_0 #if VERSION >= VERSION_NTSC_1_0
if (PLAYERCOUNT() == 1 && optionsGetEffectiveScreenSize() != SCREENSIZE_FULL) { if (LOCALPLAYERCOUNT() == 1 && optionsGetEffectiveScreenSize() != SCREENSIZE_FULL) {
wide = true; wide = true;
} }
#endif #endif
#if VERSION >= VERSION_NTSC_1_0 #if VERSION >= VERSION_NTSC_1_0
if ((PLAYERCOUNT() == 2 && (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL || IS4MB())) || PLAYERCOUNT() >= 3) if ((LOCALPLAYERCOUNT() == 2 && (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL || IS4MB())) || LOCALPLAYERCOUNT() >= 3)
#else #else
if ((PLAYERCOUNT() == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) || PLAYERCOUNT() >= 3) if ((LOCALPLAYERCOUNT() == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) || LOCALPLAYERCOUNT() >= 3)
#endif #endif
{ {
if ((g_Vars.currentplayernum % 2) == 0) { if ((g_Vars.currentplayernum % 2) == 0) {
@@ -1014,7 +1014,7 @@ Gfx *amRenderAibotInfo(Gfx *gdl, s32 buddynum)
- (s32)(textwidth * 0.5f) - (s32)(textwidth * 0.5f)
+ offset; + offset;
if (PLAYERCOUNT() >= 2) { if (LOCALPLAYERCOUNT() >= 2) {
y = viGetViewTop() + 5; y = viGetViewTop() + 5;
} else { } else {
y = viGetViewTop() + 10; y = viGetViewTop() + 10;
@@ -1030,12 +1030,12 @@ Gfx *amRenderAibotInfo(Gfx *gdl, s32 buddynum)
gdl = func0f1574d0jf(gdl, &x, &y, aibotname, g_AmFont1, g_AmFont2, -1, gdl = func0f1574d0jf(gdl, &x, &y, aibotname, g_AmFont1, g_AmFont2, -1,
0x000000ff, SCREEN_320, SCREEN_240, 0, 0); 0x000000ff, SCREEN_320, SCREEN_240, 0, 0);
y += (PLAYERCOUNT() >= 2) ? 0 : (s32)(textheight * 1.1f); y += (LOCALPLAYERCOUNT() >= 2) ? 0 : (s32)(textheight * 1.1f);
#else #else
gdl = textRender(gdl, &x, &y, aibotname, g_AmFont1, g_AmFont2, -1, gdl = textRender(gdl, &x, &y, aibotname, g_AmFont1, g_AmFont2, -1,
0x000000ff, SCREEN_320, SCREEN_240, 0, 0); 0x000000ff, SCREEN_320, SCREEN_240, 0, 0);
y += (PLAYERCOUNT() >= 2) ? 0 : (s32)(textheight * 1.1f); y += (LOCALPLAYERCOUNT() >= 2) ? 0 : (s32)(textheight * 1.1f);
textMeasure(&textheight, &textwidth, weaponname, g_AmFont1, g_AmFont2, 0); textMeasure(&textheight, &textwidth, weaponname, g_AmFont1, g_AmFont2, 0);
x = viGetViewLeft() / g_ScaleX x = viGetViewLeft() / g_ScaleX
@@ -1064,7 +1064,7 @@ Gfx *amRenderAibotInfo(Gfx *gdl, s32 buddynum)
- (s32)(textwidth * 0.5f) - (s32)(textwidth * 0.5f)
+ offset; + offset;
if (PLAYERCOUNT() >= 2) { if (LOCALPLAYERCOUNT() >= 2) {
y = viGetViewTop() + 5; y = viGetViewTop() + 5;
} else { } else {
y = viGetViewTop() + 10; y = viGetViewTop() + 10;
@@ -1123,7 +1123,7 @@ Gfx *amRenderSlot(Gfx *gdl, char *text, s16 x, s16 y, s32 mode, s32 flags)
paddingtop = 6; paddingtop = 6;
paddingbottom = 6; paddingbottom = 6;
if (PLAYERCOUNT() >= 2) { if (LOCALPLAYERCOUNT() >= 2) {
paddingtop = 5; paddingtop = 5;
paddingbottom = 3; paddingbottom = 3;
} }
@@ -1262,7 +1262,7 @@ Gfx *amRender(Gfx *gdl)
#endif #endif
#ifndef PLATFORM_N64 #ifndef PLATFORM_N64
const s32 playercount = PLAYERCOUNT(); const s32 playercount = LOCALPLAYERCOUNT();
if (playercount < 2 || (playercount == 2 && optionsGetScreenSplit() == SCREENSPLIT_HORIZONTAL)) { if (playercount < 2 || (playercount == 2 && optionsGetScreenSplit() == SCREENSPLIT_HORIZONTAL)) {
gSPSetExtraGeometryModeEXT(gdl++, G_ASPECT_CENTER_EXT); gSPSetExtraGeometryModeEXT(gdl++, G_ASPECT_CENTER_EXT);
} }
@@ -1487,7 +1487,7 @@ Gfx *amRender(Gfx *gdl)
above = 6; above = 6;
below = 6; below = 6;
if (PLAYERCOUNT() >= 2) { if (LOCALPLAYERCOUNT() >= 2) {
above = 5; above = 5;
below = 3; below = 3;
} }
@@ -1510,7 +1510,7 @@ Gfx *amRender(Gfx *gdl)
halfwidth = 1; halfwidth = 1;
above = 2; above = 2;
below = 0; below = 0;
} else if (PLAYERCOUNT() >= 2) { } else if (LOCALPLAYERCOUNT() >= 2) {
s32 textheight; s32 textheight;
s32 textwidth; s32 textwidth;
char text[32]; char text[32];
@@ -1592,16 +1592,16 @@ Gfx *amRender(Gfx *gdl)
} }
#endif #endif
barwidth = PLAYERCOUNT() >= 2 ? 48 : 64; barwidth = LOCALPLAYERCOUNT() >= 2 ? 48 : 64;
barheight = PLAYERCOUNT() >= 2 ? 7 : 11; barheight = LOCALPLAYERCOUNT() >= 2 ? 7 : 11;
xoffset = 0; xoffset = 0;
#if VERSION >= VERSION_NTSC_1_0 #if VERSION >= VERSION_NTSC_1_0
if ((PLAYERCOUNT() == 2 && (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL || IS4MB())) || PLAYERCOUNT() >= 3) { if ((LOCALPLAYERCOUNT() == 2 && (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL || IS4MB())) || LOCALPLAYERCOUNT() >= 3) {
xoffset = (g_Vars.currentplayernum & 1) == 0 ? 8 : -8; xoffset = (g_Vars.currentplayernum & 1) == 0 ? 8 : -8;
} }
if (PLAYERCOUNT() == 1 && optionsGetEffectiveScreenSize() != SCREENSIZE_FULL) { if (LOCALPLAYERCOUNT() == 1 && optionsGetEffectiveScreenSize() != SCREENSIZE_FULL) {
part1left = viGetViewLeft() / g_ScaleX + 32; part1left = viGetViewLeft() / g_ScaleX + 32;
} else { } else {
part1left = (s32) ((viGetViewWidth() / g_ScaleX) * 0.5f) part1left = (s32) ((viGetViewWidth() / g_ScaleX) * 0.5f)
@@ -1610,7 +1610,7 @@ Gfx *amRender(Gfx *gdl)
+ xoffset; + xoffset;
} }
#else #else
if ((PLAYERCOUNT() == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) || PLAYERCOUNT() >= 3) { if ((LOCALPLAYERCOUNT() == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) || LOCALPLAYERCOUNT() >= 3) {
xoffset = (g_Vars.currentplayernum & 1) == 0 ? 8 : -8; xoffset = (g_Vars.currentplayernum & 1) == 0 ? 8 : -8;
} }
@@ -1636,7 +1636,7 @@ Gfx *amRender(Gfx *gdl)
gDPSetRenderMode(gdl++, G_RM_XLU_SURF, G_RM_XLU_SURF2); gDPSetRenderMode(gdl++, G_RM_XLU_SURF, G_RM_XLU_SURF2);
gDPSetCombineMode(gdl++, G_CC_PRIMITIVE, G_CC_PRIMITIVE); gDPSetCombineMode(gdl++, G_CC_PRIMITIVE, G_CC_PRIMITIVE);
y = viGetViewTop() + viGetViewHeight() - (PLAYERCOUNT() >= 2 ? 19 : 34); y = viGetViewTop() + viGetViewHeight() - (LOCALPLAYERCOUNT() >= 2 ? 19 : 34);
// NTSC beta doesn't scale the health bar when hi-res is on, // NTSC beta doesn't scale the health bar when hi-res is on,
// and it only matches if part2left is an inline expression // and it only matches if part2left is an inline expression
+1 -1
View File
@@ -22,7 +22,7 @@ void amTick(void)
s32 prevplayernum = g_Vars.currentplayernum; s32 prevplayernum = g_Vars.currentplayernum;
s32 i; s32 i;
for (i = 0; i < PLAYERCOUNT(); i++) { for (i = 0; i < LOCALPLAYERCOUNT(); i++) {
setCurrentPlayerNum(i); setCurrentPlayerNum(i);
g_AmIndex = g_Vars.currentplayernum; g_AmIndex = g_Vars.currentplayernum;
+1 -1
View File
@@ -1016,7 +1016,7 @@ void eyespyProcessInput(bool allowbuttons)
// Make eyespy look horizontally // Make eyespy look horizontally
if (domovecentre) { if (domovecentre) {
if (g_Vars.currentplayer->eyespy->verta > 0.0f && forwardspeed != 0) { if (g_Vars.currentplayer->eyespy->verta > 0.0f && forwardspeed != 0) {
if (controlmode != CONTROLMODE_PC) { if (controlmode < CONTROLMODE_PC) {
if (g_Vars.currentplayer->eyespy->verta < 180.0f) { if (g_Vars.currentplayer->eyespy->verta < 180.0f) {
tmp = g_Vars.currentplayer->eyespy->verta; tmp = g_Vars.currentplayer->eyespy->verta;
+56 -6
View File
@@ -54,9 +54,11 @@
#include "data.h" #include "data.h"
#include "types.h" #include "types.h"
#ifndef PLATFORM_N64 #ifndef PLATFORM_N64
#include "platform.h"
#include "game/stagetable.h" #include "game/stagetable.h"
#include "video.h" #include "video.h"
#include "platform.h" #include "net/net.h"
#include "net/netmsg.h"
#endif #endif
#define GUNLOADSTATE_FLUX 0 #define GUNLOADSTATE_FLUX 0
@@ -4481,7 +4483,7 @@ struct defaultobj *bgunCreateThrownProjectile2(struct chrdata *chr, struct gset
* 2 = fumbling grenade from right hand (due to nbomb) * 2 = fumbling grenade from right hand (due to nbomb)
* 3 = fumbling grenade from left hand (actually not possible) * 3 = fumbling grenade from left hand (actually not possible)
*/ */
void bgunCreateThrownProjectile(s32 handnum, struct gset *gset) struct defaultobj *bgunCreateThrownProjectile(s32 handnum, struct gset *gset)
{ {
struct coord velocity = {0, 0, 0}; struct coord velocity = {0, 0, 0};
Mtxf sp1f4; Mtxf sp1f4;
@@ -4511,6 +4513,13 @@ void bgunCreateThrownProjectile(s32 handnum, struct gset *gset)
struct trainingdata *data; struct trainingdata *data;
u32 stack; u32 stack;
#ifndef PLATFORM_N64
// don't do anything if we're not the authority
if (g_NetMode == NETMODE_CLIENT) {
return NULL;
}
#endif
if (handnum >= 2) { if (handnum >= 2) {
droppinggrenade = true; droppinggrenade = true;
handnum -= 2; handnum -= 2;
@@ -4676,7 +4685,16 @@ void bgunCreateThrownProjectile(s32 handnum, struct gset *gset)
weapon->base.hidden |= OBJHFLAG_THROWNKNIFE; weapon->base.hidden |= OBJHFLAG_THROWNKNIFE;
} }
} }
#ifndef PLATFORM_N64
if (obj && g_NetMode == NETMODE_SERVER) {
netmsgSvcPropSpawnWrite(&g_NetMsgRel, obj->prop);
netmsgSvcPropMoveWrite(&g_NetMsgRel, obj->prop, NULL);
}
#endif
} }
return obj;
} }
void bgunUpdateHeldRocket(s32 handnum) void bgunUpdateHeldRocket(s32 handnum)
@@ -4780,6 +4798,12 @@ void bgunCreateFiredProjectile(s32 handnum)
f32 spd4[4]; f32 spd4[4];
f32 spc4[4]; f32 spc4[4];
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_CLIENT) {
return;
}
#endif
hand = g_Vars.currentplayer->hands + handnum; hand = g_Vars.currentplayer->hands + handnum;
playerprop = g_Vars.currentplayer->prop; playerprop = g_Vars.currentplayer->prop;
@@ -4992,6 +5016,12 @@ void bgunCreateFiredProjectile(s32 handnum)
weapon->base.prop = NULL; weapon->base.prop = NULL;
weapon->base.model = NULL; weapon->base.model = NULL;
} }
#ifndef PLATFORM_N64
else if (g_NetMode == NETMODE_SERVER) {
netmsgSvcPropSpawnWrite(&g_NetMsgRel, weapon->base.prop);
netmsgSvcPropMoveWrite(&g_NetMsgRel, weapon->base.prop, NULL);
}
#endif
#else #else
// NTSC beta doesn't have any of the failure checks // NTSC beta doesn't have any of the failure checks
Mtxf sp78; Mtxf sp78;
@@ -6322,6 +6352,13 @@ void bgunDisarm(struct prop *attackerprop)
s32 modelnum; s32 modelnum;
s32 i; s32 i;
bool drop; bool drop;
struct defaultobj *obj;
#ifndef PLATFORM_N64
// don't do anything if we're not the authority
if (g_NetMode == NETMODE_CLIENT) {
return;
}
#endif
if (!weaponHasFlag(weaponnum, WEAPONFLAG_UNDROPPABLE) && weaponnum <= WEAPON_RCP45) { if (!weaponHasFlag(weaponnum, WEAPONFLAG_UNDROPPABLE) && weaponnum <= WEAPON_RCP45) {
#if VERSION >= VERSION_NTSC_1_0 #if VERSION >= VERSION_NTSC_1_0
@@ -6339,6 +6376,12 @@ void bgunDisarm(struct prop *attackerprop)
return; return;
} }
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_SERVER) {
netmsgSvcChrDisarmWrite(&g_NetMsgRel, player->prop->chr, attackerprop, weaponnum, 0.f, NULL);
}
#endif
chr = player->prop->chr; chr = player->prop->chr;
drop = true; drop = true;
@@ -6367,7 +6410,7 @@ void bgunDisarm(struct prop *attackerprop)
&& player->hands[i].stateminor == HANDSTATEMINOR_ATTACK_THROW_0) { && player->hands[i].stateminor == HANDSTATEMINOR_ATTACK_THROW_0) {
#endif #endif
drop = false; drop = false;
bgunCreateThrownProjectile(i + 2, &player->hands[i].gset); obj = bgunCreateThrownProjectile(i + 2, &player->hands[i].gset);
} }
} }
} }
@@ -6391,6 +6434,13 @@ void bgunDisarm(struct prop *attackerprop)
} }
objDrop(prop2, true); objDrop(prop2, true);
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_SERVER) {
netmsgSvcPropSpawnWrite(&g_NetMsgRel, prop2);
netmsgSvcPropMoveWrite(&g_NetMsgRel, prop2, NULL);
}
#endif
} }
} }
@@ -11732,7 +11782,7 @@ void bgunSetTriggerOn(s32 handnum, bool on)
s32 bgunConsiderToggleGunFunction(s32 usedowntime, bool trigpressed, bool fromactivemenu, bool fromdedicatedbutton) s32 bgunConsiderToggleGunFunction(s32 usedowntime, bool trigpressed, bool fromactivemenu, bool fromdedicatedbutton)
{ {
#ifndef PLATFORM_N64 #ifndef PLATFORM_N64
const bool extcontrols = PLAYER_EXTCFG().extcontrols; const bool extcontrols = PLAYER_EXTCFG().extcontrols || g_Vars.currentplayer->isremote;
bool docontinue; bool docontinue;
#endif #endif
switch (bgunGetWeaponNum(HAND_RIGHT)) { switch (bgunGetWeaponNum(HAND_RIGHT)) {
@@ -11851,7 +11901,7 @@ void bgun0f0a8c50(void)
case WEAPON_LAPTOPGUN: case WEAPON_LAPTOPGUN:
case WEAPON_DRAGON: case WEAPON_DRAGON:
case WEAPON_REMOTEMINE: case WEAPON_REMOTEMINE:
if (PLAYER_EXTCFG().extcontrols) { if (PLAYER_EXTCFG().extcontrols || g_Vars.currentplayer->isremote) {
return; return;
} }
break; break;
@@ -12754,7 +12804,7 @@ Gfx *bgunDrawHud(Gfx *gdl)
{ {
struct player *player = g_Vars.currentplayer; struct player *player = g_Vars.currentplayer;
s32 bottom = viGetViewTop() + viGetViewHeight() - 13; s32 bottom = viGetViewTop() + viGetViewHeight() - 13;
s32 playercount = PLAYERCOUNT(); s32 playercount = LOCALPLAYERCOUNT();
s32 playernum = g_Vars.currentplayernum; s32 playernum = g_Vars.currentplayernum;
struct gunctrl *ctrl; struct gunctrl *ctrl;
s32 secs60; s32 secs60;
+210 -6
View File
@@ -42,6 +42,10 @@
#include <math.h> #include <math.h>
#include "input.h" #include "input.h"
#include "video.h" #include "video.h"
#include "system.h"
#include "utils.h"
#include "net/net.h"
#include "net/netmsg.h"
static void bgunProcessQuickDetonate(struct movedata *data, u32 c1buttons, u32 c1buttonsthisframe, u32 buttons1, u32 buttons2) { static void bgunProcessQuickDetonate(struct movedata *data, u32 c1buttons, u32 c1buttonsthisframe, u32 buttons1, u32 buttons2) {
if ((((c1buttons & (buttons1)) && (c1buttonsthisframe & (buttons2))) if ((((c1buttons & (buttons1)) && (c1buttonsthisframe & (buttons2)))
@@ -105,6 +109,159 @@ static void bgunProcessInputAltButton(struct movedata *data, s8 contpad, s32 i)
} }
} }
static inline void bmoveProcessRemoteInput(const bool allowc1buttons)
{
struct player *pl = g_Vars.currentplayer;
if (!pl->client) {
return;
}
struct netplayermove *inmove = &pl->client->inmove[0];
struct netplayermove *inmoveprev = &pl->client->inmove[1];
s32 moveticks = inmove->tick - inmoveprev->tick;
if (moveticks > g_NetInterpTicks) {
moveticks = g_NetInterpTicks;
}
const bool handled = (pl->client->inmovetick >= inmove->tick);
if (!inmove->tick) {
// no input
inmove->pos = inmoveprev->pos = pl->prop->pos;
inmove->angles[0] = inmoveprev->angles[0] = pl->vv_theta;
inmove->angles[1] = inmoveprev->angles[1] = pl->vv_verta;
inmove->ucmd = 0;
}
if (inmove->ucmd & UCMD_DUCK) {
pl->crouchpos = CROUCHPOS_DUCK;
} else if (inmove->ucmd & UCMD_SQUAT) {
pl->crouchpos = CROUCHPOS_SQUAT;
} else {
pl->crouchpos = CROUCHPOS_STAND;
}
pl->bondactivateorreload = 0;
pl->eyesshut = (inmove->ucmd & UCMD_EYESSHUT) != 0;
pl->speedtheta = 0.f; // TODO: figure out if anglespeed is even required
pl->speedverta = 0.f;
pl->crouchoffset = inmove->crouchofs;
pl->oldcrosspos[0] = pl->crosspos[0];
pl->oldcrosspos[1] = pl->crosspos[1];
pl->crosspos[0] = inmove->crosspos[0];
pl->crosspos[1] = inmove->crosspos[1];
// denormalize crosspos x
pl->crosspos[0] -= (f32)(SCREEN_WIDTH_LO / 2);
pl->crosspos[0] = (f32)(SCREEN_WIDTH_LO / 2) + pl->crosspos[0] / pl->aspect * SCREEN_ASPECT;
pl->crosspos2[0] = pl->crosspos[0];
pl->crosspos2[1] = pl->crosspos[1];
pl->insightaimmode = (inmove->ucmd & UCMD_AIMMODE) != 0;
if (pl->insightaimmode) {
pl->gunzoomfovs[0] = pl->gunzoomfovs[1] = pl->gunzoomfovs[2] = inmove->zoomfov;
}
f32 zoomfov = 0.f;
if (pl->insightaimmode) {
zoomfov = currentPlayerGetGunZoomFov();
}
if (bgunGetWeaponNum(HAND_RIGHT) == WEAPON_AR34 && pl->hands[HAND_RIGHT].gset.weaponfunc == FUNC_SECONDARY) {
zoomfov = currentPlayerGetGunZoomFov();
}
if (zoomfov <= 0.f) {
zoomfov = pl->client->settings.fovy;
}
playerTweenFovY(zoomfov);
playerUpdateZoom();
for (s32 h = 0; h < 2; ++h) {
pl->hands[h].crosspos[0] = pl->crosspos[0];
pl->hands[h].crosspos[1] = pl->crosspos[1];
}
if (inmove->ucmd & UCMD_SELECT) {
pl->gunctrl.dualwielding = (inmove->ucmd & UCMD_SELECT_DUAL) != 0;
if (inmove->weaponnum >= 0) {
bgunEquipWeapon(inmove->weaponnum);
}
}
if ((inmove->ucmd & UCMD_SECONDARY) && !bgunIsUsingSecondaryFunction()) {
bgunConsiderToggleGunFunction(0, false, false, true);
} else if (!(inmove->ucmd & UCMD_SECONDARY) && bgunIsUsingSecondaryFunction()) {
// do not switch back to primary if in the process of throwing laptop
if (!(bgunGetWeaponNum(HAND_RIGHT) == WEAPON_LAPTOPGUN && pl->hands[HAND_RIGHT].state == HANDSTATE_ATTACK)) {
bgunConsiderToggleGunFunction(0, false, false, true);
}
}
const bool fireguns = (inmove->ucmd & UCMD_FIRE) && !pl->waitforzrelease && allowc1buttons;
bgunTickGameplay(fireguns);
if (fireguns && g_NetMode == NETMODE_SERVER) {
netmsgSvcPlayerStatsWrite(&g_NetMsgRel, pl->client);
}
if (!handled && (inmove->ucmd & UCMD_RELOAD)) {
pl->bondactivateorreload |= JO_ACTION_RELOAD;
}
if (g_NetMode == NETMODE_SERVER) {
if (!handled && (inmove->ucmd & UCMD_ACTIVATE)) {
pl->bondactivateorreload |= JO_ACTION_ACTIVATE;
}
if (g_Vars.bondvisible && (bgunIsFiring(HAND_RIGHT) || bgunIsFiring(HAND_LEFT))) {
f32 noiseradius = 0.f;
if (bgunIsFiring(HAND_RIGHT) && bgunGetNoiseRadius(HAND_RIGHT) > noiseradius) {
noiseradius = bgunGetNoiseRadius(HAND_RIGHT);
}
if (bgunIsFiring(HAND_LEFT) && bgunGetNoiseRadius(HAND_LEFT) > noiseradius) {
noiseradius = bgunGetNoiseRadius(HAND_LEFT);
}
chrsCheckForNoise(noiseradius);
}
}
bgunSetSightVisible(GUNSIGHTREASON_NOTAIMING, pl->insightaimmode);
const bool forcepos = !inmoveprev->tick || !moveticks || (inmove->ucmd & UCMD_FL_FORCEANGLE);
// lerp towards the current speeds and angles
const f32 dt = (forcepos ? 1.f : (1.f / (f32)moveticks));
f32 t = (forcepos ? 1.f : ((f32)pl->client->lerpticks / (f32)moveticks));
if (t > 1.f) {
t = 1.f;
}
pl->speedgo = pl->speedforwards = lerpf(inmoveprev->movespeed[0], inmove->movespeed[0], t);
pl->speedstrafe = pl->speedsideways = lerpf(inmoveprev->movespeed[1], inmove->movespeed[1], t);
pl->vv_theta = lerpanglef(pl->vv_theta, inmove->angles[0], dt);
pl->vv_verta = lerpanglef(pl->vv_verta, inmove->angles[1], dt);
if (pl->bondmovemode == MOVEMODE_GRAB) {
bgrabUpdateSpeedTheta();
} else if (pl->bondmovemode == MOVEMODE_WALK) {
if (bmoveGetCrouchPos() != CROUCHPOS_STAND) {
pl->speedmaxtime60 = 0;
}
bwalkSetSwayTargetf(inmove->leanofs);
} else if (pl->bondmovemode == MOVEMODE_BIKE) {
// TODO
}
if (inmove->movespeed[0] > 0.95f) {
pl->speedmaxtime60 += g_Vars.lvupdate60;
} else {
pl->speedmaxtime60 = 0;
}
}
#endif // PLATFORM_N64 #endif // PLATFORM_N64
void bmoveSetControlDef(u32 controldef) void bmoveSetControlDef(u32 controldef)
@@ -313,6 +470,39 @@ void bmoveApplyMoveData(struct movedata *data)
} else if (g_Vars.currentplayer->bondmovemode == MOVEMODE_WALK) { } else if (g_Vars.currentplayer->bondmovemode == MOVEMODE_WALK) {
bwalkApplyMoveData(data); bwalkApplyMoveData(data);
} }
#ifndef PLATFORM_N64
// record some inputs if this is a local player
if (g_NetMode && !g_Vars.currentplayer->isremote) {
g_Vars.currentplayer->ucmd = 0;
if (g_Vars.currentplayer->isdead) {
if (g_NetMode == NETMODE_CLIENT) {
if (joyGetButtons(optionsGetContpadNum1(g_Vars.currentplayerstats->mpindex), 0xb000)) {
g_Vars.currentplayer->ucmd |= UCMD_RESPAWN;
}
}
} else {
if (data->triggeron) {
g_Vars.currentplayer->ucmd |= UCMD_FIRE;
}
if (data->aiming) {
g_Vars.currentplayer->ucmd |= UCMD_AIMMODE;
}
if (g_Vars.currentplayer->bondactivateorreload & JO_ACTION_ACTIVATE) {
g_Vars.currentplayer->ucmd |= UCMD_ACTIVATE;
}
if (g_Vars.currentplayer->bondactivateorreload & JO_ACTION_RELOAD) {
g_Vars.currentplayer->ucmd |= UCMD_RELOAD;
}
if (data->eyesshut) {
g_Vars.currentplayer->ucmd |= UCMD_EYESSHUT;
}
if (data->weaponbackoffset || data->weaponforwardoffset) {
g_Vars.currentplayer->ucmd |= UCMD_SELECT;
}
}
}
#endif
} }
void bmoveUpdateSpeedTheta(void) void bmoveUpdateSpeedTheta(void)
@@ -718,6 +908,14 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
#endif #endif
controlmode = optionsGetControlMode(g_Vars.currentplayerstats->mpindex); controlmode = optionsGetControlMode(g_Vars.currentplayerstats->mpindex);
#ifndef PLATFORM_N64
if (g_Vars.currentplayer->isremote || controlmode == CONTROLMODE_NA) {
bmoveProcessRemoteInput(allowc1buttons);
return;
}
#endif
weaponnum = bgunGetWeaponNum(HAND_RIGHT); weaponnum = bgunGetWeaponNum(HAND_RIGHT);
canmanualzoom = weaponHasAimFlag(weaponnum, INVAIMFLAG_MANUALZOOM); canmanualzoom = weaponHasAimFlag(weaponnum, INVAIMFLAG_MANUALZOOM);
contpad1 = optionsGetContpadNum1(g_Vars.currentplayerstats->mpindex); contpad1 = optionsGetContpadNum1(g_Vars.currentplayerstats->mpindex);
@@ -1033,7 +1231,7 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
} }
// Handle B button activation // Handle B button activation
if (allowc1buttons && controlmode != CONTROLMODE_PC) { if (allowc1buttons && controlmode < CONTROLMODE_PC) {
for (i = 0; i < numsamples; i++) { for (i = 0; i < numsamples; i++) {
if (joyGetButtonsOnSample(i, contpad1, c1allowedbuttons & B_BUTTON) if (joyGetButtonsOnSample(i, contpad1, c1allowedbuttons & B_BUTTON)
|| joyGetButtonsOnSample(i, contpad2, c2allowedbuttons & B_BUTTON)) { || joyGetButtonsOnSample(i, contpad2, c2allowedbuttons & B_BUTTON)) {
@@ -1503,7 +1701,7 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
for (i = 0; i < numsamples; i++) { for (i = 0; i < numsamples; i++) {
if (joyGetButtonsOnSample(i, contpad1, c1allowedbuttons & usemask)) { if (joyGetButtonsOnSample(i, contpad1, c1allowedbuttons & usemask)) {
if (g_Vars.currentplayer->usedowntime >= -1) { if (g_Vars.currentplayer->usedowntime >= -1) {
if (controlmode != CONTROLMODE_PC) { if (controlmode < CONTROLMODE_PC) {
if (joyGetButtonsPressedOnSample(i, contpad1, shootbuttons & c1allowedbuttons) if (joyGetButtonsPressedOnSample(i, contpad1, shootbuttons & c1allowedbuttons)
&& g_Vars.currentplayer->usedowntime >= 0 && g_Vars.currentplayer->usedowntime >= 0
&& bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, true, false, 0) != USETIMER_CONTINUE) { && bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, true, false, 0) != USETIMER_CONTINUE) {
@@ -1528,7 +1726,7 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
} }
} }
} else { } else {
if ((controlmode != CONTROLMODE_PC) && g_Vars.currentplayer->usedowntime >= -2) { if ((controlmode < CONTROLMODE_PC) && g_Vars.currentplayer->usedowntime >= -2) {
bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, false, false, 0); bgunConsiderToggleGunFunction(g_Vars.currentplayer->usedowntime, false, false, 0);
} }
} }
@@ -1679,7 +1877,7 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
#ifdef PLATFORM_N64 #ifdef PLATFORM_N64
if (allowc1buttons) { if (allowc1buttons) {
#else #else
if (allowc1buttons && (controlmode != CONTROLMODE_PC || (PLAYER_EXTCFG().crouchmode & CROUCHMODE_ANALOG))) { if (allowc1buttons && (controlmode < CONTROLMODE_PC || (PLAYER_EXTCFG().crouchmode & CROUCHMODE_ANALOG))) {
#endif #endif
for (i = 0; i < numsamples; i++) { for (i = 0; i < numsamples; i++) {
if (!canmanualzoom && aimonhist[i]) { if (!canmanualzoom && aimonhist[i]) {
@@ -1763,7 +1961,7 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
} }
// Handle mine detonation // Handle mine detonation
if (controlmode != CONTROLMODE_PC) { if (controlmode < CONTROLMODE_PC) {
if ((((c1buttons & invbuttons) && (c1buttonsthisframe & B_BUTTON)) if ((((c1buttons & invbuttons) && (c1buttonsthisframe & B_BUTTON))
|| ((c1buttons & B_BUTTON) && (c1buttonsthisframe & invbuttons))) || ((c1buttons & B_BUTTON) && (c1buttonsthisframe & invbuttons)))
&& weaponnum == WEAPON_REMOTEMINE) { && weaponnum == WEAPON_REMOTEMINE) {
@@ -1796,7 +1994,7 @@ void bmoveProcessInput(bool allowc1x, bool allowc1y, bool allowc1buttons, bool i
movedata.triggeron = g_Vars.currentplayer->waitforzrelease == false movedata.triggeron = g_Vars.currentplayer->waitforzrelease == false
&& (c1buttons & shootbuttons) && (c1buttons & shootbuttons)
&& g_Vars.currentplayer->pausemode == PAUSEMODE_UNPAUSED; && g_Vars.currentplayer->pausemode == PAUSEMODE_UNPAUSED;
if (controlmode != CONTROLMODE_PC) { if (controlmode < CONTROLMODE_PC) {
movedata.triggeron = movedata.triggeron && ((c1buttons & invbuttons) == 0); movedata.triggeron = movedata.triggeron && ((c1buttons & invbuttons) == 0);
} }
} }
@@ -2513,7 +2711,13 @@ void bmoveUpdateHead(f32 arg0, f32 arg1, f32 arg2, Mtxf *arg3, f32 arg4)
bheadUpdate(sp244, arg2); bheadUpdate(sp244, arg2);
mtx4LoadXRotation(BADDEG2RAD(360 - g_Vars.currentplayer->vv_verta360), &sp180); mtx4LoadXRotation(BADDEG2RAD(360 - g_Vars.currentplayer->vv_verta360), &sp180);
#ifdef PLATFORM_N64
if (optionsGetHeadRoll(g_Vars.currentplayerstats->mpindex)) { if (optionsGetHeadRoll(g_Vars.currentplayerstats->mpindex)) {
#else
// in net games only allow headroll in the death animation
// TODO: figure out how to deal with headroll in other situations
if (optionsGetHeadRoll(g_Vars.currentplayerstats->mpindex) && (!g_NetMode || g_Vars.currentplayer->isdead)) {
#endif
mtx00016d58(&sp116, mtx00016d58(&sp116,
0, 0, 0, 0, 0, 0,
-g_Vars.currentplayer->headlook.x, -g_Vars.currentplayer->headlook.y, -g_Vars.currentplayer->headlook.z, -g_Vars.currentplayer->headlook.x, -g_Vars.currentplayer->headlook.y, -g_Vars.currentplayer->headlook.z,
+72 -3
View File
@@ -27,7 +27,69 @@
#include "data.h" #include "data.h"
#include "types.h" #include "types.h"
#ifndef PLATFORM_N64 #ifndef PLATFORM_N64
extern f32 fabsf(f32); #include "net/net.h"
#include "system.h"
#include "utils.h"
static inline void lerpcoord(struct coord *c, const struct coord *a, const struct coord *b, const f32 t) {
c->x = lerpf(a->x, b->x, t);
c->y = lerpf(a->y, b->y, t);
c->z = lerpf(a->z, b->z, t);
}
static void bwalkUpdateRemote(void)
{
struct player *pl = g_Vars.currentplayer;
const struct netplayermove *inmove = &pl->client->inmove[0];
const struct netplayermove *inmoveprev = &pl->client->inmove[1];
struct coord delta;
u16 cdtype = CDTYPE_ALL;
s32 moveticks = inmove->tick - inmoveprev->tick;
if (moveticks > g_NetInterpTicks) {
moveticks = g_NetInterpTicks;
}
pl->client->inmovetick = inmove->tick;
pl->bondshotspeed.x = 0.f;
pl->bondshotspeed.y = 0.f;
pl->bondshotspeed.z = 0.f;
pl->bondbreathing = 0.f;
const bool forcepos = !inmoveprev->tick ||
(inmove->ucmd & UCMD_FL_FORCEPOS) ||
(fabsf(pl->prop->pos.x - inmove->pos.x) > 512.f) ||
(fabsf(pl->prop->pos.y - inmove->pos.y) > 512.f) ||
(fabsf(pl->prop->pos.z - inmove->pos.z) > 512.f);
delta.x = 0.f;
delta.y = 0.f;
delta.z = 0.f;
// extrapolate
bwalk0f0c69b8();
if (forcepos) {
// no interpolation, set position and lock the lad in place
pl->prop->pos = inmove->pos;
pl->client->lerpticks = g_NetInterpTicks + 1;
cdtype = CDTYPE_PLAYERS; // don't get stuck in the local client
} else if (!moveticks) {
// duplicate move, reposition to correct coords
delta.x = inmove->pos.x - pl->prop->pos.x;
delta.x = inmove->pos.y - pl->prop->pos.y;
delta.x = inmove->pos.z - pl->prop->pos.z;
bwalk0f0c63bc(&delta, pl->swaytarget == 0.0f, cdtype);
} else if (pl->client->lerpticks <= moveticks) {
// lerp towards the correct position
const f32 dt = (f32)1.f / (f32)moveticks;
delta.x = g_Vars.lvupdate60freal * (inmove->pos.x - pl->prop->pos.x) * dt;
delta.y = g_Vars.lvupdate60freal * (inmove->pos.y - pl->prop->pos.y) * dt;
delta.z = g_Vars.lvupdate60freal * (inmove->pos.z - pl->prop->pos.z) * dt;
bwalk0f0c63bc(&delta, pl->swaytarget == 0.0f, cdtype);
pl->client->lerpticks += g_Vars.lvupdate60;
}
}
#endif #endif
void bwalkInit(void) void bwalkInit(void)
@@ -454,7 +516,7 @@ bool bwalkCalculateNewPositionWithPush(struct coord *delta, f32 rotateamount, bo
} }
} else if (chr->chrflags & CHRCFLAG_PUSHABLE) { } else if (chr->chrflags & CHRCFLAG_PUSHABLE) {
if (g_Vars.antiplayernum < 0 if (g_Vars.antiplayernum < 0
|| g_Vars.currentplayer != g_Vars.anti || PLAYER_IS_NOT_ANTI(g_Vars.currentplayer)
|| (chr->hidden & CHRHFLAG_ANTINONINTERACTABLE) == 0) { || (chr->hidden & CHRHFLAG_ANTINONINTERACTABLE) == 0) {
canpush = true; canpush = true;
} }
@@ -788,7 +850,7 @@ void bwalkUpdateVertical(void)
// Maybe reset counter-op's radius - not sure why // Maybe reset counter-op's radius - not sure why
// Maybe it gets set to 0 when they die? // Maybe it gets set to 0 when they die?
if (g_Vars.antiplayernum >= 0 if (g_Vars.antiplayernum >= 0
&& g_Vars.currentplayer == g_Vars.anti && PLAYER_IS_ANTI(g_Vars.currentplayer)
&& g_Vars.currentplayer->bond2.radius != 30 && g_Vars.currentplayer->bond2.radius != 30
&& cdTestVolume(&g_Vars.currentplayer->prop->pos, 30, g_Vars.currentplayer->prop->rooms, CDTYPE_ALL, CHECKVERTICAL_YES, ymax - g_Vars.currentplayer->prop->pos.y, ymin - g_Vars.currentplayer->prop->pos.y)) { && cdTestVolume(&g_Vars.currentplayer->prop->pos, 30, g_Vars.currentplayer->prop->rooms, CDTYPE_ALL, CHECKVERTICAL_YES, ymax - g_Vars.currentplayer->prop->pos.y, ymin - g_Vars.currentplayer->prop->pos.y)) {
g_Vars.currentplayer->prop->chr->radius = 30; g_Vars.currentplayer->prop->chr->radius = 30;
@@ -1843,7 +1905,14 @@ void bwalkTick(void)
bwalkUpdatePrevPos(); bwalkUpdatePrevPos();
bwalkUpdateTheta(); bwalkUpdateTheta();
bmoveUpdateVerta(); bmoveUpdateVerta();
#ifndef PLATFORM_N64
if (g_Vars.currentplayer->isremote) {
bwalkUpdateRemote();
} else
#endif
bwalk0f0c69b8(); bwalk0f0c69b8();
bwalkUpdateVertical(); bwalkUpdateVertical();
#if VERSION >= VERSION_NTSC_1_0 #if VERSION >= VERSION_NTSC_1_0
+10 -4
View File
@@ -136,7 +136,7 @@ void challengeDetermineUnlockedFeatures(void)
} }
// Now same as above, but per player // Now same as above, but per player
for (j = 0; j < MAX_PLAYERS; j++) { for (j = 0; j < MAX_LOCAL_PLAYERS; j++) {
numgifted = 0; numgifted = 0;
for (challengeindex = 0; challengeindex < ARRAYCOUNT(g_MpChallenges); challengeindex++) { for (challengeindex = 0; challengeindex < ARRAYCOUNT(g_MpChallenges); challengeindex++) {
@@ -197,7 +197,7 @@ void challengeDetermineUnlockedFeatures(void)
} }
for (challengeindex = 0; challengeindex < ARRAYCOUNT(g_MpChallenges); challengeindex++) { for (challengeindex = 0; challengeindex < ARRAYCOUNT(g_MpChallenges); challengeindex++) {
for (prev = 0; prev < MAX_PLAYERS; prev++) { for (prev = 0; prev < MAX_LOCAL_PLAYERS; prev++) {
if (challengeIsAvailableToPlayer(prev, challengeindex)) { if (challengeIsAvailableToPlayer(prev, challengeindex)) {
for (i = 0; i < ARRAYCOUNT(g_MpChallenges[challengeindex].unlockfeatures); i++) { for (i = 0; i < ARRAYCOUNT(g_MpChallenges[challengeindex].unlockfeatures); i++) {
if (g_MpChallenges[challengeindex].unlockfeatures[i] == j) { if (g_MpChallenges[challengeindex].unlockfeatures[i] == j) {
@@ -249,7 +249,7 @@ void challengePerformSanityChecks(void)
} }
} }
// Turn off all simulants and turn them on if enabled // Turn off all simulants (and players 5-8 if supported) and turn them on if enabled
// for this number of players // for this number of players
g_MpSetup.chrslots &= 0x000f; g_MpSetup.chrslots &= 0x000f;
@@ -265,8 +265,14 @@ void challengePerformSanityChecks(void)
g_Vars.mphilltime = 10; g_Vars.mphilltime = 10;
} }
} else if (!challengeIsFeatureUnlocked(MPFEATURE_8BOTS)) { } else if (!challengeIsFeatureUnlocked(MPFEATURE_8BOTS)) {
// Limit to 4 players and 4 simulants // Limit to 4 players and 4 simulants in local games
#ifndef PLATFORM_N64
g_MpSetup.chrslots &= (g_NetMode ? 0x0fff : 0x0f0f);
#elif MAX_PLAYERS > 4
g_MpSetup.chrslots &= 0x0f0f;
#else
g_MpSetup.chrslots &= 0x00ff; g_MpSetup.chrslots &= 0x00ff;
#endif
} }
} }
+14 -4
View File
@@ -49,6 +49,8 @@
#include "types.h" #include "types.h"
#ifndef PLATFORM_N64 #ifndef PLATFORM_N64
#include "video.h" #include "video.h"
#include "net/net.h"
#include "net/netmsg.h"
#endif #endif
void rng2SetSeed(u32 seed); void rng2SetSeed(u32 seed);
@@ -4660,7 +4662,7 @@ void chrHit(struct shotdata *shotdata, struct hit *hit)
hit->model, hit->hitthing.unk28 / 2, sp90); hit->model, hit->hitthing.unk28 / 2, sp90);
if (g_Vars.antiplayernum >= 0 if (g_Vars.antiplayernum >= 0
&& g_Vars.currentplayer == g_Vars.anti && PLAYER_IS_ANTI(g_Vars.currentplayer)
&& (chr->hidden & CHRHFLAG_ANTINONINTERACTABLE)) { && (chr->hidden & CHRHFLAG_ANTINONINTERACTABLE)) {
return; return;
} }
@@ -4691,9 +4693,17 @@ void chrHit(struct shotdata *shotdata, struct hit *hit)
|| weapon->weaponnum == WEAPON_TIMEDMINE || weapon->weaponnum == WEAPON_TIMEDMINE
|| weapon->weaponnum == WEAPON_REMOTEMINE || weapon->weaponnum == WEAPON_REMOTEMINE
|| weapon->weaponnum == WEAPON_PROXIMITYMINE) { || weapon->weaponnum == WEAPON_PROXIMITYMINE) {
objSetDropped(hit->prop, DROPTYPE_DEFAULT); #ifndef PLATFORM_N64
chr->hidden |= CHRHFLAG_DROPPINGITEM; if (g_NetMode == NETMODE_SERVER) {
objDamage(&weapon->base, gsetGetDamage(&shotdata->gset), &sp98, shotdata->gset.weaponnum, g_Vars.currentplayernum); netmsgSvcChrDisarmWrite(&g_NetMsgRel, chr, g_Vars.currentplayer->prop, weapon->weaponnum, gsetGetDamage(&shotdata->gset), &sp98);
}
if (g_NetMode != NETMODE_CLIENT)
#endif
{
objSetDropped(hit->prop, DROPTYPE_DEFAULT);
chr->hidden |= CHRHFLAG_DROPPINGITEM;
objDamage(&weapon->base, gsetGetDamage(&shotdata->gset), &sp98, shotdata->gset.weaponnum, g_Vars.currentplayernum);
}
return; return;
} }
+131 -6
View File
@@ -56,6 +56,10 @@
#include "lib/vi.h" #include "lib/vi.h"
#include "data.h" #include "data.h"
#include "types.h" #include "types.h"
#ifndef PLATFORM_N64
#include "net/net.h"
#include "net/netmsg.h"
#endif
s32 g_RecentQuipsPlayed[5]; s32 g_RecentQuipsPlayed[5];
u32 var8009cd84; u32 var8009cd84;
@@ -4038,7 +4042,7 @@ void chrChoke(struct chrdata *chr, s32 choketype)
if (soundnum >= 0) { if (soundnum >= 0) {
if (chr->prop->type == PROPTYPE_PLAYER) { if (chr->prop->type == PROPTYPE_PLAYER) {
if (g_Vars.players[playernum]->chokehandle == NULL) { if (g_Vars.players[playernum]->chokehandle == NULL) {
sndStart(var80095200, soundnum, &g_Vars.players[playernum]->chokehandle, -1, -1, -1, -1, -1); playerSndStart(var80095200, soundnum, &g_Vars.players[playernum]->chokehandle, playernum, -1, -1, -1);
} }
} else { } else {
psStopSound(chr->prop, PSTYPE_CHRTALK, 0); psStopSound(chr->prop, PSTYPE_CHRTALK, 0);
@@ -4101,6 +4105,12 @@ bool func0f034080(struct chrdata *chr, struct modelnode *node, struct prop *prop
*/ */
void chrDamageByMisc(struct chrdata *chr, f32 damage, struct coord *vector, struct gset *gset, struct prop *prop) void chrDamageByMisc(struct chrdata *chr, f32 damage, struct coord *vector, struct gset *gset, struct prop *prop)
{ {
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_CLIENT) {
// don't do anything if we're not the authority
return;
}
#endif
chrDamage(chr, damage, vector, gset, prop, HITPART_GENERAL, chrDamage(chr, damage, vector, gset, prop, HITPART_GENERAL,
false, // damageshield false, // damageshield
NULL, // prop2 NULL, // prop2
@@ -4114,6 +4124,12 @@ void chrDamageByMisc(struct chrdata *chr, f32 damage, struct coord *vector, stru
void chrDamageByLaser(struct chrdata *chr, f32 damage, struct coord *vector, struct gset *gset, struct prop *prop) void chrDamageByLaser(struct chrdata *chr, f32 damage, struct coord *vector, struct gset *gset, struct prop *prop)
{ {
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_CLIENT) {
// don't do anything if we're not the authority
return;
}
#endif
chrDamage(chr, damage, vector, gset, prop, HITPART_GENERAL, chrDamage(chr, damage, vector, gset, prop, HITPART_GENERAL,
true, // damageshield true, // damageshield
chr->prop, // prop2 chr->prop, // prop2
@@ -4127,6 +4143,12 @@ void chrDamageByLaser(struct chrdata *chr, f32 damage, struct coord *vector, str
void func0f0341dc(struct chrdata *chr, f32 damage, struct coord *vector, struct gset *gset, struct prop *prop, s32 hitpart, struct prop *prop2, struct modelnode *node, struct model *model, s32 side, s16 *arg10) void func0f0341dc(struct chrdata *chr, f32 damage, struct coord *vector, struct gset *gset, struct prop *prop, s32 hitpart, struct prop *prop2, struct modelnode *node, struct model *model, s32 side, s16 *arg10)
{ {
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_CLIENT) {
// don't do anything if we're not the authority
return;
}
#endif
chrDamage(chr, damage, vector, gset, prop, hitpart, chrDamage(chr, damage, vector, gset, prop, hitpart,
true, // damageshield true, // damageshield
prop2, // prop2 prop2, // prop2
@@ -4148,6 +4170,13 @@ void func0f034248(struct chrdata *chr, f32 damage, struct coord *vector, struct
s32 side = 0; s32 side = 0;
s32 hitpart = HITPART_GENERAL; s32 hitpart = HITPART_GENERAL;
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_CLIENT) {
// don't do anything if we're not the authority
return;
}
#endif
if (chrGetShield(chr) >= 0 && chr->model) { if (chrGetShield(chr) >= 0 && chr->model) {
chrCalculateShieldHit(chr, &chr->prop->pos, vector, &node, &hitpart, &model, &side); chrCalculateShieldHit(chr, &chr->prop->pos, vector, &node, &hitpart, &model, &side);
} }
@@ -4172,6 +4201,13 @@ void chrDamageByImpact(struct chrdata *chr, f32 damage, struct coord *vector, st
struct model *model = NULL; struct model *model = NULL;
s32 side = 0; s32 side = 0;
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_CLIENT) {
// don't do anything if we're not the authority
return;
}
#endif
if (chrGetShield(chr) >= 0 && chr->model) { if (chrGetShield(chr) >= 0 && chr->model) {
chrCalculateShieldHit(chr, &chr->prop->pos, vector, &node, &hitpart, &model, &side); chrCalculateShieldHit(chr, &chr->prop->pos, vector, &node, &hitpart, &model, &side);
} }
@@ -4189,6 +4225,12 @@ void chrDamageByImpact(struct chrdata *chr, f32 damage, struct coord *vector, st
void chrDamageByExplosion(struct chrdata *chr, f32 damage, struct coord *vector, struct prop *prop, struct coord *explosionpos) void chrDamageByExplosion(struct chrdata *chr, f32 damage, struct coord *vector, struct prop *prop, struct coord *explosionpos)
{ {
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_CLIENT) {
// don't do anything if we're not the authority
return;
}
#endif
chrDamage(chr, damage, vector, NULL, prop, HITPART_GENERAL, chrDamage(chr, damage, vector, NULL, prop, HITPART_GENERAL,
true, // damageshield true, // damageshield
chr->prop, // prop2 chr->prop, // prop2
@@ -4272,6 +4314,13 @@ void chrDamage(struct chrdata *chr, f32 damage, struct coord *vector, struct gse
s32 aplayernum = -1; s32 aplayernum = -1;
s32 choketype = CHOKETYPE_NONE; s32 choketype = CHOKETYPE_NONE;
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_SERVER) {
netmsgSvcChrDamageWrite(&g_NetMsgRel, chr, damage, vector, gset, aprop, hitpart,
damageshield, prop2, side, arg11, explosion, explosionpos);
}
#endif
if (hitpart == HITPART_HEAD) { if (hitpart == HITPART_HEAD) {
choketype = CHOKETYPE_GURGLE; choketype = CHOKETYPE_GURGLE;
} }
@@ -4302,7 +4351,7 @@ void chrDamage(struct chrdata *chr, f32 damage, struct coord *vector, struct gse
// Don't damage if attacker was anti and chr is non-interactable by anti // Don't damage if attacker was anti and chr is non-interactable by anti
if (g_Vars.antiplayernum >= 0 if (g_Vars.antiplayernum >= 0
&& aprop && aprop
&& aprop == g_Vars.anti->prop && PROP_IS_FOR_ANTI_PLAYER(aprop)
&& (chr->hidden & CHRHFLAG_ANTINONINTERACTABLE)) { && (chr->hidden & CHRHFLAG_ANTINONINTERACTABLE)) {
return; return;
} }
@@ -4454,7 +4503,9 @@ void chrDamage(struct chrdata *chr, f32 damage, struct coord *vector, struct gse
} }
// Anti shooting other enemies is lethal // Anti shooting other enemies is lethal
if (aprop && aprop == g_Vars.anti->prop && vprop != g_Vars.bond->prop) { if (aprop
&& PROP_IS_FOR_ANTI_PLAYER(aprop)
&& vprop != g_Vars.bond->prop) {
damage *= 100; damage *= 100;
} }
} else { } else {
@@ -4855,6 +4906,12 @@ void chrDamage(struct chrdata *chr, f32 damage, struct coord *vector, struct gse
} }
} }
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_SERVER && g_Vars.currentplayer->client) {
netmsgSvcPlayerStatsWrite(&g_NetMsgRel, g_Vars.currentplayer->client);
}
#endif
setCurrentPlayerNum(prevplayernum); setCurrentPlayerNum(prevplayernum);
return; return;
} }
@@ -8279,7 +8336,7 @@ void chrAlertOthersOfInjury(struct chrdata *chr, bool dying)
s32 numinrange = 0; s32 numinrange = 0;
s32 numchrs = chrsGetNumSlots(); s32 numchrs = chrsGetNumSlots();
if (g_Vars.antiplayernum >= 0 && chr->prop == g_Vars.anti->prop) { if (g_Vars.antiplayernum >= 0 && PROP_IS_FOR_ANTI_PLAYER(chr->prop)) {
return; return;
} }
@@ -13514,7 +13571,7 @@ void chraTickBg(void)
if (targetprop && (targetprop->type == PROPTYPE_CHR || targetprop->type == PROPTYPE_PLAYER)) { if (targetprop && (targetprop->type == PROPTYPE_CHR || targetprop->type == PROPTYPE_PLAYER)) {
if ((targetprop->type == PROPTYPE_PLAYER if ((targetprop->type == PROPTYPE_PLAYER
&& !(g_Vars.antiplayernum >= 0 && g_Vars.anti && g_Vars.anti->prop == targetprop) && !(g_Vars.antiplayernum >= 0 && g_Vars.anti && PROP_IS_FOR_ANTI_PLAYER(targetprop))
&& chrCompareTeams(chr, targetprop->chr, COMPARE_ENEMIES)) && chrCompareTeams(chr, targetprop->chr, COMPARE_ENEMIES))
|| CHRRACE(targetprop->chr) == RACE_EYESPY) { || CHRRACE(targetprop->chr) == RACE_EYESPY) {
s32 time60; s32 time60;
@@ -15300,6 +15357,68 @@ void func0f04b740(void)
// empty // empty
} }
bool chrSetPos(struct chrdata *chr, struct coord *pos, RoomNum *rooms, f32 theta, bool findground)
{
const f32 angle = BADDEG2RAD(360.f - theta);
if (findground) {
const u32 oldhidden = chr->hidden;
chr->hidden |= CHRHFLAG_WARPONSCREEN;
const bool ret = chrMoveToPos(chr, pos, rooms, angle, true);
if ((oldhidden & CHRHFLAG_WARPONSCREEN) == 0) {
chr->hidden &= ~CHRHFLAG_WARPONSCREEN;
}
}
bool newrooms = false;
for (s32 i = 0; i < ARRAYCOUNT(chr->prop->rooms) && rooms[i] >= 0; ++i) {
if (chr->prop->rooms[i] != rooms[i]) {
newrooms = true;
break;
}
}
propSetPerimEnabled(chr->prop, false);
chr->prop->pos = *pos;
const f32 ground = cdFindGroundInfoAtCyl(pos, chr->radius, rooms, &chr->floorcol,
&chr->floortype, NULL, &chr->floorroom, NULL, NULL);
chr->ground = ground;
chr->manground = ground;
chr->sumground = ground * (PAL ? 8.4175090789795f : 9.999998f);
if (newrooms) {
propDeregisterRooms(chr->prop);
roomsCopy(rooms, chr->prop->rooms);
chr0f0220ac(chr);
}
modelSetRootPosition(chr->model, pos);
const u16 nodetype = chr->model->definition->rootnode->type;
if ((nodetype & 0xff) == MODELNODETYPE_CHRINFO) {
union modelrwdata *rwdata = modelGetNodeRwData(chr->model, chr->model->definition->rootnode);
rwdata->chrinfo.ground = ground;
}
chrSetLookAngle(chr, angle);
if (chr->prop->type == PROPTYPE_PLAYER) {
struct player *player = g_Vars.players[playermgrGetPlayerNumByProp(chr->prop)];
player->vv_manground = ground;
player->vv_ground = ground;
player->vv_theta = theta;
player->unk1c64 = 1;
}
propSetPerimEnabled(chr->prop, true);
return true;
}
bool chrMoveToPos(struct chrdata *chr, struct coord *pos, RoomNum *rooms, f32 angle, bool force) bool chrMoveToPos(struct chrdata *chr, struct coord *pos, RoomNum *rooms, f32 angle, bool force)
{ {
struct coord pos2; struct coord pos2;
@@ -15307,7 +15426,7 @@ bool chrMoveToPos(struct chrdata *chr, struct coord *pos, RoomNum *rooms, f32 an
bool result = false; bool result = false;
u32 nodetype; u32 nodetype;
union modelrwdata *rwdata; union modelrwdata *rwdata;
struct player *player; struct player *player = NULL;
f32 ground; f32 ground;
pos2.x = pos->x; pos2.x = pos->x;
@@ -15357,6 +15476,12 @@ bool chrMoveToPos(struct chrdata *chr, struct coord *pos, RoomNum *rooms, f32 an
player->unk1c64 = 1; player->unk1c64 = 1;
} }
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_SERVER && player && player->isremote) {
player->ucmd |= UCMD_FL_FORCEPOS | UCMD_FL_FORCEANGLE | UCMD_FL_FORCEGROUND;
}
#endif
result = true; result = true;
} }
+28
View File
@@ -52,6 +52,10 @@
#include "data.h" #include "data.h"
#include "types.h" #include "types.h"
#ifndef PLATFORM_N64
#include "game/mplayer/mplayer.h"
#endif
/** /**
* @cmd 0000 * @cmd 0000
*/ */
@@ -6039,11 +6043,35 @@ bool aiSetChrPresetToChrNearPad(void)
bool aiChrSetTeam(void) bool aiChrSetTeam(void)
{ {
u8 *cmd = g_Vars.ailist + g_Vars.aioffset; u8 *cmd = g_Vars.ailist + g_Vars.aioffset;
#ifdef PLATFORM_N64
struct chrdata *chr = chrFindById(g_Vars.chrdata, cmd[2]); struct chrdata *chr = chrFindById(g_Vars.chrdata, cmd[2]);
if (chr) { if (chr) {
chr->team = cmd[3]; chr->team = cmd[3];
} }
#else
u32 playernum;
if (cmd[2] == CHR_ANTI && g_Vars.antiplayernum >= 0) {
// There can be multiple counter-op players, so set this for all.
for (playernum = 0; playernum < PLAYERCOUNT(); playernum++) {
struct player *player = g_Vars.players[playernum];
if (player && PLAYER_IS_ANTI(player)) {
struct chrdata *chr = player->prop->chr;
if (chr) {
chr->team = cmd[3];
}
}
}
} else {
struct chrdata *chr = chrFindById(g_Vars.chrdata, cmd[2]);
if (chr) {
chr->team = cmd[3];
}
}
#endif
g_Vars.aioffset += 4; g_Vars.aioffset += 4;
+57 -12
View File
@@ -292,6 +292,27 @@ char *endscreenMenuTextAccuracy(struct menuitem *item)
return g_StringPointer; return g_StringPointer;
} }
#if MAX_COOPCHRS > 2
static bool enscreenAnyAntiAborted(void) {
size_t num;
if (g_Vars.antiplayernum < 0) {
return false;
}
for (num = 0; num < PLAYERCOUNT(); num++) {
if (PLAYERNUM_IS_ANTI(num) && g_Vars.players[num] && g_Vars.players[num]->aborted) {
return true;
}
}
return false;
}
#define ANTI_ABORTED() (enscreenAnyAntiAborted())
#else
#define ANTI_ABORTED() (g_Vars.anti->aborted)
#endif
char *endscreenMenuTextMissionStatus(struct menuitem *item) char *endscreenMenuTextMissionStatus(struct menuitem *item)
{ {
if (g_CheatsActiveBank0 || g_CheatsActiveBank1) { if (g_CheatsActiveBank0 || g_CheatsActiveBank1) {
@@ -312,7 +333,7 @@ char *endscreenMenuTextMissionStatus(struct menuitem *item)
return langGet(L_OPTIONS_295); // "Aborted" return langGet(L_OPTIONS_295); // "Aborted"
} }
if (g_Vars.anti->aborted) { if (ANTI_ABORTED()) {
return langGet(L_OPTIONS_295); // "Aborted" return langGet(L_OPTIONS_295); // "Aborted"
} }
@@ -320,7 +341,7 @@ char *endscreenMenuTextMissionStatus(struct menuitem *item)
return langGet(L_OPTIONS_293); // "Failed" return langGet(L_OPTIONS_293); // "Failed"
} }
} else { } else {
if (g_Vars.anti->aborted) { if (ANTI_ABORTED()) {
return langGet(L_OPTIONS_295); // "Aborted" return langGet(L_OPTIONS_295); // "Aborted"
} }
@@ -1700,14 +1721,22 @@ void endscreenPushCoop(void)
#endif #endif
{ {
// Failed or aborted // Failed or aborted
if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) { if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL
#ifndef PLATFORM_N64
|| LOCALPLAYERCOUNT() >= 3
#endif
) {
menuPushRootDialog(&g_2PMissionEndscreenFailedVMenuDialog, MENUROOT_MPENDSCREEN); menuPushRootDialog(&g_2PMissionEndscreenFailedVMenuDialog, MENUROOT_MPENDSCREEN);
} else { } else {
menuPushRootDialog(&g_2PMissionEndscreenFailedHMenuDialog, MENUROOT_MPENDSCREEN); menuPushRootDialog(&g_2PMissionEndscreenFailedHMenuDialog, MENUROOT_MPENDSCREEN);
} }
} else { } else {
// Completed // Completed
if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) { if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL
#ifndef PLATFORM_N64
|| LOCALPLAYERCOUNT() >= 3
#endif
) {
menuPushRootDialog(&g_2PMissionEndscreenCompletedVMenuDialog, MENUROOT_MPENDSCREEN); menuPushRootDialog(&g_2PMissionEndscreenCompletedVMenuDialog, MENUROOT_MPENDSCREEN);
} else { } else {
menuPushRootDialog(&g_2PMissionEndscreenCompletedHMenuDialog, MENUROOT_MPENDSCREEN); menuPushRootDialog(&g_2PMissionEndscreenCompletedHMenuDialog, MENUROOT_MPENDSCREEN);
@@ -1787,20 +1816,28 @@ void endscreenPushAnti(void)
if (g_Vars.currentplayer == g_Vars.bond) { if (g_Vars.currentplayer == g_Vars.bond) {
#if VERSION >= VERSION_NTSC_1_0 && defined(DEBUG) #if VERSION >= VERSION_NTSC_1_0 && defined(DEBUG)
if (!g_Vars.anti->aborted && (g_Vars.bond->isdead || g_Vars.bond->aborted || !objectiveIsAllComplete()) && !debugIsSetCompleteEnabled()) if (!ANTI_ABORTED() && (g_Vars.bond->isdead || g_Vars.bond->aborted || !objectiveIsAllComplete()) && !debugIsSetCompleteEnabled())
#else #else
if (!g_Vars.anti->aborted && (g_Vars.bond->isdead || g_Vars.bond->aborted || !objectiveIsAllComplete())) if (!ANTI_ABORTED() && (g_Vars.bond->isdead || g_Vars.bond->aborted || !objectiveIsAllComplete()))
#endif #endif
{ {
// Bond - failed or aborted // Bond - failed or aborted
if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) { if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL
#ifndef PLATFORM_N64
|| LOCALPLAYERCOUNT() >= 3
#endif
) {
menuPushRootDialog(&g_2PMissionEndscreenFailedVMenuDialog, MENUROOT_MPENDSCREEN); menuPushRootDialog(&g_2PMissionEndscreenFailedVMenuDialog, MENUROOT_MPENDSCREEN);
} else { } else {
menuPushRootDialog(&g_2PMissionEndscreenFailedHMenuDialog, MENUROOT_MPENDSCREEN); menuPushRootDialog(&g_2PMissionEndscreenFailedHMenuDialog, MENUROOT_MPENDSCREEN);
} }
} else { } else {
// Bond - completed // Bond - completed
if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) { if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL
#ifndef PLATFORM_N64
|| LOCALPLAYERCOUNT() >= 3
#endif
) {
menuPushRootDialog(&g_2PMissionEndscreenCompletedVMenuDialog, MENUROOT_MPENDSCREEN); menuPushRootDialog(&g_2PMissionEndscreenCompletedVMenuDialog, MENUROOT_MPENDSCREEN);
} else { } else {
menuPushRootDialog(&g_2PMissionEndscreenCompletedHMenuDialog, MENUROOT_MPENDSCREEN); menuPushRootDialog(&g_2PMissionEndscreenCompletedHMenuDialog, MENUROOT_MPENDSCREEN);
@@ -1810,20 +1847,28 @@ void endscreenPushAnti(void)
filemgrSaveOrLoad(&g_GameFileGuid, FILEOP_SAVE_GAME_000, 0); filemgrSaveOrLoad(&g_GameFileGuid, FILEOP_SAVE_GAME_000, 0);
} else { } else {
#if VERSION >= VERSION_NTSC_1_0 && defined(DEBUG) #if VERSION >= VERSION_NTSC_1_0 && defined(DEBUG)
if (!g_Vars.anti->aborted && (g_Vars.bond->isdead || g_Vars.bond->aborted || !objectiveIsAllComplete()) && !debugIsSetCompleteEnabled()) if (!ANTI_ABORTED() && (g_Vars.bond->isdead || g_Vars.bond->aborted || !objectiveIsAllComplete()) && !debugIsSetCompleteEnabled())
#else #else
if (!g_Vars.anti->aborted && (g_Vars.bond->isdead || g_Vars.bond->aborted || !objectiveIsAllComplete())) if (!ANTI_ABORTED() && (g_Vars.bond->isdead || g_Vars.bond->aborted || !objectiveIsAllComplete()))
#endif #endif
{ {
// Anti - completed // Anti - completed
if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) { if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL
#ifndef PLATFORM_N64
|| LOCALPLAYERCOUNT() >= 3
#endif
) {
menuPushRootDialog(&g_2PMissionEndscreenCompletedVMenuDialog, MENUROOT_MPENDSCREEN); menuPushRootDialog(&g_2PMissionEndscreenCompletedVMenuDialog, MENUROOT_MPENDSCREEN);
} else { } else {
menuPushRootDialog(&g_2PMissionEndscreenCompletedHMenuDialog, MENUROOT_MPENDSCREEN); menuPushRootDialog(&g_2PMissionEndscreenCompletedHMenuDialog, MENUROOT_MPENDSCREEN);
} }
} else { } else {
// Anti - failed or aborted // Anti - failed or aborted
if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) { if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL
#ifndef PLATFORM_N64
|| LOCALPLAYERCOUNT() >= 3
#endif
) {
menuPushRootDialog(&g_2PMissionEndscreenFailedVMenuDialog, MENUROOT_MPENDSCREEN); menuPushRootDialog(&g_2PMissionEndscreenFailedVMenuDialog, MENUROOT_MPENDSCREEN);
} else { } else {
menuPushRootDialog(&g_2PMissionEndscreenFailedHMenuDialog, MENUROOT_MPENDSCREEN); menuPushRootDialog(&g_2PMissionEndscreenFailedHMenuDialog, MENUROOT_MPENDSCREEN);
+15 -3
View File
@@ -847,7 +847,7 @@ void explosionInflictDamage(struct prop *expprop)
minfrac = (minfrac * 0.7f + 0.3f) * type->damage; minfrac = (minfrac * 0.7f + 0.3f) * type->damage;
if (g_Vars.antiplayernum >= 0 if (g_Vars.antiplayernum >= 0
&& g_Vars.antiplayernum == exp->owner && EXPLOSION_OWNER_IS_ANTI_PLAYER(exp->owner)
&& (obj->flags2 & OBJFLAG2_IMMUNETOANTI)) { && (obj->flags2 & OBJFLAG2_IMMUNETOANTI)) {
// anti cannot damage this obj // anti cannot damage this obj
} else if (isfirstframe) { } else if (isfirstframe) {
@@ -997,8 +997,16 @@ void explosionInflictDamage(struct prop *expprop)
ownerprop = g_Vars.bond->prop; ownerprop = g_Vars.bond->prop;
} else if (g_Vars.coopplayernum >= 0 && exp->owner == g_Vars.coopplayernum) { } else if (g_Vars.coopplayernum >= 0 && exp->owner == g_Vars.coopplayernum) {
ownerprop = g_Vars.coop->prop; ownerprop = g_Vars.coop->prop;
} else if (g_Vars.antiplayernum >= 0 && exp->owner == g_Vars.antiplayernum) { } else if (g_Vars.antiplayernum >= 0 && EXPLOSION_OWNER_IS_ANTI_PLAYER(exp->owner)) {
#if PLATFORM_N64
ownerprop = g_Vars.anti->prop; ownerprop = g_Vars.anti->prop;
#else
struct chrdata *ownerchr = mpGetChrFromPlayerIndex(exp->owner);
if (ownerchr) {
ownerprop = ownerchr->prop;
}
#endif
} }
chrDamageByExplosion(chr, minfrac, &spa0, ownerprop, &expprop->pos); chrDamageByExplosion(chr, minfrac, &spa0, ownerprop, &expprop->pos);
@@ -1212,8 +1220,12 @@ u32 explosionTick(struct prop *prop)
if (g_Vars.normmplayerisrunning) { if (g_Vars.normmplayerisrunning) {
chr = mpGetChrFromPlayerIndex(exp->owner); chr = mpGetChrFromPlayerIndex(exp->owner);
} else if (g_Vars.antiplayernum >= 0 && exp->owner == g_Vars.antiplayernum) { } else if (g_Vars.antiplayernum >= 0 && EXPLOSION_OWNER_IS_ANTI_PLAYER(exp->owner)) {
#if PLATFORM_N64
chr = g_Vars.anti->prop->chr; chr = g_Vars.anti->prop->chr;
#else
chr = mpGetChrFromPlayerIndex(exp->owner);
#endif
} else if (g_Vars.coopplayernum >= 0 && exp->owner == g_Vars.coopplayernum) { } else if (g_Vars.coopplayernum >= 0 && exp->owner == g_Vars.coopplayernum) {
chr = g_Vars.coop->prop->chr; chr = g_Vars.coop->prop->chr;
} else { } else {
+1 -1
View File
@@ -24,7 +24,7 @@
s32 g_FilelistKnownPlugCounts[5]; s32 g_FilelistKnownPlugCounts[5];
struct filelist *g_FileLists[MAX_PLAYERS] = { NULL }; struct filelist *g_FileLists[MAX_LOCAL_PLAYERS] = { NULL };
bool var80075bd0[] = { true, true, true, true }; bool var80075bd0[] = { true, true, true, true };
bool var80075be0[] = { false, false, false, false }; bool var80075be0[] = { false, false, false, false };
u32 var80075bf0 = false; u32 var80075bf0 = false;
+8 -8
View File
@@ -25,7 +25,7 @@ struct fileguid g_FilemgrFileToCopy;
struct fileguid var800a21e8; struct fileguid var800a21e8;
#if VERSION >= VERSION_JPN_FINAL #if VERSION >= VERSION_JPN_FINAL
struct fileguid g_FilemgrFileToDelete[MAX_PLAYERS]; struct fileguid g_FilemgrFileToDelete[MAX_LOCAL_PLAYERS];
#else #else
struct fileguid g_FilemgrFileToDelete; struct fileguid g_FilemgrFileToDelete;
#endif #endif
@@ -970,7 +970,7 @@ void filemgrDeleteCurrentFile(void)
filemgrPushErrorDialog(FILEERROR_DELETEFAILED); filemgrPushErrorDialog(FILEERROR_DELETEFAILED);
} else { } else {
// If deleting a loaded MP player, reset them to default // If deleting a loaded MP player, reset them to default
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_LOCAL_PLAYERS; i++) {
if (g_FilemgrFileToDelete[g_MpPlayerNum].fileid == g_PlayerConfigsArray[i].fileguid.fileid if (g_FilemgrFileToDelete[g_MpPlayerNum].fileid == g_PlayerConfigsArray[i].fileguid.fileid
&& g_FilemgrFileToDelete[g_MpPlayerNum].deviceserial == g_PlayerConfigsArray[i].fileguid.deviceserial) { && g_FilemgrFileToDelete[g_MpPlayerNum].deviceserial == g_PlayerConfigsArray[i].fileguid.deviceserial) {
mpPlayerSetDefaults(i, true); mpPlayerSetDefaults(i, true);
@@ -997,7 +997,7 @@ void filemgrDeleteCurrentFile(void)
filemgrPushErrorDialog(FILEERROR_DELETEFAILED); filemgrPushErrorDialog(FILEERROR_DELETEFAILED);
} else { } else {
// If deleting a loaded MP player, reset them to default // If deleting a loaded MP player, reset them to default
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_LOCAL_PLAYERS; i++) {
if (g_FilemgrFileToDelete.fileid == g_PlayerConfigsArray[i].fileguid.fileid if (g_FilemgrFileToDelete.fileid == g_PlayerConfigsArray[i].fileguid.fileid
&& g_FilemgrFileToDelete.deviceserial == g_PlayerConfigsArray[i].fileguid.deviceserial) { && g_FilemgrFileToDelete.deviceserial == g_PlayerConfigsArray[i].fileguid.deviceserial) {
mpPlayerSetDefaults(i, true); mpPlayerSetDefaults(i, true);
@@ -1844,7 +1844,7 @@ bool filemgrIsFileInUse(struct filelistfile *file)
} }
} }
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_LOCAL_PLAYERS; i++) {
if ((g_MpSetup.chrslots & (1 << i)) if ((g_MpSetup.chrslots & (1 << i))
&& g_PlayerConfigsArray[i].fileguid.fileid == file->fileid && g_PlayerConfigsArray[i].fileguid.fileid == file->fileid
&& g_PlayerConfigsArray[i].fileguid.deviceserial == file->deviceserial) { && g_PlayerConfigsArray[i].fileguid.deviceserial == file->deviceserial) {
@@ -1982,7 +1982,7 @@ bool filemgrIsFileInUse(struct filelistfile *file)
return true; return true;
} }
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_LOCAL_PLAYERS; i++) {
if ((g_MpSetup.chrslots & (1 << i)) if ((g_MpSetup.chrslots & (1 << i))
&& g_PlayerConfigsArray[i].fileguid.fileid == file->fileid && g_PlayerConfigsArray[i].fileguid.fileid == file->fileid
&& g_PlayerConfigsArray[i].fileguid.deviceserial == file->deviceserial) { && g_PlayerConfigsArray[i].fileguid.deviceserial == file->deviceserial) {
@@ -2420,7 +2420,7 @@ MenuDialogHandlerResult pakChoosePakMenuDialog(s32 operation, struct menudialogd
if (g_Vars.stagenum != STAGE_BOOTPAKMENU) { if (g_Vars.stagenum != STAGE_BOOTPAKMENU) {
s32 i; s32 i;
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_LOCAL_PLAYERS; i++) {
if (g_Menus[g_MpPlayerNum].fm.unke24 & (1 << i)) { if (g_Menus[g_MpPlayerNum].fm.unke24 & (1 << i)) {
g_Vars.pakstocheck &= 0xfff0; g_Vars.pakstocheck &= 0xfff0;
g_Vars.pakstocheck |= 0x0008; g_Vars.pakstocheck |= 0x0008;
@@ -2445,7 +2445,7 @@ MenuDialogHandlerResult pakChoosePakMenuDialog(s32 operation, struct menudialogd
{ {
s32 i; s32 i;
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_LOCAL_PLAYERS; i++) {
if (g_Menus[g_MpPlayerNum].fm.unke24 & (1 << i)) { if (g_Menus[g_MpPlayerNum].fm.unke24 & (1 << i)) {
pak0f1169c8(i, STAGE_BOOTPAKMENU == g_Vars.stagenum); pak0f1169c8(i, STAGE_BOOTPAKMENU == g_Vars.stagenum);
} }
@@ -2767,7 +2767,7 @@ MenuDialogHandlerResult filemgrMainMenuDialog(s32 operation, struct menudialogde
mpInit(true); mpInit(true);
// Set MP player names to "Player 1" through 4 if blank // Set MP player names to "Player 1" through 4 if blank
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_LOCAL_PLAYERS; i++) {
if (g_PlayerConfigsArray[i].base.name[0] == '\0') { if (g_PlayerConfigsArray[i].base.name[0] == '\0') {
sprintf(g_PlayerConfigsArray[i].base.name, "%s %d\n", langGet(L_MISC_437), i + 1); sprintf(g_PlayerConfigsArray[i].base.name, "%s %d\n", langGet(L_MISC_437), i + 1);
} }
+2 -2
View File
@@ -167,7 +167,7 @@ f32 func0f0b131c(s32 hand)
weapon = weaponFindById(bgunGetWeaponNum2(0)); weapon = weaponFindById(bgunGetWeaponNum2(0));
x = weapon->posx; x = weapon->posx;
if (PLAYERCOUNT() == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) { if (LOCALPLAYERCOUNT() == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) {
x -= 3.5f; x -= 3.5f;
if (g_Vars.currentplayernum == 0) { if (g_Vars.currentplayernum == 0) {
@@ -178,7 +178,7 @@ f32 func0f0b131c(s32 hand)
weapon = weaponFindById(bgunGetWeaponNum2(1)); weapon = weaponFindById(bgunGetWeaponNum2(1));
x = -weapon->posx; x = -weapon->posx;
if (PLAYERCOUNT() == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) { if (LOCALPLAYERCOUNT() == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) {
x += 3.5f; x += 3.5f;
if (g_Vars.currentplayernum == 0) { if (g_Vars.currentplayernum == 0) {
+4 -4
View File
@@ -2183,7 +2183,7 @@ Gfx *text0f156a24(Gfx *gdl, s32 x, s32 y, struct fontchar *char1, s32 arg4, s32
if (y + char1->baseline >= arg5) { if (y + char1->baseline >= arg5) {
if (arg5 + arg7 >= y + char1->baseline + char1->height + 2) { if (arg5 + arg7 >= y + char1->baseline + char1->height + 2) {
if (g_TextRotated90) { if (g_TextRotated90) {
gSPTextureRectangleFlip(gdl++, gSPTextureRectangleFlipEXT(gdl++,
((y - char1->baseline) - ((char1->height + 2) * var8007fad0)) * 4, ((y - char1->baseline) - ((char1->height + 2) * var8007fad0)) * 4,
x * 4, x * 4,
(y - char1->baseline) * 4, (y - char1->baseline) * 4,
@@ -2194,7 +2194,7 @@ Gfx *text0f156a24(Gfx *gdl, s32 x, s32 y, struct fontchar *char1, s32 arg4, s32
1024 / var8007fad0, 1024 / var8007fad0,
-1024); -1024);
} else { } else {
gSPTextureRectangle(gdl++, gSPTextureRectangleEXT(gdl++,
x * 4, x * 4,
(y + char1->baseline) * 4, (y + char1->baseline) * 4,
(x + char1->width * var8007fad0 + 2) * 4, (x + char1->width * var8007fad0 + 2) * 4,
@@ -2207,7 +2207,7 @@ Gfx *text0f156a24(Gfx *gdl, s32 x, s32 y, struct fontchar *char1, s32 arg4, s32
} }
} else { } else {
if (arg5 + arg7 >= y + char1->baseline) { if (arg5 + arg7 >= y + char1->baseline) {
gSPTextureRectangle(gdl++, gSPTextureRectangleEXT(gdl++,
x * 4, x * 4,
(y + char1->baseline) * 4, (y + char1->baseline) * 4,
(x + char1->width * var8007fad0 + 2) * 4, (x + char1->width * var8007fad0 + 2) * 4,
@@ -2221,7 +2221,7 @@ Gfx *text0f156a24(Gfx *gdl, s32 x, s32 y, struct fontchar *char1, s32 arg4, s32
} }
} else { } else {
if (y + char1->baseline + char1->height + 2 >= arg5) { if (y + char1->baseline + char1->height + 2 >= arg5) {
gSPTextureRectangle(gdl++, gSPTextureRectangleEXT(gdl++,
x * 4, x * 4,
arg5 * 4, arg5 * 4,
(x + char1->width * var8007fad0 + 2) * 4, (x + char1->width * var8007fad0 + 2) * 4,
+4 -4
View File
@@ -258,7 +258,7 @@ void gamefileLoadDefaults(struct gamefile *file)
} }
for (i = 0; i < ARRAYCOUNT(g_MpChallenges); i++) { for (i = 0; i < ARRAYCOUNT(g_MpChallenges); i++) {
for (j = 1; j < MAX_PLAYERS + 1; j++) { for (j = 1; j < MAX_LOCAL_PLAYERS + 1; j++) {
challengeSetCompletedByAnyPlayerWithNumPlayers(i, j, false); challengeSetCompletedByAnyPlayerWithNumPlayers(i, j, false);
} }
} }
@@ -362,7 +362,7 @@ s32 gamefileLoad(s32 device)
} }
for (i = 0; i < ARRAYCOUNT(g_MpChallenges); i++) { for (i = 0; i < ARRAYCOUNT(g_MpChallenges); i++) {
for (j = 1; j < MAX_PLAYERS + 1; j++) { for (j = 1; j < MAX_LOCAL_PLAYERS + 1; j++) {
challengeSetCompletedByAnyPlayerWithNumPlayers(i, j, savebufferReadBits(&buffer, 1)); challengeSetCompletedByAnyPlayerWithNumPlayers(i, j, savebufferReadBits(&buffer, 1));
} }
} }
@@ -537,7 +537,7 @@ s32 gamefileSave(s32 device, s32 fileid, u16 deviceserial)
} }
for (i = 0; i < ARRAYCOUNT(g_MpChallenges); i++) { for (i = 0; i < ARRAYCOUNT(g_MpChallenges); i++) {
for (j = 1; j < MAX_PLAYERS + 1; j++) { for (j = 1; j < MAX_LOCAL_PLAYERS + 1; j++) {
savebufferOr(&buffer, challengeIsCompletedByAnyPlayerWithNumPlayers(i, j), 1); savebufferOr(&buffer, challengeIsCompletedByAnyPlayerWithNumPlayers(i, j), 1);
} }
} }
@@ -598,7 +598,7 @@ void gamefileUnlockEverything(void)
// unlock all challenges // unlock all challenges
for (i = 0; i < ARRAYCOUNT(g_MpChallenges); ++i) { for (i = 0; i < ARRAYCOUNT(g_MpChallenges); ++i) {
for (j = 0; j < MAX_PLAYERS; ++j) { for (j = 0; j < MAX_LOCAL_PLAYERS; ++j) {
g_MpChallenges[i].completions[j] = 0xff; g_MpChallenges[i].completions[j] = 0xff;
} }
} }
+22
View File
@@ -57,6 +57,12 @@ u32 g_GfxSizesByPlayerCount[] = {
0x00018000 * GFX_SIZE_MULTIPLIER, 0x00018000 * GFX_SIZE_MULTIPLIER,
0x00020000 * GFX_SIZE_MULTIPLIER, 0x00020000 * GFX_SIZE_MULTIPLIER,
0x00028000 * GFX_SIZE_MULTIPLIER, 0x00028000 * GFX_SIZE_MULTIPLIER,
#ifndef PLATFORM_N64
0x00030000 * GFX_SIZE_MULTIPLIER,
0x00038000 * GFX_SIZE_MULTIPLIER,
0x00040000 * GFX_SIZE_MULTIPLIER,
0x00048000 * GFX_SIZE_MULTIPLIER,
#endif
}; };
u32 g_VtxSizesByPlayerCount[] = { u32 g_VtxSizesByPlayerCount[] = {
@@ -64,6 +70,12 @@ u32 g_VtxSizesByPlayerCount[] = {
0x00018000, 0x00018000,
0x00020000, 0x00020000,
0x00028000, 0x00028000,
#ifndef PLATFORM_N64
0x00030000,
0x00038000,
0x00040000,
0x00048000,
#endif
}; };
s32 g_GfxNumSwapsPerBuffer[NUM_GFXTASKS] = {0, 1}; s32 g_GfxNumSwapsPerBuffer[NUM_GFXTASKS] = {0, 1};
@@ -104,11 +116,21 @@ void gfxReset(void)
// ******** Extra Amount required = %dK ber buffer\n // ******** Extra Amount required = %dK ber buffer\n
// ******** Total of %dK (Double Buffered)\n // ******** Total of %dK (Double Buffered)\n
g_GfxSizesByPlayerCount[PLAYERCOUNT() - 1] = (gfx + gfxtra) * GFX_SIZE_MULTIPLIER; g_GfxSizesByPlayerCount[PLAYERCOUNT() - 1] = (gfx + gfxtra) * GFX_SIZE_MULTIPLIER;
#ifndef PLATFORM_N64
if (PLAYERCOUNT() > MAX_LOCAL_PLAYERS) {
g_GfxSizesByPlayerCount[PLAYERCOUNT() - 1] *= MAX_PLAYERS / MAX_LOCAL_PLAYERS;
}
#endif
} }
if (argFindByPrefix(1, "-mvtx")) { if (argFindByPrefix(1, "-mvtx")) {
// Argument specified mtxvtx_size\n // Argument specified mtxvtx_size\n
g_VtxSizesByPlayerCount[PLAYERCOUNT() - 1] = strtol(argFindByPrefix(1, "-mvtx"), NULL, 0) * 1024; g_VtxSizesByPlayerCount[PLAYERCOUNT() - 1] = strtol(argFindByPrefix(1, "-mvtx"), NULL, 0) * 1024;
#ifndef PLATFORM_N64
if (PLAYERCOUNT() > MAX_LOCAL_PLAYERS) {
g_VtxSizesByPlayerCount[PLAYERCOUNT() - 1] *= MAX_PLAYERS / MAX_LOCAL_PLAYERS;
}
#endif
} }
// %d Players : Allocating %d bytes for master dl's\n // %d Players : Allocating %d bytes for master dl's\n
+22 -15
View File
@@ -86,7 +86,7 @@ u8 hudmsgsAreActive(void)
s32 hudmsgIsZoomRangeVisible(void) s32 hudmsgIsZoomRangeVisible(void)
{ {
return optionsGetShowZoomRange(g_Vars.currentplayerstats->mpindex) return optionsGetShowZoomRange(g_Vars.currentplayerstats->mpindex)
&& (PLAYERCOUNT() == 1 && (LOCALPLAYERCOUNT() == 1
|| !g_Vars.mplayerisrunning || !g_Vars.mplayerisrunning
|| g_Vars.coopplayernum >= 0 || g_Vars.coopplayernum >= 0
|| g_Vars.antiplayernum >= 0) || g_Vars.antiplayernum >= 0)
@@ -131,7 +131,7 @@ Gfx *hudmsgRenderMissionTimer(Gfx *gdl, u32 alpha)
viewleft = viGetViewLeft() / g_ScaleX; viewleft = viGetViewLeft() / g_ScaleX;
viewtop = viGetViewTop(); viewtop = viGetViewTop();
viewheight = viGetViewHeight(); viewheight = viGetViewHeight();
playercount = PLAYERCOUNT(); playercount = LOCALPLAYERCOUNT();
playernum = g_Vars.currentplayernum; playernum = g_Vars.currentplayernum;
timery = viewheight; timery = viewheight;
@@ -234,7 +234,7 @@ Gfx *hudmsgRenderZoomRange(Gfx *gdl, u32 alpha)
texty = viewheight + viewtop - 1; texty = viewheight + viewtop - 1;
maxzoom = 1.0f; maxzoom = 1.0f;
weaponnum = g_Vars.currentplayer->hands[0].gset.weaponnum; weaponnum = g_Vars.currentplayer->hands[0].gset.weaponnum;
playercount = PLAYERCOUNT(); playercount = LOCALPLAYERCOUNT();
texty -= 17; texty -= 17;
@@ -374,7 +374,7 @@ s32 hudmsg0f0ddb1c(s32 *arg0, s32 arg1)
*arg0 = 24; *arg0 = 24;
if (PLAYERCOUNT() == 2 if (LOCALPLAYERCOUNT() == 2
&& optionsGetScreenSplit() == SCREENSPLIT_VERTICAL && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL
&& (!g_InCutscene || g_MainIsEndscreen)) { && (!g_InCutscene || g_MainIsEndscreen)) {
result -= *arg0 * 2 / 3; result -= *arg0 * 2 / 3;
@@ -388,7 +388,7 @@ s32 hudmsg0f0ddb1c(s32 *arg0, s32 arg1)
result = result + viewwidth - *arg0 - arg1 - 11; result = result + viewwidth - *arg0 - arg1 - 11;
if (PLAYERCOUNT() == 1 || (PLAYERCOUNT() == 2 && g_InCutscene && !g_MainIsEndscreen)) { if (LOCALPLAYERCOUNT() == 1 || (LOCALPLAYERCOUNT() == 2 && g_InCutscene && !g_MainIsEndscreen)) {
result -= 16; result -= 16;
#if VERSION < VERSION_JPN_FINAL #if VERSION < VERSION_JPN_FINAL
@@ -403,7 +403,7 @@ s32 hudmsg0f0ddb1c(s32 *arg0, s32 arg1)
*arg0 = 24; *arg0 = 24;
if (PLAYERCOUNT() == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) { if (LOCALPLAYERCOUNT() == 2 && optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) {
result -= *arg0 * 2 / 3; result -= *arg0 * 2 / 3;
if (g_Vars.currentplayernum == 0) { if (g_Vars.currentplayernum == 0) {
@@ -415,7 +415,7 @@ s32 hudmsg0f0ddb1c(s32 *arg0, s32 arg1)
result = result + viewwidth - *arg0 - arg1 - 11; result = result + viewwidth - *arg0 - arg1 - 11;
if (PLAYERCOUNT() == 1) { if (LOCALPLAYERCOUNT() == 1) {
result -= 16; result -= 16;
} }
#endif #endif
@@ -857,7 +857,7 @@ void hudmsgCalculatePosition(struct hudmessage *msg)
#if VERSION >= VERSION_NTSC_1_0 #if VERSION >= VERSION_NTSC_1_0
s32 offset = (msg->alignh == HUDMSGALIGN_XMIDDLE) ? 10 : 0; s32 offset = (msg->alignh == HUDMSGALIGN_XMIDDLE) ? 10 : 0;
if (PLAYERCOUNT() >= 3) { if (LOCALPLAYERCOUNT() >= 3) {
viewwidth -= offset; viewwidth -= offset;
if (g_Vars.currentplayernum == 0 || g_Vars.currentplayernum == 2) { if (g_Vars.currentplayernum == 0 || g_Vars.currentplayernum == 2) {
@@ -865,7 +865,7 @@ void hudmsgCalculatePosition(struct hudmessage *msg)
} }
} }
if (PLAYERCOUNT() == 2 && (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL || IS4MB())) { if (LOCALPLAYERCOUNT() == 2 && (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL || IS4MB())) {
#if VERSION >= VERSION_PAL_FINAL #if VERSION >= VERSION_PAL_FINAL
if (!g_InCutscene || g_MainIsEndscreen) if (!g_InCutscene || g_MainIsEndscreen)
#endif #endif
@@ -888,7 +888,7 @@ void hudmsgCalculatePosition(struct hudmessage *msg)
x = viewleft + v0 + msg->xmargin + 3; x = viewleft + v0 + msg->xmargin + 3;
if (PLAYERCOUNT() == 2 if (LOCALPLAYERCOUNT() == 2
&& (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL || IS4MB()) && (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL || IS4MB())
&& (!g_InCutscene || g_MainIsEndscreen)) { && (!g_InCutscene || g_MainIsEndscreen)) {
if (IS4MB()) { if (IS4MB()) {
@@ -904,7 +904,7 @@ void hudmsgCalculatePosition(struct hudmessage *msg)
x += 4; x += 4;
} }
} }
} else if (PLAYERCOUNT() >= 3) { } else if (LOCALPLAYERCOUNT() >= 3) {
if ((msg->playernum % 2) == 0) { if ((msg->playernum % 2) == 0) {
x--; x--;
} else { } else {
@@ -933,13 +933,13 @@ void hudmsgCalculatePosition(struct hudmessage *msg)
case HUDMSGALIGN_BOTTOM: case HUDMSGALIGN_BOTTOM:
y = viewtop + viewheight - msg->height - msg->ymargin - 14; y = viewtop + viewheight - msg->height - msg->ymargin - 14;
if (PLAYERCOUNT() == 2 && (g_InCutscene == 0 || g_MainIsEndscreen)) { if (LOCALPLAYERCOUNT() == 2 && (g_InCutscene == 0 || g_MainIsEndscreen)) {
if (IS4MB() || (optionsGetScreenSplit() != SCREENSPLIT_VERTICAL && msg->playernum == 0)) { if (IS4MB() || (optionsGetScreenSplit() != SCREENSPLIT_VERTICAL && msg->playernum == 0)) {
y += 8; y += 8;
} else { } else {
y += 3; y += 3;
} }
} else if (PLAYERCOUNT() >= 3) { } else if (LOCALPLAYERCOUNT() >= 3) {
if (msg->playernum <= 1) { if (msg->playernum <= 1) {
y += 8; y += 8;
} else { } else {
@@ -987,6 +987,13 @@ void hudmsgCreateFromArgs(char *text, s32 type, s32 conf00, s32 conf01, s32 conf
return; return;
} }
#ifndef PLATFORM_N64
if (g_NetMode && g_Vars.currentplayernum != 0) {
// do not create hudmsgs for other net players
return;
}
#endif
for (j = 0; text[j] != '\0'; j++) { for (j = 0; text[j] != '\0'; j++) {
hash = hash + text[j]; hash = hash + text[j];
} }
@@ -1284,7 +1291,7 @@ void hudmsgsTick(void)
&& msg->type != HUDMSGTYPE_CUTSCENESUBTITLE && msg->type != HUDMSGTYPE_CUTSCENESUBTITLE
&& msg->type != HUDMSGTYPE_INGAMESUBTITLE && msg->type != HUDMSGTYPE_INGAMESUBTITLE
#endif #endif
&& PLAYERCOUNT() == 1) { && LOCALPLAYERCOUNT() == 1) {
#if VERSION >= VERSION_NTSC_1_0 #if VERSION >= VERSION_NTSC_1_0
sndStart(var80095200, SFX_HUDMSG, NULL, -1, -1, -1, -1, -1); sndStart(var80095200, SFX_HUDMSG, NULL, -1, -1, -1, -1, -1);
#else #else
@@ -1383,7 +1390,7 @@ Gfx *hudmsgsRender(Gfx *gdl)
s32 timerthing = 255; s32 timerthing = 255;
s32 spdc = true; s32 spdc = true;
#ifndef PLATFORM_N64 #ifndef PLATFORM_N64
const s32 playercount = PLAYERCOUNT(); const s32 playercount = LOCALPLAYERCOUNT();
#endif #endif
#if PAL #if PAL
+47 -4
View File
@@ -97,6 +97,8 @@
#include "lib/vi.h" #include "lib/vi.h"
#include "types.h" #include "types.h"
#ifndef PLATFORM_N64 #ifndef PLATFORM_N64
#include "net/net.h"
#include "net/netmsg.h"
#include "video.h" #include "video.h"
#endif #endif
@@ -322,6 +324,16 @@ void lvReset(s32 stagenum)
s32 i; s32 i;
s32 j; s32 j;
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_SERVER) {
// if we're a server, signal to clients that the level is changing
netServerStageStart();
} else if (g_NetMode == NETMODE_CLIENT) {
// if we're a client, now is the time to apply the server's RNG seeds
netClientSyncRng();
}
#endif
tilesReset(); tilesReset();
bgReset(g_Vars.stagenum); bgReset(g_Vars.stagenum);
bgBuildTables(g_Vars.stagenum); bgBuildTables(g_Vars.stagenum);
@@ -338,9 +350,9 @@ void lvReset(s32 stagenum)
} }
if (g_Vars.mplayerisrunning == false) { if (g_Vars.mplayerisrunning == false) {
g_Vars.playerstats[0].mpindex = 4; g_Vars.playerstats[0].mpindex = MAX_PLAYERS;
g_PlayerConfigsArray[4].contpad1 = 0; g_PlayerConfigsArray[MAX_PLAYERS].contpad1 = 0;
g_PlayerConfigsArray[4].contpad2 = 1; g_PlayerConfigsArray[MAX_PLAYERS].contpad2 = 1;
} }
for (i = 0; i != ARRAYCOUNT(g_Vars.playerstats); i++) { for (i = 0; i != ARRAYCOUNT(g_Vars.playerstats); i++) {
@@ -463,6 +475,12 @@ void lvReset(s32 stagenum)
pheadReset(); pheadReset();
} }
#ifndef PLATFORM_N64
if (g_NetMode) {
netSyncIdsAllocate();
}
#endif
modelmgrSetLvResetting(false); modelmgrSetLvResetting(false);
var80084018 = 1; var80084018 = 1;
schedResetArtifacts(); schedResetArtifacts();
@@ -1125,6 +1143,13 @@ Gfx *lvRender(Gfx *gdl)
struct player *player; struct player *player;
struct chrdata *chr; struct chrdata *chr;
#ifndef PLATFORM_N64
if (g_NetMode) {
// tick all players, we'll skip the rendering
forcesingleplayer = false;
}
#endif
playercount = forcesingleplayer ? 1 : PLAYERCOUNT(); playercount = forcesingleplayer ? 1 : PLAYERCOUNT();
gSPClipRatio(gdl++, FRUSTRATIO_2); gSPClipRatio(gdl++, FRUSTRATIO_2);
@@ -1717,12 +1742,21 @@ Gfx *lvRender(Gfx *gdl)
} }
if (g_Vars.currentplayer->dostartnewlife) { if (g_Vars.currentplayer->dostartnewlife) {
playerStartNewLife(); #ifndef PLATFORM_N64
if (g_NetMode != NETMODE_CLIENT)
#endif
playerStartNewLife();
} }
} }
artifactsTick(); artifactsTick();
#ifndef PLATFORM_N64
if ((g_NetMode && i) || i >= MAX_LOCAL_PLAYERS) {
gdl = savedgdl;
}
#endif
if ((g_Vars.coopplayernum >= 0 || g_Vars.antiplayernum >= 0) if ((g_Vars.coopplayernum >= 0 || g_Vars.antiplayernum >= 0)
#if VERSION >= VERSION_NTSC_1_0 #if VERSION >= VERSION_NTSC_1_0
&& playerHasSharedViewport() && playerHasSharedViewport()
@@ -2275,6 +2309,9 @@ void lvTick(void)
if (elapsed < TICKS(g_MpTimeLimit60) && nexttime >= TICKS(g_MpTimeLimit60)) { if (elapsed < TICKS(g_MpTimeLimit60) && nexttime >= TICKS(g_MpTimeLimit60)) {
// Match is ending due to time limit reached // Match is ending due to time limit reached
#ifndef PLATFORM_N64
if (g_NetMode != NETMODE_CLIENT)
#endif
mainEndStage(); mainEndStage();
} }
@@ -2328,6 +2365,12 @@ void lvTick(void)
} }
} }
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_CLIENT) {
g_NumReasonsToEndMpMatch = 0;
}
#endif
if (g_NumReasonsToEndMpMatch > 0 && numdying == 0) { if (g_NumReasonsToEndMpMatch > 0 && numdying == 0) {
mainEndStage(); mainEndStage();
} }
+240 -59
View File
@@ -33,6 +33,9 @@
#include "lib/str.h" #include "lib/str.h"
#include "data.h" #include "data.h"
#include "types.h" #include "types.h"
#ifndef PLATFORM_N64
#include "net/net.h"
#endif
u8 g_InventoryWeapon; u8 g_InventoryWeapon;
@@ -41,6 +44,11 @@ struct menudialogdef g_CiControlPlayer2MenuDialog;
struct menudialogdef g_CinemaMenuDialog; struct menudialogdef g_CinemaMenuDialog;
#ifndef PLATFORM_N64 #ifndef PLATFORM_N64
extern struct menudialogdef g_ExtendedMenuDialog; extern struct menudialogdef g_ExtendedMenuDialog;
extern struct menudialogdef g_NetMenuDialog;
extern MenuItemHandlerResult menuhandlerJoinGame(s32 operation, struct menuitem *item, union handlerdata *data);
extern MenuItemHandlerResult menuhandlerJoinStart(s32 operation, struct menuitem *item, union handlerdata *data);
extern MenuItemHandlerResult menuhandlerHostGame(s32 operation, struct menuitem *item, union handlerdata *data);
extern MenuItemHandlerResult menuhandlerHostStart(s32 operation, struct menuitem *item, union handlerdata *data);
#endif #endif
char *menuTextCurrentStageName(struct menuitem *item) char *menuTextCurrentStageName(struct menuitem *item)
@@ -740,6 +748,7 @@ MenuItemHandlerResult menuhandlerAcceptMission(s32 operation, struct menuitem *i
setNumPlayers(1); setNumPlayers(1);
} }
} else if (g_MissionConfig.isanti) { } else if (g_MissionConfig.isanti) {
#ifdef PLATFORM_N64
if (g_Vars.pendingantiplayernum == 1) { if (g_Vars.pendingantiplayernum == 1) {
g_Vars.bondplayernum = 0; g_Vars.bondplayernum = 0;
g_Vars.antiplayernum = 1; g_Vars.antiplayernum = 1;
@@ -749,7 +758,27 @@ MenuItemHandlerResult menuhandlerAcceptMission(s32 operation, struct menuitem *i
} }
g_Vars.coopplayernum = -1; g_Vars.coopplayernum = -1;
setNumPlayers(2); setNumPlayers(2);
#else
u32 contmask = joyGetConnectedControllers();
u32 plrcount = 0;
u32 tmpmask;
// Count all players
tmpmask = contmask;
while (tmpmask) {
plrcount += (tmpmask & 0x1);
tmpmask >>= 1;
}
g_Vars.bondplayernum = g_Vars.pendingantiplayernum ^ 1;
g_Vars.antiplayernum = (g_Vars.bondplayernum == 0 ? 1 : 0);
g_Vars.coopplayernum = -1;
setNumPlayers(plrcount);
g_MpSetup.chrslots = contmask;
#endif
} else { } else {
// Solo // Solo
g_Vars.bondplayernum = 0; g_Vars.bondplayernum = 0;
@@ -1537,6 +1566,8 @@ MenuItemHandlerResult menuhandlerAntiRadar(s32 operation, struct menuitem *item,
return 0; return 0;
} }
#ifdef PLATFORM_N64
MenuItemHandlerResult menuhandlerAntiPlayer(s32 operation, struct menuitem *item, union handlerdata *data) MenuItemHandlerResult menuhandlerAntiPlayer(s32 operation, struct menuitem *item, union handlerdata *data)
{ {
const u16 labels[] = {L_OPTIONS_271, L_OPTIONS_272}; const u16 labels[] = {L_OPTIONS_271, L_OPTIONS_272};
@@ -1603,6 +1634,100 @@ struct menuitem g_AntiOptionsMenuItems[] = {
{ MENUITEMTYPE_END }, { MENUITEMTYPE_END },
}; };
#else
MenuItemHandlerResult menuhandlerAntiMainPlayer(s32 operation, struct menuitem *item, union handlerdata *data)
{
static const char *labels[] = {
"Player 1",
"Player 2",
"Player 3",
"Player 4",
};
// For consistency with the main save format,
// the main player is (pendingantiplayernum XOR 1)
// g_Vars.(bond|anti|coop)playernum is based on the n'th player slot, not the n'th controller;
// that is, it's not based on g_MpSetup.chrslots.
// Because of this, it's easier just to change the label.
u32 tmpmask = joyGetConnectedControllers();
u32 plrcount = 0;
u32 labelidx = 0;
while (tmpmask) {
plrcount += (tmpmask & 0x1);
if (plrcount <= data->dropdown.value) {
labelidx += 1;
}
tmpmask >>= 1;
}
switch (operation) {
case MENUOP_GETOPTIONCOUNT:
data->dropdown.value = plrcount;
break;
case MENUOP_GETOPTIONTEXT:
return (s32) (labels[labelidx]);
case MENUOP_SET:
g_Vars.pendingantiplayernum = data->dropdown.value ^ 1;
g_Vars.modifiedfiles |= MODFILE_GAME;
break;
case MENUOP_GETSELECTEDINDEX:
data->dropdown.value = g_Vars.pendingantiplayernum ^ 1;
break;
}
return 0;
}
struct menuitem g_AntiOptionsMenuItems[] = {
{
MENUITEMTYPE_CHECKBOX,
0,
0,
L_OPTIONS_267, // "Radar On"
0,
menuhandlerAntiRadar,
},
{
MENUITEMTYPE_DROPDOWN,
0,
MENUITEMFLAG_LITERAL_TEXT,
(uintptr_t)"Main Player",
0,
menuhandlerAntiMainPlayer,
},
{
MENUITEMTYPE_SEPARATOR,
0,
0,
0,
0,
NULL,
},
{
MENUITEMTYPE_SELECTABLE,
0,
0,
L_OPTIONS_269, // "Continue"
0,
menuhandlerBuddyOptionsContinue,
},
{
MENUITEMTYPE_SELECTABLE,
0,
MENUITEMFLAG_SELECTABLE_CLOSESDIALOG,
L_OPTIONS_270, // "Cancel"
0,
NULL,
},
{ MENUITEMTYPE_END },
};
#endif
struct menudialogdef g_AntiOptionsMenuDialog = { struct menudialogdef g_AntiOptionsMenuDialog = {
MENUDIALOGTYPE_DEFAULT, MENUDIALOGTYPE_DEFAULT,
L_OPTIONS_266, // "Counter-Operative Options" L_OPTIONS_266, // "Counter-Operative Options"
@@ -2682,7 +2807,7 @@ struct menuitem g_MissionDisplayOptionsMenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_205, // "Sight on Screen" L_OPTIONS_205, // "Sight on Screen"
0x00000004, MAX_PLAYERS,
menuhandlerSightOnScreen, menuhandlerSightOnScreen,
}, },
{ {
@@ -2690,7 +2815,7 @@ struct menuitem g_MissionDisplayOptionsMenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_206, // "Always Show Target" L_OPTIONS_206, // "Always Show Target"
0x00000004, MAX_PLAYERS,
menuhandlerAlwaysShowTarget, menuhandlerAlwaysShowTarget,
}, },
{ {
@@ -2698,7 +2823,7 @@ struct menuitem g_MissionDisplayOptionsMenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_207, // "Show Zoom Range" L_OPTIONS_207, // "Show Zoom Range"
0x00000004, MAX_PLAYERS,
menuhandlerShowZoomRange, menuhandlerShowZoomRange,
}, },
{ {
@@ -2706,7 +2831,7 @@ struct menuitem g_MissionDisplayOptionsMenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_208, // "Ammo on Screen" L_OPTIONS_208, // "Ammo on Screen"
0x00000004, MAX_PLAYERS,
menuhandlerAmmoOnScreen, menuhandlerAmmoOnScreen,
}, },
{ {
@@ -2714,7 +2839,7 @@ struct menuitem g_MissionDisplayOptionsMenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_209, // "Show Gun Function" L_OPTIONS_209, // "Show Gun Function"
0x00000004, MAX_PLAYERS,
menuhandlerShowGunFunction, menuhandlerShowGunFunction,
}, },
{ {
@@ -2722,7 +2847,7 @@ struct menuitem g_MissionDisplayOptionsMenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_210, // "Paintball" L_OPTIONS_210, // "Paintball"
0x00000004, MAX_PLAYERS,
menuhandlerPaintball, menuhandlerPaintball,
}, },
{ {
@@ -2730,7 +2855,7 @@ struct menuitem g_MissionDisplayOptionsMenuItems[] = {
0, 0,
0, 0,
L_MPWEAPONS_169, // "In-Game Subtitles" L_MPWEAPONS_169, // "In-Game Subtitles"
0x00000004, MAX_PLAYERS,
menuhandlerInGameSubtitles, menuhandlerInGameSubtitles,
}, },
{ {
@@ -2738,7 +2863,7 @@ struct menuitem g_MissionDisplayOptionsMenuItems[] = {
0, 0,
0, 0,
L_MPWEAPONS_168, // "Cutscene Subtitles" L_MPWEAPONS_168, // "Cutscene Subtitles"
0x00000004, MAX_PLAYERS,
menuhandlerCutsceneSubtitles, menuhandlerCutsceneSubtitles,
}, },
{ {
@@ -2746,7 +2871,7 @@ struct menuitem g_MissionDisplayOptionsMenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_212, // "Show Mission Time" L_OPTIONS_212, // "Show Mission Time"
0x00000004, MAX_PLAYERS,
menuhandlerShowMissionTime, menuhandlerShowMissionTime,
}, },
{ {
@@ -2783,7 +2908,7 @@ struct menuitem g_2PMissionDisplayOptionsVMenuItems[] = {
0, 0,
0, 0,
L_MPWEAPONS_145, // "Sight on Screen" L_MPWEAPONS_145, // "Sight on Screen"
0x00000004, MAX_PLAYERS,
menuhandlerSightOnScreen, menuhandlerSightOnScreen,
}, },
{ {
@@ -2791,7 +2916,7 @@ struct menuitem g_2PMissionDisplayOptionsVMenuItems[] = {
0, 0,
0, 0,
L_MPWEAPONS_146, // "Target" L_MPWEAPONS_146, // "Target"
0x00000004, MAX_PLAYERS,
menuhandlerAlwaysShowTarget, menuhandlerAlwaysShowTarget,
}, },
{ {
@@ -2799,7 +2924,7 @@ struct menuitem g_2PMissionDisplayOptionsVMenuItems[] = {
0, 0,
0, 0,
L_MPWEAPONS_147, // "Zoom Range" L_MPWEAPONS_147, // "Zoom Range"
0x00000004, MAX_PLAYERS,
menuhandlerShowZoomRange, menuhandlerShowZoomRange,
}, },
{ {
@@ -2807,7 +2932,7 @@ struct menuitem g_2PMissionDisplayOptionsVMenuItems[] = {
0, 0,
0, 0,
L_MPWEAPONS_148, // "Show Ammo" L_MPWEAPONS_148, // "Show Ammo"
0x00000004, MAX_PLAYERS,
menuhandlerAmmoOnScreen, menuhandlerAmmoOnScreen,
}, },
{ {
@@ -2815,7 +2940,7 @@ struct menuitem g_2PMissionDisplayOptionsVMenuItems[] = {
0, 0,
0, 0,
L_MPWEAPONS_149, // "Gun Function" L_MPWEAPONS_149, // "Gun Function"
0x00000004, MAX_PLAYERS,
menuhandlerShowGunFunction, menuhandlerShowGunFunction,
}, },
{ {
@@ -2823,7 +2948,7 @@ struct menuitem g_2PMissionDisplayOptionsVMenuItems[] = {
0, 0,
0, 0,
L_MPWEAPONS_150, // "Paintball" L_MPWEAPONS_150, // "Paintball"
0x00000004, MAX_PLAYERS,
menuhandlerPaintball, menuhandlerPaintball,
}, },
{ {
@@ -2835,7 +2960,7 @@ struct menuitem g_2PMissionDisplayOptionsVMenuItems[] = {
#else #else
L_MPWEAPONS_169, // "In-Game Subtitles" L_MPWEAPONS_169, // "In-Game Subtitles"
#endif #endif
0x00000004, MAX_PLAYERS,
menuhandlerInGameSubtitles, menuhandlerInGameSubtitles,
}, },
{ {
@@ -2847,7 +2972,7 @@ struct menuitem g_2PMissionDisplayOptionsVMenuItems[] = {
#else #else
L_MPWEAPONS_168, // "Cutscene Subtitles" L_MPWEAPONS_168, // "Cutscene Subtitles"
#endif #endif
0x00000004, MAX_PLAYERS,
menuhandlerCutsceneSubtitles, menuhandlerCutsceneSubtitles,
}, },
{ {
@@ -2855,7 +2980,7 @@ struct menuitem g_2PMissionDisplayOptionsVMenuItems[] = {
0, 0,
0, 0,
L_MPWEAPONS_152, // "Mission Time" L_MPWEAPONS_152, // "Mission Time"
0x00000004, MAX_PLAYERS,
menuhandlerShowMissionTime, menuhandlerShowMissionTime,
}, },
{ {
@@ -2892,7 +3017,7 @@ struct menuitem g_CiDisplayMenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_205, // "Sight on Screen" L_OPTIONS_205, // "Sight on Screen"
0x00000004, MAX_PLAYERS,
menuhandlerSightOnScreen, menuhandlerSightOnScreen,
}, },
{ {
@@ -2900,7 +3025,7 @@ struct menuitem g_CiDisplayMenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_206, // "Always Show Target" L_OPTIONS_206, // "Always Show Target"
0x00000004, MAX_PLAYERS,
menuhandlerAlwaysShowTarget, menuhandlerAlwaysShowTarget,
}, },
{ {
@@ -2908,7 +3033,7 @@ struct menuitem g_CiDisplayMenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_207, // "Show Zoom Range" L_OPTIONS_207, // "Show Zoom Range"
0x00000004, MAX_PLAYERS,
menuhandlerShowZoomRange, menuhandlerShowZoomRange,
}, },
{ {
@@ -2916,7 +3041,7 @@ struct menuitem g_CiDisplayMenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_208, // "Ammo on Screen" L_OPTIONS_208, // "Ammo on Screen"
0x00000004, MAX_PLAYERS,
menuhandlerAmmoOnScreen, menuhandlerAmmoOnScreen,
}, },
{ {
@@ -2924,7 +3049,7 @@ struct menuitem g_CiDisplayMenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_209, // "Show Gun Function" L_OPTIONS_209, // "Show Gun Function"
0x00000004, MAX_PLAYERS,
menuhandlerShowGunFunction, menuhandlerShowGunFunction,
}, },
{ {
@@ -2932,7 +3057,7 @@ struct menuitem g_CiDisplayMenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_210, // "Paintball" L_OPTIONS_210, // "Paintball"
0x00000004, MAX_PLAYERS,
menuhandlerPaintball, menuhandlerPaintball,
}, },
{ {
@@ -2940,7 +3065,7 @@ struct menuitem g_CiDisplayMenuItems[] = {
0, 0,
0, 0,
L_MPWEAPONS_169, // "In-Game Subtitles" L_MPWEAPONS_169, // "In-Game Subtitles"
0x00000004, MAX_PLAYERS,
menuhandlerInGameSubtitles, menuhandlerInGameSubtitles,
}, },
{ {
@@ -2948,7 +3073,7 @@ struct menuitem g_CiDisplayMenuItems[] = {
0, 0,
0, 0,
L_MPWEAPONS_168, // "Cutscene Subtitles" L_MPWEAPONS_168, // "Cutscene Subtitles"
0x00000004, MAX_PLAYERS,
menuhandlerCutsceneSubtitles, menuhandlerCutsceneSubtitles,
}, },
{ {
@@ -2956,7 +3081,7 @@ struct menuitem g_CiDisplayMenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_212, // "Show Mission Time" L_OPTIONS_212, // "Show Mission Time"
0x00000004, MAX_PLAYERS,
menuhandlerShowMissionTime, menuhandlerShowMissionTime,
}, },
{ {
@@ -2995,7 +3120,7 @@ struct menuitem g_CiDisplayPlayer2MenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_205, // "Sight on Screen" L_OPTIONS_205, // "Sight on Screen"
0x00000005, MAX_PLAYERS + 1,
menuhandlerSightOnScreen, menuhandlerSightOnScreen,
}, },
{ {
@@ -3003,7 +3128,7 @@ struct menuitem g_CiDisplayPlayer2MenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_206, // "Always Show Target" L_OPTIONS_206, // "Always Show Target"
0x00000005, MAX_PLAYERS + 1,
menuhandlerAlwaysShowTarget, menuhandlerAlwaysShowTarget,
}, },
{ {
@@ -3011,7 +3136,7 @@ struct menuitem g_CiDisplayPlayer2MenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_207, // "Show Zoom Range" L_OPTIONS_207, // "Show Zoom Range"
0x00000005, MAX_PLAYERS + 1,
menuhandlerShowZoomRange, menuhandlerShowZoomRange,
}, },
{ {
@@ -3019,7 +3144,7 @@ struct menuitem g_CiDisplayPlayer2MenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_208, // "Ammo on Screen" L_OPTIONS_208, // "Ammo on Screen"
0x00000005, MAX_PLAYERS + 1,
menuhandlerAmmoOnScreen, menuhandlerAmmoOnScreen,
}, },
{ {
@@ -3027,7 +3152,7 @@ struct menuitem g_CiDisplayPlayer2MenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_209, // "Show Gun Function" L_OPTIONS_209, // "Show Gun Function"
0x00000005, MAX_PLAYERS + 1,
menuhandlerShowGunFunction, menuhandlerShowGunFunction,
}, },
{ {
@@ -3035,7 +3160,7 @@ struct menuitem g_CiDisplayPlayer2MenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_210, // "Paintball" L_OPTIONS_210, // "Paintball"
0x00000005, MAX_PLAYERS + 1,
menuhandlerPaintball, menuhandlerPaintball,
}, },
{ {
@@ -3043,7 +3168,7 @@ struct menuitem g_CiDisplayPlayer2MenuItems[] = {
0, 0,
0, 0,
L_MPWEAPONS_169, // "In-Game Subtitles" L_MPWEAPONS_169, // "In-Game Subtitles"
0x00000005, MAX_PLAYERS + 1,
menuhandlerInGameSubtitles, menuhandlerInGameSubtitles,
}, },
{ {
@@ -3051,7 +3176,7 @@ struct menuitem g_CiDisplayPlayer2MenuItems[] = {
0, 0,
0, 0,
L_MPWEAPONS_168, // "Cutscene Subtitles" L_MPWEAPONS_168, // "Cutscene Subtitles"
0x00000005, MAX_PLAYERS + 1,
menuhandlerCutsceneSubtitles, menuhandlerCutsceneSubtitles,
}, },
{ {
@@ -3059,7 +3184,7 @@ struct menuitem g_CiDisplayPlayer2MenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_212, // "Show Mission Time" L_OPTIONS_212, // "Show Mission Time"
0x00000005, MAX_PLAYERS + 1,
menuhandlerShowMissionTime, menuhandlerShowMissionTime,
}, },
{ {
@@ -3104,7 +3229,7 @@ struct menuitem g_MissionControlOptionsMenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_195, // "Reverse Pitch" L_OPTIONS_195, // "Reverse Pitch"
0x00000004, MAX_PLAYERS,
menuhandlerReversePitch, menuhandlerReversePitch,
}, },
{ {
@@ -3112,7 +3237,7 @@ struct menuitem g_MissionControlOptionsMenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_196, // "Look Ahead" L_OPTIONS_196, // "Look Ahead"
0x00000004, MAX_PLAYERS,
menuhandlerLookAhead, menuhandlerLookAhead,
}, },
{ {
@@ -3120,7 +3245,7 @@ struct menuitem g_MissionControlOptionsMenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_197, // "Head Roll" L_OPTIONS_197, // "Head Roll"
0x00000004, MAX_PLAYERS,
menuhandlerHeadRoll, menuhandlerHeadRoll,
}, },
{ {
@@ -3128,7 +3253,7 @@ struct menuitem g_MissionControlOptionsMenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_198, // "Auto-Aim" L_OPTIONS_198, // "Auto-Aim"
0x00000004, MAX_PLAYERS,
menuhandlerAutoAim, menuhandlerAutoAim,
}, },
{ {
@@ -3136,7 +3261,7 @@ struct menuitem g_MissionControlOptionsMenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_199, // "Aim Control" L_OPTIONS_199, // "Aim Control"
0x00000004, MAX_PLAYERS,
menuhandlerAimControl, menuhandlerAimControl,
}, },
{ {
@@ -3182,7 +3307,7 @@ struct menuitem g_CiControlOptionsMenuItems2[] = {
0, 0,
0, 0,
L_MPWEAPONS_271, // "" L_MPWEAPONS_271, // ""
0x00000004, MAX_PLAYERS,
menuhandlerReversePitch, menuhandlerReversePitch,
}, },
{ {
@@ -3190,7 +3315,7 @@ struct menuitem g_CiControlOptionsMenuItems2[] = {
0, 0,
0, 0,
L_MPWEAPONS_272, // "" L_MPWEAPONS_272, // ""
0x00000004, MAX_PLAYERS,
menuhandlerLookAhead, menuhandlerLookAhead,
}, },
{ {
@@ -3198,7 +3323,7 @@ struct menuitem g_CiControlOptionsMenuItems2[] = {
0, 0,
0, 0,
L_MPWEAPONS_273, // "" L_MPWEAPONS_273, // ""
0x00000004, MAX_PLAYERS,
menuhandlerHeadRoll, menuhandlerHeadRoll,
}, },
{ {
@@ -3206,7 +3331,7 @@ struct menuitem g_CiControlOptionsMenuItems2[] = {
0, 0,
0, 0,
L_MPWEAPONS_274, // "" L_MPWEAPONS_274, // ""
0x00000004, MAX_PLAYERS,
menuhandlerAutoAim, menuhandlerAutoAim,
}, },
{ {
@@ -3214,7 +3339,7 @@ struct menuitem g_CiControlOptionsMenuItems2[] = {
0, 0,
0, 0,
L_MPWEAPONS_275, // "" L_MPWEAPONS_275, // ""
0x00000004, MAX_PLAYERS,
menuhandlerAimControl, menuhandlerAimControl,
}, },
{ {
@@ -3260,7 +3385,7 @@ struct menuitem g_CiControlOptionsMenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_195, // "Reverse Pitch" L_OPTIONS_195, // "Reverse Pitch"
0x00000004, MAX_PLAYERS,
menuhandlerReversePitch, menuhandlerReversePitch,
}, },
{ {
@@ -3268,7 +3393,7 @@ struct menuitem g_CiControlOptionsMenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_196, // "Look Ahead" L_OPTIONS_196, // "Look Ahead"
0x00000004, MAX_PLAYERS,
menuhandlerLookAhead, menuhandlerLookAhead,
}, },
{ {
@@ -3276,7 +3401,7 @@ struct menuitem g_CiControlOptionsMenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_197, // "Head Roll" L_OPTIONS_197, // "Head Roll"
0x00000004, MAX_PLAYERS,
menuhandlerHeadRoll, menuhandlerHeadRoll,
}, },
{ {
@@ -3284,7 +3409,7 @@ struct menuitem g_CiControlOptionsMenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_198, // "Auto-Aim" L_OPTIONS_198, // "Auto-Aim"
0x00000004, MAX_PLAYERS,
menuhandlerAutoAim, menuhandlerAutoAim,
}, },
{ {
@@ -3292,7 +3417,7 @@ struct menuitem g_CiControlOptionsMenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_199, // "Aim Control" L_OPTIONS_199, // "Aim Control"
0x00000004, MAX_PLAYERS,
menuhandlerAimControl, menuhandlerAimControl,
}, },
{ {
@@ -3337,7 +3462,7 @@ struct menuitem g_CiControlPlayer2MenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_195, // "Reverse Pitch" L_OPTIONS_195, // "Reverse Pitch"
0x00000005, MAX_PLAYERS + 1,
menuhandlerReversePitch, menuhandlerReversePitch,
}, },
{ {
@@ -3345,7 +3470,7 @@ struct menuitem g_CiControlPlayer2MenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_196, // "Look Ahead" L_OPTIONS_196, // "Look Ahead"
0x00000005, MAX_PLAYERS + 1,
menuhandlerLookAhead, menuhandlerLookAhead,
}, },
{ {
@@ -3353,7 +3478,7 @@ struct menuitem g_CiControlPlayer2MenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_197, // "Head Roll" L_OPTIONS_197, // "Head Roll"
0x00000005, MAX_PLAYERS + 1,
menuhandlerHeadRoll, menuhandlerHeadRoll,
}, },
{ {
@@ -3361,7 +3486,7 @@ struct menuitem g_CiControlPlayer2MenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_198, // "Auto-Aim" L_OPTIONS_198, // "Auto-Aim"
0x00000005, MAX_PLAYERS + 1,
menuhandlerAutoAim, menuhandlerAutoAim,
}, },
{ {
@@ -3369,7 +3494,7 @@ struct menuitem g_CiControlPlayer2MenuItems[] = {
0, 0,
0, 0,
L_OPTIONS_199, // "Aim Control" L_OPTIONS_199, // "Aim Control"
0x00000005, MAX_PLAYERS + 1,
menuhandlerAimControl, menuhandlerAimControl,
}, },
{ {
@@ -3736,7 +3861,11 @@ struct menudialogdef g_CiOptionsViaPcMenuDialog = {
L_OPTIONS_180, // "Options" L_OPTIONS_180, // "Options"
g_CiOptionsMenuItems, g_CiOptionsMenuItems,
menudialog0010559c, menudialog0010559c,
#ifdef PLATFORM_N64
0, 0,
#else
MENUDIALOGFLAG_IGNOREBACK,
#endif
NULL, NULL,
}; };
@@ -4846,7 +4975,7 @@ MenuItemHandlerResult menuhandlerMainMenuCooperative(s32 operation, struct menui
MenuItemHandlerResult menuhandlerMainMenuCounterOperative(s32 operation, struct menuitem *item, union handlerdata *data) MenuItemHandlerResult menuhandlerMainMenuCounterOperative(s32 operation, struct menuitem *item, union handlerdata *data)
{ {
if (operation == MENUOP_CHECKDISABLED) { if (operation == MENUOP_CHECKDISABLED) {
if ((joyGetConnectedControllers() & 2) == 0) { if ((joyGetConnectedControllers() & ~0x1) == 0) {
return true; return true;
} }
} }
@@ -4865,6 +4994,11 @@ MenuDialogHandlerResult menudialogMainMenu(s32 operation, struct menudialogdef *
switch (operation) { switch (operation) {
case MENUOP_OPEN: case MENUOP_OPEN:
g_Menus[g_MpPlayerNum].main.unke2c = 0; g_Menus[g_MpPlayerNum].main.unke2c = 0;
#ifndef PLATFORM_N64
if (g_NetMode) {
netDisconnect();
}
#endif
break; break;
case MENUOP_TICK: case MENUOP_TICK:
if (g_Menus[g_MpPlayerNum].curdialog && if (g_Menus[g_MpPlayerNum].curdialog &&
@@ -4872,6 +5006,17 @@ MenuDialogHandlerResult menudialogMainMenu(s32 operation, struct menudialogdef *
g_MissionConfig.iscoop = false; g_MissionConfig.iscoop = false;
g_MissionConfig.isanti = false; g_MissionConfig.isanti = false;
} }
#ifndef PLATFORM_N64
if (g_NetJoinLatch) {
menuhandlerJoinGame(MENUOP_SET, NULL, NULL);
menuhandlerJoinStart(MENUOP_SET, NULL, NULL);
g_NetJoinLatch = false;
} else if (g_NetHostLatch) {
menuhandlerHostGame(MENUOP_SET, NULL, NULL);
menuhandlerHostStart(MENUOP_SET, NULL, NULL);
g_NetHostLatch = false;
}
#endif
break; break;
} }
@@ -4905,7 +5050,11 @@ struct menuitem g_MainMenuMenuItems[] = {
{ {
MENUITEMTYPE_SELECTABLE, MENUITEMTYPE_SELECTABLE,
0, 0,
#ifdef PLATFORM_N64
MENUITEMFLAG_SELECTABLE_CLOSESDIALOG | MENUITEMFLAG_BIGFONT, MENUITEMFLAG_SELECTABLE_CLOSESDIALOG | MENUITEMFLAG_BIGFONT,
#else
MENUITEMFLAG_SELECTABLE_CLOSESDIALOG | MENUITEMFLAG_BIGFONT | MENUITEMFLAG_ALWAYSDISABLED,
#endif
L_MISC_446, // "Carrington Institute" L_MISC_446, // "Carrington Institute"
0x00000001, 0x00000001,
NULL, NULL,
@@ -4913,7 +5062,11 @@ struct menuitem g_MainMenuMenuItems[] = {
{ {
MENUITEMTYPE_SELECTABLE, MENUITEMTYPE_SELECTABLE,
0, 0,
#ifdef PLATFORM_N64
MENUITEMFLAG_BIGFONT, MENUITEMFLAG_BIGFONT,
#else
MENUITEMFLAG_BIGFONT | MENUITEMFLAG_ALWAYSDISABLED,
#endif
(uintptr_t)&mainMenuTextLabel, (uintptr_t)&mainMenuTextLabel,
0x00000002, 0x00000002,
menuhandlerMainMenuSoloMissions, menuhandlerMainMenuSoloMissions,
@@ -4921,7 +5074,11 @@ struct menuitem g_MainMenuMenuItems[] = {
{ {
MENUITEMTYPE_SELECTABLE, MENUITEMTYPE_SELECTABLE,
1, 1,
#ifdef PLATFORM_N64
MENUITEMFLAG_BIGFONT, MENUITEMFLAG_BIGFONT,
#else
MENUITEMFLAG_BIGFONT | MENUITEMFLAG_ALWAYSDISABLED,
#endif
(uintptr_t)&mainMenuTextLabel, (uintptr_t)&mainMenuTextLabel,
0x00000003, 0x00000003,
menuhandlerMainMenuCombatSimulator, menuhandlerMainMenuCombatSimulator,
@@ -4929,7 +5086,11 @@ struct menuitem g_MainMenuMenuItems[] = {
{ {
MENUITEMTYPE_SELECTABLE, MENUITEMTYPE_SELECTABLE,
2, 2,
#ifdef PLATFORM_N64
MENUITEMFLAG_BIGFONT, MENUITEMFLAG_BIGFONT,
#else
MENUITEMFLAG_BIGFONT | MENUITEMFLAG_ALWAYSDISABLED,
#endif
(uintptr_t)&mainMenuTextLabel, (uintptr_t)&mainMenuTextLabel,
0x00000004, 0x00000004,
menuhandlerMainMenuCooperative, menuhandlerMainMenuCooperative,
@@ -4937,29 +5098,45 @@ struct menuitem g_MainMenuMenuItems[] = {
{ {
MENUITEMTYPE_SELECTABLE, MENUITEMTYPE_SELECTABLE,
3, 3,
#ifdef PLATFORM_N64
MENUITEMFLAG_BIGFONT, MENUITEMFLAG_BIGFONT,
#else
MENUITEMFLAG_BIGFONT | MENUITEMFLAG_ALWAYSDISABLED,
#endif
(uintptr_t)&mainMenuTextLabel, (uintptr_t)&mainMenuTextLabel,
0x00000005, 0x00000005,
menuhandlerMainMenuCounterOperative, menuhandlerMainMenuCounterOperative,
}, },
#ifndef PLATFORM_N64
{
MENUITEMTYPE_SELECTABLE,
4,
MENUITEMFLAG_SELECTABLE_OPENSDIALOG | MENUITEMFLAG_BIGFONT | MENUITEMFLAG_LITERAL_TEXT,
(uintptr_t)"Network Game",
0x00000006,
(void *)&g_NetMenuDialog,
},
#endif
{ {
MENUITEMTYPE_SELECTABLE, MENUITEMTYPE_SELECTABLE,
0, 0,
MENUITEMFLAG_SELECTABLE_OPENSDIALOG | MENUITEMFLAG_BIGFONT, MENUITEMFLAG_SELECTABLE_OPENSDIALOG | MENUITEMFLAG_BIGFONT,
L_OPTIONS_187, // "Change Agent..." L_OPTIONS_187, // "Change Agent..."
0x00000006, 0x00000007,
(void *)&g_ChangeAgentMenuDialog, (void *)&g_ChangeAgentMenuDialog,
}, },
/*
#ifndef PLATFORM_N64 #ifndef PLATFORM_N64
{ {
MENUITEMTYPE_SELECTABLE, MENUITEMTYPE_SELECTABLE,
0, 0,
MENUITEMFLAG_SELECTABLE_OPENSDIALOG | MENUITEMFLAG_BIGFONT | MENUITEMFLAG_LITERAL_TEXT, MENUITEMFLAG_SELECTABLE_OPENSDIALOG | MENUITEMFLAG_BIGFONT | MENUITEMFLAG_LITERAL_TEXT,
(uintptr_t)"Exit Game", (uintptr_t)"Exit Game",
0x00000007, 0x00000008,
(void *)&g_ExitGameMenuDialog, (void *)&g_ExitGameMenuDialog,
}, },
#endif #endif
*/
{ MENUITEMTYPE_END }, { MENUITEMTYPE_END },
}; };
@@ -4968,7 +5145,11 @@ struct menudialogdef g_CiMenuViaPcMenuDialog = {
L_OPTIONS_116, // "Perfect Menu" L_OPTIONS_116, // "Perfect Menu"
g_MainMenuMenuItems, g_MainMenuMenuItems,
menudialogMainMenu, menudialogMainMenu,
#ifdef PLATFORM_N64
MENUDIALOGFLAG_STARTSELECTS, MENUDIALOGFLAG_STARTSELECTS,
#else
MENUDIALOGFLAG_STARTSELECTS | MENUDIALOGFLAG_IGNOREBACK,
#endif
&g_CiOptionsViaPcMenuDialog, &g_CiOptionsViaPcMenuDialog,
}; };
+18 -7
View File
@@ -49,9 +49,10 @@
#include "data.h" #include "data.h"
#include "types.h" #include "types.h"
#ifndef PLATFORM_N64 #ifndef PLATFORM_N64
#include "platform.h"
#include "video.h" #include "video.h"
#include "input.h" #include "input.h"
#include "platform.h" #include "net/net.h"
#define BLUR_OFS 10 #define BLUR_OFS 10
#else #else
#define BLUR_OFS 30 #define BLUR_OFS 30
@@ -3562,7 +3563,7 @@ void menuClose(void)
void func0f0f8120(void) void func0f0f8120(void)
{ {
#ifdef AVOID_UB #ifdef AVOID_UB
u32 mpindex = g_MpPlayerNum % MAX_PLAYERS; u32 mpindex = g_MpPlayerNum % MAX_LOCAL_PLAYERS;
struct menudialog *prev = g_Menus[mpindex].curdialog; struct menudialog *prev = g_Menus[mpindex].curdialog;
s32 i; s32 i;
#else #else
@@ -3577,9 +3578,6 @@ void func0f0f8120(void)
} }
#ifdef AVOID_UB #ifdef AVOID_UB
mpindex = g_MpPlayerNum;
if (mpindex >= MAX_PLAYERS)
mpindex -= MAX_PLAYERS;
if (g_Menus[mpindex].curdialog == prev) { if (g_Menus[mpindex].curdialog == prev) {
while (g_Menus[mpindex].depth > 0) { while (g_Menus[mpindex].depth > 0) {
menuPopDialog(); menuPopDialog();
@@ -5549,7 +5547,7 @@ Gfx *menuRender(Gfx *gdl)
} else { } else {
s32 i; s32 i;
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_LOCAL_PLAYERS; i++) {
g_MpPlayerNum = i; g_MpPlayerNum = i;
gdl = menuRenderDialogs(gdl); gdl = menuRenderDialogs(gdl);
} }
@@ -5582,7 +5580,20 @@ Gfx *menuRender(Gfx *gdl)
gdl = text0f153628(gdl); gdl = text0f153628(gdl);
for (i = 0; i < MAX_PLAYERS; i++) { #ifndef PLATFORM_N64
if (g_NetMode) {
if (g_NetMode == NETMODE_SERVER) {
sprintf(text, "Server: %d/%d %04x", g_NetNumClients, g_NetMaxClients, g_MpSetup.chrslots);
} else {
sprintf(text, "Client: ID %u", g_NetLocalClient->id);
}
x = viewleft + 2;
y = viewbottom - 9;
colour = 0x00ff00ff;
gdl = textRenderProjected(gdl, &x, &y, text, g_CharsHandelGothicSm, g_FontHandelGothicSm, colour, viGetWidth(), viGetHeight(), 0, 0);
} else
#endif
for (i = 0; i < MAX_LOCAL_PLAYERS; i++) {
// Figure out what text will be displayed. The text calculated // Figure out what text will be displayed. The text calculated
// here is for measuring purposes only and isn't rendered. // here is for measuring purposes only and isn't rendered.
// Amusingly, there's a %d placeholder in the text which isn't // Amusingly, there's a %d placeholder in the text which isn't
+14 -11
View File
@@ -24,6 +24,7 @@
#include "types.h" #include "types.h"
#ifndef PLATFORM_N64 #ifndef PLATFORM_N64
#include "input.h" #include "input.h"
#include "console.h"
#define MENU_KEYBOARD_ROWS 6 #define MENU_KEYBOARD_ROWS 6
#else #else
#define MENU_KEYBOARD_ROWS 5 #define MENU_KEYBOARD_ROWS 5
@@ -1600,15 +1601,17 @@ bool menuitemKeyboardTick(struct menuitem *item, struct menuinputs *inputs, u32
} }
} else if (kb->row == 5) { } else if (kb->row == 5) {
#ifndef PLATFORM_N64 #ifndef PLATFORM_N64
if (g_MenuKeyboardPlayer == -1) { if (!conIsOpen()) {
g_MenuKeyboardPlayer = g_MpPlayerNum; if (g_MenuKeyboardPlayer == -1) {
inputClearLastTextChar(); g_MenuKeyboardPlayer = g_MpPlayerNum;
inputStartTextInput(); inputClearLastTextChar();
menuPlaySound(MENUSOUND_SELECT); inputStartTextInput();
} else { menuPlaySound(MENUSOUND_SELECT);
g_MenuKeyboardPlayer = -1; } else {
inputStopTextInput(); g_MenuKeyboardPlayer = -1;
menuPlaySound(MENUSOUND_KEYBOARDCANCEL); inputStopTextInput();
menuPlaySound(MENUSOUND_KEYBOARDCANCEL);
}
} }
#endif #endif
} else { } else {
@@ -4368,7 +4371,7 @@ Gfx *menuitemControllerRenderText(Gfx *gdl, s32 curmode, struct menurendercontex
// during development the second player in the 2.x styles had to // during development the second player in the 2.x styles had to
// choose their control style separately to player 1, in which case // choose their control style separately to player 1, in which case
// there would have been 2.5, 2.6, 2.7 and 2.8 for player 2. // there would have been 2.5, 2.6, 2.7 and 2.8 for player 2.
if (curmode > CONTROLMODE_24 && curmode != CONTROLMODE_PC) { if (curmode > CONTROLMODE_24 && curmode < CONTROLMODE_PC) {
if (textnum == menuitemControllerGetButtonAction(prevmode + 4, i)) { if (textnum == menuitemControllerGetButtonAction(prevmode + 4, i)) {
colour = labelcolour; colour = labelcolour;
} }
@@ -4453,7 +4456,7 @@ Gfx *menuitemControllerRender(Gfx *gdl, struct menurendercontext *context)
data->prevmode = -1; data->prevmode = -1;
} }
} else { } else {
if (g_Menus[g_MpPlayerNum].main.controlmode >= CONTROLMODE_21 && g_Menus[g_MpPlayerNum].main.controlmode != CONTROLMODE_PC) { if (g_Menus[g_MpPlayerNum].main.controlmode >= CONTROLMODE_21 && g_Menus[g_MpPlayerNum].main.controlmode < CONTROLMODE_PC) {
data->controlgroup = 1; data->controlgroup = 1;
data->contfadetimer = 0; data->contfadetimer = 0;
data->prevmode = -1; data->prevmode = -1;
+52 -9
View File
@@ -27,6 +27,9 @@
#include "lib/snd.h" #include "lib/snd.h"
#include "data.h" #include "data.h"
#include "types.h" #include "types.h"
#ifndef PLATFORM_N64
#include "net/net.h"
#endif
u8 g_FileState = 0; u8 g_FileState = 0;
u8 var80062944 = 0; u8 var80062944 = 0;
@@ -218,13 +221,19 @@ void menuTick(void)
viBlack(false); viBlack(false);
g_MpNumJoined = 0; g_MpNumJoined = 0;
#ifndef PLATFORM_N64
if (g_NetMode) {
g_Vars.mpsetupmenu = MPSETUPMENU_ADVSETUP;
g_MpSetup.chrslots = 1;
} else
#endif
if (g_Vars.usingadvsetup) { if (g_Vars.usingadvsetup) {
g_Vars.mpsetupmenu = MPSETUPMENU_ADVSETUP; g_Vars.mpsetupmenu = MPSETUPMENU_ADVSETUP;
} else { } else {
g_Vars.mpsetupmenu = MPSETUPMENU_GENERAL; g_Vars.mpsetupmenu = MPSETUPMENU_GENERAL;
} }
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_LOCAL_PLAYERS; i++) {
g_Vars.waitingtojoin[i] = false; g_Vars.waitingtojoin[i] = false;
if (g_MpSetup.chrslots & (1 << i)) { if (g_MpSetup.chrslots & (1 << i)) {
@@ -233,6 +242,13 @@ void menuTick(void)
if (g_Vars.mpsetupmenu == MPSETUPMENU_ADVSETUP) { if (g_Vars.mpsetupmenu == MPSETUPMENU_ADVSETUP) {
g_MpNumJoined++; g_MpNumJoined++;
func0f17fcb0(true); func0f17fcb0(true);
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_CLIENT) {
// autodump client into waiting screen while host is changing settings
extern struct menudialogdef g_NetJoiningDialog;
menuPushDialog(&g_NetJoiningDialog);
}
#endif
} else if (g_MpNumJoined == 0) { } else if (g_MpNumJoined == 0) {
g_MpNumJoined++; g_MpNumJoined++;
@@ -286,7 +302,11 @@ void menuTick(void)
if (g_MenuData.root == MENUROOT_MPSETUP || g_MenuData.root == MENUROOT_4MBMAINMENU) { if (g_MenuData.root == MENUROOT_MPSETUP || g_MenuData.root == MENUROOT_4MBMAINMENU) {
if (g_MenuData.unk008 == -1) { if (g_MenuData.unk008 == -1) {
#if MAX_PLAYERS > 4
g_MpSetup.chrslots &= 0xff00;
#else
g_MpSetup.chrslots &= 0xfff0; g_MpSetup.chrslots &= 0xfff0;
#endif
} }
g_MpNumJoined = 0; g_MpNumJoined = 0;
@@ -301,11 +321,23 @@ void menuTick(void)
} }
} }
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_SERVER && g_MenuData.unk008 == -1) {
s32 slot = 1;
for (i = 1; i < g_NetMaxClients; ++i) {
if (g_NetClients[i].state >= CLSTATE_LOBBY) {
g_MpSetup.chrslots |= (1 << slot);
++slot;
}
}
}
#endif
mpCalculateLockIfLastWinnerOrLoser(); mpCalculateLockIfLastWinnerOrLoser();
challengePerformSanityChecks(); challengePerformSanityChecks();
} }
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_LOCAL_PLAYERS; i++) {
g_MpPlayerNum = i; g_MpPlayerNum = i;
if (g_Menus[g_MpPlayerNum].curdialog) { if (g_Menus[g_MpPlayerNum].curdialog) {
@@ -317,7 +349,7 @@ void menuTick(void)
} }
} }
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_LOCAL_PLAYERS; i++) {
g_MpPlayerNum = i; g_MpPlayerNum = i;
if (g_Menus[g_MpPlayerNum].curdialog) { if (g_Menus[g_MpPlayerNum].curdialog) {
@@ -341,7 +373,7 @@ void menuTick(void)
// Limit to 2 players? But in a roundabout kind of way // Limit to 2 players? But in a roundabout kind of way
canjoin = true; canjoin = true;
for (j = 0; j < MAX_PLAYERS; j++) { for (j = 0; j < MAX_LOCAL_PLAYERS; j++) {
if (g_Vars.waitingtojoin[j]) { if (g_Vars.waitingtojoin[j]) {
canjoin = false; canjoin = false;
} }
@@ -355,6 +387,12 @@ void menuTick(void)
canjoin = true; canjoin = true;
} }
#ifndef PLATFORM_N64
if (g_NetMode) {
canjoin = false;
}
#endif
if (g_BossFile.locktype == MPLOCKTYPE_CHALLENGE) { if (g_BossFile.locktype == MPLOCKTYPE_CHALLENGE) {
g_PlayerConfigsArray[i].base.team = 0; g_PlayerConfigsArray[i].base.team = 0;
} }
@@ -526,7 +564,12 @@ void menuTick(void)
func0f0fd548(4); func0f0fd548(4);
} }
for (i = 0; i < MAX_PLAYERS; i++) { #ifdef PLATFORM_N64
for (i = 0; i < MAX_LOCAL_PLAYERS; i++) {
#else
const s32 maxplayers = g_NetMode ? 1 : MAX_LOCAL_PLAYERS;
for (i = 0; i < maxplayers; i++) {
#endif
if (g_MpSetup.chrslots & (1 << i)) { if (g_MpSetup.chrslots & (1 << i)) {
if (g_Vars.coopplayernum >= 0) { if (g_Vars.coopplayernum >= 0) {
if (g_Vars.stagenum == STAGE_DEEPSEA) { if (g_Vars.stagenum == STAGE_DEEPSEA) {
@@ -616,12 +659,12 @@ void menuTick(void)
} else if (g_Vars.coopplayernum >= 0 || g_Vars.antiplayernum >= 0) { } else if (g_Vars.coopplayernum >= 0 || g_Vars.antiplayernum >= 0) {
struct mpplayerconfig tmp; struct mpplayerconfig tmp;
tmp = g_PlayerConfigsArray[4]; tmp = g_PlayerConfigsArray[MAX_PLAYERS];
g_PlayerConfigsArray[4] = g_PlayerConfigsArray[0]; g_PlayerConfigsArray[MAX_PLAYERS] = g_PlayerConfigsArray[0];
g_PlayerConfigsArray[0] = tmp; g_PlayerConfigsArray[0] = tmp;
tmp = g_PlayerConfigsArray[5]; tmp = g_PlayerConfigsArray[MAX_PLAYERS + 1];
g_PlayerConfigsArray[5] = g_PlayerConfigsArray[1]; g_PlayerConfigsArray[MAX_PLAYERS + 1] = g_PlayerConfigsArray[1];
g_PlayerConfigsArray[1] = tmp; g_PlayerConfigsArray[1] = tmp;
} }
+21 -1
View File
@@ -19,6 +19,9 @@
#include "lib/main.h" #include "lib/main.h"
#include "data.h" #include "data.h"
#include "types.h" #include "types.h"
#ifndef PLATFORM_N64
#include "net/net.h"
#endif
struct menudialogdef g_MpEndscreenChallengeCompletedMenuDialog; struct menudialogdef g_MpEndscreenChallengeCompletedMenuDialog;
struct menudialogdef g_MpEndscreenIndGameOverMenuDialog; struct menudialogdef g_MpEndscreenIndGameOverMenuDialog;
@@ -102,6 +105,11 @@ MenuItemHandlerResult menuhandlerMpEndGame(s32 operation, struct menuitem *item,
{ {
if (operation == MENUOP_SET) { if (operation == MENUOP_SET) {
g_Vars.currentplayer->aborted = true; g_Vars.currentplayer->aborted = true;
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_CLIENT) {
netDisconnect();
} else
#endif
mainEndStage(); mainEndStage();
} }
@@ -165,6 +173,11 @@ MenuItemHandlerResult menuhandlerMpPause(s32 operation, struct menuitem *item, u
} }
if (operation == MENUOP_CHECKHIDDEN) { if (operation == MENUOP_CHECKHIDDEN) {
#ifndef PLATFORM_N64
if (g_NetMode) {
return true;
}
#endif
if (PLAYERCOUNT() == 1) { if (PLAYERCOUNT() == 1) {
return true; return true;
} }
@@ -787,7 +800,11 @@ void mpPushPauseDialog(void)
menuPushRootDialog(&g_MpPausePlayerRankingMenuDialog, MENUROOT_MPPAUSE); menuPushRootDialog(&g_MpPausePlayerRankingMenuDialog, MENUROOT_MPPAUSE);
} }
} else { } else {
if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) { if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL
#ifndef PLATFORM_N64
|| LOCALPLAYERCOUNT() >= 3
#endif
) {
menuPushRootDialog(&g_2PMissionPauseVMenuDialog, MENUROOT_MPPAUSE); menuPushRootDialog(&g_2PMissionPauseVMenuDialog, MENUROOT_MPPAUSE);
} else { } else {
menuPushRootDialog(&g_2PMissionPauseHMenuDialog, MENUROOT_MPPAUSE); menuPushRootDialog(&g_2PMissionPauseHMenuDialog, MENUROOT_MPPAUSE);
@@ -831,6 +848,9 @@ void mpPushEndscreenDialog(u32 arg0, u32 playernum)
&& g_PlayerConfigsArray[g_MpPlayerNum].fileguid.fileid == 0 && g_PlayerConfigsArray[g_MpPlayerNum].fileguid.fileid == 0
&& g_PlayerConfigsArray[g_MpPlayerNum].fileguid.deviceserial == 0) { && g_PlayerConfigsArray[g_MpPlayerNum].fileguid.deviceserial == 0) {
g_PlayerConfigsArray[g_MpPlayerNum].options |= OPTION_ASKEDSAVEPLAYER; g_PlayerConfigsArray[g_MpPlayerNum].options |= OPTION_ASKEDSAVEPLAYER;
#ifndef PLATFORM_N64
if (!g_NetMode)
#endif
menuPushDialog(&g_MpEndscreenSavePlayerMenuDialog); menuPushDialog(&g_MpEndscreenSavePlayerMenuDialog);
} }
} }
+93 -49
View File
@@ -28,9 +28,12 @@
#include "lib/lib_317f0.h" #include "lib/lib_317f0.h"
#include "data.h" #include "data.h"
#include "types.h" #include "types.h"
#ifndef PLATFORM_N64
#include "net/net.h"
#include "fs.h" #include "fs.h"
#include "system.h" #include "system.h"
#include "mpsetups.h" #include "mpsetups.h"
#endif
// bss // bss
struct chrdata *g_MpAllChrPtrs[MAX_MPCHRS]; struct chrdata *g_MpAllChrPtrs[MAX_MPCHRS];
@@ -38,7 +41,7 @@ struct mpchrconfig *g_MpAllChrConfigPtrs[MAX_MPCHRS];
s32 g_MpNumChrs; s32 g_MpNumChrs;
u32 var800ac534; u32 var800ac534;
struct mpbotconfig g_BotConfigsArray[MAX_BOTS]; struct mpbotconfig g_BotConfigsArray[MAX_BOTS];
u8 g_MpSimulantDifficultiesPerNumPlayers[MAX_BOTS][MAX_PLAYERS]; u8 g_MpSimulantDifficultiesPerNumPlayers[MAX_BOTS][MAX_LOCAL_PLAYERS];
struct mpplayerconfig g_PlayerConfigsArray[MAX_MPPLAYERCONFIGS]; struct mpplayerconfig g_PlayerConfigsArray[MAX_MPPLAYERCONFIGS];
u8 g_AmBotCommands[9]; u8 g_AmBotCommands[9];
struct mpsetup g_MpSetup; struct mpsetup g_MpSetup;
@@ -143,7 +146,7 @@ struct mpweapon g_MpWeapons[NUM_MPWEAPONS] = {
.usereloads = false, \ .usereloads = false, \
} }
struct extplayerconfig g_PlayerExtCfg[MAX_PLAYERS] = { struct extplayerconfig g_PlayerExtCfg[MAX_LOCAL_PLAYERS] = {
PLAYER_EXT_CFG_DEFAULT, PLAYER_EXT_CFG_DEFAULT,
PLAYER_EXT_CFG_DEFAULT, PLAYER_EXT_CFG_DEFAULT,
PLAYER_EXT_CFG_DEFAULT, PLAYER_EXT_CFG_DEFAULT,
@@ -158,11 +161,18 @@ struct extplayerconfig g_PlayerExtCfg[MAX_PLAYERS] = {
* value 0 will return 0.1 * value 0 will return 0.1
* value 127 will return 1 * value 127 will return 1
* value 255 will return 10 * value 255 will return 10
* in a netgame it's always 1
*/ */
f32 mpHandicapToDamageScale(u8 value) f32 mpHandicapToDamageScale(u8 value)
{ {
f32 tmp; f32 tmp;
#ifndef PLATFORM_N64
if (g_NetMode) {
return 1.f;
}
#endif
if (value < 127) { if (value < 127) {
return (value / 127.0f) * (value / 127.0f) * 0.9f + 0.1f; return (value / 127.0f) * (value / 127.0f) * 0.9f + 0.1f;
} }
@@ -196,22 +206,38 @@ void mpStartMatch(void)
s32 stagenum; s32 stagenum;
#ifndef PLATFORM_N64 #ifndef PLATFORM_N64
if (g_MpSetup.options & MPOPTION_AUTORANDOMWEAPON_START) { if (g_NetMode == NETMODE_SERVER) {
if (g_MpWeaponSetNum == WEAPONSET_RANDOM g_MpSetup.chrslots &= 0xff00;
|| g_MpWeaponSetNum == WEAPONSET_RANDOMFIVE) { g_MpSetup.chrslots |= 1;
mpApplyWeaponSet(); s32 slot = 1;
for (s32 i = 1; i < g_NetMaxClients; ++i) {
if (g_NetClients[i].state >= CLSTATE_LOBBY) {
g_MpSetup.chrslots |= (1 << slot);
++slot;
}
} }
} }
if (g_NetMode != NETMODE_CLIENT)
#endif
{
#ifndef PLATFORM_N64
if (g_MpSetup.options & MPOPTION_AUTORANDOMWEAPON_START) {
if (g_MpWeaponSetNum == WEAPONSET_RANDOM || g_MpWeaponSetNum == WEAPONSET_RANDOMFIVE) {
mpApplyWeaponSet();
}
}
#endif #endif
mpConfigureQuickTeamSimulants(); mpConfigureQuickTeamSimulants();
if (!challengeIsFeatureUnlocked(MPFEATURE_ONEHITKILLS)) { if (!challengeIsFeatureUnlocked(MPFEATURE_ONEHITKILLS)) {
g_MpSetup.options &= ~MPOPTION_ONEHITKILLS; g_MpSetup.options &= ~MPOPTION_ONEHITKILLS;
} }
if (!challengeIsFeatureUnlocked(MPFEATURE_SLOWMOTION)) { if (!challengeIsFeatureUnlocked(MPFEATURE_SLOWMOTION)) {
g_MpSetup.options &= ~(MPOPTION_SLOWMOTION_ON | MPOPTION_SLOWMOTION_SMART); g_MpSetup.options &= ~(MPOPTION_SLOWMOTION_ON | MPOPTION_SLOWMOTION_SMART);
}
} }
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_PLAYERS; i++) {
@@ -254,7 +280,15 @@ void mpReset(void)
g_Vars.lvmpbotlevel = true; g_Vars.lvmpbotlevel = true;
} }
if (g_Vars.coopplayernum >= 0 || g_Vars.antiplayernum >= 0) { #ifdef PLATFORM_N64
if (g_Vars.coopplayernum >= 0 || g_Vars.antiplayernum >= 0)
#else
// Counter-Operative now uses a different approach which allows more than 2 players.
// Co-Operative, on the other hand, is currently limited to 2 players.
// Due to the change in approach, it's better to ignore 2.x controls for Counter-Operative.
if (g_Vars.coopplayernum >= 0)
#endif
{
struct mpplayerconfig tmp; struct mpplayerconfig tmp;
tmp = g_PlayerConfigsArray[MAX_PLAYERS]; tmp = g_PlayerConfigsArray[MAX_PLAYERS];
@@ -437,7 +471,7 @@ void mpPlayerSetDefaults(s32 playernum, bool autonames)
g_PlayerConfigsArray[playernum].controlmode = CONTROLMODE_11; g_PlayerConfigsArray[playernum].controlmode = CONTROLMODE_11;
#ifndef PLATFORM_N64 #ifndef PLATFORM_N64
if (g_PlayerExtCfg[playernum % MAX_PLAYERS].extcontrols) { if (g_PlayerExtCfg[playernum % MAX_LOCAL_PLAYERS].extcontrols) {
g_PlayerConfigsArray[playernum].controlmode = CONTROLMODE_PC; g_PlayerConfigsArray[playernum].controlmode = CONTROLMODE_PC;
} }
#endif #endif
@@ -505,9 +539,9 @@ void mpPlayerSetDefaults(s32 playernum, bool autonames)
g_PlayerConfigsArray[playernum].survivormedals = 0; g_PlayerConfigsArray[playernum].survivormedals = 0;
g_PlayerConfigsArray[playernum].title = MPPLAYERTITLE_BEGINNER; g_PlayerConfigsArray[playernum].title = MPPLAYERTITLE_BEGINNER;
if (playernum < MAX_PLAYERS) { if (playernum < MAX_LOCAL_PLAYERS) {
for (i = 0; i < ARRAYCOUNT(g_MpChallenges); i++) { for (i = 0; i < ARRAYCOUNT(g_MpChallenges); i++) {
for (j = 1; j <= MAX_PLAYERS; j++) { for (j = 1; j <= MAX_LOCAL_PLAYERS; j++) {
challengeSetCompletedByPlayerWithNumPlayers(playernum, i, j, false); challengeSetCompletedByPlayerWithNumPlayers(playernum, i, j, false);
} }
} }
@@ -1391,7 +1425,7 @@ Gfx *mpRenderModalText(Gfx *gdl)
&& g_Vars.currentplayer->redbloodfinished && g_Vars.currentplayer->redbloodfinished
&& g_Vars.currentplayer->deathanimfinished && g_Vars.currentplayer->deathanimfinished
&& !(g_Vars.coopplayernum >= 0 && ((g_Vars.bond->isdead && g_Vars.coop->isdead) || !g_Vars.currentplayer->coopcanrestart || g_InCutscene)) && !(g_Vars.coopplayernum >= 0 && ((g_Vars.bond->isdead && g_Vars.coop->isdead) || !g_Vars.currentplayer->coopcanrestart || g_InCutscene))
&& !(g_Vars.antiplayernum >= 0 && ((g_Vars.currentplayer != g_Vars.anti || g_InCutscene))) && !(g_Vars.antiplayernum >= 0 && ((PLAYER_IS_NOT_ANTI(g_Vars.currentplayer) || g_InCutscene)))
&& g_NumReasonsToEndMpMatch == 0) { && g_NumReasonsToEndMpMatch == 0) {
// Render "Press START" text // Render "Press START" text
gdl = text0f153628(gdl); gdl = text0f153628(gdl);
@@ -2539,10 +2573,12 @@ void mpEndMatch(void)
} }
#ifndef PLATFORM_N64 #ifndef PLATFORM_N64
if (g_MpSetup.options & MPOPTION_AUTORANDOMWEAPON_END) { if (g_NetMode != NETMODE_CLIENT) {
if (g_MpWeaponSetNum == WEAPONSET_RANDOM if (g_MpSetup.options & MPOPTION_AUTORANDOMWEAPON_END) {
|| g_MpWeaponSetNum == WEAPONSET_RANDOMFIVE) { if (g_MpWeaponSetNum == WEAPONSET_RANDOM
mpApplyWeaponSet(); || g_MpWeaponSetNum == WEAPONSET_RANDOMFIVE) {
mpApplyWeaponSet();
}
} }
} }
#endif #endif
@@ -2704,10 +2740,10 @@ void mpFindUnusedHeadAndBody(u8 *mpheadnum, u8 *mpbodynum)
s32 mpChooseRandomLockPlayer(void) s32 mpChooseRandomLockPlayer(void)
{ {
s32 start = rngRandom() % 4; s32 start = rngRandom() % MAX_PLAYERS;
s32 i; s32 i;
for (i = (start + 1) % 4;; i = (i + 1) % 4) { for (i = (start + 1) % MAX_PLAYERS;; i = (i + 1) % MAX_PLAYERS) {
if ((g_MpSetup.chrslots & (1 << i)) || i == start) { if ((g_MpSetup.chrslots & (1 << i)) || i == start) {
break; break;
} }
@@ -3151,11 +3187,11 @@ void mpCreateBotFromProfile(s32 botnum, u8 profilenum)
g_BotConfigsArray[botnum].type = g_BotProfiles[profilenum].type; g_BotConfigsArray[botnum].type = g_BotProfiles[profilenum].type;
g_BotConfigsArray[botnum].difficulty = g_BotProfiles[profilenum].difficulty; g_BotConfigsArray[botnum].difficulty = g_BotProfiles[profilenum].difficulty;
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_LOCAL_PLAYERS; i++) {
g_MpSimulantDifficultiesPerNumPlayers[botnum][i] = g_BotConfigsArray[botnum].difficulty; g_MpSimulantDifficultiesPerNumPlayers[botnum][i] = g_BotConfigsArray[botnum].difficulty;
} }
g_MpSetup.chrslots |= 1 << (botnum + 4); g_MpSetup.chrslots |= 1 << (botnum + MAX_PLAYERS);
strcpy(g_BotConfigsArray[botnum].base.name, "Sim\n"); strcpy(g_BotConfigsArray[botnum].base.name, "Sim\n");
g_BotConfigsArray[botnum].base.team = team; g_BotConfigsArray[botnum].base.team = team;
@@ -3184,7 +3220,7 @@ void mpSetBotDifficulty(s32 botnum, s32 difficulty)
g_BotConfigsArray[botnum].difficulty = difficulty; g_BotConfigsArray[botnum].difficulty = difficulty;
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_LOCAL_PLAYERS; i++) {
g_MpSimulantDifficultiesPerNumPlayers[botnum][i] = g_BotConfigsArray[botnum].difficulty; g_MpSimulantDifficultiesPerNumPlayers[botnum][i] = g_BotConfigsArray[botnum].difficulty;
} }
} }
@@ -3198,7 +3234,7 @@ s32 mpGetSlotForNewBot(void)
{ {
s32 i = 0; s32 i = 0;
while (i < MAX_BOTS - 1 && g_MpSetup.chrslots & (1 << (i + 4))) { while (i < MAX_BOTS - 1 && g_MpSetup.chrslots & (1 << (i + MAX_PLAYERS))) {
i++; i++;
} }
@@ -3207,7 +3243,7 @@ s32 mpGetSlotForNewBot(void)
void mpRemoveSimulant(s32 index) void mpRemoveSimulant(s32 index)
{ {
g_MpSetup.chrslots &= ~(1 << (index + 4)); g_MpSetup.chrslots &= ~(1 << (index + MAX_PLAYERS));
g_BotConfigsArray[index].base.name[0] = '\0'; g_BotConfigsArray[index].base.name[0] = '\0';
func0f1881d4(index); func0f1881d4(index);
mpGenerateBotNames(); mpGenerateBotNames();
@@ -3230,7 +3266,11 @@ void mpCopySimulant(s32 index)
bool mpHasSimulants(void) bool mpHasSimulants(void)
{ {
#if MAX_PLAYERS > 4
if ((g_MpSetup.chrslots & 0xff00) != 0) {
#else
if ((g_MpSetup.chrslots & 0xfff0) != 0) { if ((g_MpSetup.chrslots & 0xfff0) != 0) {
#endif
return true; return true;
} }
@@ -3242,7 +3282,7 @@ bool mpHasUnusedBotSlots(void)
s32 numvacant = challengeIsFeatureUnlocked(MPFEATURE_8BOTS) ? MAX_BOTS : 4; s32 numvacant = challengeIsFeatureUnlocked(MPFEATURE_8BOTS) ? MAX_BOTS : 4;
s32 i; s32 i;
for (i = 4; i < MAX_MPCHRS; i++) { for (i = MAX_PLAYERS; i < MAX_MPCHRS; i++) {
if (g_MpSetup.chrslots & (1 << i)) { if (g_MpSetup.chrslots & (1 << i)) {
numvacant--; numvacant--;
} }
@@ -3260,9 +3300,9 @@ bool mpIsSimSlotEnabled(s32 slot)
s32 numfree = MAX_BOTS; s32 numfree = MAX_BOTS;
s32 i; s32 i;
if ((g_MpSetup.chrslots & (1 << (slot + 4))) == 0) { if ((g_MpSetup.chrslots & (1 << (slot + MAX_PLAYERS))) == 0) {
for (i = 0; i < MAX_BOTS; i++) { for (i = 0; i < MAX_BOTS; i++) {
if (g_MpSetup.chrslots & (1 << (i + 4))) { if (g_MpSetup.chrslots & (1 << (i + MAX_PLAYERS))) {
numfree--; numfree--;
} }
} }
@@ -3314,9 +3354,9 @@ void mpGenerateBotNames(void)
} }
// Count the number of bots using each profile (MeatSim, TurtleSim etc) // Count the number of bots using each profile (MeatSim, TurtleSim etc)
for (i = 4; i < MAX_MPCHRS; i++) { for (i = MAX_PLAYERS; i < MAX_MPCHRS; i++) {
if (g_MpSetup.chrslots & (1 << i)) { if (g_MpSetup.chrslots & (1 << i)) {
profilenum = mpFindBotProfile(g_BotConfigsArray[i - 4].type, g_BotConfigsArray[i - 4].difficulty); profilenum = mpFindBotProfile(g_BotConfigsArray[i - MAX_PLAYERS].type, g_BotConfigsArray[i - MAX_PLAYERS].difficulty);
if (profilenum >= 0 && profilenum < ARRAYCOUNT(g_BotProfiles)) { if (profilenum >= 0 && profilenum < ARRAYCOUNT(g_BotProfiles)) {
counts[profilenum]++; counts[profilenum]++;
@@ -3335,20 +3375,20 @@ void mpGenerateBotNames(void)
} }
} }
for (i = 4; i < MAX_MPCHRS; i++) { for (i = MAX_PLAYERS; i < MAX_MPCHRS; i++) {
if (g_MpSetup.chrslots & (1 << i)) { if (g_MpSetup.chrslots & (1 << i)) {
profilenum = mpFindBotProfile(g_BotConfigsArray[i - 4].type, g_BotConfigsArray[i - 4].difficulty); profilenum = mpFindBotProfile(g_BotConfigsArray[i - MAX_PLAYERS].type, g_BotConfigsArray[i - MAX_PLAYERS].difficulty);
if (profilenum >= 0 && profilenum < ARRAYCOUNT(g_BotProfiles)) { if (profilenum >= 0 && profilenum < ARRAYCOUNT(g_BotProfiles)) {
if (counts[profilenum] >= 0) { if (counts[profilenum] >= 0) {
// Multiple bots using this profile - append the number // Multiple bots using this profile - append the number
counts[profilenum]++; counts[profilenum]++;
sprintf(name, "%s:%d\n", langGet(g_BotProfiles[profilenum].name), counts[profilenum]); sprintf(name, "%s:%d\n", langGet(g_BotProfiles[profilenum].name), counts[profilenum]);
strcpy(g_BotConfigsArray[i - 4].base.name, name); strcpy(g_BotConfigsArray[i - MAX_PLAYERS].base.name, name);
} else { } else {
// One bots using this profile - just use the profile name // One bots using this profile - just use the profile name
sprintf(name, "%s\n", langGet(g_BotProfiles[profilenum].name)); sprintf(name, "%s\n", langGet(g_BotProfiles[profilenum].name));
strcpy(g_BotConfigsArray[i - 4].base.name, name); strcpy(g_BotConfigsArray[i - MAX_PLAYERS].base.name, name);
} }
} }
} }
@@ -3397,7 +3437,7 @@ s32 func0f18d074(s32 index)
for (i = 0; i < MAX_BOTS; i++) { for (i = 0; i < MAX_BOTS; i++) {
if (&g_BotConfigsArray[i].base == g_MpAllChrConfigPtrs[index]) { if (&g_BotConfigsArray[i].base == g_MpAllChrConfigPtrs[index]) {
return i + 4; return i + MAX_PLAYERS;
} }
} }
@@ -3519,13 +3559,13 @@ void mpplayerfileLoadWad(s32 playernum, struct savebuffer *buffer, s32 arg2)
#ifndef PLATFORM_N64 #ifndef PLATFORM_N64
// override with PC controls if enabled in the config // override with PC controls if enabled in the config
if (g_PlayerExtCfg[playernum % MAX_PLAYERS].extcontrols) { if (g_PlayerExtCfg[playernum % MAX_LOCAL_PLAYERS].extcontrols) {
g_PlayerConfigsArray[playernum].controlmode = CONTROLMODE_PC; g_PlayerConfigsArray[playernum].controlmode = CONTROLMODE_PC;
} }
#endif #endif
for (i = 0; i < ARRAYCOUNT(g_MpChallenges); i++) { for (i = 0; i < ARRAYCOUNT(g_MpChallenges); i++) {
for (j = 1; j < MAX_PLAYERS + 1; j++) { for (j = 1; j < MAX_LOCAL_PLAYERS + 1; j++) {
challengeSetCompletedByPlayerWithNumPlayers(playernum, i, j, savebufferReadBits(buffer, 1)); challengeSetCompletedByPlayerWithNumPlayers(playernum, i, j, savebufferReadBits(buffer, 1));
} }
} }
@@ -3665,7 +3705,7 @@ void mpplayerfileSaveWad(s32 playernum, struct savebuffer *buffer)
savebufferOr(buffer, g_PlayerConfigsArray[playernum].options, 12); savebufferOr(buffer, g_PlayerConfigsArray[playernum].options, 12);
for (i = 0; i < ARRAYCOUNT(g_MpChallenges); i++) { for (i = 0; i < ARRAYCOUNT(g_MpChallenges); i++) {
for (j = 1; j < MAX_PLAYERS + 1; j++) { for (j = 1; j < MAX_LOCAL_PLAYERS + 1; j++) {
savebufferOr(buffer, challengeIsCompletedByPlayerWithNumPlayers(playernum, i, j), 1); savebufferOr(buffer, challengeIsCompletedByPlayerWithNumPlayers(playernum, i, j), 1);
} }
} }
@@ -3850,7 +3890,7 @@ void mpApplyConfig(struct mpconfigfull *config)
for (i = 0; i < MAX_BOTS; i++) { for (i = 0; i < MAX_BOTS; i++) {
g_BotConfigsArray[i].type = config->config.simulants[i].type; g_BotConfigsArray[i].type = config->config.simulants[i].type;
for (j = 0; j < MAX_PLAYERS; j++) { for (j = 0; j < MAX_LOCAL_PLAYERS; j++) {
g_MpSimulantDifficultiesPerNumPlayers[i][j] = config->config.simulants[i].difficulties[j]; g_MpSimulantDifficultiesPerNumPlayers[i][j] = config->config.simulants[i].difficulties[j];
} }
@@ -3907,11 +3947,15 @@ void mp0f18dec4(s32 slot)
mpApplyConfig(config); mpApplyConfig(config);
#if VERSION >= VERSION_JPN_FINAL #if VERSION >= VERSION_JPN_FINAL
#if MAX_PLAYERS > 4
g_MpSetup.chrslots &= 0xff;
#else
g_MpSetup.chrslots &= 0x0f; g_MpSetup.chrslots &= 0x0f;
#endif
for (i = 0; i < MAX_BOTS; i++) { for (i = 0; i < MAX_BOTS; i++) {
if (g_BotConfigsArray[i].difficulty != BOTDIFF_DISABLED) { if (g_BotConfigsArray[i].difficulty != BOTDIFF_DISABLED) {
g_MpSetup.chrslots |= 1 << (i + 4); g_MpSetup.chrslots |= 1 << (i + MAX_PLAYERS);
} }
} }
#endif #endif
@@ -3972,12 +4016,12 @@ void mpsetupfileLoadWad(struct savebuffer *buffer, u8 version)
g_BotConfigsArray[i].type = savebufferReadBits(buffer, 5); g_BotConfigsArray[i].type = savebufferReadBits(buffer, 5);
g_BotConfigsArray[i].difficulty = savebufferReadBits(buffer, 3); g_BotConfigsArray[i].difficulty = savebufferReadBits(buffer, 3);
for (j = 0; j < MAX_PLAYERS; j++) { for (j = 0; j < MAX_LOCAL_PLAYERS; j++) {
g_MpSimulantDifficultiesPerNumPlayers[i][j] = g_BotConfigsArray[i].difficulty; g_MpSimulantDifficultiesPerNumPlayers[i][j] = g_BotConfigsArray[i].difficulty;
} }
if (g_BotConfigsArray[i].difficulty != BOTDIFF_DISABLED) { if (g_BotConfigsArray[i].difficulty != BOTDIFF_DISABLED) {
g_MpSetup.chrslots |= 1 << (i + 4); g_MpSetup.chrslots |= 1 << (i + MAX_PLAYERS);
} }
g_BotConfigsArray[i].base.mpheadnum = savebufferReadBits(buffer, 7); g_BotConfigsArray[i].base.mpheadnum = savebufferReadBits(buffer, 7);
@@ -4004,7 +4048,7 @@ void mpsetupfileLoadWad(struct savebuffer *buffer, u8 version)
g_MpSetup.scorelimit = savebufferReadBits(buffer, 7); g_MpSetup.scorelimit = savebufferReadBits(buffer, 7);
g_MpSetup.teamscorelimit = savebufferReadBits(buffer, 9); g_MpSetup.teamscorelimit = savebufferReadBits(buffer, 9);
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_LOCAL_PLAYERS; i++) {
g_PlayerConfigsArray[i].base.team = savebufferReadBits(buffer, 3); g_PlayerConfigsArray[i].base.team = savebufferReadBits(buffer, 3);
} }
@@ -4020,7 +4064,7 @@ void mpsetupfileSaveWad(struct savebuffer *buffer)
savebufferWriteString_ext(buffer, g_MpSetup.name, MPSETUP_MAXNAME + 1); savebufferWriteString_ext(buffer, g_MpSetup.name, MPSETUP_MAXNAME + 1);
for (i = 0; i < MAX_BOTS; i++) { for (i = 0; i < MAX_BOTS; i++) {
if (g_MpSetup.chrslots & (1 << (i + 4))) { if (g_MpSetup.chrslots & (1 << (i + MAX_PLAYERS))) {
numsims++; numsims++;
} }
} }
@@ -4036,7 +4080,7 @@ void mpsetupfileSaveWad(struct savebuffer *buffer)
for (i = 0; i < MAX_BOTS; i++) { for (i = 0; i < MAX_BOTS; i++) {
savebufferOr(buffer, g_BotConfigsArray[i].type, 5); savebufferOr(buffer, g_BotConfigsArray[i].type, 5);
if (g_MpSetup.chrslots & (1 << (i + 4))) { if (g_MpSetup.chrslots & (1 << (i + MAX_PLAYERS))) {
savebufferOr(buffer, g_BotConfigsArray[i].difficulty, 3); savebufferOr(buffer, g_BotConfigsArray[i].difficulty, 3);
} else { } else {
savebufferOr(buffer, BOTDIFF_DISABLED, 3); savebufferOr(buffer, BOTDIFF_DISABLED, 3);
@@ -4072,7 +4116,7 @@ void mpsetupfileSaveWad(struct savebuffer *buffer)
savebufferOr(buffer, g_MpSetup.scorelimit, 7); savebufferOr(buffer, g_MpSetup.scorelimit, 7);
savebufferOr(buffer, g_MpSetup.teamscorelimit, 9); savebufferOr(buffer, g_MpSetup.teamscorelimit, 9);
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_LOCAL_PLAYERS; i++) {
savebufferOr(buffer, g_PlayerConfigsArray[i].base.team, 3); savebufferOr(buffer, g_PlayerConfigsArray[i].base.team, 3);
} }
} }
+1 -1
View File
@@ -1039,7 +1039,7 @@ struct prop *scenarioCreateObj(s32 modelnum, s16 padnum, f32 arg2, u32 flags, u3
*/ */
void scenarioCreateHudmsg(s32 playernum, char *message) void scenarioCreateHudmsg(s32 playernum, char *message)
{ {
if (playernum >= 0 && playernum < PLAYERCOUNT()) { if (playernum >= 0 && playernum < LOCALPLAYERCOUNT()) {
s32 prevplayernum = g_Vars.currentplayernum; s32 prevplayernum = g_Vars.currentplayernum;
setCurrentPlayerNum(playernum); setCurrentPlayerNum(playernum);
+64 -9
View File
@@ -24,9 +24,12 @@
#include "data.h" #include "data.h"
#include "gbiex.h" #include "gbiex.h"
#include "types.h" #include "types.h"
#ifndef PLATFORM_N64
#include "net/net.h"
#include "system.h" #include "system.h"
#include "input.h" #include "input.h"
#include "mpsetups.h" #include "mpsetups.h"
#endif
struct menuitem g_MpCharacterMenuItems[]; struct menuitem g_MpCharacterMenuItems[];
struct menudialogdef g_MpAddSimulantMenuDialog; struct menudialogdef g_MpAddSimulantMenuDialog;
@@ -2392,7 +2395,7 @@ MenuItemHandlerResult mpLoadPlayerMenuHandler(s32 operation, struct menuitem *it
file = &g_FileLists[0]->files[data->list.value]; file = &g_FileLists[0]->files[data->list.value];
available = true; available = true;
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_LOCAL_PLAYERS; i++) {
if (file->fileid == g_PlayerConfigsArray[i].fileguid.fileid if (file->fileid == g_PlayerConfigsArray[i].fileguid.fileid
&& file->deviceserial == g_PlayerConfigsArray[i].fileguid.deviceserial) { && file->deviceserial == g_PlayerConfigsArray[i].fileguid.deviceserial) {
if ((g_MpSetup.chrslots & (1 << i)) == 0) { if ((g_MpSetup.chrslots & (1 << i)) == 0) {
@@ -2523,6 +2526,15 @@ MenuItemHandlerResult menuhandlerMpHandicapPlayer(s32 operation, struct menuitem
char *mpMenuTextHandicapPlayerName(struct menuitem *item) char *mpMenuTextHandicapPlayerName(struct menuitem *item)
{ {
if (g_MpSetup.chrslots & (1 << item->param)) { if (g_MpSetup.chrslots & (1 << item->param)) {
#ifndef PLATFORM_N64
if (g_NetMode) {
// use client names directly, as the config names are not set yet
struct netclient *cl = netClientForPlayerNum(item->param);
if (cl) {
return cl->settings.name;
}
}
#endif
return g_PlayerConfigsArray[item->param].base.name; return g_PlayerConfigsArray[item->param].base.name;
} }
@@ -2850,6 +2862,40 @@ struct menuitem g_MpHandicapsMenuItems[] = {
0x000000ff, 0x000000ff,
menuhandlerMpHandicapPlayer, menuhandlerMpHandicapPlayer,
}, },
#if MAX_PLAYERS > 4
{
MENUITEMTYPE_SLIDER,
4,
MENUITEMFLAG_LESSLEFTPADDING | MENUITEMFLAG_LOCKABLEMINOR,
(uintptr_t)&mpMenuTextHandicapPlayerName,
0x000000ff,
menuhandlerMpHandicapPlayer,
},
{
MENUITEMTYPE_SLIDER,
5,
MENUITEMFLAG_LESSLEFTPADDING | MENUITEMFLAG_LOCKABLEMINOR,
(uintptr_t)&mpMenuTextHandicapPlayerName,
0x000000ff,
menuhandlerMpHandicapPlayer,
},
{
MENUITEMTYPE_SLIDER,
6,
MENUITEMFLAG_LESSLEFTPADDING | MENUITEMFLAG_LOCKABLEMINOR,
(uintptr_t)&mpMenuTextHandicapPlayerName,
0x000000ff,
menuhandlerMpHandicapPlayer,
},
{
MENUITEMTYPE_SLIDER,
7,
MENUITEMFLAG_LESSLEFTPADDING | MENUITEMFLAG_LOCKABLEMINOR,
(uintptr_t)&mpMenuTextHandicapPlayerName,
0x000000ff,
menuhandlerMpHandicapPlayer,
},
#endif
{ {
MENUITEMTYPE_SEPARATOR, MENUITEMTYPE_SEPARATOR,
0, 0,
@@ -2948,7 +2994,7 @@ MenuItemHandlerResult mpAddChangeSimulantMenuHandler(s32 operation, struct menui
if (botnum < 0) { if (botnum < 0) {
botnum = mpGetSlotForNewBot(); botnum = mpGetSlotForNewBot();
creating = 1; creating = 1;
} else if ((g_MpSetup.chrslots & (1 << (botnum + 4))) == 0) { } else if ((g_MpSetup.chrslots & (1 << (botnum + MAX_PLAYERS))) == 0) {
creating = 1; creating = 1;
} }
@@ -3206,7 +3252,7 @@ MenuItemHandlerResult menuhandlerMpSimulantSlot(s32 operation, struct menuitem *
case MENUOP_SET: case MENUOP_SET:
g_Menus[g_MpPlayerNum].mpsetup.slotindex = item->param; g_Menus[g_MpPlayerNum].mpsetup.slotindex = item->param;
if ((g_MpSetup.chrslots & (1 << (item->param + 4))) == 0) { if ((g_MpSetup.chrslots & (1 << (item->param + MAX_PLAYERS))) == 0) {
menuPushDialog(&g_MpAddSimulantMenuDialog); menuPushDialog(&g_MpAddSimulantMenuDialog);
} else if (IS4MB()) { } else if (IS4MB()) {
menuPushDialog(&g_MpEditSimulant4MbMenuDialog); menuPushDialog(&g_MpEditSimulant4MbMenuDialog);
@@ -3232,7 +3278,7 @@ char *mpMenuTextSimulantName(struct menuitem *item)
{ {
s32 index = item->param; s32 index = item->param;
if (g_BotConfigsArray[index].base.name[0] == '\0' || (g_MpSetup.chrslots & 1 << (index + 4)) == 0) { if (g_BotConfigsArray[index].base.name[0] == '\0' || (g_MpSetup.chrslots & 1 << (index + MAX_PLAYERS)) == 0) {
return ""; return "";
} }
@@ -3244,7 +3290,7 @@ char *func0f17d3dc(struct menuitem *item)
s32 index = item->param; s32 index = item->param;
if (g_BotConfigsArray[index].base.name[0] == '\0' if (g_BotConfigsArray[index].base.name[0] == '\0'
|| ((g_MpSetup.chrslots & 1 << (index + 4)) == 0)) { || ((g_MpSetup.chrslots & 1 << (index + MAX_PLAYERS)) == 0)) {
return ""; return "";
} }
@@ -3642,7 +3688,7 @@ MenuItemHandlerResult menuhandlerMpHumansVsSimulants(s32 operation, struct menui
if (g_MpSetup.chrslots & (1 << i)) { if (g_MpSetup.chrslots & (1 << i)) {
struct mpchrconfig *mpchr = MPCHR(i); struct mpchrconfig *mpchr = MPCHR(i);
mpchr->team = i < 4 ? 0 : 1; mpchr->team = i < MAX_PLAYERS ? 0 : 1;
} }
} }
@@ -3655,7 +3701,7 @@ MenuItemHandlerResult menuhandlerMpHumansVsSimulants(s32 operation, struct menui
MenuItemHandlerResult menuhandlerMpHumanSimulantPairs(s32 operation, struct menuitem *item, union handlerdata *data) MenuItemHandlerResult menuhandlerMpHumanSimulantPairs(s32 operation, struct menuitem *item, union handlerdata *data)
{ {
if (operation == MENUOP_SET) { if (operation == MENUOP_SET) {
u8 team_ids[4] = {0, 1, 2, 3}; u8 team_ids[MAX_PLAYERS] = {0, 1, 2, 3, 4, 5, 6, 7};
s32 i; s32 i;
s32 playerindex = 0; s32 playerindex = 0;
s32 simindex = 0; s32 simindex = 0;
@@ -3664,7 +3710,7 @@ MenuItemHandlerResult menuhandlerMpHumanSimulantPairs(s32 operation, struct menu
if (g_MpSetup.chrslots & (1 << i)) { if (g_MpSetup.chrslots & (1 << i)) {
struct mpchrconfig *mpchr = MPCHR(i); struct mpchrconfig *mpchr = MPCHR(i);
if (i < 4) { if (i < MAX_PLAYERS) {
mpchr->team = team_ids[playerindex++]; mpchr->team = team_ids[playerindex++];
} else { } else {
mpchr->team = team_ids[simindex++]; mpchr->team = team_ids[simindex++];
@@ -3687,6 +3733,15 @@ char *mpMenuTextChrNameForTeamSetup(struct menuitem *item)
struct mpchrconfig *mpchr = mpGetChrConfigBySlotNum(item->param); struct mpchrconfig *mpchr = mpGetChrConfigBySlotNum(item->param);
if (mpchr) { if (mpchr) {
#ifndef PLATFORM_N64
if (g_NetMode) {
// use client names directly, as the config names are not set yet
struct netclient *cl = netClientForPlayerNum(item->param);
if (cl) {
return cl->settings.name;
}
}
#endif
return mpchr->name; return mpchr->name;
} }
@@ -5434,7 +5489,7 @@ void mpCloseDialogsForNewSetup(void)
s32 k; s32 k;
// Loop through each player // Loop through each player
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_LOCAL_PLAYERS; i++) {
g_MpPlayerNum = i; g_MpPlayerNum = i;
// If they have a menu open // If they have a menu open
+2 -2
View File
@@ -343,7 +343,7 @@ bool musicIsAnyPlayerInAmbientRoom(void)
return false; return false;
} }
for (i = 0; i < PLAYERCOUNT(); i++) { for (i = 0; i < LOCALPLAYERCOUNT(); i++) {
if (g_Vars.players[i]->prop if (g_Vars.players[i]->prop
&& g_Vars.players[i]->prop->rooms && g_Vars.players[i]->prop->rooms
&& g_Vars.players[i]->prop->rooms[0] != -1) { && g_Vars.players[i]->prop->rooms[0] != -1) {
@@ -521,7 +521,7 @@ void _musicStartMpDeath(f32 arg0)
void musicStartMpDeath(void) void musicStartMpDeath(void)
{ {
#ifndef PLATFORM_N64 #ifndef PLATFORM_N64
if (g_MusicDisableMpDeath) { if (g_MusicDisableMpDeath || (g_NetMode && g_Vars.currentplayernum != 0)) {
return; return;
} }
#endif #endif
+1 -1
View File
@@ -324,7 +324,7 @@ Gfx *nbombCreateGdl(void)
Gfx *gdl; Gfx *gdl;
s32 index = 0; s32 index = 0;
if (PLAYERCOUNT() >= 2) { if (LOCALPLAYERCOUNT() >= 2) {
index = 1; index = 1;
} }
+7 -7
View File
@@ -234,7 +234,7 @@ struct pak g_Paks[5]; // controller paks + EEPROM
u32 var800a317c; u32 var800a317c;
#endif #endif
OSPfs g_Pfses[MAX_PLAYERS]; OSPfs g_Pfses[MAX_LOCAL_PLAYERS];
u32 var800a3320; u32 var800a3320;
u32 var800a3324; u32 var800a3324;
u32 var800a3328; u32 var800a3328;
@@ -4425,7 +4425,7 @@ void pak0f11c6d0(void)
{ {
s32 i; s32 i;
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_LOCAL_PLAYERS; i++) {
switch (g_Paks[i].state) { switch (g_Paks[i].state) {
case PAKSTATE_PROBE: case PAKSTATE_PROBE:
case PAKSTATE_MEM_DISPATCH: case PAKSTATE_MEM_DISPATCH:
@@ -5441,14 +5441,14 @@ void pakDisableRumbleForAllPlayers(void)
s32 i; s32 i;
#if VERSION >= VERSION_NTSC_1_0 #if VERSION >= VERSION_NTSC_1_0
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_LOCAL_PLAYERS; i++) {
if (g_Paks[i].type == PAKTYPE_RUMBLE) { if (g_Paks[i].type == PAKTYPE_RUMBLE) {
g_Paks[i].rumblestate = RUMBLESTATE_DISABLED_STOPPING; g_Paks[i].rumblestate = RUMBLESTATE_DISABLED_STOPPING;
joyStopRumble(i, true); joyStopRumble(i, true);
} }
} }
#else #else
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_LOCAL_PLAYERS; i++) {
pakDisableRumbleForPlayer(i); pakDisableRumbleForPlayer(i);
} }
#endif #endif
@@ -5459,13 +5459,13 @@ void pakEnableRumbleForAllPlayers(void)
s32 i; s32 i;
#if VERSION >= VERSION_NTSC_FINAL #if VERSION >= VERSION_NTSC_FINAL
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_LOCAL_PLAYERS; i++) {
if (g_Paks[i].type == PAKTYPE_RUMBLE && g_Paks[i].rumblestate == RUMBLESTATE_DISABLED_STOPPED) { if (g_Paks[i].type == PAKTYPE_RUMBLE && g_Paks[i].rumblestate == RUMBLESTATE_DISABLED_STOPPED) {
g_Paks[i].rumblestate = RUMBLESTATE_ENABLING; g_Paks[i].rumblestate = RUMBLESTATE_ENABLING;
} }
} }
#else #else
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_LOCAL_PLAYERS; i++) {
pakEnableRumbleForPlayer(i); pakEnableRumbleForPlayer(i);
} }
#endif #endif
@@ -5989,7 +5989,7 @@ bool gbpakIsAnyPerfectDark(void)
#ifdef PLATFORM_N64 #ifdef PLATFORM_N64
s8 i; s8 i;
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < MAX_LOCAL_PLAYERS; i++) {
if (gbpakIdentifyGame(i) == GBGAME_PD) { if (gbpakIdentifyGame(i) == GBGAME_PD) {
return true; return true;
} }
+139 -17
View File
@@ -71,9 +71,11 @@
#include "data.h" #include "data.h"
#include "types.h" #include "types.h"
#ifndef PLATFORM_N64 #ifndef PLATFORM_N64
#include "platform.h"
#include "video.h" #include "video.h"
#include "input.h" #include "input.h"
#include "platform.h" #include "net/net.h"
#include "net/netmsg.h"
#endif #endif
s32 g_DefaultWeapons[2]; s32 g_DefaultWeapons[2];
@@ -183,7 +185,10 @@ u32 var80070748 = 0;
u32 var8007074c = 0; u32 var8007074c = 0;
bool g_PlayersWithControl[] = { bool g_PlayersWithControl[] = {
true, true, true, true,
#if MAX_PLAYERS > 4
true, true, true, true true, true, true, true
#endif
}; };
bool g_PlayerInvincible = false; bool g_PlayerInvincible = false;
@@ -602,7 +607,7 @@ void playerStartNewLife(void)
if (cmd); if (cmd);
if (cmd); if (cmd);
if (g_Vars.antiplayernum < 0 || g_Vars.currentplayer != g_Vars.anti) { if (g_Vars.antiplayernum < 0 || PLAYER_IS_NOT_ANTI(g_Vars.currentplayer)) {
while (cmd[0] != INTROCMD_END) { while (cmd[0] != INTROCMD_END) {
switch (cmd[0]) { switch (cmd[0]) {
case INTROCMD_SPAWN: case INTROCMD_SPAWN:
@@ -976,7 +981,7 @@ void playerSpawn(void)
} }
if (g_Vars.mplayerisrunning) { if (g_Vars.mplayerisrunning) {
if (g_Vars.antiplayernum >= 0 && g_Vars.currentplayer == g_Vars.anti) { if (g_Vars.antiplayernum >= 0 && PLAYER_IS_ANTI(g_Vars.currentplayer)) {
numsqdists = 0; numsqdists = 0;
force = false; force = false;
@@ -1151,6 +1156,12 @@ void playerSpawn(void)
} }
playerUpdatePerimInfo(); playerUpdatePerimInfo();
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_SERVER && g_Vars.currentplayer->client) {
netmsgSvcPlayerStatsWrite(&g_NetMsgRel, g_Vars.currentplayer->client);
}
#endif
} }
void playerResetBond(struct playerbond *pb, struct coord *pos) void playerResetBond(struct playerbond *pb, struct coord *pos)
@@ -1193,7 +1204,7 @@ void playerChooseBodyAndHead(s32 *bodynum, s32 *headnum, s32 *arg2)
bool solo; bool solo;
if (g_Vars.antiplayernum >= 0 if (g_Vars.antiplayernum >= 0
&& g_Vars.currentplayer == g_Vars.anti && PLAYER_IS_ANTI(g_Vars.currentplayer)
&& g_Vars.antiheadnum >= 0 && g_Vars.antiheadnum >= 0
&& g_Vars.antibodynum >= 0) { && g_Vars.antibodynum >= 0) {
*headnum = g_Vars.antiheadnum; *headnum = g_Vars.antiheadnum;
@@ -1535,7 +1546,7 @@ void playerTickChrBody(void)
#if VERSION >= VERSION_NTSC_1_0 #if VERSION >= VERSION_NTSC_1_0
if (g_Vars.antiplayernum >= 0 if (g_Vars.antiplayernum >= 0
&& g_Vars.currentplayer == g_Vars.anti && PLAYER_IS_ANTI(g_Vars.currentplayer)
&& g_Vars.currentplayer->vv_eyeheight > 159) { && g_Vars.currentplayer->vv_eyeheight > 159) {
g_Vars.currentplayer->vv_eyeheight = 159; g_Vars.currentplayer->vv_eyeheight = 159;
} }
@@ -2096,6 +2107,15 @@ void playerTickCutscene(bool arg0)
} }
} }
#endif #endif
#ifndef PLATFORM_N64
if (g_Vars.stagenum == STAGE_CITRAINING) {
if (g_CutsceneCurTotalFrame60f > 10 && (g_NetHostLatch || g_NetJoinLatch)) {
// just booted up and host/join was requested from command line, skip the intro cutscene
g_CutsceneSkipRequested = true;
}
}
#endif
} }
f32 playerGetCutsceneBlurFrac(void) f32 playerGetCutsceneBlurFrac(void)
@@ -2882,6 +2902,12 @@ s16 playerGetFbHeight(void)
#if VERSION >= VERSION_NTSC_1_0 #if VERSION >= VERSION_NTSC_1_0
bool playerHasSharedViewport(void) bool playerHasSharedViewport(void)
{ {
#ifndef PLATFORM_N64
if (g_NetMode) {
return true;
}
#endif
if ((g_Vars.coopplayernum >= 0 || g_Vars.antiplayernum >= 0) if ((g_Vars.coopplayernum >= 0 || g_Vars.antiplayernum >= 0)
&& menuGetRoot() == MENUROOT_MPENDSCREEN && menuGetRoot() == MENUROOT_MPENDSCREEN
&& var8009dfc0 == 0) { && var8009dfc0 == 0) {
@@ -2902,14 +2928,14 @@ s16 playerGetViewportWidth(void)
if ((!g_InCutscene || g_MainIsEndscreen) && menuGetRoot() != MENUROOT_COOPCONTINUE) if ((!g_InCutscene || g_MainIsEndscreen) && menuGetRoot() != MENUROOT_COOPCONTINUE)
#endif #endif
{ {
if (PLAYERCOUNT() >= 3) { if (LOCALPLAYERCOUNT() >= 3) {
// 3/4 players // 3/4 players
width = g_ViModes[g_ViRes].width / 2; width = g_ViModes[g_ViRes].width / 2;
if (g_Vars.currentplayernum == 0 || g_Vars.currentplayernum == 2) { if (g_Vars.currentplayernum == 0 || g_Vars.currentplayernum == 2) {
width--; width--;
} }
} else if (PLAYERCOUNT() == 2) { } else if (LOCALPLAYERCOUNT() == 2) {
if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL || g_Vars.fourmeg2player) { if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL || g_Vars.fourmeg2player) {
// 2 players vsplit // 2 players vsplit
width = g_ViModes[g_ViRes].width / 2; width = g_ViModes[g_ViRes].width / 2;
@@ -2942,7 +2968,7 @@ s16 playerGetViewportLeft(void)
#endif #endif
s16 left; s16 left;
if (PLAYERCOUNT() >= 3 && something != 0) { if (LOCALPLAYERCOUNT() >= 3 && something != 0) {
if (g_Vars.currentplayernum == 1 || g_Vars.currentplayernum == 3) { if (g_Vars.currentplayernum == 1 || g_Vars.currentplayernum == 3) {
// 3/4 players - right side // 3/4 players - right side
left = g_ViModes[g_ViRes].width / 2 + g_ViModes[g_ViRes].fbwidth - g_ViModes[g_ViRes].width; left = g_ViModes[g_ViRes].width / 2 + g_ViModes[g_ViRes].fbwidth - g_ViModes[g_ViRes].width;
@@ -2950,7 +2976,7 @@ s16 playerGetViewportLeft(void)
// 3/4 players - left side // 3/4 players - left side
left = g_ViModes[g_ViRes].fbwidth - g_ViModes[g_ViRes].width; left = g_ViModes[g_ViRes].fbwidth - g_ViModes[g_ViRes].width;
} }
} else if (PLAYERCOUNT() == 2 && something != 0) { } else if (LOCALPLAYERCOUNT() == 2 && something != 0) {
if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL || g_Vars.fourmeg2player) { if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL || g_Vars.fourmeg2player) {
if (g_Vars.currentplayernum == 1) { if (g_Vars.currentplayernum == 1) {
// 2 players vsplit - right side // 2 players vsplit - right side
@@ -2975,7 +3001,7 @@ s16 playerGetViewportHeight(void)
{ {
s16 height; s16 height;
if (PLAYERCOUNT() >= 2 if (LOCALPLAYERCOUNT() >= 2
#if VERSION >= VERSION_NTSC_1_0 #if VERSION >= VERSION_NTSC_1_0
&& !playerHasSharedViewport() && !playerHasSharedViewport()
#else #else
@@ -2990,7 +3016,7 @@ s16 playerGetViewportHeight(void)
height = tmp / 2; height = tmp / 2;
} }
if (PLAYERCOUNT() == 2) { if (LOCALPLAYERCOUNT() == 2) {
if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) { if (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) {
height = tmp; height = tmp;
} else if (g_Vars.currentplayernum == 0 && IS8MB()) { } else if (g_Vars.currentplayernum == 0 && IS8MB()) {
@@ -3026,7 +3052,7 @@ s16 playerGetViewportTop(void)
{ {
s16 top; s16 top;
if (PLAYERCOUNT() >= 2 if (LOCALPLAYERCOUNT() >= 2
#if VERSION >= VERSION_NTSC_1_0 #if VERSION >= VERSION_NTSC_1_0
&& !playerHasSharedViewport() && !playerHasSharedViewport()
#else #else
@@ -3037,12 +3063,12 @@ s16 playerGetViewportTop(void)
top = g_ViModes[g_ViRes].fulltop; top = g_ViModes[g_ViRes].fulltop;
#if VERSION >= VERSION_NTSC_1_0 #if VERSION >= VERSION_NTSC_1_0
if (optionsGetScreenSplit() != SCREENSPLIT_VERTICAL || PLAYERCOUNT() != 2) if (optionsGetScreenSplit() != SCREENSPLIT_VERTICAL || LOCALPLAYERCOUNT() != 2)
#else #else
if (optionsGetScreenSplit() != SCREENSPLIT_VERTICAL) if (optionsGetScreenSplit() != SCREENSPLIT_VERTICAL)
#endif #endif
{ {
if (PLAYERCOUNT() == 2 if (LOCALPLAYERCOUNT() == 2
&& g_Vars.currentplayernum == 1 && g_Vars.currentplayernum == 1
&& optionsGetScreenSplit() != SCREENSPLIT_VERTICAL && optionsGetScreenSplit() != SCREENSPLIT_VERTICAL
&& !g_Vars.fourmeg2player) { && !g_Vars.fourmeg2player) {
@@ -3569,6 +3595,11 @@ void playerTick(bool arg0)
bool pause = false; bool pause = false;
f32 newspeed; f32 newspeed;
#ifndef PLATFORM_N64
if (mode == CONTROLMODE_NA) {
// TODO
} else
#endif
if (mode == CONTROLMODE_23 if (mode == CONTROLMODE_23
|| mode == CONTROLMODE_24 || mode == CONTROLMODE_24
|| mode == CONTROLMODE_22 || mode == CONTROLMODE_22
@@ -4743,8 +4774,15 @@ Gfx *playerRenderHud(Gfx *gdl)
chr->chrflags |= CHRCFLAG_HIDDEN; chr->chrflags |= CHRCFLAG_HIDDEN;
} }
if (g_Vars.antiplayernum >= 0 && g_Vars.currentplayer == g_Vars.anti) { if (g_Vars.antiplayernum >= 0 && PLAYER_IS_ANTI(g_Vars.currentplayer)) {
// Anti // Anti
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_SERVER && g_Vars.currentplayer->isremote) {
if (g_Vars.currentplayer->client->inmove[0].ucmd & UCMD_RESPAWN) {
g_Vars.currentplayer->dostartnewlife = true;
}
} else if (g_NetMode != NETMODE_CLIENT)
#endif
if (joyGetButtons(optionsGetContpadNum1(g_Vars.currentplayerstats->mpindex), 0xb000) && !mpIsPaused()) { if (joyGetButtons(optionsGetContpadNum1(g_Vars.currentplayerstats->mpindex), 0xb000) && !mpIsPaused()) {
g_Vars.currentplayer->dostartnewlife = true; g_Vars.currentplayer->dostartnewlife = true;
} }
@@ -4758,8 +4796,12 @@ Gfx *playerRenderHud(Gfx *gdl)
f32 stealhealth; f32 stealhealth;
f32 shield; f32 shield;
canrestart = joyGetButtons(optionsGetContpadNum1(g_Vars.currentplayerstats->mpindex), 0xb000) #ifndef PLATFORM_N64
&& !mpIsPaused(); if (g_NetMode == NETMODE_SERVER && g_Vars.currentplayer->isremote) {
canrestart = (g_Vars.currentplayer->client->inmove[0].ucmd & UCMD_RESPAWN) != 0;
} else if (g_NetMode != NETMODE_CLIENT)
#endif
canrestart = joyGetButtons(optionsGetContpadNum1(g_Vars.currentplayerstats->mpindex), 0xb000) && !mpIsPaused();
// Get ready to respawn. // Get ready to respawn.
// The other player's health will be halved. // The other player's health will be halved.
@@ -4865,6 +4907,13 @@ Gfx *playerRenderHud(Gfx *gdl)
} }
} }
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_SERVER && g_Vars.currentplayer->isremote) {
if (!mpIsPaused() && g_NumReasonsToEndMpMatch == 0 && (g_Vars.currentplayer->client->inmove[0].ucmd & UCMD_RESPAWN)) {
canrestart = true;
}
} else if (g_NetMode != NETMODE_CLIENT)
#endif
if (joyGetButtons(optionsGetContpadNum1(g_Vars.currentplayerstats->mpindex), 0xb000) if (joyGetButtons(optionsGetContpadNum1(g_Vars.currentplayerstats->mpindex), 0xb000)
&& !mpIsPaused() && !mpIsPaused()
&& g_NumReasonsToEndMpMatch == 0) { && g_NumReasonsToEndMpMatch == 0) {
@@ -4948,6 +4997,12 @@ void playerDie(bool force)
struct chrdata *chr = g_Vars.currentplayer->prop->chr; struct chrdata *chr = g_Vars.currentplayer->prop->chr;
s32 shooter; s32 shooter;
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_CLIENT) {
return;
}
#endif
if (chr->lastshooter >= 0 && chr->timeshooter > 0) { if (chr->lastshooter >= 0 && chr->timeshooter > 0) {
shooter = chr->lastshooter; shooter = chr->lastshooter;
} else { } else {
@@ -4955,6 +5010,12 @@ void playerDie(bool force)
} }
playerDieByShooter(shooter, force); playerDieByShooter(shooter, force);
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_SERVER && g_Vars.currentplayer->client) {
netmsgSvcPlayerStatsWrite(&g_NetMsgRel, g_Vars.currentplayer->client);
}
#endif
} }
void playerDieByShooter(u32 shooter, bool force) void playerDieByShooter(u32 shooter, bool force)
@@ -5877,3 +5938,64 @@ void player0f0c3320(Mtxf *matrices, s32 count)
mtxF2L(&sp40, matrices + i); mtxF2L(&sp40, matrices + i);
} }
} }
struct sndstate *playerSndStart(s32 arg0, s16 sound, struct sndstate **handle, s32 playernum, f32 pitch, s32 fxbus, s32 fxmix)
{
s32 vol = -1;
s32 pan = -1;
#ifndef PLATFORM_N64
const struct player *pl = g_Vars.players[playernum];
if (g_NetMode && playernum != 0 && pl && pl->prop) {
// auto attenuate sounds for remote players
psGetTheoreticalVolPan(&pl->prop->pos, pl->prop->rooms, sound, &vol, &pan);
}
#endif
return sndStart(arg0, sound, handle, vol, pan, pitch, fxbus, fxmix);
}
#ifndef PLATFORM_N64
f32 playerGetDefaultFovY(s32 playernum)
{
if (g_NetMode) {
const struct player *pl = g_Vars.players[playernum % MAX_PLAYERS];
if (pl && pl->client) {
return pl->client->settings.fovy;
}
}
return g_PlayerExtCfg[playernum % MAX_LOCAL_PLAYERS].fovy;
}
f32 playerGetZoomFovMult(s32 playernum)
{
if (g_NetMode) {
const struct player *pl = g_Vars.players[playernum % MAX_PLAYERS];
if (pl && pl->client) {
return pl->client->settings.fovzoommult;
}
}
return g_PlayerExtCfg[playernum % MAX_LOCAL_PLAYERS].fovzoommult;
}
s32 playerGetCount(void)
{
s32 count = 0;
for (s32 i = 0; i < MAX_PLAYERS; ++i) {
count += (g_Vars.players[i] != NULL);
}
return count;
}
s32 playerGetLocalCount(void)
{
if (g_NetMode) {
return 1;
}
const s32 playercount = playerGetCount();
if (playercount > MAX_LOCAL_PLAYERS) {
return MAX_LOCAL_PLAYERS;
}
return playercount;
}
#endif
+36 -1
View File
@@ -10,6 +10,9 @@
#include "lib/rng.h" #include "lib/rng.h"
#include "data.h" #include "data.h"
#include "types.h" #include "types.h"
#ifndef PLATFORM_N64
#include "net/net.h"
#endif
void playermgrInit(void) void playermgrInit(void)
{ {
@@ -26,10 +29,16 @@ void playermgrInit(void)
void playermgrReset(void) void playermgrReset(void)
{ {
#if MAX_PLAYERS > 4
for (s32 i = 0; i < MAX_PLAYERS; ++i) {
g_Vars.players[i] = NULL;
}
#else
g_Vars.players[0] = NULL; g_Vars.players[0] = NULL;
g_Vars.players[1] = NULL; g_Vars.players[1] = NULL;
g_Vars.players[2] = NULL; g_Vars.players[2] = NULL;
g_Vars.players[3] = NULL; g_Vars.players[3] = NULL;
#endif
g_Vars.currentplayer = NULL; g_Vars.currentplayer = NULL;
g_Vars.currentplayerindex = 0; g_Vars.currentplayerindex = 0;
@@ -48,10 +57,16 @@ void playermgrReset(void)
void playermgrAllocatePlayers(s32 count) void playermgrAllocatePlayers(s32 count)
{ {
#if MAX_PLAYERS > 4
for (s32 i = 0; i < MAX_PLAYERS; ++i) {
g_Vars.players[i] = NULL;
}
#else
g_Vars.players[0] = NULL; g_Vars.players[0] = NULL;
g_Vars.players[1] = NULL; g_Vars.players[1] = NULL;
g_Vars.players[2] = NULL; g_Vars.players[2] = NULL;
g_Vars.players[3] = NULL; g_Vars.players[3] = NULL;
#endif
if (count > 0) { if (count > 0) {
s32 i; s32 i;
@@ -60,6 +75,12 @@ void playermgrAllocatePlayers(s32 count)
playermgrAllocatePlayer(i); playermgrAllocatePlayer(i);
} }
#ifndef PLATFORM_N64
if (g_NetMode && g_StageNum != STAGE_TITLE && g_StageNum != STAGE_CITRAINING) {
netPlayersAllocate();
}
#endif
setCurrentPlayerNum(0); setCurrentPlayerNum(0);
g_Vars.bond = g_Vars.players[g_Vars.bondplayernum]; g_Vars.bond = g_Vars.players[g_Vars.bondplayernum];
@@ -591,7 +612,7 @@ void playermgrAllocatePlayer(s32 index)
g_Vars.players[index]->introanimnum = 0; g_Vars.players[index]->introanimnum = 0;
g_Vars.players[index]->lastsighton = 0; g_Vars.players[index]->lastsighton = 0;
for (i = 0; i < MAX_PLAYERS; i++) { for (i = 0; i < ARRAYCOUNT(g_Vars.players[index]->targetset); i++) {
g_Vars.players[index]->targetset[i] = 0; g_Vars.players[index]->targetset[i] = 0;
} }
@@ -643,6 +664,12 @@ void playermgrAllocatePlayer(s32 index)
g_Vars.players[index]->disguised = false; g_Vars.players[index]->disguised = false;
g_Vars.players[index]->dostartnewlife = false; g_Vars.players[index]->dostartnewlife = false;
#ifndef PLATFORM_N64
g_Vars.players[index]->client = NULL;
g_Vars.players[index]->ucmd = (g_NetMode == NETMODE_SERVER) ? UCMD_FL_FORCEMASK : 0;
g_Vars.players[index]->isremote = false;
#endif
g_Vars.bondvisible = true; g_Vars.bondvisible = true;
g_Vars.bondcollisions = true; g_Vars.bondcollisions = true;
} }
@@ -806,6 +833,14 @@ void playermgrShuffle(void)
g_Vars.playerorder[i] = i; g_Vars.playerorder[i] = i;
} }
#ifndef PLATFORM_N64
if (g_NetMode) {
// don't shuffle in netgames
// why is this a thing anyway?
return;
}
#endif
// Randomly swap numbers with later elements // Randomly swap numbers with later elements
for (i = 0; i < MAX_PLAYERS - 1; i++) { for (i = 0; i < MAX_PLAYERS - 1; i++) {
s32 otherindex = rngRandom() % (MAX_PLAYERS - i); s32 otherindex = rngRandom() % (MAX_PLAYERS - i);
+9 -2
View File
@@ -148,6 +148,12 @@ void playerReset(void)
g_PlayersWithControl[1] = true; g_PlayersWithControl[1] = true;
g_PlayersWithControl[2] = true; g_PlayersWithControl[2] = true;
g_PlayersWithControl[3] = true; g_PlayersWithControl[3] = true;
#if MAX_PLAYERS > 4
g_PlayersWithControl[4] = true;
g_PlayersWithControl[5] = true;
g_PlayersWithControl[6] = true;
g_PlayersWithControl[7] = true;
#endif
g_PlayerInvincible = false; g_PlayerInvincible = false;
playerSetTickMode(TICKMODE_GE_FADEIN); playerSetTickMode(TICKMODE_GE_FADEIN);
@@ -180,7 +186,8 @@ void playerReset(void)
cmd = (struct cmd32 *)((uintptr_t)cmd + 8); cmd = (struct cmd32 *)((uintptr_t)cmd + 8);
break; break;
case INTROCMD_WEAPON: case INTROCMD_WEAPON:
if (cmd->param3 == 0 && g_Vars.currentplayer != g_Vars.anti) { if (cmd->param3 == 0 && PLAYER_IS_NOT_ANTI(g_Vars.currentplayer)) {
modelmgrLoadProjectileModeldefs(cmd->param1); modelmgrLoadProjectileModeldefs(cmd->param1);
if (cmd->param2 >= 0) { if (cmd->param2 >= 0) {
@@ -207,7 +214,7 @@ void playerReset(void)
cmd = (struct cmd32 *)((uintptr_t)cmd + 16); cmd = (struct cmd32 *)((uintptr_t)cmd + 16);
break; break;
case INTROCMD_AMMO: case INTROCMD_AMMO:
if (cmd->param3 == 0 && g_Vars.currentplayer != g_Vars.anti) { if (cmd->param3 == 0 && PLAYER_IS_NOT_ANTI(g_Vars.currentplayer)) {
bgunSetAmmoQuantity(cmd->param1, cmd->param2); bgunSetAmmoQuantity(cmd->param1, cmd->param2);
} }
cmd = (struct cmd32 *)((uintptr_t)cmd + 16); cmd = (struct cmd32 *)((uintptr_t)cmd + 16);
+26 -1
View File
@@ -39,6 +39,10 @@
#include "lib/lib_317f0.h" #include "lib/lib_317f0.h"
#include "data.h" #include "data.h"
#include "types.h" #include "types.h"
#ifndef PLATFORM_N64
#include "net/net.h"
#include "net/netmsg.h"
#endif
s16 *g_RoomPropListChunkIndexes; s16 *g_RoomPropListChunkIndexes;
struct roomproplistchunk *g_RoomPropListChunks; struct roomproplistchunk *g_RoomPropListChunks;
@@ -167,6 +171,10 @@ struct prop *propAllocate(void)
prop->propupdate60err = 2; prop->propupdate60err = 2;
prop->opawallhits = NULL; prop->opawallhits = NULL;
prop->xluwallhits = NULL; prop->xluwallhits = NULL;
#ifndef PLATFORM_N64
// NOTE: this will be automatically overwritten at the start of the stage for the setup props
prop->syncid = (g_NetMode == NETMODE_SERVER) ? g_NetNextSyncId++ : 0;
#endif
g_Vars.propstates[prop->propstateindex].propcount++; g_Vars.propstates[prop->propstateindex].propcount++;
g_Vars.allocstateindex++; g_Vars.allocstateindex++;
@@ -199,6 +207,9 @@ void propFree(struct prop *prop)
prop->prev = NULL; prop->prev = NULL;
prop->chr = NULL; prop->chr = NULL;
prop->rooms[0] = -1; prop->rooms[0] = -1;
#ifndef PLATFORM_N64
prop->syncid = 0;
#endif
g_Vars.freeprops = prop; g_Vars.freeprops = prop;
} }
@@ -1615,6 +1626,13 @@ bool currentPlayerInteract(bool eyespy)
prop = propFindForInteract(eyespy); prop = propFindForInteract(eyespy);
if (prop) { if (prop) {
#ifndef PLATFORM_N64
// if we aren't the authority, don't do anything
if (g_NetMode == NETMODE_CLIENT) {
return false;
}
#endif
switch (prop->type) { switch (prop->type) {
case PROPTYPE_OBJ: case PROPTYPE_OBJ:
case PROPTYPE_WEAPON: case PROPTYPE_WEAPON:
@@ -1633,6 +1651,12 @@ bool currentPlayerInteract(bool eyespy)
propExecuteTickOperation(prop, op); propExecuteTickOperation(prop, op);
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_SERVER) {
netmsgSvcPropUseWrite(&g_NetMsgRel, prop, g_Vars.currentplayer->client, op);
}
#endif
return false; return false;
} }
@@ -2449,7 +2473,8 @@ void propsTestForPickup(void)
if (g_Vars.currentplayer->bondmovemode != MOVEMODE_CUTSCENE if (g_Vars.currentplayer->bondmovemode != MOVEMODE_CUTSCENE
&& !g_PlayerInvincible && !g_PlayerInvincible
&& g_Vars.currentplayer != g_Vars.anti) { && PLAYER_IS_NOT_ANTI(g_Vars.currentplayer)
) {
roomsCopy(g_Vars.currentplayer->prop->rooms, allrooms); roomsCopy(g_Vars.currentplayer->prop->rooms, allrooms);
for (i = 0; g_Vars.currentplayer->prop->rooms[i] != -1; i++) { for (i = 0; g_Vars.currentplayer->prop->rooms[i] != -1; i++) {
+145 -12
View File
@@ -77,6 +77,10 @@
#include "textures.h" #include "textures.h"
#include "types.h" #include "types.h"
#include "string.h" #include "string.h"
#ifndef PLATFORM_N64
#include "net/net.h"
#include "net/netmsg.h"
#endif
void rng2SetSeed(u32 seed); void rng2SetSeed(u32 seed);
@@ -155,6 +159,13 @@ bool doorCallLift(struct prop *doorprop, bool allowclose)
struct doorobj *door = doorprop->door; struct doorobj *door = doorprop->door;
bool handled = false; bool handled = false;
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_CLIENT) {
// don't automatically do anything with lifts
return handled;
}
#endif
if (door->base.hidden & OBJHFLAG_LIFTDOOR) { if (door->base.hidden & OBJHFLAG_LIFTDOOR) {
struct linkliftdoorobj *link = g_LiftDoors; struct linkliftdoorobj *link = g_LiftDoors;
@@ -5094,6 +5105,11 @@ void liftGoToStop(struct liftobj *lift, s32 stopnum)
// Sanity check to make sure lift is actually not moving // Sanity check to make sure lift is actually not moving
if (lift->dist == 0 && lift->speed == 0) { if (lift->dist == 0 && lift->speed == 0) {
lift->levelaim = stopnum; lift->levelaim = stopnum;
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_SERVER) {
netmsgSvcPropLiftWrite(&g_NetMsgRel, lift->base.prop);
}
#endif
return; return;
} }
} }
@@ -5140,6 +5156,12 @@ void liftGoToStop(struct liftobj *lift, s32 stopnum)
lift->speed = -lift->speed; lift->speed = -lift->speed;
lift->levelaim = stopnum; lift->levelaim = stopnum;
} }
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_SERVER) {
netmsgSvcPropLiftWrite(&g_NetMsgRel, lift->base.prop);
}
#endif
} }
} }
@@ -6666,6 +6688,12 @@ s32 projectileTick(struct defaultobj *obj, bool *embedded)
} }
if (projectile->speed.f[0] == 0.0f && projectile->speed.f[2] == 0.0f && projectile->unk0dc == 0.0f) { if (projectile->speed.f[0] == 0.0f && projectile->speed.f[2] == 0.0f && projectile->unk0dc == 0.0f) {
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_SERVER) {
// sliding object has stopped, sync the final position just in case
netmsgSvcPropMoveWrite(&g_NetMsgRel, prop, NULL);
}
#endif
objFreeProjectile(obj); objFreeProjectile(obj);
} }
@@ -8126,6 +8154,13 @@ void liftTick(struct prop *prop)
stop = (stop + 1) % 4; stop = (stop + 1) % 4;
} while (lift->pads[stop] < 0); } while (lift->pads[stop] < 0);
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_CLIENT) {
// don't start if we're not the authority
return;
}
#endif
liftGoToStop(lift, stop); liftGoToStop(lift, stop);
} }
} }
@@ -9128,7 +9163,7 @@ void autogunTickShoot(struct prop *autogunprop)
// (ie. autogun is a Defense autogun or a thrown laptop) // (ie. autogun is a Defense autogun or a thrown laptop)
if (g_Vars.normmplayerisrunning if (g_Vars.normmplayerisrunning
|| (targetprop && (targetprop->type == PROPTYPE_CHR)) || (targetprop && (targetprop->type == PROPTYPE_CHR))
|| (g_Vars.antiplayernum >= 0 && targetprop && targetprop == g_Vars.anti->prop)) { || (g_Vars.antiplayernum >= 0 && targetprop && PROP_IS_FOR_ANTI_PLAYER(targetprop))) {
if (cdExamLos08(&gunpos, gunrooms, &hitpos, CDTYPE_ALL, GEOFLAG_BLOCK_SHOOT) == CDRESULT_COLLISION) { if (cdExamLos08(&gunpos, gunrooms, &hitpos, CDTYPE_ALL, GEOFLAG_BLOCK_SHOOT) == CDRESULT_COLLISION) {
#if VERSION >= VERSION_PAL_FINAL #if VERSION >= VERSION_PAL_FINAL
cdGetPos(&hitpos, 11480, "prop/propobj.c"); cdGetPos(&hitpos, 11480, "prop/propobj.c");
@@ -11005,7 +11040,7 @@ s32 objTickPlayer(struct prop *prop)
if (obj->hidden & OBJHFLAG_ISRETICK) { if (obj->hidden & OBJHFLAG_ISRETICK) {
obj->hidden &= ~OBJHFLAG_ISRETICK; obj->hidden &= ~OBJHFLAG_ISRETICK;
} else if ((obj->hidden & OBJHFLAG_PROJECTILE) && (obj->projectile->flags & PROJECTILEFLAG_SLIDING) == 0) { } else if ((obj->hidden & OBJHFLAG_PROJECTILE) && obj->projectile && (obj->projectile->flags & PROJECTILEFLAG_SLIDING) == 0) {
prop->flags &= ~PROPFLAG_ONTHISSCREENTHISTICK; prop->flags &= ~PROPFLAG_ONTHISSCREENTHISTICK;
obj->hidden |= OBJHFLAG_ISRETICK; obj->hidden |= OBJHFLAG_ISRETICK;
return TICKOP_RETICK; return TICKOP_RETICK;
@@ -14217,6 +14252,12 @@ void objBounce(struct defaultobj *obj, struct coord *gundir2d)
projectile->speed.z += 3.3333333f * dir.z; projectile->speed.z += 3.3333333f * dir.z;
projectile->ownerprop = g_Vars.currentplayer->prop; projectile->ownerprop = g_Vars.currentplayer->prop;
projectile->bouncecount = 1; projectile->bouncecount = 1;
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_SERVER) {
netmsgSvcPropMoveWrite(&g_NetMsgRel, obj->prop, &rot);
}
#endif
} }
} }
@@ -14294,6 +14335,11 @@ void objApplyMomentum(struct defaultobj *obj, struct coord *speed, f32 rotation,
projectile->unk0ec = 0.07852732f; projectile->unk0ec = 0.07852732f;
projectile->unk0f0 = 6.6666665f; projectile->unk0f0 = 6.6666665f;
} }
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_SERVER) {
netmsgSvcPropMoveWrite(&g_NetMsgRel, obj->prop, NULL);
}
#endif
return; return;
} }
@@ -14324,6 +14370,12 @@ void objApplyMomentum(struct defaultobj *obj, struct coord *speed, f32 rotation,
projectile->unk0ec = 0.07852732f; projectile->unk0ec = 0.07852732f;
projectile->unk0f0 = 1.6666666f; projectile->unk0f0 = 1.6666666f;
} }
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_SERVER) {
netmsgSvcPropMoveWrite(&g_NetMsgRel, obj->prop, NULL);
}
#endif
} }
} }
@@ -15363,6 +15415,23 @@ void objTakeGunfire(struct defaultobj *obj, f32 damage, struct coord *pos, s32 w
void objDamage(struct defaultobj *obj, f32 damage, struct coord *pos, s32 weaponnum, s32 playernum) void objDamage(struct defaultobj *obj, f32 damage, struct coord *pos, s32 weaponnum, s32 playernum)
{ {
#ifndef PLATFORM_N64
// if we aren't the authority, don't do anything, unless called from netmsg handler
if (g_NetMode == NETMODE_CLIENT) {
if (damage < 0.f) {
// HACK: negative damage means we were called from netmsg.c
damage = -damage;
} else {
return;
}
} else if (g_NetMode == NETMODE_SERVER) {
if (obj->prop && obj->prop->type != PROPTYPE_CHR) {
// chr damage is handled by a separate message
netmsgSvcPropDamageWrite(&g_NetMsgRel, obj->prop, damage, pos, weaponnum, playernum);
}
}
#endif
// Store the attacker playernum into the object's "hidden" field // Store the attacker playernum into the object's "hidden" field
#if VERSION >= VERSION_NTSC_1_0 #if VERSION >= VERSION_NTSC_1_0
// ...but not for deployed laptop guns in multiplayer, because those bits // ...but not for deployed laptop guns in multiplayer, because those bits
@@ -15893,7 +15962,10 @@ void objHit(struct shotdata *shotdata, struct hit *hit)
} }
} }
if (g_Vars.antiplayernum < 0 || g_Vars.currentplayer != g_Vars.anti || (obj->flags2 & OBJFLAG2_IMMUNETOANTI) == 0) { if (g_Vars.antiplayernum < 0
|| PLAYER_IS_NOT_ANTI(g_Vars.currentplayer)
|| (obj->flags2 & OBJFLAG2_IMMUNETOANTI) == 0) {
if (hit->hitthing.texturenum != 10000) { if (hit->hitthing.texturenum != 10000) {
f32 damage = gsetGetDamage(&shotdata->gset); f32 damage = gsetGetDamage(&shotdata->gset);
@@ -15950,6 +16022,10 @@ void objHit(struct shotdata *shotdata, struct hit *hit)
pushdir.y = shotdata->gundir3d.y; pushdir.y = shotdata->gundir3d.y;
pushdir.z = shotdata->gundir3d.z; pushdir.z = shotdata->gundir3d.z;
#ifndef PLATFORM_N64
// don't push anything if we're not the authority
if (g_NetMode != NETMODE_CLIENT)
#endif
func0f082e84(obj, &spa4, &pushdir, &spb0, true); func0f082e84(obj, &spa4, &pushdir, &spb0, true);
} else { } else {
bool bounce = false; bool bounce = false;
@@ -15972,6 +16048,13 @@ void objHit(struct shotdata *shotdata, struct hit *hit)
bounce = false; bounce = false;
} }
#ifndef PLATFORM_N64
// don't bounce anything if we're not the authority
if (g_NetMode == NETMODE_CLIENT) {
bounce = false;
}
#endif
if (bounce) { if (bounce) {
objBounce(obj, &shotdata->gundir2d); objBounce(obj, &shotdata->gundir2d);
} }
@@ -16830,7 +16913,7 @@ void ammotypePlayPickupSound(u32 ammotype)
case AMMOTYPE_CLOAK: case AMMOTYPE_CLOAK:
case AMMOTYPE_BOOST: case AMMOTYPE_BOOST:
case AMMOTYPE_TOKEN: case AMMOTYPE_TOKEN:
sndStart(var80095200, SFX_PICKUP_AMMO, NULL, -1, -1, -1, -1, -1); playerSndStart(var80095200, SFX_PICKUP_AMMO, NULL, g_Vars.currentplayernum, -1, -1, -1);
break; break;
case AMMOTYPE_REMOTE_MINE: case AMMOTYPE_REMOTE_MINE:
case AMMOTYPE_PROXY_MINE: case AMMOTYPE_PROXY_MINE:
@@ -16839,10 +16922,10 @@ void ammotypePlayPickupSound(u32 ammotype)
case AMMOTYPE_MICROCAMERA: case AMMOTYPE_MICROCAMERA:
case AMMOTYPE_PLASTIQUE: case AMMOTYPE_PLASTIQUE:
case AMMOTYPE_ECM_MINE: case AMMOTYPE_ECM_MINE:
sndStart(var80095200, SFX_PICKUP_MINE, NULL, -1, -1, -1, -1, -1); playerSndStart(var80095200, SFX_PICKUP_MINE, NULL, g_Vars.currentplayernum, -1, -1, -1);
break; break;
case AMMOTYPE_KNIFE: case AMMOTYPE_KNIFE:
sndStart(var80095200, SFX_PICKUP_KNIFE, NULL, -1, -1, -1, -1, -1); playerSndStart(var80095200, SFX_PICKUP_KNIFE, NULL, g_Vars.currentplayernum, -1, -1, -1);
break; break;
} }
} }
@@ -16907,7 +16990,7 @@ void weaponPlayPickupSound(s32 weaponnum)
sound = SFX_PICKUP_GUN; sound = SFX_PICKUP_GUN;
} }
sndStart(var80095200, sound, NULL, -1, -1, -1, -1, -1); playerSndStart(var80095200, sound, NULL, g_Vars.currentplayernum, -1, -1, -1);
} }
void ammotypeGetPickupMessage(char *dst, s32 ammotype, s32 qty) void ammotypeGetPickupMessage(char *dst, s32 ammotype, s32 qty)
@@ -17220,7 +17303,7 @@ s32 propPickupByPlayer(struct prop *prop, bool showhudmsg)
switch (obj->type) { switch (obj->type) {
case OBJTYPE_KEY: case OBJTYPE_KEY:
if (g_Vars.in_cutscene == false) { if (g_Vars.in_cutscene == false) {
sndStart(var80095200, SFX_PICKUP_KEYCARD, NULL, -1, -1, -1, -1, -1); playerSndStart(var80095200, SFX_PICKUP_KEYCARD, NULL, g_Vars.currentplayernum, -1, -1, -1);
} }
if (showhudmsg) { if (showhudmsg) {
@@ -17260,7 +17343,7 @@ s32 propPickupByPlayer(struct prop *prop, bool showhudmsg)
} }
if (g_Vars.in_cutscene == false) { if (g_Vars.in_cutscene == false) {
sndStart(var80095200, SFX_PICKUP_AMMO, NULL, -1, -1, -1, -1, -1); playerSndStart(var80095200, SFX_PICKUP_AMMO, NULL, g_Vars.currentplayernum, -1, -1, -1);
} }
result = TICKOP_FREE; result = TICKOP_FREE;
@@ -17280,6 +17363,11 @@ s32 propPickupByPlayer(struct prop *prop, bool showhudmsg)
if (sp64) { if (sp64) {
weaponPlayPickupSound(weapon->weaponnum); weaponPlayPickupSound(weapon->weaponnum);
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_SERVER && g_Vars.currentplayer->client) {
netmsgSvcPropPickupWrite(&g_NetMsgRel, g_Vars.currentplayer->client, prop, sp64);
}
#endif
} }
return sp64; return sp64;
@@ -17290,6 +17378,11 @@ s32 propPickupByPlayer(struct prop *prop, bool showhudmsg)
if (sp64) { if (sp64) {
weaponPlayPickupSound(weapon->weaponnum); weaponPlayPickupSound(weapon->weaponnum);
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_SERVER && g_Vars.currentplayer->client) {
netmsgSvcPropPickupWrite(&g_NetMsgRel, g_Vars.currentplayer->client, prop, sp64);
}
#endif
} }
return sp64; return sp64;
@@ -17403,7 +17496,7 @@ s32 propPickupByPlayer(struct prop *prop, bool showhudmsg)
playerSetShieldFrac(((struct shieldobj *) prop->obj)->amount); playerSetShieldFrac(((struct shieldobj *) prop->obj)->amount);
if (!g_Vars.in_cutscene) { if (!g_Vars.in_cutscene) {
sndStart(var80095200, SFX_PICKUP_SHIELD, NULL, -1, -1, -1, -1, -1); playerSndStart(var80095200, SFX_PICKUP_SHIELD, NULL, g_Vars.currentplayernum, -1, -1, -1);
} }
if (showhudmsg) { if (showhudmsg) {
@@ -17440,7 +17533,7 @@ s32 propPickupByPlayer(struct prop *prop, bool showhudmsg)
case OBJTYPE_TINTEDGLASS: case OBJTYPE_TINTEDGLASS:
default: default:
if (g_Vars.in_cutscene == false) { if (g_Vars.in_cutscene == false) {
sndStart(var80095200, SFX_PICKUP_KEYCARD, NULL, -1, -1, -1, -1, -1); playerSndStart(var80095200, SFX_PICKUP_KEYCARD, NULL, g_Vars.currentplayernum, -1, -1, -1);
} }
if (showhudmsg) { if (showhudmsg) {
@@ -17457,6 +17550,13 @@ s32 propPickupByPlayer(struct prop *prop, bool showhudmsg)
break; break;
} }
#ifndef PLATFORM_N64
if (result != TICKOP_NONE && g_NetMode == NETMODE_SERVER && g_Vars.currentplayer->client) {
netmsgSvcPropPickupWrite(&g_NetMsgRel, g_Vars.currentplayer->client, prop, result);
netmsgSvcPlayerStatsWrite(&g_NetMsgRel, g_Vars.currentplayer->client);
}
#endif
if (result == TICKOP_FREE && (obj->hidden & OBJHFLAG_TAGGED) == 0) { if (result == TICKOP_FREE && (obj->hidden & OBJHFLAG_TAGGED) == 0) {
objFree(obj, false, obj->hidden2 & OBJH2FLAG_CANREGEN); objFree(obj, false, obj->hidden2 & OBJH2FLAG_CANREGEN);
return TICKOP_FREE; return TICKOP_FREE;
@@ -17481,6 +17581,13 @@ s32 objTestForPickup(struct prop *prop)
return TICKOP_NONE; return TICKOP_NONE;
} }
#ifndef PLATFORM_N64
// if we aren't the authority, don't do anything
if (g_NetMode == NETMODE_CLIENT) {
return TICKOP_NONE;
}
#endif
if (func0f085194(obj) && obj->type != OBJTYPE_HAT) { if (func0f085194(obj) && obj->type != OBJTYPE_HAT) {
if (obj->flags & OBJFLAG_UNCOLLECTABLE) { if (obj->flags & OBJFLAG_UNCOLLECTABLE) {
return TICKOP_NONE; return TICKOP_NONE;
@@ -19066,6 +19173,13 @@ void doorsCheckAutomatic(void)
s16 *propnumptr; s16 *propnumptr;
s16 propnums[256]; s16 propnums[256];
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_CLIENT) {
// don't do anything if we're not the authority
return;
}
#endif
roomGetProps(g_Vars.currentplayer->prop->rooms, propnums, 256); roomGetProps(g_Vars.currentplayer->prop->rooms, propnums, 256);
propnumptr = propnums; propnumptr = propnums;
@@ -19842,6 +19956,11 @@ void doorSetMode(struct doorobj *door, s32 newmode)
} else { } else {
door->mode = newmode; door->mode = newmode;
} }
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_SERVER) {
netmsgSvcPropDoorWrite(&g_NetMsgRel, door->base.prop, g_Vars.currentplayer->client);
}
#endif
} }
/** /**
@@ -20952,7 +21071,7 @@ Gfx *countdownTimerRender(Gfx *gdl)
u32 stack; u32 stack;
s32 viewright = viGetViewLeft() + (viGetViewWidth() >> 1); s32 viewright = viGetViewLeft() + (viGetViewWidth() >> 1);
s32 y = viGetViewTop() + viGetViewHeight() - 18; s32 y = viGetViewTop() + viGetViewHeight() - 18;
s32 playercount = PLAYERCOUNT(); s32 playercount = LOCALPLAYERCOUNT();
char *fmt = ":\n"; char *fmt = ":\n";
if (playercount == 2) { if (playercount == 2) {
@@ -21207,6 +21326,13 @@ void weaponCreateForPlayerDrop(s32 weaponnum)
struct chrdata *chr; struct chrdata *chr;
u32 stack2; u32 stack2;
#ifndef PLATFORM_N64
// don't do anything if we're not the authority
if (g_NetMode == NETMODE_CLIENT) {
return;
}
#endif
chr = g_Vars.currentplayer->prop->chr; chr = g_Vars.currentplayer->prop->chr;
prop = weaponCreateForChr(chr, playermgrGetModelOfWeapon(weaponnum), weaponnum, OBJFLAG_WEAPON_AICANNOTUSE, NULL, NULL); prop = weaponCreateForChr(chr, playermgrGetModelOfWeapon(weaponnum), weaponnum, OBJFLAG_WEAPON_AICANNOTUSE, NULL, NULL);
@@ -21217,6 +21343,13 @@ void weaponCreateForPlayerDrop(s32 weaponnum)
if (weaponnum == WEAPON_BRIEFCASE2) { if (weaponnum == WEAPON_BRIEFCASE2) {
scenarioHandleDroppedToken(chr, prop); scenarioHandleDroppedToken(chr, prop);
} }
#ifndef PLATFORM_N64
if (g_NetMode == NETMODE_SERVER) {
netmsgSvcPropSpawnWrite(&g_NetMsgRel, prop);
netmsgSvcPropMoveWrite(&g_NetMsgRel, prop, NULL);
}
#endif
} }
} }
+10 -5
View File
@@ -338,7 +338,7 @@ void psTickChannel(s32 channelnum)
if (lvIsPaused() if (lvIsPaused()
|| (mpIsPaused() && (channel->flags2 & PSFLAG2_MPPAUSABLE)) || (mpIsPaused() && (channel->flags2 & PSFLAG2_MPPAUSABLE))
|| (mpIsPaused() && PLAYERCOUNT() == 1)) { || (mpIsPaused() && LOCALPLAYERCOUNT() == 1)) {
channel->currentvol = -1; channel->currentvol = -1;
newvol = 0; newvol = 0;
} }
@@ -1171,7 +1171,7 @@ s32 psCalculateVol(struct coord *pos, f32 dist1, f32 dist2, f32 dist3, RoomNum *
} }
// Figure out which player is closest and store their distance in playerdist // Figure out which player is closest and store their distance in playerdist
for (i = 0; i < PLAYERCOUNT(); i++) { for (i = 0; i < LOCALPLAYERCOUNT(); i++) {
struct player *player = g_Vars.players[i]; struct player *player = g_Vars.players[i];
s32 camroom; s32 camroom;
@@ -1283,12 +1283,17 @@ s32 psCalculatePan2(struct coord *pos, s32 arg1, f32 arg2, struct pschannel *cha
s32 degrees; s32 degrees;
f32 f2; f32 f2;
if (PLAYERCOUNT() < 2) { if (LOCALPLAYERCOUNT() < 2) {
struct coord *campos = &g_Vars.currentplayer->cam_pos; #ifdef PLATFORM_N64
struct player *player = g_Vars.currentplayer;
#else
struct player *player = g_Vars.players[0] ? g_Vars.players[0] : g_Vars.currentplayer;
#endif
struct coord *campos = &player->cam_pos;
f32 sp3c; f32 sp3c;
f32 sp38; f32 sp38;
f2 = -(atan2f(pos->x - campos->x, pos->z - campos->z) * 180.0f / M_PI + g_Vars.currentplayer->vv_theta); f2 = -(atan2f(pos->x - campos->x, pos->z - campos->z) * 180.0f / M_PI + player->vv_theta);
if (arg2 >= 0.0f) { if (arg2 >= 0.0f) {
sp3c = sinf(0.017453292f * f2); sp3c = sinf(0.017453292f * f2);
+2 -2
View File
@@ -252,7 +252,7 @@ Gfx *radarRender(Gfx *gdl)
tconfig = g_TexRadarConfigs; tconfig = g_TexRadarConfigs;
playernum = g_Vars.currentplayernum; playernum = g_Vars.currentplayernum;
playercount = PLAYERCOUNT(); playercount = LOCALPLAYERCOUNT();
if (g_Vars.mplayerisrunning) { if (g_Vars.mplayerisrunning) {
if (g_Vars.normmplayerisrunning && (g_MpSetup.options & MPOPTION_NORADAR)) { if (g_Vars.normmplayerisrunning && (g_MpSetup.options & MPOPTION_NORADAR)) {
@@ -341,7 +341,7 @@ Gfx *radarRender(Gfx *gdl)
gDPSetSubpixelOffsetEXT(gdl++, 0, 0); gDPSetSubpixelOffsetEXT(gdl++, 0, 0);
if (!(g_MpSetup.options & MPOPTION_NOPLAYERONRADAR)) { if (!(g_MpSetup.options & MPOPTION_NOPLAYERONRADAR)) {
#endif #endif
for (i = 0; i < playercount; i++) { for (i = 0; i < PLAYERCOUNT(); i++) {
if (i != playernum) { if (i != playernum) {
if (g_Vars.players[i]->isdead == false if (g_Vars.players[i]->isdead == false
&& (g_Vars.players[i]->prop->chr->hidden & CHRHFLAG_CLOAKED) == 0 && (g_Vars.players[i]->prop->chr->hidden & CHRHFLAG_CLOAKED) == 0
+10
View File
@@ -12,7 +12,17 @@ void roomsReset(void)
{ {
s32 i; s32 i;
#if MAX_PLAYERS > 4
if (PLAYERCOUNT() > 4) {
g_RoomMtxNumSlots = 400;
} else if (PLAYERCOUNT() > 2) {
g_RoomMtxNumSlots = 200;
} else {
g_RoomMtxNumSlots = 120;
}
#else
g_RoomMtxNumSlots = PLAYERCOUNT() >= 2 ? 200 : 120; g_RoomMtxNumSlots = PLAYERCOUNT() >= 2 ? 200 : 120;
#endif
g_RoomMtxAges = mempAlloc(ALIGN16(g_RoomMtxNumSlots), MEMPOOL_STAGE); g_RoomMtxAges = mempAlloc(ALIGN16(g_RoomMtxNumSlots), MEMPOOL_STAGE);
g_RoomMtxLinkedRooms = mempAlloc(ALIGN16(g_RoomMtxNumSlots * sizeof(*g_RoomMtxLinkedRooms)), MEMPOOL_STAGE); g_RoomMtxLinkedRooms = mempAlloc(ALIGN16(g_RoomMtxNumSlots * sizeof(*g_RoomMtxLinkedRooms)), MEMPOOL_STAGE);
+1 -1
View File
@@ -2073,7 +2073,7 @@ void setupCreateProps(s32 stagenum)
slotnum = (slotnum + 1) % maxsimulants; slotnum = (slotnum + 1) % maxsimulants;
} }
if ((g_MpSetup.chrslots & (1 << (slotnum + 4))) if ((g_MpSetup.chrslots & (1 << (slotnum + MAX_PLAYERS)))
&& mpIsSimSlotEnabled(slotnum)) { && mpIsSimSlotEnabled(slotnum)) {
botmgrAllocateBot(chrnum, slotnum); botmgrAllocateBot(chrnum, slotnum);
chrnum++; chrnum++;
+3 -3
View File
@@ -519,7 +519,7 @@ Gfx *sightDrawAimer(Gfx *gdl, s32 x, s32 y, s32 radius, s32 cornergap, u32 colou
#endif #endif
// Draw the lines that span most of the viewport // Draw the lines that span most of the viewport
if (PLAYERCOUNT() == 1) { if (LOCALPLAYERCOUNT() == 1) {
gDPHudRectangle(gdl++, viewleft + 48, y, x - radius + 2, y); gDPHudRectangle(gdl++, viewleft + 48, y, x - radius + 2, y);
gDPHudRectangle(gdl++, x + radius - 2, y, viewright - 49, y); gDPHudRectangle(gdl++, x + radius - 2, y, viewright - 49, y);
gDPHudRectangle(gdl++, x, viewtop + 10, x, y - radius + 2); gDPHudRectangle(gdl++, x, viewtop + 10, x, y - radius + 2);
@@ -1323,7 +1323,7 @@ Gfx *sightDrawZoom(Gfx *gdl, bool sighton, f32 crossx, f32 crossy)
cornerheight *= frac; cornerheight *= frac;
} }
if (PLAYERCOUNT() >= 2) { if (LOCALPLAYERCOUNT() >= 2) {
cornerheight *= 2; cornerheight *= 2;
} }
@@ -1625,7 +1625,7 @@ Gfx *sightDraw(Gfx *gdl, bool sighton, s32 sight)
} }
#endif #endif
if (PLAYERCOUNT() >= 2 && g_Vars.coopplayernum < 0 && g_Vars.antiplayernum < 0) { if (LOCALPLAYERCOUNT() >= 2 && g_Vars.coopplayernum < 0 && g_Vars.antiplayernum < 0) {
sight = SIGHT_DEFAULT; sight = SIGHT_DEFAULT;
} }
+4 -4
View File
@@ -53,7 +53,7 @@ void zbufAllocate(void)
if (IS4MB()) { if (IS4MB()) {
g_ZbufWidth = MAX(320, FBALLOC_WIDTH_LO); g_ZbufWidth = MAX(320, FBALLOC_WIDTH_LO);
if (g_Vars.normmplayerisrunning && PLAYERCOUNT() >= 2) { if (g_Vars.normmplayerisrunning && LOCALPLAYERCOUNT() >= 2) {
g_ZbufHeight = MAX(220, FBALLOC_HEIGHT_LO) / 2; g_ZbufHeight = MAX(220, FBALLOC_HEIGHT_LO) / 2;
} else { } else {
g_ZbufHeight = MAX(220, FBALLOC_HEIGHT_LO); g_ZbufHeight = MAX(220, FBALLOC_HEIGHT_LO);
@@ -61,7 +61,7 @@ void zbufAllocate(void)
} else { } else {
g_ZbufWidth = MAX(640, FBALLOC_WIDTH_HI); g_ZbufWidth = MAX(640, FBALLOC_WIDTH_HI);
if (g_Vars.normmplayerisrunning && PLAYERCOUNT() >= 2) { if (g_Vars.normmplayerisrunning && LOCALPLAYERCOUNT() >= 2) {
g_ZbufHeight = MAX(220, FBALLOC_HEIGHT_HI); g_ZbufHeight = MAX(220, FBALLOC_HEIGHT_HI);
} else { } else {
g_ZbufHeight = MAX(220, FBALLOC_HEIGHT_HI); g_ZbufHeight = MAX(220, FBALLOC_HEIGHT_HI);
@@ -101,7 +101,7 @@ Gfx *zbufConfigureRdp(Gfx *gdl)
uintptr_t addr; uintptr_t addr;
if (g_Vars.normmplayerisrunning if (g_Vars.normmplayerisrunning
&& (g_Vars.currentplayernum >= 2 || (PLAYERCOUNT() == 2 && g_Vars.currentplayernum == 1))) { && (g_Vars.currentplayernum >= 2 || (LOCALPLAYERCOUNT() == 2 && g_Vars.currentplayernum == 1))) {
subamount = playerGetFbWidth() * playerGetFbHeight(); subamount = playerGetFbWidth() * playerGetFbHeight();
if (IS4MB() || optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) { if (IS4MB() || optionsGetScreenSplit() == SCREENSPLIT_VERTICAL) {
@@ -136,7 +136,7 @@ Gfx *zbufClear(Gfx *gdl)
gDPSetFillColor(gdl++, 0xfffcfffc); gDPSetFillColor(gdl++, 0xfffcfffc);
gDPSetScissorFrac(gdl++, G_SC_NON_INTERLACE, 0, 0, playerGetFbWidth() * 4.0f, playerGetFbHeight() * 4.0f); gDPSetScissorFrac(gdl++, G_SC_NON_INTERLACE, 0, 0, playerGetFbWidth() * 4.0f, playerGetFbHeight() * 4.0f);
if (PLAYERCOUNT() <= 2) { if (LOCALPLAYERCOUNT() <= 2) {
left = 0; left = 0;
right = playerGetFbWidth() - 1; right = playerGetFbWidth() - 1;
} else if (g_Vars.currentplayernum == 0 || g_Vars.currentplayernum == 2) { } else if (g_Vars.currentplayernum == 0 || g_Vars.currentplayernum == 2) {
+3 -3
View File
@@ -177,7 +177,7 @@ extern struct briefing g_Briefing;
extern struct missionconfig g_MissionConfig; extern struct missionconfig g_MissionConfig;
extern struct menu g_Menus[MAX_PLAYERS]; extern struct menu g_Menus[MAX_PLAYERS];
extern struct menudata g_MenuData; extern struct menudata g_MenuData;
extern struct activemenu g_AmMenus[MAX_PLAYERS]; extern struct activemenu g_AmMenus[MAX_LOCAL_PLAYERS];
extern s32 g_AmIndex; extern s32 g_AmIndex;
extern u32 g_CheatsActiveBank0; extern u32 g_CheatsActiveBank0;
extern u32 g_CheatsActiveBank1; extern u32 g_CheatsActiveBank1;
@@ -196,7 +196,7 @@ extern struct covercandidate *g_CoverCandidates;
extern u16 g_NumSpecialCovers; extern u16 g_NumSpecialCovers;
extern u16 *g_SpecialCoverNums; extern u16 *g_SpecialCoverNums;
extern struct pak g_Paks[5]; extern struct pak g_Paks[5];
extern OSPfs g_Pfses[MAX_PLAYERS]; extern OSPfs g_Pfses[MAX_LOCAL_PLAYERS];
extern u32 g_SkyStageNum; extern u32 g_SkyStageNum;
extern bool g_SkyLightningActive; extern bool g_SkyLightningActive;
extern struct explosion *g_Explosions; extern struct explosion *g_Explosions;
@@ -285,7 +285,7 @@ extern struct chrdata *g_MpAllChrPtrs[MAX_MPCHRS];
extern struct mpchrconfig *g_MpAllChrConfigPtrs[MAX_MPCHRS]; extern struct mpchrconfig *g_MpAllChrConfigPtrs[MAX_MPCHRS];
extern s32 g_MpNumChrs; extern s32 g_MpNumChrs;
extern struct mpbotconfig g_BotConfigsArray[MAX_BOTS]; extern struct mpbotconfig g_BotConfigsArray[MAX_BOTS];
extern u8 g_MpSimulantDifficultiesPerNumPlayers[MAX_BOTS][MAX_PLAYERS]; extern u8 g_MpSimulantDifficultiesPerNumPlayers[MAX_BOTS][MAX_LOCAL_PLAYERS];
extern struct mpplayerconfig g_PlayerConfigsArray[MAX_MPPLAYERCONFIGS]; extern struct mpplayerconfig g_PlayerConfigsArray[MAX_MPPLAYERCONFIGS];
extern u8 g_AmBotCommands[9]; extern u8 g_AmBotCommands[9];
extern struct mpsetup g_MpSetup; extern struct mpsetup g_MpSetup;
+35 -3
View File
@@ -20,14 +20,21 @@
#define MAX_CHRWAYPOINTS 6 #define MAX_CHRWAYPOINTS 6
#define MAX_EXPLOSIONS 6 #define MAX_EXPLOSIONS 6
#define MAX_EYESPYDARTS 8 #define MAX_EYESPYDARTS 8
#ifdef PLATFORM_N64
#define MAX_COOPCHRS 2
#else
#define MAX_COOPCHRS MAX_PLAYERS
#endif
#define MAX_MPCHRS (MAX_PLAYERS + MAX_BOTS) #define MAX_MPCHRS (MAX_PLAYERS + MAX_BOTS)
#define MAX_MPPLAYERCONFIGS (MAX_PLAYERS + 2) #define MAX_MPPLAYERCONFIGS (MAX_PLAYERS + MAX_COOPCHRS)
#define MAX_OBJECTIVES 10 #define MAX_OBJECTIVES 10
#define MAX_PLAYERS 4 #define MAX_LOCAL_PLAYERS 4
#define MAX_PLAYERS 8
#define MAX_PROPSPERROOMCHUNK 7 #define MAX_PROPSPERROOMCHUNK 7
#define MAX_ROOMPROPLISTCHUNKS 256 #define MAX_ROOMPROPLISTCHUNKS 256
#define MAX_SQUADRONS 16 #define MAX_SQUADRONS 16
#define MAX_TEAMS 8 #define MAX_TEAMS 8
#define MAX_PLAYERNAME 15
#define NUM_BOTDIFFS 6 #define NUM_BOTDIFFS 6
#define NUM_CYCLEABLE_WEAPONS 45 #define NUM_CYCLEABLE_WEAPONS 45
@@ -68,7 +75,9 @@
#define SECSTOTIME60(secs) (secs * 60) #define SECSTOTIME60(secs) (secs * 60)
#define PFS(device) (device == SAVEDEVICE_GAMEPAK ? NULL : &g_Pfses[device]) #define PFS(device) (device == SAVEDEVICE_GAMEPAK ? NULL : &g_Pfses[device])
#if MAX_PLAYERS >= 4 #if MAX_PLAYERS > 4
#define PLAYERCOUNT() playerGetCount()
#elif MAX_PLAYERS == 4
#define PLAYERCOUNT() ((g_Vars.players[0] ? 1 : 0) + (g_Vars.players[1] ? 1 : 0) + (g_Vars.players[2] ? 1 : 0) + (g_Vars.players[3] ? 1 : 0)) #define PLAYERCOUNT() ((g_Vars.players[0] ? 1 : 0) + (g_Vars.players[1] ? 1 : 0) + (g_Vars.players[2] ? 1 : 0) + (g_Vars.players[3] ? 1 : 0))
#elif MAX_PLAYERS >= 3 #elif MAX_PLAYERS >= 3
#define PLAYERCOUNT() ((g_Vars.players[0] ? 1 : 0) + (g_Vars.players[1] ? 1 : 0) + (g_Vars.players[2] ? 1 : 0)) #define PLAYERCOUNT() ((g_Vars.players[0] ? 1 : 0) + (g_Vars.players[1] ? 1 : 0) + (g_Vars.players[2] ? 1 : 0))
@@ -78,6 +87,20 @@
#define PLAYERCOUNT() 1 #define PLAYERCOUNT() 1
#endif #endif
#if MAX_COOPCHRS > 2
#define PLAYER_IS_ANTI(plr) (g_Vars.antiplayernum >= 0 && (plr) != g_Vars.bond)
#define PLAYER_IS_NOT_ANTI(plr) (g_Vars.antiplayernum < 0 || (plr) == g_Vars.bond)
#define PLAYERNUM_IS_ANTI(plrnum) (g_Vars.antiplayernum >= 0 && (plrnum) != g_Vars.bondplayernum)
#define PROP_IS_FOR_ANTI_PLAYER(plrprop) (g_Vars.antiplayernum >= 0 && g_Vars.anti && (plrprop)->type == PROPTYPE_PLAYER && (plrprop) != g_Vars.bond->prop)
#define EXPLOSION_OWNER_IS_ANTI_PLAYER(expowner) (g_Vars.antiplayernum >= 0 && (expowner) != g_Vars.bondplayernum && mpGetChrFromPlayerIndex((expowner)) != NULL)
#else
#define PLAYER_IS_ANTI(plr) ((plr) == g_Vars.anti)
#define PLAYER_IS_NOT_ANTI(plr) ((plr) != g_Vars.anti)
//define PLAYERNUM_IS_ANTI(plrnum) ((plrnum) == g_Vars.antiplayernum)
#define PROP_IS_FOR_ANTI_PLAYER(plrprop) ((plrprop) == g_Vars.anti->prop)
#define EXPLOSION_OWNER_IS_ANTI_PLAYER(expowner) ((expowner) == g_Vars.antiplayernum)
#endif
#define VALIDWEAPON() (g_Vars.currentplayer->gunctrl.weaponnum >= WEAPON_UNARMED && g_Vars.currentplayer->gunctrl.weaponnum <= WEAPON_COMBATBOOST) #define VALIDWEAPON() (g_Vars.currentplayer->gunctrl.weaponnum >= WEAPON_UNARMED && g_Vars.currentplayer->gunctrl.weaponnum <= WEAPON_COMBATBOOST)
#define FUNCISSEC() (VALIDWEAPON() && (g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].gunfuncs[(g_Vars.currentplayer->gunctrl.weaponnum - 1) >> 3] & (1 << ((g_Vars.currentplayer->gunctrl.weaponnum - 1) & 7)))) #define FUNCISSEC() (VALIDWEAPON() && (g_PlayerConfigsArray[g_Vars.currentplayerstats->mpindex].gunfuncs[(g_Vars.currentplayer->gunctrl.weaponnum - 1) >> 3] & (1 << ((g_Vars.currentplayer->gunctrl.weaponnum - 1) & 7))))
@@ -697,6 +720,7 @@
#define CONTROLMODE_23 6 #define CONTROLMODE_23 6
#define CONTROLMODE_24 7 #define CONTROLMODE_24 7
#define CONTROLMODE_PC 8 // "pc port" controls; enabled in the .ini file #define CONTROLMODE_PC 8 // "pc port" controls; enabled in the .ini file
#define CONTROLMODE_NA 9 // dummy controls for remote players
#define COUNTDOWNTIMERREASON_AI 0x01 #define COUNTDOWNTIMERREASON_AI 0x01
#define COUNTDOWNTIMERREASON_NOCONTROL 0x10 #define COUNTDOWNTIMERREASON_NOCONTROL 0x10
@@ -4716,6 +4740,8 @@ enum weaponnum {
#define BUTTON_UI_ACCEPT BUTTON_ACCEPT_WPNFORWARD #define BUTTON_UI_ACCEPT BUTTON_ACCEPT_WPNFORWARD
#define BUTTON_UI_CANCEL BUTTON_CANCEL_USE #define BUTTON_UI_CANCEL BUTTON_CANCEL_USE
#define LOCALPLAYERCOUNT() PLAYERCOUNT()
#else #else
// xbla behavior // xbla behavior
@@ -4760,6 +4786,12 @@ enum weaponnum {
#define MPSETUP_MAXNAME 17 #define MPSETUP_MAXNAME 17
#define MPSETUP_BLOCKSIZE 80 #define MPSETUP_BLOCKSIZE 80
#define NETMODE_NONE 0
#define NETMODE_SERVER 1
#define NETMODE_CLIENT 2
#define LOCALPLAYERCOUNT() playerGetLocalCount()
#endif #endif
#endif #endif
+12 -4
View File
@@ -15,6 +15,7 @@
#define bool s32 #define bool s32
#define ubool u32 #define ubool u32
extern s32 g_StageNum;
extern u8 *g_StackLeftAddrs[NUM_THREADS]; extern u8 *g_StackLeftAddrs[NUM_THREADS];
extern u8 *g_StackRightAddrs[NUM_THREADS]; extern u8 *g_StackRightAddrs[NUM_THREADS];
extern u8 *g_StackAllocatedPos; extern u8 *g_StackAllocatedPos;
@@ -303,7 +304,7 @@ extern struct menudialogdef g_MpConfirmChallenge4MbMenuDialog;
extern struct menudialogdef g_MainMenu4MbMenuDialog; extern struct menudialogdef g_MainMenu4MbMenuDialog;
extern struct menudialogdef g_MpEditSimulant4MbMenuDialog; extern struct menudialogdef g_MpEditSimulant4MbMenuDialog;
extern struct menudialogdef g_AdvancedSetup4MbMenuDialog; extern struct menudialogdef g_AdvancedSetup4MbMenuDialog;
extern struct filelist *g_FileLists[MAX_PLAYERS]; extern struct filelist *g_FileLists[MAX_LOCAL_PLAYERS];
extern bool var80075bd0[]; extern bool var80075bd0[];
extern struct headanim g_HeadAnims[2]; extern struct headanim g_HeadAnims[2];
extern s32 var80075d60; extern s32 var80075d60;
@@ -512,6 +513,8 @@ extern u8 g_ChrBioSlot;
extern u8 g_HangarBioSlot; extern u8 g_HangarBioSlot;
extern u8 g_DtSlot; extern u8 g_DtSlot;
extern u8 var80088bb4; extern u8 var80088bb4;
extern u64 g_RngSeed;
extern u64 g_Rng2Seed;
extern struct vtxstoretype g_VtxstoreTypes[4]; extern struct vtxstoretype g_VtxstoreTypes[4];
extern struct menudialogdef g_FrWeaponListMenuDialog; extern struct menudialogdef g_FrWeaponListMenuDialog;
extern struct menudialogdef g_FrTrainingInfoInGameMenuDialog; extern struct menudialogdef g_FrTrainingInfoInGameMenuDialog;
@@ -531,7 +534,7 @@ extern struct menudialogdef g_HangarListMenuDialog;
#ifndef PLATFORM_N64 #ifndef PLATFORM_N64
extern struct extplayerconfig g_PlayerExtCfg[MAX_PLAYERS]; extern struct extplayerconfig g_PlayerExtCfg[MAX_LOCAL_PLAYERS];
extern struct weathercfg g_WeatherConfig[WEATHERCFG_MAX_STAGES]; extern struct weathercfg g_WeatherConfig[WEATHERCFG_MAX_STAGES];
extern const struct weathercfg g_DefaultWeatherConfig; extern const struct weathercfg g_DefaultWeatherConfig;
@@ -565,11 +568,16 @@ extern s32 g_MpWeaponRandomFilterNum;
extern struct mpsetupfile g_MpSetupFile; extern struct mpsetupfile g_MpSetupFile;
extern s16 g_MpCurrentSetup; extern s16 g_MpCurrentSetup;
extern s32 g_NetMode;
#define PLAYER_EXTCFG() g_PlayerExtCfg[g_Vars.currentplayerstats->mpindex & 3] #define PLAYER_EXTCFG() g_PlayerExtCfg[g_Vars.currentplayerstats->mpindex & 3]
#define PLAYER_DEFAULT_FOV (PLAYER_EXTCFG().fovy) #define PLAYER_DEFAULT_FOV playerGetDefaultFovY(g_Vars.currentplayerstats->mpindex)
#define ADJUST_ZOOM_FOV(x) ((x) * playerGetZoomFovMult(g_Vars.currentplayerstats->mpindex))
#define TEX_FILTER_2D g_TexFilter2D #define TEX_FILTER_2D g_TexFilter2D
#define ADJUST_ZOOM_FOV(x) ((x) * PLAYER_EXTCFG().fovzoommult)
s32 playerGetCount(void);
s32 playerGetLocalCount(void);
#else // PLATFORM_N64 #else // PLATFORM_N64
+1 -1
View File
@@ -76,7 +76,7 @@ struct modeldef *bgunGetCartModeldef(void);
void bgun0f09ebcc(struct defaultobj *obj, struct coord *coord, RoomNum *rooms, Mtxf *matrix1, struct coord *velocity, Mtxf *matrix2, struct prop *prop, struct coord *pos); void bgun0f09ebcc(struct defaultobj *obj, struct coord *coord, RoomNum *rooms, Mtxf *matrix1, struct coord *velocity, Mtxf *matrix2, struct prop *prop, struct coord *pos);
void bgun0f09ed2c(struct defaultobj *obj, struct coord *coord, Mtxf *arg2, struct coord *velocity, Mtxf *arg4); void bgun0f09ed2c(struct defaultobj *obj, struct coord *coord, Mtxf *arg2, struct coord *velocity, Mtxf *arg4);
struct defaultobj *bgunCreateThrownProjectile2(struct chrdata *chr, struct gset *gset, struct coord *pos, RoomNum *rooms, Mtxf *arg4, struct coord *velocity); struct defaultobj *bgunCreateThrownProjectile2(struct chrdata *chr, struct gset *gset, struct coord *pos, RoomNum *rooms, Mtxf *arg4, struct coord *velocity);
void bgunCreateThrownProjectile(s32 handnum, struct gset *gset); struct defaultobj *bgunCreateThrownProjectile(s32 handnum, struct gset *gset);
void bgunUpdateHeldRocket(s32 handnum); void bgunUpdateHeldRocket(s32 handnum);
void bgunCreateHeldRocket(s32 handnum, struct weaponfunc_shootprojectile *func); void bgunCreateHeldRocket(s32 handnum, struct weaponfunc_shootprojectile *func);
void bgunFreeHeldRocket(s32 handnum); void bgunFreeHeldRocket(s32 handnum);
+1
View File
@@ -203,6 +203,7 @@ bool chrAdjustPosForSpawn(f32 chrradius, struct coord *pos, RoomNum *rooms, f32
struct prop *chrSpawnAtCoord(s32 body, s32 head, struct coord *pos, RoomNum *room, f32 angle, u8 *ailist, u32 spawnflags); struct prop *chrSpawnAtCoord(s32 body, s32 head, struct coord *pos, RoomNum *room, f32 angle, u8 *ailist, u32 spawnflags);
bool chrIsPropPresetBlockingSightToTarget(struct chrdata *chr); bool chrIsPropPresetBlockingSightToTarget(struct chrdata *chr);
bool chrSetPos(struct chrdata *chr, struct coord *pos, RoomNum *rooms, f32 angle, bool findground);
bool chrMoveToPos(struct chrdata *chr, struct coord *pos, RoomNum *room, f32 angle, bool ignorebg); bool chrMoveToPos(struct chrdata *chr, struct coord *pos, RoomNum *room, f32 angle, bool ignorebg);
bool chrCheckCoverOutOfSight(struct chrdata *chr, s32 covernum, bool soft); bool chrCheckCoverOutOfSight(struct chrdata *chr, s32 covernum, bool soft);
s32 chrAssignCoverByCriteria(struct chrdata *chr, u16 arg1, s32 arg2); s32 chrAssignCoverByCriteria(struct chrdata *chr, u16 arg1, s32 arg2);
+11
View File
@@ -107,5 +107,16 @@ void playerSetCamPropertiesWithRoom(struct coord *pos, struct coord *up, struct
void playerSetCamPropertiesWithoutRoom(struct coord *pos, struct coord *up, struct coord *look, s32 room); void playerSetCamPropertiesWithoutRoom(struct coord *pos, struct coord *up, struct coord *look, s32 room);
void playerSetCamProperties(struct coord *pos, struct coord *up, struct coord *look, s32 room); void playerSetCamProperties(struct coord *pos, struct coord *up, struct coord *look, s32 room);
void playerClearMemCamRoom(void); void playerClearMemCamRoom(void);
struct sndstate *playerSndStart(s32 arg0, s16 sound, struct sndstate **handle, s32 playernum, f32 pitch, s32 fxbus, s32 fxmix);
#if MAX_PLAYERS > 4
s32 playerGetCount(void);
s32 playerGetLocalCount(void);
#endif
#ifndef PLATFORM_N64
f32 playerGetDefaultFovY(s32 playernum);
f32 playerGetZoomFovMult(s32 playernum);
#endif
#endif #endif
+21 -6
View File
@@ -230,7 +230,7 @@ struct g_vars {
/*0x488*/ s32 totalkills; /*0x488*/ s32 totalkills;
/*0x48c*/ bool useperimshoot; /*0x48c*/ bool useperimshoot;
/*0x490*/ s32 mpsetupmenu; /*0x490*/ s32 mpsetupmenu;
/*0x494*/ s8 waitingtojoin[MAX_PLAYERS]; /*0x494*/ s8 waitingtojoin[MAX_LOCAL_PLAYERS];
/*0x498*/ s32 unk000498; /*0x498*/ s32 unk000498;
/*0x49c*/ bool usingadvsetup; /*0x49c*/ bool usingadvsetup;
/*0x4a0*/ s32 unk0004a0; /*0x4a0*/ s32 unk0004a0;
@@ -251,7 +251,7 @@ struct g_vars {
/*0x4d6*/ s8 autocutfinished; // true if cutscene reached natural end /*0x4d6*/ s8 autocutfinished; // true if cutscene reached natural end
/*0x4d7*/ s8 autocutgroupskip; // true if pressed start during auto cutscene /*0x4d7*/ s8 autocutgroupskip; // true if pressed start during auto cutscene
/*0x4d8*/ s32 joydisableframestogo; /*0x4d8*/ s32 joydisableframestogo;
/*0x4dc*/ u8 playertojoymap[MAX_PLAYERS]; /*0x4dc*/ u8 playertojoymap[MAX_LOCAL_PLAYERS];
/*0x4e0*/ u8 fourmeg2player; /*0x4e0*/ u8 fourmeg2player;
/*0x4e1*/ u8 remakewallhitvtx; /*0x4e1*/ u8 remakewallhitvtx;
/*0x4e2*/ u8 cutsceneskip60ths; /*0x4e2*/ u8 cutsceneskip60ths;
@@ -324,6 +324,9 @@ struct prop {
/*0x3f*/ u8 active : 1; /*0x3f*/ u8 active : 1;
/*0x40*/ struct wallhit *opawallhits; // opaque /*0x40*/ struct wallhit *opawallhits; // opaque
/*0x44*/ struct wallhit *xluwallhits; // translucent /*0x44*/ struct wallhit *xluwallhits; // translucent
#ifndef PLATFORM_N64
/*0x48*/ u32 syncid;
#endif
}; };
struct packedpad { struct packedpad {
@@ -2820,6 +2823,9 @@ struct player {
/*0x1c72*/ s16 amdowntime; // for alt-modes, used like invdowntime and amdowntime /*0x1c72*/ s16 amdowntime; // for alt-modes, used like invdowntime and amdowntime
#ifndef PLATFORM_N64 #ifndef PLATFORM_N64
/*0x1c74*/ f32 swivelpos[2]; /*0x1c74*/ f32 swivelpos[2];
/*0x1c84*/ u32 ucmd;
/*0x1c88*/ bool isremote;
/*0x1c8c*/ struct netclient *client;
#endif #endif
}; };
@@ -4008,7 +4014,7 @@ struct gamefile {
}; };
struct mpchrconfig { struct mpchrconfig {
/*0x00*/ char name[15]; /*0x00*/ char name[MAX_PLAYERNAME];
/*0x0f*/ u8 mpheadnum; /*0x0f*/ u8 mpheadnum;
/*0x10*/ u8 mpbodynum; /*0x10*/ u8 mpbodynum;
/*0x11*/ u8 team; /*0x11*/ u8 team;
@@ -4052,6 +4058,9 @@ struct mpplayerconfig {
/*0x96*/ u8 newtitle; /*0x96*/ u8 newtitle;
/*0x97*/ u8 gunfuncs[6]; /*0x97*/ u8 gunfuncs[6];
/*0x9d*/ u8 handicap; /*0x9d*/ u8 handicap;
#ifndef PLATFORM_N64
/*0x9e*/ struct netclient *client;
#endif
}; };
struct mpbotconfig { struct mpbotconfig {
@@ -4093,9 +4102,15 @@ struct mpsetup {
/** /**
* Each bit signifies that a player or sim is participating. * Each bit signifies that a player or sim is participating.
* *
* In the original game:
* Bits 0x000f are for players * Bits 0x000f are for players
* Bits 0x0ff0 are for sims * Bits 0x0ff0 are for sims
* Bits 0xf000 are probably not used * Bits 0xf000 are probably not used
*
* In the PC port:
* Bits 0x00ff are for players
* Bits 0xff00 are for sims
* Externally loaded MP setups get automatically converted to this format.
*/ */
/*0x800acb9e*/ u16 chrslots; /*0x800acb9e*/ u16 chrslots;
/*0x800acba0*/ u8 weapons[NUM_MPWEAPONSLOTS]; /*0x800acba0*/ u8 weapons[NUM_MPWEAPONSLOTS];
@@ -4159,7 +4174,7 @@ struct challenge {
// Same structure as availability, however each byte determines how many // Same structure as availability, however each byte determines how many
// players it was completed with. So completions[0] is for completions with // players it was completed with. So completions[0] is for completions with
// a single player and completions[3] is for completions with 4 players. // a single player and completions[3] is for completions with 4 players.
/*0x05*/ u8 completions[MAX_PLAYERS]; /*0x05*/ u8 completions[MAX_LOCAL_PLAYERS];
// Array of features which will become unlocked once the challenge is // Array of features which will become unlocked once the challenge is
// available. The array is automatically populated at runtime based on what // available. The array is automatically populated at runtime based on what
@@ -4791,7 +4806,7 @@ struct menudata {
/*0x014*/ u8 bg; /*0x014*/ u8 bg;
/*0x015*/ u8 nextbg; /*0x015*/ u8 nextbg;
/*0x016*/ u8 screenshottimer; /*0x016*/ u8 screenshottimer;
/*0x017*/ u8 playerjoinalpha[MAX_PLAYERS]; /*0x017*/ u8 playerjoinalpha[MAX_LOCAL_PLAYERS];
/*0x01b*/ s8 bannernum; /*0x01b*/ s8 bannernum;
/*0x01c*/ struct menumodel hudpiece; /*0x01c*/ struct menumodel hudpiece;
/*0x5d4*/ u8 unk5d4; /*0x5d4*/ u8 unk5d4;
@@ -5011,7 +5026,7 @@ struct mpconfigsim {
u8 mpheadnum; u8 mpheadnum;
u8 mpbodynum; u8 mpbodynum;
u8 team; u8 team;
u8 difficulties[MAX_PLAYERS]; u8 difficulties[MAX_LOCAL_PLAYERS];
}; };
struct mpconfig { struct mpconfig {
+10 -10
View File
@@ -205,7 +205,7 @@ void viReset(s32 stagenum)
? FBALLOC_WIDTH_LO * FBALLOC_HEIGHT_LO * NUM_FRAMEBUFFERS ? FBALLOC_WIDTH_LO * FBALLOC_HEIGHT_LO * NUM_FRAMEBUFFERS
: FBALLOC_WIDTH_HI * FBALLOC_HEIGHT_HI * NUM_FRAMEBUFFERS; : FBALLOC_WIDTH_HI * FBALLOC_HEIGHT_HI * NUM_FRAMEBUFFERS;
if (IS4MB() && PLAYERCOUNT() == 2) { if (IS4MB() && LOCALPLAYERCOUNT() == 2) {
// 4MB 2-player: The viewports are 110px tall // 4MB 2-player: The viewports are 110px tall
#if VERSION >= VERSION_NTSC_1_0 #if VERSION >= VERSION_NTSC_1_0
fbsize = FBALLOC_WIDTH_LO * (FBALLOC_HEIGHT_LO / 2) * NUM_FRAMEBUFFERS; fbsize = FBALLOC_WIDTH_LO * (FBALLOC_HEIGHT_LO / 2) * NUM_FRAMEBUFFERS;
@@ -213,7 +213,7 @@ void viReset(s32 stagenum)
fbsize = SCREEN_320 * (SCREEN_240 / 2) * NUM_FRAMEBUFFERS; fbsize = SCREEN_320 * (SCREEN_240 / 2) * NUM_FRAMEBUFFERS;
#endif #endif
g_Vars.fourmeg2player = true; g_Vars.fourmeg2player = true;
} else if ((g_Vars.coopplayernum >= 0 || g_Vars.antiplayernum >= 0) && PLAYERCOUNT() == 2) { } else if ((g_Vars.coopplayernum >= 0 || g_Vars.antiplayernum >= 0) && LOCALPLAYERCOUNT() == 2) {
// PAL is using its correct size // PAL is using its correct size
fbsize = SCREEN_WIDTH_LO * SCREEN_HEIGHT_LO * NUM_FRAMEBUFFERS; fbsize = SCREEN_WIDTH_LO * SCREEN_HEIGHT_LO * NUM_FRAMEBUFFERS;
} }
@@ -681,11 +681,11 @@ Gfx *viRenderViewportEdges(Gfx *gdl)
gDPSetFillColor(gdl++, GPACK_RGBA5551(0, 0, 0, 1) << 16 | GPACK_RGBA5551(0, 0, 0, 1)); gDPSetFillColor(gdl++, GPACK_RGBA5551(0, 0, 0, 1) << 16 | GPACK_RGBA5551(0, 0, 0, 1));
#if VERSION >= VERSION_NTSC_1_0 #if VERSION >= VERSION_NTSC_1_0
if (PLAYERCOUNT() == 1 if (LOCALPLAYERCOUNT() == 1
|| ((g_Vars.coopplayernum >= 0 || g_Vars.antiplayernum >= 0) || ((g_Vars.coopplayernum >= 0 || g_Vars.antiplayernum >= 0)
&& playerHasSharedViewport() && g_Vars.currentplayernum == 0)) && playerHasSharedViewport() && g_Vars.currentplayernum == 0))
#else #else
if (PLAYERCOUNT() == 1 if (LOCALPLAYERCOUNT() == 1
|| ((g_Vars.coopplayernum >= 0 || g_Vars.antiplayernum >= 0) || ((g_Vars.coopplayernum >= 0 || g_Vars.antiplayernum >= 0)
&& ( && (
(g_InCutscene && !g_MainIsEndscreen) || menuGetRoot() == MENUROOT_COOPCONTINUE (g_InCutscene && !g_MainIsEndscreen) || menuGetRoot() == MENUROOT_COOPCONTINUE
@@ -712,10 +712,10 @@ Gfx *viRenderViewportEdges(Gfx *gdl)
s32 bottomplayernum = 0; s32 bottomplayernum = 0;
s32 tmpplayernum = 0; s32 tmpplayernum = 0;
if (PLAYERCOUNT() == 2) { if (LOCALPLAYERCOUNT() == 2) {
bottomplayernum = 1; bottomplayernum = 1;
tmpplayernum = 1; tmpplayernum = 1;
} else if (PLAYERCOUNT() >= 3) { } else if (LOCALPLAYERCOUNT() >= 3) {
bottomplayernum = 2; bottomplayernum = 2;
tmpplayernum = 2; tmpplayernum = 2;
} }
@@ -740,9 +740,9 @@ Gfx *viRenderViewportEdges(Gfx *gdl)
viGetWidth() - 1, g_Vars.players[tmpplayernum]->viewtop - 1); viGetWidth() - 1, g_Vars.players[tmpplayernum]->viewtop - 1);
gDPPipeSync(gdl++); gDPPipeSync(gdl++);
if (PLAYERCOUNT() >= 3 || if (LOCALPLAYERCOUNT() >= 3 ||
(PLAYERCOUNT() == 2 && (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL || g_Vars.fourmeg2player))) { (LOCALPLAYERCOUNT() == 2 && (optionsGetScreenSplit() == SCREENSPLIT_VERTICAL || g_Vars.fourmeg2player))) {
if (PLAYERCOUNT() == 2) { if (LOCALPLAYERCOUNT() == 2) {
tmpplayernum = 0; tmpplayernum = 0;
} }
@@ -753,7 +753,7 @@ Gfx *viRenderViewportEdges(Gfx *gdl)
gDPPipeSync(gdl++); gDPPipeSync(gdl++);
} }
if (PLAYERCOUNT() == 3) { if (LOCALPLAYERCOUNT() == 3) {
// Blank square in P4 spot // Blank square in P4 spot
gDPFillRectangle(gdl++, gDPFillRectangle(gdl++,
g_Vars.players[tmpplayernum]->viewleft + g_Vars.players[tmpplayernum]->viewwidth + 1, g_Vars.players[tmpplayernum]->viewtop, g_Vars.players[tmpplayernum]->viewleft + g_Vars.players[tmpplayernum]->viewwidth + 1, g_Vars.players[tmpplayernum]->viewtop,
+106
View File
@@ -0,0 +1,106 @@
#!/usr/bin/env python3
# simple client for server status queries
import sys, os, socket, struct, selectors
DEFAULT_PORT = 27100
QUERY_MAGIC = b"PDQM\x01"
MAX_WAIT = 5.0
def checksum(data):
crc = 0xFFFF
for b in data[:-2]:
x = crc >> 8 ^ b
x ^= x >> 4
crc += (crc << 8) ^ (x << 12) ^ (x << 5) ^ x
crc &= 0xFFFF
return crc
def eat_string(data):
strlen = struct.unpack_from("<H", data)[0]
strdata = data[2:strlen + 2]
return strdata[:-1].decode(encoding='utf-8'), data[2 + strlen:]
if len(sys.argv) < 2:
print("usage: query <address>[:<port>]")
sys.exit(1)
addrstr = sys.argv[1].strip()
host = addrstr
port = None
if addrstr.startswith('[') and ("]:" in addrstr):
# [ipv6]:port
host, sep, port = addrstr.rpartition(':')
elif addrstr.count(':') == 1:
# possibly ipv4:port or hostname:port
host, sep, port = addrstr.rpartition(':')
host = host.strip('[]')
if port != None:
port = int(port)
else:
port = DEFAULT_PORT
sockfam = socket.AF_INET
if ':' in host:
sockfam = socket.AF_INET6
sel = selectors.DefaultSelector()
sock = socket.socket(sockfam, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, True)
sock.settimeout(MAX_WAIT)
sel.register(sock, selectors.EVENT_READ, None)
# send query magic to server(s)
sock.sendto(QUERY_MAGIC, (host, port))
while True:
# wait for response
events = sel.select(1.0) # timeout in seconds
if not events:
break
for (key, mask) in events:
data, from_addr = sock.recvfrom(256)
# check magic
if data[:5] != QUERY_MAGIC:
print("invalid magic: expected", QUERY_MAGIC, "got", data[:5])
sys.exit(1)
# check checksum
chkremote = struct.unpack("<H", data[-2:])[0]
chklocal = checksum(data)
if chkremote != chklocal:
print("invalid checksum: expected", chklocal, "got", chkremote)
sys.exit(1)
# check size
datalen = struct.unpack("<H", data[5:7])[0]
if datalen > len(data):
print("invalid size: expected", len(data), "got", datalen)
sys.exit(1)
data = data[7:datalen - 2]
# unpack fixed size part of the response
msgdata = struct.unpack_from("<LBBBBB", data)
# unpack strings from the end of the response
hostname, data = eat_string(data[9:])
romname, data = eat_string(data)
moddir, data = eat_string(data)
print("address:", from_addr)
print("protocol ver:", msgdata[0])
print("in progress:", msgdata[1])
print("clients: {0}/{1}".format(msgdata[2], msgdata[3]))
print("stage num:", hex(msgdata[4]))
print("scenario:", msgdata[5])
print("host name:", hostname)
print("rom name:", romname)
print("mod dir:", moddir)
print("-"*40)