2025-07-07 23:23 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0000493Spring engineGeneralpublic2007-04-04 23:15
Reporterdet 
Assigned Totvo 
PrioritynormalSeverityfeatureReproducibilityN/A
StatusresolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0000493: [PATCH] New game mode
DescriptionI introduce a new game mode (GameMode = 3) that is more flexible than the older Commander Ends mode (GameMode = 2). You can find a description of it here: http://spring.clan-sy.com/wiki/Lineage. Attached is a patch genereated with "svn diff".
TagsNo tags attached.
Checked infolog.txt for Errors
Attached Files
  • patch file icon lineage.patch (4,897 bytes) 2007-03-22 13:41 -
    Index: rts/Sim/Units/Unit.cpp
    ===================================================================
    --- rts/Sim/Units/Unit.cpp	(revision 3481)
    +++ rts/Sim/Units/Unit.cpp	(working copy)
    @@ -237,6 +237,7 @@
     	pos = position;
     	team = Team;
     	allyteam = gs->AllyTeam(Team);
    +        lineage = Team;
     	unitDef = def;
     
     	localmodel=NULL;
    @@ -1309,6 +1310,7 @@
     	blockHeightChanges=false;
     	if(unitDef->isCommander)
     		gs->Team(team)->CommanderDied(this);
    +        gs->Team(this->lineage)->LeftLineage(this);
     
     	if(!reclaimed && !beingBuilt){
     		string exp;
    Index: rts/Sim/Units/UnitTypes/Builder.cpp
    ===================================================================
    --- rts/Sim/Units/UnitTypes/Builder.cpp	(revision 3481)
    +++ rts/Sim/Units/UnitTypes/Builder.cpp	(working copy)
    @@ -215,6 +215,7 @@
     					curResurrect->UnBlock();
     					CUnit* u=unitLoader.LoadUnit(curResurrect->createdFromUnit,curResurrect->pos,team,false,curResurrect->buildFacing);
     					u->health*=0.05f;
    +                                        u->lineage = this->lineage;
     					lastResurrected=u->id;
     					curResurrect->resurrectProgress=0;
     					featureHandler->DeleteFeature(curResurrect);
    @@ -236,7 +237,11 @@
     						logOutput.SetLastMsgPos(pos);
     					}
     					ENTER_SYNCED;
    -				}
    +				} else {
    +                                        int oldLineage = curCapture->lineage;
    +                                        curCapture->lineage = this->lineage;
    +                                        gs->Team(oldLineage)->LeftLineage(curCapture);
    +                                }
     				curCapture->captureProgress=0.5f;	//make units somewhat easier to capture back after first capture
     				StopBuild(true);
     			}
    @@ -415,6 +420,7 @@
     	nextBuildPos=buildInfo.pos;
     
     	CUnit* b=unitLoader.LoadUnit(nextBuildType,nextBuildPos,team,true, buildInfo.buildFacing);
    +        b->lineage = this->lineage;
     	AddDeathDependence(b);
     	curBuild=b;
     	if (mapDamage->disabled && !(curBuild->floatOnWater)) {
    Index: rts/Sim/Units/UnitTypes/Factory.cpp
    ===================================================================
    --- rts/Sim/Units/UnitTypes/Factory.cpp	(revision 3481)
    +++ rts/Sim/Units/UnitTypes/Factory.cpp	(working copy)
    @@ -94,6 +94,7 @@
     		if(canBuild){
     			quedBuild=false;
     			CUnit* b=unitLoader.LoadUnit(nextBuild,buildPos+float3(0.01f,0.01f,0.01f),team,true,buildFacing);
    +                        b->lineage = this->lineage;
     			AddDeathDependence(b);
     			curBuild=b;
     
    Index: rts/Sim/Units/Unit.h
    ===================================================================
    --- rts/Sim/Units/Unit.h	(revision 3481)
    +++ rts/Sim/Units/Unit.h	(working copy)
    @@ -95,6 +95,7 @@
     	int id;
     	int team;								
     	int allyteam;
    +        int lineage;
     	int aihint;							//tells the unit main function to the ai
     
     	SyncedFloat3 frontdir;				//the forward direction of the unit
    Index: rts/Game/Team.cpp
    ===================================================================
    --- rts/Game/Team.cpp	(revision 3479)
    +++ rts/Game/Team.cpp	(working copy)
    @@ -278,3 +278,13 @@
     	assert(commander->unitDef->isCommander);
     	--numCommanders;
     }
    +
    +void CTeam::LeftLineage(CUnit* unit)
    +{
    +    if (gs->gameMode == 2 && unit->id == this->lineageRoot) {
    +        for(list<CUnit*>::iterator ui = uh->activeUnits.begin(); ui != uh->activeUnits.end(); ++ui) {
    +            if ((*ui)->lineage == this->teamNum)
    +                (*ui)->KillUnit(true, false, 0);
    +        }
    +    }
    +}
    Index: rts/Game/StartScripts/CommanderScript.cpp
    ===================================================================
    --- rts/Game/StartScripts/CommanderScript.cpp	(revision 3479)
    +++ rts/Game/StartScripts/CommanderScript.cpp	(working copy)
    @@ -6,6 +6,7 @@
     #include <cctype>
     #include "Game/Team.h"
     #include "Game/GameSetup.h"
    +#include "Sim/Units/Unit.h"
     #include "Sim/Units/UnitDefHandler.h"
     #include "ExternalAI/GlobalAIHandler.h"
     #include "Map/ReadMap.h"
    @@ -46,7 +47,8 @@
     							ud->metalStorage=gs->Team(a)->metalStorage;			//make sure the cmd has the right amount of storage
     							ud->energyStorage=gs->Team(a)->energyStorage;
     
    -							unitLoader.LoadUnit(cmdType,gs->Team(a)->startPos,a,false);
    +							CUnit *u = unitLoader.LoadUnit(cmdType,gs->Team(a)->startPos,a,false);
    +                                                        gs->Team(a)->lineageRoot = u->id;
     							break;
     						}
     					}
    Index: rts/Game/Team.h
    ===================================================================
    --- rts/Game/Team.h	(revision 3479)
    +++ rts/Game/Team.h	(working copy)
    @@ -48,6 +48,7 @@
     	bool isDead;
     	unsigned char color[4];
     	int leader;
    +        int lineageRoot;
     
     	float handicap;
     	std::string side;
    @@ -102,6 +103,7 @@
     	int numCommanders;		//number of units with commander tag in team, if it reaches zero with cmd ends the team dies
     	std::list<Statistics> statHistory;
     	void CommanderDied(CUnit* commander);
    +	void LeftLineage(CUnit* unit);
     };
     
     #endif /* TEAM_H */
    
    patch file icon lineage.patch (4,897 bytes) 2007-03-22 13:41 +

