Lobby chat should work now
authorunc0rr
Fri, 02 Jan 2009 19:54:23 +0000
changeset 1568 15a446307993
parent 1567 95d7aab0df3f
child 1569 4456a0dfc647
Lobby chat should work now
QTfrontend/hwform.cpp
QTfrontend/newnetclient.cpp
QTfrontend/newnetclient.h
netserver/HWProto.hs
--- a/QTfrontend/hwform.cpp	Fri Jan 02 19:49:04 2009 +0000
+++ b/QTfrontend/hwform.cpp	Fri Jan 02 19:54:23 2009 +0000
@@ -474,6 +474,13 @@
 		hwnet, SLOT(kickPlayer(const QString&)));
 	connect(ui.pageNetGame->BtnGo, SIGNAL(clicked()), hwnet, SLOT(ToggleReady()));
 
+	connect(ui.pageRoomsList->chatWidget, SIGNAL(chatLine(const QString&)),
+		hwnet, SLOT(chatLineToLobby(const QString&)));
+	connect(hwnet, SIGNAL(chatStringLobby(const QString&)),
+		ui.pageRoomsList->chatWidget, SLOT(onChatString(const QString&)));
+	connect(hwnet, SIGNAL(chatStringFromMeLobby(const QString&)),
+		ui.pageRoomsList->chatWidget, SLOT(onChatString(const QString&)));
+
 	connect(hwnet, SIGNAL(nickAdded(const QString&)),
 		ui.pageNetGame->pChatWidget, SLOT(nickAdded(const QString&)));
 	connect(hwnet, SIGNAL(nickRemoved(const QString&)),
--- a/QTfrontend/newnetclient.cpp	Fri Jan 02 19:49:04 2009 +0000
+++ b/QTfrontend/newnetclient.cpp	Fri Jan 02 19:54:23 2009 +0000
@@ -261,7 +261,10 @@
 			qWarning("Net: Empty CHAT_STRING message");
 			return;
 		}
-		emit chatStringFromNet(formatChatMsg(lst[1], lst[2]));
+		if (netClientState == 2)
+			emit chatStringLobby(formatChatMsg(lst[1], lst[2]));
+		else
+			emit chatStringFromNet(formatChatMsg(lst[1], lst[2]));
 		return;
 	}
 
@@ -344,7 +347,7 @@
 		for(int i = 1; i < lst.size(); ++i)
 		{
 			emit nickAddedLobby(lst[i]);
-			//emit chatStringFromNet(QString(tr("*** %1 joined")).arg(lst[i]));
+			emit chatStringLobby(QString(tr("*** %1 joined")).arg(lst[i]));
 		}
 		return;
 	}
@@ -370,10 +373,10 @@
 			return;
 		}
 		emit nickRemovedLobby(lst[1]);
-		/*if (lst.size() < 3)
-			emit chatStringFromNet(QString(tr("*** %1 left")).arg(lst[1]));
+		if (lst.size() < 3)
+			emit chatStringLobby(QString(tr("*** %1 left")).arg(lst[1]));
 		else
-			emit chatStringFromNet(QString(tr("*** %1 left (%2)")).arg(lst[1], lst[2]));*/
+			emit chatStringLobby(QString(tr("*** %1 left (%2)")).arg(lst[1], lst[2]));
 		return;
 	}
 
@@ -590,10 +593,18 @@
 
 void HWNewNet::chatLineToNet(const QString& str)
 {
-  if(str!="") {
-    RawSendNet(QString("CHAT_STRING")+delimeter+str);
-    emit(chatStringFromMe(formatChatMsg(mynick, str)));
-  }
+	if(str != "") {
+		RawSendNet(QString("CHAT_STRING") + delimeter + str);
+		emit(chatStringFromMe(formatChatMsg(mynick, str)));
+	}
+}
+
+void HWNewNet::chatLineToLobby(const QString& str)
+{
+	if(str != "") {
+		RawSendNet(QString("CHAT_STRING") + delimeter + str);
+		emit(chatStringFromMeLobby(formatChatMsg(mynick, str)));
+	}
 }
 
 void HWNewNet::askRoomsList()
--- a/QTfrontend/newnetclient.h	Fri Jan 02 19:49:04 2009 +0000
+++ b/QTfrontend/newnetclient.h	Fri Jan 02 19:54:23 2009 +0000
@@ -109,8 +109,10 @@
   void solidChanged(bool value);
   void hhnumChanged(const HWTeam&);
   void teamColorChanged(const HWTeam&);
+  void chatStringLobby(const QString&);
   void chatStringFromNet(const QString&);
   void chatStringFromMe(const QString&);
+  void chatStringFromMeLobby(const QString&);
   void ammoChanged(const QString& name, const QString& ammo);
 
   void roomsList(const QStringList&);
@@ -122,6 +124,7 @@
  public slots:
   void ToggleReady();
   void chatLineToNet(const QString& str);
+  void chatLineToLobby(const QString& str);
   void SendNet(const QByteArray & buf);
   void AddTeam(const HWTeam & team);
   void RemoveTeam(const HWTeam& team);
--- a/netserver/HWProto.hs	Fri Jan 02 19:49:04 2009 +0000
+++ b/netserver/HWProto.hs	Fri Jan 02 19:54:23 2009 +0000
@@ -219,6 +219,9 @@
 handleCmd_noRoom client clients rooms ["JOIN", roomName] =
 	handleCmd_noRoom client clients rooms ["JOIN", roomName, ""]
 
+handleCmd_noRoom client _ _ ["CHAT_STRING", msg] =
+	(noChangeClients, noChangeRooms, answerChatString (nick client) msg)
+
 handleCmd_noRoom _ _ _ _ = (noChangeClients, noChangeRooms, answerBadCmd)