Multiplayer Interactive-Fiction Game-Design Blog



Download 8.87 Mb.
Page139/151
Date02.02.2017
Size8.87 Mb.
#15199
1   ...   135   136   137   138   139   140   141   142   ...   151

Property Definitions

pConnection


Internet connection for the object.

If an object (such as an actor) is controlled by a real person, then the object's pConnection property should point to the connection object. Likewise, the connection object will have a pConnectionActor that points to the actor.

A connection can have only one actor, and only one actor should point to a connection.

pConnectionActor


Actor object that the connection controls.

This is the actor object (player character) that the connection controls.


pConnectionID


Number that identifies the connection.

This number identifies what connection the "Connection" object is assoated with.


pConnectionLanguage


Language ID used for the connection.

This is the language ID used for the connection. Pass this to LanguageSet().


pConnectionLogOffTime


Stores the number of seconds before the connection will log off.

Stores the number of seconds before the connection will log off.

This is linked to the "logoff" timer in the connection object. If the connection is working on logoff then the "logoff" timer will be set at pConnectionLogOffTime will be > 0. Thus, if you set pConnectionLogOffTime to 0, then make sure to kill the "logoff" timer.

pConnectionSpies


List of spy connections.

If an administrator is spying on another character, then this is a list of connections that are spying on this connections. When ConnectionSend() or ConnectionSendVoiceChat() are called, all the spies receive the messages too.


pConnectionTimeZone


Time zone offset.

This is an offset to add to local time to generate UTC, in days.

It's has an equivalent return to the TimeZone() call, which returns the offset in time for the current time zone, in days. UTC = local time + TimeZone().

pConnectionUser


User that controls this connection. (Points to cUser class)

User that controls this connection. (Points to cUser class)


pUserLogAlert


The alert level for the user, affecting what priority messages are logged.

This value is saved for each user, and stored in the connection object when the user logs on.

Most users have a value of 0 for pUserLogAlert. However, if you're concerned that the user may be cheating, set this to 1 or 2. Higher values will cause more events for the user to be logged.

Normally, only priority 1 and 2 events are logged, while 3 and 4 events are ignored. If pUserLogAlert is 1 then priorities 1 to 3 will be logged. If pUserLogAlert is 2 then priorities 1 to 4 will be logged.


Objects

cConnection


Object assocated with a server connection.

This object is automatically created when a new connection is made to the server. It then receives the ConnectionMessage() and ConnectionError() callbacks when information has been received from the user's machine (over the internet).

You may wish to override some of the methods of the connection object (particularly the ConnectionMessage() callback) to work with your software.

Object info

Description

Automatically creates as an object




Contained In




Super-classes




Properties

pConnectionID – undefined

pConnectionActor – NULL

pConnectionLanguage – 1033

pConectionUser – NULL

pConnectionSpies

pUserLogAlert

pConnectionLogOffTime

pConnectionTimeZone




ConnectionEnd


this wont compile; // so don't compile without a connectionEnd() call
// if this got called then you haven't written your own

// ConnectionEnd code. You can do so by creating an overlaid

// cConnection object in your own library, and supply only

// the ConnectionEnd() method


ConnectionError


TextLogPriorityAdjust (this);
if (gTextLogUser[1])

TextLog ("ConnectionError (" + ErrorNumber + ", " + ErrorString + ")");

// BUGFIX - More detailed connection error info

TextLogPriorityAdjust (NULL);


// start the log-off process

// BUGFIX - because this is the result of an error, log off immediately

ConnectionLogOff (0.00001);

ConnectionInfoForServer


this wont compile; // so don't compile without a connectioninfoforserver call
// if this got called then you haven't written your own

// ConnectionInfoForServer code. You can do so by creating an overlaid

// cConnection object in your own library, and supply only

// the ConnectionInfoForServer() method


ConnectionLogOff


// if it's undefined then calling from external callback

if (!IsNumber(TimeToShutdown))

TextLogPriorityAdjust (this);
// if time to shut down is 0 then aborting

if (TimeToShutDown === 0) {

if (pConnectionLogOffTime) {

TimerRemove ("logoff"); // kill the timer

pConnectionLogOffTime = Undefined;

}

if (!IsNumber(TimeToShutdown))



TextLogPriorityAdjust (NULL);

return;


}
// if there's already a timer then dont do anything

if (pConnectionLogOffTime) {

if (!IsNumber(TimeToShutdown))

TextLogPriorityAdjust (NULL);

return;

}
// else, create timer



// BUGFIX - If only a temporary character then can log-off right away

// Do this so that queries to the server don't stick around for 30 seconds

