diff --git a/source/glest_game/game/game_constants.h b/source/glest_game/game/game_constants.h index ea353d1dc..d209e81ce 100644 --- a/source/glest_game/game/game_constants.h +++ b/source/glest_game/game/game_constants.h @@ -75,6 +75,13 @@ enum FactionPersonalityType { fpt_EndCount }; +enum MasterServerGameStatusType { + game_status_waiting_for_players = 0, + game_status_waiting_for_start = 1, + game_status_in_progress = 2, + game_status_finished = 3 +}; + class GameConstants { public: static const int specialFactions = fpt_EndCount - 1; diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 7c13217ff..1416f2da9 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -1861,6 +1861,10 @@ void Renderer::renderSurface(const int renderFps) { #if defined(ENABLE_VBO_CODE) + int lastSurfaceDataIndex = -1; + std::vector surface; + //surface.reserve(qCache.visibleScaledCellList.size()); + for(int visibleIndex = 0; visibleIndex < qCache.visibleScaledCellList.size(); ++visibleIndex) { Vec2i &pos = qCache.visibleScaledCellList[visibleIndex]; @@ -1890,40 +1894,92 @@ void Renderer::renderSurface(const int renderFps) { if(tc00->getSurfaceTexture() == NULL) { throw runtime_error("tc00->getSurfaceTexture() == NULL"); } + vector &vboCache = GetSurfaceVBOs(pos); + + int surfaceDataIndex = -1; currTex= static_cast(tc00->getSurfaceTexture())->getHandle(); if(currTex != lastTex) { lastTex = currTex; - glBindTexture(GL_TEXTURE_2D, lastTex); } + else { + surfaceDataIndex = lastSurfaceDataIndex; + } + + if(surfaceDataIndex < 0) { + SurfaceData newData; + newData.textureHandle = currTex; + surface.push_back(newData); + + surfaceDataIndex = surface.size()-1; + + //surface[surfaceDataIndex].texCoords.reserve(100); + //surface[surfaceDataIndex].texCoordsSurface.reserve(100); + //surface[surfaceDataIndex].vertices.reserve(100); + //surface[surfaceDataIndex].normals.reserve(100); + } + + lastSurfaceDataIndex = surfaceDataIndex; const Vec2f &surfCoord= tc00->getSurfTexCoord(); - vector &vboCache = GetSurfaceVBOs(pos); + //int dataIndex = surface[surfaceDataIndex].texCoords.size(); + surface[surfaceDataIndex].texCoords.push_back(tc01->getFowTexCoord()); + surface[surfaceDataIndex].texCoordsSurface.push_back(Vec2f(surfCoord.x, surfCoord.y + coordStep)); + surface[surfaceDataIndex].vertices.push_back(tc01->getVertex()); + surface[surfaceDataIndex].normals.push_back(tc01->getNormal()); - glBegin(GL_TRIANGLE_STRIP); + surface[surfaceDataIndex].texCoords.push_back(tc00->getFowTexCoord()); + surface[surfaceDataIndex].texCoordsSurface.push_back(Vec2f(surfCoord.x, surfCoord.y)); + surface[surfaceDataIndex].vertices.push_back(tc00->getVertex()); + surface[surfaceDataIndex].normals.push_back(tc00->getNormal()); + + surface[surfaceDataIndex].texCoords.push_back(tc11->getFowTexCoord()); + surface[surfaceDataIndex].texCoordsSurface.push_back(Vec2f(surfCoord.x+coordStep, surfCoord.y+coordStep)); + surface[surfaceDataIndex].vertices.push_back(tc11->getVertex()); + surface[surfaceDataIndex].normals.push_back(tc11->getNormal()); + + surface[surfaceDataIndex].texCoords.push_back(tc10->getFowTexCoord()); + surface[surfaceDataIndex].texCoordsSurface.push_back(Vec2f(surfCoord.x+coordStep, surfCoord.y)); + surface[surfaceDataIndex].vertices.push_back(tc10->getVertex()); + surface[surfaceDataIndex].normals.push_back(tc10->getNormal()); + } + + //printf("\nsurface.size() = %d vs qCache.visibleScaledCellList.size() = %d \n",surface.size(),qCache.visibleScaledCellList.size()); + + for(int i = 0; i < surface.size(); ++i) { + SurfaceData &data = surface[i]; + + Vec2f *texCoords = &data.texCoords[0]; + Vec2f *texCoordsSurface = &data.texCoordsSurface[0]; + Vec3f *vertices = &data.vertices[0]; + Vec3f *normals = &data.normals[0]; + + glClientActiveTexture(fowTexUnit); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glTexCoordPointer(2, GL_FLOAT, 0,texCoords); + + glBindTexture(GL_TEXTURE_2D, data.textureHandle); + glClientActiveTexture(baseTexUnit); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + glTexCoordPointer(2, GL_FLOAT, 0, texCoordsSurface); assertGl(); - - //draw quad using immediate mode - for(int i = 0; i < vboCache.size(); ++i) { - - assertGl(); - - glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache[i].m_nVBOFowTexCoords ); - glMultiTexCoord2fv(fowTexUnit, 0); - glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache[i].m_nVBOSurfaceTexCoords ); - glMultiTexCoord2fv(baseTexUnit, 0); - glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache[i].m_nVBONormals ); - glNormal3fv(0); - glBindBufferARB( GL_ARRAY_BUFFER_ARB, vboCache[i].m_nVBOVertices ); - glVertex3fv(0); - - assertGl(); - } - + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_NORMAL_ARRAY); assertGl(); - glEnd(); + glVertexPointer(3, GL_FLOAT, 0, vertices); + glNormalPointer(GL_FLOAT, 0, normals); + + glDrawArrays(GL_TRIANGLE_STRIP, 0, data.vertices.size()); + + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + glDisableClientState(GL_TEXTURE_COORD_ARRAY); + + //assertGl(); + glDisableClientState(GL_NORMAL_ARRAY); + glDisableClientState(GL_VERTEX_ARRAY); + //assertGl(); } #else diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index 374a45260..18e19d0f1 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -1361,7 +1361,7 @@ void MenuStateCustomGame::render() { SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf); - //throw runtime_error(szBuf);!!! + //throw runtime_error(szBuf); showGeneralError=true; generalErrorToShow = ex.what(); } @@ -1842,6 +1842,11 @@ void MenuStateCustomGame::publishToMasterserver() string externalport = config.getString("MasterServerExternalPort", "61357"); publishToServerInfo["externalconnectport"] = externalport; + publishToServerInfo["gameStatus"] = intToStr(game_status_waiting_for_players); + if(slotCountHumans <= slotCountConnectedPlayers) { + publishToServerInfo["gameStatus"] = intToStr(game_status_waiting_for_start); + } + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__); } @@ -1988,7 +1993,7 @@ void MenuStateCustomGame::simpleTask(BaseThread *callingThread) { SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf); if(callingThread->getQuitStatus() == false) { - //throw runtime_error(szBuf);!!! + //throw runtime_error(szBuf); showGeneralError=true; generalErrorToShow = ex.what(); } @@ -2631,7 +2636,7 @@ void MenuStateCustomGame::updateNetworkSlots() { sprintf(szBuf,"In [%s::%s %d] Error detected:\n%s\n",__FILE__,__FUNCTION__,__LINE__,ex.what()); SystemFlags::OutputDebug(SystemFlags::debugError,szBuf); SystemFlags::OutputDebug(SystemFlags::debugSystem,"%s",szBuf); - //throw runtime_error(szBuf);!!! + //throw runtime_error(szBuf); showGeneralError=true; generalErrorToShow = ex.what(); diff --git a/source/glest_game/menu/menu_state_masterserver.cpp b/source/glest_game/menu/menu_state_masterserver.cpp index 67647e146..58749e408 100644 --- a/source/glest_game/menu/menu_state_masterserver.cpp +++ b/source/glest_game/menu/menu_state_masterserver.cpp @@ -149,13 +149,23 @@ MenuStateMasterserver::MenuStateMasterserver(Program *program, MainMenu *mainMen serverTitleLabel.init(i,startOffset-lineOffset); serverTitleLabel.setText(lang.get("MGGameTitle")); - i+=200; + i+=80; + countryLabel.registerGraphicComponent(containerName,"countryLabel"); + countryLabel.init(i,startOffset-lineOffset); + countryLabel.setText(lang.get("MGGameCountry")); + + i+=80; + statusLabel.registerGraphicComponent(containerName,"statusLabel"); + statusLabel.init(i,startOffset-lineOffset); + statusLabel.setText(lang.get("MGGameStatus")); + + i+=90; ipAddressLabel.registerGraphicComponent(containerName,"ipAddressLabel"); ipAddressLabel.init(i,startOffset-lineOffset); ipAddressLabel.setText(lang.get("MGGameIP")); //game setup info: - i+=120; + i+=100; techLabel.registerGraphicComponent(containerName,"techLabel"); techLabel.init(i,startOffset-lineOffset); techLabel.setText(lang.get("TechTree")); @@ -524,6 +534,8 @@ void MenuStateMasterserver::render(){ //game info: renderer.renderLabel(&serverTitleLabel,&titleLabelColor); + renderer.renderLabel(&countryLabel,&titleLabelColor); + renderer.renderLabel(&statusLabel,&titleLabelColor); renderer.renderLabel(&ipAddressLabel,&titleLabelColor); //game setup info: @@ -820,6 +832,8 @@ void MenuStateMasterserver::rebuildServerLines(const string &serverInfo) { Lang &lang= Lang::getInstance(); try { if(serverInfo != "") { + //printf("--------------> serverInfo [%s]\n",serverInfo.c_str()); + std::vector serverList; Tokenize(serverInfo,serverList,"\n"); for(int i=0; i < serverList.size(); i++) { @@ -827,7 +841,9 @@ void MenuStateMasterserver::rebuildServerLines(const string &serverInfo) { std::vector serverEntities; Tokenize(server,serverEntities,"|"); - const int MIN_FIELDS_EXPECTED = 12; + //printf("--------------> server [%s] serverEntities.size() = %d\n",server.c_str(),serverEntities.size()); + + const int MIN_FIELDS_EXPECTED = 14; if(serverEntities.size() >= MIN_FIELDS_EXPECTED) { labelTitle.setText(lang.get("AvailableServers")); @@ -854,6 +870,10 @@ void MenuStateMasterserver::rebuildServerLines(const string &serverInfo) { masterServerInfo->setNetworkSlots(strToInt(serverEntities[9])); masterServerInfo->setConnectedClients(strToInt(serverEntities[10])); masterServerInfo->setExternalConnectPort(strToInt(serverEntities[11])); + masterServerInfo->setCountry(serverEntities[12]); + masterServerInfo->setStatus(strToInt(serverEntities[13])); + + //printf("--------------> Country [%s] Status [%d]\n",masterServerInfo->getCountry().c_str(),masterServerInfo->getStatus()); //printf("Getting Ping time for host %s\n",masterServerInfo->getIpAddress().c_str()); //float pingTime = Socket::getAveragePingMS(masterServerInfo->getIpAddress().c_str(),1); diff --git a/source/glest_game/menu/menu_state_masterserver.h b/source/glest_game/menu/menu_state_masterserver.h index e53743314..2b4f5c1e5 100644 --- a/source/glest_game/menu/menu_state_masterserver.h +++ b/source/glest_game/menu/menu_state_masterserver.h @@ -52,6 +52,9 @@ private: //game info: GraphicLabel serverTitleLabel; + GraphicLabel countryLabel; + GraphicLabel statusLabel; + GraphicLabel ipAddressLabel; //game setup info: diff --git a/source/glest_game/menu/server_line.cpp b/source/glest_game/menu/server_line.cpp index 29d74887d..ccca4612c 100644 --- a/source/glest_game/menu/server_line.cpp +++ b/source/glest_game/menu/server_line.cpp @@ -32,6 +32,7 @@ namespace Glest{ namespace Game{ ServerLine::ServerLine( MasterServerInfo *mServerInfo, int lineIndex, int baseY, int lineHeight, const char * containerName) { this->containerName = containerName; + this->countryTexture = NULL; Lang &lang= Lang::getInstance(); this->lineHeight=lineHeight; @@ -60,7 +61,36 @@ ServerLine::ServerLine( MasterServerInfo *mServerInfo, int lineIndex, int baseY, serverTitleLabel.init(i,baseY-lineOffset); serverTitleLabel.setText(masterServerInfo.getServerTitle()); - i+=200; + i+=80; + country.init(i,baseY-lineOffset); + country.setText(masterServerInfo.getCountry()); + + string data_path = getGameReadWritePath(GameConstants::path_data_CacheLookupKey); + string countryLogoPath = data_path + "data/core/misc_textures/"; + + Config &config = Config::getInstance(); + if(config.getString("CountryTexturePath","") != "") { + countryLogoPath = config.getString("CountryTexturePath",""); + } + + if(fileExists(countryLogoPath + "/" + masterServerInfo.getCountry() + ".png") == true) { + countryTexture=GraphicsInterface::getInstance().getFactory()->newTexture2D(); + //loadingTexture = renderer.newTexture2D(rsGlobal); + countryTexture->setMipmap(true); + //loadingTexture->getPixmap()->load(filepath); + countryTexture->load(countryLogoPath + "/" + masterServerInfo.getCountry() + ".png"); + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + + Renderer &renderer= Renderer::getInstance(); + renderer.initTexture(rsGlobal,countryTexture); + } + + i+=80; + status.init(i,baseY-lineOffset); + status.setText(lang.get("MGGameStatus" + intToStr(masterServerInfo.getStatus()))); + + i+=90; ipAddressLabel.init(i,baseY-lineOffset); ipAddressLabel.setText(masterServerInfo.getIpAddress()); @@ -69,7 +99,7 @@ ServerLine::ServerLine( MasterServerInfo *mServerInfo, int lineIndex, int baseY, wrongVersionLabel.setText(lang.get("IncompatibleVersion")); //game setup info: - i+=120; + i+=100; techLabel.init(i,baseY-lineOffset); techLabel.setText(masterServerInfo.getTech()); @@ -107,6 +137,18 @@ ServerLine::ServerLine( MasterServerInfo *mServerInfo, int lineIndex, int baseY, ServerLine::~ServerLine() { //delete masterServerInfo; + + if(countryTexture != NULL) { + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + + countryTexture->end(); + delete countryTexture; + + SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__); + + //delete loadingTexture; + countryTexture=NULL; + } } bool ServerLine::buttonMouseClick(int x, int y){ @@ -147,7 +189,15 @@ void ServerLine::render() { //game info: renderer.renderLabel(&serverTitleLabel); - if(!gameFull.getEnabled()){ + if(countryTexture != NULL) { + renderer.renderTextureQuad(country.getX() + 20,country.getY(),countryTexture->getTextureWidth(),countryTexture->getTextureHeight(),countryTexture,0.7f); + } + else { + renderer.renderLabel(&country); + } + + renderer.renderLabel(&status); + if(gameFull.getEnabled() == false) { if (compatible) { renderer.renderLabel(&ipAddressLabel); @@ -176,6 +226,8 @@ void ServerLine::setY(int y) { //game info: serverTitleLabel.setY(y); + country.setY(y); + status.setY(y); ipAddressLabel.setY(y); //game setup info: diff --git a/source/glest_game/menu/server_line.h b/source/glest_game/menu/server_line.h index 60b66adf6..76e9f65f2 100644 --- a/source/glest_game/menu/server_line.h +++ b/source/glest_game/menu/server_line.h @@ -53,6 +53,11 @@ private: GraphicLabel externalConnectPort; + GraphicLabel country; + GraphicLabel status; + + Texture2D *countryTexture; + const char * containerName; public: diff --git a/source/glest_game/network/masterserver_info.h b/source/glest_game/network/masterserver_info.h index d3fe9ccf2..6a970a8a8 100644 --- a/source/glest_game/network/masterserver_info.h +++ b/source/glest_game/network/masterserver_info.h @@ -13,6 +13,7 @@ #define _GLEST_GAME_MASTERSERVERINFO_H_ #include +#include "game_constants.h" #include "leak_dumper.h" using std::string; @@ -25,7 +26,7 @@ namespace Glest{ namespace Game{ /// A type of particle system // =========================================================== -class MasterServerInfo{ +class MasterServerInfo { protected: //general info: string glestVersion; @@ -44,6 +45,8 @@ protected: int networkSlots; int connectedClients; int externalconnectport; + string country; + int status; public: const string &getGlestVersion() const {return glestVersion;} @@ -60,7 +63,8 @@ public: const int getNetworkSlots() const {return networkSlots;} const int getConnectedClients() const {return connectedClients;} const int getExternalConnectPort() const {return externalconnectport;} - + const string &getCountry() const { return country;} + const int getStatus() const { return status;} //general info: @@ -81,6 +85,8 @@ public: void setNetworkSlots(int value) { networkSlots = value; } void setConnectedClients(int value) { connectedClients = value; } void setExternalConnectPort(int value) { externalconnectport = value; } + void setCountry(string value) { country = value; } + void setStatus(int value) { status = value; } }; }}//end namespace diff --git a/source/glest_game/network/server_interface.cpp b/source/glest_game/network/server_interface.cpp index 97969f08d..c9ea38da7 100644 --- a/source/glest_game/network/server_interface.cpp +++ b/source/glest_game/network/server_interface.cpp @@ -1408,7 +1408,7 @@ std::map ServerInterface::publishToMasterserver() { publishToServerInfo["glestVersion"] = glestVersionString; publishToServerInfo["platform"] = getPlatformNameString(); publishToServerInfo["binaryCompileDate"] = getCompileDateTime(); - publishToServerInfo["serverTitle"] = getHumanPlayerName() + "'s game *IN PROGRESS*"; + publishToServerInfo["serverTitle"] = getHumanPlayerName() + "'s game"; publishToServerInfo["tech"] = this->getGameSettings()->getTech(); publishToServerInfo["map"] = this->getGameSettings()->getMap(); publishToServerInfo["tileset"] = this->getGameSettings()->getTileset(); @@ -1417,9 +1417,11 @@ std::map ServerInterface::publishToMasterserver() { publishToServerInfo["connectedClients"] = intToStr(slotCountConnectedPlayers); string externalport = config.getString("MasterServerExternalPort", "61357"); publishToServerInfo["externalconnectport"] = externalport; + publishToServerInfo["gameStatus"] = intToStr(game_status_in_progress); + if(publishToMasterserverThread == NULL) { - publishToServerInfo["serverTitle"] = getHumanPlayerName() + "'s game *FINISHED*"; publishToServerInfo["gameCmd"]= "gameOver"; + publishToServerInfo["gameStatus"] = intToStr(game_status_finished); } SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__); return publishToServerInfo; diff --git a/source/masterserver/addServerInfo.php b/source/masterserver/addServerInfo.php index f8d6fd5db..19256d6f3 100644 --- a/source/masterserver/addServerInfo.php +++ b/source/masterserver/addServerInfo.php @@ -44,11 +44,16 @@ $activeSlots = (int) clean_str( $_GET['activeSlots'] ); $networkSlots = (int) clean_str( $_GET['networkSlots'] ); $connectedClients = (int) clean_str( $_GET['connectedClients'] ); + + $status = 0; + if(isset($_GET["gameStatus"])) { + $status = (int) clean_str( $_GET['gameStatus'] ); + } - $gameCmd = ""; - if(isset($_GET["gameCmd"])) { - $gameCmd = (string) clean_str( $_GET['gameCmd'] ); -} + $gameCmd = ""; + if(isset($_GET["gameCmd"])) { + $gameCmd = (string) clean_str( $_GET['gameCmd'] ); + } define( 'DB_LINK', db_connect() ); @@ -81,6 +86,7 @@ 'networkSlots=\'' . mysql_real_escape_string( $networkSlots ) . '\', ' . 'connectedClients=\'' . mysql_real_escape_string( $connectedClients ) . '\', ' . 'externalServerPort=\''. mysql_real_escape_string( $service_port ) . '\', ' . + 'status=\'' . mysql_real_escape_string( $status ) . '\', ' . 'lasttime=' . 'now()' . ' ' . 'where ip=\'' . mysql_real_escape_string( $remote_ip ) . '\' && externalServerPort=\'' . mysql_real_escape_string( $service_port ) . '\';' ); updateServer($remote_ip, $service_port, $serverTitle, $connectedClients, $networkSlots); @@ -181,7 +187,8 @@ 'networkSlots=\'' . mysql_real_escape_string( $networkSlots ) . '\', ' . 'connectedClients=\'' . mysql_real_escape_string( $connectedClients ) . '\', ' . 'externalServerPort=\''. mysql_real_escape_string( $service_port ) . '\', ' . - 'country=\'' . mysql_real_escape_string( $country ) . '\';' + 'country=\'' . mysql_real_escape_string( $country ) . '\', ' . + 'status=\'' . mysql_real_escape_string( $status ) . '\';' ); echo 'OK'; addLatestServer($remote_ip, $service_port, $serverTitle, $connectedClients, $networkSlots); diff --git a/source/masterserver/config.php b/source/masterserver/config.php index b58a65ef6..148b2cb1f 100644 --- a/source/masterserver/config.php +++ b/source/masterserver/config.php @@ -12,4 +12,5 @@ define( 'MYSQL_LINK_PERSIST', false ); // How many recently seen servers to store define( 'MAX_RECENT_SERVERS', 5 ); + define( 'DEFAULT_COUNTRY', '?' ); ?> diff --git a/source/masterserver/createDB.sql b/source/masterserver/createDB.sql index 977943dd9..74cb131ae 100755 --- a/source/masterserver/createDB.sql +++ b/source/masterserver/createDB.sql @@ -21,6 +21,7 @@ CREATE TABLE IF NOT EXISTS `glestserver` ( `connectedClients` int(11) NOT NULL, `externalServerPort` int(11) NOT NULL, `country` varchar(2) collate utf8_unicode_ci NOT NULL, + `status` int(11) NOT NULL default 0, -- valid statuses: 0 waiting for players, 1 = game full pending start, 2 game in progress, 3 game over KEY `lasttime` (`lasttime`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; diff --git a/source/masterserver/showRecentServers.php b/source/masterserver/showRecentServers.php index 6e4e8042a..fd6f41ff4 100644 --- a/source/masterserver/showRecentServers.php +++ b/source/masterserver/showRecentServers.php @@ -13,4 +13,4 @@ echo ""; db_disconnect($link); -?> \ No newline at end of file +?> diff --git a/source/masterserver/showServers.php b/source/masterserver/showServers.php index 2045062fb..9168f7083 100644 --- a/source/masterserver/showServers.php +++ b/source/masterserver/showServers.php @@ -59,6 +59,7 @@ echo <<connectedClients externalServerPort country + status END; @@ -87,6 +88,38 @@ END; echo "\t\t\t\t" . 'unknown' . '' . PHP_EOL; } } + else { + echo "\t\t\t\t" . htmlspecialchars( $server['country'], ENT_QUOTES ) . '' . PHP_EOL; + } + + $calculatedStatus = $server['status']; + if($calculatedStatus == 0) + { + $gameFull = ($server['networkSlots'] <= $server['connectedClients']); + if($gameFull == true) + { + $calculatedStatus = 1; + } + } + + switch($calculatedStatus) + { + case 0: + echo "\t\t\t\t" . htmlspecialchars( "waiting for players", ENT_QUOTES ) . '' . PHP_EOL; + break; + case 1: + echo "\t\t\t\t" . htmlspecialchars( "game full, pending start", ENT_QUOTES ) . '' . PHP_EOL; + break; + case 2: + echo "\t\t\t\t" . htmlspecialchars( "in progress", ENT_QUOTES ) . '' . PHP_EOL; + break; + case 3: + echo "\t\t\t\t" . htmlspecialchars( "finished", ENT_QUOTES ) . '' . PHP_EOL; + break; + default: + echo "\t\t\t\t" . htmlspecialchars( "unknown: " . $server['status'], ENT_QUOTES ) . '' . PHP_EOL; + } + echo "\t\t\t" . '' . PHP_EOL; } unset( $all_servers ); diff --git a/source/masterserver/showServersForGlest.php b/source/masterserver/showServersForGlest.php index 1eedb4e88..d0effcf31 100644 --- a/source/masterserver/showServersForGlest.php +++ b/source/masterserver/showServersForGlest.php @@ -23,9 +23,30 @@ header( 'Content-Type: text/plain; charset=utf-8' ); foreach( $all_servers as &$server ) { - echo ( - "${server['glestVersion']}|${server['platform']}|${server['binaryCompileDate']}|${server['serverTitle']}|${server['ip']}|${server['tech']}|${server['map']}|${server['tileset']}|${server['activeSlots']}|${server['networkSlots']}|${server['connectedClients']}|${server['externalServerPort']}|\n" - ); + $outString = + "${server['glestVersion']}|${server['platform']}|${server['binaryCompileDate']}|${server['serverTitle']}|${server['ip']}|${server['tech']}|${server['map']}|${server['tileset']}|${server['activeSlots']}|${server['networkSlots']}|${server['connectedClients']}|${server['externalServerPort']}|"; + + if ( $server['country'] !== '' ) + { + $outString = $outString . "${server['country']}|"; + } + else + { + $outString = $outString . DEFAULT_COUNTRY . "|"; + } + + $calculatedStatus = $server['status']; + if($calculatedStatus == 0) + { + $gameFull = ($server['networkSlots'] <= $server['connectedClients']); + if($gameFull == true) + { + $outString = $outString . "1|\n"; + } + } + $outString = $outString . "$calculatedStatus|\n"; + + echo ($outString); } unset( $all_servers ); unset( $server );