# HG changeset patch # User unc0rr # Date 1223492192 0 # Node ID c8994d47f41d894408c1f4b08744d43452c68fa9 # Parent 4b48ae1f0f53643ad8b49e4c97bf778574f32efd Adding teams now works diff -r 4b48ae1f0f53 -r c8994d47f41d QTfrontend/newnetclient.cpp --- a/QTfrontend/newnetclient.cpp Wed Oct 08 18:46:02 2008 +0000 +++ b/QTfrontend/newnetclient.cpp Wed Oct 08 18:56:32 2008 +0000 @@ -241,10 +241,10 @@ return; } - if (lst[0] == "ADDTEAM") { - if(lst.size() < 22) + if (lst[0] == "ADD_TEAM") { + if(lst.size() != 21) { - qWarning("Net: Too short ADDTEAM message"); + qWarning("Net: Bad ADDTEAM message"); return; } QStringList tmp = lst; @@ -259,7 +259,7 @@ qWarning("Net: Bad REMOVETEAM message"); return; } - m_pTeamSelWidget->removeNetTeam(HWTeam(lst[1], lst[2].toUInt())); + m_pTeamSelWidget->removeNetTeam(HWTeam(lst[1])); return; } @@ -284,7 +284,7 @@ return; } - if(lst[0]=="LEFT") { + if(lst[0] == "LEFT") { if(lst.size() < 2) { qWarning("Net: Bad LEFT message"); @@ -294,21 +294,21 @@ return; } - if (lst[0] == "RUNGAME") { - RunGame(); - return; - } + if (lst[0] == "RUNGAME") { + RunGame(); + return; + } - if(lst[0]=="TEAM_ACCEPTED") { - if(lst.size() < 3) - { - qWarning("Net: Bad TEAM_ACCEPTED message"); - return; - } - m_pTeamSelWidget->changeTeamStatus(lst[1]); - return; - } + if (lst[0] == "TEAM_ACCEPTED") { + if (lst.size() != 2) + { + qWarning("Net: Bad TEAM_ACCEPTED message"); + return; + } + m_pTeamSelWidget->changeTeamStatus(lst[1]); + return; + } if (lst[0] == "CONFIG_PARAM") { if(lst.size() < 3) @@ -345,7 +345,7 @@ emit ammoChanged(lst[3], lst[2]); return; } - QStringList hhTmpList = lst[1].split('+'); + QStringList hhTmpList = lst[1].split('+');// deprecated stuff if (hhTmpList[0] == "TEAM_COLOR") { HWTeam tmptm(hhTmpList[1]); tmptm.teamColor = QColor(lst[2]); @@ -363,8 +363,6 @@ } - // should be kinda game states, which don't allow "GAMEMSG:" at configure step, - // "CONNECTED" at round phase, etc. if (lst[0] == "GAMEMSG") { if(lst.size() < 2) { diff -r 4b48ae1f0f53 -r c8994d47f41d QTfrontend/team.cpp --- a/QTfrontend/team.cpp Wed Oct 08 18:46:02 2008 +0000 +++ b/QTfrontend/team.cpp Wed Oct 08 18:56:32 2008 +0000 @@ -28,10 +28,10 @@ #include "hwconsts.h" #include "hats.h" -HWTeam::HWTeam(const QString & teamname, unsigned int netID) : - difficulty(0), - numHedgehogs(4), - m_netID(netID) +HWTeam::HWTeam(const QString & teamname) : + difficulty(0), + numHedgehogs(4), + m_isNetTeam(false) { TeamName = teamname; OldTeamName = TeamName; @@ -50,26 +50,26 @@ } HWTeam::HWTeam(const QStringList& strLst) : - numHedgehogs(4) + numHedgehogs(4), + m_isNetTeam(true) { // net teams are configured from QStringList - if(strLst.size() < 21) throw HWTeamConstructException(); - TeamName=strLst[0]; - m_netID=strLst[1].toUInt(); - Grave=strLst[2]; - Fort=strLst[3]; - difficulty=strLst[4].toUInt(); + if(strLst.size() < 20) throw HWTeamConstructException(); + TeamName = strLst[0]; + Grave = strLst[1]; + Fort = strLst[2]; + difficulty = strLst[3].toUInt(); for(int i = 0; i < 8; i++) { - HHName[i]=strLst[i * 2 + 5]; - HHHat[i]=strLst[i * 2 + 6]; + HHName[i]=strLst[i * 2 + 4]; + HHHat[i]=strLst[i * 2 + 5]; } } HWTeam::HWTeam(quint8 num) : difficulty(0), numHedgehogs(4), - m_netID(0) + m_isNetTeam(false) { num %= PREDEFTEAMS_COUNT; TeamName = QApplication::translate("teams", pteams[num].TeamName); @@ -242,13 +242,13 @@ QStringList sl; sl.push_back(QString("eaddteam %1 %2").arg(teamColor.rgb() & 0xffffff).arg(TeamName)); - if (m_netID) + if (m_isNetTeam) sl.push_back("erdriven"); sl.push_back(QString("egrave " + Grave)); sl.push_back(QString("efort " + Fort)); - if (!m_netID) + if (!m_isNetTeam) for(int i = 0; i < BINDS_NUMBER; i++) sl.push_back(QString("ebind " + binds[i].strbind + " " + binds[i].action)); @@ -266,18 +266,14 @@ bool HWTeam::isNetTeam() const { - return m_netID!=0; + return m_isNetTeam; } -unsigned int HWTeam::getNetID() const -{ - return m_netID; -} bool HWTeam::operator==(const HWTeam& t1) const { - return TeamName==t1.TeamName && m_netID==t1.m_netID; + return TeamName==t1.TeamName; } bool HWTeam::operator<(const HWTeam& t1) const { - return m_netID [name, hat]) $ hedgehogs team -- Main state-independent cmd handler handleCmd :: CmdHandler @@ -129,11 +133,12 @@ if length (teams clRoom) == 6 then (noChangeClients, noChangeRooms, answerCantAdd) else - (noChangeClients, modifyRoom clRoom{teams = newTeam : teams clRoom}, []) + (noChangeClients, modifyRoom clRoom{teams = newTeam : teams clRoom}, answerTeamAccepted newTeam ++ answerAddTeam newTeam) where clRoom = roomByName (room client) rooms newTeam = (TeamInfo name color grave fort difficulty (hhsList hhsInfo)) difficulty = fromMaybe 0 (maybeRead difStr :: Maybe Int) + hhsList [] = [] hhsList (n:h:hhs) = HedgehogInfo n h : hhsList hhs