Esempio n. 1
0
int main(int argc, char *argv[])
{
    try {
        std::cout << "BIG FAT WARNING: this server is currently under development. If you find any errors (you most likely will)";
        std::cout << " report them to mantis or the forums." << std::endl << std::endl;
        FileSystemHandler::Cleanup();
        FileSystemHandler::Initialize(false);
        CGameServer* server = 0;
        CGameSetup* gameSetup = 0;

        if (argc > 1)
        {
            std::string script = argv[1];
            std::cout << "Loading script: " << script << std::endl;
            gameSetup = new CGameSetup();	// to store the gamedata inside
            if (!gameSetup->Init(script))	// read the script provided by cmdline
            {
                std::cout << "Failed to load script" << std::endl;
                return 1;
            }

            std::cout << "Starting server..." << std::endl;
            // Create the server, it will run in a separate thread
            const std::string modArchive = archiveScanner->ModNameToModArchive(gameSetup->baseMod);
            GameData* data = new GameData();
            data->SetMap(gameSetup->mapName, archiveScanner->GetMapChecksum(gameSetup->mapName));
            data->SetMod(gameSetup->baseMod, archiveScanner->GetModChecksum(modArchive));
            data->SetScript(gameSetup->scriptName);

            server = new CGameServer(gameSetup->hostport, false, data, gameSetup);

            if (gameSetup->autohostport > 0)
                server->AddAutohostInterface(gameSetup->autohostport);
            else
            {
                std::cout << "You should specify an AutohostPort in the script" << std::endl;
            }

            while (!server->HasFinished()) // check if still running
#ifdef _WIN32
                Sleep(1000);
#else
                sleep(1);	// if so, wait 1  second
#endif
            delete server;	// delete the server after usage
            delete gameSetup;
        }
        else
        {
            std::cout << "usage: dedicated <full_path_to_script>" << std::endl;
        }

        FileSystemHandler::Cleanup();
    }
    catch (const std::exception& err)
    {
        std::cout << "Exception raised: " << err.what() << std::endl;
    }
    return 0;
}
Esempio n. 2
0
float		MinMax::eval(GameData const &gd, GameData::team t) const
{
  static int	counter(0);
  ChessBoard	c(gd);
  float		pieceVal[2] = {0, 0};

  const std::list<PieceInfo *>	*pieces;
  pieces = c.getPieces(t);
  for (std::list<PieceInfo *>::const_iterator it = pieces->begin() ; it != pieces->end() ; ++it)
    {
      pieceVal[t] += m_piecesVal[(*it)->getPiece()];
      delete *it; // Un-alloc 9
    }
  delete pieces; // Un-alloc 2
  pieces = c.getPieces(gd.getOtherTeam(t));
  for (std::list<PieceInfo *>::const_iterator it = pieces->begin() ; it != pieces->end() ; ++it)
    {
      pieceVal[gd.getOtherTeam(t)] += m_piecesVal[(*it)->getPiece()];
      delete *it; // Un-alloc 9
    }
  delete pieces; // Un-alloc 2

  if ((pieceVal[t] - pieceVal[gd.getOtherTeam(t)]) != 0 && false)
    {
  std::cout << gd << std::endl;
  std::cout << (pieceVal[t] - pieceVal[gd.getOtherTeam(t)]) << " = " << pieceVal[t] << " - " <<  pieceVal[gd.getOtherTeam(t)] << std::endl;
    }

  counter++;
  return (pieceVal[t] - pieceVal[gd.getOtherTeam(t)]);
}
Esempio n. 3
0
void GuiGameList::render()
{
	if(mTheme)
		mTheme->render();

	//header
	if(!mTheme->getBool("hideHeader"))
		Renderer::drawCenteredText(mSystem->getDescName(), 0, 1, 0xFF0000FF, Renderer::getDefaultFont(Renderer::LARGE));

	if(mDetailed)
	{
		//divider
		if(!mTheme->getBool("hideDividers"))
			Renderer::drawRect(Renderer::getScreenWidth() * mTheme->getFloat("listOffsetX") - 4, Renderer::getDefaultFont(Renderer::LARGE)->getHeight() + 2, 8, Renderer::getScreenHeight(), 0x0000FFFF);

		//if we're not scrolling and we have selected a non-folder
		if(!mList->isScrolling() && mList->getSelectedObject() && !mList->getSelectedObject()->isFolder())
		{
			GameData* game = (GameData*)mList->getSelectedObject();

			std::string desc = game->getDescription();
			if(!desc.empty())
				Renderer::drawWrappedText(desc, Renderer::getScreenWidth() * 0.03, mScreenshot->getOffsetY() + mScreenshot->getHeight() + 12, Renderer::getScreenWidth() * (mTheme->getFloat("listOffsetX") - 0.03), mTheme->getColor("description"), mTheme->getDescriptionFont());
		}

		mScreenshot->render();
	}

	mList->render();
}
Esempio n. 4
0
void ConfigsObjectsWidget::on_removeObject_pressed()
{
    GameObject *currentObject = NULL;
    GameData *gameData = GameData::getInstance();
    if(ui->listPersonagem->currentItem() != NULL) {
        currentObject = (GameObject*) ui->listPersonagem->currentItem()->data(Qt::UserRole).value<void*>();
        if(currentObject != NULL) {
            if(MessageBoxes::showConfirmBox(std::string(tr("Deseja realmente remover o objeto?").toStdString().c_str()))) {
                if(!gameData->verifyObjectUsedById(currentObject->id)) {
                    this->optionsController->removeObject(currentObject);
                    ui->scrollArea->setWidget(NULL);
                    specificWidget->removeAllWidgets();
                } else {
                    MessageBoxes::showMessageBox(QString::fromUtf8(tr("Não é possível remover o objeto, pois ele é utilizado em outro lugar.").toStdString().c_str()));
                }

            }


        }

    }

    populaListaPersonagem();
}
Esempio n. 5
0
void CPreGame::StartServer(const std::string& setupscript)
{
	assert(!gameServer);
	ScopedOnceTimer startserver("PreGame::StartServer");
	GameData* startupData = new GameData();
	CGameSetup* setup = new CGameSetup();
	setup->Init(setupscript);

	startupData->SetRandomSeed(static_cast<unsigned>(gu->usRandInt()));

	if (setup->mapName.empty()) {
		throw content_error("No map selected in startscript");
	}

	// We must map the map into VFS this early, because server needs the start positions.
	// Take care that MapInfo isn't loaded here, as map options aren't available to it yet.
	vfsHandler->AddArchiveWithDeps(setup->mapName, false);

	// Loading the start positions executes the map's Lua.
	// This means start positions can NOT be influenced by map options.
	// (Which is OK, since unitsync does not have map options available either.)
	setup->LoadStartPositions();

	const std::string& modArchive = archiveScanner->ArchiveFromName(setup->modName);
	const std::string& mapArchive = archiveScanner->ArchiveFromName(setup->mapName);
	startupData->SetModChecksum(archiveScanner->GetArchiveCompleteChecksum(modArchive));
	startupData->SetMapChecksum(archiveScanner->GetArchiveCompleteChecksum(mapArchive));

	good_fpu_control_registers("before CGameServer creation");
	startupData->SetSetup(setup->gameSetupText);
	gameServer = new CGameServer(settings->hostIP, settings->hostPort, startupData, setup);
	delete startupData;
	gameServer->AddLocalClient(settings->myPlayerName, SpringVersion::GetFull());
	good_fpu_control_registers("after CGameServer creation");
}
Esempio n. 6
0
Sprite::Sprite(string *nomeArquivo, Vector2 *pos, int nframes, int spacing) {
	animationSurfaces = (std::vector<SDL_Surface*>***) calloc(1, sizeof(std::vector<SDL_Surface*>**));
	animationSurfaces[0] = (std::vector<SDL_Surface*>**) calloc(1, sizeof(std::vector<SDL_Surface*>));

	SDL_Surface *animationSheet;
	int stepX, stepY;
	GameData *gameData = GameData::getInstance();


	animationSheet = gameData->loadIMG(nomeArquivo->c_str());

	if(animationSheet == NULL) {
		fprintf(stderr, "Arquivo %s n encontrado. Abortando... \n", nomeArquivo->c_str());
		exit(1);
	}



	stepX = (animationSheet->w - spacing*(nframes - 1))/nframes;
	stepY = (animationSheet->h);

	int k = 0;
	for(k = 0; k < nframes; k++) {
		animationSurfaces[0][0]->at(k) = cropAnimationSheet(animationSheet, k, 0, stepX, stepY);
	}


	SDL_FreeSurface(animationSheet);
}
Esempio n. 7
0
void EventsWidget::on_pushButtonNewVar_pressed()
{
    NewVariableDialog *newVariableDialog = new NewVariableDialog(NULL, this);
    newVariableDialog->setWindowTitle(QString::fromUtf8(tr("Nova variável").toStdString().c_str()));

    VariableData *variableData = newVariableDialog->exec();

    if(variableData != NULL) {
        GameObject *gameObject = (GameObject*)
            ui->comboBoxTarget->itemData(ui->comboBoxTarget->currentIndex(), Qt::UserRole).value<void*>();



        if(gameObject != NULL) {
            gameObject->addVariable(variableData);
        } else {
            GameData *gameData = GameData::getInstance();
            gameData->addVariable(variableData);
        }

        QListWidgetItem *itemVariable = new QListWidgetItem(QString(variableData->name.c_str()));
        itemVariable->setData(Qt::UserRole, QVariant::fromValue((void*) variableData));

        ui->listWidgetVariables->addItem(itemVariable);



    }
}
Esempio n. 8
0
GameData::GameData(const GameData &src)
{
    this->m_field = new PlayingField(*(src.GetField()));
    this->m_history = new HistorySave(*(src.GetHistory()));
    this->m_player1 = new Player(*(src.GetPlayer1()));
    this->m_player2 = new Player(*(src.GetPlayer2()));
    this->m_currentPlayer = src.GetCurrentPlayer()->GetColor() == this->m_player1->GetColor() ? this->m_player1 : this->m_player2;
}
Esempio n. 9
0
void Obstacle::render(GameData &data)
{
	if (obsType == COLUMN) 
		data.renderModel(GameData::COLUMN_MODEL_INDEX, getXPosition(), getYPosition(), getZPosition(), getYAngle(), 0.0f, 2.0f);
	else if (obsType == BARREL)
		data.renderModel(GameData::BARREL_MODEL_INDEX, getXPosition(), getYPosition(), getZPosition(), getYAngle(), 0.0f, 2.0f);
	if (DEBUG) renderBoundingCilinder();
}
Esempio n. 10
0
int main(int argv, char *args[])
{
	if(game.Setup() < 0)
		return -1;
	game.Run();
	game.Shutdown();
	return 0;
}
Esempio n. 11
0
void CPreGame::StartServer(const std::string& setupscript)
{
	assert(!gameServer);
	GameData* startupData = new GameData();
	CGameSetup* setup = new CGameSetup();
	setup->Init(setupscript);

	startupData->SetRandomSeed(static_cast<unsigned>(gu->usRandInt()));
	if (! setup->mapName.empty())
	{
		// would be better to use MapInfo here, but this doesn't work
		LoadMap(setup->mapName); // map into VFS
		std::string mapDefFile;
		const std::string extension = setup->mapName.substr(setup->mapName.length()-3);
		if (extension == "smf")
			mapDefFile = std::string("maps/")+setup->mapName.substr(0,setup->mapName.find_last_of('.'))+".smd";
		else if(extension == "sm3")
			mapDefFile = string("maps/")+setup->mapName;
		else
			throw std::runtime_error("CPreGame::StartServer(): Unknown extension: " + extension);

		MapParser mp(setup->mapName);
		LuaTable mapRoot = mp.GetRoot();
		const std::string mapWantedScript = mapRoot.GetString("script",     "");
		const std::string scriptFile      = mapRoot.GetString("scriptFile", "");

		if (!mapWantedScript.empty()) {
			setup->scriptName = mapWantedScript;
		}
	}
	// here we now the name of the script to use

	CScriptHandler::SelectScript(setup->scriptName);
	std::string scriptWantedMod;
	scriptWantedMod = CScriptHandler::Instance().chosenScript->GetModName();
	if (!scriptWantedMod.empty()) {
		setup->modName = archiveScanner->ModArchiveToModName(scriptWantedMod);
	}
	LoadMod(setup->modName);

	std::string modArchive = archiveScanner->ModNameToModArchive(setup->modName);
	startupData->SetModChecksum(archiveScanner->GetModChecksum(modArchive));

	std::string mapFromScript = CScriptHandler::Instance().chosenScript->GetMapName();
	if (!mapFromScript.empty() &&  setup->mapName != mapFromScript) {
		//TODO unload old map
		LoadMap(mapFromScript, true);
	}

	startupData->SetMapChecksum(archiveScanner->GetMapChecksum(setup->mapName));
	setup->LoadStartPositions();

	good_fpu_control_registers("before CGameServer creation");
	startupData->SetSetup(setup->gameSetupText);
	gameServer = new CGameServer(settings.get(), false, startupData, setup);
	gameServer->AddLocalClient(settings->myPlayerName, SpringVersion::GetFull());
	good_fpu_control_registers("after CGameServer creation");
}
Esempio n. 12
0
bool Matrix::init(){

	if (!Layer::init()){
		return false;
	}

	auto GUI = CSLoader::createNode("MatrixLayer.csb");
	this->addChild(GUI, -1);

	time = static_cast<Text*>(GUI->getChildByName("Text_Time"));
	scores = static_cast<Text*>(GUI->getChildByName("Text_Scores"));

	deal = static_cast<Button*>(GUI->getChildByName("Button_Deal"));
	deal->addTouchEventListener(CC_CALLBACK_2(Matrix::dealEvent, this));

	promot = static_cast<Button*>(GUI->getChildByName("Button_Promot"));
	promot->addTouchEventListener(CC_CALLBACK_2(Matrix::promotEvent, this));

	leave = static_cast<Button*>(GUI->getChildByName("Button_Leave"));
	leave->addTouchEventListener(CC_CALLBACK_2(Matrix::leaveEvent, this));

	cancel = static_cast<Button*>(GUI->getChildByName("Button_Cancel"));
	cancel->addTouchEventListener(CC_CALLBACK_2(Matrix::cancelEvent, this));

	back = static_cast<Button*>(GUI->getChildByName("Button_Return"));
	back->addTouchEventListener(CC_CALLBACK_2(Matrix::backEvent, this));

	Size visibleSize = Director::getInstance()->getVisibleSize();
	SpriteFrameCache::getInstance()->addSpriteFramesWithFile("poker.plist");

	GameData* gd = GameData::getInstance();

	this->scheduleUpdate();

	for (int i = 0; i < 10; i++){
		vector<Card*> temp;
		_matrix.push_back(temp);
	}

	//加载牌
	loadCards(_res, gd->getHard());
	//洗牌
	shuffleCards(_res);
	shuffleCards(_res);
	//发牌
	for (int i = 0; i < 5; i++){
		dealCards(10, false, true);
	}

	dealCards(4, false, true);
	for (int i = 0; i < 10; i++){
		_matrix.at(i).back()->change();
	}

	this->setTouchEnabled(true);
	return true;
}
Esempio n. 13
0
void TileSet::reloadTilesetImage() {
    GameData *gameData = GameData::getInstance();

    printf("ProjectDirectory: %s\n", gameData->getProjectDirectory().c_str());

    printf("t:: %s\n", gameData->getProjectDirectory().append("/").append(file).c_str());

    tilesetImage = getTilesetAlphaImage(true);


}
Esempio n. 14
0
Window::Window(const char *_title, unsigned int _width, unsigned int _height, bool _fullscreen) : title(_title), fullscreen(_fullscreen), width(_width), height(_height)
{
	GameData		*gameData = GameData::getInstance();

	if (this->width == 0)
		this->width = gameData->getWidth();
	if (this->height == 0)
		this->height = gameData->getHeight();

	this->window.setKeyRepeatEnabled(false);
}
Esempio n. 15
0
bool Career::getHomePlacementFlag(void)
{
    GameData* gameData = getGameData( "HPF" );
    if( !gameData )
    {
        gameData = new GameData( sizeof(bool) );
        *reinterpret_cast<bool*>(gameData->getData()) = false;
        addGameData( "HPF", gameData );
    }
    return *reinterpret_cast<bool*>(gameData->getData());
}
Esempio n. 16
0
bool Career::getLicensedFlag(void)
{
    GameData* gameData = getGameData( "LCF" );
    if( !gameData )
    {
        gameData = new GameData( sizeof(bool) );
        *reinterpret_cast<bool*>(gameData->getData()) = false;
        addGameData( "LCF", gameData );
    }
    return *reinterpret_cast<bool*>(gameData->getData());
}
Esempio n. 17
0
void TestAttal::testGameData()
{
    GameData * data = new GameData();
    GenericBase * base = data->getNewBase( 1 );
    base->setId( 1 );
    GameData * data2 = new GameData(*data);
    GenericBase * base2 = data2->getBaseById( 1 );
    QCOMPARE( base, base2 );
    GameData data3(*data);
    GenericBase * base3 = data3.getBaseById( 1 );
    QCOMPARE( base, base3 );
}
Esempio n. 18
0
bool Career::getAcrobaticsSkill(Acrobatics skill)
{
    GameData* gameData = getGameData( actobaticsGameData );
    if( !gameData )
    {
        // create gamedata for acrobatics and reset its contents
        gameData = new GameData( sizeof(unsigned int) );
        memset( gameData->getData(), 0, gameData->getSize() );
        addGameData( actobaticsGameData, gameData );
    }
    unsigned int bitset = *reinterpret_cast<unsigned int*>( gameData->getData() );
    return ( bitset & skill ) != 0;
}
void ObjectStateUpdateSystem::serveShooting( Ship * shooter, GameData &mGameData )
{
	if( shooter->isShooting() == true)	
	{
		//get player's data required to create new bullet
		Ogre::Quaternion playerOrientation = shooter->getOrientation();
		Ogre::Vector3 playerPos = shooter->getPosition();

		Bullet* newBullet = mGameData.instantiateBullet(shooter->getBulletIDFromActiveWeapon());
		//set player pos
		newBullet->setPosition(playerPos);
		//set player orientation
		newBullet->setOrientation(playerOrientation);
		//set owner
		newBullet->setOwner(shooter);
		//set time to live
		newBullet->getTTLComponent().setTimeToLive(3.0);
		//set speed
		newBullet->setTargetVelocityValue( 1.0 );
		newBullet->setCurrentSpeedToMax(newBullet->getForwardVector() );

		//set shooting as false
		shooter->unsetShoot();
	}
}
Esempio n. 20
0
void NetworkSaver::send_event(GameData data, signed int number_of_attempts) {
	bool success = false;
	signed int counter = 1;

	//Format data
	std::string formatted_event_data;
	formatted_event_data = data.to_json();
	//formatted_event_data = data.to_xml();

	if (not gloB->exposer_offline_mode) {
		while ((counter <= number_of_attempts) and (not success) and (not gloB->exposer_offline_mode))
		{
			//ostringstream tmpmsg;
			//tmpmsg << "Attempt number " << counter;
			//Log::log(Log::INFO, tmpmsg.str());
			try {
				send_event_attempt(formatted_event_data);
				success = true;
			}
			catch (std::exception &ex) {
				ostringstream tmpmsg;
				tmpmsg << "Exception in attempt #"<< counter <<": " << ex.what();
				Log::log(Log::ERROR, tmpmsg.str());
				counter++;
				//break;
			}
		}
	}
}
Esempio n. 21
0
void BackgroundsGraphicsScene::setBackground(Background *background) {
    GameData *gameData = GameData::getInstance();
    this->background = background;


    if(background != NULL) {
        for(std::vector<QGraphicsPixmapItem*>::iterator it = pixmapItems.begin(); it != pixmapItems.end(); ++it) {
            QGraphicsPixmapItem *graphisPixmapItem = *it;
            delete graphisPixmapItem;
        }

        pixmapItems.clear();

        for(std::vector<BgLayer*>::iterator it = background->layerList->begin(); it != background->layerList->end(); ++it) {
           BgLayer *bgLayer = *it;

           QGraphicsPixmapItem *graphicsPixmapItem = new QGraphicsPixmapItem(QPixmap(QString(gameData->getProjectDirectory().append("/").append(bgLayer->fileName).c_str())));
           pixmapItems.push_back(graphicsPixmapItem);

           graphicsPixmapItem->setPos(bgLayer->displacementX, bgLayer->displacementY);

           addItem(graphicsPixmapItem);
       }

        this->update();
    }



}
Esempio n. 22
0
void	PlayerStatusBars :: Update (GameData& GlobalGameData)
{
	PlayerDatabase* playerDb = GlobalGameData.GetPlayerDatabase();
	player = playerDb->GetCurrentPlayer ();
	
	if (player == NULL)
	{
		PlayerName.clear();
		NumberOfStationsBeingTracked = 0;
	}
	else
	{
		PlayerName = player->GetName();
		NumberOfStationsBeingTracked = player->GetNumStations();
		ShipArchetype* ship = player->GetShip ();
		PlayerShipTracking = static_cast<float>( ship->GetHealth () );
		PlayerShipShieldTracking = static_cast<float>( ship->GetShieldLevel () );
		
		for (int i=0; i<NumberOfStationsBeingTracked; i++)
		{
			SpaceStation* station = player->GetStation(i);
			StationTracking[i] = static_cast<float>( station->GetHealth () );
			StationShieldTracking[i] = static_cast<float>( station->GetShieldLevel () );
		}
	}
}
Esempio n. 23
0
	void Draw() {
		device->CreateStateBlock(D3DSBT_ALL, &state);
		state->Capture();
		device->SetVertexShader(nullptr);
		// draw
		try {
			if (memory.UpdateAll()) {
				device->GetCreationParameters(&cparams);
				GetClientRect(cparams.hFocusWindow, &gameWindow);
				if (gameWindow.bottom / 1080.0 != heightModifier || gameWindow.right / 1920.0 != widthModifier) {
					heightModifier = gameWindow.bottom / 1080.0;
					widthModifier = gameWindow.right / 1920.0;
					D3DXCreateFont(device, (int)(40 * heightModifier * (heightModifier + .75 * (1 - heightModifier))), 0, FW_NORMAL, 1, false, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, 5, DEFAULT_PITCH | FF_DONTCARE, L"Verdana", &pFont);
					int left = (int)(855 * widthModifier);
					int top = (int)(304 * heightModifier);
					int right = (int)(left + 285 * widthModifier);
					int bottom = (int)(top + 50 * heightModifier);
					rectangle = { left, top, right, bottom };
					textrect = { left, top, right, bottom };
				}
				if (memory.IsOnEndScreen.Current()) {
					DrawIGTRectangle();
					DrawIGT();
				}
			}
		}
		catch (...) {
			pFont->DrawTextA(NULL, "Exception", -1, &textrect, DT_CENTER, textColor);
		}
		//release
		state->Apply();
		state->Release();
	}
