Skip to content
Permalink
Browse files
Test hacky object refresh method.
SimSet::refresh ticks through a SimSet over multiple function calls,
simply doing a NOOP on the position field. This is enough to cause
setMaskBits to be called and update the object on all clients, leading
it to be dropped if it's out of scope for some of them.
  • Loading branch information
crabmusket committed Sep 18, 2014
1 parent c71a424 commit ada71d3e667c651dd6695e242b81120d9a96e5e4
Showing with 40 additions and 3 deletions.
  1. +40 −3 tutorials/client_server/server.cs
@@ -61,11 +61,48 @@
ambient = "0.1 0.1 0.1";
castShadows = true;
};
new StaticShape(Cube) {
datablock = CubeShape;
position = "0 20 1";
new SimGroup(Cubes) {
new StaticShape(Cube) {
datablock = CubeShape;
position = "0 20 1";
};
new StaticShape(Cube2) {
datablock = CubeShape;
position = "0 40 1";
};
new StaticShape(Cube3) {
datablock = CubeShape;
position = "0 60 1";
};
new StaticShape(Cube4) {
datablock = CubeShape;
position = "0 80 1";
};
};
};

Cubes.refresh(1000, 2);
}

function SimSet::refresh(%this, %period, %objectsPerIteration) {
%this._refresh = %this.schedule(%period, refresh, %period, %objectsPerIteration);

if(%this._refreshIndex $= "") {
%this._refreshIndex = 0;
}

%i = %this._refreshIndex;
%max = %this.getCount()-1;
for(%j = 0; %j < %objectsPerIteration; %j++) {
if(%i > %max) {
%i = 0;
}
%obj = %this.getObject(%i);
%obj.position = %obj.position;
%i++;
}

%this._refreshIndex = %i;
}

// Called when the engine is shutting down.

0 comments on commit ada71d3

Please sign in to comment.