Commits

Anonymous committed d7634bc

Added a gui progress bat to show when the last unit will get out of it.

Comments (0)

Files changed (4)

 To First release :
 
--les guerrières ne sont toujours pas intelligentes.
--Le texte inGame des messages, le dernier mot peut dépasser la zone de jeu.
+- les guerrières ne sont toujours pas intelligentes.
+- Le texte inGame des messages, le dernier mot peut dépasser la zone de jeu.
+- Implémenter AICastor
 
 NetGame:
 - Est-ce que le réseau est floodé en cas de packets perdus ? (deux vitesses de packets ?)
 - (Traduction) Regarder si il y a des %s/%d à rajouter au lieu de deux traductions. GameGUI::addMessage()
 
 MapEditor:
--http://ysagoon.com/phpBB2/viewtopic.php?t=32&sid=d676d2a022afe27b03140af75b07706a
+- http://ysagoon.com/phpBB2/viewtopic.php?t=32&sid=d676d2a022afe27b03140af75b07706a
 
 YOG:
--Ajouter des chambres
+- Ajouter des chambres
+- Mettre yog1 get yog2 si yog1 est down.
 
 Tutorial:
--Moins vite.
--Plus gros.
+- Moins vite.
+- Plus gros.
 
 SGSL:
--lire "sgslLangCount" depuis texts.txt
+-l ire "sgslLangCount" depuis texts.txt
 
 To Next version :
 

src/BuildingsTypes.cpp

 		else
 			assert((*it)->hpInc==0);
 		
