Skip to content
OE_controller.cpp 18.2 KiB
Newer Older
/*
 * Copyright (c) 2015 Tricoire Sebastien 3dsman@free.fr
 *
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the authors be held liable for any damages
 * arising from the use of this software.
 *
 * Permission is granted to anyone to use this software for any purpose,
 * including commercial applications, and to alter it and redistribute it
 * freely, subject to the following restrictions:
 *
 * 1. The origin of this software must not be misrepresented; you must not
 * claim that you wrote the original software. If you use this software
 * in a product, an acknowledgment in the product documentation would be
 * appreciated but is not required.
 * 2. Altered source versions must be plainly marked as such, and must not be
 * misrepresented as being the original software.
 * 3. This notice may not be removed or altered from any source distribution.
 *
 */

#include "OE_controller.h"
#include <iostream>
#include <typeinfo>

#include "actions/OE_actionsCurves.h"
#include "actions/OE_actionsStitchs.h"
#include "actions/OE_actionsLineStitchs.h"
#include "actions/OE_actionsBirailStitchs.h"
3dsman's avatar
3dsman committed
#include "actions/OE_actionsFillStitchs.h"
#include "actions/OE_actionsLinkStitchs.h"
#include "actions/OE_actionsSelection.h"
#include "actions/OE_actionsThreads.h"

raoul's avatar
raoul committed
// comm("/dev/ttyUSB0", 80, 10)
// comm("/dev/tty", 80, 10)
// comm("20:15:05:11:28:40", 80, 30)
// comm("/dev/rfcomm1", 80, 30)
OE_controller::OE_controller(OE_display* display, OE_document* document) : display(display), document(document),
    comm(getenv("SERIALPORT")?getenv("SERIALPORT"):"/dev/rfcomm0", 80, 30)
3dsman's avatar
3dsman committed

	//OE_linestitch::initPatterns();
raoul's avatar
raoul committed
	// TODO remove
	if (document && document->threads.empty())
raoul's avatar
raoul committed
	{
		document->addThread(new OE_thread(OE_color(.4, .4, .4), 2));
	}
}

OE_controller::~OE_controller()
{
}

void OE_controller::setDocument(OE_document* document)
{
raoul's avatar
raoul committed
	this->document = document;
void OE_controller::newSubCurve(OE_curve* curve, float curveStart, float curveEnd, bool reverse)
	addAction(new OE_actionNewSubCurve(curve, curveStart, curveEnd, reverse));
}
void OE_controller::newSubCurve(int ncurve, float curveStart, float curveEnd, bool reverse)
{
	newSubCurve(getCurve(ncurve), curveStart, curveEnd, reverse);
}
raoul's avatar
raoul committed

void OE_controller::newBirailStitch(bool reverse1, bool reverse2, float offset1, float offset2, float len)
raoul's avatar
raoul committed
	clearUndoActionStack();
	addAction(new OE_actionNewBirailStitch(reverse1, reverse2, offset1, offset2, len));
raoul's avatar
raoul committed
void OE_controller::newLineStitch(float len, float width, OE_pattern* pattern, unsigned patternSteps, float xOffset, float yOffset)
raoul's avatar
raoul committed
	clearUndoActionStack();
	addAction(new OE_actionNewLineStitch(len, width, pattern, patternSteps, xOffset, yOffset));
raoul's avatar
raoul committed
void OE_controller::newFillStitch(float len, float width, OE_pattern* pattern)
3dsman's avatar
3dsman committed
	clearUndoActionStack();
raoul's avatar
raoul committed
	addAction(new OE_actionNewFillStitch(len, width, pattern));
raoul's avatar
raoul committed
void OE_controller::setStitchThread(OE_stitchs* stitch, OE_thread* thread)
{
	addAction(new OE_actionSetStitchThread(stitch, thread));
}
void OE_controller::setStitchThread(int nstitch, int nthread)
{
	setStitchThread(getStitch(nstitch), getThread(nthread));
}

void OE_controller::setCloseCurve(OE_curve* curve, bool closed)
{
raoul's avatar
raoul committed
	addAction(new OE_actionSetCloseCurve(curve, closed));
}

void OE_controller::setCloseCurve(int ncurve, bool closed)
{
raoul's avatar
raoul committed
	setCloseCurve(getCurve(ncurve), closed);
}