if (IsNumber(TimeToShutDown))

this.pConnectionLogOffTime = TimeToShutDown;

else if (!pConnectionActor || pConnectionActor.pIsTemporary)

this.pConnectionLogOffTime = 0.1;

else

this.pConnectionLogOffTime = gConnectionLogOffTime;



TimerAdd ("logoff", FALSE, pConnectionLogOffTime, this.ConnectionLogOffSuccess);
if (!IsNumber(TimeToShutdown))

TextLogPriorityAdjust (NULL);


ConnectionMessage


this wont compile; // so don't compile without a connectionmessage call
// if this got called then you haven't written your own

// ConnectionMessage code. You can do so by creating an overlaid

// cConnection object in your own library, and supply only

// the ConnectionMessage() method


ConnectionSend


// send to spys

var i;


if (pConnectionSpies) for (i = 0; i < pConnectionSpies.ListNumber(); i++) {

// if the spy has disconnected then remove from the list

if (!ObjectQuery(pConnectionSpies[i])) {

pConnectionSpies.ListRemove (i);

i--;

continue;



}

// send


ConnectionSendFunc (pConnectionSpies[i].pConnectionID, MessageQueue, Message);

} // if spies


var vRet = ConnectionSendFunc (pConnectionID, MessageQueue, Message);
return vRet;

ConnectionSendVoiceChat


// send to spys

var i;


if (pConnectionSpies) for (i = 0; i < pConnectionSpies.ListNumber(); i++) {

// if the spy has disconnected then remove from the list

if (!ObjectQuery(pConnectionSpies[i])) {

pConnectionSpies.ListRemove (i);

i--;

continue;



}

// send


ConnectionSendVoiceChatFunc (pConnectionSpies[i].pConnectionID, MMLString, VoiceChatBinary, Garble, Effect);

} // if spies

var vRet = ConnectionSendVoiceChatFunc (pConnectionID, MMLString, VoiceChatBinary, Garble, Effect);
return vRet;

ConnectionStart


this wont compile; // so don't compile without a connection start call
// if this got called then you haven't written your own

// ConnectionStart code. You can do so by creating an overlaid

// cConnection object in your own library, and supply only

// the ConnectionStart() method


ConnectionUploadImage


this wont compile; // so don't compile without a connectionuploadimage call
// if this got called then you haven't written your own

// ConnectionUploadImage code. You can do so by creating an overlaid

// cConnection object in your own library, and supply only

// the ConnectionUploadImage() method


ConnectionVoiceChat


this wont compile; // so don't compile without a connectionvoicechat call
// if this got called then you haven't written your own

// ConnectionVoiceChat code. You can do so by creating an overlaid

// cConnection object in your own library, and supply only

// the ConnectionVoiceChat() method


Constructor


// place in the list, keeping it sorted

GConnectionList.ListInsert (this, GConnectionList.ListSearchToInsert(this));


Destructor


// just in case, send logoff

ConnectionSendFunc (pConnectionID, TRUE, "");


// call into the callback

ConnectionEnd();


// disconnect this connection in the server

ConnectionDisconnect (pConnectionID);


// remove this from the connection list

var index = GConnectionList.ListSearch (this);

if (index != -1)

GConnectionList.ListRemove (index);

// if this is a single-player mode then shutdown the server

// after all the connections are gone

if (!GConnectionList.ListNumber() && ShardParamIsOffline())

ShutDownImmediately(FALSE);


ConnectionLogOffSuccess (Private)


Called when the connection is actually allowed to log off.

This is called when the connection is actually allowed to log off, about 30 seconds after ConnectionLogOff() was called.



Parameter Name

Description

Return value description




TextLogPriorityAdjust (this);
if (gTextLogUser[1])

TextLog ("ConnectionLogOff");

// Delete this connection

delete this;


TextLogPriorityAdjust (NULL);

oServerTimers


Maintains some timers useful for the server library.

Maintains some timers useful for the server library.

The timers maintain gPerformanceCPU and gPerformanceNetwork. They also automatically shut the server down and restart if the memory used by the server is > gMemoryMaximum.

Object info

Description

Automatically creates as an object

Yes

Contained In




Super-classes




Properties





Constructor


// disable logging if we're offline

if (ShardParamIsOffline()) {

TextLogEnableSet (FALSE);

// don't allow anything to be cached

RenderCacheLimits (0, 0, 0, 0, 0);

}

else {



RenderCacheLimits (gRenderCacheLimitsDataMaximum, gRenderCacheLimitsDataMinimumHardDrive,

gRenderCacheLimitsDataGreedy, gRenderCacheLimitsDataMaxEntriesOn32,

gRenderCacheLimitsDataMaxEntriesOn64);

}
// log startup