-		//hpInc consistency:
+		//mpMax/hpInit integrity:
+		if ((*it)->isBuildingSite)
+		{
+			BuildingType *bt1=*it;
+			assert(bt1);
+			if (bt1->level)
+			{
+				assert(bt1->lastLevelTypeNum!=-1);
+				BuildingType *bt2=entitiesTypes.at(bt1->lastLevelTypeNum);
+				assert(bt2);
+				if (bt1->hpInit!=bt2->hpMax)
+				{
+					printf("Warning, with building type %d==%d. Building site (tn%d) has has hpInit=%d, but building (tn%d) has hpMax=%d\n",
+						bt1->type, bt2->type, bt1->typeNum, bt1->hpInit, bt2->typeNum, bt2->hpMax);
+				}
+			}
+		}
+		
+		
+		//hpInit/hpInc integrity:
 		if ((*it)->isBuildingSite)
 		{
 			int resSum=0;
 #define YOFFSET_TEXT_PARA 14
 #define YOFFSET_TEXT_LINE 12
 
+#define YOFFSET_PROGRESS_BAR 7
+
 enum GameGUIGfxId
 {
 	EXCHANGE_BUILDING_ICONS = 21
 		ypos += YOFFSET_BAR+YOFFSET_B_SEP;
 	}
 	
-	// cleared ressources fo clearing flags:
+	// cleared ressources for clearing flags:
 	if (buildingType->type==BuildingType::CLEARING_FLAG && ((selBuild->owner->allies)&(1<<localTeamNo)))
 	{
 		ypos+=YOFFSET_B_SEP;
 
 	// other infos
 	if (buildingType->armor)
+	{
 		globalContainer->gfx->drawString(globalContainer->gfx->getW()-128+4, ypos, globalContainer->littleFont, GAG::nsprintf("%s : %d", Toolkit::getStringTable()->getString("[armor]"), buildingType->armor).c_str());
+		ypos+=YOFFSET_TEXT_LINE;
+	}
 	ypos += YOFFSET_INFOS;
 	if (buildingType->shootDamage)
 	{
 		ypos += YOFFSET_TOWER;
 	}
 
+	if ((selBuild->owner->allies) & (1<<localTeamNo))
+	{
+		// we select food buildings, heal buildings, and upgrade buildings:
+		int maxTimeTo=0;
+		if (buildingType->timeToFeedUnit)
+			maxTimeTo=buildingType->timeToFeedUnit;
+		else if (buildingType->timeToHealUnit)
+			maxTimeTo=buildingType->timeToHealUnit;
+		else
+			for (int i=0; i<NB_ABILITY; i++)
+				if (buildingType->upgradeTime[i])
+					maxTimeTo=buildingType->upgradeTime[i];
+		if (maxTimeTo)
+		{
+			int leftMin=128;
+			for (std::list<Unit *>::iterator it=selBuild->unitsInside.begin(); it!=selBuild->unitsInside.end(); ++it)
+			{
+				Unit *u=*it;
+				assert(u);
+				if (u->displacement==Unit::DIS_INSIDE)
+				{
+					int left=(-u->insideTimeout*128+128-u->delta/2)/(1+maxTimeTo);
+					//printf("  left=%d (insideTimeout=%d, delta=%d)\n", left, u->insideTimeout, u->delta);
+					if (leftMin>left)
+						leftMin=left;
+				}
+			}
+			if (leftMin<128)
+			{
+				int left=leftMin;
+				int elapsed=128-left;
+				globalContainer->gfx->drawFilledRect(globalContainer->gfx->getW()-128, ypos, elapsed, 7, 100, 100, 255);
+				globalContainer->gfx->drawFilledRect(globalContainer->gfx->getW()-128+elapsed, ypos, left, 7, 128, 128, 128);
+			}
+			ypos+=YOFFSET_PROGRESS_BAR;
+		}
+	}
+	
 	ypos += YOFFSET_B_SEP;
 
 	// exchange building
 
 	if ((selBuild->owner->allies) & (1<<localTeamNo))
 	{
+		if (buildingType->unitProductionTime) // swarm
+		{
+			int left=(selBuild->productionTimeout*128)/buildingType->unitProductionTime;
+			int elapsed=128-left;
+			globalContainer->gfx->drawFilledRect(globalContainer->gfx->getW()-128, 256+65+12, elapsed, 7, 100, 100, 255);
+			globalContainer->gfx->drawFilledRect(globalContainer->gfx->getW()-128+elapsed, 256+65+12, left, 7, 128, 128, 128);
+
+			for (int i=0; i<NB_UNIT_TYPE; i++)
+			{
+				drawScrollBox(globalContainer->gfx->getW()-128, 256+90+(i*20)+12, selBuild->ratio[i], selBuild->ratioLocal[i], 0, MAX_RATIO_RANGE);
+				globalContainer->gfx->drawString(globalContainer->gfx->getW()-128+24, 256+90+(i*20)+12, globalContainer->littleFont, Toolkit::getStringTable()->getString("[Unit type]", i));
+			}
+		}
+		
+		// ressorces for every building except exchange building
 		if (!buildingType->canExchange)
 		{
-			// swarm
-			if (buildingType->unitProductionTime)
-			{
-				int Left=(selBuild->productionTimeout*128)/buildingType->unitProductionTime;
-				int Elapsed=128-Left;
-				globalContainer->gfx->drawFilledRect(globalContainer->gfx->getW()-128, 256+65+12, Elapsed, 7, 100, 100, 255);
-				globalContainer->gfx->drawFilledRect(globalContainer->gfx->getW()-128+Elapsed, 256+65+12, Left, 7, 128, 128, 128);
-
-				for (int i=0; i<NB_UNIT_TYPE; i++)
-				{
-					drawScrollBox(globalContainer->gfx->getW()-128, 256+90+(i*20)+12, selBuild->ratio[i], selBuild->ratioLocal[i], 0, MAX_RATIO_RANGE);
-					globalContainer->gfx->drawString(globalContainer->gfx->getW()-128+24, 256+90+(i*20)+12, globalContainer->littleFont, Toolkit::getStringTable()->getString("[Unit type]", i));
-				}
-			}
 
 			// ressources in
 			unsigned j = 0;
 	// draw network latency
 	dec += 110;
 	int cpuLoadMax=0;
+	int cpuLoadMaxIndex=0;
 	for (int i=0; i<SMOOTH_CPU_LOAD_WINDOW_LENGTH; i++)
 		if (cpuLoadMax<smoothedCpuLoad[i])
+		{
 			cpuLoadMax=smoothedCpuLoad[i];
-	if (cpuLoadMax<game.session.gameTPF-8)
+			cpuLoadMaxIndex=i;
+		}
+	int cpuLoad=0;
+	for (int i=0; i<SMOOTH_CPU_LOAD_WINDOW_LENGTH; i++)
+		if (i!=cpuLoadMaxIndex && cpuLoad<smoothedCpuLoad[i])
+			cpuLoad=smoothedCpuLoad[i];
+	if (cpuLoad<game.session.gameTPF-8)
 		memcpy(actC, greenC, sizeof(greenC));
-	else if (cpuLoadMax<game.session.gameTPF)
+	else if (cpuLoad<game.session.gameTPF)
 		memcpy(actC, yellowC, sizeof(yellowC));
 	else
 		memcpy(actC, redC, sizeof(redC));
 	
-	globalContainer->gfx->drawFilledRect(dec, 4, cpuLoadMax, 8, actC[0], actC[1], actC[2]);
+	globalContainer->gfx->drawFilledRect(dec, 4, cpuLoad, 8, actC[0], actC[1], actC[2]);
 	globalContainer->gfx->drawVertLine(dec, 2, 12, 200, 200, 200);
 	globalContainer->gfx->drawVertLine(dec+40, 2, 12, 200, 200, 200);
 	
 	for (int i=0; i<40; i++)
 		sum+=delayInsideStats[i];
 	fprintf(logFile, "delayInsideStats: (sum=%d)\n", sum);
-	for (int i=0; i<10; i++)
+	for (int i=0; i<40; i++)
 		fprintf(logFile, "delayInsideStats[%2d]=%5d (%4f%%)\n", i, delayInsideStats[i], (float)(100.*delayInsideStats[i])/(float)sum);
 	fprintf(logFile, "\n");