GHost++ : ajout de quelques fonctions intéressantes
Par PiR le mercredi, 20 mai 2009, 15:45 - Jeux - Lien permanent
Démarrer le compte à rebours de 10 au lieu de 5
Fichier : game_base.cpp
Fonction : void CBaseGame :: StartCountDown( bool force )
Modification :
2 fois dans la fonction, au début et à la fin, on remplace :
m_CountDownCounter = 5;
par :
m_CountDownCounter = 10;
Empêcher le compte à rebours si tous les slots ne sont pas remplis
Fichier : game_base.cpp
Fonction : void CBaseGame :: StartCountDown( bool force )
Modification :
Le début de la fonction est modifié de :
{ if( !m_CountDownStarted ) { if( force ) { m_CountDownStarted = true; m_CountDownCounter = 5; } else { // check if everyone has the map string StillDownloading;
en :
{ if( !m_CountDownStarted ) { if( force ) { m_CountDownStarted = true; m_CountDownCounter = 10; } else { // ajout pir // verifie qu'il n'y a pas de slot ouvert if( GetSlotsOpen( ) > 0 ) { SendAllChat( "Slot(s) open, fill them" ); return; } // check if everyone has the map string StillDownloading;
Avoir une liste des pays bannis
Fichier : ghost.cfg
Modification : par exemple pour bannir l'Espagne, l'Italie et l'Allemagne on rajoute la ligne :
bannedcountries = ESITDE
Fichier : ghost.h
Modification : après la ligne suivante :
string m_AdminGamePassword; // config value: the admin game password
On rajoute ceci :
string m_BannedCountries; // custom value: banned countries
Fichier : ghost.cpp
Modification : après la ligne suivante :
m_AdminGamePassword = CFG->GetString( "admingame_password", string( ) );
On rajoute ceci :
m_BannedCountries = CFG->GetString( "bannedcountries", string( ));
Fichier : game_base.cpp
Modification : après le bloc suivant :
// check if the new player's name is banned for( vector<CBNET *> :: iterator i = m_GHost->m_BNETs.begin( ); i != m_GHost->m_BNETs.end( ); i++ ) { CDBBan *Ban = (*i)->IsBanned( joinPlayer->GetName( ) ); if( Ban ) { CONSOLE_Print( "[GAME: " + m_GameName + "] player [" + joinPlayer->GetName( ) + "] is trying to join the game but is banned" ); SendAllChat( m_GHost->m_Language->TryingToJoinTheGameButBanned( joinPlayer->GetName( ) ) ); potential->SetDeleteMe( true ); return; } }
Mais avant celui-ci :
// try to find an empty slot unsigned char SID = GetEmptySlot( false ); // check if the player is an admin or root admin on any connected realm for determining reserved status // we can't just use the spoof checked realm like in EventPlayerBotCommand because the player hasn't spoof checked yet bool AnyAdminCheck = false;
On rajoute ceci :
// [FROMENFORCER] //Make sure from checking is enabled and config values are clean if(!m_GHost->m_BannedCountries.empty( ) || m_GHost->m_BannedCountries.length() % 2 != 0) { int num; vector<string> BannedLocations; string PlayerLocation; bool playerIsApproved; if(m_GHost->m_BannedCountries.length() == 2) num = 1; else num = m_GHost->m_BannedCountries.length() / 2; //Loop through banned countries and construct an array for(int i = 0; i < m_GHost->m_BannedCountries.length(); i += 2) BannedLocations.push_back(m_GHost->m_BannedCountries.substr(i,2)); //Get their location PlayerLocation = m_GHost->m_DBLocal->FromCheck( UTIL_ByteArrayToUInt32( potential->GetExternalIP( ), true )); //Kick if not from an allowed location, ignore if their location is approved or cannot be found "??" playerIsApproved = true; //Try to make a match for(int x = 0; x < num; x++) { //Ban the player if their country is banned if(PlayerLocation == BannedLocations[x]) playerIsApproved = false; } if(!playerIsApproved && PlayerLocation != "??") { //Player location has been found and is invalid, deny them entry CONSOLE_Print("[FROMENFORCER] Player [" + joinPlayer->GetName() + "] tried to join the game but is not from an approved location (" + PlayerLocation + ")"); SendAllChat("[" + joinPlayer->GetName() + "] tried to join the game but is not from an approved location (" + PlayerLocation + ")"); potential->SetDeleteMe(true); return; } }