Exemplo n.º 1
0
void BF3Widget::startupCommands(bool authenticated)
{
    // Misc
    con->sendVersionCommand();
    con->sendServerInfoCommand();

    if (authenticated) {
//        con->sendAdminEventsEnabledCommand(true);

        // Admins
//        con->sendAdminListPlayersCommand(All);

        // Banning

        // Maplist

        // Player

        // Punkbuster
//        con->sendPunkBusterIsActive();
//        con->sendPunkBusterPbSvCommand("pb_sv_plist");

        // Reserved Slots

        // Spectator list

        // Squad

        // Variables

    } else {
        timerPlayerList->stop();
        connect(timerPlayerList, SIGNAL(timeout()), this, SLOT(updatePlayerList()));
        timerPlayerList->start(1000);
    }
}
Exemplo n.º 2
0
void EnMapView::setupMapView()
{
    // get the screen size
    unsigned int windowwidth  = 600;
    unsigned int windowheight = 800;
    yaf3d::Application::get()->getScreenSize( windowwidth, windowheight );
    _screenSize = osg::Vec2f( static_cast< float >( windowwidth ), static_cast< float >( windowheight ) );

    // calculate internal variables
    _factor   = osg::Vec2f( ( 1.0f / _levelDimensions.x() ) * _stretch.x(), ( 1.0f / _levelDimensions.y() ) * _stretch.y() );
    _halfSize = osg::Vec2f( _size * 0.5f );

    try
    {
        // calculate position of view map
        osg::Vec2 position = calcPosition( _align, _size, _screenSize );
        _snapPoints = calcSnapPoints( _size, _screenSize );

        _p_wnd = CEGUI::WindowManager::getSingleton().createWindow( "DefaultWindow", MAPVIEW_WND "mainWnd" );
        _p_wnd->setMetricsMode( CEGUI::Absolute );
        _p_wnd->setSize( CEGUI::Size( _size.x(), _size.y() ) );
        _p_wnd->setPosition( CEGUI::Point( position.x(), position.y() ) );
        _p_wnd->setAlpha( _alpha );
        _p_wnd->setAlwaysOnTop( true );
        _p_wnd->subscribeEvent( CEGUI::Window::EventMouseButtonDown, CEGUI::Event::Subscriber( &vrc::EnMapView::onMouseDown, this ) );
        _p_wnd->subscribeEvent( CEGUI::Window::EventMouseButtonUp,   CEGUI::Event::Subscriber( &vrc::EnMapView::onMouseUp,   this ) );
        _p_wnd->subscribeEvent( CEGUI::Window::EventMouseMove,       CEGUI::Event::Subscriber( &vrc::EnMapView::onMouseMove, this ) );

        // put the map picture into a static image element
        CEGUI::StaticImage* p_staticimg = static_cast< CEGUI::StaticImage* >( CEGUI::WindowManager::getSingleton().createWindow( "TaharezLook/StaticImage", MAPVIEW_WND "image" ) );
        p_staticimg->setSize( CEGUI::Size( 1.0f, 1.0f ) );
        p_staticimg->setPosition( CEGUI::Point( 0.0f, 0.0f ) );
        p_staticimg->setBackgroundEnabled( false );
        p_staticimg->setFrameEnabled( false );
        p_staticimg->setAlpha( _alpha );
        // create a new imageset for map picture
        {
            CEGUI::Texture*  p_texture = yaf3d::GuiManager::get()->getGuiRenderer()->createTexture( _minMapFile, std::string( MAPVIEW_WND ) + _minMapFile );
            CEGUI::Imageset* p_imageSet = CEGUI::ImagesetManager::getSingleton().createImageset( std::string( MAPVIEW_WND ) + _minMapFile, p_texture );
            if ( !p_imageSet->isImageDefined( _minMapFile ) )
                p_imageSet->defineImage( std::string( MAPVIEW_WND ) + _minMapFile, CEGUI::Point( 0.0f, 0.0f ), CEGUI::Size( p_texture->getWidth(), p_texture->getHeight() ), CEGUI::Point( 0.0f,0.0f ) );

            CEGUI::Image* p_image = &const_cast< CEGUI::Image& >( p_imageSet->getImage( std::string( MAPVIEW_WND ) + _minMapFile ) );
            p_staticimg->setImage( p_image );
            _p_wnd->addChildWindow( p_staticimg );
        }

        // create a static text for displaying player name when mouse is over its point on map
        {
            _nameDisplay = static_cast< CEGUI::StaticText* >( CEGUI::WindowManager::getSingleton().createWindow( "TaharezLook/StaticText", MAPVIEW_WND "playername" ) );
            _nameDisplay->setMetricsMode( CEGUI::Absolute );
            _nameDisplay->setFrameEnabled( false );
            _nameDisplay->setBackgroundEnabled( false );
            _nameDisplay->setFont( YAF3D_GUI_FONT8 );
            _nameDisplay->setTextColours( CEGUI::colour( _nameDisplayColor.x(), _nameDisplayColor.y(), _nameDisplayColor.z() ) );
            _nameDisplay->setPosition( CEGUI::Point( _nameDisplayPos.x(), _nameDisplayPos.y() ) );
            _nameDisplay->setSize( CEGUI::Size( _nameDisplaySize.x(), _nameDisplaySize.y() ) );
            _nameDisplay->setAlwaysOnTop( true );

            _p_wnd->addChildWindow( _nameDisplay );
        }

        // image for marking a player on map
        _p_imgPlayerMarker = vrc::gameutils::GuiUtils::get()->getCustomImage( IMAGE_NAME_CROSSHAIR );

        vrc::gameutils::GuiUtils::get()->getMainGuiWindow()->addChildWindow( _p_wnd );

        // update the map
        updatePlayerList();
        updateMap();
    }
    catch ( const CEGUI::Exception& e )
    {
        log_error << "EnMapView: problem creating gui" << std::endl;
        log_out << "      reason: " << e.getMessage().c_str() << std::endl;
    }
}
Exemplo n.º 3
0
void EnMapView::onPlayerListChanged( bool /*localplayer*/, bool /*joining*/, yaf3d::BaseEntity* /*p_entity*/ )
{
    updatePlayerList();
}
Exemplo n.º 4
0
int Mineserver::run(int argc, char *argv[])
{
  uint32 starttime = (uint32)time(0);
  uint32 tick      = (uint32)time(0);

  // Init our Screen
  screen()->init(VERSION);
  screen()->log("Welcome to Mineserver v" + VERSION);
  updatePlayerList();

  initConstants();

  std::string file_config;
  file_config.assign(CONFIG_FILE);
  std::string file_commands;
  file_commands.assign(COMMANDS_FILE);

  if (argc > 1)
  {
    file_config.assign(argv[1]);
  }

  // Initialize conf
  Mineserver::get()->conf()->load(file_config);
  Mineserver::get()->conf()->load(file_commands, COMMANDS_NAME_PREFIX);

  // Write PID to file
  std::ofstream pid_out((Mineserver::get()->conf()->sValue("pid_file")).c_str());
  if (!pid_out.fail())
  {
#ifdef WIN32
     pid_out << _getpid();
#else
     pid_out << getpid();
#endif
  }
  pid_out.close();

  // Load MOTD
  Mineserver::get()->chat()->checkMotd(Mineserver::get()->conf()->sValue("motd_file"));

  // Set physics enable state according to config
  Mineserver::get()->physics()->enabled = (Mineserver::get()->conf()->bValue("liquid_physics"));

  // Initialize map
  Mineserver::get()->map()->init();

  if (Mineserver::get()->conf()->bValue("map_generate_spawn"))
  {
    Mineserver::get()->screen()->log("Generating spawn area...");
    int size = Mineserver::get()->conf()->iValue("map_generate_spawn_size");
    bool show_progress = Mineserver::get()->conf()->bValue("map_generate_spawn_show_progress");
#ifdef WIN32
    DWORD t_begin,t_end;
#else
    clock_t t_begin,t_end;
#endif

    for (int x=-size;x<=size;x++)
    {
#ifdef WIN32
      if(show_progress)
      {
        t_begin = timeGetTime();
      }
#else
      if(show_progress)
      {
        t_begin = clock();
      }
#endif
      for (int z = -size; z <= size; z++)
      {
        Mineserver::get()->map()->loadMap(x, z);
      }

      if(show_progress)
      {
#ifdef WIN32
        t_end = timeGetTime ();
        Mineserver::get()->screen()->log(dtos((x+size+1)*(size*2+1)) + "/" + dtos((size*2+1)*(size*2+1)) + " done. " + dtos((t_end-t_begin)/(size*2+1)) + "ms per chunk");
#else
        t_end = clock();
        Mineserver::get()->screen()->log(dtos((x+size+1)*(size*2+1)) + "/" + dtos((size*2+1)*(size*2+1)) + " done. " + dtos(((t_end-t_begin)/(CLOCKS_PER_SEC/1000))/(size*2+1)) + "ms per chunk");
#endif
      }
    }
#ifdef _DEBUG
    Mineserver::get()->screen()->log("Spawn area ready!");
#endif
  }

  // Initialize packethandler
  Mineserver::get()->packetHandler()->init();

  // Load ip from config
  std::string ip = Mineserver::get()->conf()->sValue("ip");

  // Load port from config
  int port = Mineserver::get()->conf()->iValue("port");

  // Initialize plugins
  Mineserver::get()->plugin()->init();

#ifdef WIN32
  WSADATA wsaData;
  int iResult;
  // Initialize Winsock
  iResult = WSAStartup(MAKEWORD(2, 2), &wsaData);
  if(iResult != 0)
  {
    printf("WSAStartup failed with error: %d\n", iResult);
    Mineserver::get()->screen()->end();
    return EXIT_FAILURE;
  }
#endif

  struct sockaddr_in addresslisten;
  int reuse = 1;

  m_eventBase = (event_base*)event_init();
#ifdef WIN32
  m_socketlisten = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
#else
  m_socketlisten = socket(AF_INET, SOCK_STREAM, 0);
#endif

  if(m_socketlisten < 0)
  {
    Mineserver::get()->screen()->log(LOG_ERROR, "Failed to create listen socket");
    Mineserver::get()->screen()->end();
    return 1;
  }

  memset(&addresslisten, 0, sizeof(addresslisten));

  addresslisten.sin_family      = AF_INET;
  addresslisten.sin_addr.s_addr = inet_addr(ip.c_str());
  addresslisten.sin_port        = htons(port);

  setsockopt(m_socketlisten, SOL_SOCKET, SO_REUSEADDR, (char*)&reuse, sizeof(reuse));

  //Bind to port
  if(bind(m_socketlisten, (struct sockaddr*)&addresslisten, sizeof(addresslisten)) < 0)
  {
    Mineserver::get()->screen()->log(LOG_ERROR, "Failed to bind");
    return 1;
  }

  if(listen(m_socketlisten, 5) < 0)
  {
    Mineserver::get()->screen()->log(LOG_ERROR, "Failed to listen to socket");
    Mineserver::get()->screen()->end();
    return 1;
  }

  setnonblock(m_socketlisten);
  event_set(&m_listenEvent, m_socketlisten, EV_WRITE|EV_READ|EV_PERSIST, accept_callback, NULL);
  event_add(&m_listenEvent, NULL);

  if(ip == "0.0.0.0")
  {
    // Print all local IPs
    char name[255];
    gethostname ( name, sizeof(name));
    struct hostent* hostinfo = gethostbyname(name);
    Mineserver::get()->screen()->log("Listening on: ");
    int ipIndex = 0;
    while(hostinfo && hostinfo->h_addr_list[ipIndex])
    {
      std::string ip(inet_ntoa(*(struct in_addr*)hostinfo->h_addr_list[ipIndex++]));
      Mineserver::get()->screen()->log(" " + ip + ":" + dtos(port));
    }
  }
  else
  {
    std::string myip(ip);
    Mineserver::get()->screen()->log("Listening on " + myip + ":" + dtos(port));
  }
  //std::cout << std::endl;

  timeval loopTime;
  loopTime.tv_sec  = 0;
  loopTime.tv_usec = 200000; //200ms

  m_running = true;
  event_base_loopexit(m_eventBase, &loopTime);

  // Create our Server Console user so we can issue commands
  User* serverUser = new User(-1, SERVER_CONSOLE_UID);
  serverUser->changeNick("[Server]");

  while(m_running && event_base_loop(m_eventBase, 0) == 0)
  {
    // Append current command and check if user entered return
    if(Mineserver::get()->screen()->hasCommand())
    {
      // Now handle this command as normal
      Mineserver::get()->chat()->handleMsg(serverUser, Mineserver::get()->screen()->getCommand().c_str());
    }

    if(time(0)-starttime > 10)
    {
      starttime = (uint32)time(0);

      //If users, ping them
      if(User::all().size() > 0)
      {
        //0x00 package
        uint8 data = 0;
        User::all()[0]->sendAll(&data, 1);

        //Send server time
        Packet pkt;
        pkt << (sint8)PACKET_TIME_UPDATE << (sint64)Mineserver::get()->map()->mapTime;
        User::all()[0]->sendAll((uint8*)pkt.getWrite(), pkt.getWriteLen());
      }

      // TODO: Run garbage collection for chunk storage dealie?
    }

    //Every second
    if(time(0)-tick > 0)
    {
      tick = (uint32)time(0);
      //Loop users
      for(unsigned int i = 0; i < User::all().size(); i++)
      {
        User::all()[i]->pushMap();
        User::all()[i]->popMap();

        //Minecart hacks!!
        /*
        if(User::all()[i]->attachedTo)
        {
          Packet pkt;
          pkt << PACKET_ENTITY_VELOCITY << (sint32)User::all()[i]->attachedTo <<  (sint16)10000       << (sint16)0 << (sint16)0;
          //pkt << PACKET_ENTITY_RELATIVE_MOVE << (sint32)User::all()[i]->attachedTo <<  (sint8)100       << (sint8)0 << (sint8)0;
          User::all()[i]->sendAll((uint8*)pkt.getWrite(), pkt.getWriteLen());
        }
        */
      }

      map()->mapTime+=20;
      if (map()->mapTime >= 24000)
      {
        map()->mapTime = 0;
      }

      map()->checkGenTrees();

      // Check for Furnace activity
      Mineserver::get()->furnaceManager()->update();
    }

    // Physics simulation every 200ms
    Mineserver::get()->physics()->update();

    // Underwater check / drowning
    int i = 0;
    int s = User::all().size();
    for(i=0;i<s;i++)
    {
      User::all()[i]->isUnderwater();
    }

//    event_set(&m_listenEvent, m_socketlisten, EV_WRITE|EV_READ|EV_PERSIST, accept_callback, NULL);
//    event_add(&m_listenEvent, NULL);

    event_base_loopexit(m_eventBase, &loopTime);
  }

#ifdef WIN32
  closesocket(m_socketlisten);
#else
  close(m_socketlisten);
#endif

  // Remove the PID file
#ifdef WIN32
  _unlink((Mineserver::get()->conf()->sValue("pid_file")).c_str());
#else
  unlink((Mineserver::get()->conf()->sValue("pid_file")).c_str());
#endif

  // End our NCurses session
  screen()->end();

  /* Free memory */
  delete m_map;
  delete m_chat;
  delete m_plugin;
  delete m_screen;
  delete m_physics;
  delete m_conf;
  delete m_furnaceManager;
  delete m_packetHandler;
  delete m_mapGen;
  delete m_logger;

  return EXIT_SUCCESS;
}
Exemplo n.º 5
0
//Se llama desde el cliente y es un paquete recibido del servidor
void NetworkEngine::managePacketFromServer( RakNet::Packet * packet )
{
	switch (packet->data[0])
	{
	//Mensajes de Raknet
	case ID_DISCONNECTION_NOTIFICATION:
		removeServerFile();
		close();
	case ID_CONNECTION_LOST:
		close();
		GameManager::getInstance()->changeState(StateMenuMain::getInstance());
		break;
	case ID_INVALID_PASSWORD:
		std::cout << "ERROR: El servidor al que intentabas reconectarte no es el mismo del que hay ahora\n";
		removeServerFile();
		close();
		GameManager::getInstance()->changeState(StateMenuMain::getInstance());
	case ID_UNCONNECTED_PONG:
		lanServerFound(packet);
		break;

	//Nuestros mensajes
	case ID_SERVER_PLAYER_LIST:
		//Recoger jugadores 
		//El problema es como avisa desde aquí al estado para que actualice la GUI
		updatePlayerList(packet);
		break;
	case ID_SERVER_STRING_MESSAGE:
		showMessageFromServer(packet);

		break;
	case ID_SERVER_GAME_STARTING:
		createFileServer();
		if(!waitingForServer) //Parche para que se conecte sin cambiar de estado para Test Online
		{
			GameManager::getInstance()->changeState(StateClientInGame::getInstance());
		}
		waitingForServer = false;
		break;

	case ID_SERVER_YOUR_CHARACTER:
		putTheCharacter(packet);
		break;
	case ID_SERVER_GIVE_EXPERIENCE:
		experienceForPlayers(packet);
		break;
	case ID_GLOBAL_GAMEOBJECT_MESSAGE:
		onGameObjectMessage(packet);
		break;
	case ID_SET_EMPTY:
		setEmpty(packet);
		break;
	case ID_SET_WALL:
		setWall(packet);
		break;
	case ID_GAME_OVER:
		gameOverFromServer(packet);
		break;
	case ID_NEXT_WAVE:
		nextWave(packet);
		break;
	}
}
Exemplo n.º 6
0
int ClientInterface::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
    _id = QMainWindow::qt_metacall(_c, _id, _a);
    if (_id < 0)
        return _id;
    if (_c == QMetaObject::InvokeMetaMethod) {
        switch (_id) {
        case 0: sendMessage(); break;
        case 1: chat((*reinterpret_cast< CLID(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2])),(*reinterpret_cast< QString(*)>(_a[3])),(*reinterpret_cast< ENUM_TYPE(*)>(_a[4]))); break;
        case 2: changeServerInformations((*reinterpret_cast< ServerInformations(*)>(_a[1]))); break;
        case 3: changeClientID((*reinterpret_cast< CLID(*)>(_a[1]))); break;
        case 4: changeClientNickname((*reinterpret_cast< CLID(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 5: showError((*reinterpret_cast< ENUM_TYPE(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 6: changeGameMaster((*reinterpret_cast< CLID(*)>(_a[1]))); break;
        case 7: clientVoted((*reinterpret_cast< CLID(*)>(_a[1])),(*reinterpret_cast< CLID(*)>(_a[2]))); break;
        case 8: connectionEtablished(); break;
        case 9: connectionLost(); break;
        case 10: diceRolled((*reinterpret_cast< CLID(*)>(_a[1])),(*reinterpret_cast< quint16(*)>(_a[2])),(*reinterpret_cast< quint16(*)>(_a[3]))); break;
        case 11: sanctionned((*reinterpret_cast< CLID(*)>(_a[1])),(*reinterpret_cast< ENUM_TYPE(*)>(_a[2])),(*reinterpret_cast< QString(*)>(_a[3]))); break;
        case 12: rollDice(); break;
        case 13: rollSpecialDice(); break;
        case 14: serverName((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 15: motdChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 16: gameLaunched(); break;
        case 17: setTitle(); break;
        case 18: playSound((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 19: updatePlayerList(); break;
        case 20: clientJoined((*reinterpret_cast< CLID(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 21: clientLeft((*reinterpret_cast< CLID(*)>(_a[1]))); break;
        case 22: updateGMLabel(); break;
        case 23: updateGMPanel(); break;
        case 24: { bool _r = addLanguage();
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 25: { bool _r = addLanguage((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< const QString(*)>(_a[2])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 26: languageListMenu((*reinterpret_cast< const QPoint(*)>(_a[1]))); break;
        case 27: { bool _r = removeLanguage((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; }  break;
        case 28: removeLanguageMenu(); break;
        case 29: importLanguageList(); break;
        case 30: sendLanguageList(); break;
        case 31: { CLID _r = CLIDFromString((*reinterpret_cast< const QString(*)>(_a[1])));
            if (_a[0]) *reinterpret_cast< CLID*>(_a[0]) = _r; }  break;
        case 32: switchConnectionState(); break;
        case 33: openSettings(); break;
        case 34: openSoundsGUI(); break;
        case 35: aboutUs(); break;
        case 36: aboutServer(); break;
        case 37: openMapEditor(); break;
        case 38: clearMapEditor(); break;
        case 39: mapFlare(); break;
        case 40: resetData(); break;
        case 41: setCSS((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 42: setCSS(); break;
        case 43: setInterface((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 44: setInterface(); break;
        case 45: playerListMenu((*reinterpret_cast< const QPoint(*)>(_a[1]))); break;
        case 46: actionKick(); break;
        case 47: actionBan(); break;
        case 48: actionVoteGM(); break;
        case 49: actionChangeGM(); break;
        case 50: refresh(); break;
        case 51: textChanged(); break;
        case 52: narrationChanged((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 53: syncSoundLibs((*reinterpret_cast< QList<SoundLibInformations>(*)>(_a[1]))); break;
        case 54: syncLanguagesList((*reinterpret_cast< QList<QPair<QString,QString> >(*)>(_a[1]))); break;
        case 55: syncDictionariesList((*reinterpret_cast< QStringList(*)>(_a[1]))); break;
        case 56: requestScriptDownload((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 57: sendScriptToServer((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 58: deleteScript((*reinterpret_cast< QString(*)>(_a[1]))); break;
        case 59: renameScript((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 60: makeEntity((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 61: deleteEntity((*reinterpret_cast< const QString(*)>(_a[1]))); break;
        case 62: injectCode((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 63: scriptToGMMsg((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 64: scriptToOwnerMsg((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 65: scriptActionMsg((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 66: scriptToPlayerMsg((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 67: scriptMsg((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 68: scriptError((*reinterpret_cast< QString(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break;
        case 69: sendMapToServer((*reinterpret_cast< const MapInformations*const(*)>(_a[1])),(*reinterpret_cast< const QMap<QString,RSID>(*)>(_a[2]))); break;
        case 70: addDictionnary(); break;
        case 71: saveGame(); break;
        case 72: loadGame(); break;
        case 73: VOIPRemoveClient(); break;
        case 74: VOIPAddClient(); break;
        case 75: VOIPClientVolume(); break;
        case 76: dataPerSecond((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break;
        default: ;
        }
        _id -= 77;
    }
    return _id;
}
Exemplo n.º 7
0
 /**
   * Affichage de la fenêtre
   */
 void WaitingWindow::show()
 {
     //On désactive les boutons en fonction de leur utilité.
     _launch->setEnabled(_client->isAdmin());
     _kick->setEnabled(_client->isAdmin());
     //On connecte le signal de Client avec addMessage
     connect(_client,SIGNAL(messageRecevied(QString,QString)),this,SLOT(addMessage(QString,QString)));
     //On connecte le signal de deconnexion du serveur
     connect(_client,SIGNAL(serverHasDisconnected()),this,SLOT(serverHasDisconnected()));
     //On connecte le signal de liste des joueurs
     connect(_client,SIGNAL(playerListHasBeenUpdated(QList<QPair<QString,bool> >)),this,SLOT(updatePlayerList(QList<QPair<QString,bool> >)));
     //On connecte le signal pour le début de partie
     connect(_client,SIGNAL(gameHasBegun()),this,SLOT(handleGameHasBegun()));
     //on affiche la fenêtre.
     QWidget::show();
 }
Exemplo n.º 8
0
void EnMapView::operator()( bool localplayer, bool joining, yaf3d::BaseEntity* p_entity )
{
    updatePlayerList();
}
Exemplo n.º 9
0
        void UpdateAI(uint32 diff) override
        {
            events.Update(diff);
            while (uint32 eventId = events.ExecuteEvent())
            {
                switch(eventId)
                {
                case EVENT_START: //Begin script if playersInvolved is not empty
                {
                    updatePlayerList();
                    if (playersInvolved.empty())
                        events.ScheduleEvent(1, 600);
                    else
                    {
                        me->MonsterSay("Keep those creatures at bay while I meditate. We'll soon have the answers we seek...", LANG_UNIVERSAL, 0);
                        me->SetReactState(REACT_PASSIVE);
                        timer = 0;
                        events.ScheduleEvent(EVENT_SPAWN_MOBS, 5000); //spawn mobs
                        events.ScheduleEvent(EVENT_PROGRESS, 1000); //update time
                        events.ScheduleEvent(EVENT_END, 90000); //end quest
                    }
                    break;
                }
                case EVENT_SPAWN_MOBS: //Spawn 3 mobs
                {
                    updatePlayerList();
                    for(int i = 0; i < std::max((int)playersInvolved.size()*3,3); i++)
                    {
                        if (TempSummon* temp = me->SummonCreature(59637, 1144.55f, 3435.65f, 104.97f, 3.3f,TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000))
                        {
                            if (temp->AI())
                                temp->AI()->AttackStart(me);

                            temp->AddThreat(me, 250.0f);
                            temp->GetMotionMaster()->Clear();
                            temp->GetMotionMaster()->MoveChase(me);
                        }
                    }
                    events.ScheduleEvent(EVENT_SPAWN_MOBS, 20000); //spawn mobs
                    break;
                }
                case EVENT_PROGRESS: //update energy
                {
                    timer++;

                    if (timer == 25 && !lifei)
                    {
                        if (lifei = me->SummonCreature(54856, 1130.162231f, 3435.905518f, 105.496597f, 0.0f,TEMPSUMMON_MANUAL_DESPAWN))
                            lifei->MonsterSay("The way of the Tushui... enlightenment through patience and mediation... the principled life", LANG_UNIVERSAL, 0);
                    }

                    if (timer == 30)
                        if (lifei)
                            lifei->MonsterSay("It is good to see you again, Aysa. You've come with respect, and so I shall give you the answers you seek.", LANG_UNIVERSAL, 0);

                    if (timer == 42)
                        if (lifei)
                            lifei->MonsterSay("Huo, the spirit of fire, is known for his hunger. He wants for tinder to eat. He needs the caress of the wind to rouse him.", LANG_UNIVERSAL, 0);

                    if (timer == 54)
                        if (lifei)
                            lifei->MonsterSay("If you find these things and bring them to his cave, on the far side of Wu-Song Village, you will face a challenge within.", LANG_UNIVERSAL, 0);

                    if (timer == 66)
                        if (lifei)
                            lifei->MonsterSay("Overcome that challenge, and you shall be graced by Huo's presence. Rekindle his flame, and if your spirit is pure, he shall follow you.", LANG_UNIVERSAL, 0);

                    if (timer == 78)
                        if (lifei)
                            lifei->MonsterSay("Go, children. We shall meet again very soon.", LANG_UNIVERSAL, 0);

                    if (timer == 85)
                    {
                        if (lifei)
                            lifei->UnSummon();

                        lifei = NULL;
                    }

                    updatePlayerList();
                    for (auto player: playersInvolved)
                    {
                        if (!player->HasAura(116421))
                            player->CastSpell(player, 116421);

                        player->ModifyPower(POWER_ALTERNATE_POWER, timer/25);
                        player->SetMaxPower(POWER_ALTERNATE_POWER, 90);
                    }

                    events.ScheduleEvent(EVENT_PROGRESS, 1000);
                    break;
                }
                case EVENT_END: //script end
                {
                    if (lifei)
                    {
                        lifei->UnSummon();
                        lifei = NULL;
                    }
                    events.ScheduleEvent(EVENT_START, 10000);
                    events.CancelEvent(EVENT_SPAWN_MOBS);
                    events.CancelEvent(EVENT_PROGRESS);
                    me->MonsterSay("And so our path lays before us. Speak to Master Shang Xi, he will tell you what comes next.", LANG_UNIVERSAL, 0);
                    updatePlayerList();
                    me->SetReactState(REACT_DEFENSIVE);
                    for(auto player: playersInvolved)
                    {
                        player->KilledMonsterCredit(54856, 0);
                        player->RemoveAura(116421);
                    }
                    break;
                }
                }
            }
        }