mirror of
https://github.com/flyinghead/flycast.git
synced 2026-11-11 01:51:38 -10:00
Support for satellite nodes (vonot, club kart) Start network game when known max of nodes is reached. Add Start Now button to network sync wait window. Ignore MultiboardSlaves option if not active when loading eeprom. Rely on game id instead.
107 lines
2.4 KiB
C++
107 lines
2.4 KiB
C++
/*
|
|
Copyright 2021 flyinghead
|
|
|
|
This file is part of Flycast.
|
|
|
|
Flycast is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation, either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
Flycast is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with Flycast. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
#include "net_handshake.h"
|
|
#include "cfg/option.h"
|
|
#include "ggpo.h"
|
|
#include "naomi_network.h"
|
|
//#include "net_serial_maxspeed.h"
|
|
#include "null_modem.h"
|
|
#include "hw/naomi/naomi_flashrom.h"
|
|
|
|
NetworkHandshake *NetworkHandshake::instance;
|
|
|
|
class GGPONetworkHandshake : public NetworkHandshake
|
|
{
|
|
public:
|
|
std::future<bool> start() override {
|
|
return ggpo::startNetwork();
|
|
}
|
|
|
|
void stop() override {
|
|
ggpo::stopSession();
|
|
}
|
|
|
|
bool canStartNow() override { return false; }
|
|
void startNow() override {}
|
|
};
|
|
|
|
class NaomiNetworkHandshake : public NetworkHandshake
|
|
{
|
|
public:
|
|
NaomiNetworkHandshake() {
|
|
auto max = naomiNetworkMaxNodes();
|
|
naomiNetwork.setMaxSlots(max.first, max.second);
|
|
}
|
|
std::future<bool> start() override {
|
|
return naomiNetwork.startNetworkAsync();
|
|
}
|
|
|
|
void stop() override {
|
|
naomiNetwork.shutdown();
|
|
}
|
|
|
|
bool canStartNow() override {
|
|
return config::ActAsServer;
|
|
}
|
|
|
|
void startNow() override {
|
|
naomiNetwork.startNow();
|
|
}
|
|
};
|
|
|
|
void NetworkHandshake::init()
|
|
{
|
|
if (settings.platform.isArcade())
|
|
setNaomiNetworkConfig(-1, 0);
|
|
|
|
if (config::GGPOEnable) {
|
|
instance = new GGPONetworkHandshake();
|
|
}
|
|
else if (naomiNetworkSupported()) {
|
|
instance = new NaomiNetworkHandshake();
|
|
}
|
|
else if (config::BattleCableEnable && !settings.platform.isNaomi())
|
|
{
|
|
if (settings.content.gameId == "MAXIMUM SPEED")
|
|
configure_maxspeed_flash(true, config::ActAsServer);
|
|
instance = new BattleCableHandshake();
|
|
}
|
|
else {
|
|
instance = nullptr;
|
|
}
|
|
}
|
|
|
|
void NetworkHandshake::term()
|
|
{
|
|
if (instance != nullptr)
|
|
{
|
|
instance->stop();
|
|
delete instance;
|
|
instance = nullptr;
|
|
}
|
|
}
|
|
|
|
bool naomiNetworkSupported() {
|
|
return naomiNetworkMaxNodes().first > 1;
|
|
}
|
|
|
|
u16 defaultNaomiServerPort() {
|
|
return NaomiNetwork::SERVER_PORT;
|
|
}
|