2019-11-22 21:43 CET

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0000688Spring engineGeneralpublic2008-01-20 18:18
Reporterrattle 
Assigned ToAuswaschbar 
PrioritynormalSeverityfeatureReproducibilityalways
StatusresolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0000688: [patch] NETMSG_KILLALLUNITS
DescriptionA substitute for the current CMD_SELFD method, hopefully not broken. Tested it through COB.
TagsNo tags attached.
Checked infolog.txt for Errors
Attached Files
  • patch file icon NETMSG_KILLALLUNITS.patch (4,175 bytes) 2007-11-20 04:25 -
    Index: Game/Game.cpp
    ===================================================================
    --- Game/Game.cpp	(revision 4836)
    +++ Game/Game.cpp	(working copy)
    @@ -3003,6 +3003,27 @@
     				break;
     			}
     
    +			case NETMSG_KILLALLUNITS: {
    +				const int player = inbuf[3];
    +				if ((player < 0) || (player >= MAX_PLAYERS)) {
    +					logOutput.Print("Got invalid player num %i in KillAllUnits message", player);
    +				}
    +				CUnitSet* tu = &gs->Team(player)->units;
    +				for(CUnitSet::iterator ui = tu->begin(); ui != tu->end(); ++ui) {
    +					if ((*ui) != NULL)
    +					{
    +						if ((*ui)->beingBuilt) {
    +							(*ui)->KillUnit(false, true, NULL); // kill units under construction without explosion
    +						}
    +						else {
    +							(*ui)->KillUnit(true, false, NULL);
    +						}
    +					}
    +				}
    +				AddTraffic(player, packetCode, dataLength);
    +				break;
    +			}
    +
     			case NETMSG_SYNCREQUEST: {
     				// TODO rename this net message, change error msg, etc.
     				ENTER_MIXED;
    Index: Game/GameServer.cpp
    ===================================================================
    --- Game/GameServer.cpp	(revision 4836)
    +++ Game/GameServer.cpp	(working copy)
    @@ -525,7 +525,16 @@
     							serverNet->RawSend(inbuf,*((short int*)&inbuf[1])); //forward data
     						}
     						break;
    -
    +					
    +					case NETMSG_KILLALLUNITS:
    +						if(inbuf[3]!=a){
    +							SendSystemMsg("Server: Warning got KillAllUnits from %i claiming to be from %i",a,inbuf[3]);
    +						}
    +						else if(!play) {
    +							serverNet->SendKillAllUnits(inbuf[1]); //forward data
    +						}
    +						break;
    +					
     					case NETMSG_SYNCRESPONSE:
     #ifdef SYNCCHECK
     						if(inbuf[1]!=a){
    Index: Game/UI/QuitBox.cpp
    ===================================================================
    --- Game/UI/QuitBox.cpp	(revision 4836)
    +++ Game/UI/QuitBox.cpp	(working copy)
    @@ -255,8 +255,7 @@
     		}
     		// resign, so self-d all units
     		if(InBox(mx,my,box+resignQuitBox) || InBox(mx,my,box+resignBox)) {
    -			c.id=CMD_SELFD;
    -			selectedUnits.GiveCommand(c,false);
    +			net->SendKillAllUnits(gu->myPlayerNum);
     		}
     		// (resign and) quit, so leave the game
     		if(InBox(mx,my,box+resignQuitBox)){
    Index: System/BaseNetProtocol.cpp
    ===================================================================
    --- System/BaseNetProtocol.cpp	(revision 4836)
    +++ System/BaseNetProtocol.cpp	(working copy)
    @@ -40,6 +40,7 @@
     	RegisterMessage(NETMSG_PLAYERLEFT, 3);
     	RegisterMessage(NETMSG_MODNAME, -1);
     	RegisterMessage(NETMSG_LUAMSG, -2);
    +	RegisterMessage(NETMSG_KILLALLUNITS, 2);
     }
     
     CBaseNetProtocol::~CBaseNetProtocol()
    @@ -313,7 +314,7 @@
     	return SendSTLData<uint, std::string> (NETMSG_MODNAME, checksum, newModName);
     }
     
    -//  NETMSG_LUAMSG          = 40, // uchar myPlayerNum; std::string modName;   (e.g. `custom msg')
    +//  NETMSG_LUAMSG           = 50, // uchar myPlayerNum; std::string modName;   (e.g. `custom msg')
     
     void CBaseNetProtocol::SendLuaMsg(uchar myPlayerNum, uchar script, uchar mode,
                                       const std::string& msg)
    @@ -329,9 +330,16 @@
       data.push_back(script);
       data.push_back(mode);
       data.append(msg);
    -  return SendData((const unsigned char*)data.data(), msgLen);    
    +  return SendData((const unsigned char*)data.data(), msgLen);
     }
     
    +//  NETMSG_KILLALLUNITS   =  51 // uchar myPlayerNum;
    +
    +void CBaseNetProtocol::SendKillAllUnits(uchar myPlayerNum)
    +{
    +	return SendData<uchar>(NETMSG_KILLALLUNITS, myPlayerNum);
    +}
    +
     /* FIXME: add these:
     
     #ifdef SYNCDEBUG
    @@ -343,4 +351,3 @@
     #endif // SYNCDEBUG
     
     */
    - 
    Index: System/BaseNetProtocol.h
    ===================================================================
    --- System/BaseNetProtocol.h	(revision 4836)
    +++ System/BaseNetProtocol.h	(working copy)
    @@ -69,6 +69,7 @@
     	NETMSG_SD_RESET         = 45,
     #endif // SYNCDEBUG
     	NETMSG_LUAMSG           = 50, // uchar myPlayerNum, std::string msg
    +	NETMSG_KILLALLUNITS     = 51, 
     };
     
     /**
    @@ -128,6 +129,7 @@
     	void SendPlayerLeft(uchar myPlayerNum, uchar bIntended);
     	void SendModName(const uint checksum, const std::string& modName);
     	void SendLuaMsg(uchar myPlayerNum, uchar script, uchar mode, const std::string& msg);
    +	void SendKillAllUnits(uchar myPlayerNum);
     
     private:
     };
    
    patch file icon NETMSG_KILLALLUNITS.patch (4,175 bytes) 2007-11-20 04:25 +
  • patch file icon NETMSG_RESIGN.patch (4,192 bytes) 2007-11-21 05:59 -
    Index: rts/Game/Game.cpp
    ===================================================================
    --- rts/Game/Game.cpp	(revision 4844)
    +++ rts/Game/Game.cpp	(working copy)
    @@ -3003,6 +3003,27 @@
     				break;
     			}
     
    +			case NETMSG_RESIGN: {
    +				const int player = inbuf[3];
    +				if ((player < 0) || (player >= MAX_PLAYERS)) {
    +					logOutput.Print("Got invalid player num %i in Resign message", player);
    +				}
    +				CUnitSet* tu = &gs->Team(player)->units;
    +				for(CUnitSet::iterator ui = tu->begin(); ui != tu->end(); ++ui) {
    +					if ((*ui) != NULL)
    +					{
    +						if ((*ui)->beingBuilt) {
    +							(*ui)->KillUnit(false, true, NULL); // kill units under construction without explosion
    +						}
    +						else {
    +							(*ui)->KillUnit(true, false, NULL);
    +						}
    +					}
    +				}
    +				AddTraffic(player, packetCode, dataLength);
    +				break;
    +			}
    +
     			case NETMSG_SYNCREQUEST: {
     				// TODO rename this net message, change error msg, etc.
     				ENTER_MIXED;
    Index: rts/Game/GameServer.cpp
    ===================================================================
    --- rts/Game/GameServer.cpp	(revision 4844)
    +++ rts/Game/GameServer.cpp	(working copy)
    @@ -525,7 +525,16 @@
     							serverNet->RawSend(inbuf,*((short int*)&inbuf[1])); //forward data
     						}
     						break;
    -
    +					
    +					case NETMSG_RESIGN:
    +						if(inbuf[3]!=a){
    +							SendSystemMsg("Server: Warning got Resign from %i claiming to be from %i",a,inbuf[3]);
    +						}
    +						else if(!play) {
    +							serverNet->SendResign(inbuf[1]); //forward data
    +						}
    +						break;
    +					
     					case NETMSG_SYNCRESPONSE:
     #ifdef SYNCCHECK
     						if(inbuf[1]!=a){
    Index: rts/Game/UI/QuitBox.cpp
    ===================================================================
    --- rts/Game/UI/QuitBox.cpp	(revision 4844)
    +++ rts/Game/UI/QuitBox.cpp	(working copy)
    @@ -255,8 +255,7 @@
     		}
     		// resign, so self-d all units
     		if(InBox(mx,my,box+resignQuitBox) || InBox(mx,my,box+resignBox)) {
    -			c.id=CMD_SELFD;
    -			selectedUnits.GiveCommand(c,false);
    +			net->SendResign(gu->myPlayerNum);
     		}
     		// (resign and) quit, so leave the game
     		if(InBox(mx,my,box+resignQuitBox)){
    Index: rts/System/BaseNetProtocol.cpp
    ===================================================================
    --- rts/System/BaseNetProtocol.cpp	(revision 4844)
    +++ rts/System/BaseNetProtocol.cpp	(working copy)
    @@ -40,6 +40,7 @@
     	RegisterMessage(NETMSG_PLAYERLEFT, 3);
     	RegisterMessage(NETMSG_MODNAME, -1);
     	RegisterMessage(NETMSG_LUAMSG, -2);
    +	RegisterMessage(NETMSG_RESIGN, 2);
     }
     
     CBaseNetProtocol::~CBaseNetProtocol()
    @@ -313,7 +314,7 @@
     	return SendSTLData<uint, std::string> (NETMSG_MODNAME, checksum, newModName);
     }
     
    -//  NETMSG_LUAMSG          = 40, // uchar myPlayerNum; std::string modName;   (e.g. `custom msg')
    +//  NETMSG_LUAMSG           = 50, // uchar myPlayerNum; std::string modName;   (e.g. `custom msg')
     
     void CBaseNetProtocol::SendLuaMsg(uchar myPlayerNum, uchar script, uchar mode,
                                       const std::string& msg)
    @@ -329,9 +330,16 @@
       data.push_back(script);
       data.push_back(mode);
       data.append(msg);
    -  return SendData((const unsigned char*)data.data(), msgLen);    
    +  return SendData((const unsigned char*)data.data(), msgLen);
     }
     
    +//  NETMSG_RESIGN           =  51 // uchar myPlayerNum;
    +
    +void CBaseNetProtocol::SendResign(uchar myPlayerNum)
    +{
    +	return SendData<uchar>(NETMSG_RESIGN, myPlayerNum);
    +}
    +
     /* FIXME: add these:
     
     #ifdef SYNCDEBUG
    @@ -343,4 +351,3 @@
     #endif // SYNCDEBUG
     
     */
    - 
    Index: rts/System/BaseNetProtocol.h
    ===================================================================
    --- rts/System/BaseNetProtocol.h	(revision 4844)
    +++ rts/System/BaseNetProtocol.h	(working copy)
    @@ -69,6 +69,7 @@
     	NETMSG_SD_RESET         = 45,
     #endif // SYNCDEBUG
     	NETMSG_LUAMSG           = 50, // uchar myPlayerNum, std::string msg
    +	NETMSG_RESIGN           = 51, 
     };
     
     /**
    @@ -128,9 +129,11 @@
     	void SendPlayerLeft(uchar myPlayerNum, uchar bIntended);
     	void SendModName(const uint checksum, const std::string& modName);
     	void SendLuaMsg(uchar myPlayerNum, uchar script, uchar mode, const std::string& msg);
    +	void SendResign(uchar myPlayerNum);
     
     private:
     };
     
     #endif
     
    +
    
    patch file icon NETMSG_RESIGN.patch (4,192 bytes) 2007-11-21 05:59 +

-Relationships
+Relationships

-Notes

~0001452

Auswaschbar (reporter)

Does it give any advantage over the current way of doing this?
Whats wrong with CMD_SELFD?

~0001453

rattle (reporter)

http://spring.clan-sy.com/mantis/view.php?id=687
So units which are immune to CMD_SELFD get properly destroyed on quit.

~0001456

rattle (reporter)

Renamed to resign

~0001463

Auswaschbar (reporter)

Last edited: 2007-11-23 12:48

Thanks for your patch so far.

I think it would be a good idea if:
- it would be more generic like NETMSG_TEAM
- it would support similar operations like:
  * give all units away
  * kill all units
  * resign (only change team to spectator)
- it would be extendible to support in the future:
  * diplomacy (allying) in-game

What do you think of this? Would you volunteer for it?
Thanks

~0001464

rattle (reporter)

I'll give it a shot

~0001874

Auswaschbar (reporter)

commited in rev5354
+Notes

-Issue History
Date Modified Username Field Change
2007-11-20 04:25 rattle New Issue
2007-11-20 04:25 rattle File Added: NETMSG_KILLALLUNITS.patch
2007-11-20 19:17 Auswaschbar Note Added: 0001452
2007-11-20 19:33 rattle Note Added: 0001453
2007-11-21 05:59 rattle File Added: NETMSG_RESIGN.patch
2007-11-21 06:00 rattle Note Added: 0001456
2007-11-23 12:48 Auswaschbar Note Added: 0001463
2007-11-23 12:48 Auswaschbar Note Edited: 0001463
2007-11-23 19:49 rattle Note Added: 0001464
2008-01-16 16:41 Auswaschbar Status new => assigned
2008-01-16 16:41 Auswaschbar Assigned To => Auswaschbar
2008-01-20 18:18 Auswaschbar Status assigned => resolved
2008-01-20 18:18 Auswaschbar Resolution open => fixed
2008-01-20 18:18 Auswaschbar Note Added: 0001874
+Issue History