Merge branch 'GarageGames/development' into ueberengine-dev-3.10

Conflicts:
	Engine/source/app/version.h
	Engine/source/terrain/terrData.cpp
This commit is contained in:
Duion 2016-12-13 17:28:36 +01:00
commit 186604eb76
974 changed files with 121718 additions and 233088 deletions

View file

@ -162,6 +162,13 @@ DefineConsoleFunction( setNetPort, bool, (int port, bool bind), (true), "(int po
return Net::openPort((S32)port, bind);
}
DefineConsoleFunction(isAddressTypeAvailable, bool, (int addressType), , "(protocol id)"
"@brief Determines if a specified address type can be reached.\n\n"
"@ingroup Networking")
{
return Net::isAddressTypeAvailable((NetAddress::Type)addressType);
}
DefineConsoleFunction( closeNetPort, void, (), , "()"
"@brief Closes the current network port\n\n"
"@ingroup Networking")

View file

@ -320,7 +320,7 @@ void StandardMainLoop::init()
Sampler::init();
// Hook in for UDP notification
Net::smPacketReceive.notify(GNet, &NetInterface::processPacketReceiveEvent);
Net::getPacketReceiveEvent().notify(GNet, &NetInterface::processPacketReceiveEvent);
#ifdef TORQUE_DEBUG_GUARD
Memory::flagCurrentAllocs( Memory::FLAG_Static );
@ -604,15 +604,11 @@ bool StandardMainLoop::doMainLoop()
lastFocus = newFocus;
}
#ifndef TORQUE_OS_MAC
// under the web plugin do not sleep the process when the child window loses focus as this will cripple the browser perfomance
if (!Platform::getWebDeployment())
tm->setBackground(!newFocus);
else
tm->setBackground(false);
#else
tm->setBackground(false);
#endif
}
else
{

View file

@ -177,7 +177,7 @@ static Vector<Ping> gQueryList(__FILE__, __LINE__);
struct PacketStatus
{
U8 index;
U16 index;
S32 key;
U32 time;
U32 tryCount;
@ -191,6 +191,9 @@ struct PacketStatus
time = _time;
tryCount = gPacketRetryCount;
}
inline U8 getOldIndex() { return (U8)index; }
inline U16 getIndex() { return index; }
};
static Vector<PacketStatus> gPacketStatusList(__FILE__, __LINE__);
@ -212,6 +215,7 @@ struct ServerFilter
OnlineQuery = 0, // Authenticated with master
OfflineQuery = BIT(0), // On our own
NoStringCompress = BIT(1),
NewStyleResponse = BIT(2), // Include IPV6 servers
};
enum // Filter flags:
@ -222,6 +226,14 @@ struct ServerFilter
CurrentVersion = BIT(7),
NotXenon = BIT(6)
};
enum // Region mask flags
{
RegionIsIPV4Address = BIT(30),
RegionIsIPV6Address = BIT(31),
RegionAddressMask = RegionIsIPV4Address | RegionIsIPV6Address
};
//Rearranging the fields according to their sizes
char* gameType;
@ -241,7 +253,7 @@ struct ServerFilter
ServerFilter()
{
type = Normal;
queryFlags = 0;
queryFlags = NewStyleResponse;
gameType = NULL;
missionType = NULL;
minPlayers = 0;
@ -401,10 +413,17 @@ void queryLanServers(U32 port, U8 flags, const char* gameType, const char* missi
NetAddress addr;
char addrText[256];
// IPV4
dSprintf( addrText, sizeof( addrText ), "IP:BROADCAST:%d", port );
Net::stringToAddress( addrText, &addr );
pushPingBroadcast( &addr );
// IPV6
dSprintf(addrText, sizeof(addrText), "IP6:MULTICAST:%d", port);
Net::stringToAddress(addrText, &addr);
pushPingBroadcast(&addr);
Con::executef("onServerQueryStatus", "start", "Querying LAN servers", "0");
processPingsAndQueries( gPingSession );
}
@ -502,7 +521,7 @@ void queryMasterServer(U8 flags, const char* gameType, const char* missionType,
dStrcpy( sActiveFilter.missionType, missionType );
}
sActiveFilter.queryFlags = flags;
sActiveFilter.queryFlags = flags | ServerFilter::NewStyleResponse;
sActiveFilter.minPlayers = minPlayers;
sActiveFilter.maxPlayers = maxPlayers;
sActiveFilter.maxBots = maxBots;
@ -519,6 +538,7 @@ void queryMasterServer(U8 flags, const char* gameType, const char* missionType,
sActiveFilter.type = ServerFilter::Buddy;
sActiveFilter.buddyCount = buddyCount;
sActiveFilter.buddyList = (U32*) dRealloc( sActiveFilter.buddyList, buddyCount * 4 );
sActiveFilter.queryFlags = ServerFilter::NewStyleResponse;
dMemcpy( sActiveFilter.buddyList, buddyList, buddyCount * 4 );
clearServerList();
}
@ -775,7 +795,7 @@ Vector<MasterInfo>* getMasterServerList()
U32 region = 1; // needs to default to something > 0
dSscanf(master,"%d:",&region);
const char* madd = dStrchr(master,':') + 1;
if (region && Net::stringToAddress(madd,&address)) {
if (region && Net::stringToAddress(madd,&address) == Net::NoError) {
masterList.increment();
MasterInfo& info = masterList.last();
info.address = address;
@ -1171,10 +1191,13 @@ static void processMasterServerQuery( U32 session )
// Send a request to the master server for the server list:
BitStream *out = BitStream::getPacketStream();
out->clearStringBuffer();
out->write( U8( NetInterface::MasterServerListRequest ) );
out->write( U8( sActiveFilter.queryFlags) );
out->write( ( gMasterServerPing.session << 16 ) | ( gMasterServerPing.key & 0xFFFF ) );
out->write( U8( 255 ) );
writeCString( out, sActiveFilter.gameType );
writeCString( out, sActiveFilter.missionType );
out->write( sActiveFilter.minPlayers );
@ -1359,23 +1382,35 @@ static void processServerListPackets( U32 session )
if ( !p.tryCount )
{
// Packet timed out :(
Con::printf( "Server list packet #%d timed out.", p.index + 1 );
Con::printf( "Server list packet #%d timed out.", p.getIndex() + 1 );
gPacketStatusList.erase( i );
}
else
{
// Try again...
Con::printf( "Rerequesting server list packet #%d...", p.index + 1 );
Con::printf( "Rerequesting server list packet #%d...", p.getIndex() + 1 );
p.tryCount--;
p.time = currentTime;
p.key = gKey++;
BitStream *out = BitStream::getPacketStream();
bool extendedPacket = (sActiveFilter.queryFlags & ServerFilter::NewStyleResponse) != 0;
out->clearStringBuffer();
out->write( U8( NetInterface::MasterServerListRequest ) );
if ( extendedPacket )
out->write( U8( NetInterface::MasterServerExtendedListRequest ) );
else
out->write( U8( NetInterface::MasterServerListRequest ) );
out->write( U8( sActiveFilter.queryFlags ) ); // flags
out->write( ( session << 16) | ( p.key & 0xFFFF ) );
out->write( p.index ); // packet index
if ( extendedPacket )
out->write( p.getOldIndex() ); // packet index
else
out->write( p.getIndex() ); // packet index
out->write( U8( 0 ) ); // game type
out->write( U8( 0 ) ); // mission type
out->write( U8( 0 ) ); // minPlayers
@ -1569,6 +1604,98 @@ static void handleMasterServerListResponse( BitStream* stream, U32 key, U8 /*fla
//-----------------------------------------------------------------------------
static void handleExtendedMasterServerListResponse(BitStream* stream, U32 key, U8 /*flags*/)
{
U16 packetIndex, packetTotal;
U32 i;
U16 serverCount, port;
U8 netNum[16];
char addressBuffer[256];
NetAddress addr;
stream->read(&packetIndex);
// Validate the packet key:
U32 packetKey = gMasterServerPing.key;
if (gGotFirstListPacket)
{
for (i = 0; i < gPacketStatusList.size(); i++)
{
if (gPacketStatusList[i].index == packetIndex)
{
packetKey = gPacketStatusList[i].key;
break;
}
}
}
U32 testKey = (gPingSession << 16) | (packetKey & 0xFFFF);
if (testKey != key)
return;
stream->read(&packetTotal);
stream->read(&serverCount);
Con::printf("Received server list packet %d of %d from the master server (%d servers).", (packetIndex + 1), packetTotal, serverCount);
// Enter all of the servers in this packet into the ping list:
for (i = 0; i < serverCount; i++)
{
U8 type;
stream->read(&type);
dMemset(&addr, '\0', sizeof(NetAddress));
if (type == 0)
{
// IPV4
addr.type = NetAddress::IPAddress;
stream->read(4, &addr.address.ipv4.netNum[0]);
stream->read(&addr.port);
}
else
{
// IPV6
addr.type = NetAddress::IPV6Address;
stream->read(16, &addr.address.ipv6.netNum[0]);
stream->read(&addr.port);
}
pushPingRequest(&addr);
}
// If this is the first list packet we have received, fill the packet status list
// and start processing:
if (!gGotFirstListPacket)
{
gGotFirstListPacket = true;
gMasterServerQueryAddress = gMasterServerPing.address;
U32 currentTime = Platform::getVirtualMilliseconds();
for (i = 0; i < packetTotal; i++)
{
if (i != packetIndex)
{
PacketStatus* p = new PacketStatus(i, gMasterServerPing.key, currentTime);
gPacketStatusList.push_back(*p);
}
}
processServerListPackets(gPingSession);
}
else
{
// Remove the packet we just received from the status list:
for (i = 0; i < gPacketStatusList.size(); i++)
{
if (gPacketStatusList[i].index == packetIndex)
{
gPacketStatusList.erase(i);
break;
}
}
}
}
//-----------------------------------------------------------------------------
static void handleGameMasterInfoRequest( const NetAddress* address, U32 key, U8 flags )
{
if ( GNet->doesAllowConnections() )
@ -1585,7 +1712,7 @@ static void handleGameMasterInfoRequest( const NetAddress* address, U32 key, U8
for(U32 i = 0; i < masterList->size(); i++)
{
masterAddr = &(*masterList)[i].address;
if (*(U32*)(masterAddr->netNum) == *(U32*)(address->netNum))
if (masterAddr->isSameAddress(*address))
{
fromMaster = true;
break;
@ -2098,6 +2225,10 @@ void DemoNetInterface::handleInfoPacket( const NetAddress* address, U8 packetTyp
case GameMasterInfoRequest:
handleGameMasterInfoRequest( address, key, flags );
break;
case MasterServerExtendedListResponse:
handleExtendedMasterServerListResponse(stream, key, flags);
break;
}
}

View file

@ -170,8 +170,8 @@ IMPLEMENT_CALLBACK(TCPObject, onDisconnect, void, (),(),
TCPObject *TCPObject::find(NetSocket tag)
{
for(TCPObject *walk = table[U32(tag) & TableMask]; walk; walk = walk->mNext)
if(walk->mTag == tag)
for(TCPObject *walk = table[tag.getHash() & TableMask]; walk; walk = walk->mNext)
if(walk->mTag.getHash() == tag.getHash())
return walk;
return NULL;
}
@ -180,13 +180,13 @@ void TCPObject::addToTable(NetSocket newTag)
{
removeFromTable();
mTag = newTag;
mNext = table[U32(mTag) & TableMask];
table[U32(mTag) & TableMask] = this;
mNext = table[mTag.getHash() & TableMask];
table[mTag.getHash() & TableMask] = this;
}
void TCPObject::removeFromTable()
{
for(TCPObject **walk = &table[U32(mTag) & TableMask]; *walk; walk = &((*walk)->mNext))
for(TCPObject **walk = &table[mTag.getHash() & TableMask]; *walk; walk = &((*walk)->mNext))
{
if(*walk == this)
{
@ -207,7 +207,7 @@ TCPObject::TCPObject()
mBuffer = NULL;
mBufferSize = 0;
mPort = 0;
mTag = InvalidSocket;
mTag = NetSocket::INVALID;
mNext = NULL;
mState = Disconnected;
@ -215,9 +215,9 @@ TCPObject::TCPObject()
if(gTCPCount == 1)
{
Net::smConnectionAccept.notify(processConnectedAcceptEvent);
Net::smConnectionReceive.notify(processConnectedReceiveEvent);
Net::smConnectionNotify.notify(processConnectedNotifyEvent);
Net::getConnectionAcceptedEvent().notify(processConnectedAcceptEvent);
Net::getConnectionReceiveEvent().notify(processConnectedReceiveEvent);
Net::getConnectionNotifyEvent().notify(processConnectedNotifyEvent);
}
}
@ -230,9 +230,9 @@ TCPObject::~TCPObject()
if(gTCPCount == 0)
{
Net::smConnectionAccept.remove(processConnectedAcceptEvent);
Net::smConnectionReceive.remove(processConnectedReceiveEvent);
Net::smConnectionNotify.remove(processConnectedNotifyEvent);
Net::getConnectionAcceptedEvent().remove(processConnectedAcceptEvent);
Net::getConnectionReceiveEvent().remove(processConnectedReceiveEvent);
Net::getConnectionNotifyEvent().remove(processConnectedNotifyEvent);
}
}
@ -242,7 +242,7 @@ bool TCPObject::processArguments(S32 argc, ConsoleValueRef *argv)
return true;
else if(argc == 1)
{
addToTable(U32(dAtoi(argv[0])));
addToTable(NetSocket::fromHandle(dAtoi(argv[0])));
return true;
}
return false;
@ -406,7 +406,7 @@ void TCPObject::onDisconnect()
void TCPObject::listen(U16 port)
{
mState = Listening;
U32 newTag = Net::openListenPort(port);
NetSocket newTag = Net::openListenPort(port);
addToTable(newTag);
}
@ -418,7 +418,7 @@ void TCPObject::connect(const char *address)
void TCPObject::disconnect()
{
if( mTag != InvalidSocket ) {
if( mTag != NetSocket::INVALID ) {
Net::closeConnectTo(mTag);
}
removeFromTable();
@ -592,7 +592,7 @@ void processConnectedAcceptEvent(NetSocket listeningPort, NetSocket newConnectio
if(!tcpo)
return;
tcpo->onConnectionRequest(&originatingAddress, newConnection);
tcpo->onConnectionRequest(&originatingAddress, (U32)newConnection.getHandle());
}
void processConnectedNotifyEvent( NetSocket sock, U32 state )