Ejemplo n.º 1
0
Game::Game(uchar playersnumber,int bombtimeout,ArawnSettings *settings,bool survive)
{
	activegame=false;
	this->cup=0;
	this->survive=survive;
	this->settings=settings;
	this->playersnumber=playersnumber;
	this->bombtimeout=bombtimeout;
	this->playerid=0;
	gametimer=new QTimer(this);
	destroymap=new QTimer(this);
	map=new Map(playersnumber,settings);
	map->Upload(1);
	clientconnection=0;
	serverconnection=new Servernet();
	serverconnection->SetSurviveCup(survive);
	serverconnection->SetPlayerNumber(playersnumber);
	serverconnection->SetLocalPlayername(settings->defaultPlayer1Name);
	connect(map,SIGNAL(ServerCommand(Command)),this,SIGNAL(ServerValidate(Command)));
	connect(this,SIGNAL(ClientValidate(Command)),this,SLOT(ClientExecute(Command)));
	connect(this,SIGNAL(ServerValidate(Command)),serverconnection,SLOT(SendCommandToClients(Command)));
	connect(this,SIGNAL(ServerValidate(Command)),this,SLOT(ServerExecute(Command)));
	connect(serverconnection,SIGNAL(CommandReceivedFromClients(Command)),this,SLOT(ClientExecute(Command)));
	connect(serverconnection,SIGNAL(ServerIsRunning()),this,SIGNAL(ServerIsRunning()));
	connect(serverconnection,SIGNAL(NewPlayerConnected()),this,SIGNAL(NewPlayer()));
	connect(serverconnection,SIGNAL(ServerNetworkError()),this,SIGNAL(ConnectionFailed()));
	connect(serverconnection,SIGNAL(AllPlayersConnected()),this,SLOT(AllReady()));
	connect(this,SIGNAL(FieldDestroyedByMap(uchar,uchar)),map,SIGNAL(FieldDestroyed(uchar,uchar)));
	connect(serverconnection,SIGNAL(PlayerDisconnected()),this,SIGNAL(Disconnected()));
}
Ejemplo n.º 2
0
void ANUTActor::ExecuteOnServer(UObject* InTargetObj, FString InTargetFunc)
{
	if (InTargetObj != NULL && InTargetFunc.Len() > 0)
	{
		// Only static functions can be used, so verify this is referencing a static function
		FName TargetFuncName = *InTargetFunc;
		UFunction* TargetFuncObj = InTargetObj->FindFunction(TargetFuncName);

		if (FString(TargetFuncName.ToString()).StartsWith(TEXT("UnitTestServer_"), ESearchCase::CaseSensitive))
		{
			if (TargetFuncObj != NULL)
			{
				if (TargetFuncObj->HasAnyFunctionFlags(FUNC_Static))
				{
					UObject* TargetObjCDO = (InTargetObj->HasAnyFlags(EObjectFlags::RF_ClassDefaultObject) ?
											InTargetObj :
											InTargetObj->GetClass()->GetDefaultObject());

					// Now that we've verified it's a static function, change the delegate object to the class default object
					// (as that is where static function must be executed, as there is no serverside unit test instance),
					// and then send it to the server
					TempDelegate.BindUFunction(TargetObjCDO, TargetFuncName);

					UDelegateProperty* DelProp = FindField<UDelegateProperty>(GetClass(), TEXT("TempDelegate"));

					FString DelString;
					DelProp->ExportTextItem(DelString, DelProp->ContainerPtrToValuePtr<uint8>(this), NULL, this, 0, NULL);

					ServerExecute(DelString);
				}
				else
				{
					UE_LOG(LogUnitTest, Log, TEXT("ExecuteOnServer: Only static functions can be passed to the server."));
				}
			}
			else
			{
				UE_LOG(LogUnitTest, Log, TEXT("ExecuteOnServer: Could not locate InTarget function."));
			}
		}
		else
		{
			UE_LOG(LogUnitTest, Log, TEXT("ExecuteOnServer: Target functions must be prefixed 'UnitTestServer_FuncName'"));
		}
	}
	else
	{
		UE_LOG(LogUnitTest, Log, TEXT("ExecuteOnServer: Target not specified"));
	}
}
Ejemplo n.º 3
0
Game::Game(QString address)
{
	this->cup=new Cup();
	this->settings=aSetInstance;
	connect(this,SIGNAL(PlayerPointChanged(uchar,int)),cup,SLOT(ChangePlayerPoint(uchar,int)));
	map=0;
	serverconnection=0;
	clientconnection=new Client(settings->defaultPlayer1Name);
	connect(this,SIGNAL(ClientValidate(Command)),clientconnection,SLOT(SendCommandToServer(Command)));
	connect(clientconnection,SIGNAL(CommandReceivedFromServer(Command)),this,SLOT(ServerExecute(Command)));
	connect(clientconnection,SIGNAL(Connected()),this,SIGNAL(Connected()));
	connect(clientconnection,SIGNAL(ConnectionFailed()),this,SIGNAL(ConnectionFailed()));
	connect(clientconnection,SIGNAL(refreshPlayers()), this, SIGNAL(RefreshPlayers()));
	connect(this,SIGNAL(PlayerPointChanged(uchar,int)),cup,SLOT(ChangePlayerPoint(uchar,int)));
	connect(clientconnection,SIGNAL(Disconnected()),this,SIGNAL(Disconnected()));
}