mirror of
https://github.com/holub/mame
synced 2025-07-01 08:18:59 +03:00
modernized network_manager (nw)
This commit is contained in:
parent
e42fafc3d7
commit
701aea7859
@ -269,7 +269,7 @@ void running_machine::start()
|
|||||||
image_init(*this);
|
image_init(*this);
|
||||||
m_tilemap = std::make_unique<tilemap_manager>(*this);
|
m_tilemap = std::make_unique<tilemap_manager>(*this);
|
||||||
crosshair_init(*this);
|
crosshair_init(*this);
|
||||||
network_init(*this);
|
m_network = std::make_unique<network_manager>(*this);
|
||||||
|
|
||||||
// initialize the debugger
|
// initialize the debugger
|
||||||
if ((debug_flags & DEBUG_FLAG_ENABLED) != 0)
|
if ((debug_flags & DEBUG_FLAG_ENABLED) != 0)
|
||||||
|
@ -85,6 +85,7 @@ class video_manager;
|
|||||||
class ui_manager;
|
class ui_manager;
|
||||||
class tilemap_manager;
|
class tilemap_manager;
|
||||||
class debug_view_manager;
|
class debug_view_manager;
|
||||||
|
class network_manager;
|
||||||
class osd_interface;
|
class osd_interface;
|
||||||
|
|
||||||
struct romload_private;
|
struct romload_private;
|
||||||
@ -163,6 +164,7 @@ public:
|
|||||||
input_manager &input() const { assert(m_input != nullptr); return *m_input; }
|
input_manager &input() const { assert(m_input != nullptr); return *m_input; }
|
||||||
sound_manager &sound() const { assert(m_sound != nullptr); return *m_sound; }
|
sound_manager &sound() const { assert(m_sound != nullptr); return *m_sound; }
|
||||||
video_manager &video() const { assert(m_video != nullptr); return *m_video; }
|
video_manager &video() const { assert(m_video != nullptr); return *m_video; }
|
||||||
|
network_manager &network() const { assert(m_network != nullptr); return *m_network; }
|
||||||
ui_manager &ui() const { assert(m_ui != nullptr); return *m_ui; }
|
ui_manager &ui() const { assert(m_ui != nullptr); return *m_ui; }
|
||||||
tilemap_manager &tilemap() const { assert(m_tilemap != nullptr); return *m_tilemap; }
|
tilemap_manager &tilemap() const { assert(m_tilemap != nullptr); return *m_tilemap; }
|
||||||
debug_view_manager &debug_view() const { assert(m_debug_view != nullptr); return *m_debug_view; }
|
debug_view_manager &debug_view() const { assert(m_debug_view != nullptr); return *m_debug_view; }
|
||||||
@ -279,6 +281,7 @@ private:
|
|||||||
std::unique_ptr<ui_manager> m_ui; // internal data from ui.c
|
std::unique_ptr<ui_manager> m_ui; // internal data from ui.c
|
||||||
std::unique_ptr<tilemap_manager> m_tilemap; // internal data from tilemap.c
|
std::unique_ptr<tilemap_manager> m_tilemap; // internal data from tilemap.c
|
||||||
std::unique_ptr<debug_view_manager> m_debug_view; // internal data from debugvw.c
|
std::unique_ptr<debug_view_manager> m_debug_view; // internal data from debugvw.c
|
||||||
|
std::unique_ptr<network_manager> m_network; // internal data from network.c
|
||||||
|
|
||||||
// system state
|
// system state
|
||||||
machine_phase m_current_phase; // current execution phase
|
machine_phase m_current_phase; // current execution phase
|
||||||
|
@ -13,11 +13,26 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "xmlfile.h"
|
#include "xmlfile.h"
|
||||||
|
|
||||||
/***************************************************************************
|
//**************************************************************************
|
||||||
INITIALIZATION HELPERS
|
// NETWORK MANAGER
|
||||||
***************************************************************************/
|
//**************************************************************************
|
||||||
|
|
||||||
static void network_load(running_machine &machine, int config_type, xml_data_node *parentnode)
|
//-------------------------------------------------
|
||||||
|
// network_manager - constructor
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
network_manager::network_manager(running_machine &machine)
|
||||||
|
: m_machine(machine)
|
||||||
|
{
|
||||||
|
config_register(machine, "network", config_saveload_delegate(FUNC(network_manager::config_load), this), config_saveload_delegate(FUNC(network_manager::config_save), this));
|
||||||
|
}
|
||||||
|
|
||||||
|
//-------------------------------------------------
|
||||||
|
// config_load - read and apply data from the
|
||||||
|
// configuration file
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
|
void network_manager::config_load(int config_type, xml_data_node *parentnode)
|
||||||
{
|
{
|
||||||
xml_data_node *node;
|
xml_data_node *node;
|
||||||
if ((config_type == CONFIG_TYPE_GAME) && (parentnode != nullptr))
|
if ((config_type == CONFIG_TYPE_GAME) && (parentnode != nullptr))
|
||||||
@ -28,7 +43,7 @@ static void network_load(running_machine &machine, int config_type, xml_data_nod
|
|||||||
|
|
||||||
if ((tag != nullptr) && (tag[0] != '\0'))
|
if ((tag != nullptr) && (tag[0] != '\0'))
|
||||||
{
|
{
|
||||||
network_interface_iterator iter(machine.root_device());
|
network_interface_iterator iter(machine().root_device());
|
||||||
for (device_network_interface *network = iter.first(); network != nullptr; network = iter.next())
|
for (device_network_interface *network = iter.first(); network != nullptr; network = iter.next())
|
||||||
{
|
{
|
||||||
if (!strcmp(tag, network->device().tag())) {
|
if (!strcmp(tag, network->device().tag())) {
|
||||||
@ -49,15 +64,19 @@ static void network_load(running_machine &machine, int config_type, xml_data_nod
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//-------------------------------------------------
|
||||||
|
// config_save - save data to the configuration
|
||||||
|
// file
|
||||||
|
//-------------------------------------------------
|
||||||
|
|
||||||
static void network_save(running_machine &machine, int config_type, xml_data_node *parentnode)
|
void network_manager::config_save(int config_type, xml_data_node *parentnode)
|
||||||
{
|
{
|
||||||
xml_data_node *node;
|
xml_data_node *node;
|
||||||
|
|
||||||
/* only care about game-specific data */
|
/* only care about game-specific data */
|
||||||
if (config_type == CONFIG_TYPE_GAME)
|
if (config_type == CONFIG_TYPE_GAME)
|
||||||
{
|
{
|
||||||
network_interface_iterator iter(machine.root_device());
|
network_interface_iterator iter(machine().root_device());
|
||||||
for (device_network_interface *network = iter.first(); network != nullptr; network = iter.next())
|
for (device_network_interface *network = iter.first(); network != nullptr; network = iter.next())
|
||||||
{
|
{
|
||||||
node = xml_add_child(parentnode, "device", nullptr);
|
node = xml_add_child(parentnode, "device", nullptr);
|
||||||
@ -73,16 +92,3 @@ static void network_save(running_machine &machine, int config_type, xml_data_nod
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/***************************************************************************
|
|
||||||
INITIALIZATION
|
|
||||||
***************************************************************************/
|
|
||||||
|
|
||||||
/*-------------------------------------------------
|
|
||||||
network_init - start up the network system
|
|
||||||
-------------------------------------------------*/
|
|
||||||
|
|
||||||
void network_init(running_machine &machine)
|
|
||||||
{
|
|
||||||
config_register(machine, "network", config_saveload_delegate(FUNC(network_load), &machine), config_saveload_delegate(FUNC(network_save), &machine));
|
|
||||||
}
|
|
||||||
|
@ -12,6 +12,22 @@
|
|||||||
#ifndef __NETWORK_H__
|
#ifndef __NETWORK_H__
|
||||||
#define __NETWORK_H__
|
#define __NETWORK_H__
|
||||||
|
|
||||||
void network_init(running_machine &machine);
|
// ======================> network_manager
|
||||||
|
|
||||||
|
class network_manager
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
// construction/destruction
|
||||||
|
network_manager(running_machine &machine);
|
||||||
|
|
||||||
|
// getters
|
||||||
|
running_machine &machine() const { return m_machine; }
|
||||||
|
private:
|
||||||
|
void config_load(int config_type, xml_data_node *parentnode);
|
||||||
|
void config_save(int config_type, xml_data_node *parentnode);
|
||||||
|
|
||||||
|
// internal state
|
||||||
|
running_machine & m_machine; // reference to our machine
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* __NETWORK_H__ */
|
#endif /* __NETWORK_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user