void OE_controller::toggleCloseSelectedCurve()
{
raoul's avatar
raoul committed
	OE_curve* curve = document->selectedCurves.back();
	if (curve)
	{
		setCloseCurve(curve, !curve->getClosed());
	}
bool OE_controller::initNewDocument()
{
raoul's avatar
raoul committed
	if (!document)
	{
		return false;
	}
	OE_actions::curDocument = document; // TODO: REMOVE, UGLY AS FUCK !!!!
raoul's avatar
raoul committed
	addAction(new OE_actionNewThread(new OE_thread(OE_color(.9, .5, .1), 2)));
raoul's avatar
raoul committed
	document->setZeroPoint(vector_2d(0, 0));
	return true;
3dsman's avatar
3dsman committed

bool OE_controller::setDefault()
{
	OE_birailstitch::defaultLen = 1;
	OE_birailstitch::defaultMaxlen = 0;
raoul's avatar
raoul committed
OE_curve* OE_controller::getCurve(int index)
	if (document && index<0)
raoul's avatar
raoul committed
	{
		index = document->curves.size() + index;
raoul's avatar
raoul committed
	}
	if (document && 0<=index && index<document->curves.size())
raoul's avatar
raoul committed
		std::list<OE_pointcurve*>::iterator curve = document->curves.begin();
		for (unsigned i=0; i<index; i++)
		{
raoul's avatar
raoul committed
		}
		return *curve;
raoul's avatar
raoul committed
OE_pointcurve* OE_controller::getPointcurve(unsigned index)
raoul's avatar
raoul committed
	return dynamic_cast<OE_pointcurve*>(getCurve(index));
raoul's avatar
raoul committed
OE_subcurve* OE_controller::getSubcurve(unsigned index)
raoul's avatar
raoul committed
	return dynamic_cast<OE_subcurve*>(getCurve(index));
raoul's avatar
raoul committed
OE_joincurve* OE_controller::getJoincurve(unsigned index)
raoul's avatar
raoul committed
	return dynamic_cast<OE_joincurve*>(getCurve(index));
raoul's avatar
raoul committed
OE_stitchs* OE_controller::getStitch(int index)
	if (document && index<0)
raoul's avatar
raoul committed
	{
		index = document->stitchs.size() + index;
raoul's avatar
raoul committed
	}
	if (document && 0<=index && index<document->stitchs.size())
	{
		std::list<OE_stitchs*>::iterator stitch = document->stitchs.begin();
raoul's avatar
raoul committed
		for (unsigned i=0; i<index;i++)
		{
raoul's avatar
raoul committed
		}
		return *stitch;
	}
raoul's avatar
raoul committed
OE_linestitch* OE_controller::getLineStitch(unsigned index)
raoul's avatar
raoul committed
	return dynamic_cast<OE_linestitch*>(getStitch(index));
raoul's avatar
raoul committed
OE_birailstitch* OE_controller::getBirailStitch(unsigned index)
raoul's avatar
raoul committed
	return dynamic_cast<OE_birailstitch*>(getStitch(index));
raoul's avatar
raoul committed
OE_fillstitch* OE_controller::getFillStitch(unsigned index)
3dsman's avatar
3dsman committed
{
raoul's avatar
raoul committed
	return dynamic_cast<OE_fillstitch*>(getStitch(index));
3dsman's avatar
3dsman committed
}

raoul's avatar
raoul committed
OE_linkstitch* OE_controller::getLinkStitch(unsigned index)
raoul's avatar
raoul committed
	return dynamic_cast<OE_linkstitch*>(getStitch(index));
raoul's avatar
raoul committed
OE_thread* OE_controller::getThread(int index)
	if (document && index<0)
raoul's avatar
raoul committed
	{
		index = document->threads.size() + index;
raoul's avatar
raoul committed
	}
	if (document && 0<=index && index<document->threads.size())
	{
		std::list<OE_thread*>::iterator thread = document->threads.begin();
raoul's avatar
raoul committed
		for (unsigned i=0; i<index; i++)
		{
raoul's avatar
raoul committed
		}
		return *thread;
	}
raoul's avatar
raoul committed
OE_pattern* OE_controller::getPattern(int index)
{
	if (document)
	{
		if (index<0)
raoul's avatar
raoul committed
		{
			index += document->patterns.size();
		}

		if (0<=index && index<document->patterns.size())
		{
			std::list<OE_pattern*>::iterator pattern = document->patterns.begin();
raoul's avatar
raoul committed
			for (unsigned i=0; i<index; i++)
			{
				pattern++;
raoul's avatar
raoul committed
			}
			return *pattern;
bool OE_controller::clearUndoActionStack()
{
raoul's avatar
raoul committed
	if (document)
	{
		OE_document::ScopeLock lock(*document);
		//flush the undoActionStack
		while (!document->undoActionsStack.empty())
		{
			delete document->undoActionsStack.back();
			document->undoActionsStack.pop_back();
		}
	}
raoul's avatar
raoul committed
bool OE_controller::addAction(OE_actions* action)
raoul's avatar
raoul committed
	if (document)
	{
raoul's avatar
raoul committed
		OE_document::ScopeLock lock(*document);
		//flush the undoActionStack
raoul's avatar
raoul committed
		while (!(document->undoActionsStack.empty()))
		{
			delete document->undoActionsStack.back();
			document->undoActionsStack.pop_back();
		}

		//push the new action to the active stack
		document->activeActionsStack.push_front(action);
	}
}

bool OE_controller::undoAction()
{
raoul's avatar
raoul committed
	if (document)
	{
		OE_document::ScopeLock lock(*document);
		if (document->activeActionsStack.size())
		{
			// get and undo the last action from active action stack
raoul's avatar
raoul committed
			OE_actions* action = *document->activeActionsStack.begin();
raoul's avatar
raoul committed
			if (action)
			{
				action->undo();
raoul's avatar
raoul committed
				// move the action from active to undo action stack
				document->activeActionsStack.pop_front();
				document->undoActionsStack.push_front(action);
			}
		}
	}
}

bool OE_controller::redoAction()
{
raoul's avatar
raoul committed
	if (document)
	{
		OE_document::ScopeLock lock(*document);
		if (document->undoActionsStack.size())
		{
			// get and redo the last action from undo action stack
raoul's avatar
raoul committed
			OE_actions* action = *document->undoActionsStack.begin();
raoul's avatar
raoul committed
			action->redo();
raoul's avatar
raoul committed
			// move the action from undo to active action stack
			document->undoActionsStack.pop_front();
			document->activeActionsStack.push_front(action);
		}
raoul's avatar
raoul committed
	}
raoul's avatar
raoul committed
bool OE_controller::selectCurve(OE_pointcurve* curve, bool replace)
raoul's avatar
raoul committed
	std::list<OE_pointcurve*> tmp;
	tmp.push_back(curve);
raoul's avatar
raoul committed
	return selectCurves(tmp, replace);
raoul's avatar
raoul committed
bool OE_controller::selectCurves(std::list<OE_pointcurve*> curves, bool replace)
raoul's avatar
raoul committed
	if (document)
	{
		addAction(new OE_actionSelectionAddCurves(curves, replace));
		return true;
	}
	return false;
raoul's avatar
raoul committed
bool OE_controller::unselectCurves(std::list<OE_pointcurve*> curves)
raoul's avatar
raoul committed
	if (document)
	{
		addAction(new OE_actionSelectionRemoveCurves(curves));
		return true;
	}
	return false;
raoul's avatar
raoul committed
	if (document)
	{
		addAction(new OE_actionSelectionClearCurves());
		return true;
	}
	return false;
raoul's avatar
raoul committed
bool OE_controller::selectStitch(OE_stitchs* stitch, bool replace)
raoul's avatar
raoul committed
	std::list<OE_stitchs*> tmp;
	tmp.push_back(stitch);
raoul's avatar
raoul committed
	return selectStitches(tmp, replace);
raoul's avatar
raoul committed
bool OE_controller::selectStitches(std::list<OE_stitchs*> stitches, bool replace)
raoul's avatar
raoul committed
	if (document)
	{
		addAction(new OE_actionSelectionAddStitches(stitches, replace));
		return true;
	}
	return false;
raoul's avatar
raoul committed
bool OE_controller::unselectStitches(std::list<OE_stitchs*> stitches)
raoul's avatar
raoul committed
	if (document)
	{
		addAction(new OE_actionSelectionRemoveStitches(stitches));
		return true;
	}
	return false;
raoul's avatar
raoul committed
	if (document)
	{
		addAction(new OE_actionSelectionClearStitches());
		return true;
	}
	return false;
raoul's avatar
raoul committed
	if (document)
	{
		addAction(new OE_actionSelectionClear());
		return true;
	}
	return false;
BoundingBox OE_controller::getSelectionBoundingBox()
{
	BoundingBox boundingBox;
	for (auto curve : document->selectedCurves)
	{
		boundingBox += curve->getBound();
	}
	for (auto stitch : document->selectedStitchs)
	{
		boundingBox += stitch->getBound();
	}
	return boundingBox;
}

raoul's avatar
raoul committed
OE_actions* OE_controller::getLastAction()
{
    if (document && document->activeActionsStack.size())
    {
        return *document->activeActionsStack.begin();
raoul's avatar
raoul committed
    return nullptr;
bool OE_controller::editActionMovePointCurve(vector_2d offset)
{
raoul's avatar
raoul committed
	OE_actionMovePointCurve* actionMovePointCurve = dynamic_cast<OE_actionMovePointCurve*>(getLastAction());
	if (actionMovePointCurve)
	{
		actionMovePointCurve->setMove(offset);
		return true;
	}
	return false;
bool OE_controller::editActionMovePointLinkStitch(vector_2d offset)
{
	OE_actionAddPointLinkStitch* actionAddPointLinkStitch = dynamic_cast<OE_actionAddPointLinkStitch*>(getLastAction());
	OE_actionMovePointLinkStitch* actionMovePointLinkStitch = dynamic_cast<OE_actionMovePointLinkStitch*>(getLastAction());
	if (actionAddPointLinkStitch)
	{
raoul's avatar
raoul committed
		actionAddPointLinkStitch->setOffset(offset);
raoul's avatar
raoul committed
		actionMovePointLinkStitch->setOffset(offset);
bool OE_controller::editActionMoveGridPointFillStitch(vector_2d offset)
{
	OE_actionMovePointFillStitch* actionMovePointFillStitch = dynamic_cast<OE_actionMovePointFillStitch*>(getLastAction());
	if (actionMovePointFillStitch)
	{
		actionMovePointFillStitch->setOffset(offset);
		return true;
	}

	return false;
}


bool OE_controller::editActionMoveSelection(vector_2d offset)
{
	OE_actionMoveSelection* actionMoveSelection = dynamic_cast<OE_actionMoveSelection*>(getLastAction());
	if (actionMoveSelection)
	{
raoul's avatar
raoul committed
		actionMoveSelection->setMove(offset);
		return true;
bool OE_controller::editActionScaleSelection(vector_2d ratio)
{
	OE_actionScaleSelection* actionScaleSelection = dynamic_cast<OE_actionScaleSelection*>(getLastAction());
	if (actionScaleSelection)
	{
raoul's avatar
raoul committed
		actionScaleSelection->setScale(ratio);
		return true;
bool OE_controller::editActionSetSubcurvePos(float val)
raoul's avatar
raoul committed
	OE_actionSetSubcurvePos* actionSetSubcurvePos = dynamic_cast<OE_actionSetSubcurvePos*>(getLastAction());
	if (actionSetSubcurvePos)
	{
		actionSetSubcurvePos->setPos(val);
		return true;
	}
	return false;
bool OE_controller::editActionSetSubcurvePosSwitchDir()
{
raoul's avatar
raoul committed
	OE_actionSetSubcurvePos* actionJoincurveSetSubcurve = dynamic_cast<OE_actionSetSubcurvePos*>(getLastAction());
	if (actionJoincurveSetSubcurve)
	{
		actionJoincurveSetSubcurve->setInvertDir(!actionJoincurveSetSubcurve->getInvertDir());
		return true;
	}
	return false;
bool OE_controller::editActionAddSubcurvePosEnd(float val)
{
raoul's avatar
raoul committed
	OE_actionJoincurveAddSubCurve* actionJoincurveAddSubcurve = dynamic_cast<OE_actionJoincurveAddSubCurve*>(getLastAction());
	if (actionJoincurveAddSubcurve)
	{
		actionJoincurveAddSubcurve->setEnd(val);
		return true;
	}
	return false;
bool OE_controller::editActionAddSubcurvePosSwitchDir()
raoul's avatar
raoul committed
	OE_actionJoincurveAddSubCurve* actionJoincurveAddSubcurve = dynamic_cast<OE_actionJoincurveAddSubCurve*>(getLastAction());
	if (actionJoincurveAddSubcurve)
	{
		actionJoincurveAddSubcurve->setDir(!actionJoincurveAddSubcurve->getDir());
		return true;
	}
	return false;
bool OE_controller::editActionSetLinestitchWidth(float val, bool offset)
	OE_actionSetLineStitchWidth* actionSetLineStitchWidth = dynamic_cast<OE_actionSetLineStitchWidth*>(getLastAction());
	if (actionSetLineStitchWidth)
raoul's avatar
raoul committed
		{
			actionSetLineStitchWidth->offsetWidth(val);
raoul's avatar
raoul committed
		}
raoul's avatar
raoul committed
		{
			actionSetLineStitchWidth->setWidth(val);
raoul's avatar
raoul committed
		}
raoul's avatar
raoul committed
bool OE_controller::refreshStitchs(float dpi, bool force)
		std::list<OE_stitchs*>::iterator stitch = document->stitchs.begin();
		
		while (stitch != document->stitchs.end())
raoul's avatar
raoul committed
		{
			(*stitch)->refresh(dpi, force);
raoul's avatar
raoul committed

raoul's avatar
raoul committed
bool OE_controller::setThreadColor(unsigned index, unsigned char r, unsigned char g, unsigned char b)
raoul's avatar
raoul committed
	OE_thread* tmpthread = getThread(index);
	if (!tmpthread)
	{
		return false;
	}
	
	tmpthread->setColor(r, g, b);

	return true;
}

bool OE_controller::setThreadWidth(unsigned index, float width)
{
raoul's avatar
raoul committed
	OE_thread* tmpthread = getThread(index);
	if (!tmpthread)
	{
		return false;
	}
raoul's avatar
raoul committed

bool OE_controller::setsubcurvePos(unsigned index, float start, float end)
raoul's avatar
raoul committed
	OE_subcurve* tmpcurve = getSubcurve(index);
	if (!tmpcurve)
	{
		return false;
	}
	
	tmpcurve->setStart(start);
	tmpcurve->setEnd(end);
	return true;
}
vector_2dt OE_controller::getClosestPoint(OE_curve* curve, vector_2d point)
{
raoul's avatar
raoul committed
	if (curve)
	{
		return curve->closestPoint(point);
	}
	return vector_2dt(vector_2d(0, 0), 0);
}

OE_curve* OE_controller::getClosestCurve(vector_2d point, vector_2dt &closestPoint)
{
raoul's avatar
raoul committed
	if (document)
	{
		std::list<OE_pointcurve*>::iterator curve = document->curves.begin();
		vector_2dt tmpPoint;
		//vector_2dt minPoint;
		double minDistance;
		double tmpDistance;
		OE_curve* minCurve;

		if (curve != document->curves.end())
		{
			closestPoint = (*curve)->closestPoint(point);
			minDistance = (closestPoint.v-point).len();
			minCurve = *curve;
			curve++;
		}
		while (curve != document->curves.end())
		{
			tmpPoint = (*curve)->closestPoint(point);
			tmpDistance = (tmpPoint.v-point).len();
			if (tmpDistance < minDistance)
			{
				closestPoint = tmpPoint;
				minDistance = tmpDistance;
				minCurve = *curve;
			}
			curve++;
		}
		return minCurve;
	}
	return nullptr;
bool OE_controller::generateInstructions()
{
raoul's avatar
raoul committed
	if (!document)
	{
		return false;
	}
raoul's avatar
raoul committed
	for (unsigned i = 0; i < document->instCommand.size(); i++)
	{
		delete document->instCommand.at(i);
	}
	document->instCommand.clear();

	std::list<OE_stitchs*>::iterator stitch = document->stitchs.begin();

raoul's avatar
raoul committed
	OE_thread* instThread = document->threads.front();
	if (stitch != document->stitchs.end() && (*stitch)->getThread())
	{
		instThread = (*stitch)->getThread();
	}

	document->instCommand.push_back(new OE_start(document->instPoints.size(), instThread->getColor()));

	while (stitch != document->stitchs.end())
		//(*stitch)->refresh(0, true);
raoul's avatar
raoul committed
		if ((*stitch)->check()&&(*stitch)->getNpts()>0)
raoul's avatar
raoul committed
			OE_thread* curThread = (*stitch)->getThread();
				curThread = document->threads.front();
			}
raoul's avatar
raoul committed
			if (curThread!=instThread)
			{
				instThread = curThread;
				document->instCommand.push_back(new OE_waitcolor(document->instPoints.size(), instThread->getColor()));
			std::vector<vector_2d> points = (*stitch)->getPoints();

raoul's avatar
raoul committed
			document->instPoints.insert(document->instPoints.end(), points.begin(), points.end());

	vector_2d zero = document->getZeroPoint();
	float size = document->getPulseByMm();
raoul's avatar
raoul committed
	for (unsigned i = 0; i < document->instPoints.size(); i++)
	{
		document->instPoints.at(i) = (document->instPoints.at(i) - zero)*size;
3dsman's avatar
3dsman committed
uint8_t int7(int i) // transform int32 to int7
{
	if (i>=0)
raoul's avatar
raoul committed
	{
3dsman's avatar
3dsman committed
		return i;
raoul's avatar
raoul committed
	}
3dsman's avatar
3dsman committed
	int8_t i8 = 2*i;
	return (*(uint8_t*)&i8)>>1;
}

void OE_controller::sendInstPoint()
{
raoul's avatar
raoul committed
#define TEST_COMM_ACK(errmsg) \
	if (!comm.ack()) \
	{\
		std::cerr << errmsg << std::endl;\
	}
	static bool running = false;
	static int oldX, oldY;
	static unsigned sndPoint;
	static uint8_t dxys[32];
	static bool started = false;
	if (!running)
	{
3dsman's avatar
3dsman committed
		std::cout << "sendInstPoint x " << document->instPoints.size() <<std::endl;
		comm.stopMove();
raoul's avatar
raoul committed
		TEST_COMM_ACK("Can't set pos");
3dsman's avatar
3dsman committed
		comm.setPos(0, 0);
raoul's avatar
raoul committed
		TEST_COMM_ACK("Can't set pos");
3dsman's avatar
3dsman committed
		comm.setNPoint(0);
raoul's avatar
raoul committed
		TEST_COMM_ACK("Can't set point");
3dsman's avatar
3dsman committed
		comm.deletePoints();
raoul's avatar
raoul committed
		TEST_COMM_ACK("Can't delete points");
3dsman's avatar
3dsman committed
		oldX = oldY = 0;
		sndPoint = 0;
		running = true;
	} else {
		document->curPoint = comm.info.nPoint;
		int x, y, dx, dy, bigdx, bigdy;
		unsigned cmdPoints = 0;
raoul's avatar
raoul committed
		if (!started && comm.info.spaceSize && comm.info.freeSpace<512)
		{
			comm.startMove();
raoul's avatar
raoul committed
			TEST_COMM_ACK("Can't start");
raoul's avatar
raoul committed
		if (sndPoint<document->instPoints.size() && comm.info.spaceSize && comm.info.freeSpace>64)
3dsman's avatar
3dsman committed
		{
			while (sndPoint<document->instPoints.size())
3dsman's avatar
3dsman committed
			{
				x = roundf(document->instPoints.at(sndPoint).x);
				y = roundf(-document->instPoints.at(sndPoint).y);
				dx = x-oldX;
				dy = y-oldY;
				if ((dx<-64)||(63<dx)||(dy<-64)||(63<dy))
3dsman's avatar
3dsman committed
				{
					bigdx = (dx+(dx>=0?0:1))/64;
					bigdy = (dy+(dy>=0?0:1))/64;
					dx -= 64*bigdx;
					dy -= 64*bigdy;
					if (cmdPoints==15)
					{
						comm.addPoints(dxys, 15);
raoul's avatar
raoul committed
						TEST_COMM_ACK("Can't add points");
						return;
					}
					dxys[2*cmdPoints] = 0x80|int7(bigdx);
					dxys[2*cmdPoints+1] = int7(bigdy);
					cmdPoints++;
3dsman's avatar
3dsman committed
				}
				dxys[2*cmdPoints] = int7(dx);
				dxys[2*cmdPoints+1] = int7(dy);
3dsman's avatar
3dsman committed
				cmdPoints++;
				sndPoint++;
				oldX = x;
				oldY = y;
				if (cmdPoints==16)
				{
					comm.addPoints(dxys, 16);
raoul's avatar
raoul committed
					TEST_COMM_ACK("Can't add points");
3dsman's avatar
3dsman committed
			}
3dsman's avatar
3dsman committed
			{
				comm.addPoints(dxys, cmdPoints);
raoul's avatar
raoul committed
				TEST_COMM_ACK("Can't add points");
3dsman's avatar
3dsman committed
			}
		}
raoul's avatar
raoul committed
#undef TEST_COMM_ACK