Renegade Public Forums
C&C: Renegade -- Dead since 2012!™
Home » Renegade Discussions » Tiberian Technologies Forum » FDS Crash
FDS Crash [message #484487] Mon, 18 November 2013 15:12 Go to next message
Neijwiert  is currently offline Neijwiert  
Messages: 124
Registered: October 2009
Recruit
From: *dynamic.upc.nl
Order of Crash:

- Join game
- Purchase refill
- Crash

Crash Type: Access violation

Crash points to: Scripts.dll

I know that it must have been my code, but I really can't find it. This is the code that I have that should get executed on refill:

// Not sure if it executes OnObjectCreate, but just in case
void NTC::OnObjectCreate(void *data, GameObject *obj)
{
Console_Output("A");
NTCPC->OnObjectCreate(obj);
}

bool NTC::OnRefill(GameObject *purchaser)
{
Console_Output("Refill\n");
return true;
}

It doesn't hit either of the Console_Output lines.
I'm out of ideas, can you please help me? I'm willing to hand over the complete source code I use.

I tried:
- Debug Text
- Attaching debugger
- Looking in the crashdump


[Updated on: Mon, 18 November 2013 15:13]

Re: FDS Crash [message #484488] Mon, 18 November 2013 15:32 Go to previous messageGo to next message
Neijwiert  is currently offline Neijwiert  
Messages: 124
Registered: October 2009
Recruit
From: *dynamic.upc.nl
After some more digging I found out that the problem lays at this method:

void NTCPlayerControl::Remove_Excess_Scripts(GameObject *Obj)
{
	if(!Obj)
		return;

	// Loop trough all the scripts
	SimpleDynVecClass<GameObjObserverClass *> Observers = Obj->Get_Observers();
	int Count = Observers.Count();
	for(int x = 0; x < Count; x++)
	{
		GameObjObserverClass *Current = Observers[x];
		if(Current)
		{
			WideStringClass Name = Current->Get_Name();

			if(Name.Compare(L"M00_GrantPowerup_Created") == 0 || Name.Substring(0, 4).Compare_No_Case(L"SSGM") == 0)
			{
				COutput("Should remove: %s\n", Current->Get_Name());
				//Obj->Remove_Observer(Current);
			}
		}
	}
}


As soon as I add the Obj->Remove_Observer line it starts crashing again. But I still haven't figured out why I cant add that line.

UPDATE:
I think somewhere in Scripts.dll there is code that assumes that all SSGM scripts are still attached.

I've changed the code to this to make sure the comparing is going right:

if(Current)
		{
			const char *ScriptName = Current->Get_Name();

			//Name.Substring(0, 4).Compare_No_Case(L"SSGM") == 0
			if(strcmp(ScriptName, "M00_GrantPowerup_Created") == 0 || (ScriptName && strlen(ScriptName) >= 4 && ScriptName[0] == 'S' && ScriptName[1] == 'S' && ScriptName[2] == 'G' && ScriptName[3] == 'M'))
			{
				COutput("Should remove: %s\n", Current->Get_Name());
				Obj->Remove_Observer(Current);
			}
		}

[Updated on: Mon, 18 November 2013 15:42]

Re: FDS Crash [message #484489] Mon, 18 November 2013 15:52 Go to previous messageGo to next message
Neijwiert  is currently offline Neijwiert  
Messages: 124
Registered: October 2009
Recruit
From: *dynamic.upc.nl
As soon as I wrote this part "I think somewhere in Scripts.dll there is code that assumes that all SSGM scripts are still attached." and ate a cookie. I realised that it must have been in the SSGM code.

The one who is responsible of SSGM should change these 2 functions:

Toggle Spoiler


to:

Toggle Spoiler

[Updated on: Mon, 18 November 2013 15:54]

Re: FDS Crash [message #484491] Tue, 19 November 2013 05:50 Go to previous messageGo to next message
danpaul88  is currently offline danpaul88  
Messages: 5792
Registered: June 2004
Location: England
General (5 Stars)
From: 94.118.104*
That change would also stop your own custom refill scripts being called since you embedded the event hook loop inside the if(script) block.


http://steamsignature.com/card/1/76561197975867233.png
Re: FDS Crash [message #484493] Tue, 19 November 2013 06:36 Go to previous messageGo to next message
Troll King  is currently offline Troll King  
Messages: 56
Registered: June 2012
Location: Netherlands
Recruit
From: 145.93.65*
Oh right, hehe yeah sorry I wasn't really looking at it very well. I guess I was tired. But I think you get the suggestion that there needs to be a null pointer check.


Also Known As: Neijwiert
Re: FDS Crash [message #484496] Tue, 19 November 2013 10:43 Go to previous message
danpaul88  is currently offline danpaul88  
Messages: 5792
Registered: June 2004
Location: England
General (5 Stars)
From: *range86-132.btcentralplus.com
Revision: 6096
Author: danpaul88
Date: 19 November 2013 17:42:18
Message:
Added some null pointers check in the SSGM refill logic to guard against the SSGM_Soldier script somehow being removed from a soldier (ie: by third party code trying to override SSGM functionality with its own)
----
Modified : /trunk/scripts/scripts/gmgame.cpp


http://steamsignature.com/card/1/76561197975867233.png
Previous Topic:Did TT make any changes to Flamers vs Infantry?
Next Topic:4.0 Server settings question
Goto Forum:
  


Current Time: Thu Nov 15 11:31:32 MST 2018
.:: Contact :: Home ::.

Powered by: FUDforum 2.7.7RC2.
Copyright ©2001-2007 FUD Forum Bulletin Board Software