Преглед на файлове

* fix for bugs 47 and 89

mateuszb преди 16 години
родител
ревизия
ad0848f1d2
променени са 5 файла, в които са добавени 45 реда и са изтрити 7 реда
  1. 6 2
      client/CBattleInterface.cpp
  2. 6 0
      client/CConfigHandler.cpp
  3. 2 0
      client/CConfigHandler.h
  4. 23 4
      client/GUIClasses.cpp
  5. 8 1
      config/settings.txt

+ 6 - 2
client/CBattleInterface.cpp

@@ -790,6 +790,10 @@ CBattleAttack::CBattleAttack(CBattleInterface * _owner, int _stackID, int _dest)
 {
 	attackedStack = LOCPLINT->cb->battleGetStackByPos(_dest, false);
 	attackingStack = LOCPLINT->cb->battleGetStackByID(_stackID, false);
+
+	assert(attackedStack && "attackedStack is NULL in CBattleAttack::CBattleAttack !\n");
+	assert(attackingStack && "attackingStack is NULL in CBattleAttack::CBattleAttack !\n");
+
 	attackingStackPosBeforeReturn = attackingStack->position;
 }
 
@@ -3336,8 +3340,8 @@ void CBattleHex::mouseMoved(const SDL_MouseMotionEvent &sEvent)
 			LOCPLINT->cb->battleGetStackByPos(myNumber)->alive())
 		{
 			char tabh[160];
-			CStack attackedStack = *LOCPLINT->cb->battleGetStackByPos(myNumber);
-			const std::string & attackedName = attackedStack.amount == 1 ? attackedStack.creature->nameSing : attackedStack.creature->namePl;
+			const CStack * attackedStack = LOCPLINT->cb->battleGetStackByPos(myNumber);
+			const std::string & attackedName = attackedStack->amount == 1 ? attackedStack->creature->nameSing : attackedStack->creature->namePl;
 			sprintf(tabh, CGI->generaltexth->allTexts[220].c_str(), attackedName.c_str());
 			myInterface->console->alterTxt = std::string(tabh);
 			setAlterText = true;

+ 6 - 0
client/CConfigHandler.cpp

@@ -288,6 +288,12 @@ struct SettingsGrammar : public grammar<SettingsGrammar>
 							  | "graphic=" >> fname[AddGemName()]
 							) 
 						 )
+				 | str_p("InGameConsole:") >> 
+						*(	
+							(	"maxInputPerLine=" >> uint_p[SetAdventureProp_a(&AdventureMapConfig::inputLineLength)]
+							  |	"maxOutputPerLine=" >> uint_p[SetAdventureProp_a(&AdventureMapConfig::outputLineLength)]
+							) 
+						 )
 				;
 			AdvMapOptionsSequence = *(AdvMapOption >> (';' | eps_p[lerror("Semicolon lacking in advmapopt!")]));
 			GUIResolution = (uint_p[assign_a(curRes.first)] >> 'x' >> uint_p[assign_a(curRes.second)])

+ 2 - 0
client/CConfigHandler.h

@@ -59,6 +59,8 @@ namespace config
 		//gems
 		int gemX[4], gemY[4];
 		std::vector<std::string> gemG;
