- Make hwengine protocol more obvious
authorunc0rr
Sat, 22 Sep 2007 09:49:55 +0000
changeset 605 2651c3fe4567
parent 604 2f1165467a66
child 606 9d800fdfd3bd
- Make hwengine protocol more obvious - Update protocol version due to changes
CMakeLists.txt
QTfrontend/team.cpp
hedgewars/CCHandlers.inc
hedgewars/uConsole.pas
--- a/CMakeLists.txt	Fri Sep 21 21:51:48 2007 +0000
+++ b/CMakeLists.txt	Sat Sep 22 09:49:55 2007 +0000
@@ -9,7 +9,7 @@
 endif(DEFINED DATA_INSTALL_DIR)
 set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
 
-set(HEDGEWARS_PROTO_VER 6)
+set(HEDGEWARS_PROTO_VER 7)
 
 add_subdirectory(bin)
 add_subdirectory(QTfrontend)
--- a/QTfrontend/team.cpp	Fri Sep 21 21:51:48 2007 +0000
+++ b/QTfrontend/team.cpp	Sat Sep 22 09:49:55 2007 +0000
@@ -212,13 +212,9 @@
 QStringList HWTeam::TeamGameConfig(quint32 InitHealth) const
 {
 	QStringList sl;
-	sl.push_back(QString("eaddteam %1").arg(teamColor.rgb() & 0xffffff));
+	sl.push_back(QString("eaddteam %1 %2").arg(teamColor.rgb() & 0xffffff).arg(TeamName));
 	if (m_netID)
 		sl.push_back("erdriven");
-	sl.push_back("ename team " + TeamName);
-
-	for (int i = 0; i < numHedgehogs; i++)
-		sl.push_back(QString("ename hh%1 ").arg(i).append(HHName[i]));
 
 	sl.push_back(QString("egrave " + Grave));
 	sl.push_back(QString("efort " + Fort));
@@ -228,9 +224,10 @@
 			sl.push_back(QString("ebind " + binds[i].strbind + " " + binds[i].action));
 
 	for (int t = 0; t < numHedgehogs; t++)
-	  sl.push_back(QString("eaddhh %1 %2")
+	  sl.push_back(QString("eaddhh %1 %2 %3")
 		       .arg(QString::number(difficulty),
-			    QString::number(InitHealth)));
+			    QString::number(InitHealth),
+			    HHName[t]));
 	return sl;
 }
 
--- a/hedgewars/CCHandlers.inc	Fri Sep 21 21:51:48 2007 +0000
+++ b/hedgewars/CCHandlers.inc	Sat Sep 22 09:49:55 2007 +0000
@@ -48,15 +48,17 @@
 
 procedure chAddTeam(var s: shortstring);
 var Color: Longword;
+    ts: shortstring;
 begin
 if isDeveloperMode then
    begin
    ParseCommand('ammstore 93919294221912103323', true);
+   SplitBySpace(s, ts);
    val(s, Color);
    TryDo(Color <> 0, 'Error: black team color', true);
 
    AddTeam(Color);
-
+   CurrentTeam^.TeamName:= ts;
    if GameType in [gmtDemo, gmtSave] then CurrentTeam^.ExtDriven:= true
    end
 end;
@@ -68,20 +70,6 @@
 CurrentTeam^.ExtDriven:= true
 end;
 
-procedure chName(var id: shortstring);
-var s: shortstring;
-begin
-if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/name"', true);
-SplitBySpace(id, s);
-if s[1]='"' then Delete(s, 1, 1);
-if s[byte(s[0])]='"' then Delete(s, byte(s[0]), 1);
-if id = 'team' then CurrentTeam^.TeamName:= s
-else if (id[1] = 'h') and (id[2] = 'h')
-     and (id[3] >= '0') and (id[3] <= chr(ord('0')+cMaxHHIndex)) then
-   CurrentTeam^.Hedgehogs[byte(id[3])-48].Name:= s
-else OutError(errmsgUnknownVariable + ' "' + id + '"', false)
-end;
-
 procedure chGrave(var s: shortstring);
 begin
 if CurrentTeam = nil then OutError(errmsgIncorrectUse + ' "/grave"', true);
@@ -109,11 +97,13 @@
      CurrentHedgehog:= @Hedgehogs[HedgehogsNumber];
      val(id, CurrentHedgehog^.BotLevel);
      Gear:= AddGear(0, 0, gtHedgehog, 0, _0, _0, 0);
+     SplitBySpace(s, id);
      val(s, Gear^.Health);
      TryDo(Gear^.Health > 0, 'Invalid hedgehog health', true);
      PHedgehog(Gear^.Hedgehog)^.Team:= CurrentTeam;
      Hedgehogs[HedgehogsNumber].AmmoStore:= TeamsCount - 1;
      Hedgehogs[HedgehogsNumber].Gear:= Gear;
+     Hedgehogs[HedgehogsNumber].Name:= id;
      inc(HedgehogsNumber)
      end
 end;
--- a/hedgewars/uConsole.pas	Fri Sep 21 21:51:48 2007 +0000
+++ b/hedgewars/uConsole.pas	Sat Sep 22 09:49:55 2007 +0000
@@ -290,7 +290,6 @@
 RegisterVariable('c_height', vtLongInt, @cConsoleHeight , false);
 RegisterVariable('gmflags' , vtLongInt, @GameFlags      , false);
 RegisterVariable('turntime', vtLongInt, @cHedgehogTurnTime, false);
-RegisterVariable('name'    , vtCommand, @chName         , false);
 RegisterVariable('fort'    , vtCommand, @chFort         , false);
 RegisterVariable('grave'   , vtCommand, @chGrave        , false);
 RegisterVariable('bind'    , vtCommand, @chBind         , true );