ScummVM API documentation
Scumm::Net Class Reference

Public Member Functions

 Net (ScummEngine_v90he *vm)
 
int hostGame (char *sessionName, char *userName)
 
int joinGame (Common::String IP, char *userName)
 
int addUser (char *shortName, char *longName)
 
int removeUser ()
 
int whoSentThis ()
 
int whoAmI ()
 
int createSession (char *name)
 Creates and host a network game session. More...
 
int joinSession (int sessionIndex)
 
int joinSessionById (int sessionId)
 
int ifSessionExist (int sessionId)
 
int endSession ()
 
void setSessionServer (Common::String sessionServer)
 
void disableSessionJoining ()
 
void enableSessionJoining ()
 
void setBotsCount (int botsCount)
 Set AI Player count. More...
 
int32 setProviderByName (int32 parameter1, int32 parameter2)
 Set and initializes the provider given by their name. More...
 
void setFakeLatency (int time)
 Sets the fake latency. More...
 
bool destroyPlayer (int32 userId)
 
int32 startQuerySessions (bool connectToSessionServer=true)
 
int32 updateQuerySessions ()
 
void stopQuerySessions ()
 
int querySessions ()
 
int queryProviders ()
 
int setProvider (int providerIndex)
 Set the provider by the index. More...
 
int closeProvider ()
 
bool initAll ()
 
bool initProvider ()
 
bool initSession ()
 
bool initUser ()
 
void remoteStartScript (int typeOfSend, int sendTypeParam, int priority, int argsCount, int32 *args)
 
void remoteSendArray (int typeOfSend, int sendTypeParam, int priority, int arrayIndex)
 
int remoteStartScriptFunction (int typeOfSend, int sendTypeParam, int priority, int defaultReturnValue, int argsCount, int32 *args)
 
void doNetworkOnceAFrame (int msecs)
 
bool getHostName (char *hostname, int length)
 
bool getIPfromName (char *ip, int ipLength, char *nameBuffer)
 
void getSessionName (int sessionNumber, char *buffer, int length)
 
int getSessionPlayerCount (int sessionNumber)
 
void getProviderName (int providerIndex, char *buffer, int length)
 Get the name of a provider of the given index. More...
 

Public Attributes

int _latencyTime
 
bool _fakeLatency
 
bool _isHost
 
int _myUserId
 
int _fromUserId
 
int _sessionId
 

Member Function Documentation

◆ hostGame()

int Scumm::Net::hostGame ( char *  sessionName,
char *  userName 
)

Creates a session and add ourselves as a user.

Parameters
sessionNameName if a session.
userNameUser name to add.
Return values
1on success.
0on falure.

◆ joinGame()

int Scumm::Net::joinGame ( Common::String  IP,
char *  userName 
)

Joins a session with the speicified IP address and user name. This gets called when attempting to join a Moonbase Commander game with the –join-game command line param.

Parameters
IPIP Address to join
userNameUsername to use.
Return values
1on success.
0on failure.

◆ addUser()

int Scumm::Net::addUser ( char *  shortName,
char *  longName 
)

Adds a user to the session and assigns a user id.

Parameters
shortNameShort username
longNameLong username.
Return values
1on success.
0on failure.

◆ removeUser()

int Scumm::Net::removeUser ( )

Remove ourselves if we have a user id for this session.

Return values
Alwaysreturns 1.
See also
destroyPlayer

◆ whoSentThis()

int Scumm::Net::whoSentThis ( )

Gets the user id who sent the previously received packet.

Return values
Lastsent user id.

◆ whoAmI()

int Scumm::Net::whoAmI ( )

Gets our assigned user id.

Return values
Ouruser id.

◆ createSession()

int Scumm::Net::createSession ( char *  name)

Creates and host a network game session.

Parameters
nameSession name
Return values
1on success.
0on failure.

◆ joinSession()

int Scumm::Net::joinSession ( int  sessionIndex)

Join a session by their given index.

Parameters
sessionIndexIndex of a session to join.
Return values
1on success.
0on falure.
Note
Use the QuerySessions methods to get sessions.

