# HG changeset patch # User unc0rr # Date 1380486058 -14400 # Node ID 265e5997580e5271cb4836f74a1bbcc0652f364a # Parent 9ed07a96349d7fe0f9c75bac9123bd024f2a0632 Incomplete implementation of 'special points' in drawn maps (crashes engine) diff -r 9ed07a96349d -r 265e5997580e QTfrontend/drawmapscene.cpp --- a/QTfrontend/drawmapscene.cpp Fri Sep 27 21:52:21 2013 -0400 +++ b/QTfrontend/drawmapscene.cpp Mon Sep 30 00:20:58 2013 +0400 @@ -156,7 +156,7 @@ if(m_isCursorShown) return; - if(items().size()) + if(paths.size()) { removeItem(items().first()); paths.removeFirst(); @@ -183,10 +183,11 @@ if(!items().size()) return; + m_specialPoints.clear(); oldItems.clear(); // do this since clear() would _destroy_ all items - while(items().size()) + for(int i = paths.size() - 1; i >= 0; --i) { oldItems.push_front(items().first()); removeItem(items().first()); @@ -211,7 +212,7 @@ QByteArray DrawMapScene::encode() { - QByteArray b; + QByteArray b(m_specialPoints); for(int i = paths.size() - 1; i >= 0; --i) { @@ -247,9 +248,12 @@ oldPaths.clear(); clear(); paths.clear(); + m_specialPoints.clear(); PathParams params; + bool isSpecial = true; + while(data.size() >= 5) { qint16 px = qFromBigEndian(*(qint16 *)data.data()); @@ -258,9 +262,11 @@ data.remove(0, 2); quint8 flags = *(quint8 *)data.data(); data.remove(0, 1); - + qDebug() << px << py; if(flags & 0x80) { + isSpecial = false; + if(params.points.size()) { addPath(pointsToPath(params.points), m_pen); @@ -278,9 +284,23 @@ else m_pen.setBrush(m_brush); params.width = penWidth; - } + } else + if(isSpecial) + { + QPainterPath path; + path.addEllipse(QPointF(px, py), 10, 10); + + addPath(path); - params.points.append(QPoint(px, py)); + qint16 x = qToBigEndian(px); + qint16 y = qToBigEndian(py); + m_specialPoints.append((const char *)&x, 2); + m_specialPoints.append((const char *)&y, 2); + m_specialPoints.append((const char *)&flags, 1); + } + + if(!isSpecial) + params.points.append(QPoint(px, py)); } if(params.points.size()) diff -r 9ed07a96349d -r 265e5997580e QTfrontend/drawmapscene.h --- a/QTfrontend/drawmapscene.h Fri Sep 27 21:52:21 2013 -0400 +++ b/QTfrontend/drawmapscene.h Mon Sep 30 00:20:58 2013 +0400 @@ -66,6 +66,7 @@ QList oldItems; QGraphicsEllipseItem * m_cursor; bool m_isCursorShown; + QByteArray m_specialPoints; virtual void mouseMoveEvent(QGraphicsSceneMouseEvent * mouseEvent); virtual void mousePressEvent(QGraphicsSceneMouseEvent * mouseEvent); diff -r 9ed07a96349d -r 265e5997580e QTfrontend/ui/widget/drawmapwidget.cpp --- a/QTfrontend/ui/widget/drawmapwidget.cpp Fri Sep 27 21:52:21 2013 -0400 +++ b/QTfrontend/ui/widget/drawmapwidget.cpp Mon Sep 30 00:20:58 2013 +0400 @@ -160,6 +160,7 @@ } else m_scene->decode(qUncompress(QByteArray::fromBase64(f.readAll()))); + //m_scene->decode(f.readAll()); } } diff -r 9ed07a96349d -r 265e5997580e hedgewars/uLandPainted.pas --- a/hedgewars/uLandPainted.pas Fri Sep 27 21:52:21 2013 -0400 +++ b/hedgewars/uLandPainted.pas Mon Sep 30 00:20:58 2013 +0400 @@ -27,7 +27,7 @@ procedure freeModule; implementation -uses uLandGraphics, uConsts, uVariables, uUtils, SDLh, uCommands, uDebug; +uses uLandGraphics, uConsts, uVariables, uUtils, SDLh, uCommands, uDebug, uScript; type PointRec = packed record X, Y: SmallInt; @@ -88,7 +88,11 @@ radius:= 0; pe:= pointsListHead; - TryDo((pe = nil) or (pe^.point.flags and $80 <> 0), 'Corrupted draw data', true); + while (pe <> nil) and (pe^.point.flags and $80 = 0) do + begin + ScriptCall('onSpecialPoint', pe^.point.X, pe^.point.Y, pe^.point.flags); + pe:= pe^.next; + end; while(pe <> nil) do begin @@ -110,7 +114,7 @@ end; prevPoint:= pe^.point; - pe:= pe^.next; + pe:= pe^.next; end; end; diff -r 9ed07a96349d -r 265e5997580e share/hedgewars/Data/Scripts/Multiplayer/Racer.lua --- a/share/hedgewars/Data/Scripts/Multiplayer/Racer.lua Fri Sep 27 21:52:21 2013 -0400 +++ b/share/hedgewars/Data/Scripts/Multiplayer/Racer.lua Mon Sep 30 00:20:58 2013 +0400 @@ -524,6 +524,10 @@ end +function onSpecialPoint(x,y,flag) + PlaceWayPoint(x,y) +end + function onNewTurn() CheckForNewRound()