From ZDoom Wiki
Jump to navigation Jump to search

Synchronizes the travel time between two commands. For example, if you wanted the ceiling to raise 20 units (with a speed of 8) in the same time the floor lower 6 units, you would do syncspeed(6, 20, 8).

function int syncspeed(int newdistance, int syncdistance, int syncspd)
	int t = fixeddiv(syncdistance<<16, syncspd<<16);
	int r = fixeddiv(newdistance<<16, t);
	return r>>16;

The function will sometimes not return with perfect synchronization due since a normal integer is required for most movement operations. The results, however, should be fairly close.