if (gTextLogSystem[1])

TextLog ("STARTUP");

TimerAdd ("10sec", TRUE, 10.0, this.TenSecondTimer);
// text log delete timer

TimerAdd ("TextLogDelete", TRUE, 60 * 10 /* 10 min */ + 0.4351, this.TextLogDeleteOld);


Constructor2


// disable logging if we're offline

if (ShardParamIsOffline()) {

TextLogEnableSet (FALSE);

// don't allow anything to be cached

RenderCacheLimits (0, 0, 0, 0, 0);

}

else {



RenderCacheLimits (gRenderCacheLimitsDataMaximum, gRenderCacheLimitsDataMinimumHardDrive,

gRenderCacheLimitsDataGreedy, gRenderCacheLimitsDataMaxEntriesOn32,

gRenderCacheLimitsDataMaxEntriesOn64);

}
// log startup

if (gTextLogSystem[1])

TextLog ("STARTUP");

// create the timer, just to make sure

TimerAdd ("10sec", TRUE, 10.0, this.TenSecondTimer);


// text log delete timer

TimerAdd ("TextLogDelete", TRUE, 60 * 10 /* 10 min */ + 0.4351, this.TextLogDeleteOld);


Destructor


// log shutdown

if (gTextLogSystem[1])

TextLog ("SHUTDOWN");


TextLogDeleteOld (Private)


Tries to delete old text logs.

This method randomly selects a text log from the enumerated list. If it's older than the gTextLogDeleteOld then it's deleted.



Parameter Name

Description

Return value description




var vEnum = TextLogEnum();

if (!IsList(vEnum))

return;
// select one

vEnum = Random(vEnum);


var vOld = TimeGet() - gTextLogDeleteOld;

if (vEnum[1] < vOld)

TextLogDelete (vEnum[0]);

TenSecondTimer (Private)


Timer that's run exactly every 10 seconds.

Timer that's run exactly every 10 seconds.

This updates gPerformanceNetwork, gPerfomanceCPU, and will reboot the server is gMemoryMaximum is reached.

Parameter Name

Description

Return value description




// CPU usage

var vCPU = PerformanceCPU();

while (gPerformanceCPU.ListNumber() > 100)

gPerformanceCPU.ListRemove (0);

gPerformanceCPU.ListConcat (vCPU);
// network usage

var vNetwork = PerformanceNetwork();

vNetwork.ListInsert (vCPU[0]); // get the time from there

while (gPerformanceNetwork.ListNumber() > 100)

gPerformanceNetwork.ListRemove (0);

gPerformanceNetwork.ListConcat (vNetwork);


// how much memory

var vMem1 = PerformanceMemory (1);

var vMem3 = PerformanceMemory (3);

if ((vMem1 > gSafetyMaximumMemory) || (vMem3 > gSafetyMaximumMemory)) {

Trace ("Called ShutDownImmediatelyCheckIn() because exceeded gMemoryMaximum.");

ShutDownImmediatelyCheckIn (TRUE);

return;

}
if (!ShardParamIsOffline()) {



// if there isn't enough hard drive then shut down immediately

vMem1 = PerformanceDisk();

if (vMem1 < gSafetyMinimumDisk) {

Trace ("Called ShutDownImmediatelyCheckIn() because exceeded gSafetyMinimumDisk.");

ShutDownImmediatelyCheckIn (TRUE);

return;


}

// if there are too many GUI objects shut down immediately

vMem1 = PerformanceGUI();

if (vMem1 > gSafetyMaximumGUI) {

Trace ("Called ShutDownImmediatelyCheckIn() because exceeded gSafetyMaximumGUI.");

ShutDownImmediatelyCheckIn (TRUE);

return;

}

// if there are too many threads, shut down immediately



vMem1 = PerformanceThreads();

if (vMem1 > gSafetyMaximumThreads) {

Trace ("Called ShutDownImmediatelyCheckIn() because exceeded gSafetyMaximumThreads.");

ShutDownImmediatelyCheckIn (TRUE);

return;

}

// if there are too many handles shut down immediately



vMem1 = PerformanceHandles();

if (vMem1 > gSafetyMaximumHandles) {

Trace ("Called ShutDownImmediatelyCheckIn() because exceeded gSafetyMaximumHandles.");

ShutDownImmediatelyCheckIn (TRUE);

return;

}

}



Download 8.87 Mb.

Share with your friends:
1   ...   135   136   137   138   139   140   141   142   ...   151




The database is protected by copyright ©ininet.org 2024
send message

    Main page