2025-07-14 17:40 CEST

View Issue Details Jump to Notes ]
IDProjectCategoryView StatusLast Update
0000461Spring engineGeneralpublic2007-03-09 05:58
ReporterM2 
Assigned ToILMTitan 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
Product Version 
Target VersionFixed in Version 
Summary0000461: [patch] Various fixes
DescriptionThis patch fixes a crash when using area load and two cases when the game state could be trashed by global objects that depends on each other constructs in the wrong order + some other small fixes.
TagsNo tags attached.
Checked infolog.txt for Errors
Attached Files
  • patch file icon various_fixes.patch (6,789 bytes) 2007-03-05 19:21 -
    Index: rts/Game/PreGame.cpp
    ===================================================================
    --- rts/Game/PreGame.cpp	(revision 3456)
    +++ rts/Game/PreGame.cpp	(working copy)
    @@ -109,6 +109,8 @@
     
     CPreGame::~CPreGame()
     {
    +	delete infoConsole;
    +	infoConsole = 0;
     }
     
     int CPreGame::KeyPressed(unsigned short k,bool isRepeat)
    Index: rts/Rendering/glFont.cpp
    ===================================================================
    --- rts/Rendering/glFont.cpp	(revision 3456)
    +++ rts/Rendering/glFont.cpp	(working copy)
    @@ -207,7 +207,7 @@
     			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
     		}
     		glTexImage2D(GL_TEXTURE_2D, 
    -			0, GL_RGBA, 
    +			0, 2, 
     			texsize, texsize, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, tex);
     		
     		charWidths[ch - charstart] = g->advance_x / 2 / texsize;		
    Index: rts/Sim/MoveTypes/groundmovetype.cpp
    ===================================================================
    --- rts/Sim/MoveTypes/groundmovetype.cpp	(revision 3456)
    +++ rts/Sim/MoveTypes/groundmovetype.cpp	(working copy)
    @@ -107,7 +107,7 @@
     const float MINIMUM_SPEED = 0.01f;					//Minimum speed a unit may move in.
     
     static const bool DEBUG_CONTROLLER=false;
    -std::vector<int2> CGroundMoveType::lineTable[11][11];
    +std::vector<int2> (*CGroundMoveType::lineTable)[11] = 0;
     
     //////////////////////////////////////////////////////////////////////
     // Construction/Destruction
    @@ -1286,6 +1286,8 @@
     //creates the tables used to see if we should advance to next pathfinding waypoint
     void CGroundMoveType::CreateLineTable(void)
     {
    +	lineTable = new std::vector<int2>[11][11];
    +
     	for(int yt=0;yt<11;++yt){
     		for(int xt=0;xt<11;++xt){
     			float3 start(0.5f,0,0.5f);
    @@ -1343,6 +1345,12 @@
     	}
     }
     
    +void CGroundMoveType::DeleteLineTable(void)
    +{
    +	delete [] lineTable;
    +	lineTable = 0;
    +}
    +
     void CGroundMoveType::TestNewTerrainSquare(void)
     {
     	int newMoveSquareX=(int)owner->pos.x / (SQUARE_SIZE*2);		//first make sure we dont go into any terrain we cant get out of
    Index: rts/Sim/MoveTypes/groundmovetype.h
    ===================================================================
    --- rts/Sim/MoveTypes/groundmovetype.h	(revision 3456)
    +++ rts/Sim/MoveTypes/groundmovetype.h	(working copy)
    @@ -120,7 +120,7 @@
     	bool CheckColH(int x, int y1, int y2, float xmove, int squareTestX);
     	bool CheckColV(int y, int x1, int x2, float zmove, int squareTestY);
     
    -	static std::vector<int2> lineTable[11][11];
    +	static std::vector<int2> (*lineTable)[11];
     	
     	float3 mainHeadingPos;
     	bool useMainHeading;
    @@ -128,6 +128,7 @@
     
     public:
     	static void CreateLineTable(void);
    +	static void DeleteLineTable(void);
     	void TestNewTerrainSquare(void);
     	bool CheckGoalFeasability(void);
     	virtual void LeaveTransport(void);
    Index: rts/Sim/Path/PathEstimator.cpp
    ===================================================================
    --- rts/Sim/Path/PathEstimator.cpp	(revision 3456)
    +++ rts/Sim/Path/PathEstimator.cpp	(working copy)
    @@ -701,7 +701,7 @@
     	char hashString[50];
     	sprintf(hashString,"%u",hash);
     
    -	string filename = string("maps/paths/") + stupidGlobalMapname.substr(0, stupidGlobalMapname.find('.') + 1) + hashString + "." + name + ".zip";
    +	string filename = string("maps/paths/") + stupidGlobalMapname.substr(0, stupidGlobalMapname.find_last_of('.') + 1) + hashString + "." + name + ".zip";
     	zipFile file;
     
     	// open file for writing in a suitable location
    Index: rts/Sim/Units/CommandAI/TransportCAI.cpp
    ===================================================================
    --- rts/Sim/Units/CommandAI/TransportCAI.cpp	(revision 3456)
    +++ rts/Sim/Units/CommandAI/TransportCAI.cpp	(working copy)
    @@ -86,26 +86,18 @@
     		}
     		CUnit* unit=uh->units[(int)c.params[0]];
     		if(c.options & INTERNAL_ORDER) {
    -			if(unit->commandAI->commandQue.size() == 0 && !LoadStillValid(unit)){
    +			if(!LoadStillValid(unit)){
     				FinishCommand();
     				return;
    -			} else {
    -				Command currentUnitCommand = unit->commandAI->commandQue[0];
    -				if(currentUnitCommand.id == CMD_LOAD_ONTO
    -					&& currentUnitCommand.params.size() == 1
    -					&& int(currentUnitCommand.params[0]) == owner->id)
    -				{
    -					if((unit->moveType->progressState == CMoveType::Failed)
    -						&& (owner->moveType->progressState == CMoveType::Failed))
    -					{
    +			}
    +			if(!unit->commandAI->commandQue.empty()){
    +				Command & currentUnitCommand = unit->commandAI->commandQue[0];
    +				if(currentUnitCommand.id == CMD_LOAD_ONTO && currentUnitCommand.params.size() == 1 && int(currentUnitCommand.params[0]) == owner->id){
    +					if((unit->moveType->progressState == CMoveType::Failed) && (owner->moveType->progressState == CMoveType::Failed)){
     						unit->commandAI->FinishCommand();
     						FinishCommand();
     						return;
     					}
    -				} else if(!LoadStillValid(unit))
    -				{
    -					FinishCommand();
    -					return;
     				}
     			}
     		}
    Index: rts/Sim/Units/UnitLoader.cpp
    ===================================================================
    --- rts/Sim/Units/UnitLoader.cpp	(revision 3456)
    +++ rts/Sim/Units/UnitLoader.cpp	(working copy)
    @@ -61,6 +61,7 @@
     
     CUnitLoader::~CUnitLoader()
     {
    +	CGroundMoveType::DeleteLineTable();
     }
     
     CUnit* CUnitLoader::LoadUnit(const string& name, float3 pos, int side, bool build, int facing)
    Index: rts/Sim/Units/UnitTracker.cpp
    ===================================================================
    --- rts/Sim/Units/UnitTracker.cpp	(revision 3456)
    +++ rts/Sim/Units/UnitTracker.cpp	(working copy)
    @@ -37,7 +37,7 @@
       oldCamDir(1,0,0)
     {
     	for (int a = 0; a < 32; ++a) {
    -		oldUp[a]=UpVector;
    +		oldUp[a]=float3(0,1,0);
     	}
     }
     
    Index: rts/System/float3.h
    ===================================================================
    --- rts/System/float3.h	(revision 3456)
    +++ rts/System/float3.h	(working copy)
    @@ -335,14 +335,14 @@
     	}
     
     	/**
    -	 * @brief distance2D between float3s (only x and y)
    +	 * @brief distance2D between float3s (only x and z)
     	 * @param f float3 to compare against
     	 * @return 2D distance between float3s
     	 * 
     	 * Calculates the distance between this float3
     	 * and another float3 2-dimensionally (that is,
    -	 * only using the x and y components).  Sums the
    -	 * differences in the x and y components, square
    +	 * only using the x and z components).  Sums the
    +	 * differences in the x and z components, square
     	 * root for pythagorean theorem
     	 */
     	inline float distance2D(const float3 &f) const{
    Index: rts/System/Object.cpp
    ===================================================================
    --- rts/System/Object.cpp	(revision 3456)
    +++ rts/System/Object.cpp	(working copy)
    @@ -12,7 +12,7 @@
     	CR_MEMBER(listening),
     	CR_MEMBER(listeners)));
     
    -CObject* CObject::syncedObjects;
    +CObject* CObject::syncedObjects = 0;
     
     //////////////////////////////////////////////////////////////////////
     // Construction/Destruction
    
    patch file icon various_fixes.patch (6,789 bytes) 2007-03-05 19:21 +
  • patch file icon various_fixes_v2.patch (6,856 bytes) 2007-03-06 14:35 -
    Index: rts/Game/PreGame.cpp
    ===================================================================
    --- rts/Game/PreGame.cpp	(revision 3456)
    +++ rts/Game/PreGame.cpp	(working copy)
    @@ -109,6 +109,8 @@
     
     CPreGame::~CPreGame()
     {
    +	delete infoConsole;
    +	infoConsole = 0;
     }
     
     int CPreGame::KeyPressed(unsigned short k,bool isRepeat)
    Index: rts/Rendering/glFont.cpp
    ===================================================================
    --- rts/Rendering/glFont.cpp	(revision 3456)
    +++ rts/Rendering/glFont.cpp	(working copy)
    @@ -207,7 +207,7 @@
     			glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
     		}
     		glTexImage2D(GL_TEXTURE_2D, 
    -			0, GL_RGBA, 
    +			0, 2, 
     			texsize, texsize, 0, GL_LUMINANCE_ALPHA, GL_UNSIGNED_BYTE, tex);
     		
     		charWidths[ch - charstart] = g->advance_x / 2 / texsize;		
    Index: rts/Sim/MoveTypes/groundmovetype.cpp
    ===================================================================
    --- rts/Sim/MoveTypes/groundmovetype.cpp	(revision 3456)
    +++ rts/Sim/MoveTypes/groundmovetype.cpp	(working copy)
    @@ -107,7 +107,7 @@
     const float MINIMUM_SPEED = 0.01f;					//Minimum speed a unit may move in.
     
     static const bool DEBUG_CONTROLLER=false;
    -std::vector<int2> CGroundMoveType::lineTable[11][11];
    +std::vector<int2> (*CGroundMoveType::lineTable)[11] = 0;
     
     //////////////////////////////////////////////////////////////////////
     // Construction/Destruction
    @@ -1286,6 +1286,8 @@
     //creates the tables used to see if we should advance to next pathfinding waypoint
     void CGroundMoveType::CreateLineTable(void)
     {
    +	lineTable = new std::vector<int2>[11][11];
    +
     	for(int yt=0;yt<11;++yt){
     		for(int xt=0;xt<11;++xt){
     			float3 start(0.5f,0,0.5f);
    @@ -1343,6 +1345,12 @@
     	}
     }
     
    +void CGroundMoveType::DeleteLineTable(void)
    +{
    +	delete [] lineTable;
    +	lineTable = 0;
    +}
    +
     void CGroundMoveType::TestNewTerrainSquare(void)
     {
     	int newMoveSquareX=(int)owner->pos.x / (SQUARE_SIZE*2);		//first make sure we dont go into any terrain we cant get out of
    Index: rts/Sim/MoveTypes/groundmovetype.h
    ===================================================================
    --- rts/Sim/MoveTypes/groundmovetype.h	(revision 3456)
    +++ rts/Sim/MoveTypes/groundmovetype.h	(working copy)
    @@ -120,7 +120,7 @@
     	bool CheckColH(int x, int y1, int y2, float xmove, int squareTestX);
     	bool CheckColV(int y, int x1, int x2, float zmove, int squareTestY);
     
    -	static std::vector<int2> lineTable[11][11];
    +	static std::vector<int2> (*lineTable)[11];
     	
     	float3 mainHeadingPos;
     	bool useMainHeading;
    @@ -128,6 +128,7 @@
     
     public:
     	static void CreateLineTable(void);
    +	static void DeleteLineTable(void);
     	void TestNewTerrainSquare(void);
     	bool CheckGoalFeasability(void);
     	virtual void LeaveTransport(void);
    Index: rts/Sim/Path/PathEstimator.cpp
    ===================================================================
    --- rts/Sim/Path/PathEstimator.cpp	(revision 3456)
    +++ rts/Sim/Path/PathEstimator.cpp	(working copy)
    @@ -701,7 +701,7 @@
     	char hashString[50];
     	sprintf(hashString,"%u",hash);
     
    -	string filename = string("maps/paths/") + stupidGlobalMapname.substr(0, stupidGlobalMapname.find('.') + 1) + hashString + "." + name + ".zip";
    +	string filename = string("maps/paths/") + stupidGlobalMapname.substr(0, stupidGlobalMapname.find_last_of('.') + 1) + hashString + "." + name + ".zip";
     	zipFile file;
     
     	// open file for writing in a suitable location
    Index: rts/Sim/Units/CommandAI/TransportCAI.cpp
    ===================================================================
    --- rts/Sim/Units/CommandAI/TransportCAI.cpp	(revision 3456)
    +++ rts/Sim/Units/CommandAI/TransportCAI.cpp	(working copy)
    @@ -86,24 +86,20 @@
     		}
     		CUnit* unit=uh->units[(int)c.params[0]];
     		if(c.options & INTERNAL_ORDER) {
    -			if(unit->commandAI->commandQue.size() == 0 && !LoadStillValid(unit)){
    -				FinishCommand();
    -				return;
    +			if(unit->commandAI->commandQue.empty()){
    +				if(!LoadStillValid(unit)){
    +					FinishCommand();
    +					return;
    +				}
     			} else {
    -				Command currentUnitCommand = unit->commandAI->commandQue[0];
    -				if(currentUnitCommand.id == CMD_LOAD_ONTO
    -					&& currentUnitCommand.params.size() == 1
    -					&& int(currentUnitCommand.params[0]) == owner->id)
    -				{
    -					if((unit->moveType->progressState == CMoveType::Failed)
    -						&& (owner->moveType->progressState == CMoveType::Failed))
    -					{
    +				Command & currentUnitCommand = unit->commandAI->commandQue[0];
    +				if(currentUnitCommand.id == CMD_LOAD_ONTO && currentUnitCommand.params.size() == 1 && int(currentUnitCommand.params[0]) == owner->id){
    +					if((unit->moveType->progressState == CMoveType::Failed) && (owner->moveType->progressState == CMoveType::Failed)){
     						unit->commandAI->FinishCommand();
     						FinishCommand();
     						return;
     					}
    -				} else if(!LoadStillValid(unit))
    -				{
    +				} else if(!LoadStillValid(unit)) {
     					FinishCommand();
     					return;
     				}
    Index: rts/Sim/Units/UnitLoader.cpp
    ===================================================================
    --- rts/Sim/Units/UnitLoader.cpp	(revision 3456)
    +++ rts/Sim/Units/UnitLoader.cpp	(working copy)
    @@ -61,6 +61,7 @@
     
     CUnitLoader::~CUnitLoader()
     {
    +	CGroundMoveType::DeleteLineTable();
     }
     
     CUnit* CUnitLoader::LoadUnit(const string& name, float3 pos, int side, bool build, int facing)
    Index: rts/Sim/Units/UnitTracker.cpp
    ===================================================================
    --- rts/Sim/Units/UnitTracker.cpp	(revision 3456)
    +++ rts/Sim/Units/UnitTracker.cpp	(working copy)
    @@ -37,7 +37,7 @@
       oldCamDir(1,0,0)
     {
     	for (int a = 0; a < 32; ++a) {
    -		oldUp[a]=UpVector;
    +		oldUp[a]=float3(0,1,0);
     	}
     }
     
    Index: rts/System/float3.h
    ===================================================================
    --- rts/System/float3.h	(revision 3456)
    +++ rts/System/float3.h	(working copy)
    @@ -335,14 +335,14 @@
     	}
     
     	/**
    -	 * @brief distance2D between float3s (only x and y)
    +	 * @brief distance2D between float3s (only x and z)
     	 * @param f float3 to compare against
     	 * @return 2D distance between float3s
     	 * 
     	 * Calculates the distance between this float3
     	 * and another float3 2-dimensionally (that is,
    -	 * only using the x and y components).  Sums the
    -	 * differences in the x and y components, square
    +	 * only using the x and z components).  Sums the
    +	 * differences in the x and z components, square
     	 * root for pythagorean theorem
     	 */
     	inline float distance2D(const float3 &f) const{
    Index: rts/System/Object.cpp
    ===================================================================
    --- rts/System/Object.cpp	(revision 3456)
    +++ rts/System/Object.cpp	(working copy)
    @@ -12,7 +12,7 @@
     	CR_MEMBER(listening),
     	CR_MEMBER(listeners)));
     
    -CObject* CObject::syncedObjects;
    +CObject* CObject::syncedObjects = 0;
     
     //////////////////////////////////////////////////////////////////////
     // Construction/Destruction
    
    patch file icon various_fixes_v2.patch (6,856 bytes) 2007-03-06 14:35 +

-Relationships
+Relationships

-Notes

~0000762

ILMTitan (reporter)

The change you made to CTransportAI breaks the have mobile unit load itself onto transport functionality.
To repeat, build a hulk and a stumpy. Select stumpy and give default command over hulk (should be a load icon). Stumpy will move toward hulk, but hulk will not pick up stumpy.

~0000765

M2 (reporter)

I have attached a new version of my patch to fix the issue pointed out by ILMTitan.

~0000768

ILMTitan (reporter)

Ok, the CTransportAI code now works correctly. I'll let someone more intimate with c++ pointer magic sign off on the rest of the changes.

~0000774

ILMTitan (reporter)

Revision 0003466:With the exception of UnitTracker.cpp, committed. Thank you.

I did not see any good reason to replace UpVector with float3(0,1,0). UpVector is const, float3 is properly constd, UpVector I believe is more clear, and float3(0,1,0) could call the constructor every time through the loop.
+Notes

-Issue History
Date Modified Username Field Change
2007-03-05 19:21 M2 New Issue
2007-03-05 19:21 M2 File Added: various_fixes.patch
2007-03-06 05:47 ILMTitan Note Added: 0000762
2007-03-06 14:35 M2 File Added: various_fixes_v2.patch
2007-03-06 14:35 M2 Note Added: 0000765
2007-03-07 07:11 ILMTitan Note Added: 0000768
2007-03-08 06:20 ILMTitan Status new => assigned
2007-03-08 06:20 ILMTitan Assigned To => ILMTitan
2007-03-09 05:58 ILMTitan Status assigned => resolved
2007-03-09 05:58 ILMTitan Resolution open => fixed
2007-03-09 05:58 ILMTitan Note Added: 0000774
+Issue History