+		//in-game console
+		int inputLineLength, outputLineLength;
 	};
 	struct GUIOptions
 	{

+ 23 - 4
client/GUIClasses.cpp

@@ -3179,11 +3179,30 @@ void CInGameConsole::show(SDL_Surface * to)
 void CInGameConsole::print(const std::string &txt)
 {
 	texts_mx.lock();
+	int lineLen = conf.go()->ac.outputLineLength;
 
-	texts.push_back(std::make_pair(txt, SDL_GetTicks()));
-	if(texts.size() > maxDisplayedTexts)
+	if(txt.size() < lineLen)
 	{
-		texts.pop_front();
+		texts.push_back(std::make_pair(txt, SDL_GetTicks()));
+		if(texts.size() > maxDisplayedTexts)
+		{
+			texts.pop_front();
+		}
+	}
+	else
+	{
+		for(int g=0; g<txt.size() / lineLen + 1; ++g)
+		{
+			std::string part = txt.substr(g * lineLen, lineLen);
+			if(part.size() == 0)
+				break;
+
+			texts.push_back(std::make_pair(part, SDL_GetTicks()));
+			if(texts.size() > maxDisplayedTexts)
+			{
+				texts.pop_front();
+			}
+		}
 	}
 
 	texts_mx.unlock();
@@ -3268,7 +3287,7 @@ void CInGameConsole::keyPressed (const SDL_KeyboardEvent & key)
 		}
 	default:
 		{
-			if(enteredText.size() > 0)
+			if(enteredText.size() > 0 && enteredText.size() < conf.go()->ac.inputLineLength)
 			{
 				if( key.keysym.unicode < 0x80 && key.keysym.unicode > 0 )
 				{

+ 8 - 1
config/settings.txt

@@ -16,7 +16,8 @@ GUISettings
 	{
 		AdventureMap
 		{
-			AdvMap: x=7 y=6 width=593 height=547 smoothMove=1;
+			InGameConsole: maxInputPerLine=60 maxOutputPerLine=40;
+			AdvMap: x=7 y=6 width=593 height=547 smoothMove=1 puzzleSepia=1;
 			InfoBox: x=605 y=389;
 			gem0: x=6 y=508 graphic=agemLL.def;
 			gem1: x=556 y=508 graphic=agemLR.def;
@@ -44,6 +45,7 @@ GUISettings
 	{
 		AdventureMap
 		{
+			InGameConsole: maxInputPerLine=60 maxOutputPerLine=40;
 			AdvMap: x=7 y=6 width=817 height=547 smoothMove=1 puzzleSepia=1;
 			InfoBox: x=829 y=389;
 		 	gem0: x=6 y=508 graphic=agemLL.def;
@@ -73,6 +75,7 @@ GUISettings
 	{
 		AdventureMap
 		{
+			InGameConsole: maxInputPerLine=60 maxOutputPerLine=40;
 			AdvMap: x=7 y=6 width=817 height=715 smoothMove=1 puzzleSepia=1;
 			InfoBox: x=829 y=557;
 			gem0: x=6 y=676 graphic=agemLL.def;
@@ -101,6 +104,7 @@ GUISettings
 	{
 		AdventureMap
 		{
+			InGameConsole: maxInputPerLine=60 maxOutputPerLine=40;
 			AdvMap: x=7 y=6 width=1073 height=907 smoothMove=1 puzzleSepia=1;
 			InfoBox: x=1085 y=749;
 			gem0: x=6 y=868 graphic=agemLL.def;
@@ -129,6 +133,7 @@ GUISettings
 	{
 		AdventureMap
 		{
+			InGameConsole: maxInputPerLine=60 maxOutputPerLine=40;
 			AdvMap: x=7 y=6 width=1073 height=971 smoothMove=1 puzzleSepia=1;
 			InfoBox: x=1085 y=557;
 			gem0: x=6 y=932 graphic=agemLL.def;
@@ -157,6 +162,7 @@ GUISettings
 	{
 		AdventureMap
 		{
+			InGameConsole: maxInputPerLine=60 maxOutputPerLine=40;
 			AdvMap: x=7 y=7 width=1234 height=846 smoothMove=1 puzzleSepia=1;
 			InfoBox: x=1246 y=690;
 			gem0: x=6 y=808 graphic=agemLL.def;
@@ -185,6 +191,7 @@ GUISettings
 	{
 		AdventureMap
 		{
+			InGameConsole: maxInputPerLine=60 maxOutputPerLine=40;
 			AdvMap: x=7 y=6 width=1395 height=1147 smoothMove=1 puzzleSepia=1;
 			InfoBox: x=1406 y=989;
 			gem0: x=6 y=1108 graphic=agemLL.def;