◆ joinSessionById()

int Scumm::Net::joinSessionById ( int  sessionId)

Join a session by their given id instead of index.

Parameters
sessionIdID of session to join
Return values
1on success.
0on falure.
Note
Use the QuerySessions methods to get sessions.

◆ ifSessionExist()

int Scumm::Net::ifSessionExist ( int  sessionId)

Checks if the queried session id exist.

Parameters
sessionIdSession ID to search for.
Return values
1if found.
0if not found.

◆ endSession()

int Scumm::Net::endSession ( )

Ends and closes an active game session.

Return values
Alwaysreturns 1

◆ setSessionServer()

void Scumm::Net::setSessionServer ( Common::String  sessionServer)

Force a session server address to connect to when creating and joining sessions, overriding an existing configuration if any.

Parameters
sessionServerAddress to a session server address.
Note
This will disable LAN hosting.

◆ disableSessionJoining()

void Scumm::Net::disableSessionJoining ( )

Disallows anymore players from joining our session.

◆ enableSessionJoining()

void Scumm::Net::enableSessionJoining ( )

Allows more players to join our session.

Note
Currently stubbed.

◆ setBotsCount()

void Scumm::Net::setBotsCount ( int  botsCount)

Set AI Player count.

Parameters
botsCountNumber of AI players currently created.

◆ setProviderByName()

int32 Scumm::Net::setProviderByName ( int32  parameter1,
int32  parameter2 
)

Set and initializes the provider given by their name.

Parameters
parameter1SCUMM string array providing the name of the provider.
parameter2SCUMM string array providing the optional paramater
Return values
1if successful
0on failure.
Note
Currently this will only initialize the ENet provider, regardless of name given.

◆ setFakeLatency()

void Scumm::Net::setFakeLatency ( int  time)

Sets the fake latency.

Parameters
timeFake latency time in milliseconds.

◆ destroyPlayer()

bool Scumm::Net::destroyPlayer ( int32  userId)

Destroys and remove an existing player.

Parameters
userIdID of player to remove.
Return values
trueon removed
falseon failure.

◆ startQuerySessions()

int32 Scumm::Net::startQuerySessions ( bool  connectToSessionServer = true)

Setup and begin to query for active game sessions

Parameters
connectToSessionServerIndicates that it should connect to the session server for Internet-wide connections
Return values
1if ready
0if not.
See also
updateQuerySessions()
stopQuerySessions()

◆ updateQuerySessions()

int32 Scumm::Net::updateQuerySessions ( )

Make a session query request and updates the session list.

Returns
Number of sessions found.

◆ stopQuerySessions()

void Scumm::Net::stopQuerySessions ( )

Stops and shuts down querying for sessions.

Note
This will clear the sessions list.

◆ querySessions()

int Scumm::Net::querySessions ( )

Shortcut for querying sessions, calls startQuerySessions and returns updateQuerySessions.

Returns
Number of sessions found.

◆ queryProviders()

int Scumm::Net::queryProviders ( )

Query aviliable providers.

Returns
Always 1 currently.

◆ setProvider()

int Scumm::Net::setProvider ( int  providerIndex)

Set the provider by the index.

Parameters
providerIndexindex of a provider
Return values
1if successful
0on failure
Note
Currently stubbed.

◆ closeProvider()

int Scumm::Net::closeProvider ( )

Close and shutsdown an active provider.

Returns
Always returns 1.

◆ initAll()

bool Scumm::Net::initAll ( )

Initializes the provider, session, and adds user all at once.

Return values
trueon success.
falseon failure.
Note
Currently stubbed.

◆ initProvider()

bool Scumm::Net::initProvider ( )

Initializes the ENet provider.

Returns
true on success.
false on failure.

◆ initSession()

bool Scumm::Net::initSession ( )

Initializes the session.

Returns
true on success.
false on failure.
Note
Currently stubbed.

◆ initUser()

bool Scumm::Net::initUser ( )

Initializes the user.

Returns
true on success.
false on failure.
Note
Currently stubbed.

