From 8bb71ee8392420f6b74eab28ae3e0f0459d1e58a Mon Sep 17 00:00:00 2001 From: ac-stef Date: Sat, 15 Jul 2017 17:27:55 +0200 Subject: [PATCH] fix direction for moving entities by scrollwheel the same mousewheel direction now always moves an entity away from or towards the player entproperty if 100 is added to the attribute index parameter, the sign of the increment value is changed editaxis returns a value for the main axis of player orientation (X:11, Y:12, Z:13) and adds 100 if the player is looking in the negative direction of the axis DOCREF entproperty editaxis --- source/src/editing.cpp | 12 ++++++------ source/src/world.cpp | 5 +++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/source/src/editing.cpp b/source/src/editing.cpp index e135b794..aaa77004 100644 --- a/source/src/editing.cpp +++ b/source/src/editing.cpp @@ -185,9 +185,9 @@ COMMANDF(selxs, "", (void) { SEL_ATTR(xs); }); COMMANDF(selys, "", (void) { SEL_ATTR(ys); }); #undef SEL_ATTR -VAR(flrceil,0,0,2); -VAR(editaxis,0,0,13); -VARP(showgrid,0,1,1); +VAR(flrceil, 2, 0, 0); +VAR(editaxis, 113, 0, 0); +VARP(showgrid, 0, 1, 1); // VC8 optimizer screws up rendering somehow if this is an actual function #define sheight(s,t,z) (!flrceil ? (s->type==FHF ? s->floor-t->vdelta/4.0f : (float)s->floor) : (s->type==CHF ? s->ceil+t->vdelta/4.0f : (float)s->ceil)) @@ -212,9 +212,9 @@ inline void forceinsideborders(int &xy) void cursorupdate() // called every frame from hud { - flrceil = ((int)(camera1->pitch>=0))*2; - int cyaw = ((int) camera1->yaw) % 180; - editaxis = editmode ? (fabs(camera1->pitch) > 65 ? 13 : (cyaw < 45 || cyaw > 135 ? 12 : 11)) : 0; + ASSERT(editmode); + flrceil = camera1->pitch >= 0 ? 2 : 0; + editaxis = fabs(camera1->pitch) > 60 ? "\161\15\15"[flrceil] : "\160\13\14\157"[(int(camera1->yaw + 45) / 90) & 3]; volatile float x = worldpos.x; // volatile needed to prevent msvc7 optimizer bug? volatile float y = worldpos.y; diff --git a/source/src/world.cpp b/source/src/world.cpp index d0a00ec8..577c0ffd 100644 --- a/source/src/world.cpp +++ b/source/src/world.cpp @@ -198,12 +198,13 @@ COMMANDF(getclosestent, "", () { intret(closestent()); }); void entproperty(int *prop, float *famount, int *unscaled) { - int n = closestent(); + int n = closestent(), amount = *prop >= 100 ? -1 : 1; + *prop %= 100; if(n < 0) return; entity &e = ents[n]; int old_a1 = e.attr1; int t = e.type < MAXENTTYPES ? e.type : 0; - int amount = int(*famount * (*prop >= 0 && *prop < 7 && !*unscaled ? entscale[t][*prop] : 1)); + amount *= int(*famount * (*prop >= 0 && *prop < 7 && !*unscaled ? entscale[t][*prop] : 1)); switch(*prop) {