- removed the rotateunit flag (its now just part of MG)
- updated rendering to consider both visible and explored cells when rendering untis and objects - added a warning message when a client is lagging and coming close to being kicked off
This commit is contained in:
parent
e38c3e341b
commit
eeda623b4f
|
@ -66,7 +66,7 @@ Game::Game(Program *program, const GameSettings *gameSettings):
|
|||
updateFps=0;
|
||||
renderFps=0;
|
||||
lastUpdateFps=0;
|
||||
lastRenderFps=0;
|
||||
lastRenderFps=-1;
|
||||
paused= false;
|
||||
gameOver= false;
|
||||
renderNetworkStatus= false;
|
||||
|
@ -432,6 +432,8 @@ void Game::init()
|
|||
|
||||
logger.add("Launching game");
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n\n\n=-=-=-=-=-=-=-=-=-=-= STARTING GAME =-=-=-=-=-=-=-=-=-=-=\n\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
|
@ -1057,7 +1059,7 @@ void Game::render3d(){
|
|||
//shadow map
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
chrono.start();
|
||||
renderer.renderShadowsToTexture(renderFps);
|
||||
renderer.renderShadowsToTexture(lastRenderFps);
|
||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d renderFps = %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis());
|
||||
|
||||
//clear buffers
|
||||
|
@ -1081,13 +1083,13 @@ void Game::render3d(){
|
|||
//units
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
chrono.start();
|
||||
renderer.renderUnits(renderFps,world.getFrameCount());
|
||||
renderer.renderUnits(lastRenderFps,world.getFrameCount());
|
||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d renderFps = %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis());
|
||||
|
||||
//objects
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
chrono.start();
|
||||
renderer.renderObjects(renderFps,world.getFrameCount());
|
||||
renderer.renderObjects(lastRenderFps,world.getFrameCount());
|
||||
if(chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d renderFps = %d took msecs: %d\n",__FILE__,__FUNCTION__,__LINE__,renderFps,chrono.getMillis());
|
||||
|
||||
//water
|
||||
|
|
|
@ -42,9 +42,10 @@ namespace Glest { namespace Game{
|
|||
bool MeshCallbackTeamColor::noTeamColors = false;
|
||||
|
||||
// if FPS is less than this we start to skip 3D renders
|
||||
//int MIN_RENDER_FPS_ALLOWED = 10;
|
||||
int MIN_RENDER_FPS_ALLOWED = -1;
|
||||
int MIN_RENDER_LAG_ALLOWED = 1;
|
||||
int MAX_RENDER_LAG_ITEMCOUNT_ALLOWED = 60;
|
||||
int MAX_RENDER_LAG_ITEMCOUNT_ALLOWED = 200;
|
||||
|
||||
bool RenderEntity::operator<(const RenderEntity &rhs) const {
|
||||
if(this->type == retUnit || this->type == retUnitFast) {
|
||||
|
@ -182,8 +183,6 @@ Renderer::Renderer(){
|
|||
particleManager[i]= graphicsFactory->newParticleManager();
|
||||
fontManager[i]= graphicsFactory->newFontManager();
|
||||
}
|
||||
|
||||
allowRotateUnits = config.getBool("AllowRotateUnits","0");
|
||||
}
|
||||
|
||||
Renderer::~Renderer(){
|
||||
|
@ -654,13 +653,12 @@ void Renderer::renderMouse3d() {
|
|||
glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, color.ptr());
|
||||
const Model *buildingModel= building->getFirstStOfClass(scStop)->getAnimation();
|
||||
|
||||
if(allowRotateUnits == true) {
|
||||
float rotateAmount = gui->getSelectedFacing() * 90.f;
|
||||
if(rotateAmount > 0) {
|
||||
//if(Socket::enableDebugText) printf("In [%s::%s] rotate unit id = %d amount = %f\n",__FILE__,__FUNCTION__,building->getId(),rotateAmount);
|
||||
glRotatef(rotateAmount, 0.f, 1.f, 0.f);
|
||||
}
|
||||
float rotateAmount = gui->getSelectedFacing() * 90.f;
|
||||
if(rotateAmount > 0) {
|
||||
//if(Socket::enableDebugText) printf("In [%s::%s] rotate unit id = %d amount = %f\n",__FILE__,__FUNCTION__,building->getId(),rotateAmount);
|
||||
glRotatef(rotateAmount, 0.f, 1.f, 0.f);
|
||||
}
|
||||
|
||||
buildingModel->updateInterpolationData(0.f, false);
|
||||
modelRenderer->render(buildingModel);
|
||||
glDisable(GL_COLOR_MATERIAL);
|
||||
|
@ -1264,7 +1262,7 @@ void Renderer::renderSurface(){
|
|||
}
|
||||
|
||||
void Renderer::renderObjects(const int renderFps, const int worldFrameCount) {
|
||||
if(renderFps < MIN_RENDER_FPS_ALLOWED) {
|
||||
if(renderFps >= 0 && renderFps < MIN_RENDER_FPS_ALLOWED) {
|
||||
renderObjectsFast();
|
||||
}
|
||||
else {
|
||||
|
@ -1309,7 +1307,7 @@ void Renderer::renderObjects(const int renderFps, const int worldFrameCount) {
|
|||
bool isVisible = (sc->isVisible(thisTeamIndex) && o!=NULL);
|
||||
if(isExplored == true && isVisible == true) {
|
||||
/*
|
||||
if(renderFps < MIN_RENDER_FPS_ALLOWED) {
|
||||
if(renderFps >= 0 && renderFps < MIN_RENDER_FPS_ALLOWED) {
|
||||
int renderLag = worldFrameCount - o->getLastRenderFrame();
|
||||
if(renderLag > MIN_RENDER_LAG_ALLOWED) {
|
||||
vctEntity.push_back(RenderEntity(retObject,o,mapPos,NULL));
|
||||
|
@ -1336,7 +1334,7 @@ void Renderer::renderObjects(const int renderFps, const int worldFrameCount) {
|
|||
void Renderer::renderObjectList(std::vector<RenderEntity> &vctEntity,const Vec3f &baseFogColor,const int renderFps, const int worldFrameCount) {
|
||||
// Need to do something to manage bad FPS
|
||||
/*
|
||||
if(renderFps < MIN_RENDER_FPS_ALLOWED) {
|
||||
if(renderFps >= 0 && renderFps < MIN_RENDER_FPS_ALLOWED) {
|
||||
// Oldest rendered objects go to top
|
||||
std::sort(vctEntity.begin(), vctEntity.end());
|
||||
for(int idx=0; idx < vctEntity.size(); ++idx) {
|
||||
|
@ -1562,7 +1560,7 @@ void Renderer::renderUnits(const int renderFps, const int worldFrameCount) {
|
|||
for(int j=0; j<world->getFaction(i)->getUnitCount(); ++j){
|
||||
Unit *unit = world->getFaction(i)->getUnit(j);
|
||||
if(world->toRenderUnit(unit, visibleQuad)) {
|
||||
if(renderFps < MIN_RENDER_FPS_ALLOWED) {
|
||||
if(renderFps >= 0 && renderFps < MIN_RENDER_FPS_ALLOWED) {
|
||||
int unitRenderLag = worldFrameCount - unit->getLastRenderFrame();
|
||||
if(unitRenderLag > MIN_RENDER_LAG_ALLOWED) {
|
||||
vctEntity.push_back(RenderEntity(retUnit,NULL,Vec2i(),unit,world->getFaction(i)->getTexture()));
|
||||
|
@ -1592,7 +1590,7 @@ void Renderer::renderUnits(const int renderFps, const int worldFrameCount) {
|
|||
|
||||
void Renderer::renderUnitList(std::vector<RenderEntity> &vctEntity,MeshCallbackTeamColor *meshCallbackTeamColor,const int renderFps, const int worldFrameCount) {
|
||||
// Need to do something to manage bad FPS
|
||||
if(renderFps < MIN_RENDER_FPS_ALLOWED) {
|
||||
if(renderFps >= 0 && renderFps < MIN_RENDER_FPS_ALLOWED) {
|
||||
// Oldest rendered units go to top
|
||||
std::sort(vctEntity.begin(), vctEntity.end());
|
||||
for(int idx=0; idx < vctEntity.size(); ++idx) {
|
||||
|
@ -2310,7 +2308,7 @@ void Renderer::renderShadowsToTexture(const int renderFps){
|
|||
Chrono chrono;
|
||||
chrono.start();
|
||||
|
||||
if(renderFps >= MIN_RENDER_FPS_ALLOWED) {
|
||||
if(renderFps >= 0 && renderFps >= MIN_RENDER_FPS_ALLOWED) {
|
||||
if(shadows==sProjected || shadows==sShadowMapping){
|
||||
|
||||
shadowMapFrame= (shadowMapFrame + 1) % (shadowFrameSkip + 1);
|
||||
|
|
|
@ -258,8 +258,6 @@ private:
|
|||
//water
|
||||
float waterAnim;
|
||||
|
||||
bool allowRotateUnits;
|
||||
|
||||
bool allowRenderUnitTitles;
|
||||
std::vector<std::pair<Unit *,Vec3f> > renderUnitTitleList;
|
||||
|
||||
|
|
|
@ -96,8 +96,6 @@ void SelectionQuad::disable(){
|
|||
Gui::Gui(){
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s] START\n",__FILE__,__FUNCTION__);
|
||||
|
||||
allowRotateUnits = Config::getInstance().getBool("AllowRotateUnits","0");
|
||||
|
||||
posObjWorld= Vec2i(54, 14);
|
||||
computeSelection= false;
|
||||
validPosObjWorld= false;
|
||||
|
@ -349,7 +347,7 @@ void Gui::hotKey(char key) {
|
|||
}
|
||||
else if(key == configKeys.getCharKey("HotKeyRotateUnitDuringPlacement")){
|
||||
// Here the user triggers a unit rotation while placing a unit
|
||||
if(allowRotateUnits == true && isPlacingBuilding()) {
|
||||
if(isPlacingBuilding()) {
|
||||
if(getBuilding()->getRotationAllowed()){
|
||||
++selectedBuildingFacing;
|
||||
}
|
||||
|
|
|
@ -131,7 +131,6 @@ private:
|
|||
bool selectingMeetingPoint;
|
||||
|
||||
CardinalDir selectedBuildingFacing;
|
||||
bool allowRotateUnits;
|
||||
|
||||
bool showDebugUI;
|
||||
|
||||
|
|
|
@ -312,7 +312,7 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, b
|
|||
//chatManager.init(&console, world.getThisTeamIndex());
|
||||
chatManager.init(&console, -1,true);
|
||||
|
||||
publishToMasterserverThread = new SimpleTaskThread(this,0,50);
|
||||
publishToMasterserverThread = new SimpleTaskThread(this,0,25);
|
||||
publishToMasterserverThread->start();
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
@ -424,13 +424,10 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||
needToSetChangedGameSettings = false;
|
||||
lastSetChangedGameSettings = time(NULL);
|
||||
}
|
||||
safeMutex.ReleaseLock(true);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
bool bOkToStart = serverInterface->launchGame(&gameSettings);
|
||||
if(bOkToStart == true)
|
||||
{
|
||||
safeMutex.Lock();
|
||||
if(bOkToStart == true) {
|
||||
if( listBoxPublishServer.getEditable() &&
|
||||
listBoxPublishServer.getSelectedItemIndex() == 0) {
|
||||
|
||||
|
@ -446,11 +443,8 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||
|
||||
BaseThread::shutdownAndWait(publishToMasterserverThread);
|
||||
|
||||
safeMutex.ReleaseLock(true);
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
safeMutex.Lock();
|
||||
delete publishToMasterserverThread;
|
||||
publishToMasterserverThread = NULL;
|
||||
safeMutex.ReleaseLock();
|
||||
|
@ -462,6 +456,9 @@ void MenuStateCustomGame::mouseClick(int x, int y, MouseButton mouseButton){
|
|||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
program->setState(new Game(program, &gameSettings));
|
||||
}
|
||||
else {
|
||||
safeMutex.ReleaseLock();
|
||||
}
|
||||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
|
|
@ -154,6 +154,7 @@ ConnectionSlot::ConnectionSlot(ServerInterface* serverInterface, int playerIndex
|
|||
this->playerIndex = playerIndex;
|
||||
this->currentFrameCount = 0;
|
||||
this->currentLagCount = 0;
|
||||
this->gotLagCountWarning = false;
|
||||
this->lastReceiveCommandListTime = 0;
|
||||
this->socket = NULL;
|
||||
this->slotThreadWorker = NULL;
|
||||
|
|
|
@ -107,6 +107,7 @@ private:
|
|||
int currentFrameCount;
|
||||
int currentLagCount;
|
||||
time_t lastReceiveCommandListTime;
|
||||
bool gotLagCountWarning;
|
||||
|
||||
public:
|
||||
ConnectionSlot(ServerInterface* serverInterface, int playerIndex);
|
||||
|
@ -149,6 +150,9 @@ public:
|
|||
|
||||
time_t getLastReceiveCommandListTime() const { return lastReceiveCommandListTime; }
|
||||
|
||||
bool getLagCountWarning() const { return gotLagCountWarning; }
|
||||
void setLagCountWarning(bool value) { gotLagCountWarning = value; }
|
||||
|
||||
protected:
|
||||
|
||||
Mutex * getServerSynchAccessor();
|
||||
|
|
|
@ -40,6 +40,8 @@ bool enabledThreadedClientCommandBroadcast = false;
|
|||
|
||||
// The maximum amount of network update iterations a client is allowed to fall behind
|
||||
int maxFrameCountLagAllowed = 20;
|
||||
// 65% of max we warn all users about the lagged client
|
||||
double warnFrameCountLagPercent = 0.65;
|
||||
|
||||
ServerInterface::ServerInterface(){
|
||||
gameHasBeenInitiated = false;
|
||||
|
@ -48,6 +50,7 @@ ServerInterface::ServerInterface(){
|
|||
|
||||
enabledThreadedClientCommandBroadcast = Config::getInstance().getBool("EnableThreadedClientCommandBroadcast","false");
|
||||
maxFrameCountLagAllowed = Config::getInstance().getInt("MaxFrameCountLagAllowed",intToStr(maxFrameCountLagAllowed).c_str());
|
||||
warnFrameCountLagPercent = Config::getInstance().getFloat("WarnFrameCountLagPercent",doubleToStr(warnFrameCountLagPercent).c_str());
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] enabledThreadedClientCommandBroadcast = %d, maxFrameCountLagAllowed = %d\n",__FILE__,__FUNCTION__,__LINE__,enabledThreadedClientCommandBroadcast,maxFrameCountLagAllowed);
|
||||
|
||||
for(int i= 0; i<GameConstants::maxPlayers; ++i){
|
||||
|
@ -232,6 +235,27 @@ bool ServerInterface::clientLagCheck(ConnectionSlot* connectionSlot) {
|
|||
|
||||
connectionSlot->close();
|
||||
}
|
||||
// New lag check warning
|
||||
else if(maxFrameCountLagAllowed > 0 && warnFrameCountLagPercent > 0 &&
|
||||
(clientLagCount > (maxFrameCountLagAllowed * warnFrameCountLagPercent))) {
|
||||
if(connectionSlot->getLagCountWarning() == false) {
|
||||
connectionSlot->setLagCountWarning(true);
|
||||
|
||||
char szBuf[4096]="";
|
||||
#ifdef WIN32
|
||||
_snprintf(szBuf,4095,"%s may exceed max allowed LAG count of %d, clientLag = %d, WARNING...",Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str()).c_str(),maxFrameCountLagAllowed,clientLagCount);
|
||||
#else
|
||||
snprintf(szBuf,4095,"%s may exceed max allowed LAG count of %d, clientLag = %d, WARNING...",Config::getInstance().getString("NetPlayerName",Socket::getHostName().c_str()).c_str(),maxFrameCountLagAllowed,clientLagCount);
|
||||
#endif
|
||||
SystemFlags::OutputDebug(SystemFlags::debugNetwork,"In [%s::%s Line: %d] %s\n",__FILE__,__FUNCTION__,__LINE__,szBuf);
|
||||
|
||||
string sMsg = szBuf;
|
||||
sendTextMessage(sMsg,-1);
|
||||
}
|
||||
}
|
||||
else if(connectionSlot->getLagCountWarning() == true) {
|
||||
connectionSlot->setLagCountWarning(false);
|
||||
}
|
||||
}
|
||||
|
||||
return clientLagExceeded;
|
||||
|
|
|
@ -134,7 +134,6 @@ Unit::Unit(int id, const Vec2i &pos, const UnitType *type, Faction *faction, Map
|
|||
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
allowRotateUnits = Config::getInstance().getBool("AllowRotateUnits","0");
|
||||
modelFacing = CardinalDir::NORTH;
|
||||
|
||||
RandomGen random;
|
||||
|
@ -1631,10 +1630,6 @@ std::string Unit::toString() const {
|
|||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
result += "allowRotateUnits = " + intToStr(allowRotateUnits) + "\n";
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
||||
result += "modelFacing = " + intToStr(modelFacing.asInt()) + "\n";
|
||||
|
||||
//SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
|
|
|
@ -193,7 +193,6 @@ private:
|
|||
UnitParticleSystems unitParticleSystems;
|
||||
UnitParticleSystems damageParticleSystems;
|
||||
|
||||
bool allowRotateUnits;
|
||||
CardinalDir modelFacing;
|
||||
|
||||
std::string lastSynchDataString;
|
||||
|
|
|
@ -50,8 +50,6 @@ void UnitUpdater::init(Game *game){
|
|||
this->console= game->getConsole();
|
||||
this->scriptManager= game->getScriptManager();
|
||||
pathFinder.init(map);
|
||||
|
||||
allowRotateUnits = Config::getInstance().getBool(reinterpret_cast<const char *>("AllowRotateUnits"),"0");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -56,7 +56,6 @@ private:
|
|||
PathFinder pathFinder;
|
||||
Game *game;
|
||||
RandomGen random;
|
||||
bool allowRotateUnits;
|
||||
|
||||
public:
|
||||
void init(Game *game);
|
||||
|
|
|
@ -54,7 +54,6 @@ World::World(){
|
|||
scriptManager= NULL;
|
||||
this->game = NULL;
|
||||
|
||||
allowRotateUnits = Config::getInstance().getBool("AllowRotateUnits","0");
|
||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||
}
|
||||
|
||||
|
|
|
@ -91,7 +91,6 @@ private:
|
|||
int fogOfWarSmoothingFrameSkip;
|
||||
bool fogOfWarSmoothing;
|
||||
Game *game;
|
||||
bool allowRotateUnits;
|
||||
|
||||
public:
|
||||
World();
|
||||
|
|
Loading…
Reference in New Issue
Block a user