◆ remoteStartScript()

void Scumm::Net::remoteStartScript ( int  typeOfSend,
int  sendTypeParam,
int  priority,
int  argsCount,
int32 *  args 
)

Sends a packet to a remote peer(s) which will call VAR_REMOTE_START_SCRIPT.

Parameters
typeOfSendA type of send this packet goes to, can be an indiviual peer, a group, host, or everybody.
sendTypeParamA parameter for this type of send, e.g. for an indiviual send, this can be a user id of a peer to send to.
priorityTells the provider to ensure that this packet has been sent and received.
argsCountNumber of args it should contain for the VAR_REMOTE_START_SCRIPT call.
argsThe arguments themselves.

◆ remoteSendArray()

void Scumm::Net::remoteSendArray ( int  typeOfSend,
int  sendTypeParam,
int  priority,
int  arrayIndex 
)

Sends an SCUMM array to a remote peer(s), calling VAR_NETWORK_RECEIVE_ARRAY_SCRIPT there.

Parameters
typeOfSendA type of send this packet goes to, can be an indiviual peer, a group, host, or everybody.
sendTypeParamA parameter for this type of send, e.g. for an indiviual send, this can be a user id of a peer to send to.
priorityTells the provider to ensure that this packet has been sent and received.
arrayIndexAn index pointing to an SCUMM array to pack and send with.

◆ remoteStartScriptFunction()

int Scumm::Net::remoteStartScriptFunction ( int  typeOfSend,
int  sendTypeParam,
int  priority,
int  defaultReturnValue,
int  argsCount,
int32 *  args 
)

Sends a packet to a peer calling VAR_NETWORK_RECEIVE_ARRAY_SCRIPT, and it'll return its return value back to us.

Parameters
typeOfSendA type of send this packet goes to, can be an indiviual peer, a group, host, or everybody.
sendTypeParamA parameter for this type of send, e.g. for an indiviual send, this can be a user id of a peer to send to.
priorityTells the provider to ensure that this packet has been sent and received.
defaultReturnValueThe default return value to return in case of a time out.
argsCountNumber of args it should contain for the VAR_REMOTE_START_SCRIPT call.
argsThe arguments themselves.
Return values
Apeer's return value.
defaultReturnValueif timed out.
Note
This has been stubbed, as no game seems to use this.

◆ doNetworkOnceAFrame()

void Scumm::Net::doNetworkOnceAFrame ( int  msecs)

A method that should be called once at the beginning of a game loop to send/receive network data.

Parameters
msecsmilliseconds to service networks for.

◆ getHostName()

bool Scumm::Net::getHostName ( char *  hostname,
int  length 
)

Gets the host name of the local machine.

Parameters
hostnamePointer to store the host name to.
lengthThe length of the pointer.
Return values
trueon successful .
falseon failure.
Note
This is currently subbed.

◆ getIPfromName()

bool Scumm::Net::getIPfromName ( char *  ip,
int  ipLength,
char *  nameBuffer 
)

Gets the IP address of the given local host name.

Parameters
ipPointer to store the address to.
ipLengthThe length of the pointer.
nameBufferthe Host name itself.
Return values
trueon successful .
falseon failure..
Note
This is currently subbed.

◆ getSessionName()

void Scumm::Net::getSessionName ( int  sessionNumber,
char *  buffer,
int  length 
)

Get the session name from the session index.

Parameters
sessionNumberThe session's index.
bufferA buffer to store the name to.
lengthMaximum length of the buffer.

◆ getSessionPlayerCount()

int Scumm::Net::getSessionPlayerCount ( int  sessionNumber)

Get the session's player count.

Parameters
sessionNumberThe session's index.
Returns
Player count.

◆ getProviderName()

void Scumm::Net::getProviderName ( int  providerIndex,
char *  buffer,
int  length 
)

Get the name of a provider of the given index.

Parameters
providerIndexThe provider's index.
bufferA buffer to store the name to.
lengthMaximum length of the buffer.

The documentation for this class was generated from the following file: