Was running TASClient with UberServer with a Vista and XP 64 machine. Had a bug where certain units caused a hard crash upon being built.
I can't reproduce the bug here under XP 32 running without another client. And it only happens with certain units, so I'm very puzzled about the circumstances.
Because I'm fairly certain that the error is related somehow to the unit scripts, I'm going to post the BOS and the Lua it's looping into- the only new things I've added since last week, when the crash wasn't happening:
BOS:
Code: Select all
// Argh's PURE Tank Script
// This script is copyright (C) Wolfe Games, 2007
// All contents were created by Wolfe Games.
// This Include is absolutely VITAL.
// You must call it FIRST. PERIOD.
// Don't say I didn't warn you ;-)
#include "STANDARD_COMMANDS_PURE.h"
piece body, turret, aimer, barrel, flare, groundflash, tread1, tread2, tread3, tread4, tread5, dust1, dust2, light;
// FX and Smoke Code.
// SmokeUnit_PURE is a completely optional Include. It *requires* STANDARD_COMMANDS_PURE.h
// ExplosionIncludes_PURE is for explosion FX. It *requires* SoundLibrary_PURE.h
// This code (C) Wolfe Games.
piece center, explode_point01, explode_point02, explode_point03, explode_point04, explode_point05, explode_point06, explode_point07, explode_point08;
#define SMOKEPIECE1 explode_point01
#define SMOKEPIECE2 explode_point02
#define SMOKEPIECE3 explode_point03
#define SMOKEPIECE4 explode_point04
#include "SmokeUnit_PURE.h"
///////////////////////////////////////FX RESERVED FOR EXPLOSIONS
#define EXPLOSION1 1024+1
#define EXPLOSION2 1024+2
#define EXPLOSION3 1024+3
#define EXPLOSION4 1024+4
#define BIG_EXPLOSION1 1024+5
#define BIG_EXPLOSION2 1024+6
#define BIG_EXPLOSION3 1024+7
#define BIG_EXPLOSION4 1024+8
#define MinExplosions 2
#define MaxExplosions 6
#include "ExplosionIncludes_PURE.h"
///////////////////////////////////////END RESERVED
#define WHAM_LAUNCH_FX 1024+9
#define WHAM_GROUND_FLASH 1024+10
#define TRACKED_FX 1024+11
static-var isMoving, amMoving;
lua_CreateLightMe(arg) { return (0); }
lua_DestroyLightMe(arg) { return (0); }
lua_KnockOver(arg) { return (0); }
TreadControl()
{
var RandomSeed, TreadSection;
RandomSeed = rand (200, 350);
While(amMoving)
{
++TreadSection;
If(TreadSection == 6)
{
TreadSection = 1;
}
If(TreadSection == 1)
{
show tread5;
hide tread1;
emit-sfx TRACKED_FX from dust1;
emit-sfx TRACKED_FX from dust2;
}
If(TreadSection == 2)
{
show tread4;
hide tread5;
emit-sfx TRACKED_FX from dust1;
emit-sfx TRACKED_FX from dust2;
}
If(TreadSection == 3)
{
show tread3;
hide tread4;
emit-sfx TRACKED_FX from dust1;
emit-sfx TRACKED_FX from dust2;
}
If(TreadSection == 4)
{
show tread2;
hide tread3;
emit-sfx TRACKED_FX from dust1;
emit-sfx TRACKED_FX from dust2;
}
If(TreadSection == 5)
{
show tread1;
hide tread2;
emit-sfx TRACKED_FX from dust1;
emit-sfx TRACKED_FX from dust2;
}
sleep 30;
}
return 0;
}
KnockOver()
{
var knockTimer;
knockTimer = rand(500,1500);
while(amMoving)
{
call-script lua_KnockOver();
sleep knockTimer;
}
return 0;
}
Halt()
{
sleep 150;
if(!amMoving)
{
isMoving = FALSE;
}
}
StartMoving()
{
amMoving = TRUE;
if (!isMoving)
{
isMoving = TRUE;
start-script TreadControl();
start-script KnockOver();
}
}
StopMoving()
{
amMoving = FALSE;
start-script Halt();
}
Create()
{
hide flare;
hide tread2;
hide tread3;
hide tread4;
hide tread5;
amMoving = FALSE;
start-script SmokeUnit_PURE();
}
RestoreAfterDelay()
{
var RandomSeed;
RandomSeed = RAND(3000, 4000);
sleep RandomSeed;
turn turret to y-axis <0.0> speed <65.0>;
turn aimer to x-axis <0.0> speed <65.0>;
}
QueryWeapon1 (piecenum)
{
piecenum = flare;
}
AimFromWeapon1 (piecenum)
{
piecenum = turret;
}
AimWeapon1(heading, pitch)
{
signal SIG_AIM1;
set-signal-mask SIG_AIM1;
turn aimer to x-axis 0 - pitch speed <80.0>;
turn turret to y-axis heading speed <80.0>;
wait-for-turn turret around y-axis;
wait-for-turn aimer around x-axis;
start-script RestoreAfterDelay();
return(TRUE);
}
FireWeapon1()
{
call-script lua_CreateLightMe(light, 255, 255, 64, 128);
emit-sfx WHAM_GROUND_FLASH from groundflash;
emit-sfx WHAM_LAUNCH_FX from flare;
move barrel to z-axis [-9] speed [100];
sleep 200;
call-script lua_DestroyLightMe();
move barrel to z-axis [0] speed [10];
return(0);
}
Killed(severity, corpsetype)
{
if (severity <= 50)
{
corpsetype = 1;
call-script Explosion();
return (corpsetype);
} else
{
corpsetype = 2;
call-script Explosion();
return (corpsetype);
}
return(0);
}
Code: Select all
function gadget:GetInfo()
return {
name = "KnockOver",
desc = "Destroys Units with the KnockOver tag, if a Unit gets too close (trees, etc.)",
author = "Argh",
date = "March 3, 2009",
license = "GPL",
layer = 1,
enabled = true,
}
end
local Gaia = Spring.GetGaiaTeamID()
local sizeX = 0
local GetUnitPosition
local knockOverTable = {}
local GetUnitDefID = Spring.GetUnitDefID
local DestroyUnit = Spring.DestroyUnit
local GetUnitsInSphere = Spring.GetUnitsInSphere
local GetUnitPosition = Spring.GetUnitPosition
local GetUnitTeam = Spring.GetUnitTeam
if (gadgetHandler:IsSyncedCode()) then
function gadget:Initialize()
for ud,_ in ipairs(UnitDefs) do -- search all UnitDef entries
if UnitDefs[ud].customParams.knockover == "yes" then
table.insert(knockOverTable,ud,0)
end
end
end
function KnockOver(u,ud,team)
sizeX = UnitDefs[ud].xsize
local x, y, z = GetUnitPosition(u)
unitGroupNum = GetUnitsInSphere(x, y, z,sizeX * 5.5)
for _,me in ipairs (unitGroupNum) do
if me ~= u and knockOverTable[GetUnitDefID(me)] then
DestroyUnit(me,true,false)
end
end
end
gadgetHandler:RegisterGlobal("KnockOver", KnockOver)
end
We saw these crashes in two instances- where this unit was being built (i.e., crash during Create() ) or when it died.
I presume that part of the reason why it may be crashing is that Lua's expecting a valid UnitID to return to, and maybe it's removing the UnitID before the Lua returns? That's problematical, and IDK how I can handle that, other than making amMoving FALSE then sleeping a few frames, which I'm going to try as a safety step.
But we didn't see the errors with lots of other units using KnockOver, so it's a bit of a mystery.