Skip to content

Commit ee753f2

Browse files
Syntax2022GregHib
andauthored
Client Zoom & Render Distance (#11)
* - Add Constant.java — centralized zoom/FOV tuning constants. - Change Class320.java to use Constant.ZOOM_OFFSET_DEFAULT. - Change Class348_Sub42_Sub3.java — linear FOV offset zoom, clamping, and offset re-sync. - Change client.java — mouse‑wheel zoom handling (direction + step, range). * Rename changes and move constants into Loader * Change zoom only when over the toplevel interface * Add support for increased render distance and culling * Fix scroll zoom when ctrl shift teleporting --------- Co-authored-by: GregHib <greghib@users.noreply.github.com>
1 parent 228561a commit ee753f2

8 files changed

Lines changed: 60 additions & 15 deletions

File tree

‎client/src/Canvas_Sub1.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ static final void method123(int i) {
216216
if (Class316.aClass348_Sub51_3959.aClass239_Sub16_7247.method1789(-32350) != 1) i_27_ = Class9.anIntArray168[Class348_Sub15.anInt6769];
217217
else i_27_ = (Class286_Sub8.anIntArray6296[Class348_Sub15.anInt6769]);
218218
if (Class348_Sub8.aHa6654.method3670()) i_27_++;
219+
i_27_ = (int) (Loader.RENDER_DISTANCE_MULTIPLIER * i_27_);
219220
Class348_Sub42_Sub2.method3171(Class348_Sub8.aHa6654, Class239_Sub16.anInt6012, 9, 4, Class367_Sub4.anInt7319, Class348_Sub40_Sub3.anInt9109, i_27_, bool_25_, Class348_Sub8.aHa6654.method3704() > 0);
220221
Class348_Sub32.method3018(Class318_Sub1_Sub4_Sub2.anInt10096);
221222
if (Class318_Sub1_Sub4_Sub2.anInt10096 != 0) Class348_Sub48.method3328(Class240.aClass324_4684);

‎client/src/Class290.java‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ static final void method2196(byte i) {
3232
if (Class348_Sub8.aHa6654.method3670()) Class239_Sub19.anInt6043 += 512;
3333
Class226.method1626(1, false);
3434
}
35+
Class239_Sub19.anInt6043 = (int) (Class239_Sub19.anInt6043 * Loader.CULLING_DISTANCE_MULTIPLIER);
3536
}
3637

3738
final boolean method2197(byte i) {

‎client/src/Class320.java‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
final class Class320 {
66
static short aShort3992 = 320;
77
static int anInt3993;
8+
static int zoomStep = Loader.ZOOM_OFFSET_DEFAULT;
9+
static boolean overGameScreen = false;
10+
static int scrollWheelDiff = 0;
811
static float aFloat3994;
912

1013
static final boolean method2547(int i, byte i_0_) {

‎client/src/Class348_Sub24.java‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,14 @@ static final void method2991(int i) {
322322
Class5_Sub2.method198(null, false, -1, -1);
323323
Class175.method1343(-1, null, 1, -1);
324324
if (!r.aBoolean9722) Class362.anInt4458 = -1;
325+
Class320.overGameScreen = false;
325326
Class216.method1583((byte) -73);
326327
Class311.anInt3918++;
328+
if (Class320.overGameScreen && Class320.scrollWheelDiff != 0) {
329+
if (Class192.anInt2581 <= 0 || !Class182.aClass346_2449.method2696(82, -125) || !Class182.aClass346_2449.method2696(81, -126)) {
330+
Class320.zoomStep += -Class320.scrollWheelDiff * Loader.ZOOM_OFFSET_STEP;
331+
}
332+
}
327333
if (Class237.aBoolean3103) {
328334
Class98.anInt1568++;
329335
Class348_Sub47 class348_sub47 = Class286_Sub3.method2148((ha_Sub2.aClass351_7715), (Class348_Sub23_Sub2.aClass77_9029), i + -11525);

‎client/src/Class348_Sub42_Sub3.java‎

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,30 @@ static final void method3174(int i, int i_0_, int i_1_, boolean bool, byte i_2_,
2323
int i_4_ = i_3_ - 334;
2424
if (i_4_ < 0) i_4_ = 0;
2525
else if (i_4_ > 100) i_4_ = 100;
26-
int i_5_ = ((-Class110.aShort1700 + Class168.aShort2250) * i_4_ / 100 + Class110.aShort1700);
27-
if (i_5_ < Class348_Sub42_Sub8.aShort9555) i_5_ = Class348_Sub42_Sub8.aShort9555;
28-
else if (Class48.aShort851 < i_5_) i_5_ = Class48.aShort851;
29-
int i_6_ = 512 * i_5_ * i_3_ / (i_1_ * 334);
26+
int adjustedZoom = ((-Class110.aShort1700 + Class168.aShort2250) * i_4_ / 100 + Class110.aShort1700);
27+
int base = adjustedZoom;
28+
if (Class320.zoomStep != 0) adjustedZoom += Class320.zoomStep;
29+
int min = Class110.aShort1700 * Loader.FOV_MIN_FACTOR_NUM / Loader.FOV_MIN_FACTOR_DEN;
30+
int max = Class168.aShort2250 * Loader.FOV_MAX_FACTOR_NUM / Loader.FOV_MAX_FACTOR_DEN;
31+
if (min < Loader.FOV_MIN_ABS) min = Loader.FOV_MIN_ABS;
32+
if (min > max) {
33+
int tmp = min;
34+
min = max;
35+
max = tmp;
36+
}
37+
if (adjustedZoom < min) adjustedZoom = min;
38+
else if (adjustedZoom > max) adjustedZoom = max;
39+
if (Class320.zoomStep != 0) Class320.zoomStep = adjustedZoom - base;
40+
if (adjustedZoom < Class348_Sub42_Sub8.aShort9555) adjustedZoom = Class348_Sub42_Sub8.aShort9555;
41+
else if (Class48.aShort851 < adjustedZoom) adjustedZoom = Class48.aShort851;
42+
int i_6_ = 512 * adjustedZoom * i_3_ / (i_1_ * 334);
3043
if (i_6_ >= Class367_Sub8.aShort7355) {
3144
if (i_6_ > Class171.aShort2269) {
3245
i_6_ = Class171.aShort2269;
33-
i_5_ = i_1_ * i_6_ * 334 / (i_3_ * 512);
34-
if (i_5_ < Class348_Sub42_Sub8.aShort9555) {
35-
i_5_ = Class348_Sub42_Sub8.aShort9555;
36-
int i_7_ = i_6_ * (i_1_ * 334) / (i_5_ * 512);
46+
adjustedZoom = i_1_ * i_6_ * 334 / (i_3_ * 512);
47+
if (adjustedZoom < Class348_Sub42_Sub8.aShort9555) {
48+
adjustedZoom = Class348_Sub42_Sub8.aShort9555;
49+
int i_7_ = i_6_ * (i_1_ * 334) / (adjustedZoom * 512);
3750
int i_8_ = (-i_7_ + i_3_) / 2;
3851
if (bool) {
3952
Class348_Sub8.aHa6654.la();
@@ -46,10 +59,10 @@ static final void method3174(int i, int i_0_, int i_1_, boolean bool, byte i_2_,
4659
}
4760
} else {
4861
i_6_ = Class367_Sub8.aShort7355;
49-
i_5_ = i_6_ * (i_1_ * 334) / (i_3_ * 512);
50-
if (Class48.aShort851 < i_5_) {
51-
i_5_ = Class48.aShort851;
52-
int i_9_ = i_5_ * i_3_ * 512 / (334 * i_6_);
62+
adjustedZoom = i_6_ * (i_1_ * 334) / (i_3_ * 512);
63+
if (Class48.aShort851 < adjustedZoom) {
64+
adjustedZoom = Class48.aShort851;
65+
int i_9_ = adjustedZoom * i_3_ * 512 / (334 * i_6_);
5366
int i_10_ = (i_1_ + -i_9_) / 2;
5467
if (bool) {
5568
Class348_Sub8.aHa6654.la();
@@ -60,7 +73,7 @@ static final void method3174(int i, int i_0_, int i_1_, boolean bool, byte i_2_,
6073
i_1_ -= i_10_ * 2;
6174
}
6275
}
63-
Class97.anInt1550 = i_3_ * i_5_ / 334;
76+
Class97.anInt1550 = i_3_ * adjustedZoom / 334;
6477
Class234.anInt3047 = i_0_;
6578
Class280.anInt3643 = (short) i_3_;
6679
Class127.anInt4656 = (short) i_1_;

‎client/src/Class348_Sub45.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ static final void method3309(int i) {
2828
Class294.aClass338Array5060 = new Class338[1000];
2929
if (i > -113) aClass304_7103 = null;
3030
Class348_Sub42_Sub10.anInt9577 = 0;
31-
Class348_Sub42_Sub19.aClass338Array9700 = new Class338[500];
31+
Class348_Sub42_Sub19.aClass338Array9700 = new Class338[(int) (500 * Loader.RENDER_DISTANCE_MULTIPLIER)];
3232
Class348_Sub40_Sub23.aBoolean9307 = !(Class9.aHa171 instanceof oa);
3333
}
3434

‎client/src/Loader.java‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,18 @@ public class Loader extends Applet {
2222
public static int port = 43594;
2323
public static final BigInteger LOGIN_SERVER_RSA_MODULUS = new BigInteger("ea3680fdebf2621da7a33601ba39925ee203b3fc80775cd3727bf27fd8c0791c803e0bdb42b8b5257567177f8569024569da9147cef59009ed016af6007e57a556f1754f09ca84dd39a03287f7e41e8626fd78ab3b53262bd63f2e37403a549980bf3077bd402b82ef5fac269eb3c04d2a9b7712a67a018321ceba6c3bfb8f7f", 16);
2424
public static final BigInteger FILE_SERVER_RSA_MODULUS = new BigInteger("d6808be939bbfd2ec4e96b1581ce3e1144b526e7643a72e3c64fbb902724fbfcf14ab601da6d6f8dbb57d1c369d080d9fc392abeb7886e0076d07f2aea5810e540d2817fd1967e35b39cc95cf7c9170b5fb55f5bf95524b60e938f0d64614bc365b87d66963a8cc8664e32875366099ef297180d01c7c3842162865e11d92299", 16);
25+
// Camera zoom constants
26+
static final int ZOOM_OFFSET_DEFAULT = 0; // Linear zoom offset added to the computed FOV (0 = no offset).
27+
static final int ZOOM_OFFSET_STEP = 15; // Scroll step size for the linear zoom offset.
28+
29+
static final int FOV_MIN_FACTOR_NUM = 1; // FOV minimum as a fraction of the base min (numerator).
30+
static final int FOV_MIN_FACTOR_DEN = 4; // FOV minimum as a fraction of the base min (denominator).
31+
static final int FOV_MAX_FACTOR_NUM = 4; // FOV maximum as a fraction of the base max (numerator).
32+
static final int FOV_MAX_FACTOR_DEN = 1; // FOV maximum as a fraction of the base max (denominator).
33+
static final int FOV_MIN_ABS = 100; // Absolute minimum FOV clamp regardless of base settings.
34+
35+
static final double RENDER_DISTANCE_MULTIPLIER = 2.0; // Adjust how many tiles off in the distance are rendered
36+
static final double CULLING_DISTANCE_MULTIPLIER = 1.8; // Adjust distance before objects go into fog
2537

2638
public static void main(String[] args) {
2739
for (int i = 0; i < args.length; i++) {

‎client/src/client.java‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,9 @@ static final void method107(Class46[] class46s, int i, int i_32_, int i_33_, int
10961096
if (class46.anInt719 >= 0) Class362.anInt4458 = class46.anInt719;
10971097
else if (class46.aBoolean776) Class362.anInt4458 = -1;
10981098
}
1099+
if (class46.aBoolean737 && (i == 48889856 || i == 35913731)) {
1100+
Class320.overGameScreen = true;
1101+
}
10991102
if (!Class5_Sub1.aBoolean8335 && i_40_ >= i_45_ && i_41_ >= i_46_ && i_40_ < i_47_ && i_41_ < i_48_) Class239_Sub17.method1797(i_41_ - i_44_, i_40_ - i_43_, class46, (byte) -95);
11001103
boolean bool_53_ = false;
11011104
if (Class258_Sub4.aClass373_8552.method3595(-91) && bool) bool_53_ = true;
@@ -1143,6 +1146,7 @@ else if (i_55_ == 10) {
11431146
class348_sub36.anInt6995 = Class98.anInt1565;
11441147
class348_sub36.anObjectArray6987 = class46.anObjectArray803;
11451148
Class348_Sub1_Sub2.aClass262_8810.method1999(class348_sub36, -20180);
1149+
Class320.overGameScreen = false;
11461150
}
11471151
if (Class289.aClass46_3701 != null || Class5_Sub1.aBoolean8335 || ((class46.anInt765 != Class348_Sub45.anInt7102) && Class348_Sub42.anInt7059 > 0)) {
11481152
bool_54_ = false;
@@ -1756,6 +1760,7 @@ private final void method114(int i) {
17561760
}
17571761
}
17581762
Class98.anInt1565 = 0;
1763+
Class320.scrollWheelDiff = 0;
17591764
for (Class348_Sub45 class348_sub45 = Class258_Sub4.aClass373_8552.method3596(0); class348_sub45 != null; class348_sub45 = Class258_Sub4.aClass373_8552.method3596(0)) {
17601765
int i_111_ = class348_sub45.method3310(86);
17611766
if (i_111_ != -1) {
@@ -1764,7 +1769,11 @@ private final void method114(int i) {
17641769
Class318_Sub1_Sub3.aClass262_8744.method1999(class348_sub45, -20180);
17651770
if (Class318_Sub1_Sub3.aClass262_8744.method1998(0) > 10) Class318_Sub1_Sub3.aClass262_8744.method1997(8);
17661771
}
1767-
} else Class98.anInt1565 += class348_sub45.method3315(0);
1772+
} else {
1773+
int anInt1565 = class348_sub45.method3315(0);
1774+
Class320.scrollWheelDiff = anInt1565;
1775+
Class98.anInt1565 += anInt1565;
1776+
}
17681777
} else r_Sub1.aClass262_10479.method1999(class348_sub45, -20180);
17691778
}
17701779
if (Class348_Sub42_Sub16_Sub2.method3263(true)) Class38.method363(125);

0 commit comments

Comments
 (0)