Author Topic: Crash with Vehicle::onRemove  (Read 2468 times)

Code: [Select]
package GoKartPackage {
function VehicleData::onEnterLiquid(%data, %obj, %coverage, %type) {
Parent::onEnterLiquid(%data, %obj, %coverage, %type);

if(isObject(%obj.lastTouched)) {
%selection = %obj.lastTouched;
%x = getWord(%selection.getPosition(),0);
%y = getWord(%selection.getPosition(),1);
%z = getWord(%selection.getPosition(),2);
%z_add = %z + %selection.getDatablock().brickSizeZ/6;
%rot = getWord(%obj.lastTransform,6);

%obj.setVelocity("0 0 0");
%obj.setTransform(getWords(%obj.lastTransform,0,2) SPC "0 0 1" SPC %rot);
%obj.setVelocity("0 0 0");
} else {
// something has gone wrong, just explode them.
%obj.finalExplosion();
}
}

function GameConnection::spawnPlayer(%this) {
parent::spawnPlayer(%this);
for(%i=1;%i<=42;%i++) {
%brick = "_vehicle_spawn" @ %i;
if(!%brick.isUsed) {
%brick.isUsed = 1;
%brick.setVehicle(SpeedKartclassicgtVehicle.getID());
%this.player.delete();
%this.player = %brick.vehicle;
%this.setControlObject(%brick.vehicle);
return;
}
}
}

function Vehicle::onRemove(%this) {
%this.dump();
%this.spawnBrick.isUsed = 0;
%client = %this.getControllingClient();
%client.setControlObject(%client.Camera);

parent::onRemove(%this);
}
};
activatePackage(GoKartPackage);

Upon landing in water (should default to the else part), Blockland crashes.
If everything in onRemove is commented out, minus the parent, it's fine. What's going on?

Try commenting out the second line.
If that does nothing, comment out single lines until you find out what's the issue.

Try getting rid of %this.dump(); maybe?

Place echoes between every line so that you know what causes it to crash.

Place echoes between every line so that you know what causes it to crash.

Make sure you use setLogMode(1); beforehand, or you might miss the last few lines before the crash.

%client.setControlObject(%client.Camera);

Try checking to see if the client exists?

Code's completely different from what's up there in the OP now, and I'm now getting a crash with finalExplosion (no longer using onRemove for what I'm trying to do).


Code here

EDIT: Should mention explosions actually work fine some of the time.

Well you are jumping from entering liquid to the final explosion, have you tried just killing it by removing all of it's health?

Well you are jumping from entering liquid to the final explosion, have you tried just killing it by removing all of it's health?
That fixed it. I assumed I could just jump straight to the final explosion, but I guess not.

EDIT: or not, it's still crashing
« Last Edit: February 17, 2015, 01:46:23 AM by TheBlackParrot »

Well I'm not the best with vehicle code, but for ::onAdd you have wheeledVehicleData, for ::onEnterLiquid you have VehicleData and for ::FinalExplosion you have Vehicle, I don't think there will be flying carpets or f-18's so you could switch it over to wheeledVehicleData, and wouldn't ::FinalExplosion be a vehicleData rather than just Vehicle?
Sorry if anything I said is incorrect, I haven't dumped or toyed with the default vehicle functions too much.

That fixed it. I assumed I could just jump straight to the final explosion, but I guess not.

EDIT: or not, it's still crashing

Does exploding it on the next frame help?
%obj.schedule(0, "finalExplosion");

Code's completely different from what's up there in the OP now, and I'm now getting a crash with finalExplosion (no longer using onRemove for what I'm trying to do).
[img width=1000]http://i.imgur.com/1gcJPTW.png[/img]

Code here

EDIT: Should mention explosions actually work fine some of the time.
The code doesn't match the console you're showing. Did you change it?

The code doesn't match the console you're showing. Did you change it?
Yeah sorry, I should've posted the one from the affected commit instead of the latest
https://raw.githubusercontent.com/TheBlackParrot/blockland-racing/fa1f3f48953ea1f06047ebc516d8529210ba1073/server.cs

Yeah sorry, I should've posted the one from the affected commit instead of the latest
https://raw.githubusercontent.com/TheBlackParrot/blockland-racing/fa1f3f48953ea1f06047ebc516d8529210ba1073/server.cs
It'd be more helpful to know how the latest one is behaving. What's weird is that you did the actual explosion pretty much identically to the one in Speedkart, which works fine. You try cutting out that stuff with the client in the final explosion to see if it's doing anything?

For some reason I had the same exact issue, I basically created a explosion instead of the vehicle exploding, and the vehicle would delete instead.