Esempio n. 24
0
void	Viewport :: Update (GameData& data)
{
	PlayerDatabase* playerdb = data.GetPlayerDatabase();
	if (playerdb != NULL)
	{
		UUID CurrentPLayerID  = playerdb->GetCurrentPlayerID();
		Player* player = playerdb->GetPlayer (CurrentPLayerID);
		
		Vector v = player->GetViewFocus ();
		v.z += NormalZDepth;
		SetCameraPosition(v);
	}
	
	float	ViewAngle = 0.11f;// simply for setting the proper frustum
	glFrustum (-ViewAngle, ViewAngle, -ViewAngle, ViewAngle, 0.1, 9000);
	
	// I can't express how important setting the Frustrum before rotating and translating is.
	// We will end up with very strange clipping in 3-space if we don't keep these
	// ordered thusly.
	Vector LookAt = -CameraAngle;
	glRotated (LookAt.pitch, 1.0, 0, 0);
	glRotated (LookAt.yaw, 0, 1.0, 0);
	glRotated (LookAt.roll, 0, 0, 1.0);		
	
	glTranslated (-Position.x, -Position.y, -Position.z);
	
}
Esempio n. 25
0
void Career::setAcrobaticsSkill(Acrobatics skill, bool isLearned)
{
    GameData* gameData = getGameData( actobaticsGameData );
    if( !gameData )
    {
        // create gamedata for acrobatics and reset its contents
        gameData = new GameData( sizeof(unsigned int) );
        memset( gameData->getData(), 0, gameData->getSize() );
        addGameData( actobaticsGameData, gameData );
    }

    // modify flag
    unsigned int bitset = *reinterpret_cast<unsigned int*>( gameData->getData() );
    if( isLearned ) bitset = bitset | skill; else bitset = bitset & ~skill;
    memcpy( gameData->getData(), &bitset, sizeof(unsigned int) );
}
Esempio n. 26
0
//---------------------------------------------------------
void			ProjectileMgr :: ProcessMessages (GameData& GlobalGameData)//inherited, send all messages to the appropriate players
{
	PlayerDatabase* playerdb = GlobalGameData.GetPlayerDatabase();
	
	int NumMessages = ReceiveQueue.Count ();
	for (int i=0; i<NumMessages; i++)
	{
		const Events::GameEvent* msg = reinterpret_cast <const Events::GameEvent*> (ReceiveQueue.Dequeue());
		switch (msg->GetType())
		{
			case Events :: FireWeapon:
			{
				const Events::FireWeaponEvent* fw = reinterpret_cast <const Events::FireWeaponEvent*> (msg);
				UUID PlayerID = fw->GetPlayerID ();
				Player* p = playerdb->GetPlayer(PlayerID);
				if (p)
				{
					ShipArchetype* ship = p->GetShip();
					if (ship)
					{
						AddBolt (*ship, PlayerID);
					}
				}
			}
			break;
		}
	}
	
}
void ObjectStateUpdateSystem::removeDeadObjects( GameData& mGameData)
{
	static int counter = 0;
	auto iterator = mGameData.getColidingObjectsIterator();
	GameObject_WithCollider * removedObject;
	iterator.skipPlayer();
	counter++;
	while (iterator.hasNext())
	{
		removedObject = iterator.getNext();
		if (removedObject->isDead())
		{
			createExplosionFor(removedObject, mGameData);
			mGameData.removeGameObject(iterator);
		}
	}
}
void ObjectStateUpdateSystem::updateShooting( GameData &mGameData )
{
	//creating bullets when player is shooting
	Player * player = mGameData.getPlayer();
	if (player != NULL)
	{
		serveShooting(player, mGameData);
	}

	//parsing through enemies
	GameCollectionIterator<EnemyObject> enemyIterator = mGameData.getEnemies().getIterator();
	EnemyObject* enemyIt;
	while (enemyIterator.hasNext())
	{
		enemyIt = enemyIterator.getNext();
		serveShooting(enemyIt, mGameData);
	}
}
Esempio n. 29
0
void Career::setMissionWalkthroughFlag(unsigned int tournamentId, unsigned int missionId, bool flag)
{
    // this feature is not available for demo tournament
    if( tournamentId == database::TournamentInfo::getDemoTournament() ) return;

    // retrieve tournament record
    database::TournamentInfo* tournamentInfo = database::TournamentInfo::getRecord( tournamentId );

    // check mission index is valid
    assert( missionId < tournamentInfo->getNumMissions() );

    // retrieve correspoding gamedata
    GameData* gameData = getGameData( tournamentInfo->gameData ); assert( gameData );
    Bitfield32* bitfield = reinterpret_cast<Bitfield32*>( gameData->getData() );

    // save result
    bitfield->setBit( missionId, flag );
}
Esempio n. 30
0
void				Window::callGameplay()
{
	GameData		*gameData = GameData::getInstance();
	sf::Event		event;

	while (this->window.pollEvent(event))
	{
		if (event.type == sf::Event::Closed || gameData->getMustQuit())
			this->window.close();
		if (gameData->getFullscreen() != this->fullscreen)
			this->switchFullscreen();
		if (event.type == sf::Event::KeyPressed)
			this->gameplay->keyPressed(event.key.code);
	}
	this->gameplay->updateLogic(&this->time);
	this->gameplay->updateGraphics();
	this->time = deltaClock.restart();
}