-Relationships
+Relationships

-Notes

~0000809

det (reporter)

I made a mistake, this GameMode is 2, the older Commander ends mode is 1.

~0000812

KDR_11k (reporter)

Careful, some mods may declare more than one commander unit so e.g. all buildings have to be destroyed to trigger comm ends (kinda like C&C quick match option).

~0000814

det (reporter)

Last edited: 2007-03-25 09:58

That kind of gameplay seems mostly incompatible with the gamemode introduced in this patch. In fact, this patch doesn't ever test to see if a unit is a commander, it just saves the id of the first commander created. Players of the mods you descibed can continue to use the older commander ends mode.

~0000866

tvo (reporter)

Committed, r3545.

Thanks for your contribution. Oh, and next time please set your editor to insert tabs, not spaces, when indenting. For the rest it was fine; I have added a few comments in the code though (hint ;-)).
+Notes

-Issue History
Date Modified Username Field Change
2007-03-22 13:41 det New Issue
2007-03-22 13:41 det File Added: lineage.patch
2007-03-22 13:47 det Note Added: 0000809
2007-03-24 09:18 KDR_11k Note Added: 0000812
2007-03-25 09:53 det Note Added: 0000814
2007-03-25 09:58 det Note Edited: 0000814
2007-04-04 23:15 tvo Status new => assigned
2007-04-04 23:15 tvo Assigned To => tvo
2007-04-04 23:15 tvo Status assigned => resolved
2007-04-04 23:15 tvo Resolution open => fixed
2007-04-04 23:15 tvo Note Added: 0000866
+Issue History