From fc3c77868f41e8339b71ca211effec44c37084ae Mon Sep 17 00:00:00 2001 From: ac-stef Date: Fri, 16 Sep 2016 12:09:48 +0200 Subject: [PATCH] add hardcoded stairs command for coop stairs xs ys Places stairs in all selections. xs and ys determine the step width in x- and y-direction. DOCREF stairs --- config/menus_edit.cfg | 2 +- source/src/clients2c.cpp | 1 + source/src/editing.cpp | 19 +++++++++++++++++++ source/src/protocol.h | 2 +- source/src/protos.h | 1 + 5 files changed, 23 insertions(+), 2 deletions(-) diff --git a/config/menus_edit.cfg b/config/menus_edit.cfg index 10eec191..3cd3f4b4 100644 --- a/config/menus_edit.cfg +++ b/config/menus_edit.cfg @@ -110,7 +110,7 @@ menuitem "Undo last placed arch or slope" [ __undoarch ; -1 ] menuitem "" -1 menuitemslider "Stairs axis: " 0 1 "$__stairaxis" 1 ["West to East (X)" "North to South (Y)"] [ __stairaxis = $arg1 ] menuitemslider "Step width: " 0 5 "$__stairwidth" 1 ["downwards 3" "downwards 2" "downwards 1" "upwards 1" "upwards 2" "upwards 3"] [ __stairwidth = $arg1 ] -menuitem "\t[ Place stairs ]" [ selectionwalk [ += sw_floor (div (if $__stairaxis $sw_rel_y $sw_rel_x) (at "-3 -2 -1 1 2 3" $__stairwidth)) ] ] +menuitem "\t[ Place stairs ]" [ push i (at "-3 -2 -1 1 2 3" $__stairwidth) ; stairs (if $__stairaxis 0 $i) (if $__stairaxis $i 0) ; pop i ; 0] newmenu skymaps menuinit [ diff --git a/source/src/clients2c.cpp b/source/src/clients2c.cpp index 0e23d260..860521ab 100644 --- a/source/src/clients2c.cpp +++ b/source/src/clients2c.cpp @@ -932,6 +932,7 @@ void parsemessages(int cn, playerent *d, ucharbuf &p, bool demo = false) case EDITXY_EQUALISE: editequalisexy(a1 != 0, b); break; case EDITXY_TAG: edittagxy(a1, a2, b); break; case EDITXY_SLOPE: slopexy(a1, a2, b); break; + case EDITXY_STAIRS: stairsxy(a1, a2, b); break; case EDITXY_FLIPROT: selfliprotate(b, a1); break; } } diff --git a/source/src/editing.cpp b/source/src/editing.cpp index dde5acb8..0f4ec3e0 100644 --- a/source/src/editing.cpp +++ b/source/src/editing.cpp @@ -956,6 +956,25 @@ void slope(int *xd, int *yd) } COMMAND(slope, "ii"); +void stairsxy(int xd, int yd, block &sel) +{ + int off = xd || yd ? 1 : 0, xo = xd < 0 ? 1 - sel.xs : 0, yo = yd < 0 ? 1 - sel.ys : 0; + loopselxy(sel, s->floor += (xd ? (x + xo) / xd : 0) + (yd ? (y + yo) / yd : 0) + off); + remipmore(sel); +} + +void stairs(int *xd, int *yd) +{ + EDITSEL; + loopv(sels) + { + block &sel = sels[i]; + addmsg(SV_EDITXY, "ri7", EDITXY_STAIRS, sel.x, sel.y, sel.xs, sel.ys, *xd, *yd); + stairsxy(*xd, *yd, sel); + } +} +COMMAND(stairs, "ii"); + void perlin(int *scale, int *seed, int *psize) { EDITSELMP; diff --git a/source/src/protocol.h b/source/src/protocol.h index 5e2b139c..14fa90e4 100644 --- a/source/src/protocol.h +++ b/source/src/protocol.h @@ -66,7 +66,7 @@ enum { FTR_INFO = 0, FTR_PLAYERWISH, FTR_AUTOTEAM, FTR_SILENTFORCE, FTR_NUM }; / enum { SP_OK = 0, SP_REFILLMATCH, SP_OK_NUM, SP_WRONGMAP, SP_SPECT, SP_NUM }; // spawn permission (